All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dong Aisheng <dong.aisheng@linaro.org>
To: Alexander Shiyan <shc_work@mail.ru>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org,
	Samuel Ortiz <sameo@linux.intel.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: Re: Re[8]: [PATCH v3] mfd: syscon: Add non-DT support
Date: Wed, 20 Feb 2013 14:01:58 +0800	[thread overview]
Message-ID: <CAP1dx+xZ=FXtmTZ5YhJ4V6OLzFK5dwmLC2+jrfTK00QRKgCbEw@mail.gmail.com> (raw)
In-Reply-To: <1361338882.986089809@f173.mail.ru>

On 20 February 2013 13:41, Alexander Shiyan <shc_work@mail.ru> wrote:
>> > ...
>> >> >> >> >>  struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
>> >> >> >> >>  {
>> >> >> >> >>       struct device_node *syscon_np;
>> >> >> >> >>       struct regmap *regmap;
>> >> >> >> >> +     struct syscon *syscon;
>> >> >> >> >> +     struct device *dev;
>> >> >> >> >>
>> >> >> >> >>       syscon_np = of_find_compatible_node(NULL, NULL, s);
>> >> >> >> >> -     if (!syscon_np)
>> >> >> >> >> +     if (syscon_np) {
>> >> >> >> >> +             regmap = syscon_node_to_regmap(syscon_np);
>> >> >> >> >> +             of_node_put(syscon_np);
>> >> >> >> >> +
>> >> >> >> >> +             return regmap;
>> >> >> >> >> +     }
>> >> >> >> >> +
>> >> >> >> >> +     /* Fallback to search by id_entry.name string */
>> >> >> >> >> +     dev = driver_find_device(&syscon_driver.driver, NULL, (void *)s,
>> >> >> >> >> +                              syscon_match_id);
>> >> >> >> >> +     if (!dev)
>> >> >> >> >>               return ERR_PTR(-ENODEV);
>> >> >> >> >>
>> >> >> >> >> -     regmap = syscon_node_to_regmap(syscon_np);
>> >> >> >> >> -     of_node_put(syscon_np);
>> >> >> >> >> +     syscon = dev_get_drvdata(dev);
>> >> >> >> >>
>> >> >> >> >> -     return regmap;
>> >> >> >> >> +     return syscon->regmap;
>> >> >> >> >>  }
>> >> >> >> >>  EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible);
>> >> >> >> >
>> >> >> >> > Since you are not actually comparing the "compatible" property here,
>> >> >> >> > I would suggest adding another function here,
>> >> >> >>
>> >> >> >> Yes, i also think like that.
>> >> >> >
>> >> >> > In this case we should provide two paths for drivers which can work as with DT
>> >> >> > and without DT.
>> >> >>
>> >> >> Yes.
>> >> >
>> >> > I still think the universal procedure is better for the driver.
>> >> >
>> >>
>> >> Why?
>> >> I did not see your reply on my other comments on the problems of using universal
>> >> procedure?
>> >> Please let me know if you think they're not issues.
>> >
>> > Yes, I do not see a problem here.
>> > I will try to show the code.
>> >
>> > In the driver:
>> > struct regmap *r;
>> > r = syscon_regmap_lookup_by_compatible("my_super_syscon");
>> >
>> > For DT case:
>> > syscon@123456 {
>> >   compatible = "my_super_syscon", "syscon";
>> >   ...
>> > };
>> >
>> > For non-DT case:
>> > struct platform_device_id id = { .name = "my_super_syscon", };
>> > struct platform_device syscon_pdev = {
>> >   .name = "syscon",
>> >   .id_entry = &id,
>>
>> This is really strange to me and i've never seen such using.
>> Usually the id_table is provided by the driver and the match process then will
>> set the correct id_entry for the platform device once it matches.
>> Please see the platform_bus match process: drivers/base/platform.c
>
> Yes, this is non-standard usage. Currently we do not have platform_device_id
> entries for a "syscon" driver, so this field is untouched for a platform device
> and we can use it. At least this works, but, of course, more experts should
> fix me on this question if I think incorrect.
>

Hmm, i'm afraid most people may not accept this.
The platform_device_id are not desgined for such using, i guess.

>>
>> >   ...
>> > };
>> > platform_device_register(&syscon_pdev);
>> >
>> > Do I understand what you mean?
>> >
>>
>> My understanding for non-dt case is something like:
>> In client driver:
>> struct regmap *r;
>> r = syscon_regmap_lookup_by_pdevname("my_super_syscon");
>>
>> In board code:
>> struct platform_device syscon_pdev = {
>> .name = "my_super_syscon",
>> ...
>> };
>>  platform_device_register(&syscon_pdev);
>>
>> In syscon driver:
>> static struct platform_device_id syscon_device_ids[] = {
>>         {
>>                 .name = "my_super_syscon",
>>         }, {
>>                 /* sentinel */
>>         }
>> };
>> MODULE_DEVICE_TABLE(platform, syscon_device_ids);
>>
>> static struct platform_driver syscon_driver = {
>>         .driver = {
>>                 .name = "syscon",
>>                 .owner = THIS_MODULE,
>>                 .of_match_table = of_syscon_match,
>>         },
>>         .id_table       = syscon_device_ids,
>>         .probe          = syscon_probe,
>>         .remove         = syscon_remove,
>> };
>>
>> One problem is that every user needs to add their syscon compatible device
>> support(platform_device_id) in syscon driver first before they can use it.
>> But it looks to me just like how other driver generally does.
>
> I agree, this is a more proper way, but in this case we should create a big table
> here with records for each device...
>

Only non-dt needs add it which may not be so many and you're the first one.

Regards
Dong Aisheng

  reply	other threads:[~2013-02-20  6:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 14:42 [PATCH v3] mfd: syscon: Add non-DT support Alexander Shiyan
2013-02-18 16:02 ` Arnd Bergmann
2013-02-19  5:52   ` Dong Aisheng
2013-02-19  7:03   ` Re[2]: " Alexander Shiyan
2013-02-19  7:55     ` Dong Aisheng
2013-02-19  8:02       ` Dong Aisheng
2013-02-19  8:56     ` Re[4]: " Alexander Shiyan
2013-02-19  9:58       ` Dong Aisheng
2013-02-19 10:54       ` Re[6]: " Alexander Shiyan
2013-02-20  5:20         ` Dong Aisheng
2013-02-20  5:41         ` Re[8]: " Alexander Shiyan
2013-02-20  6:01           ` Dong Aisheng [this message]
2013-02-20 10:06           ` Arnd Bergmann
2013-02-20 11:05             ` Dong Aisheng
2013-02-20 11:14               ` Arnd Bergmann
2013-02-20 11:28                 ` Dong Aisheng
2013-02-20 12:16                   ` Arnd Bergmann
2013-02-20 12:47                 ` Re[10]: " Alexander Shiyan
2013-02-20 15:00                   ` Arnd Bergmann
2013-02-20 16:06                     ` Re[12]: " Alexander Shiyan
2013-02-20 17:16                       ` Arnd Bergmann
2013-02-20 17:27                         ` Re[14]: " Alexander Shiyan
2013-02-20 21:27                           ` Arnd Bergmann
2013-02-21 15:27                             ` Re[16]: " Alexander Shiyan
2013-02-19 10:49     ` Re[2]: " Arnd Bergmann

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='CAP1dx+xZ=FXtmTZ5YhJ4V6OLzFK5dwmLC2+jrfTK00QRKgCbEw@mail.gmail.com' \
    --to=dong.aisheng@linaro.org \
    --cc=arnd@arndb.de \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=shc_work@mail.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.