2012-11-06 07:38:09

by Qing Xu

[permalink] [raw]
Subject: [PATCH 2/7] mfd: max8925: fix mfd device register failure

From: Qing Xu <[email protected]>

we encounter rtc/power/touch driver registry failure, root cause
it is resources confilict in insert_resouce, solved by changing
mfd_add_devices 5th parameter to NULL

Signed-off-by: Qing Xu <[email protected]>
---
drivers/mfd/max8925-core.c | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index dcc218a..b1eacae 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -873,7 +873,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,

ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
ARRAY_SIZE(rtc_devs),
- &rtc_resources[0], chip->irq_base, NULL);
+ NULL, chip->irq_base, NULL);
if (ret < 0) {
dev_err(chip->dev, "Failed to add rtc subdev\n");
goto out;
@@ -881,7 +881,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,

ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
ARRAY_SIZE(onkey_devs),
- &onkey_resources[0], 0, NULL);
+ NULL, 0, NULL);
if (ret < 0) {
dev_err(chip->dev, "Failed to add onkey subdev\n");
goto out_dev;
@@ -900,21 +900,19 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
goto out_dev;
}

- if (pdata && pdata->power) {
- ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
- ARRAY_SIZE(power_devs),
- &power_supply_resources[0], 0, NULL);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to add power supply "
- "subdev\n");
- goto out_dev;
- }
+ ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
+ ARRAY_SIZE(power_devs),
+ NULL, 0, NULL);
+ if (ret < 0) {
+ dev_err(chip->dev, "Failed to add power supply "
+ "subdev, err = %d\n", ret);
+ goto out_dev;
}

if (pdata && pdata->touch) {
ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
ARRAY_SIZE(touch_devs),
- &touch_resources[0], 0, NULL);
+ NULL, chip->tsc_irq_base, NULL);
if (ret < 0) {
dev_err(chip->dev, "Failed to add touch subdev\n");
goto out_dev;
--
1.7.0.4


2012-11-23 07:13:05

by Qing Xu

[permalink] [raw]
Subject: Re: [PATCH 2/7] mfd: max8925: fix mfd device register failure

On 11/06/2012 03:38 PM, Qing Xu wrote:
> From: Qing Xu <[email protected]>
>
> we encounter rtc/power/touch driver registry failure, root cause
> it is resources confilict in insert_resouce, solved by changing
> mfd_add_devices 5th parameter to NULL
>
> Signed-off-by: Qing Xu <[email protected]>
> ---
> drivers/mfd/max8925-core.c | 22 ++++++++++------------
> 1 files changed, 10 insertions(+), 12 deletions(-)
Hi Haojian, Sameo,

Could you help to review my patches? Can it be merged?

Thanks a lot!
-Qing

2012-11-23 08:41:58

by Haojian Zhuang

[permalink] [raw]
Subject: Re: [PATCH 2/7] mfd: max8925: fix mfd device register failure

On Tue, Nov 6, 2012 at 3:38 PM, Qing Xu <[email protected]> wrote:
> From: Qing Xu <[email protected]>
>
> we encounter rtc/power/touch driver registry failure, root cause
> it is resources confilict in insert_resouce, solved by changing
> mfd_add_devices 5th parameter to NULL
>
Since resources are not used in power/rtc driver and touch driver
isn't implemented,
it's OK to avoid use resources. Please remove those resources in
max8925-core.c also.


> Signed-off-by: Qing Xu <[email protected]>
> ---
> drivers/mfd/max8925-core.c | 22 ++++++++++------------
> 1 files changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
> index dcc218a..b1eacae 100644
> --- a/drivers/mfd/max8925-core.c
> +++ b/drivers/mfd/max8925-core.c
> @@ -873,7 +873,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
>
> ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
> ARRAY_SIZE(rtc_devs),
> - &rtc_resources[0], chip->irq_base, NULL);
> + NULL, chip->irq_base, NULL);
> if (ret < 0) {
> dev_err(chip->dev, "Failed to add rtc subdev\n");
> goto out;
> @@ -881,7 +881,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
>
> ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
> ARRAY_SIZE(onkey_devs),
> - &onkey_resources[0], 0, NULL);
> + NULL, 0, NULL);
> if (ret < 0) {
> dev_err(chip->dev, "Failed to add onkey subdev\n");
> goto out_dev;
> @@ -900,21 +900,19 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
> goto out_dev;
> }
>
> - if (pdata && pdata->power) {
> - ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
> - ARRAY_SIZE(power_devs),
> - &power_supply_resources[0], 0, NULL);
> - if (ret < 0) {
> - dev_err(chip->dev, "Failed to add power supply "
> - "subdev\n");
> - goto out_dev;
> - }
> + ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
> + ARRAY_SIZE(power_devs),
> + NULL, 0, NULL);
> + if (ret < 0) {
> + dev_err(chip->dev, "Failed to add power supply "
> + "subdev, err = %d\n", ret);
> + goto out_dev;
> }
>
> if (pdata && pdata->touch) {
> ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
> ARRAY_SIZE(touch_devs),
> - &touch_resources[0], 0, NULL);
> + NULL, chip->tsc_irq_base, NULL);
> if (ret < 0) {
> dev_err(chip->dev, "Failed to add touch subdev\n");
> goto out_dev;
> --
> 1.7.0.4
>

2012-11-27 10:06:37

by Qing Xu

[permalink] [raw]
Subject: Re: [PATCH 2/7] mfd: max8925: fix mfd device register failure

On 11/23/2012 04:41 PM, Haojian Zhuang wrote:
> On Tue, Nov 6, 2012 at 3:38 PM, Qing Xu <[email protected]> wrote:
>> From: Qing Xu <[email protected]>
>>
>> we encounter rtc/power/touch driver registry failure, root cause
>> it is resources confilict in insert_resouce, solved by changing
>> mfd_add_devices 5th parameter to NULL
>>
> Since resources are not used in power/rtc driver and touch driver
> isn't implemented,
> it's OK to avoid use resources. Please remove those resources in
> max8925-core.c also.
>

oh, we can not remove those resources, it is include in mfd_cell,
such as :
static struct resource rtc_resources[] = {
{
...

},
};

static struct mfd_cell rtc_devs[] = {
{
.name = "max8925-rtc",
...
.resources = &rtc_resources[0],
...

},
};

In the struct, the resources is for rtc dev itself's resource, but in:

ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
ARRAY_SIZE(rtc_devs),
&rtc_resources[0], chip->irq_base, NULL);

the 5th parameter, it is for rtc's child, not rtc itself, we should
remove it to NULL, otherwise, device register will find conflict
on child's and parent's resource.

>> Signed-off-by: Qing Xu <[email protected]>
>> ---
>> drivers/mfd/max8925-core.c | 22 ++++++++++------------
>> 1 files changed, 10 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
>> index dcc218a..b1eacae 100644
>> --- a/drivers/mfd/max8925-core.c
>> +++ b/drivers/mfd/max8925-core.c
>> @@ -873,7 +873,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
>>
>> ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
>> ARRAY_SIZE(rtc_devs),
>> - &rtc_resources[0], chip->irq_base, NULL);
>> + NULL, chip->irq_base, NULL);
>> if (ret < 0) {
>> dev_err(chip->dev, "Failed to add rtc subdev\n");
>> goto out;
>> @@ -881,7 +881,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
>>
>> ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
>> ARRAY_SIZE(onkey_devs),
>> - &onkey_resources[0], 0, NULL);
>> + NULL, 0, NULL);
>> if (ret < 0) {
>> dev_err(chip->dev, "Failed to add onkey subdev\n");
>> goto out_dev;
>> @@ -900,21 +900,19 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
>> goto out_dev;
>> }
>>
>> - if (pdata && pdata->power) {
>> - ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
>> - ARRAY_SIZE(power_devs),
>> - &power_supply_resources[0], 0, NULL);
>> - if (ret < 0) {
>> - dev_err(chip->dev, "Failed to add power supply "
>> - "subdev\n");
>> - goto out_dev;
>> - }
>> + ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
>> + ARRAY_SIZE(power_devs),
>> + NULL, 0, NULL);
>> + if (ret < 0) {
>> + dev_err(chip->dev, "Failed to add power supply "
>> + "subdev, err = %d\n", ret);
>> + goto out_dev;
>> }
>>
>> if (pdata && pdata->touch) {
>> ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
>> ARRAY_SIZE(touch_devs),
>> - &touch_resources[0], 0, NULL);
>> + NULL, chip->tsc_irq_base, NULL);
>> if (ret < 0) {
>> dev_err(chip->dev, "Failed to add touch subdev\n");
>> goto out_dev;
>> --
>> 1.7.0.4
>>