diff options
Diffstat (limited to 'drivers/w1/slaves')
-rw-r--r-- | drivers/w1/slaves/w1_ds2780.c | 48 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_ds2780.h | 2 |
2 files changed, 37 insertions, 13 deletions
diff --git a/drivers/w1/slaves/w1_ds2780.c b/drivers/w1/slaves/w1_ds2780.c index a134b38e34b2..39f78c0b143c 100644 --- a/drivers/w1/slaves/w1_ds2780.c +++ b/drivers/w1/slaves/w1_ds2780.c | |||
@@ -26,20 +26,14 @@ | |||
26 | #include "../w1_family.h" | 26 | #include "../w1_family.h" |
27 | #include "w1_ds2780.h" | 27 | #include "w1_ds2780.h" |
28 | 28 | ||
29 | int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count, | 29 | static int w1_ds2780_do_io(struct device *dev, char *buf, int addr, |
30 | int io) | 30 | size_t count, int io) |
31 | { | 31 | { |
32 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | 32 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); |
33 | 33 | ||
34 | if (!dev) | 34 | if (addr > DS2780_DATA_SIZE || addr < 0) |
35 | return -ENODEV; | 35 | return 0; |
36 | 36 | ||
37 | mutex_lock(&sl->master->mutex); | ||
38 | |||
39 | if (addr > DS2780_DATA_SIZE || addr < 0) { | ||
40 | count = 0; | ||
41 | goto out; | ||
42 | } | ||
43 | count = min_t(int, count, DS2780_DATA_SIZE - addr); | 37 | count = min_t(int, count, DS2780_DATA_SIZE - addr); |
44 | 38 | ||
45 | if (w1_reset_select_slave(sl) == 0) { | 39 | if (w1_reset_select_slave(sl) == 0) { |
@@ -47,7 +41,6 @@ int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count, | |||
47 | w1_write_8(sl->master, W1_DS2780_WRITE_DATA); | 41 | w1_write_8(sl->master, W1_DS2780_WRITE_DATA); |
48 | w1_write_8(sl->master, addr); | 42 | w1_write_8(sl->master, addr); |
49 | w1_write_block(sl->master, buf, count); | 43 | w1_write_block(sl->master, buf, count); |
50 | /* XXX w1_write_block returns void, not n_written */ | ||
51 | } else { | 44 | } else { |
52 | w1_write_8(sl->master, W1_DS2780_READ_DATA); | 45 | w1_write_8(sl->master, W1_DS2780_READ_DATA); |
53 | w1_write_8(sl->master, addr); | 46 | w1_write_8(sl->master, addr); |
@@ -55,13 +48,42 @@ int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count, | |||
55 | } | 48 | } |
56 | } | 49 | } |
57 | 50 | ||
58 | out: | 51 | return count; |
52 | } | ||
53 | |||
54 | int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count, | ||
55 | int io) | ||
56 | { | ||
57 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | ||
58 | int ret; | ||
59 | |||
60 | if (!dev) | ||
61 | return -ENODEV; | ||
62 | |||
63 | mutex_lock(&sl->master->mutex); | ||
64 | |||
65 | ret = w1_ds2780_do_io(dev, buf, addr, count, io); | ||
66 | |||
59 | mutex_unlock(&sl->master->mutex); | 67 | mutex_unlock(&sl->master->mutex); |
60 | 68 | ||
61 | return count; | 69 | return ret; |
62 | } | 70 | } |
63 | EXPORT_SYMBOL(w1_ds2780_io); | 71 | EXPORT_SYMBOL(w1_ds2780_io); |
64 | 72 | ||
73 | int w1_ds2780_io_nolock(struct device *dev, char *buf, int addr, size_t count, | ||
74 | int io) | ||
75 | { | ||
76 | int ret; | ||
77 | |||
78 | if (!dev) | ||
79 | return -ENODEV; | ||
80 | |||
81 | ret = w1_ds2780_do_io(dev, buf, addr, count, io); | ||
82 | |||
83 | return ret; | ||
84 | } | ||
85 | EXPORT_SYMBOL(w1_ds2780_io_nolock); | ||
86 | |||
65 | int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd) | 87 | int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd) |
66 | { | 88 | { |
67 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | 89 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); |
diff --git a/drivers/w1/slaves/w1_ds2780.h b/drivers/w1/slaves/w1_ds2780.h index a1fba79eb1b5..737379365021 100644 --- a/drivers/w1/slaves/w1_ds2780.h +++ b/drivers/w1/slaves/w1_ds2780.h | |||
@@ -124,6 +124,8 @@ | |||
124 | 124 | ||
125 | extern int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count, | 125 | extern int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count, |
126 | int io); | 126 | int io); |
127 | extern int w1_ds2780_io_nolock(struct device *dev, char *buf, int addr, | ||
128 | size_t count, int io); | ||
127 | extern int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd); | 129 | extern int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd); |
128 | 130 | ||
129 | #endif /* !_W1_DS2780_H */ | 131 | #endif /* !_W1_DS2780_H */ |