[PATCH v2] mfd/regulator: tps65217: Move regulator plat data handling to regulator

2012-08-13 Thread AnilKumar Ch
Regulator platform data handling was mistakenly added to MFD
driver. So we will see build errors if we compile MFD drivers
without CONFIG_REGULATOR. This patch moves regulator platform
data handling from TPS65217 MFD driver to regulator driver.

This makes MFD driver independent of REGULATOR framework so
build error is fixed if CONFIG_REGULATOR is not set.

drivers/built-in.o: In function `tps65217_probe':
tps65217.c:(.devinit.text+0x13e37): undefined reference
to `of_regulator_match'

This patch also fix allocation size of tps65217 platform data.
Current implementation allocates a struct tps65217_board for each
regulator specified in the device tree. But the structure itself
provides array of regulators so one instance of it is sufficient.

Signed-off-by: AnilKumar Ch 
---
This patch is tested on BeagleBone with regulator device node
additions. And this is based on mfd/master.

Changes from v1:
- Incorporated Matthias Kaehlcke's commets on v1
  * Fixed allocation size of tps65217 platform data

 drivers/mfd/tps65217.c |  130 +++-
 drivers/regulator/tps65217-regulator.c |  124 ++
 include/linux/mfd/tps65217.h   |   12 ++-
 3 files changed, 161 insertions(+), 105 deletions(-)

diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index 61c097a..3bc2744 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -24,11 +24,18 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 
 #include 
 #include 
 
+static struct mfd_cell tps65217s[] = {
+   {
+   .name = "tps65217-pmic",
+   },
+};
+
 /**
  * tps65217_reg_read: Read a single tps65217 register.
  *
@@ -133,83 +140,48 @@ int tps65217_clear_bits(struct tps65217 *tps, unsigned 
int reg,
 }
 EXPORT_SYMBOL_GPL(tps65217_clear_bits);
 
-#ifdef CONFIG_OF
-static struct of_regulator_match reg_matches[] = {
-   { .name = "dcdc1", .driver_data = (void *)TPS65217_DCDC_1 },
-   { .name = "dcdc2", .driver_data = (void *)TPS65217_DCDC_2 },
-   { .name = "dcdc3", .driver_data = (void *)TPS65217_DCDC_3 },
-   { .name = "ldo1", .driver_data = (void *)TPS65217_LDO_1 },
-   { .name = "ldo2", .driver_data = (void *)TPS65217_LDO_2 },
-   { .name = "ldo3", .driver_data = (void *)TPS65217_LDO_3 },
-   { .name = "ldo4", .driver_data = (void *)TPS65217_LDO_4 },
-};
-
-static struct tps65217_board *tps65217_parse_dt(struct i2c_client *client)
-{
-   struct device_node *node = client->dev.of_node;
-   struct tps65217_board *pdata;
-   struct device_node *regs;
-   int count = ARRAY_SIZE(reg_matches);
-   int ret, i;
-
-   regs = of_find_node_by_name(node, "regulators");
-   if (!regs)
-   return NULL;
-
-   ret = of_regulator_match(&client->dev, regs, reg_matches, count);
-   of_node_put(regs);
-   if ((ret < 0) || (ret > count))
-   return NULL;
-
-   count = ret;
-   pdata = devm_kzalloc(&client->dev, count * sizeof(*pdata), GFP_KERNEL);
-   if (!pdata)
-   return NULL;
-
-   for (i = 0; i < count; i++) {
-   if (!reg_matches[i].init_data || !reg_matches[i].of_node)
-   continue;
-
-   pdata->tps65217_init_data[i] = reg_matches[i].init_data;
-   pdata->of_node[i] = reg_matches[i].of_node;
-   }
-
-   return pdata;
-}
-
-static struct of_device_id tps65217_of_match[] = {
-   { .compatible = "ti,tps65217", },
-   { },
-};
-#else
-static struct tps65217_board *tps65217_parse_dt(struct i2c_client *client)
-{
-   return NULL;
-}
-#endif
-
 static struct regmap_config tps65217_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
 };
 
+static const struct of_device_id tps65217_of_match[] = {
+   { .compatible = "ti,tps65217", .data = (void *)TPS65217 },
+   { /* sentinel */ },
+};
+
 static int __devinit tps65217_probe(struct i2c_client *client,
const struct i2c_device_id *ids)
 {
struct tps65217 *tps;
-   struct regulator_init_data *reg_data;
-   struct tps65217_board *pdata = client->dev.platform_data;
-   int i, ret;
unsigned int version;
+   unsigned int chip_id = ids->driver_data;
+   const struct of_device_id *match;
+   int ret;
 
-   if (!pdata && client->dev.of_node)
-   pdata = tps65217_parse_dt(client);
+   if (client->dev.of_node) {
+   match = of_match_device(tps65217_of_match, &client->dev);
+   if (!match) {
+   dev_err(&client->dev,
+   "Failed to find matching dt id\n");
+   return -EINVAL;
+   }
+   chip_id = (unsigned int)match->data;
+   }
+
+   if (!chip_id) {
+   dev_err(&client->dev, "id is null.\n");
+   return -ENODEV;
+   }
 
tps = devm_kzalloc(&client->dev

Re: [PATCH v2] mfd/regulator: tps65217: Move regulator plat data handling to regulator

2012-08-13 Thread Greg KH
On Mon, Aug 13, 2012 at 08:36:05PM +0530, AnilKumar Ch wrote:
> Regulator platform data handling was mistakenly added to MFD
> driver. So we will see build errors if we compile MFD drivers
> without CONFIG_REGULATOR. This patch moves regulator platform
> data handling from TPS65217 MFD driver to regulator driver.
> 
> This makes MFD driver independent of REGULATOR framework so
> build error is fixed if CONFIG_REGULATOR is not set.
> 
> drivers/built-in.o: In function `tps65217_probe':
> tps65217.c:(.devinit.text+0x13e37): undefined reference
> to `of_regulator_match'
> 
> This patch also fix allocation size of tps65217 platform data.
> Current implementation allocates a struct tps65217_board for each
> regulator specified in the device tree. But the structure itself
> provides array of regulators so one instance of it is sufficient.
> 
> Signed-off-by: AnilKumar Ch 
> ---
> This patch is tested on BeagleBone with regulator device node
> additions. And this is based on mfd/master.



This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read Documentation/stable_kernel_rules.txt
for how to do this properly.


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v2] mfd/regulator: tps65217: Move regulator plat data handling to regulator

2012-08-13 Thread AnilKumar, Chimata
Hi Greg,

On Mon, Aug 13, 2012 at 20:53:54, Greg KH wrote:
> On Mon, Aug 13, 2012 at 08:36:05PM +0530, AnilKumar Ch wrote:
> > Regulator platform data handling was mistakenly added to MFD
> > driver. So we will see build errors if we compile MFD drivers
> > without CONFIG_REGULATOR. This patch moves regulator platform
> > data handling from TPS65217 MFD driver to regulator driver.
> > 
> > This makes MFD driver independent of REGULATOR framework so
> > build error is fixed if CONFIG_REGULATOR is not set.
> > 
> > drivers/built-in.o: In function `tps65217_probe':
> > tps65217.c:(.devinit.text+0x13e37): undefined reference
> > to `of_regulator_match'
> > 
> > This patch also fix allocation size of tps65217 platform data.
> > Current implementation allocates a struct tps65217_board for each
> > regulator specified in the device tree. But the structure itself
> > provides array of regulators so one instance of it is sufficient.
> > 
> > Signed-off-by: AnilKumar Ch 
> > ---
> > This patch is tested on BeagleBone with regulator device node
> > additions. And this is based on mfd/master.
> 
> 
> 
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree.  Please read Documentation/stable_kernel_rules.txt
> for how to do this properly.
> 

My bad, I will take care from next time onwards.

Thanks
AnilKumar 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] mfd/regulator: tps65217: Move regulator plat data handling to regulator

2012-08-22 Thread Samuel Ortiz
Hi AnilKumar,

On Mon, Aug 13, 2012 at 08:36:05PM +0530, AnilKumar Ch wrote:
> Regulator platform data handling was mistakenly added to MFD
> driver. So we will see build errors if we compile MFD drivers
> without CONFIG_REGULATOR. This patch moves regulator platform
> data handling from TPS65217 MFD driver to regulator driver.
> 
> This makes MFD driver independent of REGULATOR framework so
> build error is fixed if CONFIG_REGULATOR is not set.
> 
> drivers/built-in.o: In function `tps65217_probe':
> tps65217.c:(.devinit.text+0x13e37): undefined reference
> to `of_regulator_match'
> 
> This patch also fix allocation size of tps65217 platform data.
> Current implementation allocates a struct tps65217_board for each
> regulator specified in the device tree. But the structure itself
> provides array of regulators so one instance of it is sufficient.
> 
> Signed-off-by: AnilKumar Ch 
> ---
> This patch is tested on BeagleBone with regulator device node
> additions. And this is based on mfd/master.
> 
> Changes from v1:
>   - Incorporated Matthias Kaehlcke's commets on v1
> * Fixed allocation size of tps65217 platform data
> 
>  drivers/mfd/tps65217.c |  130 
> +++-
>  drivers/regulator/tps65217-regulator.c |  124 ++
>  include/linux/mfd/tps65217.h   |   12 ++-
>  3 files changed, 161 insertions(+), 105 deletions(-)
> 
Applied to my for-next and for-linus branches, thanks.
Btw, this is too big of a patch for stable.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html