From patchwork Fri Jan 24 09:32:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 232859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A07CC35242 for ; Fri, 24 Jan 2020 11:37:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10693214DB for ; Fri, 24 Jan 2020 11:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865855; bh=qBbBftGjyQ8ngYqtOARXAu/XpohrVD5JsN0yW8v9P8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=J8rv5Eiqk9bnQ0j2OEGg6NNlx7+d7JThaQgKGXp6bgMtJIet9oZ+1Lftr+g2UFWn4 kFcUIBs3cSbxIiN/lpRXLNJUGGDXl1kM4YNruY2dgQGfVIMnlFGYnh7Bjn6lucSKu+ RvDcBSy3wp2zmZVLZf51PZDCz4SXWQhATsgb/Cy0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404450AbgAXLce (ORCPT ); Fri, 24 Jan 2020 06:32:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:51544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404448AbgAXLcd (ORCPT ); Fri, 24 Jan 2020 06:32:33 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 79529222C2; Fri, 24 Jan 2020 11:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865553; bh=qBbBftGjyQ8ngYqtOARXAu/XpohrVD5JsN0yW8v9P8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nZUCCjmPQFEzsXuom/iGNEmKno40zTtfCjmjjp/eEY1YZXamjHhsOrHipejcs4A7d FcQGuS5YRyGXAjUtHtB7PjgFIRG870eEnClYtWjZkxWekBE6v8TgHK5CNStkizmZzU fgS5egqkydVCX0na4+FWaa6mmRHaTK35Gjz/SQnA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rashmica Gupta , Andrew Jeffery , Joel Stanley , Linus Walleij , Sasha Levin Subject: [PATCH 4.19 561/639] gpio/aspeed: Fix incorrect number of banks Date: Fri, 24 Jan 2020 10:32:11 +0100 Message-Id: <20200124093159.612855976@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Rashmica Gupta [ Upstream commit 3c4710ae6f883f9c6e3df5e27e274702a1221c57 ] The current calculation for the number of GPIO banks is only correct if the number of GPIOs is a multiple of 32 (if there were 31 GPIOs we would currently say there are 0 banks, which is incorrect). Fixes: 361b79119a4b7 ('gpio: Add Aspeed driver') Signed-off-by: Rashmica Gupta Reviewed-by: Andrew Jeffery Link: https://lore.kernel.org/r/20190906062623.13354-1-rashmica.g@gmail.com Reviewed-by: Joel Stanley Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpio-aspeed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c index b696ec35efb38..e627e0e9001ae 100644 --- a/drivers/gpio/gpio-aspeed.c +++ b/drivers/gpio/gpio-aspeed.c @@ -1199,7 +1199,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) gpio->chip.irq.need_valid_mask = true; /* Allocate a cache of the output registers */ - banks = gpio->config->nr_gpios >> 5; + banks = DIV_ROUND_UP(gpio->config->nr_gpios, 32); gpio->dcache = devm_kcalloc(&pdev->dev, banks, sizeof(u32), GFP_KERNEL); if (!gpio->dcache)