Эх сурвалжийг харах

leds: lp55xx: Remove work queue

Now the core implements the work queue, remove it from the drivers,
and switch to using brightness_set_blocking op.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Milo Kim <milo.kim@ti.com>
Andrew Lunn 10 жил өмнө
parent
commit
95b2af637e

+ 6 - 5
drivers/leds/leds-lp5521.c

@@ -362,16 +362,17 @@ static int lp5521_run_selftest(struct lp55xx_chip *chip, char *buf)
 	return 0;
 	return 0;
 }
 }
 
 
-static void lp5521_led_brightness_work(struct work_struct *work)
+static int lp5521_led_brightness(struct lp55xx_led *led)
 {
 {
-	struct lp55xx_led *led = container_of(work, struct lp55xx_led,
-					      brightness_work);
 	struct lp55xx_chip *chip = led->chip;
 	struct lp55xx_chip *chip = led->chip;
+	int ret;
 
 
 	mutex_lock(&chip->lock);
 	mutex_lock(&chip->lock);
-	lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr,
+	ret = lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr,
 		led->brightness);
 		led->brightness);
 	mutex_unlock(&chip->lock);
 	mutex_unlock(&chip->lock);
+
+	return ret;
 }
 }
 
 
 static ssize_t show_engine_mode(struct device *dev,
 static ssize_t show_engine_mode(struct device *dev,
@@ -501,7 +502,7 @@ static struct lp55xx_device_config lp5521_cfg = {
 	},
 	},
 	.max_channel  = LP5521_MAX_LEDS,
 	.max_channel  = LP5521_MAX_LEDS,
 	.post_init_device   = lp5521_post_init_device,
 	.post_init_device   = lp5521_post_init_device,
-	.brightness_work_fn = lp5521_led_brightness_work,
+	.brightness_fn      = lp5521_led_brightness,
 	.set_led_current    = lp5521_set_led_current,
 	.set_led_current    = lp5521_set_led_current,
 	.firmware_cb        = lp5521_firmware_loaded,
 	.firmware_cb        = lp5521_firmware_loaded,
 	.run_engine         = lp5521_run_engine,
 	.run_engine         = lp5521_run_engine,

+ 5 - 5
drivers/leds/leds-lp5523.c

@@ -802,16 +802,16 @@ leave:
 	return ret;
 	return ret;
 }
 }
 
 
-static void lp5523_led_brightness_work(struct work_struct *work)
+static int lp5523_led_brightness(struct lp55xx_led *led)
 {
 {
-	struct lp55xx_led *led = container_of(work, struct lp55xx_led,
-					      brightness_work);
 	struct lp55xx_chip *chip = led->chip;
 	struct lp55xx_chip *chip = led->chip;
+	int ret;
 
 
 	mutex_lock(&chip->lock);
 	mutex_lock(&chip->lock);
-	lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr,
+	ret = lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr,
 		     led->brightness);
 		     led->brightness);
 	mutex_unlock(&chip->lock);
 	mutex_unlock(&chip->lock);
+	return ret;
 }
 }
 
 
 static LP55XX_DEV_ATTR_RW(engine1_mode, show_engine1_mode, store_engine1_mode);
 static LP55XX_DEV_ATTR_RW(engine1_mode, show_engine1_mode, store_engine1_mode);
@@ -867,7 +867,7 @@ static struct lp55xx_device_config lp5523_cfg = {
 	},
 	},
 	.max_channel  = LP5523_MAX_LEDS,
 	.max_channel  = LP5523_MAX_LEDS,
 	.post_init_device   = lp5523_post_init_device,
 	.post_init_device   = lp5523_post_init_device,
-	.brightness_work_fn = lp5523_led_brightness_work,
+	.brightness_fn      = lp5523_led_brightness,
 	.set_led_current    = lp5523_set_led_current,
 	.set_led_current    = lp5523_set_led_current,
 	.firmware_cb        = lp5523_firmware_loaded,
 	.firmware_cb        = lp5523_firmware_loaded,
 	.run_engine         = lp5523_run_engine,
 	.run_engine         = lp5523_run_engine,

+ 6 - 5
drivers/leds/leds-lp5562.c

@@ -311,10 +311,8 @@ static int lp5562_post_init_device(struct lp55xx_chip *chip)
 	return 0;
 	return 0;
 }
 }
 
 
-static void lp5562_led_brightness_work(struct work_struct *work)
+static int lp5562_led_brightness(struct lp55xx_led *led)
 {
 {
-	struct lp55xx_led *led = container_of(work, struct lp55xx_led,
-					      brightness_work);
 	struct lp55xx_chip *chip = led->chip;
 	struct lp55xx_chip *chip = led->chip;
 	u8 addr[] = {
 	u8 addr[] = {
 		LP5562_REG_R_PWM,
 		LP5562_REG_R_PWM,
@@ -322,10 +320,13 @@ static void lp5562_led_brightness_work(struct work_struct *work)
 		LP5562_REG_B_PWM,
 		LP5562_REG_B_PWM,
 		LP5562_REG_W_PWM,
 		LP5562_REG_W_PWM,
 	};
 	};
+	int ret;
 
 
 	mutex_lock(&chip->lock);
 	mutex_lock(&chip->lock);
-	lp55xx_write(chip, addr[led->chan_nr], led->brightness);
+	ret = lp55xx_write(chip, addr[led->chan_nr], led->brightness);
 	mutex_unlock(&chip->lock);
 	mutex_unlock(&chip->lock);
+
+	return ret;
 }
 }
 
 
 static void lp5562_write_program_memory(struct lp55xx_chip *chip,
 static void lp5562_write_program_memory(struct lp55xx_chip *chip,
@@ -503,7 +504,7 @@ static struct lp55xx_device_config lp5562_cfg = {
 	},
 	},
 	.post_init_device   = lp5562_post_init_device,
 	.post_init_device   = lp5562_post_init_device,
 	.set_led_current    = lp5562_set_led_current,
 	.set_led_current    = lp5562_set_led_current,
-	.brightness_work_fn = lp5562_led_brightness_work,
+	.brightness_fn      = lp5562_led_brightness,
 	.run_engine         = lp5562_run_engine,
 	.run_engine         = lp5562_run_engine,
 	.firmware_cb        = lp5562_firmware_loaded,
 	.firmware_cb        = lp5562_firmware_loaded,
 	.dev_attr_group     = &lp5562_group,
 	.dev_attr_group     = &lp5562_group,

+ 5 - 7
drivers/leds/leds-lp55xx-common.c

@@ -134,13 +134,14 @@ static struct attribute *lp55xx_led_attrs[] = {
 };
 };
 ATTRIBUTE_GROUPS(lp55xx_led);
 ATTRIBUTE_GROUPS(lp55xx_led);
 
 
-static void lp55xx_set_brightness(struct led_classdev *cdev,
+static int lp55xx_set_brightness(struct led_classdev *cdev,
 			     enum led_brightness brightness)
 			     enum led_brightness brightness)
 {
 {
 	struct lp55xx_led *led = cdev_to_lp55xx_led(cdev);
 	struct lp55xx_led *led = cdev_to_lp55xx_led(cdev);
+	struct lp55xx_device_config *cfg = led->chip->cfg;
 
 
 	led->brightness = (u8)brightness;
 	led->brightness = (u8)brightness;
-	schedule_work(&led->brightness_work);
+	return cfg->brightness_fn(led);
 }
 }
 
 
 static int lp55xx_init_led(struct lp55xx_led *led,
 static int lp55xx_init_led(struct lp55xx_led *led,
@@ -172,7 +173,7 @@ static int lp55xx_init_led(struct lp55xx_led *led,
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
-	led->cdev.brightness_set = lp55xx_set_brightness;
+	led->cdev.brightness_set_blocking = lp55xx_set_brightness;
 	led->cdev.groups = lp55xx_led_groups;
 	led->cdev.groups = lp55xx_led_groups;
 
 
 	if (pdata->led_config[chan].name) {
 	if (pdata->led_config[chan].name) {
@@ -464,7 +465,7 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip)
 	int ret;
 	int ret;
 	int i;
 	int i;
 
 
-	if (!cfg->brightness_work_fn) {
+	if (!cfg->brightness_fn) {
 		dev_err(&chip->cl->dev, "empty brightness configuration\n");
 		dev_err(&chip->cl->dev, "empty brightness configuration\n");
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
@@ -481,8 +482,6 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip)
 		if (ret)
 		if (ret)
 			goto err_init_led;
 			goto err_init_led;
 
 
-		INIT_WORK(&each->brightness_work, cfg->brightness_work_fn);
-
 		chip->num_leds++;
 		chip->num_leds++;
 		each->chip = chip;
 		each->chip = chip;
 
 
@@ -507,7 +506,6 @@ void lp55xx_unregister_leds(struct lp55xx_led *led, struct lp55xx_chip *chip)
 	for (i = 0; i < chip->num_leds; i++) {
 	for (i = 0; i < chip->num_leds; i++) {
 		each = led + i;
 		each = led + i;
 		led_classdev_unregister(&each->cdev);
 		led_classdev_unregister(&each->cdev);
-		flush_work(&each->brightness_work);
 	}
 	}
 }
 }
 EXPORT_SYMBOL_GPL(lp55xx_unregister_leds);
 EXPORT_SYMBOL_GPL(lp55xx_unregister_leds);

+ 2 - 4
drivers/leds/leds-lp55xx-common.h

@@ -95,7 +95,7 @@ struct lp55xx_reg {
  * @enable             : Chip specific enable command
  * @enable             : Chip specific enable command
  * @max_channel        : Maximum number of channels
  * @max_channel        : Maximum number of channels
  * @post_init_device   : Chip specific initialization code
  * @post_init_device   : Chip specific initialization code
- * @brightness_work_fn : Brightness work function
+ * @brightness_fn      : Brightness function
  * @set_led_current    : LED current set function
  * @set_led_current    : LED current set function
  * @firmware_cb        : Call function when the firmware is loaded
  * @firmware_cb        : Call function when the firmware is loaded
  * @run_engine         : Run internal engine for pattern
  * @run_engine         : Run internal engine for pattern
@@ -110,7 +110,7 @@ struct lp55xx_device_config {
 	int (*post_init_device) (struct lp55xx_chip *chip);
 	int (*post_init_device) (struct lp55xx_chip *chip);
 
 
 	/* access brightness register */
 	/* access brightness register */
-	void (*brightness_work_fn)(struct work_struct *work);
+	int (*brightness_fn)(struct lp55xx_led *led);
 
 
 	/* current setting function */
 	/* current setting function */
 	void (*set_led_current) (struct lp55xx_led *led, u8 led_current);
 	void (*set_led_current) (struct lp55xx_led *led, u8 led_current);
@@ -164,7 +164,6 @@ struct lp55xx_chip {
  * @cdev            : LED class device
  * @cdev            : LED class device
  * @led_current     : Current setting at each led channel
  * @led_current     : Current setting at each led channel
  * @max_current     : Maximun current at each led channel
  * @max_current     : Maximun current at each led channel
- * @brightness_work : Workqueue for brightness control
  * @brightness      : Brightness value
  * @brightness      : Brightness value
  * @chip            : The lp55xx chip data
  * @chip            : The lp55xx chip data
  */
  */
@@ -173,7 +172,6 @@ struct lp55xx_led {
 	struct led_classdev cdev;
 	struct led_classdev cdev;
 	u8 led_current;
 	u8 led_current;
 	u8 max_current;
 	u8 max_current;
-	struct work_struct brightness_work;
 	u8 brightness;
 	u8 brightness;
 	struct lp55xx_chip *chip;
 	struct lp55xx_chip *chip;
 };
 };

+ 6 - 5
drivers/leds/leds-lp8501.c

@@ -272,16 +272,17 @@ static void lp8501_firmware_loaded(struct lp55xx_chip *chip)
 	lp8501_update_program_memory(chip, fw->data, fw->size);
 	lp8501_update_program_memory(chip, fw->data, fw->size);
 }
 }
 
 
-static void lp8501_led_brightness_work(struct work_struct *work)
+static int lp8501_led_brightness(struct lp55xx_led *led)
 {
 {
-	struct lp55xx_led *led = container_of(work, struct lp55xx_led,
-					      brightness_work);
 	struct lp55xx_chip *chip = led->chip;
 	struct lp55xx_chip *chip = led->chip;
+	int ret;
 
 
 	mutex_lock(&chip->lock);
 	mutex_lock(&chip->lock);
-	lp55xx_write(chip, LP8501_REG_LED_PWM_BASE + led->chan_nr,
+	ret = lp55xx_write(chip, LP8501_REG_LED_PWM_BASE + led->chan_nr,
 		     led->brightness);
 		     led->brightness);
 	mutex_unlock(&chip->lock);
 	mutex_unlock(&chip->lock);
+
+	return ret;
 }
 }
 
 
 /* Chip specific configurations */
 /* Chip specific configurations */
@@ -296,7 +297,7 @@ static struct lp55xx_device_config lp8501_cfg = {
 	},
 	},
 	.max_channel  = LP8501_MAX_LEDS,
 	.max_channel  = LP8501_MAX_LEDS,
 	.post_init_device   = lp8501_post_init_device,
 	.post_init_device   = lp8501_post_init_device,
-	.brightness_work_fn = lp8501_led_brightness_work,
+	.brightness_fn      = lp8501_led_brightness,
 	.set_led_current    = lp8501_set_led_current,
 	.set_led_current    = lp8501_set_led_current,
 	.firmware_cb        = lp8501_firmware_loaded,
 	.firmware_cb        = lp8501_firmware_loaded,
 	.run_engine         = lp8501_run_engine,
 	.run_engine         = lp8501_run_engine,