diff options
Diffstat (limited to 'drivers/mfd/88pm860x-i2c.c')
-rw-r--r-- | drivers/mfd/88pm860x-i2c.c | 66 |
1 files changed, 1 insertions, 65 deletions
diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c index a93b4d0134a2..84e313107233 100644 --- a/drivers/mfd/88pm860x-i2c.c +++ b/drivers/mfd/88pm860x-i2c.c | |||
@@ -122,7 +122,7 @@ static int read_device(struct i2c_client *i2c, int reg, | |||
122 | static int write_device(struct i2c_client *i2c, int reg, | 122 | static int write_device(struct i2c_client *i2c, int reg, |
123 | int bytes, void *src) | 123 | int bytes, void *src) |
124 | { | 124 | { |
125 | unsigned char buf[bytes + 1]; | 125 | unsigned char buf[2]; |
126 | struct i2c_adapter *adap = i2c->adapter; | 126 | struct i2c_adapter *adap = i2c->adapter; |
127 | struct i2c_msg msg; | 127 | struct i2c_msg msg; |
128 | int ret; | 128 | int ret; |
@@ -140,26 +140,6 @@ static int write_device(struct i2c_client *i2c, int reg, | |||
140 | return 0; | 140 | return 0; |
141 | } | 141 | } |
142 | 142 | ||
143 | int pm860x_page_reg_read(struct i2c_client *i2c, int reg) | ||
144 | { | ||
145 | unsigned char zero = 0; | ||
146 | unsigned char data; | ||
147 | int ret; | ||
148 | |||
149 | i2c_lock_adapter(i2c->adapter); | ||
150 | read_device(i2c, 0xFA, 0, &zero); | ||
151 | read_device(i2c, 0xFB, 0, &zero); | ||
152 | read_device(i2c, 0xFF, 0, &zero); | ||
153 | ret = read_device(i2c, reg, 1, &data); | ||
154 | if (ret >= 0) | ||
155 | ret = (int)data; | ||
156 | read_device(i2c, 0xFE, 0, &zero); | ||
157 | read_device(i2c, 0xFC, 0, &zero); | ||
158 | i2c_unlock_adapter(i2c->adapter); | ||
159 | return ret; | ||
160 | } | ||
161 | EXPORT_SYMBOL(pm860x_page_reg_read); | ||
162 | |||
163 | int pm860x_page_reg_write(struct i2c_client *i2c, int reg, | 143 | int pm860x_page_reg_write(struct i2c_client *i2c, int reg, |
164 | unsigned char data) | 144 | unsigned char data) |
165 | { | 145 | { |
@@ -195,47 +175,3 @@ int pm860x_page_bulk_read(struct i2c_client *i2c, int reg, | |||
195 | return ret; | 175 | return ret; |
196 | } | 176 | } |
197 | EXPORT_SYMBOL(pm860x_page_bulk_read); | 177 | EXPORT_SYMBOL(pm860x_page_bulk_read); |
198 | |||
199 | int pm860x_page_bulk_write(struct i2c_client *i2c, int reg, | ||
200 | int count, unsigned char *buf) | ||
201 | { | ||
202 | unsigned char zero = 0; | ||
203 | int ret; | ||
204 | |||
205 | i2c_lock_adapter(i2c->adapter); | ||
206 | read_device(i2c, 0xFA, 0, &zero); | ||
207 | read_device(i2c, 0xFB, 0, &zero); | ||
208 | read_device(i2c, 0xFF, 0, &zero); | ||
209 | ret = write_device(i2c, reg, count, buf); | ||
210 | read_device(i2c, 0xFE, 0, &zero); | ||
211 | read_device(i2c, 0xFC, 0, &zero); | ||
212 | i2c_unlock_adapter(i2c->adapter); | ||
213 | i2c_unlock_adapter(i2c->adapter); | ||
214 | return ret; | ||
215 | } | ||
216 | EXPORT_SYMBOL(pm860x_page_bulk_write); | ||
217 | |||
218 | int pm860x_page_set_bits(struct i2c_client *i2c, int reg, | ||
219 | unsigned char mask, unsigned char data) | ||
220 | { | ||
221 | unsigned char zero; | ||
222 | unsigned char value; | ||
223 | int ret; | ||
224 | |||
225 | i2c_lock_adapter(i2c->adapter); | ||
226 | read_device(i2c, 0xFA, 0, &zero); | ||
227 | read_device(i2c, 0xFB, 0, &zero); | ||
228 | read_device(i2c, 0xFF, 0, &zero); | ||
229 | ret = read_device(i2c, reg, 1, &value); | ||
230 | if (ret < 0) | ||
231 | goto out; | ||
232 | value &= ~mask; | ||
233 | value |= data; | ||
234 | ret = write_device(i2c, reg, 1, &value); | ||
235 | out: | ||
236 | read_device(i2c, 0xFE, 0, &zero); | ||
237 | read_device(i2c, 0xFC, 0, &zero); | ||
238 | i2c_unlock_adapter(i2c->adapter); | ||
239 | return ret; | ||
240 | } | ||
241 | EXPORT_SYMBOL(pm860x_page_set_bits); | ||