@@ -256,11 +256,8 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event)
static int acpi_ac_add(struct acpi_device *device)
{
int result = 0;
- struct acpi_ac *ac = NULL;
-
+ struct acpi_ac *ac;
- if (!device)
- return -EINVAL;
ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL);
if (!ac)
@@ -306,11 +303,9 @@ static int acpi_ac_add(struct acpi_device *device)
static int acpi_ac_resume(struct acpi_device *device)
{
- struct acpi_ac *ac;
+ struct acpi_ac *ac = acpi_driver_data(device);
unsigned old_state;
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
- ac = acpi_driver_data(device);
+
old_state = ac->state;
if (acpi_ac_get_state(ac))
return 0;
@@ -323,13 +318,8 @@ static int acpi_ac_resume(struct acpi_device *device)
static int acpi_ac_remove(struct acpi_device *device, int type)
{
- struct acpi_ac *ac = NULL;
-
-
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
+ struct acpi_ac *ac = acpi_driver_data(device);
- ac = acpi_driver_data(device);
#ifdef CONFIG_ACPI_SYSFS_POWER
if (ac->charger.dev)
@@ -401,11 +401,8 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
static int acpi_memory_device_add(struct acpi_device *device)
{
int result;
- struct acpi_memory_device *mem_device = NULL;
-
+ struct acpi_memory_device *mem_device;
- if (!device)
- return -EINVAL;
mem_device = kzalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
if (!mem_device)
@@ -450,13 +447,9 @@ static int acpi_memory_device_add(struct acpi_device *device)
static int acpi_memory_device_remove(struct acpi_device *device, int type)
{
- struct acpi_memory_device *mem_device = NULL;
+ struct acpi_memory_device *mem_device = acpi_driver_data(device);
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
- mem_device = acpi_driver_data(device);
kfree(mem_device);
return 0;
@@ -840,9 +840,8 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
static int acpi_battery_add(struct acpi_device *device)
{
int result = 0;
- struct acpi_battery *battery = NULL;
- if (!device)
- return -EINVAL;
+ struct acpi_battery *battery;
+
battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
if (!battery)
return -ENOMEM;
@@ -870,11 +869,8 @@ static int acpi_battery_add(struct acpi_device *device)
static int acpi_battery_remove(struct acpi_device *device, int type)
{
- struct acpi_battery *battery = NULL;
+ struct acpi_battery *battery = acpi_driver_data(device);
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
- battery = acpi_driver_data(device);
#ifdef CONFIG_ACPI_PROCFS_POWER
acpi_battery_remove_fs(device);
#endif
@@ -889,10 +885,8 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
/* this is needed to learn about changes made in suspended state */
static int acpi_battery_resume(struct acpi_device *device)
{
- struct acpi_battery *battery;
- if (!device)
- return -EINVAL;
- battery = acpi_driver_data(device);
+ struct acpi_battery *battery = acpi_driver_data(device);
+
battery->update_time = 0;
acpi_battery_update(battery);
return 0;
@@ -97,11 +97,6 @@ static int acpi_container_add(struct acpi_device *device)
struct acpi_container *container;
- if (!device) {
- printk(KERN_ERR PREFIX "device is NULL\n");
- return -EINVAL;
- }
-
container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL);
if (!container)
return -ENOMEM;
@@ -120,9 +115,8 @@ static int acpi_container_add(struct acpi_device *device)
static int acpi_container_remove(struct acpi_device *device, int type)
{
acpi_status status = AE_OK;
- struct acpi_container *pc = NULL;
+ struct acpi_container *pc = acpi_driver_data(device);
- pc = acpi_driver_data(device);
kfree(pc);
return status;
}
@@ -837,13 +837,9 @@ static int acpi_ec_add(struct acpi_device *device)
static int acpi_ec_remove(struct acpi_device *device, int type)
{
- struct acpi_ec *ec;
+ struct acpi_ec *ec = acpi_driver_data(device);
struct acpi_ec_query_handler *handler, *tmp;
- if (!device)
- return -EINVAL;
-
- ec = acpi_driver_data(device);
ec_remove_handlers(ec);
mutex_lock(&ec->lock);
list_for_each_entry_safe(handler, tmp, &ec->list, node) {
@@ -244,9 +244,6 @@ static int acpi_fan_add(struct acpi_device *device)
int state = 0;
struct thermal_cooling_device *cdev;
- if (!device)
- return -EINVAL;
-
strcpy(acpi_device_name(device), "Fan");
strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
@@ -300,9 +297,6 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
{
struct thermal_cooling_device *cdev = acpi_driver_data(device);
- if (!device || !cdev)
- return -EINVAL;
-
acpi_fan_remove_fs(device);
sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
sysfs_remove_link(&cdev->device.kobj, "device");
@@ -313,9 +307,6 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state)
{
- if (!device)
- return -EINVAL;
-
acpi_bus_set_power(device->handle, ACPI_STATE_D0);
return AE_OK;
@@ -326,9 +317,6 @@ static int acpi_fan_resume(struct acpi_device *device)
int result = 0;
int power_state = 0;
- if (!device)
- return -EINVAL;
-
result = acpi_bus_get_power(device->handle, &power_state);
if (result) {
printk(KERN_ERR PREFIX
@@ -639,9 +639,6 @@ static int acpi_power_add(struct acpi_device *device)
struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
- if (!device)
- return -EINVAL;
-
resource = kzalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
if (!resource)
return -ENOMEM;
@@ -695,15 +692,10 @@ static int acpi_power_add(struct acpi_device *device)
static int acpi_power_remove(struct acpi_device *device, int type)
{
- struct acpi_power_resource *resource = NULL;
+ struct acpi_power_resource *resource = acpi_driver_data(device);
struct list_head *node, *next;
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
- resource = acpi_driver_data(device);
-
acpi_power_remove_fs(device);
mutex_lock(&resource->resource_lock);
@@ -722,14 +714,9 @@ static int acpi_power_remove(struct acpi_device *device, int type)
static int acpi_power_resume(struct acpi_device *device)
{
int result = 0, state;
- struct acpi_power_resource *resource = NULL;
+ struct acpi_power_resource *resource = acpi_driver_data(device);
struct acpi_power_reference *ref;
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
- resource = acpi_driver_data(device);
-
result = acpi_power_get_state(device->handle, &state);
if (result)
return result;
@@ -888,13 +888,8 @@ err_free_cpumask:
static int acpi_processor_remove(struct acpi_device *device, int type)
{
- struct acpi_processor *pr = NULL;
-
-
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
+ struct acpi_processor *pr = acpi_driver_data(device);
- pr = acpi_driver_data(device);
if (pr->id >= nr_cpu_ids)
goto free;
@@ -960,12 +960,9 @@ static int acpi_sbs_add(struct acpi_device *device)
static int acpi_sbs_remove(struct acpi_device *device, int type)
{
- struct acpi_sbs *sbs;
+ struct acpi_sbs *sbs = acpi_driver_data(device);
int id;
- if (!device)
- return -EINVAL;
- sbs = acpi_driver_data(device);
if (!sbs)
return -EINVAL;
mutex_lock(&sbs->lock);
@@ -995,10 +992,8 @@ static void acpi_sbs_rmdirs(void)
static int acpi_sbs_resume(struct acpi_device *device)
{
- struct acpi_sbs *sbs;
- if (!device)
- return -EINVAL;
- sbs = device->driver_data;
+ struct acpi_sbs *sbs = acpi_driver_data(device);
+
acpi_sbs_callback(sbs);
return 0;
}
@@ -262,9 +262,6 @@ static int acpi_smbus_hc_add(struct acpi_device *device)
unsigned long long val;
struct acpi_smb_hc *hc;
- if (!device)
- return -EINVAL;
-
status = acpi_evaluate_integer(device->handle, "_EC", NULL, &val);
if (ACPI_FAILURE(status)) {
printk(KERN_ERR PREFIX "error obtaining _EC.\n");
@@ -296,12 +293,8 @@ extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
static int acpi_smbus_hc_remove(struct acpi_device *device, int type)
{
- struct acpi_smb_hc *hc;
-
- if (!device)
- return -EINVAL;
+ struct acpi_smb_hc *hc = acpi_driver_data(device);
- hc = acpi_driver_data(device);
acpi_ec_remove_query_handler(hc->ec, hc->query_bit);
kfree(hc);
return 0;
@@ -1361,12 +1361,9 @@ static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
static int acpi_thermal_add(struct acpi_device *device)
{
int result = 0;
- struct acpi_thermal *tz = NULL;
+ struct acpi_thermal *tz;
- if (!device)
- return -EINVAL;
-
tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
if (!tz)
return -ENOMEM;
@@ -1408,12 +1405,7 @@ end:
static int acpi_thermal_remove(struct acpi_device *device, int type)
{
- struct acpi_thermal *tz = NULL;
-
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
- tz = acpi_driver_data(device);
+ struct acpi_thermal *tz = acpi_driver_data(device);
acpi_thermal_remove_fs(device);
acpi_thermal_unregister_thermal_zone(tz);
@@ -1424,15 +1416,10 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
static int acpi_thermal_resume(struct acpi_device *device)
{
- struct acpi_thermal *tz = NULL;
+ struct acpi_thermal *tz = acpi_driver_data(device);
int i, j, power_state, result;
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
- tz = acpi_driver_data(device);
-
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
if (!(&tz->trips.active[i]))
break;
@@ -2207,15 +2207,10 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
static int instance;
static int acpi_video_resume(struct acpi_device *device)
{
- struct acpi_video_bus *video;
+ struct acpi_video_bus *video = acpi_driver_data(device);
struct acpi_video_device *video_device;
int i;
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
- video = acpi_driver_data(device);
-
for (i = 0; i < video->attached_count; i++) {
video_device = video->attached_array[i].bind_info;
if (video_device && video_device->backlight)
@@ -2351,13 +2346,8 @@ static int acpi_video_bus_add(struct acpi_device *device)
static int acpi_video_bus_remove(struct acpi_device *device, int type)
{
- struct acpi_video_bus *video = NULL;
-
-
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
+ struct acpi_video_bus *video = acpi_driver_data(device);
- video = acpi_driver_data(device);
acpi_video_bus_stop_devices(video);
acpi_video_bus_put_devices(video);
@@ -275,9 +275,6 @@ static int lis3lv02d_add(struct acpi_device *device)
{
int ret;
- if (!device)
- return -EINVAL;
-
lis3_dev.bus_priv = device;
lis3_dev.init = lis3lv02d_acpi_init;
lis3_dev.read = lis3lv02d_acpi_read;
@@ -315,9 +312,6 @@ static int lis3lv02d_add(struct acpi_device *device)
static int lis3lv02d_remove(struct acpi_device *device, int type)
{
- if (!device)
- return -EINVAL;
-
lis3lv02d_joystick_disable();
lis3lv02d_poweroff(&lis3_dev);
@@ -1240,9 +1240,6 @@ static int asus_hotk_add(struct acpi_device *device)
{
int result;
- if (!device)
- return -EINVAL;
-
pr_notice("Asus Laptop Support version %s\n",
ASUS_LAPTOP_VERSION);
@@ -1306,9 +1303,6 @@ end:
static int asus_hotk_remove(struct acpi_device *device, int type)
{
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
kfree(hotk->name);
kfree(hotk);
@@ -1334,9 +1334,6 @@ static int asus_hotk_add(struct acpi_device *device)
acpi_status status = AE_OK;
int result;
- if (!device)
- return -EINVAL;
-
printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
ASUS_ACPI_VERSION);
@@ -1392,9 +1389,6 @@ end:
static int asus_hotk_remove(struct acpi_device *device, int type)
{
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
asus_hotk_remove_fs(device);
kfree(hotk);
@@ -1194,8 +1194,6 @@ static int eeepc_hotk_add(struct acpi_device *device)
struct device *dev;
int result;
- if (!device)
- return -EINVAL;
pr_notice(EEEPC_HOTK_NAME "\n");
ehotk = kzalloc(sizeof(struct eeepc_hotk), GFP_KERNEL);
if (!ehotk)
@@ -1276,9 +1274,6 @@ fail_platform_driver:
static int eeepc_hotk_remove(struct acpi_device *device, int type)
{
- if (!device || !acpi_driver_data(device))
- return -EINVAL;
-
eeepc_backlight_exit();
eeepc_rfkill_exit();
eeepc_input_exit();
@@ -657,9 +657,6 @@ static int acpi_fujitsu_add(struct acpi_device *device)
struct input_dev *input;
int error;
- if (!device)
- return -EINVAL;
-
fujitsu->acpi_handle = device->handle;
sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME);
sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
@@ -813,9 +810,6 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
int error;
int i;
- if (!device)
- return -EINVAL;
-
fujitsu_hotkey->acpi_handle = device->handle;
sprintf(acpi_device_name(device), "%s",
ACPI_FUJITSU_HOTKEY_DEVICE_NAME);
@@ -156,9 +156,6 @@ static int intel_menlow_memory_add(struct acpi_device *device)
acpi_handle dummy;
struct thermal_cooling_device *cdev;
- if (!device)
- return -EINVAL;
-
status = acpi_get_handle(device->handle, MEMORY_GET_BANDWIDTH, &dummy);
if (ACPI_FAILURE(status))
goto end;
@@ -200,9 +197,6 @@ static int intel_menlow_memory_remove(struct acpi_device *device, int type)
{
struct thermal_cooling_device *cdev = acpi_driver_data(device);
- if (!device || !cdev)
- return -EINVAL;
-
sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
sysfs_remove_link(&cdev->device.kobj, "device");
thermal_cooling_device_unregister(cdev);
@@ -588,9 +588,6 @@ static int acpi_pcc_hotkey_resume(struct acpi_device *device)
struct pcc_acpi *pcc = acpi_driver_data(device);
acpi_status status = AE_OK;
- if (device == NULL || pcc == NULL)
- return -EINVAL;
-
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Sticky mode restore: %d\n",
pcc->sticky_mode));
@@ -604,9 +601,6 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
struct pcc_acpi *pcc;
int num_sifr, result;
- if (!device)
- return -EINVAL;
-
num_sifr = acpi_pcc_get_sqty(device);
if (num_sifr > 255) {
@@ -703,9 +697,6 @@ static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type)
{
struct pcc_acpi *pcc = acpi_driver_data(device);
- if (!device || !pcc)
- return -EINVAL;
-
sysfs_remove_group(&device->dev.kobj, &pcc_attr_group);
backlight_device_unregister(pcc->backlight);