diff mbox series

[v3,3/3] USB: serial: blacklist USB-UIRT when driver is selected

Message ID 37339f4102666345168a738d0ffd80d8133a6a03.1620304986.git.sean@mess.org
State New
Headers show
Series IR driver for USB-UIRT device | expand

Commit Message

Sean Young May 6, 2021, 12:44 p.m. UTC
The USB-UIRT device has its own driver, so blacklist the fdti driver
from using it if the driver has been enabled.

Signed-off-by: Sean Young <sean@mess.org>
---
 drivers/usb/serial/ftdi_sio.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Johan Hovold May 14, 2021, 11:40 a.m. UTC | #1
On Thu, May 06, 2021 at 01:44:55PM +0100, Sean Young wrote:
> The USB-UIRT device has its own driver, so blacklist the fdti driver

> from using it if the driver has been enabled.

> 

> Signed-off-by: Sean Young <sean@mess.org>

> ---

>  drivers/usb/serial/ftdi_sio.c | 8 ++++++++

>  1 file changed, 8 insertions(+)

> 

> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c

> index 542073d2f0dd..2320bda57796 100644

> --- a/drivers/usb/serial/ftdi_sio.c

> +++ b/drivers/usb/serial/ftdi_sio.c

> @@ -95,7 +95,9 @@ static int   ftdi_jtag_probe(struct usb_serial *serial);

>  static int   ftdi_NDI_device_setup(struct usb_serial *serial);

>  static int   ftdi_stmclite_probe(struct usb_serial *serial);

>  static int   ftdi_8u2232c_probe(struct usb_serial *serial);

> +#if !IS_ENABLED(CONFIG_IR_UIRT)

>  static void  ftdi_USB_UIRT_setup(struct ftdi_private *priv);

> +#endif

>  static void  ftdi_HE_TIRA1_setup(struct ftdi_private *priv);

>  

>  static const struct ftdi_sio_quirk ftdi_jtag_quirk = {

> @@ -106,9 +108,11 @@ static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = {

>  	.probe	= ftdi_NDI_device_setup,

>  };

>  

> +#if !IS_ENABLED(CONFIG_IR_UIRT)

>  static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {


Please use __maybe_unused instead of sprinkling ifdefs throughout the
driver.

>  	.port_probe = ftdi_USB_UIRT_setup,

>  };

> +#endif

>  

>  static const struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {

>  	.port_probe = ftdi_HE_TIRA1_setup,

> @@ -568,8 +572,10 @@ static const struct usb_device_id id_table_combined[] = {

>  	{ USB_DEVICE(OCT_VID, OCT_DK201_PID) },

>  	{ USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),

>  		.driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },

> +#if !IS_ENABLED(CONFIG_IR_UIRT)

>  	{ USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),

>  		.driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },

> +#endif


This would still be needed.

>  	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },

>  	{ USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },

>  	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },

> @@ -2292,6 +2298,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)

>  	return 0;

>  }

>  

> +#if !IS_ENABLED(CONFIG_IR_UIRT)

>  /* Setup for the USB-UIRT device, which requires hardwired

>   * baudrate (38400 gets mapped to 312500) */

>  /* Called from usbserial:serial_probe */

> @@ -2301,6 +2308,7 @@ static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)

>  	priv->custom_divisor = 77;

>  	priv->force_baud = 38400;

>  }

> +#endif

>  

>  /* Setup for the HE-TIRA1 device, which requires hardwired

>   * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled.  */


Johan
Sean Young May 15, 2021, 9:56 a.m. UTC | #2
On Fri, May 14, 2021 at 01:40:21PM +0200, Johan Hovold wrote:
> On Thu, May 06, 2021 at 01:44:55PM +0100, Sean Young wrote:

> > The USB-UIRT device has its own driver, so blacklist the fdti driver

> > from using it if the driver has been enabled.

> > 

> > Signed-off-by: Sean Young <sean@mess.org>

> > ---

> >  drivers/usb/serial/ftdi_sio.c | 8 ++++++++

> >  1 file changed, 8 insertions(+)

> > 

> > diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c

> > index 542073d2f0dd..2320bda57796 100644

> > --- a/drivers/usb/serial/ftdi_sio.c

> > +++ b/drivers/usb/serial/ftdi_sio.c

> > @@ -95,7 +95,9 @@ static int   ftdi_jtag_probe(struct usb_serial *serial);

> >  static int   ftdi_NDI_device_setup(struct usb_serial *serial);

> >  static int   ftdi_stmclite_probe(struct usb_serial *serial);

> >  static int   ftdi_8u2232c_probe(struct usb_serial *serial);

> > +#if !IS_ENABLED(CONFIG_IR_UIRT)

> >  static void  ftdi_USB_UIRT_setup(struct ftdi_private *priv);

> > +#endif

> >  static void  ftdi_HE_TIRA1_setup(struct ftdi_private *priv);

> >  

> >  static const struct ftdi_sio_quirk ftdi_jtag_quirk = {

> > @@ -106,9 +108,11 @@ static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = {

> >  	.probe	= ftdi_NDI_device_setup,

> >  };

> >  

> > +#if !IS_ENABLED(CONFIG_IR_UIRT)

> >  static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {

> 

> Please use __maybe_unused instead of sprinkling ifdefs throughout the

> driver.


Good point.

> >  	.port_probe = ftdi_USB_UIRT_setup,

> >  };

> > +#endif

> >  

> >  static const struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {

> >  	.port_probe = ftdi_HE_TIRA1_setup,

> > @@ -568,8 +572,10 @@ static const struct usb_device_id id_table_combined[] = {

> >  	{ USB_DEVICE(OCT_VID, OCT_DK201_PID) },

> >  	{ USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),

> >  		.driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },

> > +#if !IS_ENABLED(CONFIG_IR_UIRT)

> >  	{ USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),

> >  		.driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },

> > +#endif

> 

> This would still be needed.


I agree having the quirk in place would be useful, but if vid/pid is listed
in the id_table then both uirt and ftdi_sio have the same vid/pid listed,
which is not a great idea. How can this work?

Thanks

> 

> >  	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },

> >  	{ USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },

> >  	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },

> > @@ -2292,6 +2298,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)

> >  	return 0;

> >  }

> >  

> > +#if !IS_ENABLED(CONFIG_IR_UIRT)

> >  /* Setup for the USB-UIRT device, which requires hardwired

> >   * baudrate (38400 gets mapped to 312500) */

> >  /* Called from usbserial:serial_probe */

> > @@ -2301,6 +2308,7 @@ static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)

> >  	priv->custom_divisor = 77;

> >  	priv->force_baud = 38400;

> >  }

> > +#endif

> >  

> >  /* Setup for the HE-TIRA1 device, which requires hardwired

> >   * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled.  */

> 

> Johan
Johan Hovold May 17, 2021, 9:40 a.m. UTC | #3
On Sat, May 15, 2021 at 10:56:28AM +0100, Sean Young wrote:
> On Fri, May 14, 2021 at 01:40:21PM +0200, Johan Hovold wrote:

> > On Thu, May 06, 2021 at 01:44:55PM +0100, Sean Young wrote:

> > > The USB-UIRT device has its own driver, so blacklist the fdti driver

> > > from using it if the driver has been enabled.

> > > 

> > > Signed-off-by: Sean Young <sean@mess.org>

> > > ---

> > >  drivers/usb/serial/ftdi_sio.c | 8 ++++++++

> > >  1 file changed, 8 insertions(+)

> > > 

> > > diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c

> > > index 542073d2f0dd..2320bda57796 100644

> > > --- a/drivers/usb/serial/ftdi_sio.c

> > > +++ b/drivers/usb/serial/ftdi_sio.c

> > > @@ -95,7 +95,9 @@ static int   ftdi_jtag_probe(struct usb_serial *serial);

> > >  static int   ftdi_NDI_device_setup(struct usb_serial *serial);

> > >  static int   ftdi_stmclite_probe(struct usb_serial *serial);

> > >  static int   ftdi_8u2232c_probe(struct usb_serial *serial);

> > > +#if !IS_ENABLED(CONFIG_IR_UIRT)

> > >  static void  ftdi_USB_UIRT_setup(struct ftdi_private *priv);

> > > +#endif

> > >  static void  ftdi_HE_TIRA1_setup(struct ftdi_private *priv);

> > >  

> > >  static const struct ftdi_sio_quirk ftdi_jtag_quirk = {

> > > @@ -106,9 +108,11 @@ static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = {

> > >  	.probe	= ftdi_NDI_device_setup,

> > >  };

> > >  

> > > +#if !IS_ENABLED(CONFIG_IR_UIRT)

> > >  static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {

> > 

> > Please use __maybe_unused instead of sprinkling ifdefs throughout the

> > driver.

> 

> Good point.

> 

> > >  	.port_probe = ftdi_USB_UIRT_setup,

> > >  };

> > > +#endif

> > >  

> > >  static const struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {

> > >  	.port_probe = ftdi_HE_TIRA1_setup,

> > > @@ -568,8 +572,10 @@ static const struct usb_device_id id_table_combined[] = {

> > >  	{ USB_DEVICE(OCT_VID, OCT_DK201_PID) },

> > >  	{ USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),

> > >  		.driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },

> > > +#if !IS_ENABLED(CONFIG_IR_UIRT)

> > >  	{ USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),

> > >  		.driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },

> > > +#endif

> > 

> > This would still be needed.

> 

> I agree having the quirk in place would be useful, but if vid/pid is listed

> in the id_table then both uirt and ftdi_sio have the same vid/pid listed,

> which is not a great idea. How can this work?


Sorry if I was being unclear; I meant that this ifdef would still be
needed.

Johan
diff mbox series

Patch

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 542073d2f0dd..2320bda57796 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -95,7 +95,9 @@  static int   ftdi_jtag_probe(struct usb_serial *serial);
 static int   ftdi_NDI_device_setup(struct usb_serial *serial);
 static int   ftdi_stmclite_probe(struct usb_serial *serial);
 static int   ftdi_8u2232c_probe(struct usb_serial *serial);
+#if !IS_ENABLED(CONFIG_IR_UIRT)
 static void  ftdi_USB_UIRT_setup(struct ftdi_private *priv);
+#endif
 static void  ftdi_HE_TIRA1_setup(struct ftdi_private *priv);
 
 static const struct ftdi_sio_quirk ftdi_jtag_quirk = {
@@ -106,9 +108,11 @@  static const struct ftdi_sio_quirk ftdi_NDI_device_quirk = {
 	.probe	= ftdi_NDI_device_setup,
 };
 
+#if !IS_ENABLED(CONFIG_IR_UIRT)
 static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
 	.port_probe = ftdi_USB_UIRT_setup,
 };
+#endif
 
 static const struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {
 	.port_probe = ftdi_HE_TIRA1_setup,
@@ -568,8 +572,10 @@  static const struct usb_device_id id_table_combined[] = {
 	{ USB_DEVICE(OCT_VID, OCT_DK201_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
+#if !IS_ENABLED(CONFIG_IR_UIRT)
 	{ USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },
+#endif
 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },
 	{ USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
 	{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
@@ -2292,6 +2298,7 @@  static int ftdi_sio_port_probe(struct usb_serial_port *port)
 	return 0;
 }
 
+#if !IS_ENABLED(CONFIG_IR_UIRT)
 /* Setup for the USB-UIRT device, which requires hardwired
  * baudrate (38400 gets mapped to 312500) */
 /* Called from usbserial:serial_probe */
@@ -2301,6 +2308,7 @@  static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
 	priv->custom_divisor = 77;
 	priv->force_baud = 38400;
 }
+#endif
 
 /* Setup for the HE-TIRA1 device, which requires hardwired
  * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled.  */