]> Pileus Git - ~andy/linux/blobdiff - drivers/mfd/palmas.c
Merge branch 'opw-next' into staging-next
[~andy/linux] / drivers / mfd / palmas.c
index 135afabe4ae2ae850a6897ddad06dc1969dba301..d280d789e55a5cc0a60896eee95ad8de3ee1dac8 100644 (file)
@@ -368,6 +368,7 @@ static const struct of_device_id of_palmas_match_tbl[] = {
        },
        { },
 };
+MODULE_DEVICE_TABLE(of, of_palmas_match_tbl);
 
 static int palmas_i2c_probe(struct i2c_client *i2c,
                            const struct i2c_device_id *id)
@@ -402,7 +403,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
        palmas->dev = &i2c->dev;
        palmas->irq = i2c->irq;
 
-       match = of_match_device(of_match_ptr(of_palmas_match_tbl), &i2c->dev);
+       match = of_match_device(of_palmas_match_tbl, &i2c->dev);
 
        if (!match)
                return -ENODATA;
@@ -421,7 +422,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
                                dev_err(palmas->dev,
                                        "can't attach client %d\n", i);
                                ret = -ENOMEM;
-                               goto err;
+                               goto err_i2c;
                        }
                        palmas->i2c_clients[i]->dev.of_node = of_node_get(node);
                }
@@ -432,7 +433,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
                        dev_err(palmas->dev,
                                "Failed to allocate regmap %d, err: %d\n",
                                i, ret);
-                       goto err;
+                       goto err_i2c;
                }
        }
 
@@ -451,7 +452,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
                        reg);
        if (ret < 0) {
                dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret);
-               goto err;
+               goto err_i2c;
        }
 
        /* Change IRQ into clear on read mode for efficiency */
@@ -465,7 +466,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
                        IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip,
                        &palmas->irq_data);
        if (ret < 0)
-               goto err;
+               goto err_i2c;
 
 no_irq:
        slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
@@ -551,7 +552,6 @@ no_irq:
                } else if (pdata->pm_off && !pm_power_off) {
                        palmas_dev = palmas;
                        pm_power_off = palmas_power_off;
-                       return ret;
                }
        }
 
@@ -559,17 +559,31 @@ no_irq:
 
 err_irq:
        regmap_del_irq_chip(palmas->irq, palmas->irq_data);
-err:
+err_i2c:
+       for (i = 1; i < PALMAS_NUM_CLIENTS; i++) {
+               if (palmas->i2c_clients[i])
+                       i2c_unregister_device(palmas->i2c_clients[i]);
+       }
        return ret;
 }
 
 static int palmas_i2c_remove(struct i2c_client *i2c)
 {
        struct palmas *palmas = i2c_get_clientdata(i2c);
+       int i;
 
-       mfd_remove_devices(palmas->dev);
        regmap_del_irq_chip(palmas->irq, palmas->irq_data);
 
+       for (i = 1; i < PALMAS_NUM_CLIENTS; i++) {
+               if (palmas->i2c_clients[i])
+                       i2c_unregister_device(palmas->i2c_clients[i]);
+       }
+
+       if (palmas == palmas_dev) {
+               pm_power_off = NULL;
+               palmas_dev = NULL;
+       }
+
        return 0;
 }