summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 14:21:43 +0400
committerBryan Wu <cooloney@gmail.com>2013-02-07 03:59:29 +0400
commit9ca3bd8022d76a0d1b386cedcecaf49004a58644 (patch)
treebc10df89bca5a34cf4b5410591e96188d80ef6df /drivers/leds/leds-lp5521.c
parente73c0ce6beaa71bee39b2d11bff0253be84c71a9 (diff)
downloadlinux-9ca3bd8022d76a0d1b386cedcecaf49004a58644.tar.xz
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.c30
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)
return i2c_smbus_write_byte_data(client, reg, value);
}
-static int lp5521_read(struct i2c_client *client, u8 reg, u8 *buf)
-{
- s32 ret;
-
- ret = i2c_smbus_read_byte_data(client, reg);
- if (ret < 0)
- return ret;
-
- *buf = ret;
- return 0;
-}
-
static void lp5521_load_engine(struct lp55xx_chip *chip)
{
enum lp55xx_engine_index idx = chip->engine_idx;
@@ -378,19 +366,23 @@ static int lp5521_post_init_device(struct lp55xx_chip *chip)
return 0;
}
-static int lp5521_run_selftest(struct lp5521_chip *chip, char *buf)
+static int lp5521_run_selftest(struct lp55xx_chip *chip, char *buf)
{
+ struct lp55xx_platform_data *pdata = chip->pdata;
int ret;
u8 status;
- ret = lp5521_read(chip->client, LP5521_REG_STATUS, &status);
+ ret = lp55xx_read(chip, LP5521_REG_STATUS, &status);
if (ret < 0)
return ret;
+ if (pdata->clock_mode != LP55XX_CLOCK_EXT)
+ return 0;
+
/* Check that ext clock is really in use if requested */
- if (chip->pdata && chip->pdata->clock_mode == LP5521_CLOCK_EXT)
- if ((status & LP5521_EXT_CLK_USED) == 0)
- return -EIO;
+ if ((status & LP5521_EXT_CLK_USED) == 0)
+ return -EIO;
+
return 0;
}
@@ -410,8 +402,8 @@ static ssize_t lp5521_selftest(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct i2c_client *client = to_i2c_client(dev);
- struct lp5521_chip *chip = i2c_get_clientdata(client);
+ struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
+ struct lp55xx_chip *chip = led->chip;
int ret;
mutex_lock(&chip->lock);