mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: cs42xx8-i2c: Simplify probe()
@ 2023-08-28 17:48 Biju Das
  2023-08-29 15:19 ` Andy Shevchenko
  2023-09-11 23:57 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Biju Das @ 2023-08-28 17:48 UTC (permalink / raw)
  To: James Schulman, David Rhodes, Richard Fitzgerald,
	Jaroslav Kysela, Takashi Iwai
  Cc: Biju Das, Liam Girdwood, Mark Brown, alsa-devel, patches,
	linux-kernel, Andy Shevchenko, Charles Keepax

Simplify probe() by replacing of_match_device->i2c_get_match_data() and
extend matching support for ID table. Also replace
dev_err()->dev_err_probe() to simplify the code.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
Note:
 This patch is only compile tested.

v1->v2:
 * Added Ack from Charles Keepax.
 * Restored the error EINVAL.
---
 sound/soc/codecs/cs42xx8-i2c.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/cs42xx8-i2c.c b/sound/soc/codecs/cs42xx8-i2c.c
index a422472820fb..9028c0f0fe77 100644
--- a/sound/soc/codecs/cs42xx8-i2c.c
+++ b/sound/soc/codecs/cs42xx8-i2c.c
@@ -18,21 +18,15 @@
 
 #include "cs42xx8.h"
 
-static const struct of_device_id cs42xx8_of_match[];
-
 static int cs42xx8_i2c_probe(struct i2c_client *i2c)
 {
 	int ret;
 	struct cs42xx8_driver_data *drvdata;
-	const struct of_device_id *of_id;
-
-	of_id = of_match_device(cs42xx8_of_match, &i2c->dev);
-	if (!of_id) {
-		dev_err(&i2c->dev, "failed to find driver data\n");
-		return -EINVAL;
-	}
 
-	drvdata = (struct cs42xx8_driver_data *)of_id->data;
+	drvdata = (struct cs42xx8_driver_data *)i2c_get_match_data(i2c);
+	if (!drvdata)
+		return dev_err_probe(&i2c->dev, -EINVAL,
+				     "failed to find driver data\n");
 
 	ret = cs42xx8_probe(&i2c->dev,
 		devm_regmap_init_i2c(i2c, &cs42xx8_regmap_config), drvdata);
-- 
2.25.1


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

* Re: [PATCH v2] ASoC: cs42xx8-i2c: Simplify probe()
  2023-08-28 17:48 [PATCH v2] ASoC: cs42xx8-i2c: Simplify probe() Biju Das
@ 2023-08-29 15:19 ` Andy Shevchenko
  2023-08-29 18:01   ` Biju Das
  2023-09-11 23:57 ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-29 15:19 UTC (permalink / raw)
  To: Biju Das
  Cc: James Schulman, David Rhodes, Richard Fitzgerald,
	Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
	alsa-devel, patches, linux-kernel, Charles Keepax

On Mon, Aug 28, 2023 at 06:48:56PM +0100, Biju Das wrote:
> Simplify probe() by replacing of_match_device->i2c_get_match_data() and
> extend matching support for ID table. Also replace
> dev_err()->dev_err_probe() to simplify the code.

...

Can also be

	struct device *dev = &i2c->dev;

>  	int ret;
>  	struct cs42xx8_driver_data *drvdata;
> -	const struct of_device_id *of_id;
> -
> -	of_id = of_match_device(cs42xx8_of_match, &i2c->dev);
> -	if (!of_id) {
> -		dev_err(&i2c->dev, "failed to find driver data\n");
> -		return -EINVAL;
> -	}
>  
> -	drvdata = (struct cs42xx8_driver_data *)of_id->data;
> +	drvdata = (struct cs42xx8_driver_data *)i2c_get_match_data(i2c);
> +	if (!drvdata)

> +		return dev_err_probe(&i2c->dev, -EINVAL,
> +				     "failed to find driver data\n");

		return dev_err_probe(dev, -EINVAL, "failed to find driver data\n");

-- 
With Best Regards,
Andy Shevchenko



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

* RE: [PATCH v2] ASoC: cs42xx8-i2c: Simplify probe()
  2023-08-29 15:19 ` Andy Shevchenko
@ 2023-08-29 18:01   ` Biju Das
  0 siblings, 0 replies; 4+ messages in thread
From: Biju Das @ 2023-08-29 18:01 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: James Schulman, David Rhodes, Richard Fitzgerald,
	Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
	alsa-devel, patches, linux-kernel, Charles Keepax

Hi Andy,

> Subject: Re: [PATCH v2] ASoC: cs42xx8-i2c: Simplify probe()
> 
> On Mon, Aug 28, 2023 at 06:48:56PM +0100, Biju Das wrote:
> > Simplify probe() by replacing of_match_device->i2c_get_match_data()
> > and extend matching support for ID table. Also replace
> > dev_err()->dev_err_probe() to simplify the code.
> 
> ...
> 
> Can also be
> 
> 	struct device *dev = &i2c->dev;
> 
> >  	int ret;
> >  	struct cs42xx8_driver_data *drvdata;
> > -	const struct of_device_id *of_id;
> > -
> > -	of_id = of_match_device(cs42xx8_of_match, &i2c->dev);
> > -	if (!of_id) {
> > -		dev_err(&i2c->dev, "failed to find driver data\n");
> > -		return -EINVAL;
> > -	}
> >
> > -	drvdata = (struct cs42xx8_driver_data *)of_id->data;
> > +	drvdata = (struct cs42xx8_driver_data *)i2c_get_match_data(i2c);
> > +	if (!drvdata)
> 
> > +		return dev_err_probe(&i2c->dev, -EINVAL,
> > +				     "failed to find driver data\n");
> 
> 		return dev_err_probe(dev, -EINVAL, "failed to find driver
> data\n");

True,

Cheers,
Biju

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

* Re: [PATCH v2] ASoC: cs42xx8-i2c: Simplify probe()
  2023-08-28 17:48 [PATCH v2] ASoC: cs42xx8-i2c: Simplify probe() Biju Das
  2023-08-29 15:19 ` Andy Shevchenko
@ 2023-09-11 23:57 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-09-11 23:57 UTC (permalink / raw)
  To: James Schulman, David Rhodes, Richard Fitzgerald,
	Jaroslav Kysela, Takashi Iwai, Biju Das
  Cc: Liam Girdwood, alsa-devel, patches, linux-kernel,
	Andy Shevchenko, Charles Keepax

On Mon, 28 Aug 2023 18:48:56 +0100, Biju Das wrote:
> Simplify probe() by replacing of_match_device->i2c_get_match_data() and
> extend matching support for ID table. Also replace
> dev_err()->dev_err_probe() to simplify the code.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: cs42xx8-i2c: Simplify probe()
      commit: ad191992330cfeb80ba341d1e75d9fe2719ced68

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

end of thread, other threads:[~2023-09-12  3:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 17:48 [PATCH v2] ASoC: cs42xx8-i2c: Simplify probe() Biju Das
2023-08-29 15:19 ` Andy Shevchenko
2023-08-29 18:01   ` Biju Das
2023-09-11 23:57 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®