Commit 00c0f9d3 authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Guenter Roeck
Browse files

hwmon: (lm85) 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: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent e97a45f1
Loading
Loading
Loading
Loading
+55 −1
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@
 */
 */


#include <linux/module.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/jiffies.h>
@@ -1552,6 +1553,9 @@ static int lm85_probe(struct i2c_client *client, const struct i2c_device_id *id)
		return -ENOMEM;
		return -ENOMEM;


	data->client = client;
	data->client = client;
	if (client->dev.of_node)
		data->type = (enum chips)of_device_get_match_data(&client->dev);
	else
		data->type = id->driver_data;
		data->type = id->driver_data;
	mutex_init(&data->update_lock);
	mutex_init(&data->update_lock);


@@ -1623,10 +1627,60 @@ static const struct i2c_device_id lm85_id[] = {
};
};
MODULE_DEVICE_TABLE(i2c, lm85_id);
MODULE_DEVICE_TABLE(i2c, lm85_id);


static const struct of_device_id lm85_of_match[] = {
	{
		.compatible = "adi,adm1027",
		.data = (void *)adm1027
	},
	{
		.compatible = "adi,adt7463",
		.data = (void *)adt7463
	},
	{
		.compatible = "adi,adt7468",
		.data = (void *)adt7468
	},
	{
		.compatible = "national,lm85",
		.data = (void *)lm85
	},
	{
		.compatible = "national,lm85b",
		.data = (void *)lm85
	},
	{
		.compatible = "national,lm85c",
		.data = (void *)lm85
	},
	{
		.compatible = "smsc,emc6d100",
		.data = (void *)emc6d100
	},
	{
		.compatible = "smsc,emc6d101",
		.data = (void *)emc6d100
	},
	{
		.compatible = "smsc,emc6d102",
		.data = (void *)emc6d102
	},
	{
		.compatible = "smsc,emc6d103",
		.data = (void *)emc6d103
	},
	{
		.compatible = "smsc,emc6d103s",
		.data = (void *)emc6d103s
	},
	{ },
};
MODULE_DEVICE_TABLE(of, lm85_of_match);

static struct i2c_driver lm85_driver = {
static struct i2c_driver lm85_driver = {
	.class		= I2C_CLASS_HWMON,
	.class		= I2C_CLASS_HWMON,
	.driver = {
	.driver = {
		.name   = "lm85",
		.name   = "lm85",
		.of_match_table = of_match_ptr(lm85_of_match),
	},
	},
	.probe		= lm85_probe,
	.probe		= lm85_probe,
	.id_table	= lm85_id,
	.id_table	= lm85_id,