return sprintf(buf, "%s\n", ret ? "FAIL" : "OK");
}
-static void lp5521_clear_program_memory(struct i2c_client *cl)
-{
- int i;
- u8 rgb_mem[] = {
- LP5521_REG_R_PROG_MEM,
- LP5521_REG_G_PROG_MEM,
- LP5521_REG_B_PROG_MEM,
- };
-
- for (i = 0; i < ARRAY_SIZE(rgb_mem); i++) {
- lp5521_write(cl, rgb_mem[i], 0);
- lp5521_write(cl, rgb_mem[i] + 1, 0);
- }
-}
-
-static void lp5521_write_program_memory(struct i2c_client *cl,
- u8 base, u8 *rgb, int size)
-{
- int i;
-
- if (!rgb || size <= 0)
- return;
-
- for (i = 0; i < size; i++)
- lp5521_write(cl, base + i, *(rgb + i));
-
- lp5521_write(cl, base + i, 0);
- lp5521_write(cl, base + i + 1, 0);
-}
-
static inline struct lp5521_led_pattern *lp5521_get_pattern
(struct lp5521_chip *chip, u8 offset)
{
return ptn;
}
-static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
-{
- struct lp5521_led_pattern *ptn;
- struct i2c_client *cl = chip->client;
- int num_patterns = chip->pdata->num_patterns;
-
- if (mode > num_patterns || !(chip->pdata->patterns))
- return;
-
- if (mode == PATTERN_OFF) {
- lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
- usleep_range(1000, 2000);
- lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
- } else {
- ptn = lp5521_get_pattern(chip, mode);
- if (!ptn)
- return;
-
- lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_LOAD);
- usleep_range(1000, 2000);
-
- lp5521_clear_program_memory(cl);
-
- lp5521_write_program_memory(cl, LP5521_REG_R_PROG_MEM,
- ptn->r, ptn->size_r);
- lp5521_write_program_memory(cl, LP5521_REG_G_PROG_MEM,
- ptn->g, ptn->size_g);
- lp5521_write_program_memory(cl, LP5521_REG_B_PROG_MEM,
- ptn->b, ptn->size_b);
-
- lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN);
- usleep_range(1000, 2000);
- lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
- }
-}
-
/* device attributes */
static DEVICE_ATTR(selftest, S_IRUGO, lp5521_selftest, NULL);
.attrs = lp5521_attributes,
};
-static void lp5521_unregister_sysfs(struct i2c_client *client)
-{
- struct device *dev = &client->dev;
-
- sysfs_remove_group(&dev->kobj, &lp5521_group);
-}
-
/* Chip specific configurations */
static struct lp55xx_device_config lp5521_cfg = {
.reset = {
static int lp5521_remove(struct i2c_client *client)
{
- struct lp5521_chip *old_chip = i2c_get_clientdata(client);
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;
- lp5521_run_led_pattern(PATTERN_OFF, old_chip);
- lp5521_unregister_sysfs(client);
-
+ lp5521_stop_engine(chip);
+ lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);
led_current);
}
-static int lp5523_write(struct i2c_client *client, u8 reg, u8 value)
-{
- return i2c_smbus_write_byte_data(client, reg, value);
-}
-
static int lp5523_post_init_device(struct lp55xx_chip *chip)
{
int ret;
.attrs = lp5523_attributes,
};
-static void lp5523_unregister_sysfs(struct i2c_client *client)
-{
- struct device *dev = &client->dev;
-
- sysfs_remove_group(&dev->kobj, &lp5523_group);
-}
-
/* Chip specific configurations */
static struct lp55xx_device_config lp5523_cfg = {
.reset = {
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;
- /* Disable engine mode */
- lp5523_write(client, LP5523_REG_OP_MODE, LP5523_CMD_DISABLED);
-
- lp5523_unregister_sysfs(client);
-
+ lp5523_stop_engine(chip);
+ lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);