linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@amd.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
	Linus Walleij <linus.walleij@linaro.org>,
	Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>,
	Srinivas Neeli <srinivas.neeli@amd.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 2/3] gpio: xilinx: use helper variable to store the address of pdev->dev
Date: Tue, 1 Oct 2024 12:28:19 +0200	[thread overview]
Message-ID: <fe3669cd-99a5-42d2-99af-acbe28485577@amd.com> (raw)
In-Reply-To: <20240930144804.75068-2-brgl@bgdev.pl>



On 9/30/24 16:48, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> For better readability don't repeatedly dereference pdev->dev but
> instead store the address of the embedded struct device in a local
> variable in probe().
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>   drivers/gpio/gpio-xilinx.c | 34 +++++++++++++++++-----------------
>   1 file changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
> index afcf432a1573..d99824d42c77 100644
> --- a/drivers/gpio/gpio-xilinx.c
> +++ b/drivers/gpio/gpio-xilinx.c
> @@ -561,9 +561,10 @@ static const struct irq_chip xgpio_irq_chip = {
>    */
>   static int xgpio_probe(struct platform_device *pdev)
>   {
> +	struct device *dev = &pdev->dev;
>   	struct xgpio_instance *chip;
>   	int status = 0;
> -	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *np = dev->of_node;
>   	u32 is_dual = 0;
>   	u32 width[2];
>   	u32 state[2];
> @@ -571,7 +572,7 @@ static int xgpio_probe(struct platform_device *pdev)
>   	struct gpio_irq_chip *girq;
>   	u32 temp;
>   
> -	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
> +	chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
>   	if (!chip)
>   		return -ENOMEM;
>   
> @@ -624,7 +625,7 @@ static int xgpio_probe(struct platform_device *pdev)
>   
>   	chip->gc.base = -1;
>   	chip->gc.ngpio = bitmap_weight(chip->hw_map, 64);
> -	chip->gc.parent = &pdev->dev;
> +	chip->gc.parent = dev;
>   	chip->gc.direction_input = xgpio_dir_in;
>   	chip->gc.direction_output = xgpio_dir_out;
>   	chip->gc.get = xgpio_get;
> @@ -633,21 +634,21 @@ static int xgpio_probe(struct platform_device *pdev)
>   	chip->gc.free = xgpio_free;
>   	chip->gc.set_multiple = xgpio_set_multiple;
>   
> -	chip->gc.label = dev_name(&pdev->dev);
> +	chip->gc.label = dev_name(dev);
>   
>   	chip->regs = devm_platform_ioremap_resource(pdev, 0);
>   	if (IS_ERR(chip->regs)) {
> -		dev_err(&pdev->dev, "failed to ioremap memory resource\n");
> +		dev_err(dev, "failed to ioremap memory resource\n");
>   		return PTR_ERR(chip->regs);
>   	}
>   
> -	chip->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
> +	chip->clk = devm_clk_get_optional_enabled(dev, NULL);
>   	if (IS_ERR(chip->clk))
> -		return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk), "input clock not found.\n");
> +		return dev_err_probe(dev, PTR_ERR(chip->clk), "input clock not found.\n");
>   
> -	pm_runtime_get_noresume(&pdev->dev);
> -	pm_runtime_set_active(&pdev->dev);
> -	pm_runtime_enable(&pdev->dev);
> +	pm_runtime_get_noresume(dev);
> +	pm_runtime_set_active(dev);
> +	pm_runtime_enable(dev);
>   
>   	xgpio_save_regs(chip);
>   
> @@ -667,8 +668,7 @@ static int xgpio_probe(struct platform_device *pdev)
>   	gpio_irq_chip_set_chip(girq, &xgpio_irq_chip);
>   	girq->parent_handler = xgpio_irqhandler;
>   	girq->num_parents = 1;
> -	girq->parents = devm_kcalloc(&pdev->dev, 1,
> -				     sizeof(*girq->parents),
> +	girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
>   				     GFP_KERNEL);
>   	if (!girq->parents) {
>   		status = -ENOMEM;
> @@ -679,18 +679,18 @@ static int xgpio_probe(struct platform_device *pdev)
>   	girq->handler = handle_bad_irq;
>   
>   skip_irq:
> -	status = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
> +	status = devm_gpiochip_add_data(dev, &chip->gc, chip);
>   	if (status) {
> -		dev_err(&pdev->dev, "failed to add GPIO chip\n");
> +		dev_err(dev, "failed to add GPIO chip\n");
>   		goto err_pm_put;
>   	}
>   
> -	pm_runtime_put(&pdev->dev);
> +	pm_runtime_put(dev);
>   	return 0;
>   
>   err_pm_put:
> -	pm_runtime_disable(&pdev->dev);
> -	pm_runtime_put_noidle(&pdev->dev);
> +	pm_runtime_disable(dev);
> +	pm_runtime_put_noidle(dev);
>   	return status;
>   }
>   

make sense.

Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal

  reply	other threads:[~2024-10-01 10:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 14:48 [PATCH 1/3] gpio: xilinx: drop dependency on GPIO_OF Bartosz Golaszewski
2024-09-30 14:48 ` [PATCH 2/3] gpio: xilinx: use helper variable to store the address of pdev->dev Bartosz Golaszewski
2024-10-01 10:28   ` Michal Simek [this message]
2024-10-02 13:19   ` Linus Walleij
2024-09-30 14:48 ` [PATCH 3/3] gpio: xilinx: use generic device properties Bartosz Golaszewski
2024-10-01 10:29   ` Michal Simek
2024-10-02 13:20   ` Linus Walleij
2024-10-01 10:30 ` [PATCH 1/3] gpio: xilinx: drop dependency on GPIO_OF Michal Simek
2024-10-01 10:44   ` Bartosz Golaszewski
2024-10-01 11:13     ` Michal Simek
2024-10-01 12:31       ` Bartosz Golaszewski
2024-10-02 14:34         ` Bartosz Golaszewski
2024-10-08  8:18 ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe3669cd-99a5-42d2-99af-acbe28485577@amd.com \
    --to=michal.simek@amd.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shubhrajyoti.datta@amd.com \
    --cc=srinivas.neeli@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).