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

hwmon: (lm90) Add OF device ID table

The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Javier Martinez Canillas and committed by
Guenter Roeck
df8d57bf 00c0f9d3

+99 -1
+99 -1
drivers/hwmon/lm90.c
··· 92 92 #include <linux/hwmon.h> 93 93 #include <linux/err.h> 94 94 #include <linux/mutex.h> 95 + #include <linux/of_device.h> 95 96 #include <linux/sysfs.h> 96 97 #include <linux/interrupt.h> 97 98 #include <linux/regulator/consumer.h> ··· 235 234 { } 236 235 }; 237 236 MODULE_DEVICE_TABLE(i2c, lm90_id); 237 + 238 + static const struct of_device_id lm90_of_match[] = { 239 + { 240 + .compatible = "adi,adm1032", 241 + .data = (void *)adm1032 242 + }, 243 + { 244 + .compatible = "adi,adt7461", 245 + .data = (void *)adt7461 246 + }, 247 + { 248 + .compatible = "adi,adt7461a", 249 + .data = (void *)adt7461 250 + }, 251 + { 252 + .compatible = "gmt,g781", 253 + .data = (void *)g781 254 + }, 255 + { 256 + .compatible = "national,lm90", 257 + .data = (void *)lm90 258 + }, 259 + { 260 + .compatible = "national,lm86", 261 + .data = (void *)lm86 262 + }, 263 + { 264 + .compatible = "national,lm89", 265 + .data = (void *)lm86 266 + }, 267 + { 268 + .compatible = "national,lm99", 269 + .data = (void *)lm99 270 + }, 271 + { 272 + .compatible = "dallas,max6646", 273 + .data = (void *)max6646 274 + }, 275 + { 276 + .compatible = "dallas,max6647", 277 + .data = (void *)max6646 278 + }, 279 + { 280 + .compatible = "dallas,max6649", 281 + .data = (void *)max6646 282 + }, 283 + { 284 + .compatible = "dallas,max6657", 285 + .data = (void *)max6657 286 + }, 287 + { 288 + .compatible = "dallas,max6658", 289 + .data = (void *)max6657 290 + }, 291 + { 292 + .compatible = "dallas,max6659", 293 + .data = (void *)max6659 294 + }, 295 + { 296 + .compatible = "dallas,max6680", 297 + .data = (void *)max6680 298 + }, 299 + { 300 + .compatible = "dallas,max6681", 301 + .data = (void *)max6680 302 + }, 303 + { 304 + .compatible = "dallas,max6695", 305 + .data = (void *)max6696 306 + }, 307 + { 308 + .compatible = "dallas,max6696", 309 + .data = (void *)max6696 310 + }, 311 + { 312 + .compatible = "onnn,nct1008", 313 + .data = (void *)adt7461 314 + }, 315 + { 316 + .compatible = "winbond,w83l771", 317 + .data = (void *)w83l771 318 + }, 319 + { 320 + .compatible = "nxp,sa56004", 321 + .data = (void *)sa56004 322 + }, 323 + { 324 + .compatible = "ti,tmp451", 325 + .data = (void *)tmp451 326 + }, 327 + { }, 328 + }; 329 + MODULE_DEVICE_TABLE(of, lm90_of_match); 238 330 239 331 /* 240 332 * chip type specific parameters ··· 1771 1677 mutex_init(&data->update_lock); 1772 1678 1773 1679 /* Set the device type */ 1774 - data->kind = id->driver_data; 1680 + if (client->dev.of_node) 1681 + data->kind = (enum chips)of_device_get_match_data(&client->dev); 1682 + else 1683 + data->kind = id->driver_data; 1775 1684 if (data->kind == adm1032) { 1776 1685 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) 1777 1686 client->flags &= ~I2C_CLIENT_PEC; ··· 1913 1816 .class = I2C_CLASS_HWMON, 1914 1817 .driver = { 1915 1818 .name = "lm90", 1819 + .of_match_table = of_match_ptr(lm90_of_match), 1916 1820 }, 1917 1821 .probe = lm90_probe, 1918 1822 .alert = lm90_alert,