Skip to contentSkip to conversation

USB-SERIAL : Changing usb_serial_generic_open prototype

PATCH In review Abhishek Bist 2 participants 4 messages May 30, 2015 – Jun 2, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB-SERIAL : Changing usb_serial_generic_open prototype

While designing a usb to uart converter driver open function I am using usb_serial_generic_open, but wouldn't find need to pass tty as an argument. As it is not performing any task for further significance.
So, This patch proposed a change in usb_serial_generic_open
function prototype which has struct tty_struct as a first argument.

usb_serial_generic_open(struct tty_struct *tty,

	struct usb_serial_port *port);
---
 drivers/usb/serial/ark3116.c         | 2 +-
 drivers/usb/serial/belkin_sa.c       | 2 +-
 drivers/usb/serial/ch341.c           | 2 +-
 drivers/usb/serial/cp210x.c          | 2 +-
 drivers/usb/serial/f81232.c          | 2 +-
 drivers/usb/serial/ftdi_sio.c        | 2 +-
 drivers/usb/serial/generic.c         | 2 +-
 drivers/usb/serial/ipaq.c            | 2 +-
 drivers/usb/serial/ir-usb.c          | 2 +-
 drivers/usb/serial/kl5kusb105.c      | 2 +-
 drivers/usb/serial/omninet.c         | 2 +-
 drivers/usb/serial/opticon.c         | 2 +-
 drivers/usb/serial/pl2303.c          | 2 +-
 drivers/usb/serial/spcp8x5.c         | 2 +-
 drivers/usb/serial/ssu100.c          | 2 +-
 drivers/usb/serial/visor.c           | 2 +-
 drivers/usb/serial/whiteheat.c       | 2 +-
 drivers/usb/serial/wishbone-serial.c | 2 +-
 include/linux/usb/serial.h           | 3 +--
 19 files changed, 19 insertions(+), 20 deletions(-)
drivers/usb/serial/ark3116.c +1 -1
index 1532cde..663297a 100644
@@ -361,7 +361,7 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
 	if (buf == NULL)
 		return -ENOMEM;
 
-	result = usb_serial_generic_open(tty, port);
+	result = usb_serial_generic_open(port);
 	if (result) {
 		dev_dbg(&port->dev,
 			"%s - usb_serial_generic_open failed: %d\n",
drivers/usb/serial/belkin_sa.c +1 -1
index 15bc718..1925e1b 100644
@@ -159,7 +159,7 @@ static int belkin_sa_open(struct tty_struct *tty,
 		return retval;
 	}
 
-	retval = usb_serial_generic_open(tty, port);
+	retval = usb_serial_generic_open(port);
 	if (retval)
 		usb_kill_urb(port->interrupt_in_urb);
 
drivers/usb/serial/ch341.c +1 -1
index c73808f..6893e65 100644
@@ -328,7 +328,7 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
 		goto out;
 	}
 
-	r = usb_serial_generic_open(tty, port);
+	r = usb_serial_generic_open(port);
 
 out:	return r;
 }
drivers/usb/serial/cp210x.c +1 -1
index 84ce2d7..95fb901 100644
@@ -467,7 +467,7 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
 	if (tty)
 		cp210x_change_speed(tty, port, NULL);
 
-	return usb_serial_generic_open(tty, port);
+	return usb_serial_generic_open(port);
 }
 
 static void cp210x_close(struct usb_serial_port *port)
drivers/usb/serial/f81232.c +1 -1
index 972f5a5..ad89623 100644
@@ -549,7 +549,7 @@ static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
 		return result;
 	}
 
-	result = usb_serial_generic_open(tty, port);
+	result = usb_serial_generic_open(port);
 	if (result) {
 		usb_kill_urb(port->interrupt_in_urb);
 		return result;
drivers/usb/serial/ftdi_sio.c +1 -1
index 8eb68a3..9079b61 100644
@@ -1947,7 +1947,7 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
 	if (tty)
 		ftdi_set_termios(tty, port, NULL);
 
-	return usb_serial_generic_open(tty, port);
+	return usb_serial_generic_open(port);
 }
 
 static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
drivers/usb/serial/generic.c +1 -1
index 54e170d..5917dea 100644
@@ -77,7 +77,7 @@ void usb_serial_generic_deregister(void)
 #endif
 }
 
-int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port)
+int usb_serial_generic_open(struct usb_serial_port *port)
 {
 	int result = 0;
 	unsigned long flags;
drivers/usb/serial/ipaq.c +1 -1
index f51a5d5..b0e50cf 100644
@@ -546,7 +546,7 @@ static int ipaq_open(struct tty_struct *tty,
 		return result;
 	}
 
-	return usb_serial_generic_open(tty, port);
+	return usb_serial_generic_open(port);
 }
 
 static int ipaq_calc_num_ports(struct usb_serial *serial)
drivers/usb/serial/ir-usb.c +1 -1
index 73956d4..718c3ba 100644
@@ -260,7 +260,7 @@ static int ir_open(struct tty_struct *tty, struct usb_serial_port *port)
 		port->write_urbs[i]->transfer_flags = URB_ZERO_PACKET;
 
 	/* Start reading from the device */
-	return usb_serial_generic_open(tty, port);
+	return usb_serial_generic_open(port);
 }
 
 static int ir_prepare_write_buffer(struct usb_serial_port *port,
drivers/usb/serial/kl5kusb105.c +1 -1
index e020ad2..06e2606 100644
@@ -293,7 +293,7 @@ static int  klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
 	spin_unlock_irqrestore(&priv->lock, flags);
 
 	/* READ_ON and urb submission */
-	rc = usb_serial_generic_open(tty, port);
+	rc = usb_serial_generic_open(port);
 	if (rc) {
 		retval = rc;
 		goto exit;
drivers/usb/serial/omninet.c +1 -1
index f6c6900..32146ac 100644
@@ -135,7 +135,7 @@ static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port)
 	wport = serial->port[1];
 	tty_port_tty_set(&wport->port, tty);
 
-	return usb_serial_generic_open(tty, port);
+	return usb_serial_generic_open(port);
 }
 
 #define OMNINET_HEADERLEN	4
drivers/usb/serial/opticon.c +1 -1
index 4b7bfb3..e42a792 100644
@@ -141,7 +141,7 @@ static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port)
 	/* clear the halt status of the endpoint */
 	usb_clear_halt(port->serial->dev, port->read_urb->pipe);
 
-	res = usb_serial_generic_open(tty, port);
+	res = usb_serial_generic_open(port);
 	if (!res)
 		return res;
 
drivers/usb/serial/pl2303.c +1 -1
index 829604d..1b81aac 100644
@@ -645,7 +645,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
 		return result;
 	}
 
-	result = usb_serial_generic_open(tty, port);
+	result = usb_serial_generic_open(port);
 	if (result) {
 		usb_kill_urb(port->interrupt_in_urb);
 		return result;
drivers/usb/serial/spcp8x5.c +1 -1
index ef0dbf0..51eb234 100644
@@ -409,7 +409,7 @@ static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
 	if (tty)
 		spcp8x5_set_termios(tty, port, NULL);
 
-	return usb_serial_generic_open(tty, port);
+	return usb_serial_generic_open(port);
 }
 
 static int spcp8x5_tiocmset(struct tty_struct *tty,
drivers/usb/serial/ssu100.c +1 -1
index 70a098d..bc04ea3 100644
@@ -310,7 +310,7 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port)
 	if (tty)
 		ssu100_set_termios(tty, port, &tty->termios);
 
-	return usb_serial_generic_open(tty, port);
+	return usb_serial_generic_open(port);
 }
 
 static int get_serial_info(struct usb_serial_port *port,
drivers/usb/serial/visor.c +1 -1
index bf2bd40..4ce5631 100644
@@ -235,7 +235,7 @@ static int visor_open(struct tty_struct *tty, struct usb_serial_port *port)
 	}
 
 	/* Start reading from the device */
-	result = usb_serial_generic_open(tty, port);
+	result = usb_serial_generic_open(port);
 	if (result)
 		goto exit;
 
drivers/usb/serial/whiteheat.c +1 -1
index 6c3734d..139e24d 100644
@@ -385,7 +385,7 @@ static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port)
 	usb_clear_halt(port->serial->dev, port->read_urb->pipe);
 	usb_clear_halt(port->serial->dev, port->write_urb->pipe);
 
-	retval = usb_serial_generic_open(tty, port);
+	retval = usb_serial_generic_open(port);
 	if (retval) {
 		firm_close(port);
 		stop_command_port(port->serial);
drivers/usb/serial/wishbone-serial.c +1 -1
index 4fed4a0..07b1ba1 100644
@@ -59,7 +59,7 @@ static int wishbone_serial_open(struct tty_struct *tty,
 		return retval;
 	}
 
-	retval = usb_serial_generic_open(tty, port);
+	retval = usb_serial_generic_open(port);
 	if (retval)
 		usb_gsi_openclose(port, 0);
 
include/linux/usb/serial.h +1 -2
index 704a1ab..c8ed44a 100644
@@ -318,8 +318,7 @@ static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
 /* Functions needed by other parts of the usbserial core */
 extern struct usb_serial_port *usb_serial_port_get_by_minor(unsigned int minor);
 extern void usb_serial_put(struct usb_serial *serial);
-extern int usb_serial_generic_open(struct tty_struct *tty,
-	struct usb_serial_port *port);
+extern int usb_serial_generic_open(struct usb_serial_port *port);
 extern int usb_serial_generic_write_start(struct usb_serial_port *port,
 							gfp_t mem_flags);
 extern int usb_serial_generic_write(struct tty_struct *tty,
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 16 lines · Abhishek Bist

While designing a usb to uart converter driver open function I am using usb_serial_generic_open, but wouldn't find need to pass tty as an argument. As it is not performing any task for further significance.
So, This patch proposed a change in usb_serial_generic_open
function prototype which has struct tty_struct as a first argument.

usb_serial_generic_open(struct tty_struct *tty,

	struct usb_serial_port *port);
include/linux/usb/serial.h +0 -0
index 704a1ab..c8ed44a 100644

include/linux/usb/serial.h static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} · line 324

Quoted 9 lines
include/linux/usb/serial.h +1 -2
@@ -318,8 +318,7 @@ static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
 /* Functions needed by other parts of the usbserial core */
 extern struct usb_serial_port *usb_serial_port_get_by_minor(unsigned int minor);
 extern void usb_serial_put(struct usb_serial *serial);
-extern int usb_serial_generic_open(struct tty_struct *tty,
-	struct usb_serial_port *port);
+extern int usb_serial_generic_open(struct usb_serial_port *port);
 extern int usb_serial_generic_write_start(struct usb_serial_port *port,
 							gfp_t mem_flags);
 extern int usb_serial_generic_write(struct tty_struct *tty,

This does not work as usb_serial_generic_open is the default driver callback.

If you had compile tested your patch you would have seen the following warning:

linux/drivers/usb/serial/usb-serial.c: In function 'usb_serial_operations_init':
linux/drivers/usb/serial/usb-serial.c:1318:19: warning: assignment from incompatible pointer type

    type->function = usb_serial_generic_##function; \
                   ^

linux/drivers/usb/serial/usb-serial.c:1326:2: note: in expansion of macro 'set_to_generic_if_null'
set_to_generic_if_null(device, open);
^

Johan

#2 lore raw

Yes, I gone through this warning. It is because if i want to make this compilation warning free
than i have to change the prototype of a open function pointer described in usb_serial_driver
and changing the prototype over there would affect all the device driver lying in usb-serial
category , which is definitely not recommended.
Anyways i got your point .

Thanks
Abhishek-bist

Quoted 42 lines · Johan Hovold
Quoted 16 lines · Abhishek Bist

While designing a usb to uart converter driver open function I am using usb_serial_generic_open, but wouldn't find need to pass tty as an argument. As it is not performing any task for further significance.
So, This patch proposed a change in usb_serial_generic_open
function prototype which has struct tty_struct as a first argument.

usb_serial_generic_open(struct tty_struct *tty,

      struct usb_serial_port *port);
include/linux/usb/serial.h +0 -0
index 704a1ab..c8ed44a 100644

include/linux/usb/serial.h static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} · line 324

Quoted 9 lines
include/linux/usb/serial.h +1 -2
@@ -318,8 +318,7 @@ static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
 /* Functions needed by other parts of the usbserial core */
 extern struct usb_serial_port *usb_serial_port_get_by_minor(unsigned int minor);
 extern void usb_serial_put(struct usb_serial *serial);
-extern int usb_serial_generic_open(struct tty_struct *tty,
-     struct usb_serial_port *port);
+extern int usb_serial_generic_open(struct usb_serial_port *port);
 extern int usb_serial_generic_write_start(struct usb_serial_port *port,
                                                      gfp_t mem_flags);
 extern int usb_serial_generic_write(struct tty_struct *tty,

This does not work as usb_serial_generic_open is the default driver callback.

If you had compile tested your patch you would have seen the following warning:

linux/drivers/usb/serial/usb-serial.c: In function 'usb_serial_operations_init':
linux/drivers/usb/serial/usb-serial.c:1318:19: warning: assignment from incompatible pointer type

    type->function = usb_serial_generic_##function; \
                   ^

linux/drivers/usb/serial/usb-serial.c:1326:2: note: in expansion of macro 'set_to_generic_if_null'
set_to_generic_if_null(device, open);
^

Johan

maintainer
#3 lore raw

[ Please avoid top-posting. ]

Quoted 7 lines · Abhishek bist

Yes, I gone through this warning. It is because if i want to make this compilation warning free
than i have to change the prototype of a open function pointer described in usb_serial_driver
and changing the prototype over there would affect all the device driver lying in usb-serial
category , which is definitely not recommended.

Exactly. My point was that this change is neither correct or desired. And that you need to pay attention to any compilation warning that your changes cause. ;)

Quoted 1 line

Anyways i got your point .

Johan