* [PATCH] platform: x86: int3472: Register a LED lookup table entry for the privacy LED
@ 2023-02-24 16:37 Hans de Goede
2023-02-24 17:29 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2023-02-24 16:37 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko, Pavel Machek, Lee Jones,
Daniel Scally
Cc: Hans de Goede, platform-driver-x86, linux-leds, Kate Hsuan
All currently known models using the tps68470 PMIC have a privacy LED for
the back sensor (first ACPI consumer dev of the PMIC) connected to the
ileda output of the PMIC.
Add a LED lookup table entry for this, so that the v4l2-core code turns on
the LED when streaming from the sensor.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Kate, please include this in the v2 series adding the leds-tps68470 driver.
---
drivers/platform/x86/intel/int3472/tps68470.c | 28 ++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel/int3472/tps68470.c b/drivers/platform/x86/intel/int3472/tps68470.c
index 82ef022f8916..4372e2c89837 100644
--- a/drivers/platform/x86/intel/int3472/tps68470.c
+++ b/drivers/platform/x86/intel/int3472/tps68470.c
@@ -140,11 +140,17 @@ skl_int3472_fill_clk_pdata(struct device *dev, struct tps68470_clk_platform_data
return n_consumers;
}
+static void skl_int3472_tps68470_unregister_led_lookup(void *led_lookup)
+{
+ led_remove_lookup(led_lookup);
+}
+
static int skl_int3472_tps68470_probe(struct i2c_client *client)
{
struct acpi_device *adev = ACPI_COMPANION(&client->dev);
const struct int3472_tps68470_board_data *board_data;
struct tps68470_clk_platform_data *clk_pdata;
+ struct led_lookup_data *led_lookup;
struct mfd_cell *cells;
struct regmap *regmap;
int n_consumers;
@@ -177,6 +183,26 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client)
if (!board_data)
return dev_err_probe(&client->dev, -ENODEV, "No board-data found for this model\n");
+ /* Add a LED lookup table entry for the privacy LED */
+ led_lookup = devm_kzalloc(&client->dev, sizeof(*led_lookup), GFP_KERNEL);
+ if (!led_lookup)
+ return -ENOMEM;
+
+ ret = skl_int3472_get_sensor_adev_and_name(&client->dev, NULL,
+ &led_lookup->dev_id);
+ if (ret)
+ return ret;
+
+ led_lookup->provider = "tps68470-ileda";
+ led_lookup->con_id = "privacy-led";
+ led_add_lookup(led_lookup);
+
+ ret = devm_add_action_or_reset(&client->dev,
+ skl_int3472_tps68470_unregister_led_lookup,
+ led_lookup);
+ if (ret)
+ return ret;
+
cells = kcalloc(TPS68470_WIN_MFD_CELL_COUNT, sizeof(*cells), GFP_KERNEL);
if (!cells)
return -ENOMEM;
@@ -259,4 +285,4 @@ module_i2c_driver(int3472_tps68470);
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI TPS68470 Device Driver");
MODULE_AUTHOR("Daniel Scally <djrscally@gmail.com>");
MODULE_LICENSE("GPL v2");
-MODULE_SOFTDEP("pre: clk-tps68470 tps68470-regulator");
+MODULE_SOFTDEP("pre: clk-tps68470 tps68470-regulator leds-tps68470");
--
2.39.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] platform: x86: int3472: Register a LED lookup table entry for the privacy LED
2023-02-24 16:37 [PATCH] platform: x86: int3472: Register a LED lookup table entry for the privacy LED Hans de Goede
@ 2023-02-24 17:29 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2023-02-24 17:29 UTC (permalink / raw)
To: Hans de Goede
Cc: Mark Gross, Andy Shevchenko, Pavel Machek, Lee Jones,
Daniel Scally, platform-driver-x86, linux-leds, Kate Hsuan
On Fri, Feb 24, 2023 at 6:37 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> All currently known models using the tps68470 PMIC have a privacy LED for
> the back sensor (first ACPI consumer dev of the PMIC) connected to the
> ileda output of the PMIC.
>
> Add a LED lookup table entry for this, so that the v4l2-core code turns on
> the LED when streaming from the sensor.
...
> static int skl_int3472_tps68470_probe(struct i2c_client *client)
> {
For now and the future improvements you may
struct device *dev = &client->dev;
> struct acpi_device *adev = ACPI_COMPANION(&client->dev);
struct acpi_device *adev = ACPI_COMPANION(dev);
...
> + ret = skl_int3472_get_sensor_adev_and_name(&client->dev, NULL,
> + &led_lookup->dev_id);
After above this probably can take only a single line.
> + if (ret)
> + return ret;
...
> + ret = devm_add_action_or_reset(&client->dev,
> + skl_int3472_tps68470_unregister_led_lookup,
> + led_lookup);
Similar gain.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-24 17:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-24 16:37 [PATCH] platform: x86: int3472: Register a LED lookup table entry for the privacy LED Hans de Goede
2023-02-24 17:29 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox