aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2012-01-27 01:58:39 -0500
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-03-26 12:40:55 -0400
commit27aefa3b7d8b1c37e0bc21cbd0ce3c93bdf163ca (patch)
tree78fb84a4cb9c092632ffc99ce34185c55ba1b4d5 /drivers/power
parent7da6334e73fe3c0579d8c6a56001336a430a5d99 (diff)
lp8727_charger: Change i2c functions
On writing single byte via i2c, use i2c_smbus_write_byte_data() rather than i2c_smbus_write_i2c_block_data(). Name changes : lp8727_i2c_read() -> lp8727_read_bytes() lp8727_i2c_write() -> removed lp8727_i2c_read_byte() -> lp8727_read_byte() lp8727_i2c_write_byte() -> lp8727_write_byte() Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/lp8727_charger.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c
index 6239bd7bcc2..1e8a98b29d8 100644
--- a/drivers/power/lp8727_charger.c
+++ b/drivers/power/lp8727_charger.c
@@ -92,7 +92,7 @@ struct lp8727_chg {
92 enum lp8727_dev_id devid; 92 enum lp8727_dev_id devid;
93}; 93};
94 94
95static int lp8727_i2c_read(struct lp8727_chg *pchg, u8 reg, u8 *data, u8 len) 95static int lp8727_read_bytes(struct lp8727_chg *pchg, u8 reg, u8 *data, u8 len)
96{ 96{
97 s32 ret; 97 s32 ret;
98 98
@@ -103,29 +103,22 @@ static int lp8727_i2c_read(struct lp8727_chg *pchg, u8 reg, u8 *data, u8 len)
103 return (ret != len) ? -EIO : 0; 103 return (ret != len) ? -EIO : 0;
104} 104}
105 105
106static int lp8727_i2c_write(struct lp8727_chg *pchg, u8 reg, u8 *data, u8 len) 106static inline int lp8727_read_byte(struct lp8727_chg *pchg, u8 reg, u8 *data)
107{ 107{
108 s32 ret; 108 return lp8727_read_bytes(pchg, reg, data, 1);
109}
110
111static int lp8727_write_byte(struct lp8727_chg *pchg, u8 reg, u8 data)
112{
113 int ret;
109 114
110 mutex_lock(&pchg->xfer_lock); 115 mutex_lock(&pchg->xfer_lock);
111 ret = i2c_smbus_write_i2c_block_data(pchg->client, reg, len, data); 116 ret = i2c_smbus_write_byte_data(pchg->client, reg, data);
112 mutex_unlock(&pchg->xfer_lock); 117 mutex_unlock(&pchg->xfer_lock);
113 118
114 return ret; 119 return ret;
115} 120}
116 121
117static inline int lp8727_i2c_read_byte(struct lp8727_chg *pchg, u8 reg,
118 u8 *data)
119{
120 return lp8727_i2c_read(pchg, reg, data, 1);
121}
122
123static inline int lp8727_i2c_write_byte(struct lp8727_chg *pchg, u8 reg,
124 u8 *data)
125{
126 return lp8727_i2c_write(pchg, reg, data, 1);
127}
128
129static int lp8727_is_charger_attached(const char *name, int id) 122static int lp8727_is_charger_attached(const char *name, int id)
130{ 123{
131 if (name) { 124 if (name) {
@@ -144,12 +137,12 @@ static int lp8727_init_device(struct lp8727_chg *pchg)
144 int ret; 137 int ret;
145 138
146 val = ID200_EN | ADC_EN | CP_EN; 139 val = ID200_EN | ADC_EN | CP_EN;
147 ret = lp8727_i2c_write_byte(pchg, CTRL1, &val); 140 ret = lp8727_write_byte(pchg, CTRL1, val);
148 if (ret) 141 if (ret)
149 return ret; 142 return ret;
150 143
151 val = INT_EN | CHGDET_EN; 144 val = INT_EN | CHGDET_EN;
152 ret = lp8727_i2c_write_byte(pchg, CTRL2, &val); 145 ret = lp8727_write_byte(pchg, CTRL2, val);
153 if (ret) 146 if (ret)
154 return ret; 147 return ret;
155 148
@@ -159,21 +152,20 @@ static int lp8727_init_device(struct lp8727_chg *pchg)
159static int lp8727_is_dedicated_charger(struct lp8727_chg *pchg) 152static int lp8727_is_dedicated_charger(struct lp8727_chg *pchg)
160{ 153{
161 u8 val; 154 u8 val;
162 lp8727_i2c_read_byte(pchg, STATUS1, &val); 155 lp8727_read_byte(pchg, STATUS1, &val);
163 return (val & DCPORT); 156 return (val & DCPORT);
164} 157}
165 158
166static int lp8727_is_usb_charger(struct lp8727_chg *pchg) 159static int lp8727_is_usb_charger(struct lp8727_chg *pchg)
167{ 160{
168 u8 val; 161 u8 val;
169 lp8727_i2c_read_byte(pchg, STATUS1, &val); 162 lp8727_read_byte(pchg, STATUS1, &val);
170 return (val & CHPORT); 163 return (val & CHPORT);
171} 164}
172 165
173static void lp8727_ctrl_switch(struct lp8727_chg *pchg, u8 sw) 166static void lp8727_ctrl_switch(struct lp8727_chg *pchg, u8 sw)
174{ 167{
175 u8 val = sw; 168 lp8727_write_byte(pchg, SWCTRL, sw);
176 lp8727_i2c_write_byte(pchg, SWCTRL, &val);
177} 169}
178 170
179static void lp8727_id_detection(struct lp8727_chg *pchg, u8 id, int vbusin) 171static void lp8727_id_detection(struct lp8727_chg *pchg, u8 id, int vbusin)
@@ -213,9 +205,9 @@ static void lp8727_enable_chgdet(struct lp8727_chg *pchg)
213{ 205{
214 u8 val; 206 u8 val;
215 207
216 lp8727_i2c_read_byte(pchg, CTRL2, &val); 208 lp8727_read_byte(pchg, CTRL2, &val);
217 val |= CHGDET_EN; 209 val |= CHGDET_EN;
218 lp8727_i2c_write_byte(pchg, CTRL2, &val); 210 lp8727_write_byte(pchg, CTRL2, val);
219} 211}
220 212
221static void lp8727_delayed_func(struct work_struct *_work) 213static void lp8727_delayed_func(struct work_struct *_work)
@@ -224,7 +216,7 @@ static void lp8727_delayed_func(struct work_struct *_work)
224 struct lp8727_chg *pchg = 216 struct lp8727_chg *pchg =
225 container_of(_work, struct lp8727_chg, work.work); 217 container_of(_work, struct lp8727_chg, work.work);
226 218
227 if (lp8727_i2c_read(pchg, INT1, intstat, 2)) { 219 if (lp8727_read_bytes(pchg, INT1, intstat, 2)) {
228 dev_err(pchg->dev, "can not read INT registers\n"); 220 dev_err(pchg->dev, "can not read INT registers\n");
229 return; 221 return;
230 } 222 }
@@ -308,7 +300,7 @@ static int lp8727_battery_get_property(struct power_supply *psy,
308 switch (psp) { 300 switch (psp) {
309 case POWER_SUPPLY_PROP_STATUS: 301 case POWER_SUPPLY_PROP_STATUS:
310 if (lp8727_is_charger_attached(psy->name, pchg->devid)) { 302 if (lp8727_is_charger_attached(psy->name, pchg->devid)) {
311 lp8727_i2c_read_byte(pchg, STATUS1, &read); 303 lp8727_read_byte(pchg, STATUS1, &read);
312 if (((read & CHGSTAT) >> 4) == EOC) 304 if (((read & CHGSTAT) >> 4) == EOC)
313 val->intval = POWER_SUPPLY_STATUS_FULL; 305 val->intval = POWER_SUPPLY_STATUS_FULL;
314 else 306 else
@@ -318,7 +310,7 @@ static int lp8727_battery_get_property(struct power_supply *psy,
318 } 310 }
319 break; 311 break;
320 case POWER_SUPPLY_PROP_HEALTH: 312 case POWER_SUPPLY_PROP_HEALTH:
321 lp8727_i2c_read_byte(pchg, STATUS2, &read); 313 lp8727_read_byte(pchg, STATUS2, &read);
322 read = (read & TEMP_STAT) >> 5; 314 read = (read & TEMP_STAT) >> 5;
323 if (read >= 0x1 && read <= 0x3) 315 if (read >= 0x1 && read <= 0x3)
324 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; 316 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
@@ -359,7 +351,7 @@ static void lp8727_charger_changed(struct power_supply *psy)
359 eoc_level = pchg->chg_parm->eoc_level; 351 eoc_level = pchg->chg_parm->eoc_level;
360 ichg = pchg->chg_parm->ichg; 352 ichg = pchg->chg_parm->ichg;
361 val = (ichg << 4) | eoc_level; 353 val = (ichg << 4) | eoc_level;
362 lp8727_i2c_write_byte(pchg, CHGCTRL2, &val); 354 lp8727_write_byte(pchg, CHGCTRL2, val);
363 } 355 }
364 } 356 }
365} 357}