[PATCH v3 0/2] Match data improvements for ak4642 driver
This patch series aims to add match data improvements for ak4642 driver.
This patch series is only compile tested.
v2->v3: * Patch#1 for cleanups and patch#2 for simplifying probe() * Replace local variable np with dev_fwnode() * Replace dev_err()->dev_err_probe(). * Remove comma in the terminator entry for OF table. * Drop a space in the terminator entry for ID table. 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.
Biju Das (2): ASoC: ak4642: Minor cleanups in probe() ASoC: ak4642: Simplify probe()
sound/soc/codecs/ak4642.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-)
Some minor cleanups: Replace local variable np with dev_fwnode() Replace dev_err()->dev_err_probe(). Remove comma in the terminator entry for OF table. Drop a space in the terminator entry for ID table.
Signed-off-by: Biju Das biju.das.jz@bp.renesas.com --- v3: * New patch. --- sound/soc/codecs/ak4642.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 2a8984c1fa9c..901014909c0f 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -633,13 +633,12 @@ 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; struct regmap *regmap; struct ak4642_priv *priv; struct clk *mcko = NULL;
- if (np) { + if (dev_fwnode(dev)) { const struct of_device_id *of_id;
mcko = ak4642_of_parse_mcko(dev); @@ -655,10 +654,8 @@ static int ak4642_i2c_probe(struct i2c_client *i2c) drvdata = (const struct ak4642_drvdata *)id->driver_data; }
- if (!drvdata) { - dev_err(dev, "Unknown device type\n"); - return -EINVAL; - } + if (!drvdata) + return dev_err_probe(dev, -EINVAL, "Unknown device type\n");
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -681,7 +678,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 +686,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);
Simpilfy probe() by replacing of_device_get_match_data() and id lookup for retrieving match data by i2c_get_match_data().
Signed-off-by: Biju Das biju.das.jz@bp.renesas.com --- v2->v3: * Removing local variable np is handled in patch#1. 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 | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 901014909c0f..8a40c6b3f4d8 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -628,32 +628,21 @@ 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; - const struct ak4642_drvdata *drvdata = NULL; + const struct ak4642_drvdata *drvdata; struct regmap *regmap; struct ak4642_priv *priv; struct clk *mcko = NULL;
if (dev_fwnode(dev)) { - const struct of_device_id *of_id; - 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; }
+ drvdata = i2c_get_match_data(i2c); if (!drvdata) return dev_err_probe(dev, -EINVAL, "Unknown device type\n");
On Thu, 31 Aug 2023 21:47:32 +0100, Biju Das wrote:
This patch series aims to add match data improvements for ak4642 driver.
This patch series is only compile tested.
v2->v3:
- Patch#1 for cleanups and patch#2 for simplifying probe()
- Replace local variable np with dev_fwnode()
- Replace dev_err()->dev_err_probe().
- Remove comma in the terminator entry for OF table.
- Drop a space in the terminator entry for ID table.
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.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: ak4642: Minor cleanups in probe() commit: a157d07d029be5b72ee3bce3ac44dab7b967bc9b [2/2] 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
participants (2)
-
Biju Das
-
Mark Brown