diff mbox series

[v1,1/2] power: ip5xxx_power: Make use of i2c_get_match_data()

Message ID 20250212165012.2413079-2-andriy.shevchenko@linux.intel.com
State Superseded
Headers show
Series i2c: Reduce use of i2c_of_match_device() | expand

Commit Message

Andy Shevchenko Feb. 12, 2025, 4:46 p.m. UTC
Get matching data in one step by switching to use i2c_get_match_data().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/power/supply/ip5xxx_power.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Sebastian Reichel Feb. 12, 2025, 5:07 p.m. UTC | #1
Hi,

On Wed, Feb 12, 2025 at 06:46:23PM +0200, Andy Shevchenko wrote:
> Get matching data in one step by switching to use i2c_get_match_data().
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---

Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/power/supply/ip5xxx_power.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c
> index c448e0ac0dfa..717ec86c769b 100644
> --- a/drivers/power/supply/ip5xxx_power.c
> +++ b/drivers/power/supply/ip5xxx_power.c
> @@ -828,7 +828,7 @@ static void ip5xxx_setup_regs(struct device *dev, struct ip5xxx *ip5xxx,
>  
>  static int ip5xxx_power_probe(struct i2c_client *client)
>  {
> -	const struct ip5xxx_regfield_config *fields = &ip51xx_fields;
> +	const struct ip5xxx_regfield_config *fields;
>  	struct power_supply_config psy_cfg = {};
>  	struct device *dev = &client->dev;
>  	const struct of_device_id *of_id;
> @@ -843,9 +843,7 @@ static int ip5xxx_power_probe(struct i2c_client *client)
>  	if (IS_ERR(ip5xxx->regmap))
>  		return PTR_ERR(ip5xxx->regmap);
>  
> -	of_id = i2c_of_match_device(dev->driver->of_match_table, client);
> -	if (of_id)
> -		fields = (const struct ip5xxx_regfield_config *)of_id->data;
> +	fields = i2c_get_match_data(client) ?: &ip51xx_fields;
>  	ip5xxx_setup_regs(dev, ip5xxx, fields);
>  
>  	psy_cfg.of_node = dev->of_node;
> -- 
> 2.45.1.3035.g276e886db78b
>
Andy Shevchenko Feb. 13, 2025, 9:56 a.m. UTC | #2
On Wed, Feb 12, 2025 at 06:07:19PM +0100, Sebastian Reichel wrote:
> On Wed, Feb 12, 2025 at 06:46:23PM +0200, Andy Shevchenko wrote:
> > Get matching data in one step by switching to use i2c_get_match_data().

...

> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Thank you!

...

> >  static int ip5xxx_power_probe(struct i2c_client *client)
> >  {
> > -	const struct ip5xxx_regfield_config *fields = &ip51xx_fields;
> > +	const struct ip5xxx_regfield_config *fields;
> >  	struct power_supply_config psy_cfg = {};
> >  	struct device *dev = &client->dev;

> >  	const struct of_device_id *of_id;

Seems I forgot to drop this (unused) variable.

> > @@ -843,9 +843,7 @@ static int ip5xxx_power_probe(struct i2c_client *client)
> >  	if (IS_ERR(ip5xxx->regmap))
> >  		return PTR_ERR(ip5xxx->regmap);
> >  
> > -	of_id = i2c_of_match_device(dev->driver->of_match_table, client);
> > -	if (of_id)
> > -		fields = (const struct ip5xxx_regfield_config *)of_id->data;
> > +	fields = i2c_get_match_data(client) ?: &ip51xx_fields;
diff mbox series

Patch

diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c
index c448e0ac0dfa..717ec86c769b 100644
--- a/drivers/power/supply/ip5xxx_power.c
+++ b/drivers/power/supply/ip5xxx_power.c
@@ -828,7 +828,7 @@  static void ip5xxx_setup_regs(struct device *dev, struct ip5xxx *ip5xxx,
 
 static int ip5xxx_power_probe(struct i2c_client *client)
 {
-	const struct ip5xxx_regfield_config *fields = &ip51xx_fields;
+	const struct ip5xxx_regfield_config *fields;
 	struct power_supply_config psy_cfg = {};
 	struct device *dev = &client->dev;
 	const struct of_device_id *of_id;
@@ -843,9 +843,7 @@  static int ip5xxx_power_probe(struct i2c_client *client)
 	if (IS_ERR(ip5xxx->regmap))
 		return PTR_ERR(ip5xxx->regmap);
 
-	of_id = i2c_of_match_device(dev->driver->of_match_table, client);
-	if (of_id)
-		fields = (const struct ip5xxx_regfield_config *)of_id->data;
+	fields = i2c_get_match_data(client) ?: &ip51xx_fields;
 	ip5xxx_setup_regs(dev, ip5xxx, fields);
 
 	psy_cfg.of_node = dev->of_node;