diff options
Diffstat (limited to 'drivers/hwmon/lm70.c')
-rw-r--r-- | drivers/hwmon/lm70.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c index 472f79521a96..2d1777a03edb 100644 --- a/drivers/hwmon/lm70.c +++ b/drivers/hwmon/lm70.c @@ -43,6 +43,8 @@ #define LM70_CHIP_LM70 0 /* original NS LM70 */ #define LM70_CHIP_TMP121 1 /* TI TMP121/TMP123 */ +#define LM70_CHIP_LM71 2 /* NS LM71 */ +#define LM70_CHIP_LM74 3 /* NS LM74 */ struct lm70 { struct device *hwmon_dev; @@ -88,9 +90,13 @@ static ssize_t lm70_sense_temp(struct device *dev, * Celsius. * So it's equivalent to multiplying by 0.25 * 1000 = 250. * - * TMP121/TMP123: + * LM74 and TMP121/TMP123: * 13 bits of 2's complement data, discard LSB 3 bits, * resolution 0.0625 degrees celsius. + * + * LM71: + * 14 bits of 2's complement data, discard LSB 2 bits, + * resolution 0.0312 degrees celsius. */ switch (p_lm70->chip) { case LM70_CHIP_LM70: @@ -98,8 +104,13 @@ static ssize_t lm70_sense_temp(struct device *dev, break; case LM70_CHIP_TMP121: + case LM70_CHIP_LM74: val = ((int)raw / 8) * 625 / 10; break; + + case LM70_CHIP_LM71: + val = ((int)raw / 4) * 3125 / 100; + break; } status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */ @@ -113,20 +124,7 @@ static DEVICE_ATTR(temp1_input, S_IRUGO, lm70_sense_temp, NULL); static ssize_t lm70_show_name(struct device *dev, struct device_attribute *devattr, char *buf) { - struct lm70 *p_lm70 = dev_get_drvdata(dev); - int ret; - - switch (p_lm70->chip) { - case LM70_CHIP_LM70: - ret = sprintf(buf, "lm70\n"); - break; - case LM70_CHIP_TMP121: - ret = sprintf(buf, "tmp121\n"); - break; - default: - ret = -EINVAL; - } - return ret; + return sprintf(buf, "%s\n", to_spi_device(dev)->modalias); } static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL); @@ -139,17 +137,13 @@ static int __devinit lm70_probe(struct spi_device *spi) struct lm70 *p_lm70; int status; - /* signaling is SPI_MODE_0 for both LM70 and TMP121 */ + /* signaling is SPI_MODE_0 */ if (spi->mode & (SPI_CPOL | SPI_CPHA)) return -EINVAL; - /* 3-wire link (shared SI/SO) for LM70 */ - if (chip == LM70_CHIP_LM70 && !(spi->mode & SPI_3WIRE)) - return -EINVAL; - /* NOTE: we assume 8-bit words, and convert to 16 bits manually */ - p_lm70 = kzalloc(sizeof *p_lm70, GFP_KERNEL); + p_lm70 = devm_kzalloc(&spi->dev, sizeof(*p_lm70), GFP_KERNEL); if (!p_lm70) return -ENOMEM; @@ -181,7 +175,6 @@ out_dev_create_file_failed: device_remove_file(&spi->dev, &dev_attr_temp1_input); out_dev_create_temp_file_failed: spi_set_drvdata(spi, NULL); - kfree(p_lm70); return status; } @@ -193,7 +186,6 @@ static int __devexit lm70_remove(struct spi_device *spi) device_remove_file(&spi->dev, &dev_attr_temp1_input); device_remove_file(&spi->dev, &dev_attr_name); spi_set_drvdata(spi, NULL); - kfree(p_lm70); return 0; } @@ -202,6 +194,8 @@ static int __devexit lm70_remove(struct spi_device *spi) static const struct spi_device_id lm70_ids[] = { { "lm70", LM70_CHIP_LM70 }, { "tmp121", LM70_CHIP_TMP121 }, + { "lm71", LM70_CHIP_LM71 }, + { "lm74", LM70_CHIP_LM74 }, { }, }; MODULE_DEVICE_TABLE(spi, lm70_ids); @@ -219,5 +213,5 @@ static struct spi_driver lm70_driver = { module_spi_driver(lm70_driver); MODULE_AUTHOR("Kaiwan N Billimoria"); -MODULE_DESCRIPTION("NS LM70 / TI TMP121/TMP123 Linux driver"); +MODULE_DESCRIPTION("NS LM70 and compatibles Linux driver"); MODULE_LICENSE("GPL"); |