From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20D94C38A2B for ; Fri, 17 Apr 2020 21:24:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0DCF20857 for ; Fri, 17 Apr 2020 21:24:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="rC9lFw3K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727791AbgDQVYK (ORCPT ); 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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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