Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1024654ybz; Fri, 17 Apr 2020 14:25:27 -0700 (PDT) X-Google-Smtp-Source: APiQypI6i4GJ0wzNKDdP/WkwiPgnzRhNDzC6ZAV29cNcr56fc81MuWbf+3zrshorQs2C2HwMDipP X-Received: by 2002:a17:906:6856:: with SMTP id a22mr563782ejs.115.1587158727154; Fri, 17 Apr 2020 14:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587158727; cv=none; d=google.com; s=arc-20160816; b=w6ER9kqAweMdgw6mdrcvkBmr5saTEgW4w/jbxldrjY8InVxHxRiKgm5bLF5uhNrLvx S8lCV21G7DuR3buC3znudOP4SQAUtUGtTS4Bhu23CKgchnZFtVGqLU0y4CBtemxSmKw1 jOOm+nNYrT9gEZahLzFVt0MCB6FnH5HJiMTkRg1RHA+9foeHSLrB/LuLEmzN8Pp/r/p6 qFhgjvXSAGJs8d+/KgQOzOROycrCWF2Tbuyz0kOjareXlr2QC4avvK4Ns+Yr+T2Jl2yI 4ypThbCb6yV5voJAh4PTTW7jnJ9GpgsHjP2UHdKdXbLFv9ug+4GPXjKJjylZqUtdXYva ScOQ== 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=WccMFp68EcyAjhnWK/SjfcUdqGevziF5O9dUK1eEzlQ=; b=iBuzszQ1M5ZzbXKiaisOJRpUo3+c4JpC86lS8zZE2f8M06NHf/tXh2nrsBFbWsK5Io 6LUehuaucjgg9M3uHKFGW4YPCDN5QSAC8SZCg/k6Rc5hudoOLQK7q/wcKiAtYtuKqNJQ bGN5wkHHylksIsnOlURHQcDUyESP13PrajvNpiLgqvGu9xgbbEKXPflqtA6YOEPFsypn dtw9VCK7ED2Ur5EJyUwiloxsftA0nNqb1NhbMzTDF6rwa4hSxsiSCm+QffYmKIyP8/Y8 MkHKT8NH+2UFtL2EFfLVW+SeyxnIqmUWWJxIKT0d0hqn7OyPaGNgU7KXrPM0qvuoSWWS m8XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=rC9lFw3K; 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 f3si14288578ejt.299.2020.04.17.14.25.03; Fri, 17 Apr 2020 14:25:27 -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=rC9lFw3K; 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 S1727897AbgDQVYK (ORCPT + 99 others); Fri, 17 Apr 2020 17:24:10 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:36796 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbgDQVYJ (ORCPT ); Fri, 17 Apr 2020 17:24:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1587158647; 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=WccMFp68EcyAjhnWK/SjfcUdqGevziF5O9dUK1eEzlQ=; b=rC9lFw3KxDac/HzVkuO4Xp5GHw2P36PAJvhmT8SvYFcSxpbGdyJR9appFMoVeRieN3htVa +8Aa42oVc1T8A/wV4nPoHkHACAc1LHnqfbyVmEmAF7tacR37/5ztZqV+/epmIzxgqrffpd HgfFpjo4/1f9td3khMaNjj1K/HO176g= Date: Fri, 17 Apr 2020 23:23:54 +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> 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 Andy, Le sam. 18 avril 2020 =E0 0:10, Andy Shevchenko=20 a =E9crit : > On Fri, Apr 17, 2020 at 11:21 PM Artur Rojek =20 > wrote: >>=20 >> Add a driver for joystick devices connected to ADC controllers >> supporting the Industrial I/O subsystem. >=20 > ... >=20 >> +#include >=20 > Do you really need this? (See below as well) >=20 > ... >=20 >> + sign =3D=20 >> (tolower(joy->chans[i].channel->scan_type.sign) =3D=3D 's'); >=20 > Too many parentheses. But here it's up to you, >=20 > ... >=20 >> + case 2: >=20 >> + val =3D ((const u16 *)data)[i]; >=20 > Can't you do this in each branch below? >=20 >> + if (endianness =3D=3D IIO_BE) >> + val =3D be16_to_cpu(val); >> + else if (endianness =3D=3D IIO_LE) >> + val =3D le16_to_cpu(val); >> + break; >=20 > ... >=20 >> + device_for_each_child_node(dev, child) { >> + ret =3D fwnode_property_read_u32(child, "reg", &i); >> + if (ret || i >=3D num_axes) { >> + dev_err(dev, "reg invalid or missing"); >> + goto err; >> + } >> + >> + if (fwnode_property_read_u32(child, "linux,code", >> + &axes[i].code)) { >> + dev_err(dev, "linux,code invalid or=20 >> missing"); >> + goto err; >> + } >> + >> + if (fwnode_property_read_u32_array(child,=20 >> "abs-range", >> + axes[i].range,=20 >> 2)) { >> + dev_err(dev, "abs-range invalid or=20 >> missing"); >> + goto err; >> + } >=20 >> + } >> + >> + joy->axes =3D axes; >> + >> + return 0; >> + >> +err: >> + fwnode_handle_put(child); >=20 >> + return -EINVAL; >=20 > Can we avoid shadowing the actual error code? >=20 > ... >=20 >> + bits =3D joy->chans[0].channel->scan_type.storagebits; >=20 >> + if (!bits || (bits >> 3) > 2) { >=20 > Wouldn't be clear to use simple 'bits > 16'? >=20 >> + dev_err(dev, "Unsupported channel storage size"); >> + return -EINVAL; >> + } >=20 > ... >=20 >> +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 =3D { >> + .driver =3D { >> + .name =3D "adc-joystick", >=20 >> + .of_match_table =3D=20 >> of_match_ptr(adc_joystick_of_match), >=20 > 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? > 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=20 platform code, doesn't mean that it shouldn't have a table to probe=20 from devicetree. -Paul >=20 >> + }, >> + .probe =3D adc_joystick_probe, >> +}; >=20 > -- > With Best Regards, > Andy Shevchenko