* [PATCH v2] ASoC: ak4642: Simplify probe()
@ 2023-08-28 18:00 Biju Das
2023-08-29 15:24 ` Andy Shevchenko
2023-09-11 23:57 ` Mark Brown
0 siblings, 2 replies; 6+ messages in thread
From: Biju Das @ 2023-08-28 18:00 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai
Cc: Biju Das, Liam Girdwood, Mark Brown, Uwe Kleine-König,
alsa-devel, linux-kernel, Andy Shevchenko
Simpilfy probe() by replacing of_device_get_match_data() and id lookup for
retrieving match data by i2c_get_match_data() and replace
dev_err()->dev_err_probe().
While at it, drop local variable np and use dev_fwnode() instead and
remove comma in the terminator entry.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Note:
This patch is only compile tested.
v1->v2:
* Removed forward declaration ak4642_of_match and ak4642_i2c_id.
* Restored error EINVAL.
* Used dev_fwnode() and replaced dev->of_node.
* Removed comma in the terminator entry.
---
sound/soc/codecs/ak4642.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 2a8984c1fa9c..8a40c6b3f4d8 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -628,37 +628,23 @@ static struct clk *ak4642_of_parse_mcko(struct device *dev)
#define ak4642_of_parse_mcko(d) 0
#endif
-static const struct of_device_id ak4642_of_match[];
-static const struct i2c_device_id ak4642_i2c_id[];
static int ak4642_i2c_probe(struct i2c_client *i2c)
{
struct device *dev = &i2c->dev;
- struct device_node *np = dev->of_node;
- const struct ak4642_drvdata *drvdata = NULL;
+ const struct ak4642_drvdata *drvdata;
struct regmap *regmap;
struct ak4642_priv *priv;
struct clk *mcko = NULL;
- if (np) {
- const struct of_device_id *of_id;
-
+ if (dev_fwnode(dev)) {
mcko = ak4642_of_parse_mcko(dev);
if (IS_ERR(mcko))
mcko = NULL;
-
- of_id = of_match_device(ak4642_of_match, dev);
- if (of_id)
- drvdata = of_id->data;
- } else {
- const struct i2c_device_id *id =
- i2c_match_id(ak4642_i2c_id, i2c);
- drvdata = (const struct ak4642_drvdata *)id->driver_data;
}
- if (!drvdata) {
- dev_err(dev, "Unknown device type\n");
- return -EINVAL;
- }
+ drvdata = i2c_get_match_data(i2c);
+ if (!drvdata)
+ return dev_err_probe(dev, -EINVAL, "Unknown device type\n");
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -681,7 +667,7 @@ static const struct of_device_id ak4642_of_match[] = {
{ .compatible = "asahi-kasei,ak4642", .data = &ak4642_drvdata},
{ .compatible = "asahi-kasei,ak4643", .data = &ak4643_drvdata},
{ .compatible = "asahi-kasei,ak4648", .data = &ak4648_drvdata},
- {},
+ {}
};
MODULE_DEVICE_TABLE(of, ak4642_of_match);
@@ -689,7 +675,7 @@ static const struct i2c_device_id ak4642_i2c_id[] = {
{ "ak4642", (kernel_ulong_t)&ak4642_drvdata },
{ "ak4643", (kernel_ulong_t)&ak4643_drvdata },
{ "ak4648", (kernel_ulong_t)&ak4648_drvdata },
- { }
+ {}
};
MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id);
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2] ASoC: ak4642: Simplify probe()
2023-08-28 18:00 [PATCH v2] ASoC: ak4642: Simplify probe() Biju Das
@ 2023-08-29 15:24 ` Andy Shevchenko
2023-08-29 18:02 ` Biju Das
2023-09-11 23:57 ` Mark Brown
1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-08-29 15:24 UTC (permalink / raw)
To: Biju Das
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
Uwe Kleine-König, alsa-devel, linux-kernel
On Mon, Aug 28, 2023 at 07:00:03PM +0100, Biju Das wrote:
> Simpilfy probe() by replacing of_device_get_match_data() and id lookup for
> retrieving match data by i2c_get_match_data() and replace
> dev_err()->dev_err_probe().
...
> - if (np) {
> - const struct of_device_id *of_id;
> -
> + if (dev_fwnode(dev)) {
Why do we need this at all?
> mcko = ak4642_of_parse_mcko(dev);
> if (IS_ERR(mcko))
> mcko = NULL;
This can suffice on its own, right?
Can be done in a separate change as a precursor to this one.
> -
> - of_id = of_match_device(ak4642_of_match, dev);
> - if (of_id)
> - drvdata = of_id->data;
> - } else {
> - const struct i2c_device_id *id =
> - i2c_match_id(ak4642_i2c_id, i2c);
> - drvdata = (const struct ak4642_drvdata *)id->driver_data;
> }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [PATCH v2] ASoC: ak4642: Simplify probe()
2023-08-29 15:24 ` Andy Shevchenko
@ 2023-08-29 18:02 ` Biju Das
2023-08-31 13:37 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Biju Das @ 2023-08-29 18:02 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
Uwe Kleine-König, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org
Hi Andy,
> Subject: Re: [PATCH v2] ASoC: ak4642: Simplify probe()
>
> On Mon, Aug 28, 2023 at 07:00:03PM +0100, Biju Das wrote:
> > Simpilfy probe() by replacing of_device_get_match_data() and id lookup
> > for retrieving match data by i2c_get_match_data() and replace
> > dev_err()->dev_err_probe().
>
> ...
>
> > - if (np) {
> > - const struct of_device_id *of_id;
> > -
>
> > + if (dev_fwnode(dev)) {
>
> Why do we need this at all?
It is replacement for np.
>
> > mcko = ak4642_of_parse_mcko(dev);
> > if (IS_ERR(mcko))
> > mcko = NULL;
>
> This can suffice on its own, right?
>
> Can be done in a separate change as a precursor to this one.
Agreed.
Cheers,
Biju
>
> > -
> > - of_id = of_match_device(ak4642_of_match, dev);
> > - if (of_id)
> > - drvdata = of_id->data;
> > - } else {
> > - const struct i2c_device_id *id =
> > - i2c_match_id(ak4642_i2c_id, i2c);
> > - drvdata = (const struct ak4642_drvdata *)id->driver_data;
> > }
>
> --
> With Best Regards,
> Andy Shevchenko
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] ASoC: ak4642: Simplify probe()
2023-08-29 18:02 ` Biju Das
@ 2023-08-31 13:37 ` Andy Shevchenko
2023-08-31 14:13 ` Biju Das
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-08-31 13:37 UTC (permalink / raw)
To: Biju Das
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
Uwe Kleine-König, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org
On Tue, Aug 29, 2023 at 06:02:51PM +0000, Biju Das wrote:
> > On Mon, Aug 28, 2023 at 07:00:03PM +0100, Biju Das wrote:
...
> > > - if (np) {
> > > - const struct of_device_id *of_id;
> > > -
> >
> > > + if (dev_fwnode(dev)) {
> >
> > Why do we need this at all?
> It is replacement for np.
I am questioning it's necessity to begin with (even before your patch).
> > > mcko = ak4642_of_parse_mcko(dev);
> > > if (IS_ERR(mcko))
> > > mcko = NULL;
> >
> > This can suffice on its own, right?
> >
> > Can be done in a separate change as a precursor to this one.
>
> Agreed.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [PATCH v2] ASoC: ak4642: Simplify probe()
2023-08-31 13:37 ` Andy Shevchenko
@ 2023-08-31 14:13 ` Biju Das
0 siblings, 0 replies; 6+ messages in thread
From: Biju Das @ 2023-08-31 14:13 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown,
Uwe Kleine-König, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org
Hi Andy,
> Subject: Re: [PATCH v2] ASoC: ak4642: Simplify probe()
>
> On Tue, Aug 29, 2023 at 06:02:51PM +0000, Biju Das wrote:
> > > On Mon, Aug 28, 2023 at 07:00:03PM +0100, Biju Das wrote:
>
> ...
>
> > > > - if (np) {
> > > > - const struct of_device_id *of_id;
> > > > -
> > >
> > > > + if (dev_fwnode(dev)) {
> > >
> > > Why do we need this at all?
> > It is replacement for np.
>
> I am questioning it's necessity to begin with (even before your patch).
OK, I will make separate patch as precursor to this one
if (dev_fwnode(dev)) {
mcko = ak4642_of_parse_mcko(dev);
if (IS_ERR(mcko))
mcko = NULL;
}
Cheers,
Biju
>
> > > > mcko = ak4642_of_parse_mcko(dev);
> > > > if (IS_ERR(mcko))
> > > > mcko = NULL;
> > >
> > > This can suffice on its own, right?
> > >
> > > Can be done in a separate change as a precursor to this one.
> >
> > Agreed.
>
> --
> With Best Regards,
> Andy Shevchenko
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: ak4642: Simplify probe()
2023-08-28 18:00 [PATCH v2] ASoC: ak4642: Simplify probe() Biju Das
2023-08-29 15:24 ` Andy Shevchenko
@ 2023-09-11 23:57 ` Mark Brown
1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2023-09-11 23:57 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai, Biju Das
Cc: Liam Girdwood, Uwe Kleine-König, alsa-devel, linux-kernel,
Andy Shevchenko
On Mon, 28 Aug 2023 19:00:03 +0100, Biju Das wrote:
> Simpilfy probe() by replacing of_device_get_match_data() and id lookup for
> retrieving match data by i2c_get_match_data() and replace
> dev_err()->dev_err_probe().
>
> While at it, drop local variable np and use dev_fwnode() instead and
> remove comma in the terminator entry.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: ak4642: Simplify probe()
commit: d9e6a80a2c7bea4cc2edc87fa43b876a64b13074
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] 6+ messages in thread
end of thread, other threads:[~2023-09-12 0:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-28 18:00 [PATCH v2] ASoC: ak4642: Simplify probe() Biju Das
2023-08-29 15:24 ` Andy Shevchenko
2023-08-29 18:02 ` Biju Das
2023-08-31 13:37 ` Andy Shevchenko
2023-08-31 14:13 ` Biju Das
2023-09-11 23:57 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.