]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mfd: adp5520: Convert to managed resources for allocating memory
authorLee Jones <lee.jones@linaro.org>
Thu, 23 May 2013 15:25:08 +0000 (16:25 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 13 Jun 2013 10:11:41 +0000 (12:11 +0200)
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/adp5520.c

index 0d2eba0234391d9e70967211d7afee328931a1cb..28346ad0b4a6da0eee7e5e6f09e025769d11b024 100644 (file)
@@ -223,7 +223,7 @@ static int adp5520_probe(struct i2c_client *client,
                return -ENODEV;
        }
 
-       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+       chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
        if (!chip)
                return -ENOMEM;
 
@@ -244,7 +244,7 @@ static int adp5520_probe(struct i2c_client *client,
                if (ret) {
                        dev_err(&client->dev, "failed to request irq %d\n",
                                        chip->irq);
-                       goto out_free_chip;
+                       return ret;
                }
        }
 
@@ -302,9 +302,6 @@ out_free_irq:
        if (chip->irq)
                free_irq(chip->irq, chip);
 
-out_free_chip:
-       kfree(chip);
-
        return ret;
 }
 
@@ -317,7 +314,6 @@ static int adp5520_remove(struct i2c_client *client)
 
        adp5520_remove_subdevs(chip);
        adp5520_write(chip->dev, ADP5520_MODE_STATUS, 0);
-       kfree(chip);
        return 0;
 }