diff mbox series

iio: adc: ti-adc081c: Simplify probe()

Message ID 20230902162633.50546-1-biju.das.jz@bp.renesas.com (mailing list archive)
State Accepted
Headers show
Series iio: adc: ti-adc081c: Simplify probe() | expand

Commit Message

Biju Das Sept. 2, 2023, 4:26 p.m. UTC
Simpilfy probe() by replacing of_device_get_match_data() and id lookup for
retrieving match data by using i2c_get_match_data() by making similar
OF/I2C/ACPI match tables.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/iio/adc/ti-adc081c.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Jonathan Cameron Sept. 3, 2023, 12:03 p.m. UTC | #1
On Sat,  2 Sep 2023 17:26:33 +0100
Biju Das <biju.das.jz@bp.renesas.com> wrote:

> Simpilfy probe() by replacing of_device_get_match_data() and id lookup for
> retrieving match data by using i2c_get_match_data() by making similar
> OF/I2C/ACPI match tables.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Applied to the togreg branch of iio.git and pushed out as testing
for all the normal reasons.

Thanks

Jonathan

> ---
>  drivers/iio/adc/ti-adc081c.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c
> index 50c450e7a55f..6c2cb3dabbbf 100644
> --- a/drivers/iio/adc/ti-adc081c.c
> +++ b/drivers/iio/adc/ti-adc081c.c
> @@ -154,7 +154,6 @@ static void adc081c_reg_disable(void *reg)
>  
>  static int adc081c_probe(struct i2c_client *client)
>  {
> -	const struct i2c_device_id *id = i2c_client_get_device_id(client);
>  	struct iio_dev *iio;
>  	struct adc081c *adc;
>  	const struct adcxx1c_model *model;
> @@ -163,10 +162,7 @@ static int adc081c_probe(struct i2c_client *client)
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
>  		return -EOPNOTSUPP;
>  
> -	if (dev_fwnode(&client->dev))
> -		model = device_get_match_data(&client->dev);
> -	else
> -		model = &adcxx1c_models[id->driver_data];
> +	model = i2c_get_match_data(client);
>  
>  	iio = devm_iio_device_alloc(&client->dev, sizeof(*adc));
>  	if (!iio)
> @@ -207,9 +203,9 @@ static int adc081c_probe(struct i2c_client *client)
>  }
>  
>  static const struct i2c_device_id adc081c_id[] = {
> -	{ "adc081c", ADC081C },
> -	{ "adc101c", ADC101C },
> -	{ "adc121c", ADC121C },
> +	{ "adc081c", (kernel_ulong_t)&adcxx1c_models[ADC081C] },
> +	{ "adc101c", (kernel_ulong_t)&adcxx1c_models[ADC101C] },
> +	{ "adc121c", (kernel_ulong_t)&adcxx1c_models[ADC121C] },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(i2c, adc081c_id);
diff mbox series

Patch

diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c
index 50c450e7a55f..6c2cb3dabbbf 100644
--- a/drivers/iio/adc/ti-adc081c.c
+++ b/drivers/iio/adc/ti-adc081c.c
@@ -154,7 +154,6 @@  static void adc081c_reg_disable(void *reg)
 
 static int adc081c_probe(struct i2c_client *client)
 {
-	const struct i2c_device_id *id = i2c_client_get_device_id(client);
 	struct iio_dev *iio;
 	struct adc081c *adc;
 	const struct adcxx1c_model *model;
@@ -163,10 +162,7 @@  static int adc081c_probe(struct i2c_client *client)
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
 		return -EOPNOTSUPP;
 
-	if (dev_fwnode(&client->dev))
-		model = device_get_match_data(&client->dev);
-	else
-		model = &adcxx1c_models[id->driver_data];
+	model = i2c_get_match_data(client);
 
 	iio = devm_iio_device_alloc(&client->dev, sizeof(*adc));
 	if (!iio)
@@ -207,9 +203,9 @@  static int adc081c_probe(struct i2c_client *client)
 }
 
 static const struct i2c_device_id adc081c_id[] = {
-	{ "adc081c", ADC081C },
-	{ "adc101c", ADC101C },
-	{ "adc121c", ADC121C },
+	{ "adc081c", (kernel_ulong_t)&adcxx1c_models[ADC081C] },
+	{ "adc101c", (kernel_ulong_t)&adcxx1c_models[ADC101C] },
+	{ "adc121c", (kernel_ulong_t)&adcxx1c_models[ADC121C] },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, adc081c_id);