Re: [RFC/RFT PATCH] hwmon: (lm75) Hide register size differences in regmap access functions

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

 



On 12/18/24 04:46, Wolfram Sang wrote:
On Tue, Dec 17, 2024 at 02:52:10PM -0800, Guenter Roeck wrote:
Hide register size differences in regmap access functions to simplify
runtime code and to simplify adding support for I3C devices. Also
use regmap API functions for bit operations where possible.

Cc: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
---
This should help with adding I3C support.
Module tested only.

Does that mean 'build tested as a module only'?


No, it means tested by loading as module, simulating a LM75 using the SMBus
stub driver, and running a script on it testing the various attributes.
The scripts I use are at git@xxxxxxxxxx:groeck/module-tests.git.

With the following small patch on top, it works \o/ I suggest that I
will include your patch in my series for adding I3C support. I have a
few patches on top already. I think this makes dependency handling a bit
easier?


Makes sense. It needs more changes for chips with 16-bit addresses, though.
I'll send another version.


diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index f2550f623bee..1ef47ba6b458 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -653,6 +653,7 @@ static int lm75_probe(struct i2c_client *client)
  	if (!data)
  		return -ENOMEM;
+ /* Set this early. Our custom regmap callbacks need it */
  	dev_set_drvdata(dev, data);
data->client = client;
@@ -662,7 +663,7 @@ static int lm75_probe(struct i2c_client *client)
  	if (IS_ERR(data->vs))
  		return PTR_ERR(data->vs);
- data->regmap = devm_regmap_init_i2c(client, &lm75_regmap_config);
+	data->regmap = devm_regmap_init(&client->dev, NULL, data, &lm75_regmap_config);

If  devm_regmap_init_i2c() doesn't work, it would be better to define a
regmap_bus and use it to access the registers. This way the actual regmap
configuration would be the same for i2c and i3c, and only the regmap bus
would be different (or at least I hope so). I'll do that in the next version
of the patch.

Thanks,
Guenter





[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux