linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Karoly Pados" <pados@pados.hu>
To: "Johan Hovold" <johan@kernel.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Loic Poulain" <loic.poulain@linaro.org>
Subject: Re: [PATCH v6] USB: serial: ftdi_sio: implement GPIO support for FT-X devices
Date: Tue, 25 Sep 2018 10:46:30 +0000	[thread overview]
Message-ID: <e4a12a0856d083eed0994ab888bc8869@pados.hu> (raw)
In-Reply-To: <20180925100635.GC3332@localhost>

Hi,

>> +#if defined(CONFIG_GPIOLIB)
>> +static const char * const ftdi_ftx_gpio_names[] = {
>> + "CBUS0", "CBUS1", "CBUS2", "CBUS3"
>> +};
>> +#endif
> 
> We want to keep the ifdeffery to a minimum, so move this inside the
> gpiolib ifdef below (and possibly even into the function where it is
> used).
> 
> Also note that these names are shared with FT232R, but not with FT232H.
> 

What naming do you suggest then?

My personal preference would be however to leave this name as is, because
this patch only adds support for the FT-X. Even if support for others can 
be added relatively trivially after this, there is explicitly no GPIO 
support for FT232R *yet*. If somebody else adds GPIO support for the FT232R
in a later patch, he/she should make corresponding adjustments themselves,
including naming changes. IMHO.

>> +static void ftdi_gpio_set_multiple(struct gpio_chip *gc,
>> + unsigned long *mask, unsigned long *bits)
>> +{
>> + struct usb_serial_port *port = gpiochip_get_data(gc);
>> + struct ftdi_private *priv = usb_get_serial_port_data(port);
>> +
>> + mutex_lock(&priv->gpio_lock);
>> +
>> + priv->gpio_value &= ~(*mask);
>> + priv->gpio_value |= *bits;
> 
> gpiolib doesn't clear bits not in mask for you, so you need to OR with
> *mask here to avoid setting random other bits.

I guess you meant AND here?

>> + if (priv->gpio_output & BIT(gpio))
>> + return 0;
>> + else
>> + return 1;
> 
> This could just simplified using negation (!), but perhaps this is
> easier to parse as it stands.
> 

Sorry, it is not clear what your preferred action here is. 
So should I leave it as is then or not?

Karoly

  parent reply	other threads:[~2018-09-25 10:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 14:31 [PATCH v6] USB: serial: ftdi_sio: implement GPIO support for FT-X devices Karoly Pados
2018-09-25 10:06 ` Johan Hovold
2018-09-25 10:15   ` Johan Hovold
2018-09-25 10:47   ` Karoly Pados
2018-09-25 10:46 ` Karoly Pados [this message]
2018-09-25 11:00   ` Johan Hovold
2018-09-25 11:11   ` Karoly Pados
2018-09-25 12:08     ` Johan Hovold

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=e4a12a0856d083eed0994ab888bc8869@pados.hu \
    --to=pados@pados.hu \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=loic.poulain@linaro.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;
as well as URLs for NNTP newsgroup(s).