mfd: tps80031: add subdevs through mfd_add_devices()
Laxman Dewangan [Thu, 26 Jul 2012 11:06:17 +0000 (16:06 +0530)]
Add provision to register sub devices through mfd sub
devices. This will help to move all sub devices as
mfd subdevices.

Change-Id: Ibc9f56a210d852749cdc3be7da92d54aad298a21
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/118957

drivers/mfd/tps80031.c

index 42e1faa..e8a00a8 100644 (file)
@@ -297,6 +297,14 @@ struct tps80031 {
        struct regmap           *regmap[TPS_NUM_SLAVES];
 };
 
+/* TPS80031 sub mfd devices */
+static struct mfd_cell tps80031_cell[] = {
+       {
+               .name = "tps80031-regulators",
+       },
+};
+
+
 int tps80031_write(struct device *dev, int sid, int reg, uint8_t val)
 {
        struct tps80031 *tps80031 = dev_get_drvdata(dev);
@@ -1226,6 +1234,8 @@ static int __devexit tps80031_i2c_remove(struct i2c_client *client)
        struct tps80031 *tps80031 = i2c_get_clientdata(client);
        int i;
 
+       mfd_remove_devices(tps80031->dev);
+
        if (client->irq)
                free_irq(client->irq, tps80031);
 
@@ -1331,6 +1341,13 @@ static int __devinit tps80031_i2c_probe(struct i2c_client *client,
 
        tps80031_init_ext_control(tps80031, pdata);
 
+       ret = mfd_add_devices(tps80031->dev, -1,
+                       tps80031_cell, ARRAY_SIZE(tps80031_cell), NULL, 0);
+       if (ret < 0) {
+               dev_err(&client->dev, "mfd_add_devices failed: %d\n", ret);
+               goto fail_mfd_add;
+       }
+
        ret = tps80031_add_subdevs(tps80031, pdata);
        if (ret) {
                dev_err(&client->dev, "add devices failed: %d\n", ret);
@@ -1353,9 +1370,11 @@ static int __devinit tps80031_i2c_probe(struct i2c_client *client,
        return 0;
 
 fail_add_subdev:
+       mfd_remove_devices(tps80031->dev);
+
+fail_mfd_add:
        if (client->irq)
                free_irq(client->irq, tps80031);
-
 fail_client_reg:
        for (i = 0; i < TPS_NUM_SLAVES; i++) {
                struct tps80031_client *tps = &tps80031->tps_clients[i];