From mboxrd@z Thu Jan 1 00:00:00 1970 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 7BDDEC4332D for ; Thu, 14 Jan 2021 01:50:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 473C52310A for ; Thu, 14 Jan 2021 01:50:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727203AbhANBtt (ORCPT ); Wed, 13 Jan 2021 20:49:49 -0500 Received: from atlmailgw1.ami.com ([63.147.10.40]:61942 "EHLO atlmailgw1.ami.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729878AbhANA3Y (ORCPT ); Wed, 13 Jan 2021 19:29:24 -0500 X-AuditID: ac1060b2-a7dff700000017ec-b8-5fff765d82bc Received: from atlms1.us.megatrends.com (atlms1.us.megatrends.com [172.16.96.144]) (using TLS with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client did not present a certificate) by atlmailgw1.ami.com (Symantec Messaging Gateway) with SMTP id 05.B8.06124.D567FFF5; Wed, 13 Jan 2021 17:38:21 -0500 (EST) Received: from ami-us-wk.us.megatrends.com (172.16.98.207) by atlms1.us.megatrends.com (172.16.96.144) with Microsoft SMTP Server (TLS) id 14.3.468.0; Wed, 13 Jan 2021 17:38:20 -0500 From: Hongwei Zhang To: Linus Walleij , Bartosz Golaszewski , Joel Stanley , Andrew Jeffery , , , , , CC: Hongwei Zhang Subject: [PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading Date: Wed, 13 Jan 2021 17:38:08 -0500 Message-ID: <20210113223808.31626-2-hongweiz@ami.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210113223808.31626-1-hongweiz@ami.com> References: <20210113223808.31626-1-hongweiz@ami.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.16.98.207] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsWyRiBhgm5s2f94g8dvdS12Xeaw+DL3FIvF 7/N/mS2m/FnOZLHp8TVWi+bV55gtNs//w2hxedccNotTLS9YHDg9rrbvYvd4f6OV3ePix2PM Hneu7WHz2Lyk3uP8jIWMHp83yQWwR3HZpKTmZJalFunbJXBlnHs2lbmgi6tizwP9BsatHF2M HBwSAiYShzYldTFycQgJ7GKSeH+xnQnKYZQ4uOMBYxcjJwebgJrE3s1zwBIiAieZJGbt/sUE kmAWUJH4sfoaK4gtLOAisfrXezaQqSwCqhIn1uaDhHkFTCUapu9iAbElBOQlVm84wAxicwqY SbxquAY2XwioZkP7LHaIekGJkzOfsECMl5A4+OIFM0SNrMStQ4+ZIOYoSjz49Z11AqPALCQt s5C0LGBkWsUolFiSk5uYmZNebqiXmJupl5yfu4kREuibdjC2XDQ/xMjEwXiIUYKDWUmEt6j7 b7wQb0piZVVqUX58UWlOavEhRmkOFiVx3lXuR+OFBNITS1KzU1MLUotgskwcnFINjA4Cfs/+ h7F+/rd2tcJJtvVL9m3atPe+yN2rpdnXlraL57qlHaniva/hrXr8cd0KK5ltDd1X7pWtaayx jnz8kdNx27K/mdHJKdw7HjnUvN+151Pc3EChrgKWuYuXN9YxbZFrzDF/113F/n8HX1FJ0q1t x/S2Shyx+C0oeun8zYXXHyW9LVT690OJpTgj0VCLuag4EQBg8FzCYgIAAA== Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Add gpio base address reading in the driver; in old code, it just returns -1 to gpio->chip.base. Fixes: 7ee2d5b4d4340353 ("ARM: dts: nuvoton: Add Fii Kudo system") Signed-off-by: Hongwei Zhang --- drivers/gpio/gpio-aspeed.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c index d07bf2c3f136..4ebe4c40154c 100644 --- a/drivers/gpio/gpio-aspeed.c +++ b/drivers/gpio/gpio-aspeed.c @@ -1140,7 +1140,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) const struct of_device_id *gpio_id; struct aspeed_gpio *gpio; int rc, i, banks, err; - u32 ngpio; + u32 ngpio, base; gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); if (!gpio) @@ -1179,7 +1179,10 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) gpio->chip.set = aspeed_gpio_set; gpio->chip.set_config = aspeed_gpio_set_config; gpio->chip.label = dev_name(&pdev->dev); - gpio->chip.base = -1; + err = of_property_read_u32(pdev->dev.of_node, "base", &base); + gpio->chip.base = (u16) base; + if (err) + gpio->chip.base = -1; /* Allocate a cache of the output registers */ banks = DIV_ROUND_UP(gpio->chip.ngpio, 32); -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 A1226C433E0 for ; Fri, 5 Feb 2021 22:02:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56F4464F95 for ; Fri, 5 Feb 2021 22:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232862AbhBEWB5 (ORCPT ); Fri, 5 Feb 2021 17:01:57 -0500 Received: from atlmailgw2.ami.com ([63.147.10.42]:47870 "EHLO atlmailgw2.ami.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbhBEO5b (ORCPT ); Fri, 5 Feb 2021 09:57:31 -0500 X-AuditID: ac10606f-247ff70000001934-f3-601d73c116e9 Received: from atlms1.us.megatrends.com (atlms1.us.megatrends.com [172.16.96.144]) (using TLS with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client did not present a certificate) by atlmailgw2.ami.com (Symantec Messaging Gateway) with SMTP id E5.4A.06452.1C37D106; Fri, 5 Feb 2021 11:35:13 -0500 (EST) Received: from ami-us-wk.us.megatrends.com (172.16.98.207) by atlms1.us.megatrends.com (172.16.96.144) with Microsoft SMTP Server (TLS) id 14.3.468.0; Fri, 5 Feb 2021 11:35:11 -0500 From: Hongwei Zhang To: Linus Walleij CC: Hongwei Zhang , Bartosz Golaszewski , Joel Stanley , Andrew Jeffery , , , , , Subject: [PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading Date: Fri, 5 Feb 2021 11:34:50 -0500 Message-ID: <20210113223808.31626-2-hongweiz@ami.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210113223808.31626-1-hongweiz@ami.com> References: <20210113223808.31626-1-hongweiz@ami.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.16.98.207] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsWyRiBhgu7BYtkEg6un9C12Xeaw+DL3FIvF 7/N/mS2m/FnOZLHp8TVWi+bV55gtNs//w2hxedccNotTLS9YHDg9rrbvYvd4f6OV3ePix2PM Hneu7WHz2Lyk3uP8jIWMHp83yQWwR3HZpKTmZJalFunbJXBlLPpqXPCNreLYvevMDYx7WLsY OTkkBEwk9mxfxNbFyMUhJLCLSeLt69usEM5ORomVOy8xg1SxCahJ7N08hwnEFhHQkeje9hOs iFngIJPE9Gl72EESwgIuEqt/vWcDsVkEVCRWf38A1sArYCrRMH0XC8Q6eYnVGw6ADeUUMJfY 1vQcrF5IwEyi9dMjqHpBiZMzn4DVMwtISBx88YIZokZW4tahx0wQcxQlHvz6zjqBUWAWkpZZ SFoWMDKtYhRKLMnJTczMSS830kvMzdRLzs/dxAgJ9vwdjB8/mh9iZOJgPMQowcGsJMKb2CaV IMSbklhZlVqUH19UmpNafIhRmoNFSZx3lfvReCGB9MSS1OzU1ILUIpgsEwenVAPjofrHXB6Z H4tUdX8Grk/3MvG9aJU3KeSb3n4e5R6pjXNzbM91mqbcLHxX8J11H2PUzn0dG1YVusYevNR3 9faXyMuvpqzl+3G9lGlFDe+mstcJbtuadrntzizZlPqy0zsv91zZpS8RSp720ldEKyJlnCyy T/y68/Dm37Zrtr0fVTiX+BV+O/RfiaU4I9FQi7moOBEAYb4BgWQCAAA= Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Message-ID: <20210205163450.8P8KJYDEeKJZw-XKamYQRQwL6iwb51yzsVbBudFERP8@z> > On Wed, Jan 13, 2021 at 11:38 PM Hongwei Zhang wrote: > > > Add gpio base address reading in the driver; in old code, it just > > returns -1 to gpio->chip.base. > > > > Fixes: 7ee2d5b4d4340353 ("ARM: dts: nuvoton: Add Fii Kudo system") > > Signed-off-by: Hongwei Zhang > > NAK, sorry. > > We never allow the device tree to specify this. > > First, it is a Linux-only base so it would have to be a "linux,..." property. > > Even if it is a Linux-only property, it is a bad idea. > > Only people using sysfs should have any need to specify global GPIO numbers. Don't use sysfs. Use the > GPIO character device instead. See further: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpio/TODO > > Yours, > Linus Walleij Hi Linus, Thanks for your review and advice. --Hongwei From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=no 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 456C5C433E6 for ; Fri, 5 Feb 2021 22:03:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E91A764F92 for ; Fri, 5 Feb 2021 22:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbhBEWCA (ORCPT ); Fri, 5 Feb 2021 17:02:00 -0500 Received: from atlmailgw1.ami.com ([63.147.10.40]:59858 "EHLO atlmailgw1.ami.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232953AbhBEO5g (ORCPT ); Fri, 5 Feb 2021 09:57:36 -0500 X-AuditID: ac1060b2-427ff70000001a01-01-601d73ccbbc9 Received: from atlms1.us.megatrends.com (atlms1.us.megatrends.com [172.16.96.144]) (using TLS with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client did not present a certificate) by atlmailgw1.ami.com (Symantec Messaging Gateway) with SMTP id 09.CB.06657.CC37D106; Fri, 5 Feb 2021 11:35:24 -0500 (EST) Received: from ami-us-wk.us.megatrends.com (172.16.98.207) by atlms1.us.megatrends.com (172.16.96.144) with Microsoft SMTP Server (TLS) id 14.3.468.0; Fri, 5 Feb 2021 11:35:23 -0500 From: Hongwei Zhang To: Andrew Jeffery CC: Hongwei Zhang , Bartosz Golaszewski , Joel Stanley , Linus Walleij , , , , , Subject: [PATCH, v1 1/1] gpio: aspeed: Add gpio base address reading Date: Fri, 5 Feb 2021 11:34:51 -0500 Message-ID: <20210113223808.31626-2-hongweiz@ami.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210113223808.31626-1-hongweiz@ami.com> References: <20210113223808.31626-1-hongweiz@ami.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.16.98.207] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsWyRiBhgu6ZYtkEgx8v9C12Xeaw+DL3FIvF 7/N/mS2m/FnOZLHp8TVWi+bV55gtNs//w2hxedccNotTLS9YHDg9rrbvYvd4f6OV3ePix2PM Hneu7WHz2Lyk3uP8jIWMHp83yQWwR3HZpKTmZJalFunbJXBl/D/3i6mgg73iV/8JxgbGQ6xd jJwcEgImEnu6G5m7GLk4hAR2MUncb17KAuHsZJT4+KGbBaSKTUBNYu/mOUwgtoiAisTu3rfs IEXMAieZJJY/PQ82SljARWL1r/dsIDYLUFHn2u+MIDavgKlEw/RdLBDr5CVWbzjADGJzCphJ vGq4BlYjBFSzoX0WO0S9oMTJmU/A6pkFJCQOvnjBDFEjK3Hr0GMmiDmKEg9+fWedwCgwC0nL LCQtCxiZVjEKJZbk5CZm5qSXG+ol5mbqJefnbmKEhPumHYwtF80PMTJxMB5ilOBgVhLhTWyT ShDiTUmsrEotyo8vKs1JLT7EKM3BoiTOu8r9aLyQQHpiSWp2ampBahFMlomDU6qB8VLB9VLP DT4XNx6uF+SUuSN53Gw3q6GpRbjvn8P2gtu22Rp9NLG56FzteHrC1r3Vjr0PukwqHNQ/TWho +SjU3fS7Su/oxpLTotfZP6tt3zG9L5cllN33eL6ZzetDorXHZ2sZr6z4vIrpfmdqqmBW3Bfp DjY9p30hnTONkiTDA0518t4LklutxFKckWioxVxUnAgAHqXWC2UCAAA= Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Message-ID: <20210205163451.Cnb_K2A_3FsCb4SzY4VzwFvp_ONziv_noe1XFLG3-vg@z> > Hello, > > On Thu, 14 Jan 2021, at 09:08, Hongwei Zhang wrote: > > Add gpio base address reading in the driver; in old code, it just > > returns -1 to gpio->chip.base. > > Why do you want to do this? It feels hacky. The base address only affects the legacy sysfs number-space, > and even then if you're using the sysfs interface you can discover the base address for a specific gpiochip > via the associated attribute. For example: > > # cat /sys/bus/platform/devices/1e780000.gpio/gpio/gpiochip*/base > 816 > > I feel that you should instead be changing your userspace not to assume a fixed value. > > Finally, the base value is a linux-specific thing and doesn't belong in the devicetree, and if it did, you > would also need to update the devicetree binding in Documentation/. > > Cheers, > > Andrew Hi Andrew, Thanks for your review and advice. --Hongwei