Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a608a9d5 authored by Micha? K?pie?'s avatar Micha? K?pie? Committed by Andy Shevchenko
Browse files

platform/x86: fujitsu-laptop: use brightness_set_blocking for LED-setting callbacks



All LED-setting functions in fujitsu-laptop are currently assigned to
the brightness_set callback, which is incorrect because they can sleep
(due to their use of call_fext_func(), which in turn issues ACPI calls)
and the documentation (in include/linux/leds.h) clearly states they must
not.  Assign them to brightness_set_blocking instead and change them to
match the expected function prototype.

This change makes it possible to use Fujitsu-specific LEDs with "heavy"
triggers, like disk-activity or phy0rx.

Fixes: 3a407086 ("fujitsu-laptop: Add BL power, LED control and radio state information")
Fixes: 4f62568c ("fujitsu-laptop: Support radio LED")
Fixes: d6b88f64 ("fujitsu-laptop: Add support for eco LED")
Signed-off-by: default avatarMichał Kępień <kernel@kempniu.pl>
Acked-by: default avatarJonathan Woithe <jwoithe@just42.net>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent f6c5c1f9
Loading
Loading
Loading
Loading
+21 −21
Original line number Original line Diff line number Diff line
@@ -177,43 +177,43 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);


#if IS_ENABLED(CONFIG_LEDS_CLASS)
#if IS_ENABLED(CONFIG_LEDS_CLASS)
static enum led_brightness logolamp_get(struct led_classdev *cdev);
static enum led_brightness logolamp_get(struct led_classdev *cdev);
static void logolamp_set(struct led_classdev *cdev,
static int logolamp_set(struct led_classdev *cdev,
			       enum led_brightness brightness);
			       enum led_brightness brightness);


static struct led_classdev logolamp_led = {
static struct led_classdev logolamp_led = {
 .name = "fujitsu::logolamp",
 .name = "fujitsu::logolamp",
 .brightness_get = logolamp_get,
 .brightness_get = logolamp_get,
 .brightness_set = logolamp_set
 .brightness_set_blocking = logolamp_set
};
};


static enum led_brightness kblamps_get(struct led_classdev *cdev);
static enum led_brightness kblamps_get(struct led_classdev *cdev);
static void kblamps_set(struct led_classdev *cdev,
static int kblamps_set(struct led_classdev *cdev,
			       enum led_brightness brightness);
			       enum led_brightness brightness);


static struct led_classdev kblamps_led = {
static struct led_classdev kblamps_led = {
 .name = "fujitsu::kblamps",
 .name = "fujitsu::kblamps",
 .brightness_get = kblamps_get,
 .brightness_get = kblamps_get,
 .brightness_set = kblamps_set
 .brightness_set_blocking = kblamps_set
};
};


static enum led_brightness radio_led_get(struct led_classdev *cdev);
static enum led_brightness radio_led_get(struct led_classdev *cdev);
static void radio_led_set(struct led_classdev *cdev,
static int radio_led_set(struct led_classdev *cdev,
			       enum led_brightness brightness);
			       enum led_brightness brightness);


static struct led_classdev radio_led = {
static struct led_classdev radio_led = {
 .name = "fujitsu::radio_led",
 .name = "fujitsu::radio_led",
 .brightness_get = radio_led_get,
 .brightness_get = radio_led_get,
 .brightness_set = radio_led_set
 .brightness_set_blocking = radio_led_set
};
};


static enum led_brightness eco_led_get(struct led_classdev *cdev);
static enum led_brightness eco_led_get(struct led_classdev *cdev);
static void eco_led_set(struct led_classdev *cdev,
static int eco_led_set(struct led_classdev *cdev,
			       enum led_brightness brightness);
			       enum led_brightness brightness);


static struct led_classdev eco_led = {
static struct led_classdev eco_led = {
 .name = "fujitsu::eco_led",
 .name = "fujitsu::eco_led",
 .brightness_get = eco_led_get,
 .brightness_get = eco_led_get,
 .brightness_set = eco_led_set
 .brightness_set_blocking = eco_led_set
};
};
#endif
#endif


@@ -267,48 +267,48 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
#if IS_ENABLED(CONFIG_LEDS_CLASS)
#if IS_ENABLED(CONFIG_LEDS_CLASS)
/* LED class callbacks */
/* LED class callbacks */


static void logolamp_set(struct led_classdev *cdev,
static int logolamp_set(struct led_classdev *cdev,
			       enum led_brightness brightness)
			       enum led_brightness brightness)
{
{
	if (brightness >= LED_FULL) {
	if (brightness >= LED_FULL) {
		call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
		call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
		call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON);
		return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON);
	} else if (brightness >= LED_HALF) {
	} else if (brightness >= LED_HALF) {
		call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
		call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
		call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF);
		return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF);
	} else {
	} else {
		call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF);
		return call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF);
	}
	}
}
}


static void kblamps_set(struct led_classdev *cdev,
static int kblamps_set(struct led_classdev *cdev,
			       enum led_brightness brightness)
			       enum led_brightness brightness)
{
{
	if (brightness >= LED_FULL)
	if (brightness >= LED_FULL)
		call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
		return call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
	else
	else
		call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
		return call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
}
}


static void radio_led_set(struct led_classdev *cdev,
static int radio_led_set(struct led_classdev *cdev,
				enum led_brightness brightness)
				enum led_brightness brightness)
{
{
	if (brightness >= LED_FULL)
	if (brightness >= LED_FULL)
		call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON);
		return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON);
	else
	else
		call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0);
		return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0);
}
}


static void eco_led_set(struct led_classdev *cdev,
static int eco_led_set(struct led_classdev *cdev,
				enum led_brightness brightness)
				enum led_brightness brightness)
{
{
	int curr;
	int curr;


	curr = call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0);
	curr = call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0);
	if (brightness >= LED_FULL)
	if (brightness >= LED_FULL)
		call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr | ECO_LED_ON);
		return call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr | ECO_LED_ON);
	else
	else
		call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr & ~ECO_LED_ON);
		return call_fext_func(FUNC_LEDS, 0x1, ECO_LED, curr & ~ECO_LED_ON);
}
}


static enum led_brightness logolamp_get(struct led_classdev *cdev)
static enum led_brightness logolamp_get(struct led_classdev *cdev)