Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3974548pxj; Tue, 8 Jun 2021 03:30:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwurE/QJk90ubYCJO07Hc/oYtL7Dddz3wwJ1tVznq3mZuHLR1bTgvDLRkb8x82k7qsBeEN1 X-Received: by 2002:a17:906:e253:: with SMTP id gq19mr23176303ejb.138.1623148233445; Tue, 08 Jun 2021 03:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623148233; cv=none; d=google.com; s=arc-20160816; b=RumhP/Rn3Ct7AwDXBhnUPCJh0dB1nnUuSMJt+O+4EPD+1loNoDDi6aZ4WnStR0tgVW 4nfmXXxkPVarchNN49UJLVi5mKqjIMVPCzH0JMHHRTw1r1/ZLH2ROB/16fPiXtVirGaX TYFFb5EBy0Zc5YhwyRNu8/SBZFnscMJQpbQI76Er45HGWRPcGThvj6/06LECKsBy88po emI3z8KJ3ik8twKtWNyBiQ3cbRm13YejJ3Npk5lHRP7jvOCqyi2M49+vPo0QjFGbKaaZ /uc5N4RIn10iRG7x6/RkIw32EIf4bxJ/3tqkx7h7AMV1iEZWUFeKwAw2NuTnqVBiMo3R pnOA== 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=hknb/cT46pT/JN19SU+aIolVVJebcubP9dDwPA8YmZE=; b=CNXCBbXMXGOd24fg1Hun28xZNoch05BrQjEp4D9Ri/lx0+msqrmR3H6YpHxgmT4l2b 6QOgISAHtYLX/XPS29xtXw8OPSUjxod7kb0R6w5F98HUnMRRv7FCWxNU1V0QPmWMyck/ 6ZFQDjBCer69pFjpHaf2R9A9GQSqSFjZ5ZR8gFmgn2F0Ji4otl0ur8uJqlG+PDB+b/nU Cz+972ePXf+9D6AIo3hnjYMhSI98Pgz9ts+aU/WBzt4HJRZ2bYwQ2qZmjfl1cAjCblaB lNOacalbJTtGwhKIVEoF6q7KGL17/ASKgPGvZMTyA4PpLq+3IboqTkXdQQ7fyUixkj7i iTgQ== 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 h3si11491219edf.193.2021.06.08.03.30.10; Tue, 08 Jun 2021 03:30:33 -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 S231577AbhFHK2j (ORCPT + 99 others); Tue, 8 Jun 2021 06:28:39 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:22568 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231557AbhFHK2g (ORCPT ); Tue, 8 Jun 2021 06:28:36 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 158ACHT6009919; Tue, 8 Jun 2021 18:12:17 +0800 (GMT-8) (envelope-from steven_lee@aspeedtech.com) Received: from slee-VirtualBox.localdomain (192.168.100.253) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Jun 2021 18:26:07 +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 v5 10/10] gpio: gpio-aspeed-sgpio: Return error if ngpios is not multiple of 8. Date: Tue, 8 Jun 2021 18:25:45 +0800 Message-ID: <20210608102547.4880-11-steven_lee@aspeedtech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210608102547.4880-1-steven_lee@aspeedtech.com> References: <20210608102547.4880-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 158ACHT6009919 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 --- 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 f1e40486d401..1a3fcc721664 100644 --- a/drivers/gpio/gpio-aspeed-sgpio.c +++ b/drivers/gpio/gpio-aspeed-sgpio.c @@ -572,6 +572,10 @@ static int __init aspeed_sgpio_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Number of GPIOs exceeds the maximum of %d: %d\n", gpio->max_ngpios, nr_gpios); return -EINVAL; + } else if (nr_gpios % 8) { + dev_err(&pdev->dev, "Number of GPIOs not multiple of 8: %d\n", + nr_gpios); + return -EINVAL; } gpio->n_sgpio = nr_gpios; -- 2.17.1