lkml.org 
[lkml]   [2012]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 1/3] max17042_battery: Use devm_kzalloc() where applicable
    This allows us to simplify probe and exit function.

    Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
    Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
    ---
    drivers/power/max17042_battery.c | 4 +---
    1 files changed, 1 insertions(+), 3 deletions(-)

    diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
    index 86acee2..21a3650 100644
    --- a/drivers/power/max17042_battery.c
    +++ b/drivers/power/max17042_battery.c
    @@ -220,7 +220,7 @@ static int __devinit max17042_probe(struct i2c_client *client,
    if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
    return -EIO;

    - chip = kzalloc(sizeof(*chip), GFP_KERNEL);
    + chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
    if (!chip)
    return -ENOMEM;

    @@ -246,7 +246,6 @@ static int __devinit max17042_probe(struct i2c_client *client,
    ret = power_supply_register(&client->dev, &chip->battery);
    if (ret) {
    dev_err(&client->dev, "failed: power supply register\n");
    - kfree(chip);
    return ret;
    }

    @@ -269,7 +268,6 @@ static int __devexit max17042_remove(struct i2c_client *client)
    struct max17042_chip *chip = i2c_get_clientdata(client);

    power_supply_unregister(&chip->battery);
    - kfree(chip);
    return 0;
    }

    --
    1.7.8.3


    \
     
     \ /
      Last update: 2012-02-22 19:09    [W:0.020 / U:0.112 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site