ACPI: dock: cleanup the uid patch
Make uid sysfs file error path free memory, and cleanup sysfs file when removing driver. Also fix CodingStyle violations. Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Cc: Illya A. Volynets-Evenbakh <ilya@total-knowledge.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
de5603748a
commit
38ff4ffc03
|
@ -675,16 +675,15 @@ static ssize_t show_dock_uid(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
unsigned long lbuf;
|
unsigned long lbuf;
|
||||||
acpi_status status = acpi_evaluate_integer(dock_station->handle, "_UID", NULL, &lbuf);
|
acpi_status status = acpi_evaluate_integer(dock_station->handle,
|
||||||
if(ACPI_FAILURE(status)) {
|
"_UID", NULL, &lbuf);
|
||||||
|
if (ACPI_FAILURE(status))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf);
|
return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf);
|
||||||
}
|
}
|
||||||
DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
|
DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dock_add - add a new dock station
|
* dock_add - add a new dock station
|
||||||
* @handle: the dock station handle
|
* @handle: the dock station handle
|
||||||
|
@ -736,6 +735,8 @@ static int dock_add(acpi_handle handle)
|
||||||
ret = device_create_file(&dock_device.dev, &dev_attr_uid);
|
ret = device_create_file(&dock_device.dev, &dev_attr_uid);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk("Error %d adding sysfs file\n", ret);
|
printk("Error %d adding sysfs file\n", ret);
|
||||||
|
device_remove_file(&dock_device.dev, &dev_attr_docked);
|
||||||
|
device_remove_file(&dock_device.dev, &dev_attr_undock);
|
||||||
platform_device_unregister(&dock_device);
|
platform_device_unregister(&dock_device);
|
||||||
kfree(dock_station);
|
kfree(dock_station);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -775,6 +776,7 @@ dock_add_err:
|
||||||
dock_add_err_unregister:
|
dock_add_err_unregister:
|
||||||
device_remove_file(&dock_device.dev, &dev_attr_docked);
|
device_remove_file(&dock_device.dev, &dev_attr_docked);
|
||||||
device_remove_file(&dock_device.dev, &dev_attr_undock);
|
device_remove_file(&dock_device.dev, &dev_attr_undock);
|
||||||
|
device_remove_file(&dock_device.dev, &dev_attr_uid);
|
||||||
platform_device_unregister(&dock_device);
|
platform_device_unregister(&dock_device);
|
||||||
kfree(dock_station);
|
kfree(dock_station);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -806,6 +808,7 @@ static int dock_remove(void)
|
||||||
/* cleanup sysfs */
|
/* cleanup sysfs */
|
||||||
device_remove_file(&dock_device.dev, &dev_attr_docked);
|
device_remove_file(&dock_device.dev, &dev_attr_docked);
|
||||||
device_remove_file(&dock_device.dev, &dev_attr_undock);
|
device_remove_file(&dock_device.dev, &dev_attr_undock);
|
||||||
|
device_remove_file(&dock_device.dev, &dev_attr_uid);
|
||||||
platform_device_unregister(&dock_device);
|
platform_device_unregister(&dock_device);
|
||||||
|
|
||||||
/* free dock station memory */
|
/* free dock station memory */
|
||||||
|
|
Loading…
Reference in New Issue