Skip to contentSkip to conversation

ASoC: tegra: ADX: use of_device_get_match_data

PATCH Superseded Rosen Penev 2 participants 4 messages May 22 – May 28

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: tegra: ADX: use of_device_get_match_data

Remove open coding of the function to simplify the code.

---
 sound/soc/tegra/tegra210_adx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/tegra/tegra210_adx.c +3 -4
index 12371f895234..a2c28369fbc8 100644
@@ -677,17 +677,16 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct tegra210_adx *adx;
-	const struct of_device_id *match;
-	struct tegra210_adx_soc_data *soc_data;
+	const struct tegra210_adx_soc_data *soc_data;
 	void __iomem *regs;
 	int err, i;
 
+	soc_data = of_device_get_match_data(dev);
+
 	adx = devm_kzalloc(dev, sizeof(*adx), GFP_KERNEL);
 	if (!adx)
 		return -ENOMEM;
 
-	match = of_match_device(tegra210_adx_of_match, dev);
-	soc_data = (struct tegra210_adx_soc_data *)match->data;
 	adx->soc_data = soc_data;
 
 	dev_set_drvdata(dev, adx);
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 20 lines · Rosen Penev

Remove open coding of the function to simplify the code.

---
 sound/soc/tegra/tegra210_adx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/tegra/tegra210_adx.c +1 -2
index 12371f895234..a2c28369fbc8 100644
@@ -677,17 +677,16 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct tegra210_adx *adx;
-	const struct of_device_id *match;
-	struct tegra210_adx_soc_data *soc_data;
+	const struct tegra210_adx_soc_data *soc_data;
 	void __iomem *regs;
 	int err, i;

sound/soc/tegra/tegra210_adx.c static int tegra210_adx_platform_probe(struct platform_device *pdev) · line 690

Quoted 10 lines
sound/soc/tegra/tegra210_adx.c +2 -2
 
+	soc_data = of_device_get_match_data(dev);
+
 	adx = devm_kzalloc(dev, sizeof(*adx), GFP_KERNEL);
 	if (!adx)
 		return -ENOMEM;
 
-	match = of_match_device(tegra210_adx_of_match, dev);
-	soc_data = (struct tegra210_adx_soc_data *)match->data;
 	adx->soc_data = soc_data;

Why not just:

	adx->soc_data = of_device_get_match_data(dev);

? That saves you a few temporary variables and since you're not moving around the assignment needlessly, you get a much simpler diff, too.

Thierry

#2 lore raw
Quoted 35 lines · Thierry Reding
Quoted 20 lines · Rosen Penev

Remove open coding of the function to simplify the code.

---
 sound/soc/tegra/tegra210_adx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/tegra/tegra210_adx.c +1 -2
index 12371f895234..a2c28369fbc8 100644
@@ -677,17 +677,16 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
      struct tegra210_adx *adx;
-     const struct of_device_id *match;
-     struct tegra210_adx_soc_data *soc_data;
+     const struct tegra210_adx_soc_data *soc_data;
      void __iomem *regs;
      int err, i;

sound/soc/tegra/tegra210_adx.c static int tegra210_adx_platform_probe(struct platform_device *pdev) · line 690

Quoted 10 lines
sound/soc/tegra/tegra210_adx.c +2 -2
 
+     soc_data = of_device_get_match_data(dev);
+
      adx = devm_kzalloc(dev, sizeof(*adx), GFP_KERNEL);
      if (!adx)
              return -ENOMEM;
 
-     match = of_match_device(tegra210_adx_of_match, dev);
-     soc_data = (struct tegra210_adx_soc_data *)match->data;
      adx->soc_data = soc_data;

Why not just:

Quoted 4 lines
        adx->soc_data = of_device_get_match_data(dev);

? That saves you a few temporary variables and since you're not moving around the assignment needlessly, you get a much simpler diff, too.

Because soc_data is used later on in this function. I'd have to add adx-> everywhere.

Quoted 2 lines

Thierry

maintainer
#3 lore raw
Quoted 37 lines · Rosen Penev
Quoted 35 lines · Thierry Reding
Quoted 20 lines · Rosen Penev

Remove open coding of the function to simplify the code.

---
 sound/soc/tegra/tegra210_adx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/tegra/tegra210_adx.c +1 -2
index 12371f895234..a2c28369fbc8 100644
@@ -677,17 +677,16 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
      struct tegra210_adx *adx;
-     const struct of_device_id *match;
-     struct tegra210_adx_soc_data *soc_data;
+     const struct tegra210_adx_soc_data *soc_data;
      void __iomem *regs;
      int err, i;

sound/soc/tegra/tegra210_adx.c static int tegra210_adx_platform_probe(struct platform_device *pdev) · line 690

Quoted 10 lines
sound/soc/tegra/tegra210_adx.c +2 -2
 
+     soc_data = of_device_get_match_data(dev);
+
      adx = devm_kzalloc(dev, sizeof(*adx), GFP_KERNEL);
      if (!adx)
              return -ENOMEM;
 
-     match = of_match_device(tegra210_adx_of_match, dev);
-     soc_data = (struct tegra210_adx_soc_data *)match->data;
      adx->soc_data = soc_data;

Why not just:

Quoted 6 lines
Quoted 4 lines
        adx->soc_data = of_device_get_match_data(dev);

? That saves you a few temporary variables and since you're not moving around the assignment needlessly, you get a much simpler diff, too.

Because soc_data is used later on in this function. I'd have to add adx-> everywhere.

Hm... I guess that's what we should've done in the first place. Maybe just leave the assignment in the same place to keep the diff tidy, then. Also makes it easier to spot what you're actually doing.

Thierry