[PATCH v2] mfd: max77541: Simplify probe()

Biju Das posted 1 patch 2 years, 3 months ago
There is a newer version of this series
drivers/mfd/max77541.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
[PATCH v2] mfd: max77541: Simplify probe()
Posted by Biju Das 2 years, 3 months ago
Simplify probe() by replacing device_get_match_data() and ID lookup for
retrieving match data by i2c_get_match_data().

While at it, drop leading commas from OF table.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
 * Restored error code -EINVAL.
---
 drivers/mfd/max77541.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/max77541.c b/drivers/mfd/max77541.c
index 10c2e274b4af..2d50444a7b96 100644
--- a/drivers/mfd/max77541.c
+++ b/drivers/mfd/max77541.c
@@ -162,7 +162,6 @@ static int max77541_pmic_setup(struct device *dev)
 
 static int max77541_probe(struct i2c_client *client)
 {
-	const struct i2c_device_id *id = i2c_client_get_device_id(client);
 	struct device *dev = &client->dev;
 	struct max77541 *max77541;
 
@@ -173,10 +172,7 @@ static int max77541_probe(struct i2c_client *client)
 	i2c_set_clientdata(client, max77541);
 	max77541->i2c = client;
 
-	max77541->id = (uintptr_t)device_get_match_data(dev);
-	if (!max77541->id)
-		max77541->id  = (enum max7754x_ids)id->driver_data;
-
+	max77541->id = (uintptr_t)i2c_get_match_data(client);
 	if (!max77541->id)
 		return -EINVAL;
 
@@ -190,14 +186,8 @@ static int max77541_probe(struct i2c_client *client)
 }
 
 static const struct of_device_id max77541_of_id[] = {
-	{
-		.compatible = "adi,max77540",
-		.data = (void *)MAX77540,
-	},
-	{
-		.compatible = "adi,max77541",
-		.data = (void *)MAX77541,
-	},
+	{ .compatible = "adi,max77540", .data = (void *)MAX77540 },
+	{ .compatible = "adi,max77541", .data = (void *)MAX77541 },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, max77541_of_id);
-- 
2.25.1
Re: [PATCH v2] mfd: max77541: Simplify probe()
Posted by Andy Shevchenko 2 years, 3 months ago
On Mon, Aug 28, 2023 at 04:38:05PM +0100, Biju Das wrote:
> Simplify probe() by replacing device_get_match_data() and ID lookup for
> retrieving match data by i2c_get_match_data().

...

> While at it, drop leading commas from OF table.

Sure?

...

>  static const struct of_device_id max77541_of_id[] = {
> -	{
> -		.compatible = "adi,max77540",
> -		.data = (void *)MAX77540,
> -	},
> -	{
> -		.compatible = "adi,max77541",
> -		.data = (void *)MAX77541,
> -	},
> +	{ .compatible = "adi,max77540", .data = (void *)MAX77540 },
> +	{ .compatible = "adi,max77541", .data = (void *)MAX77541 },
>  	{ }
>  };

Seems to me an unneeded churn as nothing has been changed here
(except commas and indentation). If any, it should be a separate
change.

-- 
With Best Regards,
Andy Shevchenko
RE: [PATCH v2] mfd: max77541: Simplify probe()
Posted by Biju Das 2 years, 3 months ago
Hi Andy Shevchenko,

> Subject: Re: [PATCH v2] mfd: max77541: Simplify probe()
> 
> On Mon, Aug 28, 2023 at 04:38:05PM +0100, Biju Das wrote:
> > Simplify probe() by replacing device_get_match_data() and ID lookup
> > for retrieving match data by i2c_get_match_data().
> 
> ...
> 
> > While at it, drop leading commas from OF table.
> 
> Sure?
> 
> ...
> 
> >  static const struct of_device_id max77541_of_id[] = {
> > -	{
> > -		.compatible = "adi,max77540",
> > -		.data = (void *)MAX77540,
> > -	},
> > -	{
> > -		.compatible = "adi,max77541",
> > -		.data = (void *)MAX77541,
> > -	},
> > +	{ .compatible = "adi,max77540", .data = (void *)MAX77540 },
> > +	{ .compatible = "adi,max77541", .data = (void *)MAX77541 },
> >  	{ }
> >  };
> 
> Seems to me an unneeded churn as nothing has been changed here (except
> commas and indentation). If any, it should be a separate change.

See there is a comma after every .data, that is leading commas right?

Cheers,
Biju
Re: [PATCH v2] mfd: max77541: Simplify probe()
Posted by Andy Shevchenko 2 years, 3 months ago
On Tue, Aug 29, 2023 at 02:58:20PM +0000, Biju Das wrote:
> > On Mon, Aug 28, 2023 at 04:38:05PM +0100, Biju Das wrote:

...

> > > While at it, drop leading commas from OF table.
> > 
> > Sure?

...

> See there is a comma after every .data, that is leading commas right?

No, it's called trailing.

Ex.:

  lead  ..., trail
  0, 1, ..., N


-- 
With Best Regards,
Andy Shevchenko