Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1689302ybz; Sat, 18 Apr 2020 06:27:56 -0700 (PDT) X-Google-Smtp-Source: APiQypIXqmRD6oamwZDv2NZw9vzzVZH+58dAXm6I42dusGkEzGaasKTfOer8Z3pk9zx21D+hLSfh X-Received: by 2002:a50:da4a:: with SMTP id a10mr7186073edk.158.1587216476599; Sat, 18 Apr 2020 06:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587216476; cv=none; d=google.com; s=arc-20160816; b=mGG1wZ8sPCy2vP9PzwFZ7VtltzKIhFU+mBjXtSTn9gwPc2EsSDqa/3prkSpE7emFSV Ji9ahyL9K/u5XwH+uU+9U4JgZhglfIBHcooFzsl+/VgBDnOx/wU0EcP8L2gQ1a/bvJPM Sq7F39uGOIk9I31ErWIgvl/d2tMwVfpAUV8MK8Ar4BfR+glK8xEphJh7GI+Kr5qNdIWk AO+XnAngQHFyQnVuOs+QYUc0spxaRXDJ1f1q0ty69C7ZRhncvOPHMf1uwLBlJ00xBI8y MXSBdj2MhW7c2UpeKer8Y1eteTOSriHf1vcfefdQUyL9Dr4EVbwh2hzMD15Vt1v0hpE+ ZJNA== 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=qPREZdljeZZMQNmCDVpmtfuQSa2YgdhGa45qFkNG4bA=; b=Fl3aARo7NLFhAjN6wKp70DyjWxVdA5yeqPZaV8LrFuR489FBIChqYGto9Ch6AfA+CS RJuzXZyMEWUQavKYJzRxbN9SiRImqJOCwluaWRWw/ww7bDVqOyoBtSv927rrbSh5fVJN 75YRdlKkK7sqYykEjQNnXplyc8fRwb07Y+egV5nLWwsk32AtCU6NfpwSVVn+exLYN/PS tjVdgh3GXzYhrd8g5RWrueLpGBn2G25FW3vzh9jBRgp2ZCHPfVHCIAdPuDJBtmuY6oe0 r92JjoiodCCzDBpzqlZzJB3OmAzW6H6pQdf8PaDXCnEa19DskZ0XcfWihvU3LI+vSOsc wGOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=UFqaxoTh; 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 u2si15168195ejr.370.2020.04.18.06.27.12; Sat, 18 Apr 2020 06:27:56 -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=UFqaxoTh; 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 S1725923AbgDRNZN (ORCPT + 99 others); Sat, 18 Apr 2020 09:25:13 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:59946 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgDRNZM (ORCPT ); Sat, 18 Apr 2020 09:25:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1587216310; 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=qPREZdljeZZMQNmCDVpmtfuQSa2YgdhGa45qFkNG4bA=; b=UFqaxoThyRQoRhg/v5pzojh5cWXRrL35xfuSPGYdRJR5Yymrkid+8O6wQsm3jF6BN3uuBT rm5qxFe8DE0A5uN5fUaicdFb+EZj9z3i0SZZ6MND5l57be0K2YoEzgIzk+q3rcl8wcB9yD UMTWD0w5z12EqIMGZIxOZ3zOT6A2VVg= Date: Sat, 18 Apr 2020 15:24:58 +0200 From: Paul Cercueil Subject: Re: [RESEND PATCH v5 5/5] input: joystick: Add ADC attached joystick driver. To: Andy Shevchenko Cc: Artur Rojek , Dmitry Torokhov , Rob Herring , Mark Rutland , Jonathan Cameron , Heiko Stuebner , linux-input , devicetree , linux-iio , Linux Kernel Mailing List Message-Id: In-Reply-To: References: <20200417202859.35427-1-contact@artur-rojek.eu> <20200417202859.35427-5-contact@artur-rojek.eu> <7CFY8Q.68YMS0V08F992@crapouillou.net> <0HGZ8Q.TO6FK92GVGIN3@crapouillou.net> 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 Le sam. 18 avril 2020 =E0 15:42, Andy Shevchenko=20 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=20 >> >> > 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: >=20 > ... >=20 >> >> >> >> +#include >> >> >> > >> >> >> > Do you really need this? (See below as well) >> >> > >> >> >> >> +static const struct of_device_id=20 >> adc_joystick_of_match[] =3D >> >> { >> >> >> >> + { .compatible =3D "adc-joystick", }, >> >> >> >> + { }, >> >> >> >> +}; >> >> >> >> +MODULE_DEVICE_TABLE(of, adc_joystick_of_match); >> >> >> >> + >> >> >> >> +static struct platform_driver adc_joystick_driver =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 should go >> >> with >> >> >> ugly >> >> >> > #ifdeffery. Here you simple introduced a compiler warning. >> >> >> >> >> >> I assume you mean #ifdef around the of_device_id + module=20 >> table >> >> >> macro? >> >> > >> >> > Yes. >> >> > >> >> >> > On top of that, you are using device property API, OF use=20 >> in >> >> this >> >> >> case >> >> >> > is contradictory (at lest to some extend). >> >> >> >> >> >> I don't see why. The fact that the driver can work when=20 >> 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. >>=20 >> 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. >=20 > 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=20 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? >>=20 >> platform_device_add_properties(). >=20 > 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=20 be used. Anyway, this discussion is pointless. I don't think anybody would want=20 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=20 >> favour of >> >> more >> >> > generic approach. Mixing those two can be done only in=20 >> 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=20 >> probe >> >> from >> >> devicetree. >> > >> > Table is fine(JFYI the types and sections are defined outside of=20 >> OF >> > stuff, though being [heavily] used by it) , API (of_match_ptr()=20 >> macro >> > use) is not. >>=20 >> Sorry, but that's just stupid. Please have a look at how=20 >> of_match_ptr() >> macro is defined in . >=20 > 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=20 done here. > It needs either of: > - ugly ifdeffery > - dropping of_match_ptr() > - explicit dependence to OF >=20 > 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=20 magically probe from ACPI, without a acpi_match_table? -Paul