Skip to contentSkip to conversation

ACPI related patches for 2.6.21 -- part II

PATCH In review Len Brown 1 participant 42 messages Feb 13, 2007 1 message not in the archive

Subsystems (7)
Documentation USB ACPI PCI +3 more subsystems
lore
Share & tools
lore

Len Brown

author reviewer
#0 lore raw

The following patches are staged to go upstream for 2.6.21.

thanks,
-Len

author reviewer
#1 lore raw

PATCH 1/41 sony_acpi: SNC device support for Sony Vaios

From: Stelian Pop <[email protected]>

From: Bjorn Helgaas <[email protected]>

Even though the devices claimed by sony_acpi.c can not be hot-plugged, the driver registration infrastructure allows the .add() and .remove() methods to be called at any time while the driver is registered. So remove __init and __exit from them.

DESC
acpi/sony: Add FN hotkey support
EDESC
From: Matthew Garrett <[email protected]>

in -mm only

[UBUNTU:acpi/sony] Add FN hotkey support
Source URL of Patch:
http://www.kernel.org/git/?p=linux/kernel/git/bcollins/ubuntu-dapper.git;a=commitdiff;h=7a9b49cba4919e8506604629db03add8e0b85767

---
 Documentation/acpi/sony_acpi.txt |   87 +++++++++
 drivers/acpi/Kconfig             |   14 ++
 drivers/acpi/Makefile            |    1 +
 drivers/acpi/sony_acpi.c         |  397 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 499 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/acpi/sony_acpi.txt
 create mode 100644 drivers/acpi/sony_acpi.c
Documentation/acpi/sony_acpi.txt new file +87 -0
new file mode 100644
index 0000000..35a04be
@@ -0,0 +1,87 @@
+ACPI Sony Notebook Control Driver (SNC) Readme
+----------------------------------------------
+	Copyright (C) 2004- 2005 Stelian Pop <[email protected]>
+
+This mini-driver drives the ACPI SNC device present in the
+ACPI BIOS of the Sony Vaio laptops.
+
+It gives access to some extra laptop functionalities. In
+its current form, this driver is mainly useful for controlling the
+screen brightness, but it may do more in the future.
+
+You should probably start by trying the sonypi driver, and try
+sony_acpi only if sonypi doesn't work for you.
+
+Usage:
+------
+
+Loading the sony_acpi module will create a /proc/acpi/sony/
+directory populated with a couple of files.
+
+You then read/write integer values from/to those files by using
+standard UNIX tools.
+
+The files are:
+	brightness		current screen brightness
+	brightness_default	screen brightness which will be set
+				when the laptop will be rebooted
+	cdpower			power on/off the internal CD drive
+
+Note that some files may be missing if they are not supported
+by your particular laptop model.
+
+Example usage:
+	# echo "1" > /proc/acpi/sony/brightness
+sets the lowest screen brightness,
+	# echo "8" > /proc/acpi/sony/brightness
+sets the highest screen brightness,
+	# cat /proc/acpi/sony/brightness
+retrieves the current screen brightness.
+
+Development:
+------------
+
+If you want to help with the development of this driver (and
+you are not afraid of any side effects doing strange things with
+your ACPI BIOS could have on your laptop), load the driver and
+pass the option 'debug=1'.
+
+REPEAT: DON'T DO THIS IF YOU DON'T LIKE RISKY BUSINESS.
+
+In your kernel logs you will find the list of all ACPI methods
+the SNC device has on your laptop. You can see the GBRT/SBRT methods
+used to get/set the brightness, but there are others.
+
+I HAVE NO IDEA WHAT THOSE METHODS DO.
+
+The sony_acpi driver creates, for some of those methods (the most
+current ones found on several Vaio models), an entry under
+/proc/acpi/sony/, just like the 'brightness' one. You can create
+other entries corresponding to your own laptop methods by further
+editing the source (see the 'sony_acpi_values' table, and add a new
+structure to this table with your get/set method names).
+
+Your mission, should you accept it, is to try finding out what
+those entries are for, by reading/writing random values from/to those
+files and find out what is the impact on your laptop.
+
+Should you find anything interesting, please report it back to me,
+I will not disavow all knowledge of your actions :)
+
+Bugs/Limitations:
+-----------------
+
+* This driver is not based on official documentation from Sony
+  (because there is none), so there is no guarantee this driver
+  will work at all, or do the right thing. Although this hasn't
+  happened to me, this driver could do very bad things to your
+  laptop, including permanent damage.
+
+* The sony_acpi and sonypi drivers do not interact at all. In the
+  future, sonypi could use sony_acpi to do (part of) its business.
+
+* spicctrl, which is the userspace tool used to communicate with the
+  sonypi driver (through /dev/sonypi) does not try to use the
+  sony_acpi driver. In the future, spicctrl could try sonypi first,
+  and if it isn't present, try sony_acpi instead.
+
drivers/acpi/Kconfig +14 -0
index f4f000a..e11371f 100644
@@ -252,6 +252,20 @@ config ACPI_TOSHIBA
 	  If you have a legacy free Toshiba laptop (such as the Libretto L1
 	  series), say Y.
 
+config ACPI_SONY
+	tristate "Sony Laptop Extras"
+	depends on X86 && ACPI
+	default m
+	  ---help---
+	  This mini-driver drives the ACPI SNC device present in the
+	  ACPI BIOS of the Sony Vaio laptops.
+
+	  It gives access to some extra laptop functionalities. In
+	  its current form, the only thing this driver does is letting
+	  the user set or query the screen brightness.
+
+	  Read <file:Documentation/acpi/sony_acpi.txt> for more information.
+
 config ACPI_CUSTOM_DSDT
 	bool "Include Custom DSDT"
 	depends on !STANDALONE
drivers/acpi/Makefile +1 -0
index bce7ca2..31b9ad2 100644
@@ -53,6 +53,7 @@ obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
 obj-$(CONFIG_ACPI_SYSTEM)	+= system.o event.o
 obj-$(CONFIG_ACPI_DEBUG)	+= debug.o
 obj-$(CONFIG_ACPI_NUMA)		+= numa.o
+obj-$(CONFIG_ACPI_SONY)		+= sony_acpi.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
 obj-$(CONFIG_ACPI_IBM)		+= ibm_acpi.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
drivers/acpi/sony_acpi.c new file +397 -0

397 lines not on this page · raw message

Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#2 lore raw

PATCH 2/41 sony_acpi: Avoid dimness on resume.

From: Andrew Morton <[email protected]>

Doesn't work.

---
 drivers/acpi/sony_acpi.c |   49 +++++++++++++++++++++++++++++++--------------
 1 files changed, 34 insertions(+), 15 deletions(-)
drivers/acpi/sony_acpi.c +34 -15
index e23522a..beb56b9 100644
@@ -46,19 +46,6 @@ module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
 			"the development of this driver");
 
-static int sony_acpi_add (struct acpi_device *device);
-static int sony_acpi_remove (struct acpi_device *device, int type);
-
-static struct acpi_driver sony_acpi_driver = {
-	.name	= ACPI_SNC_DRIVER_NAME,
-	.class	= ACPI_SNC_CLASS,
-	.ids	= ACPI_SNC_HID,
-	.ops	= {
-			.add	= sony_acpi_add,
-			.remove	= sony_acpi_remove,
-		  },
-};
-
 static acpi_handle sony_acpi_handle;
 static struct proc_dir_entry *sony_acpi_dir;
 
@@ -69,6 +56,8 @@ static struct sony_acpi_value {
 	char			*acpiset;/* name of the ACPI get function */
 	int 			min;	 /* minimum allowed value or -1 */
 	int			max;	 /* maximum allowed value or -1 */
+	int			value;	 /* current setting */
+	int			valid;	 /* Has ever been set */
 	int			debug;	 /* active only in debug mode ? */
 } sony_acpi_values[] = {
 	{
@@ -239,10 +228,30 @@ static int sony_acpi_write(struct file *file, const char __user *buffer,
 
 	if (acpi_callsetfunc(sony_acpi_handle, item->acpiset, value, NULL) < 0)
 		return -EIO;
-
+	item->value = value;
+	item->valid = 1;
 	return count;
 }
 
+static int sony_acpi_resume(struct acpi_device *device, int state)
+{
+	struct sony_acpi_value *item;
+
+	for (item = sony_acpi_values; item->name; item++) {
+		int ret;
+
+		if (!item->valid)
+			continue;
+		ret = acpi_callsetfunc(sony_acpi_handle, item->acpiset,
+					item->value, NULL);
+		if (ret < 0) {
+			printk("%s: %d\n", __FUNCTION__, ret);
+			break;
+		}
+	}
+	return 0;
+}
+
 static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
 	printk(LOG_PFX "sony_acpi_notify\n");
@@ -344,7 +353,6 @@ outwalk:
 	return result;
 }
 
-
 static int sony_acpi_remove(struct acpi_device *device, int type)
 {
 	acpi_status status;
@@ -367,6 +375,17 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	return 0;
 }
 
+static struct acpi_driver sony_acpi_driver = {
+	.name	= ACPI_SNC_DRIVER_NAME,
+	.class	= ACPI_SNC_CLASS,
+	.ids	= ACPI_SNC_HID,
+	.ops	= {
+			.add	= sony_acpi_add,
+			.remove	= sony_acpi_remove,
+			.resume = sony_acpi_resume,
+		  },
+};
+
 static int __init sony_acpi_init(void)
 {
 	int result;
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#3 lore raw

PATCH 3/41 sony_acpi: Fix sony_acpi_resume call

From: Andrew Morton <[email protected]>

---
 drivers/acpi/sony_acpi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/sony_acpi.c +1 -1
index beb56b9..f323c2c 100644
@@ -233,7 +233,7 @@ static int sony_acpi_write(struct file *file, const char __user *buffer,
 	return count;
 }
 
-static int sony_acpi_resume(struct acpi_device *device, int state)
+static int sony_acpi_resume(struct acpi_device *device)
 {
 	struct sony_acpi_value *item;
 
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#4 lore raw

PATCH 4/41 sony_acpi: Add backlight support to the sony_acpi

From: Alessandro Guido <[email protected]>

Make the sony_acpi use the backlight subsystem to adjust brightness value instead of using the /proc/sony/brightness file. (Other settings will still have a /proc/sony/... entry)

---
 drivers/acpi/Kconfig     |    1 +
 drivers/acpi/sony_acpi.c |   59 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 48 insertions(+), 12 deletions(-)
drivers/acpi/Kconfig +1 -0
index e11371f..364e6fe 100644
@@ -255,6 +255,7 @@ config ACPI_TOSHIBA
 config ACPI_SONY
 	tristate "Sony Laptop Extras"
 	depends on X86 && ACPI
+	select BACKLIGHT_CLASS_DEVICE
 	default m
 	  ---help---
 	  This mini-driver drives the ACPI SNC device present in the
drivers/acpi/sony_acpi.c +47 -12

112 lines not on this page · raw message

Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#5 lore raw

PATCH 5/41 sony_acpi: Add backlight support to the sony_acpi v2

From: Alessandro Guido <[email protected]>

Enable the sony_acpi driver to use the backlight subsysyem for adjusting the monitor brightness. Old way of changing the brightness will be still available for compatibility with existing tools.

---
 drivers/acpi/sony_acpi.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/acpi/sony_acpi.c +8 -0
index d509468..fd7d55a 100644
@@ -77,6 +77,14 @@ static struct sony_acpi_value {
 	int			debug;	 /* active only in debug mode ? */
 } sony_acpi_values[] = {
 	{
+		.name		= "brightness",
+		.acpiget	= "GBRT",
+		.acpiset	= "SBRT",
+		.min		= 1,
+		.max		= SONY_MAX_BRIGHTNESS,
+		.debug		= 0,
+	},
+	{
 		.name		= "brightness_default",
 		.acpiget	= "GPBR",
 		.acpiset	= "SPBR",
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#6 lore raw

PATCH 6/41 sony_acpi: Video sysfs support take 2

From: Andrew Morton <[email protected]>

add dev argument for backlight_device_register

---
 drivers/acpi/sony_acpi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/sony_acpi.c +1 -1
index fd7d55a..195895c 100644
@@ -322,7 +322,7 @@ static int sony_acpi_add(struct acpi_device *device)
 
 	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
 		sony_backlight_device = backlight_device_register("sony", NULL,
-					&sony_backlight_properties);
+					NULL, &sony_backlight_properties);
 	        if (IS_ERR(sony_backlight_device)) {
         	        printk(LOG_PFX "unable to register backlight device\n");
 		}
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#7 lore raw

PATCH 7/41 sony_acpi: Add acpi_bus_generate event

From: Stelian Pop <[email protected]>

Added acpi_bus_generate event for forwarding Fn-keys pressed to acpi subsystem, and made correspondent necessary changes for this to work.

---
 drivers/acpi/sony_acpi.c |   53 ++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 25 deletions(-)
drivers/acpi/sony_acpi.c +28 -25
index 195895c..138f2b6 100644
@@ -54,6 +54,7 @@ MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
 
 static acpi_handle sony_acpi_handle;
 static struct proc_dir_entry *sony_acpi_dir;
+static struct acpi_device *sony_acpi_acpi_device = NULL;
 
 static int sony_backlight_update_status(struct backlight_device *bd);
 static int sony_backlight_get_brightness(struct backlight_device *bd);
@@ -270,7 +271,9 @@ static int sony_acpi_resume(struct acpi_device *device)
 
 static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
-	printk(LOG_PFX "sony_acpi_notify\n");
+	if (debug)
+		printk(LOG_PFX "sony_acpi_notify, event: %d\n", event);
+	acpi_bus_generate_event(sony_acpi_acpi_device, 1, event);
 }
 
 static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
@@ -295,6 +298,8 @@ static int sony_acpi_add(struct acpi_device *device)
 	acpi_handle handle;
 	struct sony_acpi_value *item;
 
+	sony_acpi_acpi_device = device;
+
 	sony_acpi_handle = device->handle;
 
 	acpi_driver_data(device) = NULL;
@@ -308,16 +313,16 @@ static int sony_acpi_add(struct acpi_device *device)
 			result = -ENODEV;
 			goto outwalk;
 		}
+	}
 
-		status = acpi_install_notify_handler(sony_acpi_handle,
-						     ACPI_DEVICE_NOTIFY,
-						     sony_acpi_notify,
-						     NULL);
-		if (ACPI_FAILURE(status)) {
-			printk(LOG_PFX "unable to install notify handler\n");
-			result = -ENODEV;
-			goto outnotify;
-		}
+	status = acpi_install_notify_handler(sony_acpi_handle,
+					     ACPI_DEVICE_NOTIFY,
+					     sony_acpi_notify,
+					     NULL);
+	if (ACPI_FAILURE(status)) {
+		printk(LOG_PFX "unable to install notify handler\n");
+		result = -ENODEV;
+		goto outnotify;
 	}
 
 	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
@@ -342,7 +347,7 @@ static int sony_acpi_add(struct acpi_device *device)
 		    		 item->acpiset, &handle)))
 		    	continue;
 
-		item->proc = create_proc_entry(item->name, 0600,
+		item->proc = create_proc_entry(item->name, 0666,
 					       acpi_device_dir(device));
 		if (!item->proc) {
 			printk(LOG_PFX "unable to create proc entry\n");
@@ -361,13 +366,11 @@ static int sony_acpi_add(struct acpi_device *device)
 	return 0;
 
 outproc:
-	if (debug) {
-		status = acpi_remove_notify_handler(sony_acpi_handle,
-						    ACPI_DEVICE_NOTIFY,
-						    sony_acpi_notify);
-		if (ACPI_FAILURE(status))
-			printk(LOG_PFX "unable to remove notify handler\n");
-	}
+	status = acpi_remove_notify_handler(sony_acpi_handle,
+					    ACPI_DEVICE_NOTIFY,
+					    sony_acpi_notify);
+	if (ACPI_FAILURE(status))
+		printk(LOG_PFX "unable to remove notify handler\n");
 outnotify:
 	for (item = sony_acpi_values; item->name; ++item)
 		if (item->proc)
@@ -384,13 +387,13 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	if (sony_backlight_device)
 		backlight_device_unregister(sony_backlight_device);
 
-	if (debug) {
-		status = acpi_remove_notify_handler(sony_acpi_handle,
-						    ACPI_DEVICE_NOTIFY,
-						    sony_acpi_notify);
-		if (ACPI_FAILURE(status))
-			printk(LOG_PFX "unable to remove notify handler\n");
-	}
+	sony_acpi_acpi_device = NULL;
+
+	status = acpi_remove_notify_handler(sony_acpi_handle,
+					    ACPI_DEVICE_NOTIFY,
+					    sony_acpi_notify);
+	if (ACPI_FAILURE(status))
+		printk(LOG_PFX "unable to remove notify handler\n");
 
 	for (item = sony_acpi_values; item->name; ++item)
 		if (item->proc)
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#8 lore raw

PATCH 8/41 sony_acpi: Allow easier debugging for the unknown SNC methods.

From: Mattia Dongili <[email protected]>

Allow the existence of a setter method without a getter and viceversa, additionaly set /proc file permissions reflecting it.
Fix also the error exit path.

---
 drivers/acpi/sony_acpi.c |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)
drivers/acpi/sony_acpi.c +21 -9
index 138f2b6..69122ad 100644
@@ -296,6 +296,7 @@ static int sony_acpi_add(struct acpi_device *device)
 	acpi_status status;
 	int result;
 	acpi_handle handle;
+	mode_t proc_file_mode;
 	struct sony_acpi_value *item;
 
 	sony_acpi_acpi_device = device;
@@ -334,20 +335,31 @@ static int sony_acpi_add(struct acpi_device *device)
 	}
 
 	for (item = sony_acpi_values; item->name; ++item) {
+		proc_file_mode = 0;
+
 		if (!debug && item->debug)
 			continue;
 
 		if (item->acpiget &&
-		    ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
 		    		 item->acpiget, &handle)))
-		    	continue;
+			proc_file_mode = S_IRUSR;
+		else
+			printk(LOG_PFX "unable to get ACPI handle for %s (get)\n",
+					item->name);
 
 		if (item->acpiset &&
-		    ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
 		    		 item->acpiset, &handle)))
-		    	continue;
+			proc_file_mode |= S_IWUSR;
+		else
+			printk(LOG_PFX "unable to get ACPI handle for %s (set)\n",
+					item->name);
+
+		if (proc_file_mode == 0)
+			continue;
 
-		item->proc = create_proc_entry(item->name, 0666,
+		item->proc = create_proc_entry(item->name, proc_file_mode,
 					       acpi_device_dir(device));
 		if (!item->proc) {
 			printk(LOG_PFX "unable to create proc entry\n");
@@ -366,15 +378,15 @@ static int sony_acpi_add(struct acpi_device *device)
 	return 0;
 
 outproc:
+	for (item = sony_acpi_values; item->name; ++item)
+		if (item->proc)
+			remove_proc_entry(item->name, acpi_device_dir(device));
+outnotify:
 	status = acpi_remove_notify_handler(sony_acpi_handle,
 					    ACPI_DEVICE_NOTIFY,
 					    sony_acpi_notify);
 	if (ACPI_FAILURE(status))
 		printk(LOG_PFX "unable to remove notify handler\n");
-outnotify:
-	for (item = sony_acpi_values; item->name; ++item)
-		if (item->proc)
-			remove_proc_entry(item->name, acpi_device_dir(device));
 outwalk:
 	return result;
 }
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#9 lore raw

PATCH 9/41 sony_acpi: Add lanpower and audiopower controls

From: Mattia Dongili <[email protected]>

audiopower works well on my SZ72B so it's not marked has "debug" while lanpower has at least one report of not resuming power happily so morked as "debug"

---
 drivers/acpi/sony_acpi.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
drivers/acpi/sony_acpi.c +18 -2
index 69122ad..1f7dca3 100644
@@ -102,11 +102,27 @@ static struct sony_acpi_value {
 		.name		= "cdpower",
 		.acpiget	= "GCDP",
 		.acpiset	= "SCDP",
-		.min		= -1,
-		.max		= -1,
+		.min		= 0,
+		.max		= 1,
 		.debug		= 0,
 	},
 	{
+		.name           = "audiopower",
+		.acpiget        = "GAZP",
+		.acpiset        = "AZPW",
+		.min            = 0,
+		.max            = 1,
+		.debug          = 0,
+	},
+	{
+		.name           = "lanpower",
+		.acpiget        = "GLNP",
+		.acpiset        = "LNPW",
+		.min            = 0,
+		.max            = 1,
+		.debug          = 1,
+	},
+	{
 		.name		= "PID",
 		.acpiget	= "GPID",
 		.debug		= 1,
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#10 lore raw

PATCH 10/41 sony_acpi: Allow multiple sony_acpi_values for the same .name

From: Mattia Dongili <[email protected]>

The acpi handles are kept _only_ if both the requested .acpiget and .acpiset are available in the DSDT.
Currently only the SCDP/CDPW dualism is known.

---
 drivers/acpi/sony_acpi.c |   44 +++++++++++++++++++++++++-------------------
 1 files changed, 25 insertions(+), 19 deletions(-)
drivers/acpi/sony_acpi.c +25 -19
index 1f7dca3..c65f589 100644
@@ -68,7 +68,7 @@ static struct backlight_properties sony_backlight_properties = {
 
 static struct sony_acpi_value {
 	char			*name;	 /* name of the entry */
-	struct proc_dir_entry 	*proc;	 /* /proc entry */
+	struct proc_dir_entry	*proc;	 /* /proc entry */
 	char			*acpiget;/* name of the ACPI get function */
 	char			*acpiset;/* name of the ACPI get function */
 	int 			min;	 /* minimum allowed value or -1 */
@@ -78,6 +78,7 @@ static struct sony_acpi_value {
 	int			debug;	 /* active only in debug mode ? */
 } sony_acpi_values[] = {
 	{
+		/* for backward compatibility only */
 		.name		= "brightness",
 		.acpiget	= "GBRT",
 		.acpiset	= "SBRT",
@@ -107,6 +108,14 @@ static struct sony_acpi_value {
 		.debug		= 0,
 	},
 	{
+		.name		= "cdpower",
+		.acpiget	= "GCDP",
+		.acpiset	= "CDPW",
+		.min		= 0,
+		.max		= 1,
+		.debug		= 0,
+	},
+	{
 		.name           = "audiopower",
 		.acpiget        = "GAZP",
 		.acpiset        = "AZPW",
@@ -356,27 +365,24 @@ static int sony_acpi_add(struct acpi_device *device)
 		if (!debug && item->debug)
 			continue;
 
-		if (item->acpiget &&
-		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
-		    		 item->acpiget, &handle)))
-			proc_file_mode = S_IRUSR;
-		else
-			printk(LOG_PFX "unable to get ACPI handle for %s (get)\n",
-					item->name);
-
-		if (item->acpiset &&
-		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
-		    		 item->acpiset, &handle)))
-			proc_file_mode |= S_IWUSR;
-		else
-			printk(LOG_PFX "unable to get ACPI handle for %s (set)\n",
-					item->name);
+		if (item->acpiget) {
+			if (ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+							item->acpiget, &handle)))
+				continue;
 
-		if (proc_file_mode == 0)
-			continue;
+			proc_file_mode |= S_IRUSR;
+		}
+
+		if (item->acpiset) {
+			if (ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
+							item->acpiset, &handle)))
+				continue;
+
+			proc_file_mode |= S_IWUSR;
+		}
 
 		item->proc = create_proc_entry(item->name, proc_file_mode,
-					       acpi_device_dir(device));
+				acpi_device_dir(device));
 		if (!item->proc) {
 			printk(LOG_PFX "unable to create proc entry\n");
 			result = -EIO;
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#11 lore raw

PATCH 11/41 sony_acpi: Fix sony_acpi backlight registration and unregistration

From: Mattia Dongili <[email protected]>

Initialize the current brightness if the driver registration was successful and unregister the driver in the error exit path.

---
 drivers/acpi/sony_acpi.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/acpi/sony_acpi.c +8 -0
index c65f589..c01d98d 100644
@@ -354,9 +354,14 @@ static int sony_acpi_add(struct acpi_device *device)
 	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
 		sony_backlight_device = backlight_device_register("sony", NULL,
 					NULL, &sony_backlight_properties);
+
 	        if (IS_ERR(sony_backlight_device)) {
         	        printk(LOG_PFX "unable to register backlight device\n");
+			sony_backlight_device = NULL;
 		}
+		else
+			sony_backlight_properties.brightness =
+				sony_backlight_get_brightness(sony_backlight_device);
 	}
 
 	for (item = sony_acpi_values; item->name; ++item) {
@@ -400,6 +405,9 @@ static int sony_acpi_add(struct acpi_device *device)
 	return 0;
 
 outproc:
+	if (sony_backlight_device)
+		backlight_device_unregister(sony_backlight_device);
+
 	for (item = sony_acpi_values; item->name; ++item)
 		if (item->proc)
 			remove_proc_entry(item->name, acpi_device_dir(device));
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#12 lore raw

PATCH 12/41 sony-laptop: create from sony_acpi

From: Mattia Dongili <[email protected]>

Move drivers/acpi/sony_acpi.c to drivers/misc/sony-laptop.c with all the necessary configuration.
The SONY_LAPTOP config option substitutes the old ACPI_SONY and is 'default n' now.

---
 drivers/acpi/Kconfig       |   15 --
 drivers/acpi/Makefile      |    1 -
 drivers/acpi/sony_acpi.c   |  504 --------------------------------------------
 drivers/misc/Kconfig       |   14 ++
 drivers/misc/Makefile      |    1 +
 drivers/misc/sony-laptop.c |  504 ++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 519 insertions(+), 520 deletions(-)
 delete mode 100644 drivers/acpi/sony_acpi.c
 create mode 100644 drivers/misc/sony-laptop.c
drivers/acpi/Kconfig +0 -15
index 364e6fe..f4f000a 100644
@@ -252,21 +252,6 @@ config ACPI_TOSHIBA
 	  If you have a legacy free Toshiba laptop (such as the Libretto L1
 	  series), say Y.
 
-config ACPI_SONY
-	tristate "Sony Laptop Extras"
-	depends on X86 && ACPI
-	select BACKLIGHT_CLASS_DEVICE
-	default m
-	  ---help---
-	  This mini-driver drives the ACPI SNC device present in the
-	  ACPI BIOS of the Sony Vaio laptops.
-
-	  It gives access to some extra laptop functionalities. In
-	  its current form, the only thing this driver does is letting
-	  the user set or query the screen brightness.
-
-	  Read <file:Documentation/acpi/sony_acpi.txt> for more information.
-
 config ACPI_CUSTOM_DSDT
 	bool "Include Custom DSDT"
 	depends on !STANDALONE
drivers/acpi/Makefile +0 -1
index 31b9ad2..bce7ca2 100644
@@ -53,7 +53,6 @@ obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
 obj-$(CONFIG_ACPI_SYSTEM)	+= system.o event.o
 obj-$(CONFIG_ACPI_DEBUG)	+= debug.o
 obj-$(CONFIG_ACPI_NUMA)		+= numa.o
-obj-$(CONFIG_ACPI_SONY)		+= sony_acpi.o
 obj-$(CONFIG_ACPI_ASUS)		+= asus_acpi.o
 obj-$(CONFIG_ACPI_IBM)		+= ibm_acpi.o
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
drivers/acpi/sony_acpi.c deleted +0 -504

504 lines not on this page · raw message

drivers/misc/Kconfig +14 -0
index 00db31c..78fc47b 100644
@@ -88,4 +88,18 @@ config MSI_LAPTOP
 
 	  If you have an MSI S270 laptop, say Y or M here.
 
+config SONY_LAPTOP
+	tristate "Sony Laptop Extras"
+	depends on X86 && ACPI
+	select BACKLIGHT_CLASS_DEVICE
+	  ---help---
+	  This mini-driver drives the ACPI SNC device present in the
+	  ACPI BIOS of the Sony Vaio laptops.
+
+	  It gives access to some extra laptop functionalities. In
+	  its current form, the only thing this driver does is letting
+	  the user set or query the screen brightness.
+
+	  Read <file:Documentation/acpi/sony_acpi.txt> for more information.
+
 endmenu
drivers/misc/Makefile +1 -0
index c9e98ab..f86f9dc 100644
@@ -10,3 +10,4 @@ obj-$(CONFIG_LKDTM)		+= lkdtm.o
 obj-$(CONFIG_TIFM_CORE)       	+= tifm_core.o
 obj-$(CONFIG_TIFM_7XX1)       	+= tifm_7xx1.o
 obj-$(CONFIG_SGI_IOC4)		+= ioc4.o
+obj-$(CONFIG_SONY_LAPTOP)	+= sony-laptop.o
drivers/misc/sony-laptop.c new file +504 -0

504 lines not on this page · raw message

Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#13 lore raw

PATCH 13/41 sony-laptop: Remove /proc/acpi/sony interface and implement platform_device.

From: Mattia Dongili <[email protected]>

Rework method names list to allow an easier management of multiple values.
Add myself as author/maintainer and bump the version number.

---
 drivers/misc/sony-laptop.c |  396 ++++++++++++++++++++++----------------------
 1 files changed, 198 insertions(+), 198 deletions(-)
drivers/misc/sony-laptop.c +198 -198
index 103657e..1d14969 100644
@@ -2,6 +2,7 @@
  * ACPI Sony Notebook Control Driver (SNC)
  *
  * Copyright (C) 2004-2005 Stelian Pop <[email protected]>
+ * Copyright (C) 2007 Mattia Dongili <[email protected]>
  *
  * Parts of this driver inspired from asus_acpi.c and ibm_acpi.c
  * which are copyrighted by their respective authors.
@@ -28,6 +29,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/backlight.h>
+#include <linux/platform_device.h>
 #include <linux/err.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
@@ -35,15 +37,15 @@
 
 #define ACPI_SNC_CLASS		"sony"
 #define ACPI_SNC_HID		"SNY5001"
-#define ACPI_SNC_DRIVER_NAME	"ACPI Sony Notebook Control Driver v0.3"
+#define ACPI_SNC_DRIVER_NAME	"ACPI Sony Notebook Control Driver v0.4"
 
 /* the device uses 1-based values, while the backlight subsystem uses
    0-based values */
 #define SONY_MAX_BRIGHTNESS	8
 
-#define LOG_PFX			KERN_WARNING "sony_acpi: "
+#define LOG_PFX			KERN_WARNING "sony-laptop: "
 
-MODULE_AUTHOR("Stelian Pop");
+MODULE_AUTHOR("Stelian Pop, Mattia Dongili");
 MODULE_DESCRIPTION(ACPI_SNC_DRIVER_NAME);
 MODULE_LICENSE("GPL");
 
@@ -52,10 +54,6 @@ module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
 			"the development of this driver");
 
-static acpi_handle sony_acpi_handle;
-static struct proc_dir_entry *sony_acpi_dir;
-static struct acpi_device *sony_acpi_acpi_device = NULL;
-
 static int sony_backlight_update_status(struct backlight_device *bd);
 static int sony_backlight_get_brightness(struct backlight_device *bd);
 static struct backlight_device *sony_backlight_device;
@@ -66,105 +64,79 @@ static struct backlight_properties sony_backlight_properties = {
 	.max_brightness	= SONY_MAX_BRIGHTNESS - 1,
 };
 
-static struct sony_acpi_value {
-	char			*name;	 /* name of the entry */
-	struct proc_dir_entry	*proc;	 /* /proc entry */
-	char			*acpiget;/* name of the ACPI get function */
-	char			*acpiset;/* name of the ACPI get function */
-	int 			min;	 /* minimum allowed value or -1 */
-	int			max;	 /* maximum allowed value or -1 */
-	int			value;	 /* current setting */
-	int			valid;	 /* Has ever been set */
-	int			debug;	 /* active only in debug mode ? */
-} sony_acpi_values[] = {
-	{
-		/* for backward compatibility only */
-		.name		= "brightness",
-		.acpiget	= "GBRT",
-		.acpiset	= "SBRT",
-		.min		= 1,
-		.max		= SONY_MAX_BRIGHTNESS,
-		.debug		= 0,
-	},
-	{
-		.name		= "brightness_default",
-		.acpiget	= "GPBR",
-		.acpiset	= "SPBR",
-		.min		= 1,
-		.max		= SONY_MAX_BRIGHTNESS,
-		.debug		= 0,
-	},
-	{
-		.name           = "fnkey",
-		.acpiget        = "GHKE",
-		.debug          = 0,
-	},
-	{
-		.name		= "cdpower",
-		.acpiget	= "GCDP",
-		.acpiset	= "SCDP",
-		.min		= 0,
-		.max		= 1,
-		.debug		= 0,
-	},
-	{
-		.name		= "cdpower",
-		.acpiget	= "GCDP",
-		.acpiset	= "CDPW",
-		.min		= 0,
-		.max		= 1,
-		.debug		= 0,
-	},
-	{
-		.name           = "audiopower",
-		.acpiget        = "GAZP",
-		.acpiset        = "AZPW",
-		.min            = 0,
-		.max            = 1,
-		.debug          = 0,
-	},
-	{
-		.name           = "lanpower",
-		.acpiget        = "GLNP",
-		.acpiset        = "LNPW",
-		.min            = 0,
-		.max            = 1,
-		.debug          = 1,
-	},
-	{
-		.name		= "PID",
-		.acpiget	= "GPID",
-		.debug		= 1,
-	},
-	{
-		.name		= "CTR",
-		.acpiget	= "GCTR",
-		.acpiset	= "SCTR",
-		.min		= -1,
-		.max		= -1,
-		.debug		= 1,
-	},
-	{
-		.name		= "PCR",
-		.acpiget	= "GPCR",
-		.acpiset	= "SPCR",
-		.min		= -1,
-		.max		= -1,
-		.debug		= 1,
-	},
-	{
-		.name		= "CMI",
-		.acpiget	= "GCMI",
-		.acpiset	= "SCMI",
-		.min		= -1,
-		.max		= -1,
-		.debug		= 1,
-	},
-	{
-		.name		= NULL,
+static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *);
+static ssize_t sony_acpi_store(struct device *, struct device_attribute *, const char *, size_t);
+
+struct sony_acpi_value {
+	char			*name;		/* name of the entry */
+	char			**acpiget;	/* names of the ACPI get function */
+	char			**acpiset;	/* names of the ACPI set function */
+	int 			min;		/* minimum allowed value or -1 */
+	int			max;		/* maximum allowed value or -1 */
+	int			value;		/* current setting */
+	int			valid;		/* Has ever been set */
+	int			debug;		/* active only in debug mode ? */
+	struct device_attribute	devattr;	/* sysfs atribute */
+};
+
+#define HANDLE_NAMES(_name, _values...) \
+	static char *snc_##_name[] = { _values, NULL }
+
+#define SONY_ACPI_VALUE(_name, _getters, _setters, _min, _max, _debug) \
+	{ \
+		.name		= __stringify(_name), \
+		.acpiget	= _getters, \
+		.acpiset	= _setters, \
+		.min		= _min, \
+		.max		= _max, \
+		.debug		= _debug, \
+		.devattr	= __ATTR(_name, 0, sony_acpi_show, sony_acpi_store), \
 	}
+
+#define SONY_ACPI_VALUE_NULL	{ .name = NULL }
+
+HANDLE_NAMES(fnkey_get, "GHKE");
+
+HANDLE_NAMES(brightness_def_get, "GPBR");
+HANDLE_NAMES(brightness_def_set, "SPBR");
+
+HANDLE_NAMES(cdpower_get, "GCDP");
+HANDLE_NAMES(cdpower_set, "SCDP", "CDPW");
+
+HANDLE_NAMES(audiopower_get, "GAZP");
+HANDLE_NAMES(audiopower_set, "AZPW");
+
+HANDLE_NAMES(lanpower_get, "GLNP");
+HANDLE_NAMES(lanpower_set, "LNPW");
+
+HANDLE_NAMES(PID_get, "GPID");
+
+HANDLE_NAMES(CTR_get, "GCTR");
+HANDLE_NAMES(CTR_set, "SCTR");
+
+HANDLE_NAMES(PCR_get, "GPCR");
+HANDLE_NAMES(PCR_set, "SPCR");
+
+HANDLE_NAMES(CMI_get, "GCMI");
+HANDLE_NAMES(CMI_set, "SCMI");
+
+static struct sony_acpi_value sony_acpi_values[] = {
+	SONY_ACPI_VALUE(brightness_default, snc_brightness_def_get, snc_brightness_def_set, 1, SONY_MAX_BRIGHTNESS, 0),
+	SONY_ACPI_VALUE(fnkey,		snc_fnkey_get, NULL, -1, -1, 0),
+	SONY_ACPI_VALUE(cdpower,	snc_cdpower_get, snc_cdpower_set, 0, 1, 0),
+	SONY_ACPI_VALUE(audiopower,	snc_audiopower_get, snc_audiopower_set, 0, 1, 0),
+	SONY_ACPI_VALUE(lanpower,	snc_lanpower_get, snc_lanpower_set, 0, 1, 1),
+	/* unknown methods */
+	SONY_ACPI_VALUE(PID,		snc_PID_get, NULL, -1, -1, 1),
+	SONY_ACPI_VALUE(CTR,		snc_CTR_get, snc_CTR_set, -1, -1, 1),
+	SONY_ACPI_VALUE(PCR,		snc_PCR_get, snc_PCR_set, -1, -1, 1),
+	SONY_ACPI_VALUE(CMI,		snc_CMI_get, snc_CMI_set, -1, -1, 1),
+	SONY_ACPI_VALUE_NULL
 };
 
+static acpi_handle sony_acpi_handle;
+static struct acpi_device *sony_acpi_acpi_device = NULL;
+
 static int acpi_callgetfunc(acpi_handle handle, char *name, int *result)
 {
 	struct acpi_buffer output;
@@ -220,61 +192,149 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,
 	return -1;
 }
 
-static int parse_buffer(const char __user *buffer, unsigned long count,
-			int *val) {
-	char s[32];
-	int ret;
-
-	if (count > 31)
-		return -EINVAL;
-	if (copy_from_user(s, buffer, count))
-		return -EFAULT;
-	s[count] = '\0';
-	ret = simple_strtoul(s, NULL, 10);
-	*val = ret;
-	return 0;
-}
-
-static int sony_acpi_read(char* page, char** start, off_t off, int count,
-			  int* eof, void *data)
+/*
+ * Sysfs show/store common to all sony_acpi_values
+ */
+static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr,
+		char *buffer)
 {
-	struct sony_acpi_value *item = data;
 	int value;
+	struct sony_acpi_value *item = container_of(attr, struct sony_acpi_value, devattr);
 
-	if (!item->acpiget)
+	if (!*item->acpiget)
 		return -EIO;
 
-	if (acpi_callgetfunc(sony_acpi_handle, item->acpiget, &value) < 0)
+	if (acpi_callgetfunc(sony_acpi_handle, *item->acpiget, &value) < 0)
 		return -EIO;
 
-	return sprintf(page, "%d\n", value);
+	return snprintf(buffer, PAGE_SIZE, "%d\n", value);
 }
 
-static int sony_acpi_write(struct file *file, const char __user *buffer,
-			   unsigned long count, void *data)
+static ssize_t sony_acpi_store(struct device *dev, struct device_attribute *attr,
+		const char *buffer, size_t count)
 {
-	struct sony_acpi_value *item = data;
-	int result;
 	int value;
+	struct sony_acpi_value *item = container_of(attr, struct sony_acpi_value, devattr);
 
 	if (!item->acpiset)
 		return -EIO;
 
-	if ((result = parse_buffer(buffer, count, &value)) < 0)
-		return result;
+	if (count > 31)
+		return -EINVAL;
+
+	value = simple_strtoul(buffer, NULL, 10);
 
 	if (item->min != -1 && value < item->min)
 		return -EINVAL;
 	if (item->max != -1 && value > item->max)
 		return -EINVAL;
 
-	if (acpi_callsetfunc(sony_acpi_handle, item->acpiset, value, NULL) < 0)
+	if (acpi_callsetfunc(sony_acpi_handle, *item->acpiset, value, NULL) < 0)
 		return -EIO;
 	item->value = value;
 	item->valid = 1;
 	return count;
 }
 
+/*
+ * Platform device
+ */
+static struct platform_driver sncpf_driver = {
+	.driver = {
+		.name = "sony-laptop",
+		.owner = THIS_MODULE,
+	}
+};
+static struct platform_device *sncpf_device;
+
+static int sony_snc_pf_add(void)
+{
+	acpi_handle handle;
+	struct sony_acpi_value *item;
+	int ret = 0;
+
+	ret = platform_driver_register(&sncpf_driver);
+	if (ret)
+		goto out;
+
+	sncpf_device = platform_device_alloc("sony-laptop", -1);
+	if (!sncpf_device) {
+		ret = -ENOMEM;
+		goto out_platform_registered;
+	}
+
+	ret = platform_device_add(sncpf_device);
+	if (ret)
+		goto out_platform_alloced;
+
+	for (item = sony_acpi_values; item->name; ++item) {
+
+		if (!debug && item->debug)
+			continue;
+
+		/* find the available acpiget as described in the DSDT */
+		for (; item->acpiget && *item->acpiget; ++item->acpiget) {
+			if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
+							*item->acpiget,
+							&handle))) {
+				if (debug)
+					printk(LOG_PFX "Found %s getter: %s\n",
+							item->name,
+							*item->acpiget);
+				item->devattr.attr.mode |= S_IRUGO;
+				break;
+			}
+		}
+
+		/* find the available acpiset as described in the DSDT */
+		for (; item->acpiset && *item->acpiset; ++item->acpiset) {
+			if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
+							*item->acpiset,
+							&handle))) {
+				if (debug)
+					printk(LOG_PFX "Found %s setter: %s\n",
+							item->name,
+							*item->acpiset);
+				item->devattr.attr.mode |= S_IWUSR;
+				break;
+			}
+		}
+
+	       if (item->devattr.attr.mode != 0) {
+		       ret = device_create_file(&sncpf_device->dev, &item->devattr);
+		       if (ret)
+			       goto out_sysfs;
+	       }
+	}
+
+	return 0;
+
+out_sysfs:
+	for (item = sony_acpi_values; item->name; ++item) {
+		device_remove_file(&sncpf_device->dev, &item->devattr);
+	}
+	platform_device_del(sncpf_device);
+out_platform_alloced:
+	platform_device_put(sncpf_device);
+out_platform_registered:
+	platform_driver_unregister(&sncpf_driver);
+out:
+	return ret;
+}
+
+static void sony_snc_pf_remove(void)
+{
+	struct sony_acpi_value *item;
+
+	for (item = sony_acpi_values; item->name; ++item) {
+		device_remove_file(&sncpf_device->dev, &item->devattr);
+	}
+
+	platform_device_del(sncpf_device);
+	platform_device_put(sncpf_device);
+	platform_driver_unregister(&sncpf_driver);
+}
+
 static int sony_acpi_resume(struct acpi_device *device)
 {
 	struct sony_acpi_value *item;
@@ -284,7 +344,7 @@ static int sony_acpi_resume(struct acpi_device *device)
 
 		if (!item->valid)
 			continue;
-		ret = acpi_callsetfunc(sony_acpi_handle, item->acpiset,
+		ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset,
 					item->value, NULL);
 		if (ret < 0) {
 			printk("%s: %d\n", __FUNCTION__, ret);
@@ -321,16 +381,11 @@ static int sony_acpi_add(struct acpi_device *device)
 	acpi_status status;
 	int result;
 	acpi_handle handle;
-	mode_t proc_file_mode;
-	struct sony_acpi_value *item;
 
 	sony_acpi_acpi_device = device;
 
 	sony_acpi_handle = device->handle;
 
-	acpi_driver_data(device) = NULL;
-	acpi_device_dir(device) = sony_acpi_dir;
-
 	if (debug) {
 		status = acpi_walk_namespace(ACPI_TYPE_METHOD, sony_acpi_handle,
 					     1, sony_walk_callback, NULL, NULL);
@@ -348,7 +403,7 @@ static int sony_acpi_add(struct acpi_device *device)
 	if (ACPI_FAILURE(status)) {
 		printk(LOG_PFX "unable to install notify handler\n");
 		result = -ENODEV;
-		goto outnotify;
+		goto outwalk;
 	}
 
 	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
@@ -364,54 +419,17 @@ static int sony_acpi_add(struct acpi_device *device)
 				sony_backlight_get_brightness(sony_backlight_device);
 	}
 
-	for (item = sony_acpi_values; item->name; ++item) {
-		proc_file_mode = 0;
-
-		if (!debug && item->debug)
-			continue;
-
-		if (item->acpiget) {
-			if (ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
-							item->acpiget, &handle)))
-				continue;
-
-			proc_file_mode |= S_IRUSR;
-		}
-
-		if (item->acpiset) {
-			if (ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
-							item->acpiset, &handle)))
-				continue;
-
-			proc_file_mode |= S_IWUSR;
-		}
-
-		item->proc = create_proc_entry(item->name, proc_file_mode,
-				acpi_device_dir(device));
-		if (!item->proc) {
-			printk(LOG_PFX "unable to create proc entry\n");
-			result = -EIO;
-			goto outproc;
-		}
-
-		item->proc->read_proc = sony_acpi_read;
-		item->proc->write_proc = sony_acpi_write;
-		item->proc->data = item;
-		item->proc->owner = THIS_MODULE;
-	}
+	if (sony_snc_pf_add())
+		goto outbacklight;
 
 	printk(KERN_INFO ACPI_SNC_DRIVER_NAME " successfully installed\n");
 
 	return 0;
 
-outproc:
+outbacklight:
 	if (sony_backlight_device)
 		backlight_device_unregister(sony_backlight_device);
 
-	for (item = sony_acpi_values; item->name; ++item)
-		if (item->proc)
-			remove_proc_entry(item->name, acpi_device_dir(device));
-outnotify:
 	status = acpi_remove_notify_handler(sony_acpi_handle,
 					    ACPI_DEVICE_NOTIFY,
 					    sony_acpi_notify);
@@ -424,7 +442,6 @@ outwalk:
 static int sony_acpi_remove(struct acpi_device *device, int type)
 {
 	acpi_status status;
-	struct sony_acpi_value *item;
 
 	if (sony_backlight_device)
 		backlight_device_unregister(sony_backlight_device);
@@ -437,9 +454,7 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	if (ACPI_FAILURE(status))
 		printk(LOG_PFX "unable to remove notify handler\n");
 
-	for (item = sony_acpi_values; item->name; ++item)
-		if (item->proc)
-			remove_proc_entry(item->name, acpi_device_dir(device));
+	sony_snc_pf_remove();
 
 	printk(KERN_INFO ACPI_SNC_DRIVER_NAME " successfully removed\n");
 
@@ -476,28 +491,13 @@ static struct acpi_driver sony_acpi_driver = {
 
 static int __init sony_acpi_init(void)
 {
-	int result;
-
-	sony_acpi_dir = proc_mkdir("sony", acpi_root_dir);
-	if (!sony_acpi_dir) {
-		printk(LOG_PFX "unable to create /proc entry\n");
-		return -ENODEV;
-	}
-	sony_acpi_dir->owner = THIS_MODULE;
-
-	result = acpi_bus_register_driver(&sony_acpi_driver);
-	if (result < 0) {
-		remove_proc_entry("sony", acpi_root_dir);
-		return -ENODEV;
-	}
-	return 0;
+	return acpi_bus_register_driver(&sony_acpi_driver);
 }
 
 
 static void __exit sony_acpi_exit(void)
 {
 	acpi_bus_unregister_driver(&sony_acpi_driver);
-	remove_proc_entry("sony", acpi_root_dir);
 }
 
 module_init(sony_acpi_init);
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#14 lore raw

PATCH 14/41 sony-laptop: Small update to the Kconfig help to make people believe this driver is useful.

From: Mattia Dongili <[email protected]>

---
 drivers/misc/Kconfig |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/misc/Kconfig +2 -1
index 78fc47b..009aff8 100644
@@ -98,7 +98,8 @@ config SONY_LAPTOP
 
 	  It gives access to some extra laptop functionalities. In
 	  its current form, the only thing this driver does is letting
-	  the user set or query the screen brightness.
+	  the user set or query the screen brightness and remove/apply
+	  power to some devices.
 
 	  Read <file:Documentation/acpi/sony_acpi.txt> for more information.
 
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#15 lore raw

PATCH 15/41 sony-laptop: Group functions and structures to better draw subsytems usage

From: Mattia Dongili <[email protected]>

---
 drivers/misc/sony-laptop.c |   92 ++++++++++++++++++++++++-------------------
 1 files changed, 51 insertions(+), 41 deletions(-)
drivers/misc/sony-laptop.c +51 -41
index 1d14969..4a69ce7 100644
@@ -54,16 +54,6 @@ module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
 			"the development of this driver");
 
-static int sony_backlight_update_status(struct backlight_device *bd);
-static int sony_backlight_get_brightness(struct backlight_device *bd);
-static struct backlight_device *sony_backlight_device;
-static struct backlight_properties sony_backlight_properties = {
-	.owner		= THIS_MODULE,
-	.update_status	= sony_backlight_update_status,
-	.get_brightness	= sony_backlight_get_brightness,
-	.max_brightness	= SONY_MAX_BRIGHTNESS - 1,
-};
-
 static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *);
 static ssize_t sony_acpi_store(struct device *, struct device_attribute *, const char *, size_t);
 
@@ -137,6 +127,9 @@ static struct sony_acpi_value sony_acpi_values[] = {
 static acpi_handle sony_acpi_handle;
 static struct acpi_device *sony_acpi_acpi_device = NULL;
 
+/*
+ * acpi_evaluate_object wrappers
+ */
 static int acpi_callgetfunc(acpi_handle handle, char *name, int *result)
 {
 	struct acpi_buffer output;
@@ -335,25 +328,37 @@ static void sony_snc_pf_remove(void)
 	platform_driver_unregister(&sncpf_driver);
 }
 
-static int sony_acpi_resume(struct acpi_device *device)
+/*
+ * Backlight device
+ */
+static int sony_backlight_update_status(struct backlight_device *bd)
 {
-	struct sony_acpi_value *item;
+	return acpi_callsetfunc(sony_acpi_handle, "SBRT",
+				bd->props->brightness + 1,
+				NULL);
+}
 
-	for (item = sony_acpi_values; item->name; item++) {
-		int ret;
+static int sony_backlight_get_brightness(struct backlight_device *bd)
+{
+	int value;
 
-		if (!item->valid)
-			continue;
-		ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset,
-					item->value, NULL);
-		if (ret < 0) {
-			printk("%s: %d\n", __FUNCTION__, ret);
-			break;
-		}
-	}
-	return 0;
+	if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value))
+		return 0;
+	/* brightness levels are 1-based, while backlight ones are 0-based */
+	return value - 1;
 }
 
+static struct backlight_device *sony_backlight_device;
+static struct backlight_properties sony_backlight_properties = {
+	.owner		= THIS_MODULE,
+	.update_status	= sony_backlight_update_status,
+	.get_brightness	= sony_backlight_get_brightness,
+	.max_brightness	= SONY_MAX_BRIGHTNESS - 1,
+};
+
+/*
+ * ACPI callbacks
+ */
 static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
 	if (debug)
@@ -376,6 +381,28 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
 	return AE_OK;
 }
 
+/*
+ * ACPI device
+ */
+static int sony_acpi_resume(struct acpi_device *device)
+{
+	struct sony_acpi_value *item;
+
+	for (item = sony_acpi_values; item->name; item++) {
+		int ret;
+
+		if (!item->valid)
+			continue;
+		ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset,
+					item->value, NULL);
+		if (ret < 0) {
+			printk("%s: %d\n", __FUNCTION__, ret);
+			break;
+		}
+	}
+	return 0;
+}
+
 static int sony_acpi_add(struct acpi_device *device)
 {
 	acpi_status status;
@@ -461,23 +488,6 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 	return 0;
 }
 
-static int sony_backlight_update_status(struct backlight_device *bd)
-{
-	return acpi_callsetfunc(sony_acpi_handle, "SBRT",
-				bd->props->brightness + 1,
-				NULL);
-}
-
-static int sony_backlight_get_brightness(struct backlight_device *bd)
-{
-	int value;
-
-	if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value))
-		return 0;
-	/* brightness levels are 1-based, while backlight ones are 0-based */
-	return value - 1;
-}
-
 static struct acpi_driver sony_acpi_driver = {
 	.name	= ACPI_SNC_DRIVER_NAME,
 	.class	= ACPI_SNC_CLASS,
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#16 lore raw

PATCH 16/41 sony-laptop: Lindent

From: Len Brown <[email protected]>

---
 drivers/misc/sony-laptop.c |  151 +++++++++++++++++++++++---------------------
 1 files changed, 78 insertions(+), 73 deletions(-)
drivers/misc/sony-laptop.c +78 -73
index 4a69ce7..d7b5330 100644
@@ -52,21 +52,23 @@ MODULE_LICENSE("GPL");
 static int debug;
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
-			"the development of this driver");
+		 "the development of this driver");
 
-static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *);
-static ssize_t sony_acpi_store(struct device *, struct device_attribute *, const char *, size_t);
+static ssize_t sony_acpi_show(struct device *, struct device_attribute *,
+			      char *);
+static ssize_t sony_acpi_store(struct device *, struct device_attribute *,
+			       const char *, size_t);
 
 struct sony_acpi_value {
-	char			*name;		/* name of the entry */
-	char			**acpiget;	/* names of the ACPI get function */
-	char			**acpiset;	/* names of the ACPI set function */
-	int 			min;		/* minimum allowed value or -1 */
-	int			max;		/* maximum allowed value or -1 */
-	int			value;		/* current setting */
-	int			valid;		/* Has ever been set */
-	int			debug;		/* active only in debug mode ? */
-	struct device_attribute	devattr;	/* sysfs atribute */
+	char *name;		/* name of the entry */
+	char **acpiget;		/* names of the ACPI get function */
+	char **acpiset;		/* names of the ACPI set function */
+	int min;		/* minimum allowed value or -1 */
+	int max;		/* maximum allowed value or -1 */
+	int value;		/* current setting */
+	int valid;		/* Has ever been set */
+	int debug;		/* active only in debug mode ? */
+	struct device_attribute devattr;	/* sysfs atribute */
 };
 
 #define HANDLE_NAMES(_name, _values...) \
@@ -111,16 +113,18 @@ HANDLE_NAMES(CMI_get, "GCMI");
 HANDLE_NAMES(CMI_set, "SCMI");
 
 static struct sony_acpi_value sony_acpi_values[] = {
-	SONY_ACPI_VALUE(brightness_default, snc_brightness_def_get, snc_brightness_def_set, 1, SONY_MAX_BRIGHTNESS, 0),
-	SONY_ACPI_VALUE(fnkey,		snc_fnkey_get, NULL, -1, -1, 0),
-	SONY_ACPI_VALUE(cdpower,	snc_cdpower_get, snc_cdpower_set, 0, 1, 0),
-	SONY_ACPI_VALUE(audiopower,	snc_audiopower_get, snc_audiopower_set, 0, 1, 0),
-	SONY_ACPI_VALUE(lanpower,	snc_lanpower_get, snc_lanpower_set, 0, 1, 1),
+	SONY_ACPI_VALUE(brightness_default, snc_brightness_def_get,
+			snc_brightness_def_set, 1, SONY_MAX_BRIGHTNESS, 0),
+	SONY_ACPI_VALUE(fnkey, snc_fnkey_get, NULL, -1, -1, 0),
+	SONY_ACPI_VALUE(cdpower, snc_cdpower_get, snc_cdpower_set, 0, 1, 0),
+	SONY_ACPI_VALUE(audiopower, snc_audiopower_get, snc_audiopower_set, 0,
+			1, 0),
+	SONY_ACPI_VALUE(lanpower, snc_lanpower_get, snc_lanpower_set, 0, 1, 1),
 	/* unknown methods */
-	SONY_ACPI_VALUE(PID,		snc_PID_get, NULL, -1, -1, 1),
-	SONY_ACPI_VALUE(CTR,		snc_CTR_get, snc_CTR_set, -1, -1, 1),
-	SONY_ACPI_VALUE(PCR,		snc_PCR_get, snc_PCR_set, -1, -1, 1),
-	SONY_ACPI_VALUE(CMI,		snc_CMI_get, snc_CMI_set, -1, -1, 1),
+	SONY_ACPI_VALUE(PID, snc_PID_get, NULL, -1, -1, 1),
+	SONY_ACPI_VALUE(CTR, snc_CTR_get, snc_CTR_set, -1, -1, 1),
+	SONY_ACPI_VALUE(PCR, snc_PCR_get, snc_PCR_set, -1, -1, 1),
+	SONY_ACPI_VALUE(CMI, snc_CMI_get, snc_CMI_set, -1, -1, 1),
 	SONY_ACPI_VALUE_NULL
 };
 
@@ -189,10 +193,11 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,
  * Sysfs show/store common to all sony_acpi_values
  */
 static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr,
-		char *buffer)
+			      char *buffer)
 {
 	int value;
-	struct sony_acpi_value *item = container_of(attr, struct sony_acpi_value, devattr);
+	struct sony_acpi_value *item =
+	    container_of(attr, struct sony_acpi_value, devattr);
 
 	if (!*item->acpiget)
 		return -EIO;
@@ -203,11 +208,13 @@ static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr,
 	return snprintf(buffer, PAGE_SIZE, "%d\n", value);
 }
 
-static ssize_t sony_acpi_store(struct device *dev, struct device_attribute *attr,
-		const char *buffer, size_t count)
+static ssize_t sony_acpi_store(struct device *dev,
+			       struct device_attribute *attr,
+			       const char *buffer, size_t count)
 {
 	int value;
-	struct sony_acpi_value *item = container_of(attr, struct sony_acpi_value, devattr);
+	struct sony_acpi_value *item =
+	    container_of(attr, struct sony_acpi_value, devattr);
 
 	if (!item->acpiset)
 		return -EIO;
@@ -234,9 +241,9 @@ static ssize_t sony_acpi_store(struct device *dev, struct device_attribute *attr
  */
 static struct platform_driver sncpf_driver = {
 	.driver = {
-		.name = "sony-laptop",
-		.owner = THIS_MODULE,
-	}
+		   .name = "sony-laptop",
+		   .owner = THIS_MODULE,
+		   }
 };
 static struct platform_device *sncpf_device;
 
@@ -268,12 +275,11 @@ static int sony_snc_pf_add(void)
 		/* find the available acpiget as described in the DSDT */
 		for (; item->acpiget && *item->acpiget; ++item->acpiget) {
 			if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
-							*item->acpiget,
-							&handle))) {
+							 *item->acpiget,
+							 &handle))) {
 				if (debug)
 					printk(LOG_PFX "Found %s getter: %s\n",
-							item->name,
-							*item->acpiget);
+					       item->name, *item->acpiget);
 				item->devattr.attr.mode |= S_IRUGO;
 				break;
 			}
@@ -282,36 +288,37 @@ static int sony_snc_pf_add(void)
 		/* find the available acpiset as described in the DSDT */
 		for (; item->acpiset && *item->acpiset; ++item->acpiset) {
 			if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
-							*item->acpiset,
-							&handle))) {
+							 *item->acpiset,
+							 &handle))) {
 				if (debug)
 					printk(LOG_PFX "Found %s setter: %s\n",
-							item->name,
-							*item->acpiset);
+					       item->name, *item->acpiset);
 				item->devattr.attr.mode |= S_IWUSR;
 				break;
 			}
 		}
 
-	       if (item->devattr.attr.mode != 0) {
-		       ret = device_create_file(&sncpf_device->dev, &item->devattr);
-		       if (ret)
-			       goto out_sysfs;
-	       }
+		if (item->devattr.attr.mode != 0) {
+			ret =
+			    device_create_file(&sncpf_device->dev,
+					       &item->devattr);
+			if (ret)
+				goto out_sysfs;
+		}
 	}
 
 	return 0;
 
-out_sysfs:
+      out_sysfs:
 	for (item = sony_acpi_values; item->name; ++item) {
 		device_remove_file(&sncpf_device->dev, &item->devattr);
 	}
 	platform_device_del(sncpf_device);
-out_platform_alloced:
+      out_platform_alloced:
 	platform_device_put(sncpf_device);
-out_platform_registered:
+      out_platform_registered:
 	platform_driver_unregister(&sncpf_driver);
-out:
+      out:
 	return ret;
 }
 
@@ -334,8 +341,7 @@ static void sony_snc_pf_remove(void)
 static int sony_backlight_update_status(struct backlight_device *bd)
 {
 	return acpi_callsetfunc(sony_acpi_handle, "SBRT",
-				bd->props->brightness + 1,
-				NULL);
+				bd->props->brightness + 1, NULL);
 }
 
 static int sony_backlight_get_brightness(struct backlight_device *bd)
@@ -350,10 +356,10 @@ static int sony_backlight_get_brightness(struct backlight_device *bd)
 
 static struct backlight_device *sony_backlight_device;
 static struct backlight_properties sony_backlight_properties = {
-	.owner		= THIS_MODULE,
-	.update_status	= sony_backlight_update_status,
-	.get_brightness	= sony_backlight_get_brightness,
-	.max_brightness	= SONY_MAX_BRIGHTNESS - 1,
+	.owner = THIS_MODULE,
+	.update_status = sony_backlight_update_status,
+	.get_brightness = sony_backlight_get_brightness,
+	.max_brightness = SONY_MAX_BRIGHTNESS - 1,
 };
 
 /*
@@ -372,8 +378,8 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
 	struct acpi_namespace_node *node;
 	union acpi_operand_object *operand;
 
-	node = (struct acpi_namespace_node *) handle;
-	operand = (union acpi_operand_object *) node->object;
+	node = (struct acpi_namespace_node *)handle;
+	operand = (union acpi_operand_object *)node->object;
 
 	printk(LOG_PFX "method: name: %4.4s, args %X\n", node->name.ascii,
 	       (u32) operand->method.param_count);
@@ -394,7 +400,7 @@ static int sony_acpi_resume(struct acpi_device *device)
 		if (!item->valid)
 			continue;
 		ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset,
-					item->value, NULL);
+				       item->value, NULL);
 		if (ret < 0) {
 			printk("%s: %d\n", __FUNCTION__, ret);
 			break;
@@ -425,8 +431,7 @@ static int sony_acpi_add(struct acpi_device *device)
 
 	status = acpi_install_notify_handler(sony_acpi_handle,
 					     ACPI_DEVICE_NOTIFY,
-					     sony_acpi_notify,
-					     NULL);
+					     sony_acpi_notify, NULL);
 	if (ACPI_FAILURE(status)) {
 		printk(LOG_PFX "unable to install notify handler\n");
 		result = -ENODEV;
@@ -435,15 +440,16 @@ static int sony_acpi_add(struct acpi_device *device)
 
 	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
 		sony_backlight_device = backlight_device_register("sony", NULL,
-					NULL, &sony_backlight_properties);
+								  NULL,
+								  &sony_backlight_properties);
 
-	        if (IS_ERR(sony_backlight_device)) {
+		if (IS_ERR(sony_backlight_device)) {
 			printk(LOG_PFX "unable to register backlight device\n");
 			sony_backlight_device = NULL;
-		}
-		else
+		} else
 			sony_backlight_properties.brightness =
-				sony_backlight_get_brightness(sony_backlight_device);
+			    sony_backlight_get_brightness
+			    (sony_backlight_device);
 	}
 
 	if (sony_snc_pf_add())
@@ -453,7 +459,7 @@ static int sony_acpi_add(struct acpi_device *device)
 
 	return 0;
 
-outbacklight:
+      outbacklight:
 	if (sony_backlight_device)
 		backlight_device_unregister(sony_backlight_device);
 
@@ -462,7 +468,7 @@ outbacklight:
 					    sony_acpi_notify);
 	if (ACPI_FAILURE(status))
 		printk(LOG_PFX "unable to remove notify handler\n");
-outwalk:
+      outwalk:
 	return result;
 }
 
@@ -489,14 +495,14 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
 }
 
 static struct acpi_driver sony_acpi_driver = {
-	.name	= ACPI_SNC_DRIVER_NAME,
-	.class	= ACPI_SNC_CLASS,
-	.ids	= ACPI_SNC_HID,
-	.ops	= {
-			.add	= sony_acpi_add,
-			.remove	= sony_acpi_remove,
-			.resume = sony_acpi_resume,
-		  },
+	.name = ACPI_SNC_DRIVER_NAME,
+	.class = ACPI_SNC_CLASS,
+	.ids = ACPI_SNC_HID,
+	.ops = {
+		.add = sony_acpi_add,
+		.remove = sony_acpi_remove,
+		.resume = sony_acpi_resume,
+		},
 };
 
 static int __init sony_acpi_init(void)
@@ -504,7 +510,6 @@ static int __init sony_acpi_init(void)
 	return acpi_bus_register_driver(&sony_acpi_driver);
 }
 
-
 static void __exit sony_acpi_exit(void)
 {
 	acpi_bus_unregister_driver(&sony_acpi_driver);
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#17 lore raw

PATCH 17/41 ACPI: bay: remove ACPI driver struct

From: Kristen Carlson Accardi <[email protected]>

The bay driver is a platform driver, and doesn't need to also be an acpi driver. Remove the acpi driver related structures and callbacks, they didn't do anything anyway. Switch to uevent for user space event notification.

---
 drivers/acpi/bay.c |   99 ++-------------------------------------------------
 1 files changed, 4 insertions(+), 95 deletions(-)
drivers/acpi/bay.c +4 -95
index 667fa1d..9fdee61 100644
@@ -47,18 +47,6 @@ MODULE_LICENSE("GPL");
 	acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\
 	printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); }
 static void bay_notify(acpi_handle handle, u32 event, void *data);
-static int acpi_bay_add(struct acpi_device *device);
-static int acpi_bay_remove(struct acpi_device *device, int type);
-
-static struct acpi_driver acpi_bay_driver = {
-	.name = ACPI_BAY_DRIVER_NAME,
-	.class = ACPI_BAY_CLASS,
-	.ids = ACPI_BAY_HID,
-	.ops = {
-		.add = acpi_bay_add,
-		.remove = acpi_bay_remove,
-		},
-};
 
 struct bay {
 	acpi_handle handle;
@@ -234,14 +222,6 @@ int eject_removable_drive(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(eject_removable_drive);
 
-static int acpi_bay_add(struct acpi_device *device)
-{
-	bay_dprintk(device->handle, "adding bay device");
-	strcpy(acpi_device_name(device), "Dockable Bay");
-	strcpy(acpi_device_class(device), "bay");
-	return 0;
-}
-
 static int acpi_bay_add_fs(struct bay *bay)
 {
 	int ret;
@@ -339,52 +319,6 @@ bay_add_err:
 	return -ENODEV;
 }
 
-static int acpi_bay_remove(struct acpi_device *device, int type)
-{
-	/*** FIXME: do something here */
-	return 0;
-}
-
-/**
- * bay_create_acpi_device - add new devices to acpi
- * @handle - handle of the device to add
- *
- *  This function will create a new acpi_device for the given
- *  handle if one does not exist already.  This should cause
- *  acpi to scan for drivers for the given devices, and call
- *  matching driver's add routine.
- *
- *  Returns a pointer to the acpi_device corresponding to the handle.
- */
-static struct acpi_device * bay_create_acpi_device(acpi_handle handle)
-{
-	struct acpi_device *device = NULL;
-	struct acpi_device *parent_device;
-	acpi_handle parent;
-	int ret;
-
-	bay_dprintk(handle, "Trying to get device");
-	if (acpi_bus_get_device(handle, &device)) {
-		/*
-		 * no device created for this object,
-		 * so we should create one.
-		 */
-		bay_dprintk(handle, "No device for handle");
-		acpi_get_parent(handle, &parent);
-		if (acpi_bus_get_device(parent, &parent_device))
-			parent_device = NULL;
-
-		ret = acpi_bus_add(&device, parent_device, handle,
-			ACPI_BUS_TYPE_DEVICE);
-		if (ret) {
-			pr_debug("error adding bus, %x\n",
-				-ret);
-			return NULL;
-		}
-	}
-	return device;
-}
-
 /**
  * bay_notify - act upon an acpi bay notification
  * @handle: the bay handle
@@ -394,38 +328,19 @@ static struct acpi_device * bay_create_acpi_device(acpi_handle handle)
  */
 static void bay_notify(acpi_handle handle, u32 event, void *data)
 {
-	struct acpi_device *dev;
+	struct bay *bay_dev = (struct bay *)data;
+	struct device *dev = &bay_dev->pdev->dev;
 
 	bay_dprintk(handle, "Bay event");
 
 	switch(event) {
 	case ACPI_NOTIFY_BUS_CHECK:
-		printk("Bus Check\n");
 	case ACPI_NOTIFY_DEVICE_CHECK:
-		printk("Device Check\n");
-		dev = bay_create_acpi_device(handle);
-		if (dev)
-			acpi_bus_generate_event(dev, event, 0);
-		else
-			printk("No device for generating event\n");
-		/* wouldn't it be a good idea to just rescan SATA
-		 * right here?
-		 */
-		break;
 	case ACPI_NOTIFY_EJECT_REQUEST:
-		printk("Eject request\n");
-		dev = bay_create_acpi_device(handle);
-		if (dev)
-			acpi_bus_generate_event(dev, event, 0);
-		else
-			printk("No device for generating eventn");
-
-		/* wouldn't it be a good idea to just call the
-		 * eject_device here if we were a SATA device?
-		 */
+		kobject_uevent(&dev->kobj, KOBJ_CHANGE);
 		break;
 	default:
-		printk("unknown event %d\n", event);
+		printk(KERN_ERR PREFIX "Bay: unknown event %d\n", event);
 	}
 }
 
@@ -457,10 +372,6 @@ static int __init bay_init(void)
 	acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
 		ACPI_UINT32_MAX, find_bay, &bays, NULL);
 
-	if (bays)
-		if ((acpi_bus_register_driver(&acpi_bay_driver) < 0))
-			printk(KERN_ERR "Unable to register bay driver\n");
-
 	if (!bays)
 		return -ENODEV;
 
@@ -481,8 +392,6 @@ static void __exit bay_exit(void)
 		kfree(bay->name);
 		kfree(bay);
 	}
-
-	acpi_bus_unregister_driver(&acpi_bay_driver);
 }
 
 postcore_initcall(bay_init);
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#18 lore raw

PATCH 18/41 ACPI: asus_acpi: Add support for Asus Z81SP

From: Matthew C Campbell <[email protected]>

Adds support in asus_acpi for the Asus Z81SP laptop. This preserves all old functionality when improperly detected as well as enabling Bluetooth support.

---
 drivers/acpi/asus_acpi.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
drivers/acpi/asus_acpi.c +13 -1
index 31ad70a..fa19a6c 100644
@@ -141,6 +141,7 @@ struct asus_hotk {
 		W5A,		//W5A
 		W3V,            //W3030V
 		xxN,		//M2400N, M3700N, M5200N, M6800N, S1300N, S5200N
+		A4S,            //Z81sp
 		//(Centrino)
 		END_MODEL
 	} model;		//Models currently supported
@@ -397,7 +398,16 @@ static struct model_data model_conf[END_MODEL] = {
 	 .brightness_set = "SPLV",
 	 .brightness_get = "GPLV",
 	 .display_set = "SDSP",
-	 .display_get = "\\ADVG"}
+	.display_get = "\\ADVG"},
+
+	{
+		.name              = "A4S",
+		.brightness_set    = "SPLV",
+		.brightness_get    = "GPLV",
+		.mt_bt_switch      = "BLED",
+		.mt_wled           = "WLED"
+	}
+
 };
 
 /* procdir we use */
@@ -1117,6 +1127,8 @@ static int asus_model_match(char *model)
 		return W3V;
 	else if (strncmp(model, "W5A", 3) == 0)
 		return W5A;
+	else if (strncmp(model, "A4S", 3) == 0)
+		return A4S;
 	else
 		return END_MODEL;
 }
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#19 lore raw

PATCH 19/41 ACPI: updates rtc-cmos device platform_data

From: David Brownell <[email protected]>

Update ACPI to export its RTC extension information through platform_data to the PNPACPI or platform bus device node used on the system being set up.

This will need to be updated later to provide a firmware hook to handle system suspend with an alarm pending.

Len notes that "Eventually we may bundle ACPI/PNP/PNPACPI..." but if/when that happens, ACPI can simplify this without my help.

And until it does, the separate patch creating a platform_device (on all X86_PC systems, even without ACPI) will be needed.

---
 drivers/acpi/glue.c |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)
drivers/acpi/glue.c +89 -0
index 7b6c9ff..9950087 100644
@@ -241,3 +241,92 @@ static int __init init_acpi_device_notify(void)
 }
 
 arch_initcall(init_acpi_device_notify);
+
+
+#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE)
+
+/* Every ACPI platform has a mc146818 compatible "cmos rtc".  Here we find
+ * its device node and pass extra config data.  This helps its driver use
+ * capabilities that the now-obsolete mc146818 didn't have, and informs it
+ * that this board's RTC is wakeup-capable (per ACPI spec).
+ */
+#include <linux/mc146818rtc.h>
+
+static struct cmos_rtc_board_info rtc_info;
+
+
+#ifdef CONFIG_PNPACPI
+
+/* PNP devices are registered in a subsys_initcall();
+ * ACPI specifies the PNP IDs to use.
+ */
+#include <linux/pnp.h>
+
+static int __init pnp_match(struct device *dev, void *data)
+{
+	static const char *ids[] = { "PNP0b00", "PNP0b01", "PNP0b02", };
+	struct pnp_dev *pnp = to_pnp_dev(dev);
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ids); i++) {
+		if (compare_pnp_id(pnp->id, ids[i]) != 0)
+			return 1;
+	}
+	return 0;
+}
+
+static struct device *__init get_rtc_dev(void)
+{
+	return bus_find_device(&pnp_bus_type, NULL, NULL, pnp_match);
+}
+
+#else
+
+/* We expect non-PNPACPI platforms to register an RTC device, usually
+ * at or near arch_initcall().  That also helps for example PCs that
+ * aren't configured with ACPI (where this code wouldn't run, but the
+ * RTC would still be available).  The device name matches the driver;
+ * that's how the platform bus works.
+ */
+#include <linux/platform_device.h>
+
+static int __init platform_match(struct device *dev, void *data)
+{
+	struct platform_device	*pdev;
+
+	pdev = container_of(dev, struct platform_device, dev);
+	return strcmp(pdev->name, "rtc_cmos") == 0;
+}
+
+static struct device *__init get_rtc_dev(void)
+{
+	return bus_find_device(&platform_bus_type, NULL, NULL, platform_match);
+}
+
+#endif
+
+static int __init acpi_rtc_init(void)
+{
+	struct device *dev = get_rtc_dev();
+
+	if (dev) {
+		rtc_info.rtc_day_alarm = acpi_gbl_FADT.day_alarm;
+		rtc_info.rtc_mon_alarm = acpi_gbl_FADT.month_alarm;
+		rtc_info.rtc_century = acpi_gbl_FADT.century;
+
+		/* NOTE:  acpi_gbl_FADT->rtcs4 is NOT currently useful */
+
+		dev->platform_data = &rtc_info;
+
+		/* RTC always wakes from S1/S2/S3, and often S4/STD */
+		device_init_wakeup(dev, 1);
+
+		put_device(dev);
+	} else
+		pr_debug("ACPI: RTC unavailable?\n");
+	return 0;
+}
+/* do this between RTC subsys_initcall() and rtc_cmos driver_initcall() */
+fs_initcall(acpi_rtc_init);
+
+#endif
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#20 lore raw

PATCH 20/41 ACPI: bay: fix build warning

From: Andrew Morton <[email protected]>

drivers/acpi/bay.c: In function 'bay_add':
drivers/acpi/bay.c:310: warning: statement with no effect

Fix it by rewriting those macros in C. Much nicer.

Cc Kristen Carlson Accardi <[email protected]>
---
 include/acpi/acpi_drivers.h |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)
include/acpi/acpi_drivers.h +19 -5
index 4dc8a50..3d7ebe0 100644
@@ -122,10 +122,24 @@ extern int register_hotplug_dock_device(acpi_handle handle,
 	acpi_notify_handler handler, void *context);
 extern void unregister_hotplug_dock_device(acpi_handle handle);
 #else
-#define is_dock_device(h)			(0)
-#define register_dock_notifier(nb) 		(-ENODEV)
-#define unregister_dock_notifier(nb)           	do { } while(0)
-#define register_hotplug_dock_device(h1, h2, c)	(-ENODEV)
-#define unregister_hotplug_dock_device(h)       do { } while(0)
+static inline int is_dock_device(acpi_handle handle)
+{
+	return 0;
+}
+static inline int register_dock_notifier(struct notifier_block *nb)
+{
+	return -ENODEV;
+}
+static inline void unregister_dock_notifier(struct notifier_block *nb)
+{
+}
+static inline int register_hotplug_dock_device(acpi_handle handle,
+				acpi_notify_handler handler, void *context)
+{
+	return -ENODEV;
+}
+static inline void unregister_hotplug_dock_device(acpi_handle handle)
+{
+}
 #endif
 #endif /*__ACPI_DRIVERS_H__*/
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#22 lore raw

PATCH 22/41 sony-laptop: Update docs

In reply to a message not in the archive

From: Mattia Dongili <[email protected]>

Update documentation to be consistent with current implementation (backlight subsys and platform_device).

---
 Documentation/acpi/sony_acpi.txt |   87 -------------------------------
 Documentation/sony-laptop.txt    |  106 ++++++++++++++++++++++++++++++++++++++
 drivers/misc/Kconfig             |   14 +++---
 3 files changed, 113 insertions(+), 94 deletions(-)
 delete mode 100644 Documentation/acpi/sony_acpi.txt
 create mode 100644 Documentation/sony-laptop.txt
Documentation/acpi/sony_acpi.txt deleted +0 -87
deleted file mode 100644
index 35a04be..0000000
@@ -1,87 +0,0 @@
-ACPI Sony Notebook Control Driver (SNC) Readme
-----------------------------------------------
-	Copyright (C) 2004- 2005 Stelian Pop <[email protected]>
-
-This mini-driver drives the ACPI SNC device present in the
-ACPI BIOS of the Sony Vaio laptops.
-
-It gives access to some extra laptop functionalities. In
-its current form, this driver is mainly useful for controlling the
-screen brightness, but it may do more in the future.
-
-You should probably start by trying the sonypi driver, and try
-sony_acpi only if sonypi doesn't work for you.
-
-Usage:
-------
-
-Loading the sony_acpi module will create a /proc/acpi/sony/
-directory populated with a couple of files.
-
-You then read/write integer values from/to those files by using
-standard UNIX tools.
-
-The files are:
-	brightness		current screen brightness
-	brightness_default	screen brightness which will be set
-				when the laptop will be rebooted
-	cdpower			power on/off the internal CD drive
-
-Note that some files may be missing if they are not supported
-by your particular laptop model.
-
-Example usage:
-	# echo "1" > /proc/acpi/sony/brightness
-sets the lowest screen brightness,
-	# echo "8" > /proc/acpi/sony/brightness
-sets the highest screen brightness,
-	# cat /proc/acpi/sony/brightness
-retrieves the current screen brightness.
-
-Development:
-------------
-
-If you want to help with the development of this driver (and
-you are not afraid of any side effects doing strange things with
-your ACPI BIOS could have on your laptop), load the driver and
-pass the option 'debug=1'.
-
-REPEAT: DON'T DO THIS IF YOU DON'T LIKE RISKY BUSINESS.
-
-In your kernel logs you will find the list of all ACPI methods
-the SNC device has on your laptop. You can see the GBRT/SBRT methods
-used to get/set the brightness, but there are others.
-
-I HAVE NO IDEA WHAT THOSE METHODS DO.
-
-The sony_acpi driver creates, for some of those methods (the most
-current ones found on several Vaio models), an entry under
-/proc/acpi/sony/, just like the 'brightness' one. You can create
-other entries corresponding to your own laptop methods by further
-editing the source (see the 'sony_acpi_values' table, and add a new
-structure to this table with your get/set method names).
-
-Your mission, should you accept it, is to try finding out what
-those entries are for, by reading/writing random values from/to those
-files and find out what is the impact on your laptop.
-
-Should you find anything interesting, please report it back to me,
-I will not disavow all knowledge of your actions :)
-
-Bugs/Limitations:
------------------
-
-* This driver is not based on official documentation from Sony
-  (because there is none), so there is no guarantee this driver
-  will work at all, or do the right thing. Although this hasn't
-  happened to me, this driver could do very bad things to your
-  laptop, including permanent damage.
-
-* The sony_acpi and sonypi drivers do not interact at all. In the
-  future, sonypi could use sony_acpi to do (part of) its business.
-
-* spicctrl, which is the userspace tool used to communicate with the
-  sonypi driver (through /dev/sonypi) does not try to use the
-  sony_acpi driver. In the future, spicctrl could try sonypi first,
-  and if it isn't present, try sony_acpi instead.
-
Documentation/sony-laptop.txt new file +106 -0

106 lines not on this page · raw message

drivers/misc/Kconfig +7 -7
index 009aff8..d7e8969 100644
@@ -93,14 +93,14 @@ config SONY_LAPTOP
 	depends on X86 && ACPI
 	select BACKLIGHT_CLASS_DEVICE
 	  ---help---
-	  This mini-driver drives the ACPI SNC device present in the
-	  ACPI BIOS of the Sony Vaio laptops.
+	  This mini-driver drives the SNC device present in the ACPI BIOS of
+	  the Sony Vaio laptops.
 
-	  It gives access to some extra laptop functionalities. In
-	  its current form, the only thing this driver does is letting
-	  the user set or query the screen brightness and remove/apply
-	  power to some devices.
+	  It gives access to some extra laptop functionalities. In its current
+	  form, this driver let the user set or query the screen brightness
+	  through the backlight subsystem and remove/apply power to some
+	  devices.
 
-	  Read <file:Documentation/acpi/sony_acpi.txt> for more information.
+	  Read <file:Documentation/sony-laptop.txt> for more information.
 
 endmenu
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#23 lore raw

PATCH 23/41 sony-laptop: add to MAINTAINERS

From: Mattia Dongili <[email protected]>

---
 MAINTAINERS |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
MAINTAINERS +2 -0
index 0ad8803..7b3cd6d 100644
@@ -3004,6 +3004,8 @@ S:	Maintained
 SONY VAIO CONTROL DEVICE DRIVER
 P:	Stelian Pop
 M:	[email protected]
+P:	Mattia Dongili
+M:	[email protected]
 W:	http://popies.net/sonypi/
 S:	Maintained
 
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#24 lore raw

PATCH 24/41 ACPI: bay: fix wrong order of kzalloc arguments

From: Al Viro <[email protected]>

---
 drivers/acpi/bay.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/bay.c +1 -1
index 9fdee61..73dc10d 100644
@@ -276,7 +276,7 @@ static int bay_add(acpi_handle handle, int id)
 	/*
 	 * Initialize bay device structure
 	 */
-	new_bay = kzalloc(GFP_ATOMIC, sizeof(*new_bay));
+	new_bay = kzalloc(sizeof(*new_bay), GFP_ATOMIC);
 	INIT_LIST_HEAD(&new_bay->list);
 	new_bay->handle = handle;
 	new_bay->name = (char *)nbuffer.pointer;
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#25 lore raw

PATCH 25/41 ACPI: ibm-acpi: cleanup init and exit paths

From: Henrique de Moraes Holschuh <[email protected]>

Fix a small memory leak on module removal, and other assorted minor cleanups on the module init codepath.

---
 drivers/acpi/ibm_acpi.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/acpi/ibm_acpi.c +8 -5
index c6144ca..2429e11 100644
@@ -496,6 +496,10 @@ static int ibm_acpi_driver_init(void)
 	printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION);
 	printk(IBM_INFO "%s\n", IBM_URL);
 
+	if (ibm_thinkpad_ec_found)
+		printk(IBM_INFO "ThinkPad EC firmware %s\n",
+		       ibm_thinkpad_ec_found);
+
 	return 0;
 }
 
@@ -2617,7 +2621,7 @@ static void __init ibm_handle_init(char *name,
 	ibm_handle_init(#object, &object##_handle, *object##_parent,	\
 		object##_paths, ARRAY_SIZE(object##_paths), &object##_path)
 
-static int set_ibm_param(const char *val, struct kernel_param *kp)
+static int __init set_ibm_param(const char *val, struct kernel_param *kp)
 {
 	unsigned int i;
 
@@ -2659,7 +2663,8 @@ static void acpi_ibm_exit(void)
 	for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--)
 		ibm_exit(&ibms[i]);
 
-	remove_proc_entry(IBM_DIR, acpi_root_dir);
+	if (proc_dir)
+		remove_proc_entry(IBM_DIR, acpi_root_dir);
 
 	if (ibm_thinkpad_ec_found)
 		kfree(ibm_thinkpad_ec_found);
@@ -2710,9 +2715,6 @@ static int __init acpi_ibm_init(void)
 
 	/* Models with newer firmware report the EC in DMI */
 	ibm_thinkpad_ec_found = check_dmi_for_ec();
-	if (ibm_thinkpad_ec_found)
-		printk(IBM_INFO "ThinkPad EC firmware %s\n",
-		       ibm_thinkpad_ec_found);
 
 	/* these handles are not required */
 	IBM_HANDLE_INIT(vid);
@@ -2742,6 +2744,7 @@ static int __init acpi_ibm_init(void)
 	proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
 	if (!proc_dir) {
 		printk(IBM_ERR "unable to create proc dir %s", IBM_DIR);
+		acpi_ibm_exit();
 		return -ENODEV;
 	}
 	proc_dir->owner = THIS_MODULE;
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#26 lore raw

PATCH 26/41 ACPI: video: Fix null pointer in appledisplay driver

From: Michael Hanselmann <[email protected]>

commit "ACPI: video: Add dev argument for backlight_device_register" 519ab5f2be65b72cf12ae99c89752bbe79b44df6
broke the apple display driver.

---
 drivers/usb/misc/appledisplay.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/misc/appledisplay.c +1 -1
index a7932a7..31ab83c 100644
@@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
 	/* Register backlight device */
 	snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
 		atomic_inc_return(&count_displays) - 1);
-	pdata->bd = backlight_device_register(bl_name, NULL, NULL,
+	pdata->bd = backlight_device_register(bl_name, NULL, pdata
 						&appledisplay_bl_data);
 	if (IS_ERR(pdata->bd)) {
 		err("appledisplay: Backlight registration failed");
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#27 lore raw

PATCH 27/41 ACPI: hotkey: remove driver, per feature-removal-schedule.txt

From: Len Brown <[email protected]>

---
 Documentation/acpi-hotkey.txt              |   38 -
 Documentation/feature-removal-schedule.txt |   23 -
 drivers/acpi/asus_acpi.c                   |    4 -
 drivers/acpi/hotkey.c                      | 1042 ----------------------------
 drivers/acpi/ibm_acpi.c                    |    5 -
 drivers/acpi/osl.c                         |   11 -
 drivers/acpi/toshiba_acpi.c                |    4 -
 drivers/misc/asus-laptop.c                 |    5 -
 include/acpi/acpi_drivers.h                |    6 -
 9 files changed, 0 insertions(+), 1138 deletions(-)
 delete mode 100644 Documentation/acpi-hotkey.txt
 delete mode 100644 drivers/acpi/hotkey.c
Documentation/acpi-hotkey.txt deleted +0 -38
deleted file mode 100644
index 38040fa..0000000
@@ -1,38 +0,0 @@
-driver/acpi/hotkey.c implement:
-1. /proc/acpi/hotkey/event_config 
-(event based hotkey or event config interface):
-a. add a  event based hotkey(event) : 
-echo "0:bus::action:method:num:num" > event_config
-
-b. delete a event based hotkey(event): 
-echo "1:::::num:num" > event_config
-
-c.  modify a event based hotkey(event):    
-echo "2:bus::action:method:num:num" > event_config
-
-2. /proc/acpi/hotkey/poll_config 
-(polling based hotkey or event config interface):
-a.add a polling based hotkey(event) : 	
-echo "0:bus:method:action:method:num" > poll_config
-this adding command will create a proc file 
-/proc/acpi/hotkey/method, which is used to get 
-result of polling.
-
-b.delete a polling based hotkey(event): 	
-echo "1:::::num" > event_config
-
-c.modify a polling based hotkey(event):    
-echo "2:bus:method:action:method:num" > poll_config
-
-3./proc/acpi/hotkey/action 
-(interface to call aml method associated with a 
-specific hotkey(event))
-echo "event_num:event_type:event_argument" > 
-	/proc/acpi/hotkey/action.
-The result of the execution of this aml method is 
-attached to /proc/acpi/hotkey/poll_method, which is dynamically
-created.  Please use command "cat /proc/acpi/hotkey/polling_method" 
-to retrieve it.
-
-Note: Use cmdline "acpi_generic_hotkey" to over-ride
-platform-specific with generic driver.
Documentation/feature-removal-schedule.txt +0 -23
index fa844fd..7dec8e0 100644
@@ -246,29 +246,6 @@ Who:	Venkatesh Pallipadi <[email protected]>
 
 ---------------------------
 
-<<<<<<< test:Documentation/feature-removal-schedule.txt
-What:	ACPI hotkey driver (CONFIG_ACPI_HOTKEY)
-When:	2.6.21
-Why:	hotkey.c was an attempt to consolidate multiple drivers that use
-	ACPI to implement hotkeys.  However, hotkeys are not documented
-	in the ACPI specification, so the drivers used undocumented
-	vendor-specific hooks and turned out to be more different than
-	the same.
-
-	Further, the keys and the features supplied by each platform
-	are different, so there will always be a need for
-	platform-specific drivers.
-
-	So the new plan is to delete hotkey.c and instead, work on the
-	platform specific drivers to try to make them look the same
-	to the user when they supply the same features.
-
-	hotkey.c has always depended on CONFIG_EXPERIMENTAL
-
-Who:	Len Brown <[email protected]>
-
----------------------------
-
 What:	/sys/firmware/acpi/namespace
 When:	2.6.21
 Why:	The ACPI namespace is effectively the symbol list for
drivers/acpi/asus_acpi.c +0 -4
index 31ad70a..ab8c5cb 100644
@@ -1365,10 +1365,6 @@ static int __init asus_acpi_init(void)
 	if (acpi_disabled)
 		return -ENODEV;
 
-	if (!acpi_specific_hotkey_enabled) {
-		printk(KERN_ERR "Using generic hotkey driver\n");
-		return -ENODEV;
-	}
 	asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
 	if (!asus_proc_dir) {
 		printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
drivers/acpi/hotkey.c deleted +0 -1042

1,042 lines not on this page · raw message

drivers/acpi/ibm_acpi.c +0 -5
index c6144ca..4def52c 100644
@@ -2696,11 +2696,6 @@ static int __init acpi_ibm_init(void)
 	if (acpi_disabled)
 		return -ENODEV;
 
-	if (!acpi_specific_hotkey_enabled) {
-		printk(IBM_ERR "using generic hotkey driver\n");
-		return -ENODEV;
-	}
-
 	/* ec is required because many other handles are relative to it */
 	IBM_HANDLE_INIT(ec);
 	if (!ec_handle) {
drivers/acpi/osl.c +0 -11
index 0f6f3bc..368e111 100644
@@ -68,9 +68,6 @@ EXPORT_SYMBOL(acpi_in_debugger);
 extern char line_buf[80];
 #endif				/*ENABLE_DEBUGGER */
 
-int acpi_specific_hotkey_enabled = TRUE;
-EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
-
 static unsigned int acpi_irq_irq;
 static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
@@ -1012,14 +1009,6 @@ static int __init acpi_wake_gpes_always_on_setup(char *str)
 
 __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
 
-static int __init acpi_hotkey_setup(char *str)
-{
-	acpi_specific_hotkey_enabled = FALSE;
-	return 1;
-}
-
-__setup("acpi_generic_hotkey", acpi_hotkey_setup);
-
 /*
  * max_cstate is defined in the base kernel so modules can
  * change it w/o depending on the state of the processor module.
drivers/acpi/toshiba_acpi.c +0 -4
index d9b651f..56ec550 100644
@@ -561,10 +561,6 @@ static int __init toshiba_acpi_init(void)
 	if (acpi_disabled)
 		return -ENODEV;
 
-	if (!acpi_specific_hotkey_enabled) {
-		printk(MY_INFO "Using generic hotkey driver\n");
-		return -ENODEV;
-	}
 	/* simple device detection: look for HCI method */
 	if (is_valid_acpi_path(METHOD_HCI_1))
 		method_hci = METHOD_HCI_1;
drivers/misc/asus-laptop.c +0 -5
index 861c399..e4e2b70 100644
@@ -1088,11 +1088,6 @@ static int __init asus_laptop_init(void)
 	if (acpi_disabled)
 		return -ENODEV;
 
-	if (!acpi_specific_hotkey_enabled) {
-		printk(ASUS_ERR "Using generic hotkey driver\n");
-		return -ENODEV;
-	}
-
 	result = acpi_bus_register_driver(&asus_hotk_driver);
 	if (result < 0)
 		return result;
include/acpi/acpi_drivers.h +0 -6
index 4dc8a50..0e21efb 100644
@@ -105,12 +105,6 @@ int acpi_ec_ecdt_probe(void);
 
 int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
 
-/* --------------------------------------------------------------------------
-                                    Hot Keys
-   -------------------------------------------------------------------------- */
-
-extern int acpi_specific_hotkey_enabled;
-
 /*--------------------------------------------------------------------------
                                   Dock Station
   -------------------------------------------------------------------------- */
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#28 lore raw

PATCH 28/41 ACPI: Disable GPEs in preparation for sleep.

From: Alexey Starikovskiy <[email protected]>

http://bugzilla.kernel.org/show_bug.cgi?id=7887

---
 drivers/acpi/hardware/hwsleep.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/acpi/hardware/hwsleep.c +8 -5
index 57901ca..8fa9312 100644
@@ -235,6 +235,14 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
 				"While executing method _SST"));
 	}
 
+	/*
+	 * 1) Disable/Clear all GPEs
+	 */
+	status = acpi_hw_disable_all_gpes();
+	if (ACPI_FAILURE(status)) {
+		return_ACPI_STATUS(status);
+	}
+
 	return_ACPI_STATUS(AE_OK);
 }
 
@@ -290,13 +298,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
 	}
 
 	/*
-	 * 1) Disable/Clear all GPEs
 	 * 2) Enable all wakeup GPEs
 	 */
-	status = acpi_hw_disable_all_gpes();
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
 	acpi_gbl_system_awake_and_running = FALSE;
 
 	status = acpi_hw_enable_all_wakeup_gpes();
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#29 lore raw

PATCH 29/41 ACPI: invoke acpi_sleep_init() earlier

From: Alexey Starikovskiy <[email protected]>

late_initcall() is too late for acpi_sleep_init(). Call it directly from acpi_init code.

http://bugzilla.kernel.org/show_bug.cgi?id=7887

---
 drivers/acpi/bus.c          |   13 ++++++++-----
 drivers/acpi/sleep/main.c   |    3 +--
 include/acpi/acpi_drivers.h |   10 ++++++++++
 3 files changed, 19 insertions(+), 7 deletions(-)
drivers/acpi/bus.c +8 -5
index c26468d..41cebe5 100644
@@ -147,7 +147,7 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
 			*state = ACPI_STATE_D0;
 	} else {
 		/*
-		 * Get the device's power state either directly (via _PSC) or 
+		 * Get the device's power state either directly (via _PSC) or
 		 * indirectly (via power resources).
 		 */
 		if (device->power.flags.explicit_get) {
@@ -462,7 +462,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
 				  "Received BUS CHECK notification for device [%s]\n",
 				  device->pnp.bus_id));
 		result = acpi_bus_check_scope(device);
-		/* 
+		/*
 		 * TBD: We'll need to outsource certain events to non-ACPI
 		 *      drivers via the device manager (device.c).
 		 */
@@ -473,7 +473,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
 				  "Received DEVICE CHECK notification for device [%s]\n",
 				  device->pnp.bus_id));
 		result = acpi_bus_check_device(device, NULL);
-		/* 
+		/*
 		 * TBD: We'll need to outsource certain events to non-ACPI
 		 *      drivers via the device manager (device.c).
 		 */
@@ -543,7 +543,7 @@ static int __init acpi_bus_init_irq(void)
 	char *message = NULL;
 
 
-	/* 
+	/*
 	 * Let the system know what interrupt model we are using by
 	 * evaluating the \_PIC object, if exists.
 	 */
@@ -684,7 +684,7 @@ static int __init acpi_bus_init(void)
 	 * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
 	 * is called).
 	 *
-	 * This is accomplished by looking for the ECDT table, and getting 
+	 * This is accomplished by looking for the ECDT table, and getting
 	 * the EC parameters out of that.
 	 */
 	status = acpi_ec_ecdt_probe();
@@ -699,6 +699,9 @@ static int __init acpi_bus_init(void)
 
 	printk(KERN_INFO PREFIX "Interpreter enabled\n");
 
+	/* Initialize sleep structures */
+	acpi_sleep_init();
+
 	/*
 	 * Get the system interrupt model and evaluate \_PIC.
 	 */
drivers/acpi/sleep/main.c +1 -2
index 62ce87d..37a0930 100644
@@ -200,7 +200,7 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
 	{},
 };
 
-static int __init acpi_sleep_init(void)
+int __init acpi_sleep_init(void)
 {
 	int i = 0;
 
@@ -229,4 +229,3 @@ static int __init acpi_sleep_init(void)
 	return 0;
 }
 
-late_initcall(acpi_sleep_init);
include/acpi/acpi_drivers.h +10 -0
index 4dc8a50..ce0e62f 100644
@@ -128,4 +128,14 @@ extern void unregister_hotplug_dock_device(acpi_handle handle);
 #define register_hotplug_dock_device(h1, h2, c)	(-ENODEV)
 #define unregister_hotplug_dock_device(h)       do { } while(0)
 #endif
+
+/*--------------------------------------------------------------------------
+                                  Suspend/Resume
+  -------------------------------------------------------------------------- */
+#ifdef CONFIG_ACPI_SLEEP
+extern int acpi_sleep_init(void);
+#else
+#define acpi_sleep_init() do {} while (0)
+#endif
+
 #endif /*__ACPI_DRIVERS_H__*/
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#30 lore raw

PATCH 30/41 ACPI: battery: check for battery present on /proc/battery access

From: Vladimir Lebedev <[email protected]>

http://bugzilla.kernel.org/show_bug.cgi?id=7200

---
 drivers/acpi/battery.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/acpi/battery.c +15 -0
index 2f4521a..0d7a32e 100644
@@ -324,6 +324,13 @@ static int acpi_battery_check(struct acpi_battery *battery)
 	return result;
 }
 
+static void acpi_battery_check_present(struct acpi_battery *battery)
+{
+	if (!battery->flags.present) {
+		acpi_battery_check(battery);
+	}
+}
+
 /* --------------------------------------------------------------------------
                               FS Interface (/proc)
    -------------------------------------------------------------------------- */
@@ -340,6 +347,8 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
 	if (!battery)
 		goto end;
 
+	acpi_battery_check_present(battery);
+
 	if (battery->flags.present)
 		seq_printf(seq, "present:                 yes\n");
 	else {
@@ -424,6 +433,8 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
 	if (!battery)
 		goto end;
 
+	acpi_battery_check_present(battery);
+
 	if (battery->flags.present)
 		seq_printf(seq, "present:                 yes\n");
 	else {
@@ -499,6 +510,8 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
 	if (!battery)
 		goto end;
 
+	acpi_battery_check_present(battery);
+
 	if (!battery->flags.present) {
 		seq_printf(seq, "present:                 no\n");
 		goto end;
@@ -536,6 +549,8 @@ acpi_battery_write_alarm(struct file *file,
 	if (!battery || (count > sizeof(alarm_string) - 1))
 		return -EINVAL;
 
+	acpi_battery_check_present(battery);
+
 	if (!battery->flags.present)
 		return -ENODEV;
 
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#31 lore raw

PATCH 31/41 ACPI: sbs: fix present rate

From: Vladimir Lebedev <[email protected]>

http://bugzilla.kernel.org/show_bug.cgi?id=7897

---
 drivers/acpi/sbs.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
drivers/acpi/sbs.c +9 -11
index f58fc74..87b48f8 100644
@@ -1034,21 +1034,19 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
 	} else {
 		seq_printf(seq, "capacity state:          ok\n");
 	}
+
+	foo = (s16) battery->state.amperage * battery->info.ipscale;
+	if (battery->info.capacity_mode) {
+		foo = foo * battery->info.design_voltage / 1000;
+	}
 	if (battery->state.amperage < 0) {
 		seq_printf(seq, "charging state:          discharging\n");
-		foo = battery->state.remaining_capacity * cscale * 60 /
-		    (battery->state.average_time_to_empty == 0 ? 1 :
-		     battery->state.average_time_to_empty);
-		seq_printf(seq, "present rate:            %i%s\n",
-			   foo, battery->info.capacity_mode ? "0 mW" : " mA");
+		seq_printf(seq, "present rate:            %d %s\n",
+			   -foo, battery->info.capacity_mode ? "mW" : "mA");
 	} else if (battery->state.amperage > 0) {
 		seq_printf(seq, "charging state:          charging\n");
-		foo = (battery->info.full_charge_capacity -
-		       battery->state.remaining_capacity) * cscale * 60 /
-		    (battery->state.average_time_to_full == 0 ? 1 :
-		     battery->state.average_time_to_full);
-		seq_printf(seq, "present rate:            %i%s\n",
-			   foo, battery->info.capacity_mode ? "0 mW" : " mA");
+		seq_printf(seq, "present rate:            %d %s\n",
+			   foo, battery->info.capacity_mode ? "mW" : "mA");
 	} else {
 		seq_printf(seq, "charging state:          charged\n");
 		seq_printf(seq, "present rate:            0 %s\n",
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#32 lore raw

PATCH 32/41 ACPI: add video driver MAINTAINER

From: Len Brown <[email protected]>

---
 MAINTAINERS |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
MAINTAINERS +7 -0
index fe35f3a..7c5d329 100644
@@ -247,6 +247,13 @@ L:	[email protected]
 W:	http://acpi.sourceforge.net/
 S:	Supported
 
+ACPI VIDEO DRIVER
+P:	Luming Yu
+M:	[email protected]
+L:	[email protected]
+W:	http://acpi.sourceforge.net/
+S:	Supported
+
 AD1816 SOUND DRIVER
 P:	Thorsten Knabe
 M:	Thorsten Knabe <[email protected]>
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#33 lore raw

PATCH 33/41 ACPI: acpi_table_parse() now returns success/fail, not count

From: Len Brown <[email protected]>

Returning count for tables that are supposed to be unique was useless and confusing.

---
 arch/x86_64/kernel/early-quirks.c |    4 +++-
 arch/x86_64/pci/mmconfig.c        |    4 +++-
 drivers/acpi/numa.c               |    6 ++----
 drivers/acpi/tables.c             |   13 +++++++++++--
 4 files changed, 19 insertions(+), 8 deletions(-)
arch/x86_64/kernel/early-quirks.c +3 -1
index bd30d13..8047ea8 100644
@@ -53,7 +53,9 @@ static void nvidia_bugs(void)
 		return;
 
 	nvidia_hpet_detected = 0;
-	acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check);
+	if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check))
+		return;
+
 	if (nvidia_hpet_detected == 0) {
 		acpi_skip_timer_override = 1;
 		printk(KERN_INFO "Nvidia board "
arch/x86_64/pci/mmconfig.c +3 -1
index faabb6e..98202cb 100644
@@ -170,7 +170,9 @@ void __init pci_mmcfg_init(int type)
 	if ((pci_probe & PCI_PROBE_MMCONF) == 0)
 		return;
 
-	acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg);
+	if (acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg))
+		return;
+
 	if ((pci_mmcfg_config_num == 0) ||
 	    (pci_mmcfg_config == NULL) ||
 	    (pci_mmcfg_config[0].address == 0))
drivers/acpi/numa.c +2 -4
index 4a9faff..b33daf8 100644
@@ -220,9 +220,7 @@ int __init acpi_numa_init(void)
 	int result;
 
 	/* SRAT: Static Resource Affinity Table */
-	result = acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat);
-
-	if (result > 0) {
+	if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
 		result = acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY,
 					       acpi_parse_processor_affinity,
 					       NR_CPUS);
@@ -230,7 +228,7 @@ int __init acpi_numa_init(void)
 	}
 
 	/* SLIT: System Locality Information Table */
-	result = acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
+	acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
 
 	acpi_numa_arch_fixup();
 	return 0;
drivers/acpi/tables.c +11 -2
index ba4cb20..2075ec7 100644
@@ -226,6 +226,15 @@ acpi_table_parse_madt(enum acpi_madt_type id,
 					    handler, max_entries);
 }
 
+/**
+ * acpi_table_parse - find table with @id, run @handler on it
+ *
+ * @id: table id to find
+ * @handler: handler to run
+ *
+ * Scan the ACPI System Descriptor Table (STD) for a table matching @id,
+ * run @handler on it.  Return 0 if table found, return on if not.
+ */
 int __init acpi_table_parse(char *id, acpi_table_handler handler)
 {
 	struct acpi_table_header *table = NULL;
@@ -235,9 +244,9 @@ int __init acpi_table_parse(char *id, acpi_table_handler handler)
 	acpi_get_table(id, 0, &table);
 	if (table) {
 		handler(table);
-		return 1;
-	} else
 		return 0;
+	} else
+		return 1;
 }
 
 /*
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#34 lore raw

PATCH 34/41 ACPI: acpi_madt_entry_handler() is not MADT specific

From: Len Brown <[email protected]>

acpi_madt_entry_handler() is also used for the SRAT, so re-name it acpi_table_entry_handler().

cosmetic only.

---
 drivers/acpi/numa.c   |    4 ++--
 drivers/acpi/tables.c |    4 ++--
 include/linux/acpi.h  |    6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/acpi/numa.c +2 -2
index b33daf8..fd21e20 100644
@@ -48,7 +48,7 @@ int __cpuinitdata node_to_pxm_map[MAX_NUMNODES]
 extern int __init acpi_table_parse_madt_family(char *id,
 					       unsigned long madt_size,
 					       int entry_id,
-					       acpi_madt_entry_handler handler,
+					       acpi_table_entry_handler handler,
 					       unsigned int max_entries);
 
 int __cpuinit pxm_to_node(int pxm)
@@ -208,7 +208,7 @@ static int __init acpi_parse_srat(struct acpi_table_header *table)
 
 int __init
 acpi_table_parse_srat(enum acpi_srat_type id,
-		      acpi_madt_entry_handler handler, unsigned int max_entries)
+		      acpi_table_entry_handler handler, unsigned int max_entries)
 {
 	return acpi_table_parse_madt_family(ACPI_SIG_SRAT,
 					    sizeof(struct acpi_table_srat), id,
drivers/acpi/tables.c +2 -2
index 2075ec7..f211fa3 100644
@@ -173,7 +173,7 @@ int __init
 acpi_table_parse_madt_family(char *id,
 			     unsigned long madt_size,
 			     int entry_id,
-			     acpi_madt_entry_handler handler,
+			     acpi_table_entry_handler handler,
 			     unsigned int max_entries)
 {
 	struct acpi_table_header *madt = NULL;
@@ -219,7 +219,7 @@ acpi_table_parse_madt_family(char *id,
 
 int __init
 acpi_table_parse_madt(enum acpi_madt_type id,
-		      acpi_madt_entry_handler handler, unsigned int max_entries)
+		      acpi_table_entry_handler handler, unsigned int max_entries)
 {
 	return acpi_table_parse_madt_family(ACPI_SIG_MADT,
 					    sizeof(struct acpi_table_madt), id,
include/linux/acpi.h +3 -3
index 815f1fb..15a23b6 100644
@@ -75,7 +75,7 @@ enum acpi_address_range_id {
 
 typedef int (*acpi_table_handler) (struct acpi_table_header *table);
 
-typedef int (*acpi_madt_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
+typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
 
 char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
 unsigned long acpi_find_rsdp (void);
@@ -85,8 +85,8 @@ int acpi_numa_init (void);
 
 int acpi_table_init (void);
 int acpi_table_parse (char *id, acpi_table_handler handler);
-int acpi_table_parse_madt (enum acpi_madt_type id, acpi_madt_entry_handler handler, unsigned int max_entries);
-int acpi_table_parse_srat (enum acpi_srat_type id, acpi_madt_entry_handler handler, unsigned int max_entries);
+int acpi_table_parse_madt (enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
+int acpi_table_parse_srat (enum acpi_srat_type id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_parse_mcfg (struct acpi_table_header *header);
 void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
 void acpi_table_print_srat_entry (struct acpi_subtable_header *srat);
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#35 lore raw

PATCH 35/41 ACPI: acpi_table_parse_madt_family() is not MADT specific

From: Len Brown <[email protected]>

acpi_table_parse_madt_family() is also used to parse SRAT entries. So re-name it to acpi_table_parse_entries(), and re-name the madt-specific variables within it accordingly.

cosmetic only.

---
 drivers/acpi/numa.c   |    8 +-------
 drivers/acpi/tables.c |   24 ++++++++++++------------
 include/linux/acpi.h  |    2 ++
 3 files changed, 15 insertions(+), 19 deletions(-)
drivers/acpi/numa.c +1 -7
index fd21e20..a651139 100644
@@ -45,12 +45,6 @@ int __cpuinitdata pxm_to_node_map[MAX_PXM_DOMAINS]
 int __cpuinitdata node_to_pxm_map[MAX_NUMNODES]
 				= { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
 
-extern int __init acpi_table_parse_madt_family(char *id,
-					       unsigned long madt_size,
-					       int entry_id,
-					       acpi_table_entry_handler handler,
-					       unsigned int max_entries);
-
 int __cpuinit pxm_to_node(int pxm)
 {
 	if (pxm < 0)
@@ -210,7 +204,7 @@ int __init
 acpi_table_parse_srat(enum acpi_srat_type id,
 		      acpi_table_entry_handler handler, unsigned int max_entries)
 {
-	return acpi_table_parse_madt_family(ACPI_SIG_SRAT,
+	return acpi_table_parse_entries(ACPI_SIG_SRAT,
 					    sizeof(struct acpi_table_srat), id,
 					    handler, max_entries);
 }
drivers/acpi/tables.c +12 -12
index f211fa3..4ed6400 100644
@@ -170,40 +170,40 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header * header)
 
 
 int __init
-acpi_table_parse_madt_family(char *id,
-			     unsigned long madt_size,
+acpi_table_parse_entries(char *id,
+			     unsigned long table_size,
 			     int entry_id,
 			     acpi_table_entry_handler handler,
 			     unsigned int max_entries)
 {
-	struct acpi_table_header *madt = NULL;
+	struct acpi_table_header *table_header = NULL;
 	struct acpi_subtable_header *entry;
 	unsigned int count = 0;
-	unsigned long madt_end;
+	unsigned long table_end;
 
 	if (!handler)
 		return -EINVAL;
 
-	/* Locate the MADT (if exists). There should only be one. */
-	acpi_get_table(id, 0, &madt);
+	/* Locate the table (if exists). There should only be one. */
+	acpi_get_table(id, 0, &table_header);
 
-	if (!madt) {
+	if (!table_header) {
 		printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
 		return -ENODEV;
 	}
 
-	madt_end = (unsigned long)madt + madt->length;
+	table_end = (unsigned long)table_header + table_header->length;
 
 	/* Parse all entries looking for a match. */
 
 	entry = (struct acpi_subtable_header *)
-	    ((unsigned long)madt + madt_size);
+	    ((unsigned long)table_header + table_size);
 
 	while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
-	       madt_end) {
+	       table_end) {
 		if (entry->type == entry_id
 		    && (!max_entries || count++ < max_entries))
-			if (handler(entry, madt_end))
+			if (handler(entry, table_end))
 				return -EINVAL;
 
 		entry = (struct acpi_subtable_header *)
@@ -221,7 +221,7 @@ int __init
 acpi_table_parse_madt(enum acpi_madt_type id,
 		      acpi_table_entry_handler handler, unsigned int max_entries)
 {
-	return acpi_table_parse_madt_family(ACPI_SIG_MADT,
+	return acpi_table_parse_entries(ACPI_SIG_MADT,
 					    sizeof(struct acpi_table_madt), id,
 					    handler, max_entries);
 }
include/linux/acpi.h +2 -0
index 15a23b6..8bcfaa4 100644
@@ -85,6 +85,8 @@ int acpi_numa_init (void);
 
 int acpi_table_init (void);
 int acpi_table_parse (char *id, acpi_table_handler handler);
+int __init acpi_table_parse_entries(char *id, unsigned long table_size,
+	int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_table_parse_madt (enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_table_parse_srat (enum acpi_srat_type id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_parse_mcfg (struct acpi_table_header *header);
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#36 lore raw

PATCH 36/41 ACPI: IA64: fix calculation of apic_id

From: Alexey Starikovskiy <[email protected]>

fix regression from recent table re-write

---
 drivers/acpi/processor_core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/processor_core.c +1 -1
index 0079bc5..61d976e 100644
@@ -404,7 +404,7 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
 	if (lsapic->lapic_flags & ACPI_MADT_ENABLED) {
 		/* First check against id */
 		if (lsapic->processor_id == acpi_id) {
-			*apic_id = lsapic->id;
+			*apic_id = (lsapic->id << 8) | lsapic->eid;
 			return 1;
 		/* Check against optional uid */
 		} else if (entry->length >= 16 &&
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#37 lore raw

PATCH 37/41 ACPI: clean up ACPI_MODULE_NAME() use

From: Len Brown <[email protected]>

cosmetic only

Make "module name" actually match the file name.
Invoke with ';' as leaving it off confuses Lindent and gcc doesn't care. Fix indentation where Lindent did get confused.

---
 drivers/acpi/ac.c                   |    4 ++--
 drivers/acpi/acpi_memhotplug.c      |    4 ++--
 drivers/acpi/battery.c              |    4 ++--
 drivers/acpi/bay.c                  |    2 +-
 drivers/acpi/bus.c                  |    2 +-
 drivers/acpi/button.c               |    2 +-
 drivers/acpi/cm_sbs.c               |    2 +-
 drivers/acpi/container.c            |    4 ++--
 drivers/acpi/debug.c                |    2 +-
 drivers/acpi/dock.c                 |    2 +-
 drivers/acpi/ec.c                   |    2 +-
 drivers/acpi/event.c                |    2 +-
 drivers/acpi/fan.c                  |    4 ++--
 drivers/acpi/i2c_ec.c               |    2 +-
 drivers/acpi/numa.c                 |    2 +-
 drivers/acpi/osl.c                  |    2 +-
 drivers/acpi/pci_bind.c             |    2 +-
 drivers/acpi/pci_irq.c              |    2 +-
 drivers/acpi/pci_link.c             |    2 +-
 drivers/acpi/pci_root.c             |    2 +-
 drivers/acpi/power.c                |    2 +-
 drivers/acpi/processor_core.c       |    4 ++--
 drivers/acpi/processor_idle.c       |    2 +-
 drivers/acpi/processor_perflib.c    |    2 +-
 drivers/acpi/processor_thermal.c    |    2 +-
 drivers/acpi/processor_throttling.c |    2 +-
 drivers/acpi/sbs.c                  |    2 +-
 drivers/acpi/scan.c                 |    2 +-
 drivers/acpi/system.c               |    2 +-
 drivers/acpi/thermal.c              |    2 +-
 drivers/acpi/utils.c                |    2 +-
 drivers/acpi/video.c                |    4 ++--
 32 files changed, 39 insertions(+), 39 deletions(-)
drivers/acpi/ac.c +2 -2
index 6daeace..a9b30e6 100644
@@ -44,9 +44,9 @@
 #define ACPI_AC_STATUS_UNKNOWN		0xFF
 
 #define _COMPONENT		ACPI_AC_COMPONENT
-ACPI_MODULE_NAME("acpi_ac")
+ACPI_MODULE_NAME("ac");
 
-    MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME);
 MODULE_LICENSE("GPL");
 
drivers/acpi/acpi_memhotplug.c +2 -2
index cd946ed..88a6dc3 100644
@@ -40,8 +40,8 @@
 
 #define _COMPONENT		ACPI_MEMORY_DEVICE_COMPONENT
 
-ACPI_MODULE_NAME("acpi_memory")
-    MODULE_AUTHOR("Naveen B S <[email protected]>");
+ACPI_MODULE_NAME("acpi_memhotplug");
+MODULE_AUTHOR("Naveen B S <[email protected]>");
 MODULE_DESCRIPTION(ACPI_MEMORY_DEVICE_DRIVER_NAME);
 MODULE_LICENSE("GPL");
 
drivers/acpi/battery.c +2 -2
index 2f4521a..4b8db56 100644
@@ -53,9 +53,9 @@
 #define ACPI_BATTERY_UNITS_AMPS		"mA"
 
 #define _COMPONENT		ACPI_BATTERY_COMPONENT
-ACPI_MODULE_NAME("acpi_battery")
+ACPI_MODULE_NAME("battery");
 
-    MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME);
 MODULE_LICENSE("GPL");
 
drivers/acpi/bay.c +1 -1
index 91082ce..19fe57d 100644
@@ -34,7 +34,7 @@
 
 #define ACPI_BAY_DRIVER_NAME "ACPI Removable Drive Bay Driver"
 
-ACPI_MODULE_NAME("bay")
+ACPI_MODULE_NAME("bay");
 MODULE_AUTHOR("Kristen Carlson Accardi");
 MODULE_DESCRIPTION(ACPI_BAY_DRIVER_NAME);
 MODULE_LICENSE("GPL");
drivers/acpi/bus.c +1 -1
index c26468d..fd37e19 100644
@@ -39,7 +39,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_BUS_COMPONENT
-ACPI_MODULE_NAME("acpi_bus")
+ACPI_MODULE_NAME("bus");
 #ifdef	CONFIG_X86
 extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger);
 #endif
drivers/acpi/button.c +1 -1
index c726612..28ce5c6 100644
@@ -61,7 +61,7 @@
 #define ACPI_BUTTON_TYPE_LID		0x05
 
 #define _COMPONENT		ACPI_BUTTON_COMPONENT
-ACPI_MODULE_NAME("acpi_button")
+ACPI_MODULE_NAME("button");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME);
drivers/acpi/cm_sbs.c +1 -1
index 4a9b7bf..f9db4f4 100644
@@ -31,7 +31,7 @@
 #include <acpi/actypes.h>
 #include <acpi/acutils.h>
 
-ACPI_MODULE_NAME("cm_sbs")
+ACPI_MODULE_NAME("cm_sbs");
 #define ACPI_AC_CLASS		"ac_adapter"
 #define ACPI_BATTERY_CLASS	"battery"
 #define ACPI_SBS_COMPONENT	0x00080000
drivers/acpi/container.c +2 -2
index 69a68fd..f3e59af 100644
@@ -44,9 +44,9 @@
 
 #define ACPI_CONTAINER_COMPONENT	0x01000000
 #define _COMPONENT			ACPI_CONTAINER_COMPONENT
-ACPI_MODULE_NAME("acpi_container")
+ACPI_MODULE_NAME("container");
 
-    MODULE_AUTHOR("Anil S Keshavamurthy");
+MODULE_AUTHOR("Anil S Keshavamurthy");
 MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME);
 MODULE_LICENSE("GPL");
 
drivers/acpi/debug.c +1 -1
index d48f65a..bf513e0 100644
@@ -12,7 +12,7 @@
 #include <acpi/acglobal.h>
 
 #define _COMPONENT		ACPI_SYSTEM_COMPONENT
-ACPI_MODULE_NAME("debug")
+ACPI_MODULE_NAME("debug");
 
 #ifdef MODULE_PARAM_PREFIX
 #undef MODULE_PARAM_PREFIX
drivers/acpi/dock.c +1 -1
index 688e83a..b3a04ff 100644
@@ -34,7 +34,7 @@
 
 #define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver"
 
-ACPI_MODULE_NAME("dock")
+ACPI_MODULE_NAME("dock");
 MODULE_AUTHOR("Kristen Carlson Accardi");
 MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME);
 MODULE_LICENSE("GPL");
drivers/acpi/ec.c +1 -1
index 743ce27..a5c0b5c 100644
@@ -38,7 +38,7 @@
 #include <acpi/actypes.h>
 
 #define _COMPONENT		ACPI_EC_COMPONENT
-ACPI_MODULE_NAME("acpi_ec")
+ACPI_MODULE_NAME("ec");
 #define ACPI_EC_COMPONENT		0x00100000
 #define ACPI_EC_CLASS			"embedded_controller"
 #define ACPI_EC_HID			"PNP0C09"
drivers/acpi/event.c +1 -1
index 959a893..3b23562 100644
@@ -13,7 +13,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_SYSTEM_COMPONENT
-ACPI_MODULE_NAME("event")
+ACPI_MODULE_NAME("event");
 
 /* Global vars for handling event proc entry */
 static DEFINE_SPINLOCK(acpi_system_event_lock);
drivers/acpi/fan.c +2 -2
index af22fdf..b902d3b 100644
@@ -40,9 +40,9 @@
 #define ACPI_FAN_FILE_STATE		"state"
 
 #define _COMPONENT		ACPI_FAN_COMPONENT
-ACPI_MODULE_NAME("acpi_fan")
+ACPI_MODULE_NAME("fan");
 
-    MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME);
 MODULE_LICENSE("GPL");
 
drivers/acpi/i2c_ec.c +1 -1
index 8338be0..62af6da 100644
@@ -33,7 +33,7 @@
 
 #define _COMPONENT		ACPI_EC_HC_COMPONENT
 
-ACPI_MODULE_NAME("acpi_smbus")
+ACPI_MODULE_NAME("i2c_ec");
 
 static int acpi_ec_hc_add(struct acpi_device *device);
 static int acpi_ec_hc_remove(struct acpi_device *device, int type);
drivers/acpi/numa.c +1 -1
index 4a9faff..dcd58a4 100644
@@ -33,7 +33,7 @@
 
 #define ACPI_NUMA	0x80000000
 #define _COMPONENT	ACPI_NUMA
-ACPI_MODULE_NAME("numa")
+ACPI_MODULE_NAME("numa");
 
 static nodemask_t nodes_found_map = NODE_MASK_NONE;
 #define PXM_INVAL	-1
drivers/acpi/osl.c +1 -1
index 0f6f3bc..851ac49 100644
@@ -46,7 +46,7 @@
 #include <linux/efi.h>
 
 #define _COMPONENT		ACPI_OS_SERVICES
-ACPI_MODULE_NAME("osl")
+ACPI_MODULE_NAME("osl");
 #define PREFIX		"ACPI: "
 struct acpi_os_dpc {
 	acpi_osd_exec_callback function;
drivers/acpi/pci_bind.c +1 -1
index 55f57a6..0289693 100644
@@ -36,7 +36,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_PCI_COMPONENT
-ACPI_MODULE_NAME("pci_bind")
+ACPI_MODULE_NAME("pci_bind");
 
 struct acpi_pci_data {
 	struct acpi_pci_id id;
drivers/acpi/pci_irq.c +1 -1
index fe7d007..dd3186a 100644
@@ -38,7 +38,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_PCI_COMPONENT
-ACPI_MODULE_NAME("pci_irq")
+ACPI_MODULE_NAME("pci_irq");
 
 static struct acpi_prt_list acpi_prt;
 static DEFINE_SPINLOCK(acpi_prt_lock);
drivers/acpi/pci_link.c +1 -1
index 0f683c8..da22c5e 100644
@@ -44,7 +44,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_PCI_COMPONENT
-ACPI_MODULE_NAME("pci_link")
+ACPI_MODULE_NAME("pci_link");
 #define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
 #define ACPI_PCI_LINK_HID		"PNP0C0F"
 #define ACPI_PCI_LINK_DRIVER_NAME	"ACPI PCI Interrupt Link Driver"
drivers/acpi/pci_root.c +1 -1
index 4ecf701..3db2cd3 100644
@@ -36,7 +36,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_PCI_COMPONENT
-ACPI_MODULE_NAME("pci_root")
+ACPI_MODULE_NAME("pci_root");
 #define ACPI_PCI_ROOT_CLASS		"pci_bridge"
 #define ACPI_PCI_ROOT_HID		"PNP0A03"
 #define ACPI_PCI_ROOT_DRIVER_NAME	"ACPI PCI Root Bridge Driver"
drivers/acpi/power.c +1 -1
index 0ba7dfb..26e8edc 100644
@@ -45,7 +45,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_POWER_COMPONENT
-ACPI_MODULE_NAME("acpi_power")
+ACPI_MODULE_NAME("power");
 #define ACPI_POWER_COMPONENT		0x00800000
 #define ACPI_POWER_CLASS		"power_resource"
 #define ACPI_POWER_DRIVER_NAME		"ACPI Power Resource Driver"
drivers/acpi/processor_core.c +2 -2
index 0079bc5..13135f8 100644
@@ -74,9 +74,9 @@
 #define ACPI_STA_PRESENT 0x00000001
 
 #define _COMPONENT		ACPI_PROCESSOR_COMPONENT
-ACPI_MODULE_NAME("acpi_processor")
+ACPI_MODULE_NAME("processor_core");
 
-    MODULE_AUTHOR("Paul Diefenbaugh");
+MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME);
 MODULE_LICENSE("GPL");
 
drivers/acpi/processor_idle.c +1 -1
index 6c6751b..a26433d 100644
@@ -50,7 +50,7 @@
 #define ACPI_PROCESSOR_CLASS            "processor"
 #define ACPI_PROCESSOR_DRIVER_NAME      "ACPI Processor Driver"
 #define _COMPONENT              ACPI_PROCESSOR_COMPONENT
-ACPI_MODULE_NAME("acpi_processor")
+ACPI_MODULE_NAME("processor_idle");
 #define ACPI_PROCESSOR_FILE_POWER	"power"
 #define US_TO_PM_TIMER_TICKS(t)		((t * (PM_TIMER_FREQUENCY/1000)) / 1000)
 #define C2_OVERHEAD			4	/* 1us (3.579 ticks per us) */
drivers/acpi/processor_perflib.c +1 -1
index 058f13c..c2add4e 100644
@@ -47,7 +47,7 @@
 #define ACPI_PROCESSOR_DRIVER_NAME	"ACPI Processor Driver"
 #define ACPI_PROCESSOR_FILE_PERFORMANCE	"performance"
 #define _COMPONENT		ACPI_PROCESSOR_COMPONENT
-ACPI_MODULE_NAME("acpi_processor")
+ACPI_MODULE_NAME("processor_perflib");
 
 static DEFINE_MUTEX(performance_mutex);
 
drivers/acpi/processor_thermal.c +1 -1
index 40fecd6..9357d63 100644
@@ -43,7 +43,7 @@
 #define ACPI_PROCESSOR_CLASS            "processor"
 #define ACPI_PROCESSOR_DRIVER_NAME      "ACPI Processor Driver"
 #define _COMPONENT              ACPI_PROCESSOR_COMPONENT
-ACPI_MODULE_NAME("acpi_processor")
+ACPI_MODULE_NAME("processor_thermal");
 
 /* --------------------------------------------------------------------------
                                  Limit Interface
drivers/acpi/processor_throttling.c +1 -1
index 89dff36..8194eb0 100644
@@ -43,7 +43,7 @@
 #define ACPI_PROCESSOR_CLASS            "processor"
 #define ACPI_PROCESSOR_DRIVER_NAME      "ACPI Processor Driver"
 #define _COMPONENT              ACPI_PROCESSOR_COMPONENT
-ACPI_MODULE_NAME("acpi_processor")
+ACPI_MODULE_NAME("processor_throttling");
 
 /* --------------------------------------------------------------------------
                               Throttling Control
drivers/acpi/sbs.c +1 -1
index f58fc74..f5b714d 100644
@@ -78,7 +78,7 @@ extern void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
 #define	MAX_SBS_BAT			4
 #define	MAX_SMBUS_ERR			1
 
-ACPI_MODULE_NAME("acpi_sbs");
+ACPI_MODULE_NAME("sbs");
 
 MODULE_AUTHOR("Rich Townsend");
 MODULE_DESCRIPTION("Smart Battery System ACPI interface driver");
drivers/acpi/scan.c +1 -1
index 64f26db..cff1b59 100644
@@ -11,7 +11,7 @@
 #include <acpi/acinterp.h>	/* for acpi_ex_eisa_id_to_string() */
 
 #define _COMPONENT		ACPI_BUS_COMPONENT
-ACPI_MODULE_NAME("scan")
+ACPI_MODULE_NAME("scan");
 #define STRUCT_TO_INT(s)	(*((int*)&s))
 extern struct acpi_device *acpi_root;
 
drivers/acpi/system.c +1 -1
index 7147b0b..edead9e 100644
@@ -31,7 +31,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_SYSTEM_COMPONENT
-ACPI_MODULE_NAME("acpi_system")
+ACPI_MODULE_NAME("system");
 #ifdef MODULE_PARAM_PREFIX
 #undef MODULE_PARAM_PREFIX
 #endif
drivers/acpi/thermal.c +1 -1
index f76d316..bf0a9f2 100644
@@ -70,7 +70,7 @@
 #define CELSIUS_TO_KELVIN(t)	((t+273)*10)
 
 #define _COMPONENT		ACPI_THERMAL_COMPONENT
-ACPI_MODULE_NAME("acpi_thermal")
+ACPI_MODULE_NAME("thermal");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
drivers/acpi/utils.c +1 -1
index 68a809f..34f1575 100644
@@ -31,7 +31,7 @@
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT		ACPI_BUS_COMPONENT
-ACPI_MODULE_NAME("acpi_utils")
+ACPI_MODULE_NAME("utils");
 
 /* --------------------------------------------------------------------------
                             Object Evaluation Helpers
drivers/acpi/video.c +2 -2
index e0b97ad..a095d01 100644
@@ -65,9 +65,9 @@
 #define ACPI_VIDEO_DISPLAY_LCD	4
 
 #define _COMPONENT		ACPI_VIDEO_COMPONENT
-ACPI_MODULE_NAME("acpi_video")
+ACPI_MODULE_NAME("video");
 
-    MODULE_AUTHOR("Bruno Ducrot");
+MODULE_AUTHOR("Bruno Ducrot");
 MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME);
 MODULE_LICENSE("GPL");
 
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#38 lore raw

PATCH 38/41 ACPI: fix acpi_driver.name usage

From: Len Brown <[email protected]>

It was erroneously used as a description rather than a name.

ie. turn this:

lenb@se7525gp2:/sys> ls bus/acpi/drivers

ACPI AC Adapter Driver  ACPI Embedded Controller Driver  ACPI Power Resource Driver
ACPI Battery Driver     ACPI Fan Driver                  ACPI Processor Driver
ACPI Button Driver      ACPI PCI Interrupt Link Driver   ACPI Thermal Zone Driver
ACPI container driver   ACPI PCI Root Bridge Driver      hpet

into this:

lenb@se7525gp2:~> ls /sys/bus/acpi/drivers
ac battery button container ec fan hpet pci_link pci_root power processor thermal

---
 drivers/acpi/ac.c              |    2 +-
 drivers/acpi/acpi_memhotplug.c |    2 +-
 drivers/acpi/asus_acpi.c       |    2 +-
 drivers/acpi/battery.c         |    2 +-
 drivers/acpi/bay.c             |    2 +-
 drivers/acpi/button.c          |    2 +-
 drivers/acpi/container.c       |    2 +-
 drivers/acpi/ec.c              |    2 +-
 drivers/acpi/fan.c             |    2 +-
 drivers/acpi/i2c_ec.c          |    2 +-
 drivers/acpi/pci_link.c        |    2 +-
 drivers/acpi/pci_root.c        |    2 +-
 drivers/acpi/power.c           |    2 +-
 drivers/acpi/processor_core.c  |    2 +-
 drivers/acpi/sbs.c             |    2 +-
 drivers/acpi/thermal.c         |    2 +-
 drivers/acpi/video.c           |    2 +-
 17 files changed, 17 insertions(+), 17 deletions(-)
drivers/acpi/ac.c +1 -1
index a9b30e6..17eef27 100644
@@ -58,7 +58,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type);
 static int acpi_ac_open_fs(struct inode *inode, struct file *file);
 
 static struct acpi_driver acpi_ac_driver = {
-	.name = ACPI_AC_DRIVER_NAME,
+	.name = "ac",
 	.class = ACPI_AC_CLASS,
 	.ids = ACPI_AC_HID,
 	.ops = {
drivers/acpi/acpi_memhotplug.c +1 -1
index 88a6dc3..d677130 100644
@@ -60,7 +60,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type);
 static int acpi_memory_device_start(struct acpi_device *device);
 
 static struct acpi_driver acpi_memory_device_driver = {
-	.name = ACPI_MEMORY_DEVICE_DRIVER_NAME,
+	.name = "acpi_memhotplug",
 	.class = ACPI_MEMORY_DEVICE_CLASS,
 	.ids = ACPI_MEMORY_DEVICE_HID,
 	.ops = {
drivers/acpi/asus_acpi.c +1 -1
index 31ad70a..40a2f4c 100644
@@ -421,7 +421,7 @@ static struct asus_hotk *hotk;
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
 static struct acpi_driver asus_hotk_driver = {
-	.name = ACPI_HOTK_NAME,
+	.name = "asus_acpi",
 	.class = ACPI_HOTK_CLASS,
 	.ids = ACPI_HOTK_HID,
 	.ops = {
drivers/acpi/battery.c +1 -1
index 4b8db56..da29d9d 100644
@@ -67,7 +67,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type);
 static int acpi_battery_resume(struct acpi_device *device);
 
 static struct acpi_driver acpi_battery_driver = {
-	.name = ACPI_BATTERY_DRIVER_NAME,
+	.name = "battery",
 	.class = ACPI_BATTERY_CLASS,
 	.ids = ACPI_BATTERY_HID,
 	.ops = {
drivers/acpi/bay.c +1 -1
index 19fe57d..1f88858 100644
@@ -51,7 +51,7 @@ static int acpi_bay_add(struct acpi_device *device);
 static int acpi_bay_remove(struct acpi_device *device, int type);
 
 static struct acpi_driver acpi_bay_driver = {
-	.name = ACPI_BAY_DRIVER_NAME,
+	.name = "bay",
 	.class = ACPI_BAY_CLASS,
 	.ids = ACPI_BAY_HID,
 	.ops = {
drivers/acpi/button.c +1 -1
index 28ce5c6..45f960d 100644
@@ -73,7 +73,7 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
 static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
 
 static struct acpi_driver acpi_button_driver = {
-	.name = ACPI_BUTTON_DRIVER_NAME,
+	.name = "button",
 	.class = ACPI_BUTTON_CLASS,
 	.ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E",
 	.ops = {
drivers/acpi/container.c +1 -1
index f3e59af..0e36062 100644
@@ -56,7 +56,7 @@ static int acpi_container_add(struct acpi_device *device);
 static int acpi_container_remove(struct acpi_device *device, int type);
 
 static struct acpi_driver acpi_container_driver = {
-	.name = ACPI_CONTAINER_DRIVER_NAME,
+	.name = "container",
 	.class = ACPI_CONTAINER_CLASS,
 	.ids = "ACPI0004,PNP0A05,PNP0A06",
 	.ops = {
drivers/acpi/ec.c +1 -1
index a5c0b5c..9d67952 100644
@@ -80,7 +80,7 @@ static int acpi_ec_stop(struct acpi_device *device, int type);
 static int acpi_ec_add(struct acpi_device *device);
 
 static struct acpi_driver acpi_ec_driver = {
-	.name = ACPI_EC_DRIVER_NAME,
+	.name = "ec",
 	.class = ACPI_EC_CLASS,
 	.ids = ACPI_EC_HID,
 	.ops = {
drivers/acpi/fan.c +1 -1
index b902d3b..5ac727e 100644
@@ -52,7 +52,7 @@ static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state);
 static int acpi_fan_resume(struct acpi_device *device);
 
 static struct acpi_driver acpi_fan_driver = {
-	.name = ACPI_FAN_DRIVER_NAME,
+	.name = "fan",
 	.class = ACPI_FAN_CLASS,
 	.ids = "PNP0C0B",
 	.ops = {
drivers/acpi/i2c_ec.c +1 -1
index 62af6da..d2fde7a 100644
@@ -39,7 +39,7 @@ static int acpi_ec_hc_add(struct acpi_device *device);
 static int acpi_ec_hc_remove(struct acpi_device *device, int type);
 
 static struct acpi_driver acpi_ec_hc_driver = {
-	.name = ACPI_EC_HC_DRIVER_NAME,
+	.name = "i2c_ec",
 	.class = ACPI_EC_HC_CLASS,
 	.ids = ACPI_EC_HC_HID,
 	.ops = {
drivers/acpi/pci_link.c +1 -1
index da22c5e..a95f03f 100644
@@ -56,7 +56,7 @@ static int acpi_pci_link_add(struct acpi_device *device);
 static int acpi_pci_link_remove(struct acpi_device *device, int type);
 
 static struct acpi_driver acpi_pci_link_driver = {
-	.name = ACPI_PCI_LINK_DRIVER_NAME,
+	.name = "pci_link",
 	.class = ACPI_PCI_LINK_CLASS,
 	.ids = ACPI_PCI_LINK_HID,
 	.ops = {
drivers/acpi/pci_root.c +1 -1
index 3db2cd3..7bf24c3 100644
@@ -46,7 +46,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type);
 static int acpi_pci_root_start(struct acpi_device *device);
 
 static struct acpi_driver acpi_pci_root_driver = {
-	.name = ACPI_PCI_ROOT_DRIVER_NAME,
+	.name = "pci_root",
 	.class = ACPI_PCI_ROOT_CLASS,
 	.ids = ACPI_PCI_ROOT_HID,
 	.ops = {
drivers/acpi/power.c +1 -1
index 26e8edc..09b855d 100644
@@ -60,7 +60,7 @@ static int acpi_power_remove(struct acpi_device *device, int type);
 static int acpi_power_open_fs(struct inode *inode, struct file *file);
 
 static struct acpi_driver acpi_power_driver = {
-	.name = ACPI_POWER_DRIVER_NAME,
+	.name = "power",
 	.class = ACPI_POWER_CLASS,
 	.ids = ACPI_POWER_HID,
 	.ops = {
drivers/acpi/processor_core.c +1 -1
index 13135f8..19c44b5 100644
@@ -89,7 +89,7 @@ static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
 static int acpi_processor_handle_eject(struct acpi_processor *pr);
 
 static struct acpi_driver acpi_processor_driver = {
-	.name = ACPI_PROCESSOR_DRIVER_NAME,
+	.name = "processor",
 	.class = ACPI_PROCESSOR_CLASS,
 	.ids = ACPI_PROCESSOR_HID,
 	.ops = {
drivers/acpi/sbs.c +1 -1
index f5b714d..1c2d8fb 100644
@@ -110,7 +110,7 @@ static void acpi_battery_smbus_err_handler(struct acpi_ec_smbus *smbus);
 static void acpi_sbs_update_queue(void *data);
 
 static struct acpi_driver acpi_sbs_driver = {
-	.name = ACPI_SBS_DRIVER_NAME,
+	.name = "sbs",
 	.class = ACPI_SBS_CLASS,
 	.ids = ACPI_SBS_HID,
 	.ops = {
drivers/acpi/thermal.c +1 -1
index bf0a9f2..c34a89d 100644
@@ -98,7 +98,7 @@ static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
 					  size_t, loff_t *);
 
 static struct acpi_driver acpi_thermal_driver = {
-	.name = ACPI_THERMAL_DRIVER_NAME,
+	.name = "thermal",
 	.class = ACPI_THERMAL_CLASS,
 	.ids = ACPI_THERMAL_HID,
 	.ops = {
drivers/acpi/video.c +1 -1
index a095d01..0c44ffd 100644
@@ -75,7 +75,7 @@ static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
 
 static struct acpi_driver acpi_video_bus = {
-	.name = ACPI_VIDEO_DRIVER_NAME,
+	.name = "video",
 	.class = ACPI_VIDEO_CLASS,
 	.ids = ACPI_VIDEO_HID,
 	.ops = {
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#39 lore raw

PATCH 39/41 ACPI: delete extra #defines in /drivers/acpi/ drivers

From: Len Brown <[email protected]>

Cosmetic only.

Except in a single case, #define ACPI_*_DRIVER_NAME were invoked 0 or 1 times.

---
 drivers/acpi/ac.c                   |    3 +--
 drivers/acpi/acpi_memhotplug.c      |    3 +--
 drivers/acpi/battery.c              |    3 +--
 drivers/acpi/bay.c                  |    4 +---
 drivers/acpi/button.c               |    3 +--
 drivers/acpi/container.c            |    3 +--
 drivers/acpi/dock.c                 |    6 +++---
 drivers/acpi/ec.c                   |    1 -
 drivers/acpi/fan.c                  |    3 +--
 drivers/acpi/i2c_ec.c               |    1 -
 drivers/acpi/pci_link.c             |    1 -
 drivers/acpi/pci_root.c             |    1 -
 drivers/acpi/power.c                |    1 -
 drivers/acpi/processor_core.c       |    3 +--
 drivers/acpi/processor_idle.c       |    1 -
 drivers/acpi/processor_perflib.c    |    1 -
 drivers/acpi/processor_thermal.c    |    1 -
 drivers/acpi/processor_throttling.c |    1 -
 drivers/acpi/sbs.c                  |    1 -
 drivers/acpi/scan.c                 |    1 -
 drivers/acpi/system.c               |    1 -
 drivers/acpi/thermal.c              |    3 +--
 drivers/acpi/video.c                |    3 +--
 23 files changed, 13 insertions(+), 36 deletions(-)
drivers/acpi/ac.c +1 -2
index 17eef27..37c7dc4 100644
@@ -35,7 +35,6 @@
 #define ACPI_AC_COMPONENT		0x00020000
 #define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_AC_HID 			"ACPI0003"
-#define ACPI_AC_DRIVER_NAME		"ACPI AC Adapter Driver"
 #define ACPI_AC_DEVICE_NAME		"AC Adapter"
 #define ACPI_AC_FILE_STATE		"state"
 #define ACPI_AC_NOTIFY_STATUS		0x80
@@ -47,7 +46,7 @@
 ACPI_MODULE_NAME("ac");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
-MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI AC Adapter Driver");
 MODULE_LICENSE("GPL");
 
 extern struct proc_dir_entry *acpi_lock_ac_dir(void);
drivers/acpi/acpi_memhotplug.c +1 -2
index d677130..c261726 100644
@@ -35,14 +35,13 @@
 #define ACPI_MEMORY_DEVICE_COMPONENT		0x08000000UL
 #define ACPI_MEMORY_DEVICE_CLASS		"memory"
 #define ACPI_MEMORY_DEVICE_HID			"PNP0C80"
-#define ACPI_MEMORY_DEVICE_DRIVER_NAME		"Hotplug Mem Driver"
 #define ACPI_MEMORY_DEVICE_NAME			"Hotplug Mem Device"
 
 #define _COMPONENT		ACPI_MEMORY_DEVICE_COMPONENT
 
 ACPI_MODULE_NAME("acpi_memhotplug");
 MODULE_AUTHOR("Naveen B S <[email protected]>");
-MODULE_DESCRIPTION(ACPI_MEMORY_DEVICE_DRIVER_NAME);
+MODULE_DESCRIPTION("Hotplug Mem Driver");
 MODULE_LICENSE("GPL");
 
 /* ACPI _STA method values */
drivers/acpi/battery.c +1 -2
index da29d9d..02de49e 100644
@@ -42,7 +42,6 @@
 #define ACPI_BATTERY_COMPONENT		0x00040000
 #define ACPI_BATTERY_CLASS		"battery"
 #define ACPI_BATTERY_HID		"PNP0C0A"
-#define ACPI_BATTERY_DRIVER_NAME	"ACPI Battery Driver"
 #define ACPI_BATTERY_DEVICE_NAME	"Battery"
 #define ACPI_BATTERY_FILE_INFO		"info"
 #define ACPI_BATTERY_FILE_STATUS	"state"
@@ -56,7 +55,7 @@
 ACPI_MODULE_NAME("battery");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
-MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI Battery Driver");
 MODULE_LICENSE("GPL");
 
 extern struct proc_dir_entry *acpi_lock_battery_dir(void);
drivers/acpi/bay.c +1 -3
index 1f88858..36dcb89 100644
@@ -32,11 +32,9 @@
 #include <asm/uaccess.h>
 #include <linux/platform_device.h>
 
-#define ACPI_BAY_DRIVER_NAME "ACPI Removable Drive Bay Driver"
-
 ACPI_MODULE_NAME("bay");
 MODULE_AUTHOR("Kristen Carlson Accardi");
-MODULE_DESCRIPTION(ACPI_BAY_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI Removable Drive Bay Driver");
 MODULE_LICENSE("GPL");
 #define ACPI_BAY_CLASS "bay"
 #define ACPI_BAY_COMPONENT	0x10000000
drivers/acpi/button.c +1 -2
index 45f960d..cb4110b 100644
@@ -34,7 +34,6 @@
 #include <acpi/acpi_drivers.h>
 
 #define ACPI_BUTTON_COMPONENT		0x00080000
-#define ACPI_BUTTON_DRIVER_NAME		"ACPI Button Driver"
 #define ACPI_BUTTON_CLASS		"button"
 #define ACPI_BUTTON_FILE_INFO		"info"
 #define ACPI_BUTTON_FILE_STATE		"state"
@@ -64,7 +63,7 @@
 ACPI_MODULE_NAME("button");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
-MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI Button Driver");
 MODULE_LICENSE("GPL");
 
 static int acpi_button_add(struct acpi_device *device);
drivers/acpi/container.c +1 -2
index 0e36062..0930d94 100644
@@ -35,7 +35,6 @@
 #include <acpi/acpi_drivers.h>
 #include <acpi/container.h>
 
-#define ACPI_CONTAINER_DRIVER_NAME	"ACPI container driver"
 #define ACPI_CONTAINER_DEVICE_NAME	"ACPI container device"
 #define ACPI_CONTAINER_CLASS		"container"
 
@@ -47,7 +46,7 @@
 ACPI_MODULE_NAME("container");
 
 MODULE_AUTHOR("Anil S Keshavamurthy");
-MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI container driver");
 MODULE_LICENSE("GPL");
 
 #define ACPI_STA_PRESENT		(0x00000001)
drivers/acpi/dock.c +3 -3
index b3a04ff..54a697f 100644
@@ -32,11 +32,11 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
-#define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver"
+#define ACPI_DOCK_DRIVER_DESCRIPTION "ACPI Dock Station Driver"
 
 ACPI_MODULE_NAME("dock");
 MODULE_AUTHOR("Kristen Carlson Accardi");
-MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME);
+MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION);
 MODULE_LICENSE("GPL");
 
 static struct atomic_notifier_head dock_notifier_list;
@@ -741,7 +741,7 @@ static int dock_add(acpi_handle handle)
 		goto dock_add_err;
 	}
 
-	printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_NAME);
+	printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_DESCRIPTION);
 
 	return 0;
 
drivers/acpi/ec.c +0 -1
index 9d67952..c1f6251 100644
@@ -42,7 +42,6 @@ ACPI_MODULE_NAME("ec");
 #define ACPI_EC_COMPONENT		0x00100000
 #define ACPI_EC_CLASS			"embedded_controller"
 #define ACPI_EC_HID			"PNP0C09"
-#define ACPI_EC_DRIVER_NAME		"ACPI Embedded Controller Driver"
 #define ACPI_EC_DEVICE_NAME		"Embedded Controller"
 #define ACPI_EC_FILE_INFO		"info"
 #undef PREFIX
drivers/acpi/fan.c +1 -2
index 5ac727e..ec655c5 100644
@@ -36,14 +36,13 @@
 
 #define ACPI_FAN_COMPONENT		0x00200000
 #define ACPI_FAN_CLASS			"fan"
-#define ACPI_FAN_DRIVER_NAME		"ACPI Fan Driver"
 #define ACPI_FAN_FILE_STATE		"state"
 
 #define _COMPONENT		ACPI_FAN_COMPONENT
 ACPI_MODULE_NAME("fan");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
-MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI Fan Driver");
 MODULE_LICENSE("GPL");
 
 static int acpi_fan_add(struct acpi_device *device);
drivers/acpi/i2c_ec.c +0 -1
index d2fde7a..a29b827 100644
@@ -28,7 +28,6 @@
 #define ACPI_EC_HC_COMPONENT	0x00080000
 #define ACPI_EC_HC_CLASS	"ec_hc_smbus"
 #define ACPI_EC_HC_HID		"ACPI0001"
-#define ACPI_EC_HC_DRIVER_NAME	"ACPI EC HC smbus driver"
 #define ACPI_EC_HC_DEVICE_NAME	"EC HC smbus"
 
 #define _COMPONENT		ACPI_EC_HC_COMPONENT
drivers/acpi/pci_link.c +0 -1
index a95f03f..acc5947 100644
@@ -47,7 +47,6 @@
 ACPI_MODULE_NAME("pci_link");
 #define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
 #define ACPI_PCI_LINK_HID		"PNP0C0F"
-#define ACPI_PCI_LINK_DRIVER_NAME	"ACPI PCI Interrupt Link Driver"
 #define ACPI_PCI_LINK_DEVICE_NAME	"PCI Interrupt Link"
 #define ACPI_PCI_LINK_FILE_INFO		"info"
 #define ACPI_PCI_LINK_FILE_STATUS	"state"
drivers/acpi/pci_root.c +0 -1
index 7bf24c3..ad4145a 100644
@@ -39,7 +39,6 @@
 ACPI_MODULE_NAME("pci_root");
 #define ACPI_PCI_ROOT_CLASS		"pci_bridge"
 #define ACPI_PCI_ROOT_HID		"PNP0A03"
-#define ACPI_PCI_ROOT_DRIVER_NAME	"ACPI PCI Root Bridge Driver"
 #define ACPI_PCI_ROOT_DEVICE_NAME	"PCI Root Bridge"
 static int acpi_pci_root_add(struct acpi_device *device);
 static int acpi_pci_root_remove(struct acpi_device *device, int type);
drivers/acpi/power.c +0 -1
index 09b855d..92f80ba 100644
@@ -48,7 +48,6 @@
 ACPI_MODULE_NAME("power");
 #define ACPI_POWER_COMPONENT		0x00800000
 #define ACPI_POWER_CLASS		"power_resource"
-#define ACPI_POWER_DRIVER_NAME		"ACPI Power Resource Driver"
 #define ACPI_POWER_DEVICE_NAME		"Power Resource"
 #define ACPI_POWER_FILE_INFO		"info"
 #define ACPI_POWER_FILE_STATUS		"state"
drivers/acpi/processor_core.c +1 -2
index 19c44b5..911fc8c 100644
@@ -60,7 +60,6 @@
 
 #define ACPI_PROCESSOR_COMPONENT	0x01000000
 #define ACPI_PROCESSOR_CLASS		"processor"
-#define ACPI_PROCESSOR_DRIVER_NAME	"ACPI Processor Driver"
 #define ACPI_PROCESSOR_DEVICE_NAME	"Processor"
 #define ACPI_PROCESSOR_FILE_INFO	"info"
 #define ACPI_PROCESSOR_FILE_THROTTLING	"throttling"
@@ -77,7 +76,7 @@
 ACPI_MODULE_NAME("processor_core");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
-MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI Processor Driver");
 MODULE_LICENSE("GPL");
 
 static int acpi_processor_add(struct acpi_device *device);
drivers/acpi/processor_idle.c +0 -1
index a26433d..92f5185 100644
@@ -48,7 +48,6 @@
 
 #define ACPI_PROCESSOR_COMPONENT        0x01000000
 #define ACPI_PROCESSOR_CLASS            "processor"
-#define ACPI_PROCESSOR_DRIVER_NAME      "ACPI Processor Driver"
 #define _COMPONENT              ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_idle");
 #define ACPI_PROCESSOR_FILE_POWER	"power"
drivers/acpi/processor_perflib.c +0 -1
index c2add4e..2f2e796 100644
@@ -44,7 +44,6 @@
 
 #define ACPI_PROCESSOR_COMPONENT	0x01000000
 #define ACPI_PROCESSOR_CLASS		"processor"
-#define ACPI_PROCESSOR_DRIVER_NAME	"ACPI Processor Driver"
 #define ACPI_PROCESSOR_FILE_PERFORMANCE	"performance"
 #define _COMPONENT		ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_perflib");
drivers/acpi/processor_thermal.c +0 -1
index 9357d63..06e6f3f 100644
@@ -41,7 +41,6 @@
 
 #define ACPI_PROCESSOR_COMPONENT        0x01000000
 #define ACPI_PROCESSOR_CLASS            "processor"
-#define ACPI_PROCESSOR_DRIVER_NAME      "ACPI Processor Driver"
 #define _COMPONENT              ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_thermal");
 
drivers/acpi/processor_throttling.c +0 -1
index 8194eb0..b334860 100644
@@ -41,7 +41,6 @@
 
 #define ACPI_PROCESSOR_COMPONENT        0x01000000
 #define ACPI_PROCESSOR_CLASS            "processor"
-#define ACPI_PROCESSOR_DRIVER_NAME      "ACPI Processor Driver"
 #define _COMPONENT              ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_throttling");
 
drivers/acpi/sbs.c +0 -1
index 1c2d8fb..1eab203 100644
@@ -59,7 +59,6 @@ extern void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
 #define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_BATTERY_CLASS		"battery"
 #define ACPI_SBS_HID			"ACPI0002"
-#define ACPI_SBS_DRIVER_NAME		"ACPI Smart Battery System Driver"
 #define ACPI_SBS_DEVICE_NAME		"Smart Battery System"
 #define ACPI_SBS_FILE_INFO		"info"
 #define ACPI_SBS_FILE_STATE		"state"
drivers/acpi/scan.c +0 -1
index cff1b59..bb0e0da 100644
@@ -17,7 +17,6 @@ extern struct acpi_device *acpi_root;
 
 #define ACPI_BUS_CLASS			"system_bus"
 #define ACPI_BUS_HID			"ACPI_BUS"
-#define ACPI_BUS_DRIVER_NAME		"ACPI Bus Driver"
 #define ACPI_BUS_DEVICE_NAME		"System Bus"
 
 static LIST_HEAD(acpi_device_list);
drivers/acpi/system.c +0 -1
index edead9e..83a8d30 100644
@@ -38,7 +38,6 @@ ACPI_MODULE_NAME("system");
 #define MODULE_PARAM_PREFIX "acpi."
 
 #define ACPI_SYSTEM_CLASS		"system"
-#define ACPI_SYSTEM_DRIVER_NAME		"ACPI System Driver"
 #define ACPI_SYSTEM_DEVICE_NAME		"System"
 #define ACPI_SYSTEM_FILE_INFO		"info"
 #define ACPI_SYSTEM_FILE_EVENT		"event"
drivers/acpi/thermal.c +1 -2
index c34a89d..f50a405 100644
@@ -46,7 +46,6 @@
 
 #define ACPI_THERMAL_COMPONENT		0x04000000
 #define ACPI_THERMAL_CLASS		"thermal_zone"
-#define ACPI_THERMAL_DRIVER_NAME	"ACPI Thermal Zone Driver"
 #define ACPI_THERMAL_DEVICE_NAME	"Thermal Zone"
 #define ACPI_THERMAL_FILE_STATE		"state"
 #define ACPI_THERMAL_FILE_TEMPERATURE	"temperature"
@@ -73,7 +72,7 @@
 ACPI_MODULE_NAME("thermal");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
-MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI Thermal Zone Driver");
 MODULE_LICENSE("GPL");
 
 static int tzp;
drivers/acpi/video.c +1 -2
index 0c44ffd..bf525cc 100644
@@ -40,7 +40,6 @@
 
 #define ACPI_VIDEO_COMPONENT		0x08000000
 #define ACPI_VIDEO_CLASS		"video"
-#define ACPI_VIDEO_DRIVER_NAME		"ACPI Video Driver"
 #define ACPI_VIDEO_BUS_NAME		"Video Bus"
 #define ACPI_VIDEO_DEVICE_NAME		"Video Device"
 #define ACPI_VIDEO_NOTIFY_SWITCH	0x80
@@ -68,7 +67,7 @@
 ACPI_MODULE_NAME("video");
 
 MODULE_AUTHOR("Bruno Ducrot");
-MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI Video Driver");
 MODULE_LICENSE("GPL");
 
 static int acpi_video_bus_add(struct acpi_device *device);
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#40 lore raw

PATCH 40/41 sony-laptop: allow complex per-value input/output validation

From: Mattia Dongili <[email protected]>

Replace sony_acpi_value.{min,max} with a callback function that allows more complex reasoning in accepting input and presenting output.

This allows consistency between the sony-laptop specific 'brightness_default' and the backlight subsystem 0-based 'brightness'.

---
 drivers/misc/sony-laptop.c |   81 +++++++++++++++++++++++++++++++++----------
 1 files changed, 62 insertions(+), 19 deletions(-)
drivers/misc/sony-laptop.c +62 -19
index d7b5330..cabbed0 100644
@@ -58,13 +58,17 @@ static ssize_t sony_acpi_show(struct device *, struct device_attribute *,
 			      char *);
 static ssize_t sony_acpi_store(struct device *, struct device_attribute *,
 			       const char *, size_t);
+static int boolean_validate(const int, const int);
+static int brightness_default_validate(const int, const int);
+
+#define SNC_VALIDATE_IN		0
+#define SNC_VALIDATE_OUT	1
 
 struct sony_acpi_value {
 	char *name;		/* name of the entry */
 	char **acpiget;		/* names of the ACPI get function */
 	char **acpiset;		/* names of the ACPI set function */
-	int min;		/* minimum allowed value or -1 */
-	int max;		/* maximum allowed value or -1 */
+	int (*validate)(const int, const int);	/* input/output validation */
 	int value;		/* current setting */
 	int valid;		/* Has ever been set */
 	int debug;		/* active only in debug mode ? */
@@ -74,13 +78,12 @@ struct sony_acpi_value {
 #define HANDLE_NAMES(_name, _values...) \
 	static char *snc_##_name[] = { _values, NULL }
 
-#define SONY_ACPI_VALUE(_name, _getters, _setters, _min, _max, _debug) \
+#define SONY_ACPI_VALUE(_name, _getters, _setters, _validate, _debug) \
 	{ \
 		.name		= __stringify(_name), \
 		.acpiget	= _getters, \
 		.acpiset	= _setters, \
-		.min		= _min, \
-		.max		= _max, \
+		.validate	= _validate, \
 		.debug		= _debug, \
 		.devattr	= __ATTR(_name, 0, sony_acpi_show, sony_acpi_store), \
 	}
@@ -114,17 +117,18 @@ HANDLE_NAMES(CMI_set, "SCMI");
 
 static struct sony_acpi_value sony_acpi_values[] = {
 	SONY_ACPI_VALUE(brightness_default, snc_brightness_def_get,
-			snc_brightness_def_set, 1, SONY_MAX_BRIGHTNESS, 0),
-	SONY_ACPI_VALUE(fnkey, snc_fnkey_get, NULL, -1, -1, 0),
-	SONY_ACPI_VALUE(cdpower, snc_cdpower_get, snc_cdpower_set, 0, 1, 0),
-	SONY_ACPI_VALUE(audiopower, snc_audiopower_get, snc_audiopower_set, 0,
-			1, 0),
-	SONY_ACPI_VALUE(lanpower, snc_lanpower_get, snc_lanpower_set, 0, 1, 1),
+			snc_brightness_def_set, brightness_default_validate, 0),
+	SONY_ACPI_VALUE(fnkey, snc_fnkey_get, NULL, NULL, 0),
+	SONY_ACPI_VALUE(cdpower, snc_cdpower_get, snc_cdpower_set, boolean_validate, 0),
+	SONY_ACPI_VALUE(audiopower, snc_audiopower_get, snc_audiopower_set,
+			boolean_validate, 0),
+	SONY_ACPI_VALUE(lanpower, snc_lanpower_get, snc_lanpower_set,
+			boolean_validate, 1),
 	/* unknown methods */
-	SONY_ACPI_VALUE(PID, snc_PID_get, NULL, -1, -1, 1),
-	SONY_ACPI_VALUE(CTR, snc_CTR_get, snc_CTR_set, -1, -1, 1),
-	SONY_ACPI_VALUE(PCR, snc_PCR_get, snc_PCR_set, -1, -1, 1),
-	SONY_ACPI_VALUE(CMI, snc_CMI_get, snc_CMI_set, -1, -1, 1),
+	SONY_ACPI_VALUE(PID, snc_PID_get, NULL, NULL, 1),
+	SONY_ACPI_VALUE(CTR, snc_CTR_get, snc_CTR_set, NULL, 1),
+	SONY_ACPI_VALUE(PCR, snc_PCR_get, snc_PCR_set, NULL, 1),
+	SONY_ACPI_VALUE(CMI, snc_CMI_get, snc_CMI_set, NULL, 1),
 	SONY_ACPI_VALUE_NULL
 };
 
@@ -190,6 +194,41 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,
 }
 
 /*
+ * sony_acpi_values input/output validate functions
+ */
+
+/* brightness_default_validate:
+ *
+ * manipulate input output values to keep consistency with the
+ * backlight framework for which brightness values are 0-based.
+ */
+static int brightness_default_validate(const int direction, const int value)
+{
+	switch (direction) {
+		case SNC_VALIDATE_OUT:
+			return value - 1;
+		case SNC_VALIDATE_IN:
+			if (value >= 0 && value < SONY_MAX_BRIGHTNESS)
+				return value + 1;
+	}
+	return -EINVAL;
+}
+
+/* boolean_validate:
+ *
+ * on input validate boolean values 0/1, on output just pass the
+ * received value.
+ */
+static int boolean_validate(const int direction, const int value)
+{
+	if (direction == SNC_VALIDATE_IN) {
+		if (value != 0 && value != 1)
+			return -EINVAL;
+	}
+	return value;
+}
+
+/*
  * Sysfs show/store common to all sony_acpi_values
  */
 static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr,
@@ -205,6 +244,9 @@ static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr,
 	if (acpi_callgetfunc(sony_acpi_handle, *item->acpiget, &value) < 0)
 		return -EIO;
 
+	if (item->validate)
+		value = item->validate(SNC_VALIDATE_OUT, value);
+
 	return snprintf(buffer, PAGE_SIZE, "%d\n", value);
 }
 
@@ -224,10 +266,11 @@ static ssize_t sony_acpi_store(struct device *dev,
 
 	value = simple_strtoul(buffer, NULL, 10);
 
-	if (item->min != -1 && value < item->min)
-		return -EINVAL;
-	if (item->max != -1 && value > item->max)
-		return -EINVAL;
+	if (item->validate)
+		value = item->validate(SNC_VALIDATE_IN, value);
+
+	if (value < 0)
+		return value;
 
 	if (acpi_callsetfunc(sony_acpi_handle, *item->acpiset, value, NULL) < 0)
 		return -EIO;
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#41 lore raw

PATCH 41/41 ACPI: cleanup: make disable_acpi() valid w/o CONFIG_ACPI

From: Rusty Russell <[email protected]>

Quoted 4 lines · Len Brown

Okay, but better to use disable_acpi()
indeed, since this would be the first code not already inside CONFIG_ACPI to invoke disable_acpi(), we could define the inline as empty and you could then scratch the #ifdef too.

---
 include/asm-i386/acpi.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/asm-i386/acpi.h +1 -0
index 5e657eb..449f3f2 100644
@@ -127,6 +127,7 @@ extern int acpi_irq_balance_set(char *str);
 #define acpi_ioapic 0
 static inline void acpi_noirq_set(void) { }
 static inline void acpi_disable_pci(void) { }
+static inline void disable_acpi(void) { }
 
 #endif	/* !CONFIG_ACPI */
 
Signature · 1 line
1.5.0.rc4.345.gb4d2
author reviewer
#42 lore raw

Re: [PATCH 26/41] ACPI: video: Fix null pointer in appledisplay driver

In reply to Len Brown
Quoted 17 lines · Len Brown

From: Michael Hanselmann <[email protected]>

commit "ACPI: video: Add dev argument for backlight_device_register" 519ab5f2be65b72cf12ae99c89752bbe79b44df6
broke the apple display driver.

---
 drivers/usb/misc/appledisplay.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/misc/appledisplay.c +0 -0
index a7932a7..31ab83c 100644

drivers/usb/misc/appledisplay.c static int appledisplay_probe(struct usb_interface *iface, · line 287

Quoted 8 lines
drivers/usb/misc/appledisplay.c +1 -1
@@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
 	/* Register backlight device */
 	snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
 		atomic_inc_return(&count_displays) - 1);
-	pdata->bd = backlight_device_register(bl_name, NULL, NULL,
+	pdata->bd = backlight_device_register(bl_name, NULL, pdata
 						&appledisplay_bl_data);
 	if (IS_ERR(pdata->bd)) {
 		err("appledisplay: Backlight registration failed");

huh, this version of the patch is missing a comma. anyway, it is fixed now.

cheers,
-Len