]> Pileus Git - ~andy/linux/blobdiff - drivers/mfd/pm8921-core.c
i2c: mv64xxx: Fix some build warnings
[~andy/linux] / drivers / mfd / pm8921-core.c
index ecc137ffa8c3c6369592a5cea5ecd987f9deeed4..a6841f77aa5e709d472b120336e25e5572646cf8 100644 (file)
@@ -14,6 +14,7 @@
 #define pr_fmt(fmt) "%s: " fmt, __func__
 
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/err.h>
@@ -106,7 +107,7 @@ static int pm8921_add_subdevices(const struct pm8921_platform_data
 
 static int pm8921_probe(struct platform_device *pdev)
 {
-       const struct pm8921_platform_data *pdata = pdev->dev.platform_data;
+       const struct pm8921_platform_data *pdata = dev_get_platdata(&pdev->dev);
        struct pm8921 *pmic;
        int rc;
        u8 val;
@@ -117,7 +118,7 @@ static int pm8921_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       pmic = kzalloc(sizeof(struct pm8921), GFP_KERNEL);
+       pmic = devm_kzalloc(&pdev->dev, sizeof(struct pm8921), GFP_KERNEL);
        if (!pmic) {
                pr_err("Cannot alloc pm8921 struct\n");
                return -ENOMEM;
@@ -127,7 +128,7 @@ static int pm8921_probe(struct platform_device *pdev)
        rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val));
        if (rc) {
                pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc);
-               goto err_read_rev;
+               return rc;
        }
        pr_info("PMIC revision 1: %02X\n", val);
        rev = val;
@@ -137,7 +138,7 @@ static int pm8921_probe(struct platform_device *pdev)
        if (rc) {
                pr_err("Failed to read hw rev 2 reg %d:rc=%d\n",
                        REG_HWREV_2, rc);
-               goto err_read_rev;
+               return rc;
        }
        pr_info("PMIC revision 2: %02X\n", val);
        rev |= val << BITS_PER_BYTE;
@@ -159,9 +160,6 @@ static int pm8921_probe(struct platform_device *pdev)
 
 err:
        mfd_remove_devices(pmic->dev);
-       platform_set_drvdata(pdev, NULL);
-err_read_rev:
-       kfree(pmic);
        return rc;
 }
 
@@ -179,8 +177,6 @@ static int pm8921_remove(struct platform_device *pdev)
                pm8xxx_irq_exit(pmic->irq_chip);
                pmic->irq_chip = NULL;
        }
-       platform_set_drvdata(pdev, NULL);
-       kfree(pmic);
 
        return 0;
 }