public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Artur Rojek <contact@artur-rojek.eu>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Jonathan Cameron <jic23@kernel.org>,
	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: Fri, 17 Apr 2020 23:23:54 +0200	[thread overview]
Message-ID: <UFBY8Q.ES4D59V22INC1@crapouillou.net> (raw)
In-Reply-To: <CAHp75VfRbnnuUhfyXpu+5dp4TutHSrHus=sX_vG_5F0dX4k0fQ@mail.gmail.com>

Hi Andy,

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:
>> 
>>  Add a driver for joystick devices connected to ADC controllers
>>  supporting the Industrial I/O subsystem.
> 
> ...
> 
>>  +#include <linux/of.h>
> 
> Do you really need this? (See below as well)
> 
> ...
> 
>>  +               sign = 
>> (tolower(joy->chans[i].channel->scan_type.sign) == 's');
> 
> Too many parentheses. But here it's up to you,
> 
> ...
> 
>>  +               case 2:
> 
>>  +                       val = ((const u16 *)data)[i];
> 
> Can't you do this in each branch below?
> 
>>  +                       if (endianness == IIO_BE)
>>  +                               val = be16_to_cpu(val);
>>  +                       else if (endianness == IIO_LE)
>>  +                               val = le16_to_cpu(val);
>>  +                       break;
> 
> ...
> 
>>  +       device_for_each_child_node(dev, child) {
>>  +               ret = fwnode_property_read_u32(child, "reg", &i);
>>  +               if (ret || i >= 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 
>> missing");
>>  +                       goto err;
>>  +               }
>>  +
>>  +               if (fwnode_property_read_u32_array(child, 
>> "abs-range",
>>  +                                                  axes[i].range, 
>> 2)) {
>>  +                       dev_err(dev, "abs-range invalid or 
>> missing");
>>  +                       goto err;
>>  +               }
> 
>>  +       }
>>  +
>>  +       joy->axes = axes;
>>  +
>>  +       return 0;
>>  +
>>  +err:
>>  +       fwnode_handle_put(child);
> 
>>  +       return -EINVAL;
> 
> Can we avoid shadowing the actual error code?
> 
> ...
> 
>>  +       bits = joy->chans[0].channel->scan_type.storagebits;
> 
>>  +       if (!bits || (bits >> 3) > 2) {
> 
> Wouldn't be clear to use simple 'bits > 16'?
> 
>>  +               dev_err(dev, "Unsupported channel storage size");
>>  +               return -EINVAL;
>>  +       }
> 
> ...
> 
>>  +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?

> 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, doesn't mean that it shouldn't have a table to probe 
from devicetree.

-Paul

> 
>>  +       },
>>  +       .probe = adc_joystick_probe,
>>  +};
> 
> --
> With Best Regards,
> Andy Shevchenko



  reply	other threads:[~2020-04-17 21:24 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 [this message]
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
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=UFBY8Q.ES4D59V22INC1@crapouillou.net \
    --to=paul@crapouillou.net \
    --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=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --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