1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-23 08:35:19 -05:00

Merge branch 'ib-mfd-leds-platform-6.11' into ibs-for-mfd-merged

This commit is contained in:
Lee Jones 2024-07-04 17:07:01 +01:00
commit 5ffe70d81e
5 changed files with 54 additions and 7 deletions

View file

@ -503,6 +503,11 @@ int led_classdev_register_ext(struct device *parent,
ret = led_classdev_next_name(proposed_name, final_name, sizeof(final_name)); ret = led_classdev_next_name(proposed_name, final_name, sizeof(final_name));
if (ret < 0) if (ret < 0)
return ret; return ret;
else if (ret && led_cdev->flags & LED_REJECT_NAME_CONFLICT)
return -EEXIST;
else if (ret)
dev_warn(parent, "Led %s renamed to %s due to name collision\n",
proposed_name, final_name);
if (led_cdev->color >= LED_COLOR_ID_MAX) if (led_cdev->color >= LED_COLOR_ID_MAX)
dev_warn(parent, "LED %s color identifier out of range\n", final_name); dev_warn(parent, "LED %s color identifier out of range\n", final_name);
@ -518,10 +523,6 @@ int led_classdev_register_ext(struct device *parent,
if (init_data && init_data->fwnode) if (init_data && init_data->fwnode)
device_set_node(led_cdev->dev, init_data->fwnode); device_set_node(led_cdev->dev, init_data->fwnode);
if (ret)
dev_warn(parent, "Led %s renamed to %s due to name collision",
proposed_name, dev_name(led_cdev->dev));
if (led_cdev->flags & LED_BRIGHT_HW_CHANGED) { if (led_cdev->flags & LED_BRIGHT_HW_CHANGED) {
ret = led_add_brightness_hw_changed(led_cdev); ret = led_add_brightness_hw_changed(led_cdev);
if (ret) { if (ret) {

View file

@ -103,6 +103,10 @@ static const struct mfd_cell cros_ec_led_cells[] = {
{ .name = "cros-ec-led", }, { .name = "cros-ec-led", },
}; };
static const struct mfd_cell cros_ec_keyboard_leds_cells[] = {
{ .name = "cros-keyboard-leds", },
};
static const struct cros_feature_to_cells cros_subdevices[] = { static const struct cros_feature_to_cells cros_subdevices[] = {
{ {
.id = EC_FEATURE_CEC, .id = EC_FEATURE_CEC,
@ -134,6 +138,11 @@ static const struct cros_feature_to_cells cros_subdevices[] = {
.mfd_cells = cros_ec_led_cells, .mfd_cells = cros_ec_led_cells,
.num_cells = ARRAY_SIZE(cros_ec_led_cells), .num_cells = ARRAY_SIZE(cros_ec_led_cells),
}, },
{
.id = EC_FEATURE_PWM_KEYB,
.mfd_cells = cros_ec_keyboard_leds_cells,
.num_cells = ARRAY_SIZE(cros_ec_keyboard_leds_cells),
},
}; };
static const struct mfd_cell cros_ec_platform_cells[] = { static const struct mfd_cell cros_ec_platform_cells[] = {

View file

@ -150,7 +150,7 @@ config CROS_EC_PROTO
config CROS_KBD_LED_BACKLIGHT config CROS_KBD_LED_BACKLIGHT
tristate "Backlight LED support for Chrome OS keyboards" tristate "Backlight LED support for Chrome OS keyboards"
depends on LEDS_CLASS && (ACPI || CROS_EC) depends on LEDS_CLASS && (ACPI || CROS_EC || MFD_CROS_EC_DEV)
help help
This option enables support for the keyboard backlight LEDs on This option enables support for the keyboard backlight LEDs on
select Chrome OS systems. select Chrome OS systems.

View file

@ -9,6 +9,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/mfd/core.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
@ -194,13 +195,46 @@ static const __maybe_unused struct keyboard_led_drvdata keyboard_led_drvdata_ec_
#endif /* IS_ENABLED(CONFIG_CROS_EC) */ #endif /* IS_ENABLED(CONFIG_CROS_EC) */
#if IS_ENABLED(CONFIG_MFD_CROS_EC_DEV)
static int keyboard_led_init_ec_pwm_mfd(struct platform_device *pdev)
{
struct cros_ec_dev *ec_dev = dev_get_drvdata(pdev->dev.parent);
struct cros_ec_device *cros_ec = ec_dev->ec_dev;
struct keyboard_led *keyboard_led = platform_get_drvdata(pdev);
keyboard_led->ec = cros_ec;
return 0;
}
static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm_mfd = {
.init = keyboard_led_init_ec_pwm_mfd,
.brightness_set_blocking = keyboard_led_set_brightness_ec_pwm,
.brightness_get = keyboard_led_get_brightness_ec_pwm,
.max_brightness = KEYBOARD_BACKLIGHT_MAX,
};
#else /* IS_ENABLED(CONFIG_MFD_CROS_EC_DEV) */
static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm_mfd = {};
#endif /* IS_ENABLED(CONFIG_MFD_CROS_EC_DEV) */
static int keyboard_led_is_mfd_device(struct platform_device *pdev)
{
return IS_ENABLED(CONFIG_MFD_CROS_EC_DEV) && mfd_get_cell(pdev);
}
static int keyboard_led_probe(struct platform_device *pdev) static int keyboard_led_probe(struct platform_device *pdev)
{ {
const struct keyboard_led_drvdata *drvdata; const struct keyboard_led_drvdata *drvdata;
struct keyboard_led *keyboard_led; struct keyboard_led *keyboard_led;
int error; int error;
drvdata = device_get_match_data(&pdev->dev); if (keyboard_led_is_mfd_device(pdev))
drvdata = &keyboard_led_drvdata_ec_pwm_mfd;
else
drvdata = device_get_match_data(&pdev->dev);
if (!drvdata) if (!drvdata)
return -EINVAL; return -EINVAL;
@ -216,13 +250,15 @@ static int keyboard_led_probe(struct platform_device *pdev)
} }
keyboard_led->cdev.name = "chromeos::kbd_backlight"; keyboard_led->cdev.name = "chromeos::kbd_backlight";
keyboard_led->cdev.flags |= LED_CORE_SUSPENDRESUME; keyboard_led->cdev.flags |= LED_CORE_SUSPENDRESUME | LED_REJECT_NAME_CONFLICT;
keyboard_led->cdev.max_brightness = drvdata->max_brightness; keyboard_led->cdev.max_brightness = drvdata->max_brightness;
keyboard_led->cdev.brightness_set = drvdata->brightness_set; keyboard_led->cdev.brightness_set = drvdata->brightness_set;
keyboard_led->cdev.brightness_set_blocking = drvdata->brightness_set_blocking; keyboard_led->cdev.brightness_set_blocking = drvdata->brightness_set_blocking;
keyboard_led->cdev.brightness_get = drvdata->brightness_get; keyboard_led->cdev.brightness_get = drvdata->brightness_get;
error = devm_led_classdev_register(&pdev->dev, &keyboard_led->cdev); error = devm_led_classdev_register(&pdev->dev, &keyboard_led->cdev);
if (error == -EEXIST) /* Already bound via other mechanism */
return -ENODEV;
if (error) if (error)
return error; return error;

View file

@ -107,6 +107,7 @@ struct led_classdev {
#define LED_BRIGHT_HW_CHANGED BIT(21) #define LED_BRIGHT_HW_CHANGED BIT(21)
#define LED_RETAIN_AT_SHUTDOWN BIT(22) #define LED_RETAIN_AT_SHUTDOWN BIT(22)
#define LED_INIT_DEFAULT_TRIGGER BIT(23) #define LED_INIT_DEFAULT_TRIGGER BIT(23)
#define LED_REJECT_NAME_CONFLICT BIT(24)
/* set_brightness_work / blink_timer flags, atomic, private. */ /* set_brightness_work / blink_timer flags, atomic, private. */
unsigned long work_flags; unsigned long work_flags;