linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/3] USB: serial: ftdi_sio: use cur_altsetting for consistency
@ 2020-10-02 18:49 Mychaela N. Falconia
  2020-10-05 11:00 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Mychaela N. Falconia @ 2020-10-02 18:49 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-usb, mychaela.falconia

ftdi_determine_type() function had this construct in it to get the
number of the interface it is operating on:

  inter = serial->interface->altsetting->desc.bInterfaceNumber;

Elsewhere in this driver cur_altsetting is used instead for this
purpose.  Change ftdi_determine_type() to use cur_altsetting
for consistency.

Signed-off-by: Mychaela N. Falconia <falcon@freecalypso.org>
---

Simply changing altsetting to cur_altsetting would have caused the
offending line to exceed the 80 character limit.  Instead I changed
the code structure to be the same as in Johan's recent JTAG quirk
cleanup patch.

---
 drivers/usb/serial/ftdi_sio.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 12a4b74ca1f4..a34c0d8b0cd3 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1571,7 +1571,8 @@ static void ftdi_determine_type(struct usb_serial_port *port)
 	dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__,
 		version, interfaces);
 	if (interfaces > 1) {
-		int inter;
+		struct usb_interface *intf = serial->interface;
+		int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
 
 		/* Multiple interfaces.*/
 		if (version == 0x0800) {
@@ -1586,14 +1587,13 @@ static void ftdi_determine_type(struct usb_serial_port *port)
 			priv->chip_type = FT2232C;
 
 		/* Determine interface code. */
-		inter = serial->interface->altsetting->desc.bInterfaceNumber;
-		if (inter == 0) {
+		if (ifnum == 0) {
 			priv->interface = INTERFACE_A;
-		} else  if (inter == 1) {
+		} else  if (ifnum == 1) {
 			priv->interface = INTERFACE_B;
-		} else  if (inter == 2) {
+		} else  if (ifnum == 2) {
 			priv->interface = INTERFACE_C;
-		} else  if (inter == 3) {
+		} else  if (ifnum == 3) {
 			priv->interface = INTERFACE_D;
 		}
 		/* BM-type devices have a bug where bcdDevice gets set
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 1/3] USB: serial: ftdi_sio: use cur_altsetting for consistency
  2020-10-02 18:49 [PATCH v3 1/3] USB: serial: ftdi_sio: use cur_altsetting for consistency Mychaela N. Falconia
@ 2020-10-05 11:00 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2020-10-05 11:00 UTC (permalink / raw)
  To: Mychaela N. Falconia; +Cc: Johan Hovold, linux-usb, mychaela.falconia

On Fri, Oct 02, 2020 at 06:49:37PM +0000, Mychaela N. Falconia wrote:
> ftdi_determine_type() function had this construct in it to get the
> number of the interface it is operating on:
> 
>   inter = serial->interface->altsetting->desc.bInterfaceNumber;
> 
> Elsewhere in this driver cur_altsetting is used instead for this
> purpose.  Change ftdi_determine_type() to use cur_altsetting
> for consistency.
> 
> Signed-off-by: Mychaela N. Falconia <falcon@freecalypso.org>
> ---
> 
> Simply changing altsetting to cur_altsetting would have caused the
> offending line to exceed the 80 character limit.  Instead I changed
> the code structure to be the same as in Johan's recent JTAG quirk
> cleanup patch.
> 
> ---
>  drivers/usb/serial/ftdi_sio.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index 12a4b74ca1f4..a34c0d8b0cd3 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -1571,7 +1571,8 @@ static void ftdi_determine_type(struct usb_serial_port *port)
>  	dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__,
>  		version, interfaces);
>  	if (interfaces > 1) {
> -		int inter;
> +		struct usb_interface *intf = serial->interface;
> +		int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
>  
>  		/* Multiple interfaces.*/
>  		if (version == 0x0800) {
> @@ -1586,14 +1587,13 @@ static void ftdi_determine_type(struct usb_serial_port *port)
>  			priv->chip_type = FT2232C;
>  
>  		/* Determine interface code. */
> -		inter = serial->interface->altsetting->desc.bInterfaceNumber;
> -		if (inter == 0) {
> +		if (ifnum == 0) {
>  			priv->interface = INTERFACE_A;
> -		} else  if (inter == 1) {
> +		} else  if (ifnum == 1) {
>  			priv->interface = INTERFACE_B;
> -		} else  if (inter == 2) {
> +		} else  if (ifnum == 2) {
>  			priv->interface = INTERFACE_C;
> -		} else  if (inter == 3) {
> +		} else  if (ifnum == 3) {
>  			priv->interface = INTERFACE_D;
>  		}

I've applied this one now after fixing the old style issues here
(unnecessary braces and random white space after else).

Thanks!

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-05 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-02 18:49 [PATCH v3 1/3] USB: serial: ftdi_sio: use cur_altsetting for consistency Mychaela N. Falconia
2020-10-05 11:00 ` Johan Hovold

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).