Skip to contentSkip to conversation

Add Dell Business Class Netbook LED driver

PATCH In review Bob Rodgers 4 participants 7 messages Feb 8, 2010 – Feb 11, 2010 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add Dell Business Class Netbook LED driver

This patch adds an LED driver to support the Dell Activity LED on the Dell Latitude 2100 netbook and future products to come. The Activity LED is visible externally in the lid so classroom instructors can observe it from a distance. The driver uses the sysfs led_class and provides a standard LED interface. This driver is ready for submission upstream.

Signed-off by: Bob Rodgers <[email protected]>

---
 drivers/leds/Kconfig    |    7 ++
 drivers/leds/Makefile   |    1 +
 drivers/leds/dell-led.c |  233 
+++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 241 insertions(+), 0 deletions(-)
 create mode 100644 drivers/leds/dell-led.c
drivers/leds/Kconfig +7 -0
index 8a0e1ec..40dd693 100644
@@ -269,6 +269,13 @@ config LEDS_ADP5520
 	  To compile this driver as a module, choose M here: the module will
 	  be called leds-adp5520.
 
+config LEDS_DELL_NETBOOKS
+	tristate "External LED on Dell Business Netbooks"
+	depends on LEDS_CLASS
+	help
+	  This adds support for the Latitude 2100 and similar
+	  notebooks that have an external LED.
+
 comment "LED Triggers"
 
 config LEDS_TRIGGERS
drivers/leds/Makefile +1 -0
index 9e63869..327bfa0 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_LEDS_REGULATOR)		+= leds-regulator.o
 obj-$(CONFIG_LEDS_INTEL_SS4200)		+= leds-ss4200.o
 obj-$(CONFIG_LEDS_LT3593)		+= leds-lt3593.o
 obj-$(CONFIG_LEDS_ADP5520)		+= leds-adp5520.o
+obj-$(CONFIG_LEDS_DELL_NETBOOKS)	+= dell-led.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_DAC124S085)		+= leds-dac124s085.o
drivers/leds/dell-led.c new file +233 -0

233 lines not on this page · raw message

Signature · 1 line
1.6.5
#2 lore raw
In reply to Richard Purdie
Quoted 76 lines · Richard Purdie
Quoted 5 lines · Bob Rodgers

This patch adds an LED driver to support the Dell Activity LED on the Dell Latitude 2100 netbook and future products to come. The Activity LED is visible externally in the lid so classroom instructors can observe it from a distance. The driver uses the sysfs led_class and provides a standard LED interface. This driver is ready for submission upstream.

A couple of comments:

Quoted 6 lines
drivers/leds/Kconfig +0 -0
index 8a0e1ec..40dd693 100644
@@ -269,6 +269,13 @@ config LEDS_ADP5520
 	  To compile this driver as a module, choose M here: the module will

drivers/leds/Kconfig config LEDS_ADP5520 · line 279

Quoted 10 lines
drivers/leds/Kconfig +7 -0
 	  be called leds-adp5520.
 
+config LEDS_DELL_NETBOOKS
+	tristate "External LED on Dell Business Netbooks"
+	depends on LEDS_CLASS
+	help
+	  This adds support for the Latitude 2100 and similar
+	  notebooks that have an external LED.
+
 comment "LED Triggers"

I assume this driver applies to X86 only? Is there anything else this config option should be depending on?

Quoted 47 lines
drivers/leds/Kconfig +47 -0
+static int __devinit dell_led_probe(struct platform_device *pdev)
+{
+	return led_classdev_register(&pdev->dev, &dell_led);
+}
+
+static int dell_led_remove(struct platform_device *pdev)
+{
+	led_classdev_unregister(&dell_led);
+	return 0;
+}
+
+static struct platform_driver dell_led_driver = {
+	.probe		= dell_led_probe,
+	.remove		= dell_led_remove,
+	.driver		= {
+		.name	= KBUILD_MODNAME,
+		.owner	= THIS_MODULE,
+	},
+};
+
+static struct platform_device *pdev;
+
+static int __init dell_led_init(void)
+{
+	int error = 0;
+
+	if (!wmi_has_guid(DELL_LED_BIOS_GUID)) {
+		printk(KERN_DEBUG KBUILD_MODNAME
+			": could not find: DELL_LED_BIOS_GUID\n");
+		return -ENODEV;
+	}
+
+	error = led_off();
+	if (error != 0) {
+		printk(KERN_DEBUG KBUILD_MODNAME
+			": could not communicate with LED"
+			": error %d\n", error);
+		return -ENODEV;
+	}
+
+	error = platform_driver_register(&dell_led_driver);
+	if (error < 0)
+		return error;
+
+	pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
+	if (IS_ERR(pdev)) {
+		error = PTR_ERR(pdev);
Quoted 9 lines

drivers/leds/Kconfig

Quoted 5 lines
drivers/leds/Kconfig +5 -0
+		platform_driver_unregister(&dell_led_driver);
+	}
+
+	return error;
+}

Rather than add all this overhead of a platform device, why not just pass NULL as the parent to led_classdev_register()?

Or stuck it in dell-wmi.c...

Signature · 1 line
Dmitry
#1 lore raw
In reply to Bob Rodgers
Quoted 5 lines · Bob Rodgers

This patch adds an LED driver to support the Dell Activity LED on the Dell Latitude 2100 netbook and future products to come. The Activity LED is visible externally in the lid so classroom instructors can observe it from a distance. The driver uses the sysfs led_class and provides a standard LED interface. This driver is ready for submission upstream.

A couple of comments:

Quoted 6 lines
drivers/leds/Kconfig +0 -0
index 8a0e1ec..40dd693 100644
@@ -269,6 +269,13 @@ config LEDS_ADP5520
 	  To compile this driver as a module, choose M here: the module will

drivers/leds/Kconfig config LEDS_ADP5520 · line 279

Quoted 10 lines
drivers/leds/Kconfig +7 -0
 	  be called leds-adp5520.
 
+config LEDS_DELL_NETBOOKS
+	tristate "External LED on Dell Business Netbooks"
+	depends on LEDS_CLASS
+	help
+	  This adds support for the Latitude 2100 and similar
+	  notebooks that have an external LED.
+
 comment "LED Triggers"

I assume this driver applies to X86 only? Is there anything else this config option should be depending on?

Quoted 42 lines
drivers/leds/Kconfig +42 -0
+static int __devinit dell_led_probe(struct platform_device *pdev)
+{
+	return led_classdev_register(&pdev->dev, &dell_led);
+}
+
+static int dell_led_remove(struct platform_device *pdev)
+{
+	led_classdev_unregister(&dell_led);
+	return 0;
+}
+
+static struct platform_driver dell_led_driver = {
+	.probe		= dell_led_probe,
+	.remove		= dell_led_remove,
+	.driver		= {
+		.name	= KBUILD_MODNAME,
+		.owner	= THIS_MODULE,
+	},
+};
+
+static struct platform_device *pdev;
+
+static int __init dell_led_init(void)
+{
+	int error = 0;
+
+	if (!wmi_has_guid(DELL_LED_BIOS_GUID)) {
+		printk(KERN_DEBUG KBUILD_MODNAME
+			": could not find: DELL_LED_BIOS_GUID\n");
+		return -ENODEV;
+	}
+
+	error = led_off();
+	if (error != 0) {
+		printk(KERN_DEBUG KBUILD_MODNAME
+			": could not communicate with LED"
+			": error %d\n", error);
+		return -ENODEV;
+	}
+
+	error = platform_driver_register(&dell_led_driver);
+	if (error < 0)

drivers/leds/Kconfig config LEDS_ADP5520

Quoted 10 lines
drivers/leds/Kconfig +10 -0
+		return error;
+
+	pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
+	if (IS_ERR(pdev)) {
+		error = PTR_ERR(pdev);
+		platform_driver_unregister(&dell_led_driver);
+	}
+
+	return error;
+}

Rather than add all this overhead of a platform device, why not just pass NULL as the parent to led_classdev_register()?

Cheers,

Richard

#3 lore raw
In reply to Dmitry Torokhov
Quoted 1 line · Dmitry Torokhov

Or stuck it in dell-wmi.c...

I'd prefer not to put it in dell-wmi. There's no logical association between it and the rest of the code there, so it'd just be overhead on the majority of systems. With the exception of cases where the event and functional interfaces are different GUIDs, I'd prefer a one GUID per driver model.

Signature · 1 line
Matthew Garrett | [email protected]
#6 lore raw
In reply to Richard Purdie
Quoted 11 lines · Richard Purdie

drivers/leds/Kconfig config LEDS_ADP5520 · line 279

Quoted 8 lines
drivers/leds/Kconfig +7 -0
+config LEDS_DELL_NETBOOKS
+	tristate "External LED on Dell Business Netbooks"
+	depends on LEDS_CLASS
+	help
+	  This adds support for the Latitude 2100 and similar
+	  notebooks that have an external LED.
+
 comment "LED Triggers"

I assume this driver applies to X86 only? Is there anything else this config option should be depending on?

Sorry for not catching that. It ought to depend on ACPI_WMI as well.

Signature · 1 line
Matthew Garrett | [email protected]
#4 lore raw
In reply to Matthew Garrett
Quoted 10 lines · Matthew Garrett
Quoted 1 line · Dmitry Torokhov

Or stuck it in dell-wmi.c...

I'd prefer not to put it in dell-wmi. There's no logical association between it and the rest of the code there, so it'd just be overhead on the majority of systems. With the exception of cases where the event and functional interfaces are different GUIDs, I'd prefer a one GUID per driver model.

This is an opposite direction form the rest of the platform drivers which tend to combine functionality on per-vendor basis in one driver.

I'd say that in this case with this LED driver overhead on DELL systems not supportinfg it is miniscule. The benefit is that all vendor-specific sub-devices are children of one parent platform device.

Signature · 1 line
Dmitry
#5 lore raw
Quoted 2 lines · Dmitry Torokhov

This is an opposite direction form the rest of the platform drivers which tend to combine functionality on per-vendor basis in one driver.

I don't think that's true - we /tend/ to see one driver per ACPI device or device interface (see the dell-wmi/dell-laptop split, for instance).

Quoted 3 lines

I'd say that in this case with this LED driver overhead on DELL systems not supportinfg it is miniscule. The benefit is that all vendor-specific sub-devices are children of one parent platform device.

I really don't see that as a strong benefit.

Signature · 1 line
Matthew Garrett | [email protected]