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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 467A5CA0EF8 for ; Wed, 20 Aug 2025 20:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=55i7wJ2ySvENX6OFoHwP53Kw9OUvpU44Nxs7wZwCSNY=; b=JT0Psolb4nR9+8Ejq/er3zK1kl hnLZAqV735YgUn6jSQINzAAYySsKQYEc0tBHAHKALkg1CxMZs8jFs74F1FC2ElHDfjbLonkYRvq0E ieaboN1K4FSE9ia0wUPMoT94EN4uzcmfBmtVwT8qrYppIlEBXlhKRpp/Fu4B4Arzh8K0W9x9E0Vt8 zRK8i+mV22v/CMZZf09i0xNH3X+8AytyV672nxku93rPzm+CzbNn6nlw17bDE2tapoVmWU3h3tNtX FA0PAez6vL7iPmwcpGQJxN4LYEJfhhhAv+Ax6dAKHKK9u7s63OvgaqmKXHNqi1bYJdj6oY6DuyBIX fm17Fm3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uopkX-0000000ErxL-07XA; Wed, 20 Aug 2025 20:49:37 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uolCW-0000000EK2d-3Xro for linux-arm-kernel@lists.infradead.org; Wed, 20 Aug 2025 15:58:14 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 6DA0E44022; Wed, 20 Aug 2025 15:58:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9FFEC4CEEB; Wed, 20 Aug 2025 15:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755705492; bh=2Y6pXY5C3fzYpd9lxWJ0ZagqNozVP0PkFBHNE3P4K2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FlWwG/6+6E1DT25N7XcMNcfSJZkErGpZxNGhz97Dkv1SYq9n3s+mPI6kH9RGSaftL a7RbelbN65r34/f4YunyhYa90/w/doU+dKQf3fCQH7uAX6B2GTu9nGa+ewGno1Qo28 nK+OIuQf9yS+YxHVRakyMtYk1jQj1h6+j5mg8nptG7CbI+TFBgSXmc0wVC3QhqVhmM eS7tfTx/O7R8CoLN/6V5TkBd5GE0GA9wAQ5ByYk9ZO/PsKmp8KMU37kHvKWFhNMK8i 4UJ2qtuAF3fJGjjMxGTVOAXXgJJOz24Q1xXCja9lnFCU38V3xDatum4KmBnOMF5QNR s/ScKIGQmFjJA== From: Jisheng Zhang To: Doug Berger , Florian Fainelli , Linus Walleij , Bartosz Golaszewski , Michael Buesch , Hoan Tran , Andy Shevchenko , Daniel Palmer , Romain Perier , Grygorii Strashko , Santosh Shilimkar , Kevin Hilman , Robert Jarzmik , Kunihiko Hayashi , Masami Hiramatsu , Shubhrajyoti Datta , Srinivas Neeli , Michal Simek Cc: Broadcom internal kernel review list , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux@ew.tq-group.com Subject: [PATCH 01/16] gpio: dwapb: Use modern PM macros Date: Wed, 20 Aug 2025 23:40:22 +0800 Message-ID: <20250820154037.22228-2-jszhang@kernel.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250820154037.22228-1-jszhang@kernel.org> References: <20250820154037.22228-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250820_085812_933841_46E2830C X-CRM114-Status: GOOD ( 17.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards. This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch. The dwapb_context structure is always embedded into struct dwapb_gpio_port to simplify code. Sure this brings a tiny 36 bytes data overhead for !CONFIG_PM_SLEP. Signed-off-by: Jisheng Zhang --- drivers/gpio/gpio-dwapb.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 43b667b41f5d..d831e6c61566 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -78,7 +78,6 @@ struct dwapb_platform_data { unsigned int nports; }; -#ifdef CONFIG_PM_SLEEP /* Store GPIO context across system-wide suspend/resume transitions */ struct dwapb_context { u32 data; @@ -91,7 +90,6 @@ struct dwapb_context { u32 int_deb; u32 wake_en; }; -#endif struct dwapb_gpio_port_irqchip { unsigned int nr_irqs; @@ -102,9 +100,7 @@ struct dwapb_gpio_port { struct gpio_chip gc; struct dwapb_gpio_port_irqchip *pirq; struct dwapb_gpio *gpio; -#ifdef CONFIG_PM_SLEEP - struct dwapb_context *ctx; -#endif + struct dwapb_context ctx; unsigned int idx; }; #define to_dwapb_gpio(_gc) \ @@ -357,12 +353,11 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type) return 0; } -#ifdef CONFIG_PM_SLEEP static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct dwapb_gpio *gpio = to_dwapb_gpio(gc); - struct dwapb_context *ctx = gpio->ports[0].ctx; + struct dwapb_context *ctx = &gpio->ports[0].ctx; irq_hw_number_t bit = irqd_to_hwirq(d); if (enable) @@ -372,9 +367,6 @@ static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable) return 0; } -#else -#define dwapb_irq_set_wake NULL -#endif static const struct irq_chip dwapb_irq_chip = { .name = DWAPB_DRIVER_NAME, @@ -384,7 +376,7 @@ static const struct irq_chip dwapb_irq_chip = { .irq_set_type = dwapb_irq_set_type, .irq_enable = dwapb_irq_enable, .irq_disable = dwapb_irq_disable, - .irq_set_wake = dwapb_irq_set_wake, + .irq_set_wake = pm_sleep_ptr(dwapb_irq_set_wake), .flags = IRQCHIP_IMMUTABLE, GPIOCHIP_IRQ_RESOURCE_HELPERS, }; @@ -509,12 +501,6 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, port->gpio = gpio; port->idx = pp->idx; -#ifdef CONFIG_PM_SLEEP - port->ctx = devm_kzalloc(gpio->dev, sizeof(*port->ctx), GFP_KERNEL); - if (!port->ctx) - return -ENOMEM; -#endif - dat = gpio->regs + GPIO_EXT_PORTA + pp->idx * GPIO_EXT_PORT_STRIDE; set = gpio->regs + GPIO_SWPORTA_DR + pp->idx * GPIO_SWPORT_DR_STRIDE; dirout = gpio->regs + GPIO_SWPORTA_DDR + pp->idx * GPIO_SWPORT_DDR_STRIDE; @@ -746,7 +732,6 @@ static int dwapb_gpio_probe(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP static int dwapb_gpio_suspend(struct device *dev) { struct dwapb_gpio *gpio = dev_get_drvdata(dev); @@ -758,7 +743,7 @@ static int dwapb_gpio_suspend(struct device *dev) for (i = 0; i < gpio->nr_ports; i++) { unsigned int offset; unsigned int idx = gpio->ports[i].idx; - struct dwapb_context *ctx = gpio->ports[i].ctx; + struct dwapb_context *ctx = &gpio->ports[i].ctx; offset = GPIO_SWPORTA_DDR + idx * GPIO_SWPORT_DDR_STRIDE; ctx->dir = dwapb_read(gpio, offset); @@ -805,7 +790,7 @@ static int dwapb_gpio_resume(struct device *dev) for (i = 0; i < gpio->nr_ports; i++) { unsigned int offset; unsigned int idx = gpio->ports[i].idx; - struct dwapb_context *ctx = gpio->ports[i].ctx; + struct dwapb_context *ctx = &gpio->ports[i].ctx; offset = GPIO_SWPORTA_DR + idx * GPIO_SWPORT_DR_STRIDE; dwapb_write(gpio, offset, ctx->data); @@ -832,15 +817,13 @@ static int dwapb_gpio_resume(struct device *dev) return 0; } -#endif -static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, - dwapb_gpio_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, dwapb_gpio_resume); static struct platform_driver dwapb_gpio_driver = { .driver = { .name = DWAPB_DRIVER_NAME, - .pm = &dwapb_gpio_pm_ops, + .pm = pm_sleep_ptr(&dwapb_gpio_pm_ops), .of_match_table = dwapb_of_match, .acpi_match_table = dwapb_acpi_match, }, -- 2.50.1