Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: shtc1: add support for device tree bindings

Add support for DTS bindings for the sensirion shtc1,shtw1 and shtc3.

Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200815012227.32538-2-chris.ruehl@gtsys.com.hk
[groeck: Resolved conflicts]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Chris Ruehl and committed by
Guenter Roeck
be7373b6 65b2aad0

+22 -3
+22 -3
drivers/hwmon/shtc1.c
··· 14 14 #include <linux/err.h> 15 15 #include <linux/delay.h> 16 16 #include <linux/platform_data/shtc1.h> 17 + #include <linux/of.h> 17 18 18 19 /* commands (high precision mode) */ 19 20 static const unsigned char shtc1_cmd_measure_blocking_hpm[] = { 0x7C, 0xA2 }; ··· 198 197 enum shtcx_chips chip = i2c_match_id(shtc1_id, client)->driver_data; 199 198 struct i2c_adapter *adap = client->adapter; 200 199 struct device *dev = &client->dev; 200 + struct device_node *np = dev->of_node; 201 201 202 202 if (!i2c_check_functionality(adap, I2C_FUNC_I2C)) { 203 203 dev_err(dev, "plain i2c transactions not supported\n"); ··· 236 234 data->client = client; 237 235 data->chip = chip; 238 236 239 - if (client->dev.platform_data) 240 - data->setup = *(struct shtc1_platform_data *)dev->platform_data; 237 + if (np) { 238 + data->setup.blocking_io = of_property_read_bool(np, "sensirion,blocking-io"); 239 + data->setup.high_precision = !of_property_read_bool(np, "sensicon,low-precision"); 240 + } else { 241 + if (client->dev.platform_data) 242 + data->setup = *(struct shtc1_platform_data *)dev->platform_data; 243 + } 244 + 241 245 shtc1_select_command(data); 242 246 mutex_init(&data->update_lock); 243 247 ··· 266 258 }; 267 259 MODULE_DEVICE_TABLE(i2c, shtc1_id); 268 260 261 + static const struct of_device_id shtc1_of_match[] = { 262 + { .compatible = "sensirion,shtc1" }, 263 + { .compatible = "sensirion,shtw1" }, 264 + { .compatible = "sensirion,shtc3" }, 265 + { } 266 + }; 267 + MODULE_DEVICE_TABLE(of, shtc1_of_match); 268 + 269 269 static struct i2c_driver shtc1_i2c_driver = { 270 - .driver.name = "shtc1", 270 + .driver = { 271 + .name = "shtc1", 272 + .of_match_table = shtc1_of_match, 273 + }, 271 274 .probe_new = shtc1_probe, 272 275 .id_table = shtc1_id, 273 276 };