public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andy Shevchenko <andy@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH v1 2/3] pinctrl: baytrail: Replace ifdeffery by pm_sleep_ptr() macro
Date: Wed, 4 Sep 2024 08:06:30 +0300	[thread overview]
Message-ID: <20240904050630.GC1532424@black.fi.intel.com> (raw)
In-Reply-To: <20240903170752.3564538-3-andriy.shevchenko@linux.intel.com>

On Tue, Sep 03, 2024 at 08:04:50PM +0300, Andy Shevchenko wrote:
> Explicit ifdeffery is ugly and theoretically might be not synchronised
> with the rest of functions that are assigned via pm_sleep_ptr() macro.
> Replace ifdeffery by pm_sleep_ptr() macro to improve this.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-baytrail.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
> index 4533c4d0a9e7..7aa0ddca7a59 100644
> --- a/drivers/pinctrl/intel/pinctrl-baytrail.c
> +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
> @@ -1514,13 +1514,6 @@ static int byt_gpio_probe(struct intel_pinctrl *vg)
>  	gc->parent	= vg->dev;
>  	gc->ngpio	= vg->soc->npins;
>  
> -#ifdef CONFIG_PM_SLEEP
> -	vg->context.pads = devm_kcalloc(vg->dev, gc->ngpio, sizeof(*vg->context.pads),
> -					GFP_KERNEL);
> -	if (!vg->context.pads)
> -		return -ENOMEM;
> -#endif
> -
>  	/* set up interrupts  */
>  	irq = platform_get_irq_optional(pdev, 0);
>  	if (irq > 0) {
> @@ -1581,6 +1574,16 @@ static const struct acpi_device_id byt_gpio_acpi_match[] = {
>  	{ }
>  };
>  
> +static int byt_pinctrl_pm_init(struct intel_pinctrl *vg)
> +{
> +	vg->context.pads = devm_kcalloc(vg->dev, vg->soc->npins,
> +					sizeof(*vg->context.pads), GFP_KERNEL);
> +	if (!vg->context.pads)
> +		return -ENOMEM;
> +
> +	return 0;
> +}
> +
>  static int byt_pinctrl_probe(struct platform_device *pdev)
>  {
>  	const struct intel_pinctrl_soc_data *soc_data;
> @@ -1603,6 +1606,10 @@ static int byt_pinctrl_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> +	ret = pm_sleep_ptr(byt_pinctrl_pm_init) ? byt_pinctrl_pm_init(vg) : 0;

Same here.

> +	if (ret)
> +		return ret;
> +
>  	vg->pctldesc		= byt_pinctrl_desc;
>  	vg->pctldesc.name	= dev_name(dev);
>  	vg->pctldesc.pins	= vg->soc->pins;
> -- 
> 2.43.0.rc1.1336.g36b5255a03ac

  reply	other threads:[~2024-09-04  5:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-03 17:04 [PATCH v1 0/3] pinctrl: intel: Get rid of ifdeffery leftovers Andy Shevchenko
2024-09-03 17:04 ` [PATCH v1 1/3] pinctrl: intel: Replace ifdeffery by pm_sleep_ptr() macro Andy Shevchenko
2024-09-04  5:05   ` Mika Westerberg
2024-09-04  7:47     ` Andy Shevchenko
2024-09-04  7:48       ` Andy Shevchenko
2024-09-04 11:18         ` Mika Westerberg
2024-09-04  9:46   ` kernel test robot
2024-09-03 17:04 ` [PATCH v1 2/3] pinctrl: baytrail: " Andy Shevchenko
2024-09-04  5:06   ` Mika Westerberg [this message]
2024-09-04 13:04   ` kernel test robot
2024-09-03 17:04 ` [PATCH v1 3/3] pinctrl: cherryview: " Andy Shevchenko
2024-09-04  5:06   ` Mika Westerberg
2024-09-04 11:28   ` kernel test robot

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=20240904050630.GC1532424@black.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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