diff mbox series

[4/7] mfd: da9052: Simplify getting of_device_id match data

Message ID 20210419081726.67867-4-krzysztof.kozlowski@canonical.com (mailing list archive)
State New
Headers show
Series [1/7] mfd: max8997: Simplify getting of_device_id match data | expand

Commit Message

Krzysztof Kozlowski April 19, 2021, 8:17 a.m. UTC
Use of_device_get_match_data() to make the code slightly smaller.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/mfd/da9062-core.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Adam Thomson April 19, 2021, 11 a.m. UTC | #1
On 19 April 2021 09:17, Krzysztof Kozlowski wrote:

> Use of_device_get_match_data() to make the code slightly smaller.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

>  drivers/mfd/da9062-core.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c
> index 8d913375152d..01f8e10dfa55 100644
> --- a/drivers/mfd/da9062-core.c
> +++ b/drivers/mfd/da9062-core.c
> @@ -9,6 +9,7 @@
>  #include <linux/init.h>
>  #include <linux/device.h>
>  #include <linux/interrupt.h>
> +#include <linux/of_device.h>
>  #include <linux/regmap.h>
>  #include <linux/irq.h>
>  #include <linux/mfd/core.h>
> @@ -622,7 +623,6 @@ static int da9062_i2c_probe(struct i2c_client *i2c,
>  	const struct i2c_device_id *id)
>  {
>  	struct da9062 *chip;
> -	const struct of_device_id *match;
>  	unsigned int irq_base;
>  	const struct mfd_cell *cell;
>  	const struct regmap_irq_chip *irq_chip;
> @@ -635,15 +635,10 @@ static int da9062_i2c_probe(struct i2c_client *i2c,
>  	if (!chip)
>  		return -ENOMEM;
> 
> -	if (i2c->dev.of_node) {
> -		match = of_match_node(da9062_dt_ids, i2c->dev.of_node);
> -		if (!match)
> -			return -EINVAL;
> -
> -		chip->chip_type = (uintptr_t)match->data;
> -	} else {
> +	if (i2c->dev.of_node)
> +		chip->chip_type = (uintptr_t)of_device_get_match_data(&i2c-
> >dev);
> +	else
>  		chip->chip_type = id->driver_data;
> -	}
> 
>  	i2c_set_clientdata(i2c, chip);
>  	chip->dev = &i2c->dev;
> --
> 2.25.1
Krzysztof Kozlowski April 19, 2021, 11:04 a.m. UTC | #2
On 19/04/2021 10:17, Krzysztof Kozlowski wrote:
> Use of_device_get_match_data() to make the code slightly smaller.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---
>  drivers/mfd/da9062-core.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)

Copy-paste error in the subject - the prefix should be:
mfd: da9062:


Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c
index 8d913375152d..01f8e10dfa55 100644
--- a/drivers/mfd/da9062-core.c
+++ b/drivers/mfd/da9062-core.c
@@ -9,6 +9,7 @@ 
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/interrupt.h>
+#include <linux/of_device.h>
 #include <linux/regmap.h>
 #include <linux/irq.h>
 #include <linux/mfd/core.h>
@@ -622,7 +623,6 @@  static int da9062_i2c_probe(struct i2c_client *i2c,
 	const struct i2c_device_id *id)
 {
 	struct da9062 *chip;
-	const struct of_device_id *match;
 	unsigned int irq_base;
 	const struct mfd_cell *cell;
 	const struct regmap_irq_chip *irq_chip;
@@ -635,15 +635,10 @@  static int da9062_i2c_probe(struct i2c_client *i2c,
 	if (!chip)
 		return -ENOMEM;
 
-	if (i2c->dev.of_node) {
-		match = of_match_node(da9062_dt_ids, i2c->dev.of_node);
-		if (!match)
-			return -EINVAL;
-
-		chip->chip_type = (uintptr_t)match->data;
-	} else {
+	if (i2c->dev.of_node)
+		chip->chip_type = (uintptr_t)of_device_get_match_data(&i2c->dev);
+	else
 		chip->chip_type = id->driver_data;
-	}
 
 	i2c_set_clientdata(i2c, chip);
 	chip->dev = &i2c->dev;