ASoC: tegra: ADX: use of_device_get_match_data
Subsystems (3)
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
@@ -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
Thierry Reding
maintainerQuoted 20 lines · Rosen Penev
Remove open coding of the function to simplify the code.
Signed-off-by Rosen Penev <[email protected]>--- sound/soc/tegra/tegra210_adx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)sound/soc/tegra/tegra210_adx.c +1
-2@@ -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
Quoted 35 lines · Thierry Reding
Quoted 20 lines · Rosen Penev
Remove open coding of the function to simplify the code.
Signed-off-by Rosen Penev <[email protected]>--- sound/soc/tegra/tegra210_adx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)sound/soc/tegra/tegra210_adx.c +1
-2@@ -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
Thierry Reding
maintainerQuoted 37 lines · Rosen Penev
Quoted 35 lines · Thierry Reding
Quoted 20 lines · Rosen Penev
Remove open coding of the function to simplify the code.
Signed-off-by Rosen Penev <[email protected]>--- sound/soc/tegra/tegra210_adx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)sound/soc/tegra/tegra210_adx.c +1
-2@@ -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_datais 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