Skip to content

Commit

Permalink
leds: convert LP3944 LED driver to devm_kzalloc()
Browse files Browse the repository at this point in the history
Cc: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
  • Loading branch information
Bryan Wu committed Jul 23, 2012
1 parent 4aad381 commit 9813d74
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/leds/leds-lp3944.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ static int __devinit lp3944_probe(struct i2c_client *client,
return -ENODEV;
}

data = kzalloc(sizeof(struct lp3944_data), GFP_KERNEL);
data = devm_kzalloc(&client->dev, sizeof(struct lp3944_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;

Expand All @@ -403,10 +404,8 @@ static int __devinit lp3944_probe(struct i2c_client *client,
mutex_init(&data->lock);

err = lp3944_configure(client, data, lp3944_pdata);
if (err < 0) {
kfree(data);
if (err < 0)
return err;
}

dev_info(&client->dev, "lp3944 enabled\n");
return 0;
Expand All @@ -431,8 +430,6 @@ static int __devexit lp3944_remove(struct i2c_client *client)
break;
}

kfree(data);

return 0;
}

Expand Down

0 comments on commit 9813d74

Please sign in to comment.