public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Artur Rojek <contact@artur-rojek.eu>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-input <linux-input@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	linux-iio <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RESEND PATCH v5 5/5] input: joystick: Add ADC attached joystick driver.
Date: Sat, 18 Apr 2020 15:22:57 +0100	[thread overview]
Message-ID: <20200418152257.5f8a45bd@archlinux> (raw)
In-Reply-To: <NXJZ8Q.5YQ6OBV5Y9V8@crapouillou.net>

On Sat, 18 Apr 2020 15:24:58 +0200
Paul Cercueil <paul@crapouillou.net> wrote:

> Le sam. 18 avril 2020 à 15:42, Andy Shevchenko 
> <andy.shevchenko@gmail.com> a écrit :
> > On Sat, Apr 18, 2020 at 3:10 PM Paul Cercueil <paul@crapouillou.net> 
> > wrote:  
> >>  Le sam. 18 avril 2020 à 14:57, Andy Shevchenko
> >>  <andy.shevchenko@gmail.com> a écrit :  
> >>  > On Sat, Apr 18, 2020 at 1:48 AM Paul Cercueil   
> >> <paul@crapouillou.net>  
> >>  > wrote:  
> >>  >>  Le sam. 18 avril 2020 à 0:49, Andy Shevchenko
> >>  >>  <andy.shevchenko@gmail.com> a écrit :  
> >>  >>  > On Sat, Apr 18, 2020 at 12:24 AM Paul Cercueil  
> >>  >> <paul@crapouillou.net>  
> >>  >>  > wrote:  
> >>  >>  >>  Le sam. 18 avril 2020 à 0:10, Andy Shevchenko
> >>  >>  >>  <andy.shevchenko@gmail.com> a écrit :  
> >>  >>  >>  > On Fri, Apr 17, 2020 at 11:21 PM Artur Rojek  
> >>  >>  >> <contact@artur-rojek.eu>  
> >>  >>  >>  > wrote:  
> > 
> > ...
> >   
> >>  >>  >>  >>  +#include <linux/of.h>  
> >>  >>  >>  >
> >>  >>  >>  > Do you really need this? (See below as well)  
> >>  >>  >  
> >>  >>  >>  >>  +static const struct of_device_id   
> >> adc_joystick_of_match[] =  
> >>  >> {  
> >>  >>  >>  >>  +       { .compatible = "adc-joystick", },
> >>  >>  >>  >>  +       { },
> >>  >>  >>  >>  +};
> >>  >>  >>  >>  +MODULE_DEVICE_TABLE(of, adc_joystick_of_match);
> >>  >>  >>  >>  +
> >>  >>  >>  >>  +static struct platform_driver adc_joystick_driver = {
> >>  >>  >>  >>  +       .driver = {
> >>  >>  >>  >>  +               .name = "adc-joystick",  
> >>  >>  >>  >  
> >>  >>  >>  >>  +               .of_match_table =
> >>  >>  >>  >> of_match_ptr(adc_joystick_of_match),  
> >>  >>  >>  >
> >>  >>  >>  > Drop this a bit harmful of_match_ptr() macro. It should go  
> >>  >> with  
> >>  >>  >> ugly  
> >>  >>  >>  > #ifdeffery. Here you simple introduced a compiler warning.  
> >>  >>  >>
> >>  >>  >>  I assume you mean #ifdef around the of_device_id + module   
> >> table  
> >>  >>  >> macro?  
> >>  >>  >
> >>  >>  > Yes.
> >>  >>  >  
> >>  >>  >>  > On top of that, you are using device property API, OF use   
> >> in  
> >>  >> this  
> >>  >>  >> case  
> >>  >>  >>  > is contradictory (at lest to some extend).  
> >>  >>  >>
> >>  >>  >>  I don't see why. The fact that the driver can work when   
> >> probed  
> >>  >> from  
> >>  >>  >>  platform code  
> >>  >>  >
> >>  >>  > Ha-ha, tell me how. I would like to be very surprised.  
> >>  >>
> >>  >>  iio_map_array_register(),
> >>  >>  pinctrl_register_mappings(),
> >>  >>  platform_add_devices(),
> >>  >>
> >>  >>  you're welcome.  
> >>  >
> >>  > I think above has no relation to what I'm talking about.  
> >> 
> >>  Yes it does. It allows you to map the IIO channels, set the pinctrl
> >>  configurations and register a device from platform code instead of
> >>  devicetree.  
> > 
> > I'm not talking about other drivers, I'm talking about this driver and
> > how it will be instantiated. Above, according to the code, can't be
> > comprehensive to fulfill this.  
> 
> This is how the platform devices were instanciated on JZ4740 before we 
> switched everything to devicetree.
> 
> >>  > How *this* driver can work as a platform instantiated one?
> >>  > We seems have a conceptual misunderstanding here.
> >>  >
> >>  > For example, how can probe of this driver not fail, if it is not
> >>  > backed by a DT/ACPI properties?  
> >> 
> >>  platform_device_add_properties().  
> > 
> > Yes, I waited for this. And seems you don't understand the (scope of)
> > API, you are trying to insist this driver can be used as a platform
> > one.
> > Sorry, I must to disappoint you, it can't. Above interface is created
> > solely for quirks to support (broken) DT/ACPI tables. It's not
> > supposed to be used as a main source for the device properties.  
> 
> The fact that it was designed for something else doesn't mean it can't 
> be used.
> 
> Anyway, this discussion is pointless. I don't think anybody would want 
> to do that.
> 
> >>  >>  >>  doesn't mean that it shouldn't have a table to probe
> >>  >>  >>  from devicetree.  
> >>  >>  >
> >>  >>  > I didn't get what you are talking about here. The idea of  
> >>  >> _unified_  
> >>  >>  > device property API is to get rid of OF-centric code in   
> >> favour of  
> >>  >> more  
> >>  >>  > generic approach. Mixing those two can be done only in   
> >> specific  
> >>  >> cases  
> >>  >>  > (here is not the one).  
> >>  >>
> >>  >>  And how are we mixing those two here? The only OF-centric thing
> >>  >> here is
> >>  >>  the device table, which is required if we want the driver to   
> >> probe  
> >>  >> from
> >>  >>  devicetree.  
> >>  >
> >>  > Table is fine(JFYI the types and sections are defined outside of   
> >> OF  
> >>  > stuff, though being [heavily] used by it) , API (of_match_ptr()   
> >> macro  
> >>  > use) is not.  
> >> 
> >>  Sorry, but that's just stupid. Please have a look at how 
> >> of_match_ptr()
> >>  macro is defined in <linux/of.h>.  
> > 
> > Call it whatever you want, but above code is broken.  
> 
> of_match_ptr() is basically defined like this:
> 
> #ifdef CONFIG_OF
> #define of_match_ptr(x) (x)
> #else
> #define of_match_ptr(x) NULL
> #endif
> 
> So please, enlighten me, tell me what is so wrong about what's being 
> done here.
> 
> > It needs either of:
> > - ugly ifdeffery
> > - dropping of_match_ptr()
> > - explicit dependence to OF
> > 
> > My choice is second one. Because it makes code better and allows also
> > ACPI to use this driver (usually) without changes.  
> 
> And how is unconditionally compiling the of_match_table make it 
> magically probe from ACPI, without a acpi_match_table?
> 
> -Paul

Look up PRP0001 ACPI ID.  Magic trick ;)

https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.html?highlight=PRP0001

It allows you to define an ACPI device in DSDT that is instantiated
from what is effectively the DT binding including the id table.

Jonathan

> 
> 


  reply	other threads:[~2020-04-18 14:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-17 20:28 [RESEND PATCH v5 1/5] IIO: Ingenic JZ47xx: Add xlate cb to retrieve correct channel idx Artur Rojek
2020-04-17 20:28 ` [RESEND PATCH v5 2/5] dt-bindings: iio/adc: Add touchscreen idx for JZ47xx SoC ADC Artur Rojek
2020-04-17 20:28 ` [RESEND PATCH v5 3/5] IIO: Ingenic JZ47xx: Add touchscreen mode Artur Rojek
2020-04-17 20:59   ` Andy Shevchenko
2020-04-17 21:04     ` Paul Cercueil
2020-04-17 21:13       ` Andy Shevchenko
2020-04-17 21:18         ` Paul Cercueil
2020-04-17 21:42           ` Andy Shevchenko
2020-04-17 21:45             ` Paul Cercueil
2020-04-17 21:52               ` Andy Shevchenko
2020-04-17 21:56                 ` Paul Cercueil
2020-04-19 12:54                 ` Ezequiel Garcia
2020-04-19 13:23                   ` Paul Cercueil
2020-04-19 13:31                   ` Artur Rojek
2020-04-19 12:19     ` Artur Rojek
2020-04-17 20:28 ` [RESEND PATCH v5 4/5] dt-bindings: input: Add docs for ADC driven joystick Artur Rojek
2020-04-17 20:28 ` [RESEND PATCH v5 5/5] input: joystick: Add ADC attached joystick driver Artur Rojek
2020-04-17 21:10   ` Andy Shevchenko
2020-04-17 21:23     ` Paul Cercueil
2020-04-17 21:49       ` Andy Shevchenko
2020-04-17 22:48         ` Paul Cercueil
2020-04-18 11:57           ` Andy Shevchenko
2020-04-18 12:10             ` Paul Cercueil
2020-04-18 12:42               ` Andy Shevchenko
2020-04-18 13:24                 ` Paul Cercueil
2020-04-18 14:22                   ` Jonathan Cameron [this message]
2020-04-18 17:25                     ` Paul Cercueil
2020-04-18 18:20                       ` Jonathan Cameron

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=20200418152257.5f8a45bd@archlinux \
    --to=jic23@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=contact@artur-rojek.eu \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=heiko@sntech.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=paul@crapouillou.net \
    --cc=robh+dt@kernel.org \
    /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