diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 05:21:43 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-06 18:59:29 -0500 |
commit | 9ca3bd8022d76a0d1b386cedcecaf49004a58644 (patch) | |
tree | bc10df89bca5a34cf4b5410591e96188d80ef6df /drivers/leds/leds-lp5521.c | |
parent | e73c0ce6beaa71bee39b2d11bff0253be84c71a9 (diff) |
leds-lp55xx: code refactoring on selftest function
LP5521 and LP5523 have a selftest function which is run via the sysfs.
Use lp55xx driver data and R/W functions rather than lp5521/5523 private data
and functions.
Additionally, if-statements are changed for code simplicity.
Unused functions, lp5521/5523_read() are removed.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index abc33139e6fa..1f6d9c7eb4a2 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -168,18 +168,6 @@ static inline int lp5521_write(struct i2c_client *client, u8 reg, u8 value) | |||
168 | return i2c_smbus_write_byte_data(client, reg, value); | 168 | return i2c_smbus_write_byte_data(client, reg, value); |
169 | } | 169 | } |
170 | 170 | ||
171 | static int lp5521_read(struct i2c_client *client, u8 reg, u8 *buf) | ||
172 | { | ||
173 | s32 ret; | ||
174 | |||
175 | ret = i2c_smbus_read_byte_data(client, reg); | ||
176 | if (ret < 0) | ||
177 | return ret; | ||
178 | |||
179 | *buf = ret; | ||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | static void lp5521_load_engine(struct lp55xx_chip *chip) | 171 | static void lp5521_load_engine(struct lp55xx_chip *chip) |
184 | { | 172 | { |
185 | enum lp55xx_engine_index idx = chip->engine_idx; | 173 | enum lp55xx_engine_index idx = chip->engine_idx; |
@@ -378,19 +366,23 @@ static int lp5521_post_init_device(struct lp55xx_chip *chip) | |||
378 | return 0; | 366 | return 0; |
379 | } | 367 | } |
380 | 368 | ||
381 | static int lp5521_run_selftest(struct lp5521_chip *chip, char *buf) | 369 | static int lp5521_run_selftest(struct lp55xx_chip *chip, char *buf) |
382 | { | 370 | { |
371 | struct lp55xx_platform_data *pdata = chip->pdata; | ||
383 | int ret; | 372 | int ret; |
384 | u8 status; | 373 | u8 status; |
385 | 374 | ||
386 | ret = lp5521_read(chip->client, LP5521_REG_STATUS, &status); | 375 | ret = lp55xx_read(chip, LP5521_REG_STATUS, &status); |
387 | if (ret < 0) | 376 | if (ret < 0) |
388 | return ret; | 377 | return ret; |
389 | 378 | ||
379 | if (pdata->clock_mode != LP55XX_CLOCK_EXT) | ||
380 | return 0; | ||
381 | |||
390 | /* Check that ext clock is really in use if requested */ | 382 | /* Check that ext clock is really in use if requested */ |
391 | if (chip->pdata && chip->pdata->clock_mode == LP5521_CLOCK_EXT) | 383 | if ((status & LP5521_EXT_CLK_USED) == 0) |
392 | if ((status & LP5521_EXT_CLK_USED) == 0) | 384 | return -EIO; |
393 | return -EIO; | 385 | |
394 | return 0; | 386 | return 0; |
395 | } | 387 | } |
396 | 388 | ||
@@ -410,8 +402,8 @@ static ssize_t lp5521_selftest(struct device *dev, | |||
410 | struct device_attribute *attr, | 402 | struct device_attribute *attr, |
411 | char *buf) | 403 | char *buf) |
412 | { | 404 | { |
413 | struct i2c_client *client = to_i2c_client(dev); | 405 | struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); |
414 | struct lp5521_chip *chip = i2c_get_clientdata(client); | 406 | struct lp55xx_chip *chip = led->chip; |
415 | int ret; | 407 | int ret; |
416 | 408 | ||
417 | mutex_lock(&chip->lock); | 409 | mutex_lock(&chip->lock); |