From: Chao Xie <xiechao.mail@gmail.com>
To: Eric Miao <eric.y.miao@gmail.com>
Cc: Chao Xie <chao.xie@marvell.com>,
Thierry Reding <thierry.reding@avionic-design.de>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V4 3/3] pwm: pxa: add device tree support
Date: Tue, 21 May 2013 13:21:29 +0800 [thread overview]
Message-ID: <CADApbegt4qprfioKj9aHiX0s7wOGvbtTLtBKzeecxoR+aBo++w@mail.gmail.com> (raw)
In-Reply-To: <CAMPhdO8apwiG22puibsyGLdnmomFHyQcBEp9OO0_iqYwZycdQA@mail.gmail.com>
hi, Thierry
Eric has acked all the patches. So can you help to merge them?
Thanks.
On Mon, May 13, 2013 at 2:20 PM, Eric Miao <eric.y.miao@gmail.com> wrote:
> On Mon, May 13, 2013 at 1:04 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
>>>> + const struct of_device_id *of_id =
>>>> + of_match_device(pxa_pwm_of_match, &pdev->dev);
>>>> + unsigned int npwm;
>>>> +
>>>> + if (!of_id)
>>>> + return -ENODEV;
>>>> +
>>>> + npwm = (unsigned int)of_id->data;
>>>> + pwm->chip.npwm = (npwm & HAS_SECONDARY_PWM) ? 2 : 1;
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> static int pwm_probe(struct platform_device *pdev)
>>>> {
>>>> const struct platform_device_id *id = platform_get_device_id(pdev);
>>>> @@ -144,7 +180,6 @@ static int pwm_probe(struct platform_device *pdev)
>>>> pwm->chip.dev = &pdev->dev;
>>>> pwm->chip.ops = &pxa_pwm_ops;
>>>> pwm->chip.base = -1;
>>>> - pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
>>>>
>>>> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> if (r == NULL) {
>>>> @@ -156,6 +191,20 @@ static int pwm_probe(struct platform_device *pdev)
>>>> if (IS_ERR(pwm->mmio_base))
>>>> return PTR_ERR(pwm->mmio_base);
>>>>
>>>> + if (!id) {
>>>> + if (IS_ENABLED(CONFIG_OF))
>>>> + ret = pxa_pwm_parse_data_dt(pdev, pwm);
>>>> + else
>>>> + ret = -ENODEV;
>>>> + } else {
>>>> + pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
>>>> + }
>>>
>>> ^^ braces not necessarily here, and I'm not really sure if we should check
>>> CONFIG_OF firstly, and leave the platform_device_id thing as a legacy
>>> fall back, what do you think?
>>>
>>> if (IS_ENABLED(CONFIG_OF)) {
>>> ...
>>> } else {
>>> const struct platform_device_id *id = platform_get_device_id(...);
>>> ...
>>> }
>>>
>> it has some reasons.
>> You ways works for
>> 1. PWM defined in DT configuration file and CONFIG_OF is defined
>> 2. CONFIG_OF is not defined.
>> If COFNIG_OF is defined, but PWM is not defined in device tree
>> configuration file. The device
>> can still match the driver is the id_table is matched or name is matched.
>> So I covered addtional situation
>> 1. PWM is not defined in DT configuration file but CONFIG_OF is defined.
>>
>> So i keep the possiblility that event CONFIG_OF is defined, but PWM is
>> not defined in DT file, and we still can use old way to probe the
>> device.
>>
>
> Yeah I was thinking maybe we should not keep the legacy working if
> CONFIG_OF is defined, but that should be OK:
>
> Acked-by: Eric Miao <eric.y.miao@gmail.com>
>
>>>> +
>>>> + if (ret) {
>>>> + dev_err(&pdev->dev, "failed to parse data from device id\n");
>>>> + return ret;
>>>> + }
>>>> +
>>>> ret = pwmchip_add(&pwm->chip);
>>>> if (ret < 0) {
>>>> dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
>>>> @@ -181,6 +230,7 @@ static struct platform_driver pwm_driver = {
>>>> .driver = {
>>>> .name = "pxa25x-pwm",
>>>> .owner = THIS_MODULE,
>>>> + .of_match_table = pxa_pwm_of_match,
>>>> },
>>>> .probe = pwm_probe,
>>>> .remove = pwm_remove,
>>>> --
>>>> 1.7.4.1
>>>>
next prev parent reply other threads:[~2013-05-21 5:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 1:29 [PATCH V4 0/3] pwm: pxa: bug fix and " Chao Xie
2013-05-06 1:29 ` [PATCH V4 1/3] pwm: pxa: ARCH_MMP share same pwm driver with ARCH_PXA Chao Xie
2013-05-13 2:07 ` Eric Miao
2013-05-06 1:30 ` [PATCH V4 2/3] pwm: pxa: use module_platform_driver() Chao Xie
2013-05-13 2:08 ` Eric Miao
2013-05-06 1:30 ` [PATCH V4 3/3] pwm: pxa: add device tree support Chao Xie
2013-05-13 2:27 ` Eric Miao
2013-05-13 5:04 ` Chao Xie
2013-05-13 6:20 ` Eric Miao
2013-05-21 5:21 ` Chao Xie [this message]
2013-05-23 19:10 ` Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADApbegt4qprfioKj9aHiX0s7wOGvbtTLtBKzeecxoR+aBo++w@mail.gmail.com \
--to=xiechao.mail@gmail.com \
--cc=chao.xie@marvell.com \
--cc=eric.y.miao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=thierry.reding@avionic-design.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®