27 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/device.h>
39 #include <linux/slab.h>
42 #define DRVNAME "lm70"
44 #define LM70_CHIP_LM70 0
45 #define LM70_CHIP_TMP121 1
46 #define LM70_CHIP_LM71 2
47 #define LM70_CHIP_LM74 3
63 struct lm70 *p_lm70 = spi_get_drvdata(spi);
74 pr_warn(
"spi_write_then_read failed with status %d\n", status);
77 raw = (rxbuf[0] << 8) + rxbuf[1];
78 dev_dbg(dev,
"rxbuf[0] : 0x%02x rxbuf[1] : 0x%02x raw=0x%04x\n",
79 rxbuf[0], rxbuf[1], raw);
101 switch (p_lm70->
chip) {
103 val = ((
int)raw / 32) * 250;
108 val = ((
int)raw / 8) * 625 / 10;
112 val = ((
int)raw / 4) * 3125 / 100;
116 status =
sprintf(buf,
"%d\n", val);
127 return sprintf(buf,
"%s\n", to_spi_device(dev)->modalias);
153 spi_set_drvdata(spi, p_lm70);
157 goto out_dev_create_temp_file_failed;
160 goto out_dev_create_file_failed;
165 dev_dbg(&spi->
dev,
"hwmon_device_register failed.\n");
167 goto out_dev_reg_failed;
174 out_dev_create_file_failed:
176 out_dev_create_temp_file_failed:
177 spi_set_drvdata(spi,
NULL);
183 struct lm70 *p_lm70 = spi_get_drvdata(spi);
188 spi_set_drvdata(spi,
NULL);
208 .id_table = lm70_ids,