Re: [PATCH] rtc: pcf2127: Simplify probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28/08/2023 10:51:16+0100, Biju Das wrote:
> Make similar OF and ID table for I2C and 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@xxxxxxxxxxxxxx>
> ---
> Note:
>  * This patch is only compile tested.

I would really prefer those kind of patches to be actually tested. Else,
I'm going to end up with 60 patches that may or may not break probing.

> ---
>  drivers/rtc/rtc-pcf2127.c | 33 ++++++++++++---------------------
>  1 file changed, 12 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> index 9c04c4e1a49c..ec3968e3b8ac 100644
> --- a/drivers/rtc/rtc-pcf2127.c
> +++ b/drivers/rtc/rtc-pcf2127.c
> @@ -1349,15 +1349,6 @@ static const struct regmap_bus pcf2127_i2c_regmap = {
>  
>  static struct i2c_driver pcf2127_i2c_driver;
>  
> -static const struct i2c_device_id pcf2127_i2c_id[] = {
> -	{ "pcf2127", PCF2127 },
> -	{ "pcf2129", PCF2129 },
> -	{ "pca2129", PCF2129 },
> -	{ "pcf2131", PCF2131 },
> -	{ }
> -};
> -MODULE_DEVICE_TABLE(i2c, pcf2127_i2c_id);
> -
>  static int pcf2127_i2c_probe(struct i2c_client *client)
>  {
>  	struct regmap *regmap;
> @@ -1370,18 +1361,9 @@ static int pcf2127_i2c_probe(struct i2c_client *client)
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
>  		return -ENODEV;
>  
> -	if (client->dev.of_node) {
> -		variant = of_device_get_match_data(&client->dev);
> -		if (!variant)
> -			return -ENODEV;
> -	} else {
> -		enum pcf21xx_type type =
> -			i2c_match_id(pcf2127_i2c_id, client)->driver_data;
> -
> -		if (type >= PCF21XX_LAST_ID)
> -			return -ENODEV;
> -		variant = &pcf21xx_cfg[type];
> -	}
> +	variant = i2c_get_match_data(client);
> +	if (!variant)
> +		return -ENODEV;
>  
>  	config.max_register = variant->max_register,
>  
> @@ -1396,6 +1378,15 @@ static int pcf2127_i2c_probe(struct i2c_client *client)
>  	return pcf2127_probe(&client->dev, regmap, client->irq, variant);
>  }
>  
> +static const struct i2c_device_id pcf2127_i2c_id[] = {
> +	{ "pcf2127", (kernel_ulong_t)&pcf21xx_cfg[PCF2127] },
> +	{ "pcf2129", (kernel_ulong_t)&pcf21xx_cfg[PCF2129] },
> +	{ "pca2129", (kernel_ulong_t)&pcf21xx_cfg[PCF2129] },
> +	{ "pcf2131", (kernel_ulong_t)&pcf21xx_cfg[PCF2131] },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(i2c, pcf2127_i2c_id);
> +
>  static struct i2c_driver pcf2127_i2c_driver = {
>  	.driver		= {
>  		.name	= "rtc-pcf2127-i2c",
> -- 
> 2.25.1
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux