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

hwmon: (lm75) 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
e97a45f1 b25f663b

+97 -1
+97 -1
drivers/hwmon/lm75.c
··· 26 26 #include <linux/hwmon.h> 27 27 #include <linux/hwmon-sysfs.h> 28 28 #include <linux/err.h> 29 + #include <linux/of_device.h> 29 30 #include <linux/of.h> 30 31 #include <linux/regmap.h> 31 32 #include "lm75.h" ··· 274 273 int status, err; 275 274 u8 set_mask, clr_mask; 276 275 int new; 277 - enum lm75_type kind = id->driver_data; 276 + enum lm75_type kind; 277 + 278 + if (client->dev.of_node) 279 + kind = (enum lm75_type)of_device_get_match_data(&client->dev); 280 + else 281 + kind = id->driver_data; 278 282 279 283 if (!i2c_check_functionality(client->adapter, 280 284 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) ··· 430 424 }; 431 425 MODULE_DEVICE_TABLE(i2c, lm75_ids); 432 426 427 + static const struct of_device_id lm75_of_match[] = { 428 + { 429 + .compatible = "adi,adt75", 430 + .data = (void *)adt75 431 + }, 432 + { 433 + .compatible = "dallas,ds1775", 434 + .data = (void *)ds1775 435 + }, 436 + { 437 + .compatible = "dallas,ds75", 438 + .data = (void *)ds75 439 + }, 440 + { 441 + .compatible = "dallas,ds7505", 442 + .data = (void *)ds7505 443 + }, 444 + { 445 + .compatible = "gmt,g751", 446 + .data = (void *)g751 447 + }, 448 + { 449 + .compatible = "national,lm75", 450 + .data = (void *)lm75 451 + }, 452 + { 453 + .compatible = "national,lm75a", 454 + .data = (void *)lm75a 455 + }, 456 + { 457 + .compatible = "national,lm75b", 458 + .data = (void *)lm75b 459 + }, 460 + { 461 + .compatible = "maxim,max6625", 462 + .data = (void *)max6625 463 + }, 464 + { 465 + .compatible = "maxim,max6626", 466 + .data = (void *)max6626 467 + }, 468 + { 469 + .compatible = "maxim,mcp980x", 470 + .data = (void *)mcp980x 471 + }, 472 + { 473 + .compatible = "st,stds75", 474 + .data = (void *)stds75 475 + }, 476 + { 477 + .compatible = "microchip,tcn75", 478 + .data = (void *)tcn75 479 + }, 480 + { 481 + .compatible = "ti,tmp100", 482 + .data = (void *)tmp100 483 + }, 484 + { 485 + .compatible = "ti,tmp101", 486 + .data = (void *)tmp101 487 + }, 488 + { 489 + .compatible = "ti,tmp105", 490 + .data = (void *)tmp105 491 + }, 492 + { 493 + .compatible = "ti,tmp112", 494 + .data = (void *)tmp112 495 + }, 496 + { 497 + .compatible = "ti,tmp175", 498 + .data = (void *)tmp175 499 + }, 500 + { 501 + .compatible = "ti,tmp275", 502 + .data = (void *)tmp275 503 + }, 504 + { 505 + .compatible = "ti,tmp75", 506 + .data = (void *)tmp75 507 + }, 508 + { 509 + .compatible = "ti,tmp75c", 510 + .data = (void *)tmp75c 511 + }, 512 + { }, 513 + }; 514 + MODULE_DEVICE_TABLE(of, lm75_of_match); 515 + 433 516 #define LM75A_ID 0xA1 434 517 435 518 /* Return 0 if detection is successful, -ENODEV otherwise */ ··· 655 560 .class = I2C_CLASS_HWMON, 656 561 .driver = { 657 562 .name = "lm75", 563 + .of_match_table = of_match_ptr(lm75_of_match), 658 564 .pm = LM75_DEV_PM_OPS, 659 565 }, 660 566 .probe = lm75_probe,