Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1884800ybz; Sat, 18 Apr 2020 10:27:30 -0700 (PDT) X-Google-Smtp-Source: APiQypIGrOQHls0gVw3iMtde90W/X1mXWBJXMk9Uq4KQ2yK/dj2GAcJIcjZZFZf9Bm3XCZpvQeU7 X-Received: by 2002:a05:6402:4:: with SMTP id d4mr7729937edu.344.1587230850340; Sat, 18 Apr 2020 10:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587230850; cv=none; d=google.com; s=arc-20160816; b=kgr/fselXd+rh/0nnzYtH1Tji9FlPHHX1EROZVJT8JrLm6LB7etNSAqc78NWE9Ufad HvnB9Gzu+MION/+zf2f4Cf1CYyL33UCF+oQMFBBEzm4YtT8T1N3+0tN8E60QZYBDAWIy c1SSHUGA2JYMvkaF2jXyXwQYNaactOMfHnWt8z9dVoOvPF0TmVaxC2IXiLEtVr/jb0DA eGxv/ny5K0/5vDLow2+Ld5gXKLfX1HgV/NYAiIWmWx2ES8JaUSg3Xcy2m1f8vBY0pizj zr4q41EeWF+Riymy2PNn8l0zVuNL2IaRNBBVn2izXoCpx5JZdimOs67mYo196zK+ek/L of6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date :dkim-signature; bh=BJK3SzVpQ1si/reyVxcaxpHREQLlO3j66OLfCZHjFz8=; b=GfXJ7+si+1DuBTFzi8nlz1ZwV7D9D1D346hwkcZQRPj1fxqOpx3+7RNlsi/zlJP77f LzQGBW3ARp+IfhWH+aqblp1nauxDvCjPAZM/Nwg88XaJMmtIQluqhpUZ+mR7y5RT80Al /bAwlD/Vy0VUsAAEi/bNgzKI3lHsge5bjdozREkRLJjzPOKqCY7F5/+8DfhqupG4zdMH 6HqzJLnYZWB4fWHJ4DPse0T/QH5OT1EB/d7jDvBqOHbzF2ZaNhNHidTXKzLPkQOuNLt1 VWzWHi4M+6aGFb9Q+fpKLKrOxj/tOVw1T2BoCa01QW30nVRYffUkZc0Bq0lDcNJ59OdM VQ2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=ovFlkDng; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v15si5774859edq.394.2020.04.18.10.27.06; Sat, 18 Apr 2020 10:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=ovFlkDng; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726907AbgDRRZa (ORCPT + 99 others); Sat, 18 Apr 2020 13:25:30 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:46150 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbgDRRZ3 (ORCPT ); Sat, 18 Apr 2020 13:25:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1587230726; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BJK3SzVpQ1si/reyVxcaxpHREQLlO3j66OLfCZHjFz8=; b=ovFlkDngSG/UH+xUeOabMOqk8s3sWsFD3Ajn8VcLM8qAURKHeCHdwIj7x/gJoK4/NpubJI myHC+zj7i0mU/gSasdHYFqsLUsoeJGpV/q0y8PqLe2XgILJUB29h+7/8tnQY/LFH+UYumP YfxXY+P6PmNPBqiZzfguL8HLsdOb72c= Date: Sat, 18 Apr 2020 19:25:15 +0200 From: Paul Cercueil Subject: Re: [RESEND PATCH v5 5/5] input: joystick: Add ADC attached joystick driver. To: Jonathan Cameron Cc: Andy Shevchenko , Artur Rojek , Dmitry Torokhov , Rob Herring , Mark Rutland , Heiko Stuebner , linux-input , devicetree , linux-iio , Linux Kernel Mailing List Message-Id: <32VZ8Q.HWUYPX9U9OKT@crapouillou.net> In-Reply-To: <20200418152257.5f8a45bd@archlinux> References: <20200417202859.35427-1-contact@artur-rojek.eu> <20200417202859.35427-5-contact@artur-rojek.eu> <7CFY8Q.68YMS0V08F992@crapouillou.net> <0HGZ8Q.TO6FK92GVGIN3@crapouillou.net> <20200418152257.5f8a45bd@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, Le sam. 18 avril 2020 =E0 15:22, Jonathan Cameron a=20 =E9crit : > On Sat, 18 Apr 2020 15:24:58 +0200 > Paul Cercueil wrote: >=20 >> Le sam. 18 avril 2020 =E0 15:42, Andy Shevchenko >> a =E9crit : >> > On Sat, Apr 18, 2020 at 3:10 PM Paul Cercueil=20 >> >> > wrote: >> >> Le sam. 18 avril 2020 =E0 14:57, Andy Shevchenko >> >> a =E9crit : >> >> > On Sat, Apr 18, 2020 at 1:48 AM Paul Cercueil >> >> >> >> > wrote: >> >> >> Le sam. 18 avril 2020 =E0 0:49, Andy Shevchenko >> >> >> a =E9crit : >> >> >> > On Sat, Apr 18, 2020 at 12:24 AM Paul Cercueil >> >> >> >> >> >> > wrote: >> >> >> >> Le sam. 18 avril 2020 =E0 0:10, Andy Shevchenko >> >> >> >> a =E9crit : >> >> >> >> > On Fri, Apr 17, 2020 at 11:21 PM Artur Rojek >> >> >> >> >> >> >> >> > wrote: >> > >> > ... >> > >> >> >> >> >> +#include >> >> >> >> > >> >> >> >> > Do you really need this? (See below as well) >> >> >> > >> >> >> >> >> +static const struct of_device_id >> >> adc_joystick_of_match[] =3D >> >> >> { >> >> >> >> >> + { .compatible =3D "adc-joystick", }, >> >> >> >> >> + { }, >> >> >> >> >> +}; >> >> >> >> >> +MODULE_DEVICE_TABLE(of, adc_joystick_of_match); >> >> >> >> >> + >> >> >> >> >> +static struct platform_driver adc_joystick_driver=20 >> =3D { >> >> >> >> >> + .driver =3D { >> >> >> >> >> + .name =3D "adc-joystick", >> >> >> >> > >> >> >> >> >> + .of_match_table =3D >> >> >> >> >> of_match_ptr(adc_joystick_of_match), >> >> >> >> > >> >> >> >> > Drop this a bit harmful of_match_ptr() macro. It=20 >> should go >> >> >> with >> >> >> >> ugly >> >> >> >> > #ifdeffery. Here you simple introduced a compiler=20 >> warning. >> >> >> >> >> >> >> >> I assume you mean #ifdef around the of_device_id +=20 >> module >> >> table >> >> >> >> macro? >> >> >> > >> >> >> > Yes. >> >> >> > >> >> >> >> > On top of that, you are using device property API, OF=20 >> 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=20 >> pinctrl >> >> configurations and register a device from platform code instead=20 >> of >> >> devicetree. >> > >> > I'm not talking about other drivers, I'm talking about this=20 >> driver and >> > how it will be instantiated. Above, according to the code, can't=20 >> be >> > comprehensive to fulfill this. >>=20 >> This is how the platform devices were instanciated on JZ4740 before=20 >> we >> switched everything to devicetree. >>=20 >> >> > 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=20 >> not >> >> > backed by a DT/ACPI properties? >> >> >> >> platform_device_add_properties(). >> > >> > Yes, I waited for this. And seems you don't understand the (scope=20 >> of) >> > API, you are trying to insist this driver can be used as a=20 >> platform >> > one. >> > Sorry, I must to disappoint you, it can't. Above interface is=20 >> 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. >>=20 >> The fact that it was designed for something else doesn't mean it=20 >> can't >> be used. >>=20 >> Anyway, this discussion is pointless. I don't think anybody would=20 >> want >> to do that. >>=20 >> >> >> >> 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=20 >> 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=20 >> of >> >> OF >> >> > stuff, though being [heavily] used by it) , API=20 >> (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 . >> > >> > Call it whatever you want, but above code is broken. >>=20 >> of_match_ptr() is basically defined like this: >>=20 >> #ifdef CONFIG_OF >> #define of_match_ptr(x) (x) >> #else >> #define of_match_ptr(x) NULL >> #endif >>=20 >> So please, enlighten me, tell me what is so wrong about what's being >> done here. >>=20 >> > 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=20 >> also >> > ACPI to use this driver (usually) without changes. >>=20 >> And how is unconditionally compiling the of_match_table make it >> magically probe from ACPI, without a acpi_match_table? >>=20 >> -Paul >=20 > Look up PRP0001 ACPI ID. Magic trick ;) >=20 > https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.ht= ml?highlight=3DPRP0001 >=20 > It allows you to define an ACPI device in DSDT that is instantiated > from what is effectively the DT binding including the id table. So what you're saying, is that the OF table should be present, even=20 though CONFIG_OF is not set, just in case it is probed from ACPI? -Paul