Skip to content

Commit

Permalink
asus-laptop: Remove redundant NULL checks
Browse files Browse the repository at this point in the history
The acpi device callbacks add, start, remove, suspend and resume can
never be called with a NULL acpi_device. Each callsite in acpi/scan.c
has to dereference the device in order to get the ops structure, e.g.

    struct acpi_device *acpi_dev = to_acpi_device(dev);
    struct acpi_driver *acpi_drv = acpi_dev->driver;

    if (acpi_drv && acpi_drv->ops.suspend)
        return acpi_drv->ops.suspend(acpi_dev, state);

Remove all checks for acpi_dev == NULL within these callbacks.

Also remove the checks for acpi_driver_data(acpi_dev) == NULL. None of
these checks could fail unless the driver does something strange
(which none of them do), the acpi core did something terribly wrong,
or we have a memory corruption issue. If this does happen then it's
best to dereference the pointer and crash noisily.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Alan Jenkins authored and Len Brown committed Dec 9, 2009
1 parent 6dff29b commit 1df8d8d
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions drivers/platform/x86/asus-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -1306,9 +1303,6 @@ static int asus_hotk_add(struct acpi_device *device)

static int asus_hotk_remove(struct acpi_device *device, int type)
{
if (!device || !acpi_driver_data(device))
return -EINVAL;

kfree(hotk->name);
kfree(hotk);

Expand Down

0 comments on commit 1df8d8d

Please sign in to comment.