16 #include <linux/module.h>
17 #include <linux/kernel.h>
23 #include <linux/slab.h>
27 #define MAX1111_TX_BUF_SIZE 1
28 #define MAX1111_RX_BUF_SIZE 2
31 #define MAX1111_CTRL_PD0 (1u << 0)
32 #define MAX1111_CTRL_PD1 (1u << 1)
33 #define MAX1111_CTRL_SGL (1u << 2)
34 #define MAX1111_CTRL_UNI (1u << 3)
35 #define MAX1110_CTRL_SEL_SH (4)
36 #define MAX1111_CTRL_SEL_SH (5)
37 #define MAX1111_CTRL_STR (1u << 7)
67 dev_err(dev,
"spi_sync failed with %d\n", err);
77 if ((v1 & 0xc0) || (v2 & 0x3f))
80 return (v1 << 2) | (v2 >> 6);
83 #ifdef CONFIG_SHARPSL_PM
88 return max1111_read(&the_max1111->
spi->dev, channel);
101 return sprintf(buf,
"%s\n", to_spi_device(dev)->modalias);
111 ret = max1111_read(dev, channel);
122 #define MAX1111_ADC_ATTR(_id) \
123 SENSOR_DEVICE_ATTR(in##_id##_input, S_IRUGO, show_adc, NULL, _id)
135 static struct attribute *max1111_attributes[] = {
137 &sensor_dev_attr_in0_input.dev_attr.attr,
138 &sensor_dev_attr_in1_input.dev_attr.attr,
139 &sensor_dev_attr_in2_input.dev_attr.attr,
140 &sensor_dev_attr_in3_input.dev_attr.attr,
145 .attrs = max1111_attributes,
148 static struct attribute *max1110_attributes[] = {
149 &sensor_dev_attr_in4_input.dev_attr.attr,
150 &sensor_dev_attr_in5_input.dev_attr.attr,
151 &sensor_dev_attr_in6_input.dev_attr.attr,
152 &sensor_dev_attr_in7_input.dev_attr.attr,
157 .attrs = max1110_attributes,
172 spi_message_add_tail(x, m);
177 spi_message_add_tail(x, m);
196 dev_err(&spi->
dev,
"failed to allocate memory\n");
218 err = setup_transfer(data);
225 spi_set_drvdata(spi, data);
229 dev_err(&spi->
dev,
"failed to create attribute group\n");
236 "failed to create extended attribute group\n");
243 dev_err(&spi->
dev,
"failed to create hwmon device\n");
248 #ifdef CONFIG_SHARPSL_PM
284 .id_table = max1111_ids,
285 .probe = max1111_probe,