static int max77693_led_flash_strobe_set( struct led_classdev_flash *fled_cdev, bool state) { struct max77693_sub_led *sub_led = flcdev_to_sub_led(fled_cdev); struct max77693_led_device *led = sub_led_to_led(sub_led); int fled_id = sub_led->fled_id; int ret; mutex_lock(&led->lock); if (!state) { ret = max77693_clear_mode(led, MODE_FLASH(fled_id)); goto unlock; } if (sub_led->flash_timeout != led->current_flash_timeout) { ret = max77693_set_timeout(led, sub_led->flash_timeout); if (ret < 0) goto unlock; } led->strobing_sub_led_id = fled_id; ret = max77693_add_mode(led, MODE_FLASH(fled_id)); if (ret < 0) goto unlock; ret = max77693_get_flash_faults(sub_led); unlock: mutex_unlock(&led->lock); return ret; }
static int __max77693_led_brightness_set(struct max77693_led_device *led, int fled_id, enum led_brightness value) { int ret; mutex_lock(&led->lock); if (value == 0) { ret = max77693_clear_mode(led, MODE_TORCH(fled_id)); if (ret < 0) dev_dbg(&led->pdev->dev, "Failed to clear torch mode (%d)\n", ret); goto unlock; } ret = max77693_set_torch_current(led, fled_id, value * TORCH_IOUT_STEP); if (ret < 0) { dev_dbg(&led->pdev->dev, "Failed to set torch current (%d)\n", ret); goto unlock; } ret = max77693_add_mode(led, MODE_TORCH(fled_id)); if (ret < 0) dev_dbg(&led->pdev->dev, "Failed to set torch mode (%d)\n", ret); unlock: mutex_unlock(&led->lock); return ret; }
/* LED subsystem callbacks */ static int max77693_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness value) { struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); struct max77693_sub_led *sub_led = flcdev_to_sub_led(fled_cdev); struct max77693_led_device *led = sub_led_to_led(sub_led); int fled_id = sub_led->fled_id, ret; mutex_lock(&led->lock); if (value == 0) { ret = max77693_clear_mode(led, MODE_TORCH(fled_id)); if (ret < 0) dev_dbg(&led->pdev->dev, "Failed to clear torch mode (%d)\n", ret); goto unlock; } ret = max77693_set_torch_current(led, fled_id, value * TORCH_IOUT_STEP); if (ret < 0) { dev_dbg(&led->pdev->dev, "Failed to set torch current (%d)\n", ret); goto unlock; } ret = max77693_add_mode(led, MODE_TORCH(fled_id)); if (ret < 0) dev_dbg(&led->pdev->dev, "Failed to set torch mode (%d)\n", ret); unlock: mutex_unlock(&led->lock); return ret; }