From 6780aa683d4d83ed887dd07b7987947d339d76f1 Mon Sep 17 00:00:00 2001 From: Adrian Huang Date: Sat, 15 Dec 2012 00:30:07 +0100 Subject: ACPI / APEI: Fix the returned value in erst_dbg_read If the persistent store is empty initially, the function 'erst_dbg_read' returns a nonzero value. The better way is to return a zero indicating the read operation reaches EOF. Tested on two different servers. Signed-off-by: Adrian Huang Signed-off-by: Rafael J. Wysocki --- drivers/acpi/apei/erst-dbg.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c index 903549df809b..04ab5c9d3ced 100644 --- a/drivers/acpi/apei/erst-dbg.c +++ b/drivers/acpi/apei/erst-dbg.c @@ -111,8 +111,17 @@ retry_next: if (rc) goto out; /* no more record */ - if (id == APEI_ERST_INVALID_RECORD_ID) + if (id == APEI_ERST_INVALID_RECORD_ID) { + /* + * If the persistent store is empty initially, the function + * 'erst_read' below will return "-ENOENT" value. This causes + * 'retry_next' label is entered again. The returned value + * should be zero indicating the read operation is EOF. + */ + len = 0; + goto out; + } retry: rc = len = erst_read(id, erst_dbg_buf, erst_dbg_buf_len); /* The record may be cleared by others, try read next record */ -- cgit v1.2.3 From 8611ea5f5d708d60ab29ed3cdb33e67168404fc0 Mon Sep 17 00:00:00 2001 From: Liu Jinsong Date: Sun, 16 Dec 2012 14:08:41 +0100 Subject: ACPI / memhotplug: remove redundant logic of acpi memory hotadd When memory hotadd, acpi_memory_enable_device has already been done at drv->ops.add (acpi_memory_device_add), no need to do it again at notify callback. At acpi_memory_enable_device, acpi_memory_get_device_resources is also a redundant action, since it has been done at drv->ops.add. Signed-off-by: Liu Jinsong Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_memhotplug.c | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index eb30e5ab4cab..b679bf8478f7 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -226,16 +226,6 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) struct acpi_memory_info *info; int node; - - /* Get the range from the _CRS */ - result = acpi_memory_get_device_resources(mem_device); - if (result) { - dev_err(&mem_device->device->dev, - "get_device_resources failed\n"); - mem_device->state = MEMORY_INVALID_STATE; - return result; - } - node = acpi_get_node(mem_device->device->handle); /* * Tell the VM there is more memory here... @@ -342,14 +332,6 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) break; } - if (acpi_memory_check_device(mem_device)) - break; - - if (acpi_memory_enable_device(mem_device)) { - acpi_handle_err(handle,"Cannot enable memory device\n"); - break; - } - ost_code = ACPI_OST_SC_SUCCESS; break; -- cgit v1.2.3 From 5cc36c724eb60b5e5457807f3230e5bb5454e4d0 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Sun, 16 Dec 2012 23:28:53 +0100 Subject: ACPI / PM: Do not apply ACPI_SUCCESS() to acpi_bus_get_device() result Since the return value of acpi_bus_get_device() is not of type acpi_status, ACPI_SUCCESS() should not be used for checking its return value. Fix that. Signed-off-by: Rafael J. Wysocki Reviewed-by: Mika Westerberg --- drivers/acpi/device_pm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index f09dc987cf17..c6ff606c6d5b 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -358,8 +358,7 @@ static struct acpi_device *acpi_dev_pm_get_node(struct device *dev) acpi_handle handle = DEVICE_ACPI_HANDLE(dev); struct acpi_device *adev; - return handle && ACPI_SUCCESS(acpi_bus_get_device(handle, &adev)) ? - adev : NULL; + return handle && !acpi_bus_get_device(handle, &adev) ? adev : NULL; } /** -- cgit v1.2.3 From 23415eb5233eb3c1939c4cb7d6235af98a3a2955 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 18 Dec 2012 06:31:30 +0000 Subject: ACPI / glue: Update DBG macro to include KERN_DEBUG Currently these DBG statements are emitted at KERN_DEFAULT. Change the macro to emit at KERN_DEBUG. This can help avoid unexpected message interleaving. Signed-off-by: Joe Perches Signed-off-by: Rafael J. Wysocki --- drivers/acpi/glue.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 01551840d236..95af6f674a6c 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -18,9 +18,14 @@ #define ACPI_GLUE_DEBUG 0 #if ACPI_GLUE_DEBUG -#define DBG(x...) printk(PREFIX x) +#define DBG(fmt, ...) \ + printk(KERN_DEBUG PREFIX fmt, ##__VA_ARGS__) #else -#define DBG(x...) do { } while(0) +#define DBG(fmt, ...) \ +do { \ + if (0) \ + printk(KERN_DEBUG PREFIX fmt, ##__VA_ARGS__); \ +} while (0) #endif static LIST_HEAD(bus_type_list); static DECLARE_RWSEM(bus_type_sem); -- cgit v1.2.3 From 0271f4f1176d7205b2b73ef956b169db8f417932 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Wed, 26 Dec 2012 13:26:46 +0100 Subject: ACPI / power: Remove useless message from device registering routine After commit 71fbad6 (PCI/ACPI: Notify PCI devices when their power resource is turned on) made acpi_pci_bind() call acpi_power_resource_register_device(), the debug message at the end of the latter appears in the kernel log for every PCI device that doesn't happen to have power resources assigned (which is the vast majority of them). However, this message is totally useless, because it doesn't even say which device it is about. Moreover, it is misleading, because it only means that the given device has no power resources, which isn't exceptional at all. Remove that useless message altogether and simplify acpi_power_resource_register_device() slightly. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/power.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 7db61b8fa11f..6e7b9d523812 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -445,11 +445,8 @@ int acpi_power_resource_register_device(struct device *dev, acpi_handle handle) return -ENODEV; ret = acpi_bus_get_device(handle, &acpi_dev); - if (ret) - goto no_power_resource; - - if (!acpi_dev->power.flags.power_resources) - goto no_power_resource; + if (ret || !acpi_dev->power.flags.power_resources) + return -ENODEV; powered_device = kzalloc(sizeof(*powered_device), GFP_KERNEL); if (!powered_device) @@ -471,10 +468,6 @@ int acpi_power_resource_register_device(struct device *dev, acpi_handle handle) } return ret; - -no_power_resource: - printk(KERN_DEBUG PREFIX "Invalid Power Resource to register!\n"); - return -ENODEV; } EXPORT_SYMBOL_GPL(acpi_power_resource_register_device); -- cgit v1.2.3 From 4f5f64cf0cc916220aaa055992e31195470cfe37 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 4 Jan 2013 23:00:54 +0100 Subject: ACPI / scan: Do not use dummy HID for system bus ACPI nodes At one point acpi_device_set_id() checks if acpi_device_hid(device) returns NULL, but that never happens, so system bus devices with an empty list of PNP IDs are given the dummy HID ("device") instead of the "system bus HID" ("LNXSYBUS"). Fix the code to use the right check. Signed-off-by: Rafael J. Wysocki Cc: --- drivers/acpi/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 53502d1bbf26..c88be6c37c30 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1346,7 +1346,7 @@ static void acpi_device_set_id(struct acpi_device *device) acpi_add_id(device, ACPI_DOCK_HID); else if (!acpi_ibm_smbus_match(device)) acpi_add_id(device, ACPI_SMBUS_IBM_HID); - else if (!acpi_device_hid(device) && + else if (list_empty(&device->pnp.ids) && ACPI_IS_ROOT_DEVICE(device->parent)) { acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); -- cgit v1.2.3