Skip to content

Commit bc4c975

Browse files
mwilczyrafaeljw
authored andcommitted
ACPI: AC: Remove redundant checks
Remove unnecessary checks against NULL for pointers that can't be NULL when the checks are done. Signed-off-by: Michal Wilczynski <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 470508f commit bc4c975

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

drivers/acpi/ac.c

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
131131
struct acpi_device *device = data;
132132
struct acpi_ac *ac = acpi_driver_data(device);
133133

134-
if (!ac)
135-
return;
136-
137134
switch (event) {
138135
default:
139136
acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",
@@ -216,12 +213,8 @@ static const struct dmi_system_id ac_dmi_table[] __initconst = {
216213
static int acpi_ac_add(struct acpi_device *device)
217214
{
218215
struct power_supply_config psy_cfg = {};
219-
int result = 0;
220-
struct acpi_ac *ac = NULL;
221-
222-
223-
if (!device)
224-
return -EINVAL;
216+
struct acpi_ac *ac;
217+
int result;
225218

226219
ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL);
227220
if (!ac)
@@ -275,16 +268,9 @@ static int acpi_ac_add(struct acpi_device *device)
275268
#ifdef CONFIG_PM_SLEEP
276269
static int acpi_ac_resume(struct device *dev)
277270
{
278-
struct acpi_ac *ac;
271+
struct acpi_ac *ac = acpi_driver_data(to_acpi_device(dev));
279272
unsigned int old_state;
280273

281-
if (!dev)
282-
return -EINVAL;
283-
284-
ac = acpi_driver_data(to_acpi_device(dev));
285-
if (!ac)
286-
return -EINVAL;
287-
288274
old_state = ac->state;
289275
if (acpi_ac_get_state(ac))
290276
return 0;
@@ -299,12 +285,7 @@ static int acpi_ac_resume(struct device *dev)
299285

300286
static void acpi_ac_remove(struct acpi_device *device)
301287
{
302-
struct acpi_ac *ac = NULL;
303-
304-
if (!device || !acpi_driver_data(device))
305-
return;
306-
307-
ac = acpi_driver_data(device);
288+
struct acpi_ac *ac = acpi_driver_data(device);
308289

309290
acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
310291
acpi_ac_notify);

0 commit comments

Comments
 (0)