mfd: tps65910: dt: cleanups in device node parsing
Subsystems (3)
cover mfd: tps65910: dt: cleanups in device node parsing
In this patch series organizing the processing of device node locally specific to driver.
- The gpio specific processing is moved to gpio driver.
- Core will only process the non-subdevices information.
- Also keep the allocated pointer for device node in to global structure so that sub devices can use this.
This patch series is generated on-top of Samuel's mfd subsystem tree.
Laxman Dewangan (3):
mfd: save device node parsed platform data for sub devices
mfd: remove the parsing of dt info for gpio
gpio: tps65910: dt: process gpio specific device node info
drivers/gpio/gpio-tps65910.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/mfd/tps65910.c | 21 +++++---------------- include/linux/mfd/tps65910.h | 3 +++ 3 files changed, 44 insertions(+), 16 deletions(-)
PATCH 1/3 mfd: save device node parsed platform data for sub devices
Save the allocated memory to store the parsed device node information to the global device structure so that sub devices can directly use this pointer.
In this way, the sub devices does not require to re-allocate the memory for storing the sub-devices specific device node information.
--- drivers/mfd/tps65910.c | 6 +++++- include/linux/mfd/tps65910.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletions(-)
drivers/mfd/tps65910.c +5 -1
@@ -209,14 +209,17 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c, {struct tps65910 *tps65910;struct tps65910_board *pmic_plat_data; +struct tps65910_board *of_pmic_plat_data =NULL ;struct tps65910_platform_data *init_data;int ret =0 ;int chip_id = id->driver_data; pmic_plat_data =dev_get_platdata (&i2c->dev); -if (!pmic_plat_data && i2c->dev.of_node) +if (!pmic_plat_data && i2c->dev.of_node) { pmic_plat_data =tps65910_parse_dt (i2c, &chip_id); + of_pmic_plat_data = pmic_plat_data; + }if (!pmic_plat_data)return -EINVAL ;
@@ -229,6 +232,7 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,if (tps65910 ==NULL )return -ENOMEM ; + tps65910->of_plat_data = of_pmic_plat_data;i2c_set_clientdata (i2c, tps65910); tps65910->dev = &i2c->dev; tps65910->i2c_client = i2c;
include/linux/mfd/tps65910.h +3 -0
@@ -830,6 +830,9 @@ struct tps65910 {struct tps65910_rtc *rtc;struct tps65910_power *power; +/* Device node parsed board data */ +struct tps65910_board *of_plat_data; +/* IRQ Handling */ struct mutex irq_lock;int chip_irq;
Signature · 1 line
1.7.1.1
PATCH 2/3 mfd: remove the parsing of dt info for gpio
In reply to Laxman DewanganRemove the parsing of device node information for sub devices from core file.
The sub devices will parse the information as per the sub-devices specific information.
--- drivers/mfd/tps65910.c | 15 --------------- 1 files changed, 0 insertions(+), 15 deletions(-)
drivers/mfd/tps65910.c +0 -15
@@ -146,9 +146,7 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,struct tps65910_board *board_info;unsigned int prop;const struct of_device_id *match; -unsigned int prop_array[TPS6591X_MAX_NUM_GPIO ];int ret =0 ; -int idx; match =of_match_device (tps65910_of_match, &client->dev);if (!match) {
@@ -177,21 +175,8 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,else if (*chip_id ==TPS65911 )dev_warn (&client->dev,"VMBCH2-Threshold not specified" ); - ret =of_property_read_u32_array (np,"ti,en-gpio-sleep" , - prop_array,TPS6591X_MAX_NUM_GPIO ); -if (!ret) -for (idx =0 ; idx <ARRAY_SIZE (prop_array); idx++) - board_info->en_gpio_sleep[idx] = (prop_array[idx] !=0 ); -else if (ret != -EINVAL ) { -dev_err (&client->dev, -"error reading property ti,en-gpio-sleep: %d\n." , ret); -return NULL ; - } - - board_info->irq = client->irq; board_info->irq_base =-1 ; - board_info->gpio_base =-1 ;return board_info; }
Signature · 1 line
1.7.1.1
PATCH 3/3 gpio: tps65910: dt: process gpio specific device node info
In reply to Laxman DewanganParse the gpio specific device node information locally.
--- drivers/gpio/gpio-tps65910.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-)
drivers/gpio/gpio-tps65910.c +36 -0
@@ -20,6 +20,7 @@#include <linux/i2c.h> #include <linux/platform_device.h> #include <linux/mfd/tps65910.h> +#include <linux/of_device.h> struct tps65910_gpio {struct gpio_chip gpio_chip;
@@ -81,6 +82,37 @@ static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset) GPIO_CFG_MASK); } +#ifdef CONFIG_OF +static struct tps65910_board *tps65910_parse_dt_for_gpio (struct device *dev, +struct tps65910 *tps65910,int chip_ngpio) +{ +struct tps65910_board *tps65910_board = tps65910->of_plat_data; +unsigned int prop_array[TPS6591X_MAX_NUM_GPIO ]; +int ngpio =min (chip_ngpio,TPS6591X_MAX_NUM_GPIO ); +int ret; +int idx; + + tps65910_board->gpio_base =-1 ; + ret =of_property_read_u32_array (tps65910->dev->of_node, +"ti,en-gpio-sleep" , prop_array, ngpio); +if (ret <0 ) { +dev_dbg (dev,"ti,en-gpio-sleep not specified\n" ); +return tps65910_board; + } + +for (idx =0 ; idx < ngpio; idx++) + tps65910_board->en_gpio_sleep[idx] = (prop_array[idx] !=0 ); + +return tps65910_board; +} +#else +static struct tps65910_board *tps65910_parse_dt_for_gpio (struct device *dev, +struct tps65910 *tps65910,int chip_ngpio) +{ +return NULL ; +} +#endif +static int __devinit tps65910_gpio_probe (struct platform_device *pdev) {struct tps65910 *tps65910 =dev_get_drvdata (pdev->dev.parent);
@@ -122,6 +154,10 @@ static int __devinit tps65910_gpio_probe(struct platform_device *pdev)else tps65910_gpio->gpio_chip.base =-1 ; +if (!pdata && tps65910->dev->of_node) + pdata =tps65910_parse_dt_for_gpio (&pdev->dev, tps65910, + tps65910_gpio->gpio_chip.ngpio); +if (!pdata) goto skip_init;
Signature · 1 line
1.7.1.1
Re: [PATCH 3/3] gpio: tps65910: dt: process gpio specific device node info
Quoted 3 lines · Laxman Dewangan
Parse the gpio specific device node information locally.
Signed-off-by Laxman Dewangan <[email protected]>
I expect this needs to go in via Samuel's tree with the mfd patches?
g.
Quoted 68 lines
--- drivers/gpio/gpio-tps65910.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-)drivers/gpio/gpio-tps65910.c +36
-0@@ -20,6 +20,7 @@#include <linux/i2c.h> #include <linux/platform_device.h> #include <linux/mfd/tps65910.h> +#include <linux/of_device.h> struct tps65910_gpio {struct gpio_chip gpio_chip;@@ -81,6 +82,37 @@ static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset) GPIO_CFG_MASK); } +#ifdef CONFIG_OF +static struct tps65910_board *tps65910_parse_dt_for_gpio (struct device *dev, +struct tps65910 *tps65910,int chip_ngpio) +{ +struct tps65910_board *tps65910_board = tps65910->of_plat_data; +unsigned int prop_array[TPS6591X_MAX_NUM_GPIO ]; +int ngpio =min (chip_ngpio,TPS6591X_MAX_NUM_GPIO ); +int ret; +int idx; + + tps65910_board->gpio_base =-1 ; + ret =of_property_read_u32_array (tps65910->dev->of_node, +"ti,en-gpio-sleep" , prop_array, ngpio); +if (ret <0 ) { +dev_dbg (dev,"ti,en-gpio-sleep not specified\n" ); +return tps65910_board; + } + +for (idx =0 ; idx < ngpio; idx++) + tps65910_board->en_gpio_sleep[idx] = (prop_array[idx] !=0 ); + +return tps65910_board; +} +#else +static struct tps65910_board *tps65910_parse_dt_for_gpio (struct device *dev, +struct tps65910 *tps65910,int chip_ngpio) +{ +return NULL ; +} +#endif +static int __devinit tps65910_gpio_probe (struct platform_device *pdev) {struct tps65910 *tps65910 =dev_get_drvdata (pdev->dev.parent);@@ -122,6 +154,10 @@ static int __devinit tps65910_gpio_probe(struct platform_device *pdev)else tps65910_gpio->gpio_chip.base =-1 ; +if (!pdata && tps65910->dev->of_node) + pdata =tps65910_parse_dt_for_gpio (&pdev->dev, tps65910, + tps65910_gpio->gpio_chip.ngpio); +if (!pdata) goto skip_init;Signature · 1 line
1.7.1.1
Signature · 2 lines
Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd.
Hi Laxman,
Quoted 8 lines · Laxman Dewangan
In this patch series organizing the processing of device node locally specific to driver.
- The gpio specific processing is moved to gpio driver.
- Core will only process the non-subdevices information.
- Also keep the allocated pointer for device node in to global structure so that sub devices can use this.This patch series is generated on-top of Samuel's mfd subsystem tree.
Thanks, all 3 patches applied.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/