linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] pinctrl: intel: Use temporary variable for struct device
@ 2022-11-02 15:29 Andy Shevchenko
  2022-11-02 15:29 ` [PATCH v1 2/2] pinctrl: merrifield: " Andy Shevchenko
  2022-11-03  7:26 ` [PATCH v1 1/2] pinctrl: intel: " Mika Westerberg
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-11-02 15:29 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij

Use temporary variable for struct device to make code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-intel.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index fe5bf2184cbf..e15629348cb5 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -1522,14 +1522,15 @@ static int intel_pinctrl_probe_pwm(struct intel_pinctrl *pctrl,
 int intel_pinctrl_probe(struct platform_device *pdev,
 			const struct intel_pinctrl_soc_data *soc_data)
 {
+	struct device *dev = &pdev->dev;
 	struct intel_pinctrl *pctrl;
 	int i, ret, irq;
 
-	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
+	pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL);
 	if (!pctrl)
 		return -ENOMEM;
 
-	pctrl->dev = &pdev->dev;
+	pctrl->dev = dev;
 	pctrl->soc = soc_data;
 	raw_spin_lock_init(&pctrl->lock);
 
@@ -1538,8 +1539,8 @@ int intel_pinctrl_probe(struct platform_device *pdev,
 	 * to the registers.
 	 */
 	pctrl->ncommunities = pctrl->soc->ncommunities;
-	pctrl->communities = devm_kcalloc(&pdev->dev, pctrl->ncommunities,
-				  sizeof(*pctrl->communities), GFP_KERNEL);
+	pctrl->communities = devm_kcalloc(dev, pctrl->ncommunities,
+					  sizeof(*pctrl->communities), GFP_KERNEL);
 	if (!pctrl->communities)
 		return -ENOMEM;
 
@@ -1603,7 +1604,7 @@ int intel_pinctrl_probe(struct platform_device *pdev,
 			offset = (value & CAPLIST_NEXT_MASK) >> CAPLIST_NEXT_SHIFT;
 		} while (offset);
 
-		dev_dbg(&pdev->dev, "Community%d features: %#08x\n", i, community->features);
+		dev_dbg(dev, "Community%d features: %#08x\n", i, community->features);
 
 		/* Read offset of the pad configuration registers */
 		offset = readl(regs + PADBAR);
@@ -1632,14 +1633,13 @@ int intel_pinctrl_probe(struct platform_device *pdev,
 		return ret;
 
 	pctrl->pctldesc = intel_pinctrl_desc;
-	pctrl->pctldesc.name = dev_name(&pdev->dev);
+	pctrl->pctldesc.name = dev_name(dev);
 	pctrl->pctldesc.pins = pctrl->soc->pins;
 	pctrl->pctldesc.npins = pctrl->soc->npins;
 
-	pctrl->pctldev = devm_pinctrl_register(&pdev->dev, &pctrl->pctldesc,
-					       pctrl);
+	pctrl->pctldev = devm_pinctrl_register(dev, &pctrl->pctldesc, pctrl);
 	if (IS_ERR(pctrl->pctldev)) {
-		dev_err(&pdev->dev, "failed to register pinctrl driver\n");
+		dev_err(dev, "failed to register pinctrl driver\n");
 		return PTR_ERR(pctrl->pctldev);
 	}
 
@@ -1681,10 +1681,11 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_
 {
 	const struct intel_pinctrl_soc_data * const *table;
 	const struct intel_pinctrl_soc_data *data = NULL;
+	struct device *dev = &pdev->dev;
 
-	table = device_get_match_data(&pdev->dev);
+	table = device_get_match_data(dev);
 	if (table) {
-		struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
+		struct acpi_device *adev = ACPI_COMPANION(dev);
 		unsigned int i;
 
 		for (i = 0; table[i]; i++) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 2/2] pinctrl: merrifield: Use temporary variable for struct device
  2022-11-02 15:29 [PATCH v1 1/2] pinctrl: intel: Use temporary variable for struct device Andy Shevchenko
@ 2022-11-02 15:29 ` Andy Shevchenko
  2022-11-03  7:26 ` [PATCH v1 1/2] pinctrl: intel: " Mika Westerberg
  1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-11-02 15:29 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij

Use temporary variable for struct device to make code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-merrifield.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-merrifield.c b/drivers/pinctrl/intel/pinctrl-merrifield.c
index 527957ea35b7..c0845bb1e9e3 100644
--- a/drivers/pinctrl/intel/pinctrl-merrifield.c
+++ b/drivers/pinctrl/intel/pinctrl-merrifield.c
@@ -897,17 +897,18 @@ static const struct pinctrl_desc mrfld_pinctrl_desc = {
 
 static int mrfld_pinctrl_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct mrfld_family *families;
 	struct mrfld_pinctrl *mp;
 	void __iomem *regs;
 	size_t nfamilies;
 	unsigned int i;
 
-	mp = devm_kzalloc(&pdev->dev, sizeof(*mp), GFP_KERNEL);
+	mp = devm_kzalloc(dev, sizeof(*mp), GFP_KERNEL);
 	if (!mp)
 		return -ENOMEM;
 
-	mp->dev = &pdev->dev;
+	mp->dev = dev;
 	raw_spin_lock_init(&mp->lock);
 
 	regs = devm_platform_ioremap_resource(pdev, 0);
@@ -919,9 +920,7 @@ static int mrfld_pinctrl_probe(struct platform_device *pdev)
 	 * to the registers.
 	 */
 	nfamilies = ARRAY_SIZE(mrfld_families),
-	families = devm_kmemdup(&pdev->dev, mrfld_families,
-					    sizeof(mrfld_families),
-					    GFP_KERNEL);
+	families = devm_kmemdup(dev, mrfld_families, sizeof(mrfld_families), GFP_KERNEL);
 	if (!families)
 		return -ENOMEM;
 
@@ -939,13 +938,13 @@ static int mrfld_pinctrl_probe(struct platform_device *pdev)
 	mp->groups = mrfld_groups;
 	mp->ngroups = ARRAY_SIZE(mrfld_groups);
 	mp->pctldesc = mrfld_pinctrl_desc;
-	mp->pctldesc.name = dev_name(&pdev->dev);
+	mp->pctldesc.name = dev_name(dev);
 	mp->pctldesc.pins = mrfld_pins;
 	mp->pctldesc.npins = ARRAY_SIZE(mrfld_pins);
 
-	mp->pctldev = devm_pinctrl_register(&pdev->dev, &mp->pctldesc, mp);
+	mp->pctldev = devm_pinctrl_register(dev, &mp->pctldesc, mp);
 	if (IS_ERR(mp->pctldev)) {
-		dev_err(&pdev->dev, "failed to register pinctrl driver\n");
+		dev_err(dev, "failed to register pinctrl driver\n");
 		return PTR_ERR(mp->pctldev);
 	}
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/2] pinctrl: intel: Use temporary variable for struct device
  2022-11-02 15:29 [PATCH v1 1/2] pinctrl: intel: Use temporary variable for struct device Andy Shevchenko
  2022-11-02 15:29 ` [PATCH v1 2/2] pinctrl: merrifield: " Andy Shevchenko
@ 2022-11-03  7:26 ` Mika Westerberg
  2022-11-03 10:54   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2022-11-03  7:26 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, linux-kernel, Andy Shevchenko, Linus Walleij

Hi,

On Wed, Nov 02, 2022 at 05:29:14PM +0200, Andy Shevchenko wrote:
> Use temporary variable for struct device to make code neater.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-intel.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
> index fe5bf2184cbf..e15629348cb5 100644
> --- a/drivers/pinctrl/intel/pinctrl-intel.c
> +++ b/drivers/pinctrl/intel/pinctrl-intel.c
> @@ -1522,14 +1522,15 @@ static int intel_pinctrl_probe_pwm(struct intel_pinctrl *pctrl,
>  int intel_pinctrl_probe(struct platform_device *pdev,
>  			const struct intel_pinctrl_soc_data *soc_data)
>  {
> +	struct device *dev = &pdev->dev;
>  	struct intel_pinctrl *pctrl;
>  	int i, ret, irq;
>  
> -	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
> +	pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL);

IMHO &pdev->dev is neater and saves an extra line. I would agree if this
would be something like &foo->bar->baz->dev but it is not.

Anyway, no feelings about this so feel free to add,

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

for both patches.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/2] pinctrl: intel: Use temporary variable for struct device
  2022-11-03  7:26 ` [PATCH v1 1/2] pinctrl: intel: " Mika Westerberg
@ 2022-11-03 10:54   ` Andy Shevchenko
  2022-11-03 11:44     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2022-11-03 10:54 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Andy Shevchenko, linux-gpio, linux-kernel, Andy Shevchenko,
	Linus Walleij

On Thu, Nov 3, 2022 at 9:26 AM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> On Wed, Nov 02, 2022 at 05:29:14PM +0200, Andy Shevchenko wrote:
> > Use temporary variable for struct device to make code neater.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  drivers/pinctrl/intel/pinctrl-intel.c | 23 ++++++++++++-----------
> >  1 file changed, 12 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
> > index fe5bf2184cbf..e15629348cb5 100644
> > --- a/drivers/pinctrl/intel/pinctrl-intel.c
> > +++ b/drivers/pinctrl/intel/pinctrl-intel.c
> > @@ -1522,14 +1522,15 @@ static int intel_pinctrl_probe_pwm(struct intel_pinctrl *pctrl,
> >  int intel_pinctrl_probe(struct platform_device *pdev,
> >                       const struct intel_pinctrl_soc_data *soc_data)
> >  {
> > +     struct device *dev = &pdev->dev;
> >       struct intel_pinctrl *pctrl;
> >       int i, ret, irq;
> >
> > -     pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
> > +     pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL);
>
> IMHO &pdev->dev is neater and saves an extra line. I would agree if this
> would be something like &foo->bar->baz->dev but it is not.

I have no strong opinion, but one thing which may play in favour of
the patches is that all other drivers, that have their custom
->probe() implemented, are using temporary variable. That said, let's
consider this as unification among Intel pin control drivers.

> Anyway, no feelings about this so feel free to add,
>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> for both patches.

Thank you!

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/2] pinctrl: intel: Use temporary variable for struct device
  2022-11-03 10:54   ` Andy Shevchenko
@ 2022-11-03 11:44     ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-11-03 11:44 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: linux-gpio, linux-kernel, Linus Walleij

On Thu, Nov 03, 2022 at 12:54:23PM +0200, Andy Shevchenko wrote:
> On Thu, Nov 3, 2022 at 9:26 AM Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
> > On Wed, Nov 02, 2022 at 05:29:14PM +0200, Andy Shevchenko wrote:

...

> > Anyway, no feelings about this so feel free to add,
> >
> > Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> >
> > for both patches.
> 
> Thank you!

Pushed to my review and testing queue, thank you!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-03 11:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-02 15:29 [PATCH v1 1/2] pinctrl: intel: Use temporary variable for struct device Andy Shevchenko
2022-11-02 15:29 ` [PATCH v1 2/2] pinctrl: merrifield: " Andy Shevchenko
2022-11-03  7:26 ` [PATCH v1 1/2] pinctrl: intel: " Mika Westerberg
2022-11-03 10:54   ` Andy Shevchenko
2022-11-03 11:44     ` Andy Shevchenko

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).