Skip to contentSkip to conversation

cmpc_acpi: add support for Classmate PC ACPI devices

PATCH In review [email protected] 3 participants 4 messages Nov 17, 2009 – Nov 18, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/12 cmpc_acpi: add support for Classmate PC ACPI devices

From: Thadeu Lima de Souza Cascardo <[email protected]>

This add supports for devices like keyboard, backlight, tablet and accelerometer.

This work is supported by International Syst S/A.

[[email protected]: cmpc_acpi: depends on ACPI]
[[email protected]: readability tweaks]
Cc Len Brown <[email protected]>

---

 MAINTAINERS                      |    6 
 drivers/platform/x86/Kconfig     |   12 
 drivers/platform/x86/Makefile    |    1 
 drivers/platform/x86/cmpc_acpi.c |  543 +++++++++++++++++++++++++++++
 4 files changed, 562 insertions(+)
MAINTAINERS renamed from MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +6 -0
diff -puN MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices MAINTAINERS
@@ -1427,6 +1427,12 @@ L:	[email protected]
 S:	Supported
 F:	drivers/scsi/fnic/
 
+CMPC ACPI DRIVER
+M:	Thadeu Lima de Souza Cascardo <[email protected]>
+M:	Daniel Oliveira Nascimento <[email protected]>
+S:	Supported
+F:	drivers/platform/x86/cmpc_acpi.c
+
 CODA FILE SYSTEM
 M:	Jan Harkes <[email protected]>
 M:	[email protected]
drivers/platform/x86/Kconfig renamed from drivers/platform/x86/Kconfig~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +12 -0
diff -puN drivers/platform/x86/Kconfig~cmpc_acpi-add-support-for-classmate-pc-acpi-devices drivers/platform/x86/Kconfig
@@ -435,4 +435,16 @@ config ACPI_TOSHIBA
 
 	  If you have a legacy free Toshiba laptop (such as the Libretto L1
 	  series), say Y.
+
+config ACPI_CMPC
+	tristate "CMPC Laptop Extras"
+	depends on X86 && ACPI
+	select INPUT
+	select BACKLIGHT_CLASS_DEVICE
+	default n
+	help
+	  Support for Intel Classmate PC ACPI devices, including some
+	  keys as input device, backlight device, tablet and accelerometer
+	  devices.
+
 endif # X86_PLATFORM_DEVICES
drivers/platform/x86/Makefile renamed from drivers/platform/x86/Makefile~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +1 -0
diff -puN drivers/platform/x86/Makefile~cmpc_acpi-add-support-for-classmate-pc-acpi-devices drivers/platform/x86/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_ACPI_WMI)		+= wmi.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
 obj-$(CONFIG_TOPSTAR_LAPTOP)	+= topstar-laptop.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
+obj-$(CONFIG_ACPI_CMPC)		+= cmpc_acpi.o
drivers/platform/x86/cmpc_acpi.c new file +543 -0

543 lines not on this page · raw message

_

#1 lore raw
Quoted 150 lines · On 11/17/09, [email protected] <[email protected]> wrote:

From: Thadeu Lima de Souza Cascardo <[email protected]>

This add supports for devices like keyboard, backlight, tablet and accelerometer.

This work is supported by International Syst S/A.

[[email protected]: cmpc_acpi: depends on ACPI]
[[email protected]: readability tweaks]
Cc Len Brown <[email protected]>

---

 MAINTAINERS                      |    6
 drivers/platform/x86/Kconfig     |   12
 drivers/platform/x86/Makefile    |    1
 drivers/platform/x86/cmpc_acpi.c |  543 +++++++++++++++++++++++++++++
 4 files changed, 562 insertions(+)

diff -puN MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices MAINTAINERS

MAINTAINERS renamed from MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +6 -0
@@ -1427,6 +1427,12 @@ L:	[email protected]
 S:	Supported
 F:	drivers/scsi/fnic/
 
+CMPC ACPI DRIVER
+M:	Thadeu Lima de Souza Cascardo <[email protected]>
+M:	Daniel Oliveira Nascimento <[email protected]>
+S:	Supported
+F:	drivers/platform/x86/cmpc_acpi.c
+
 CODA FILE SYSTEM
 M:	Jan Harkes <[email protected]>
 M:	[email protected]

diff -puN drivers/platform/x86/Kconfig~cmpc_acpi-add-support-for-classmate-pc-acpi-devices drivers/platform/x86/Kconfig
---
a/drivers/platform/x86/Kconfig~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +++ a/drivers/platform/x86/Kconfig

MAINTAINERS renamed from MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +12 -0
@@ -435,4 +435,16 @@ config ACPI_TOSHIBA
 
 	  If you have a legacy free Toshiba laptop (such as the Libretto L1
 	  series), say Y.
+
+config ACPI_CMPC
+	tristate "CMPC Laptop Extras"
+	depends on X86 && ACPI
+	select INPUT
+	select BACKLIGHT_CLASS_DEVICE
+	default n
+	help
+	  Support for Intel Classmate PC ACPI devices, including some
+	  keys as input device, backlight device, tablet and accelerometer
+	  devices.
+
 endif # X86_PLATFORM_DEVICES

diff -puN drivers/platform/x86/Makefile~cmpc_acpi-add-support-for-classmate-pc-acpi-devices drivers/platform/x86/Makefile
---
a/drivers/platform/x86/Makefile~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +++ a/drivers/platform/x86/Makefile

MAINTAINERS renamed from MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +1 -0
@@ -21,3 +21,4 @@ obj-$(CONFIG_ACPI_WMI)		+= wmi.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
 obj-$(CONFIG_TOPSTAR_LAPTOP)	+= topstar-laptop.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
+obj-$(CONFIG_ACPI_CMPC)		+= cmpc_acpi.o

diff -puN /dev/null drivers/platform/x86/cmpc_acpi.c

drivers/platform/x86/cmpc_acpi.c new file +2 -0
@@ -0,0 +1,543 @@
+/*
+ *  Copyright (C) 2009  Thadeu Lima de Souza Cascardo

<[email protected]>
+ *

+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

+ */

drivers/platform/x86/cmpc_acpi.c new file +19 -0
+
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/workqueue.h>
+#include <acpi/acpi_drivers.h>
+#include <linux/backlight.h>
+#include <linux/input.h>
+
+MODULE_LICENSE("GPL");
+
+
+/*
+ * Generic input device code.
+ */
+
+typedef void (*input_device_init)(struct input_dev *dev);
+
+static int cmpc_add_acpi_notify_device(struct acpi_device *acpi, char

*name,

drivers/platform/x86/cmpc_acpi.c new file +37 -0
+				       acpi_notify_handler handler,
+				       input_device_init idev_init)
+{
+	struct input_dev *inputdev;
+	acpi_status status;
+	int error;
+
+	inputdev = input_allocate_device();
+	if (!inputdev) {
+		error = -ENOMEM;
+		goto out;
+	}
+	inputdev->name = name;
+	inputdev->dev.parent = &acpi->dev;
+	idev_init(inputdev);
+	error = input_register_device(inputdev);
+	if (error)
+		goto err_reg;
+	dev_set_drvdata(&acpi->dev, inputdev);
+	status = acpi_install_notify_handler(acpi->handle, ACPI_DEVICE_NOTIFY,
+					     handler, inputdev);
+	if (ACPI_FAILURE(status)) {
+		error = -ENODEV;
+		goto err_acpi;
+	}
+	return 0;
+err_acpi:
+	input_unregister_device(inputdev);
+err_reg:
+	input_free_device(inputdev);
+out:
+	return error;
+}
+
+static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi,
+					  acpi_notify_handler handler)
+{

drivers/platform/x86/cmpc_acpi.c line 83

Quoted 10 lines
drivers/platform/x86/cmpc_acpi.c new file +10 -0
+	struct input_dev *inputdev;
+	acpi_status status;
+
+	status = acpi_remove_notify_handler(acpi->handle, ACPI_DEVICE_NOTIFY,
+					    handler);
+	inputdev = dev_get_drvdata(&acpi->dev);
+	input_unregister_device(inputdev);
+	input_free_device(inputdev);
+	return 0;
+}

This version still needs some fixes. For example, input_free_device() should not be called after input_unregister_device().

The other main problem was that the state of the "tablet mode" switch is not set on initialisation (and the same for resume from suspend).

At the very least, I don't think this version should be merged without putting it under CONFIG_EXPERIMENTAL. For more details and less serious nits see
<http://thread.gmane.org/gmane.linux.acpi.devel/42017/focus=42025>.

Thanks
Alan

#2 lore raw
Quoted 168 lines · Alan Jenkins
Quoted 150 lines · On 11/17/09, [email protected] <[email protected]> wrote:

From: Thadeu Lima de Souza Cascardo <[email protected]>

This add supports for devices like keyboard, backlight, tablet and accelerometer.

This work is supported by International Syst S/A.

[[email protected]: cmpc_acpi: depends on ACPI]
[[email protected]: readability tweaks]
Cc Len Brown <[email protected]>

---

 MAINTAINERS                      |    6
 drivers/platform/x86/Kconfig     |   12
 drivers/platform/x86/Makefile    |    1
 drivers/platform/x86/cmpc_acpi.c |  543 +++++++++++++++++++++++++++++
 4 files changed, 562 insertions(+)

diff -puN MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices MAINTAINERS

MAINTAINERS renamed from MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +6 -0
@@ -1427,6 +1427,12 @@ L:	[email protected]
 S:	Supported
 F:	drivers/scsi/fnic/
 
+CMPC ACPI DRIVER
+M:	Thadeu Lima de Souza Cascardo <[email protected]>
+M:	Daniel Oliveira Nascimento <[email protected]>
+S:	Supported
+F:	drivers/platform/x86/cmpc_acpi.c
+
 CODA FILE SYSTEM
 M:	Jan Harkes <[email protected]>
 M:	[email protected]

diff -puN drivers/platform/x86/Kconfig~cmpc_acpi-add-support-for-classmate-pc-acpi-devices drivers/platform/x86/Kconfig
---
a/drivers/platform/x86/Kconfig~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +++ a/drivers/platform/x86/Kconfig

MAINTAINERS renamed from MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +12 -0
@@ -435,4 +435,16 @@ config ACPI_TOSHIBA
 
 	  If you have a legacy free Toshiba laptop (such as the Libretto L1
 	  series), say Y.
+
+config ACPI_CMPC
+	tristate "CMPC Laptop Extras"
+	depends on X86 && ACPI
+	select INPUT
+	select BACKLIGHT_CLASS_DEVICE
+	default n
+	help
+	  Support for Intel Classmate PC ACPI devices, including some
+	  keys as input device, backlight device, tablet and accelerometer
+	  devices.
+
 endif # X86_PLATFORM_DEVICES

diff -puN drivers/platform/x86/Makefile~cmpc_acpi-add-support-for-classmate-pc-acpi-devices drivers/platform/x86/Makefile
---
a/drivers/platform/x86/Makefile~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +++ a/drivers/platform/x86/Makefile

MAINTAINERS renamed from MAINTAINERS~cmpc_acpi-add-support-for-classmate-pc-acpi-devices +1 -0
@@ -21,3 +21,4 @@ obj-$(CONFIG_ACPI_WMI)		+= wmi.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
 obj-$(CONFIG_TOPSTAR_LAPTOP)	+= topstar-laptop.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
+obj-$(CONFIG_ACPI_CMPC)		+= cmpc_acpi.o

diff -puN /dev/null drivers/platform/x86/cmpc_acpi.c

drivers/platform/x86/cmpc_acpi.c new file +2 -0
@@ -0,0 +1,543 @@
+/*
+ *  Copyright (C) 2009  Thadeu Lima de Souza Cascardo

<[email protected]>
+ *

+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

+ */

drivers/platform/x86/cmpc_acpi.c new file +19 -0
+
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/workqueue.h>
+#include <acpi/acpi_drivers.h>
+#include <linux/backlight.h>
+#include <linux/input.h>
+
+MODULE_LICENSE("GPL");
+
+
+/*
+ * Generic input device code.
+ */
+
+typedef void (*input_device_init)(struct input_dev *dev);
+
+static int cmpc_add_acpi_notify_device(struct acpi_device *acpi, char

*name,

drivers/platform/x86/cmpc_acpi.c new file +37 -0
+				       acpi_notify_handler handler,
+				       input_device_init idev_init)
+{
+	struct input_dev *inputdev;
+	acpi_status status;
+	int error;
+
+	inputdev = input_allocate_device();
+	if (!inputdev) {
+		error = -ENOMEM;
+		goto out;
+	}
+	inputdev->name = name;
+	inputdev->dev.parent = &acpi->dev;
+	idev_init(inputdev);
+	error = input_register_device(inputdev);
+	if (error)
+		goto err_reg;
+	dev_set_drvdata(&acpi->dev, inputdev);
+	status = acpi_install_notify_handler(acpi->handle, ACPI_DEVICE_NOTIFY,
+					     handler, inputdev);
+	if (ACPI_FAILURE(status)) {
+		error = -ENODEV;
+		goto err_acpi;
+	}
+	return 0;
+err_acpi:
+	input_unregister_device(inputdev);
+err_reg:
+	input_free_device(inputdev);
+out:
+	return error;
+}
+
+static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi,
+					  acpi_notify_handler handler)
+{

drivers/platform/x86/cmpc_acpi.c line 83

Quoted 10 lines
drivers/platform/x86/cmpc_acpi.c new file +10 -0
+	struct input_dev *inputdev;
+	acpi_status status;
+
+	status = acpi_remove_notify_handler(acpi->handle, ACPI_DEVICE_NOTIFY,
+					    handler);
+	inputdev = dev_get_drvdata(&acpi->dev);
+	input_unregister_device(inputdev);
+	input_free_device(inputdev);
+	return 0;
+}

This version still needs some fixes. For example, input_free_device() should not be called after input_unregister_device().

The other main problem was that the state of the "tablet mode" switch is not set on initialisation (and the same for resume from suspend).

Quoted 7 lines

At the very least, I don't think this version should be merged without putting it under CONFIG_EXPERIMENTAL. For more details and less serious nits see
<http://thread.gmane.org/gmane.linux.acpi.devel/42017/focus=42025>.

Thanks
Alan

Since Andrew has put some patches over the first version, I had some doubts on how to handle the fixes. Should I import those patches as git patches and submit them together with many other patches fixing every issue in its own commit? Or should I write another version and write a log in the commit message?

UPDATE:
I've just fixed every issue reported. How should I send it?

Regards,
Cascardo.

#3 lore raw
Quoted 11 lines · Thadeu Lima de Souza Cascardo

Since Andrew has put some patches over the first version, I had some doubts on how to handle the fixes. Should I import those patches as git patches and submit them together with many other patches fixing every issue in its own commit? Or should I write another version and write a log in the commit message?

UPDATE:
I've just fixed every issue reported. How should I send it?

Regards,
Cascardo.

Great! I would send the revised version as a new patch. Normally the log of changes is not included in the commit message, because they don't make much sense out of context. I.e.

    commit message
    ---
      log of changes to original version here; git will ignore it

    diff ...

Thanks
Alan