38 #include <linux/module.h>
39 #include <linux/kernel.h>
40 #include <linux/slab.h>
41 #include <linux/device.h>
50 #define DRVNAME "adcxx"
65 struct adcxx *
adc = spi_get_drvdata(spi);
75 status = spi_read(spi, rx_buf,
sizeof(rx_buf));
77 tx_buf[0] = attr->
index << 3;
79 rx_buf,
sizeof(rx_buf));
82 dev_warn(dev,
"SPI synch. transfer failed with status %d\n",
87 value = (rx_buf[0] << 8) + rx_buf[1];
88 dev_dbg(dev,
"raw value = 0x%x\n", value);
91 status =
sprintf(buf,
"%d\n", value);
108 struct adcxx *adc = spi_get_drvdata(spi);
118 return sprintf(buf,
"%d\n", reference);
125 struct adcxx *adc = spi_get_drvdata(spi);
128 if (kstrtoul(buf, 10, &value))
144 return sprintf(buf,
"%s\n", to_spi_device(dev)->modalias);
182 spi_set_drvdata(spi, adc);
184 for (i = 0; i < 3 + adc->
channels; i++) {
187 dev_err(&spi->
dev,
"device_create_file failed.\n");
194 dev_err(&spi->
dev,
"hwmon_device_register failed.\n");
203 for (i--; i >= 0; i--)
206 spi_set_drvdata(spi,
NULL);
213 struct adcxx *adc = spi_get_drvdata(spi);
218 for (i = 0; i < 3 + adc->
channels; i++)
221 spi_set_drvdata(spi,
NULL);
241 .id_table = adcxx_ids,
242 .probe = adcxx_probe,