Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2894426pxv; Mon, 12 Jul 2021 04:39:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFwjpp46WO5iOBsNnxy5f2E50KYR11z8Y1DhIM37QLeSYSRcYAsS20wqxhkGEOTVuNE05N X-Received: by 2002:a92:3f08:: with SMTP id m8mr36464952ila.104.1626089959032; Mon, 12 Jul 2021 04:39:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626089959; cv=none; d=google.com; s=arc-20160816; b=fxWxpF9jeSSaj2g9LRk3OQp7Kiew0o1LgqxFQFfzTI3ninCnF5oT/Ybrjkufel7VOK lU1o4wnySpETs80MwusLWwFBIToElr765o5W05u/BD08xSxdkqpIe601E3ORPQJfXGjw DW72/3GZ0cmNnJuueOVuGfJJYuu8dTBM4fkA5TmARyA4Ug8tx3JOAvMo19KV270+z4Gd Xz4QC9x1JBPPczdcFelqH9EIw6u6H4zOa3MEw3KrTNzK+pVOGpbhVzCyC0Uc/Xl2TUtM drih3YqIuPe6iAroIteoKh9UKnphLPqTI+mUdOX3m1jRoZsaSXSpnmz5JOe+MQcrApRW GXzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=KAUFxUamemXwxX7e1Qjm79Mz2wRhBoiqHexsn71lnrE=; b=aF6A7dZ7RR71L9haZaD4L+jE02n9Ux1tp6aLYpJEQWhpdCQduvc7d84JkV1qxwIfjL IO91bfYv01I8QhyXyZIb05AuvDqHJfnDUksalxHxzls+hu9GYPQhVQM/ryTyPUEggE+i syVcXnlnN27cX1ZnTO/8icw/1CzaTPzDrU2QpJ+KfdBRjaQLkN+2x+b6q7p+MQJUmx69 fhvJOOvbDB7OGTqvmmjEmrBOW17enuU3FzNT47YU/zSvI1YhA3v7UlPkOy5gC+Xj/77p YEytj90x8kfdPUeeEs4keOlny3ExJP8Dtx10F0sX7AWaR7Ess2AyVw2hnE3UOOEVj5T1 3lBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si18905759jat.81.2021.07.12.04.39.07; Mon, 12 Jul 2021 04:39:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234393AbhGLKHN (ORCPT + 99 others); Mon, 12 Jul 2021 06:07:13 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:18789 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235657AbhGLKG6 (ORCPT ); Mon, 12 Jul 2021 06:06:58 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 16C9lfEp099610; Mon, 12 Jul 2021 17:47:41 +0800 (GMT-8) (envelope-from steven_lee@aspeedtech.com) Received: from localhost.localdomain (192.168.100.253) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Jul 2021 18:03:35 +0800 From: Steven Lee To: Linus Walleij , Bartosz Golaszewski , Rob Herring , Joel Stanley , Andrew Jeffery , "open list:GPIO SUBSYSTEM" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/ASPEED MACHINE SUPPORT" , "moderated list:ARM/ASPEED MACHINE SUPPORT" , open list CC: , , , Subject: [PATCH v6 9/9] gpio: gpio-aspeed-sgpio: Return error if ngpios is not multiple of 8. Date: Mon, 12 Jul 2021 18:03:16 +0800 Message-ID: <20210712100317.23298-10-steven_lee@aspeedtech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210712100317.23298-1-steven_lee@aspeedtech.com> References: <20210712100317.23298-1-steven_lee@aspeedtech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.100.253] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 16C9lfEp099610 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add an else-if condition in the probe function to check whether ngpios is multiple of 8. Per AST datasheet, numbers of available serial GPIO pins in Serial GPIO Configuration Register must be n bytes. For instance, if n = 1, it means AST SoC supports 8 GPIO pins. Signed-off-by: Steven Lee Reviewed-by: Andrew Jeffery --- drivers/gpio/gpio-aspeed-sgpio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpio/gpio-aspeed-sgpio.c b/drivers/gpio/gpio-aspeed-sgpio.c index b3d05fc724f0..191b82a2560c 100644 --- a/drivers/gpio/gpio-aspeed-sgpio.c +++ b/drivers/gpio/gpio-aspeed-sgpio.c @@ -537,6 +537,10 @@ static int __init aspeed_sgpio_probe(struct platform_device *pdev) if (rc < 0) { dev_err(&pdev->dev, "Could not read ngpios property\n"); return -EINVAL; + } else if (nr_gpios % 8) { + dev_err(&pdev->dev, "Number of GPIOs not multiple of 8: %d\n", + nr_gpios); + return -EINVAL; } rc = device_property_read_u32(&pdev->dev, "bus-frequency", &sgpio_freq); -- 2.17.1