Re: USB: serial: optimize sysrq function calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greg KH wrote:
> On Mon, Jun 22, 2009 at 11:32:22AM -0500, Jason Wessel wrote:
>   
>> There is no need to have external function calls for the sysrq
>> functions.  The compiler can inline the sysrq calls such that they are
>> entirely a NOP if CONFIG_MAGIC_SYSRQ is not set.
>>
>> Signed-off-by: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
>> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
>>     
>
> This now doesn't seem needed in Linus's tree due to Alan's changes,
> right?
>
> I've dropped it, if it's still needed, please redo and send it to me.
>
>   

I re-spun the patch.  It is not necessarily "required", but I think it
is a good practice to optimize the usb serial code in the same manner as
the rs232 uart driver code, and of course cutting out two extra kernel
exports and a level of extra function calls.

If you would prefer to keep it the way it is, let me know, because I
have a change set that stacks on top of this, for processing the sysrq
with a tasklet.

Thanks,
Jason.
From: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
Date: Wed, 17 Jun 2009 14:00:06 -0500
Subject: [PATCH] usb-serial: optimize sysrq function calls

There is no need to have external function calls for the sysrq
functions.  The compiler can inline the sysrq calls such that they are
entirely a NOP if CONFIG_MAGIC_SYSRQ is not set.

Signed-off-by: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
---
 drivers/usb/serial/generic.c |   26 --------------------------
 include/linux/usb/serial.h   |   34 +++++++++++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 31 deletions(-)

--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -534,32 +534,6 @@ void usb_serial_generic_unthrottle(struc
 	}
 }
 
-int usb_serial_handle_sysrq_char(struct tty_struct *tty,
-			struct usb_serial_port *port, unsigned int ch)
-{
-	if (port->sysrq && port->console) {
-		if (ch && time_before(jiffies, port->sysrq)) {
-			handle_sysrq(ch, tty);
-			port->sysrq = 0;
-			return 1;
-		}
-		port->sysrq = 0;
-	}
-	return 0;
-}
-EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char);
-
-int usb_serial_handle_break(struct usb_serial_port *port)
-{
-	if (!port->sysrq) {
-		port->sysrq = jiffies + HZ*5;
-		return 1;
-	}
-	port->sysrq = 0;
-	return 0;
-}
-EXPORT_SYMBOL_GPL(usb_serial_handle_break);
-
 void usb_serial_generic_disconnect(struct usb_serial *serial)
 {
 	int i;
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -317,11 +317,6 @@ extern int usb_serial_generic_register(i
 extern void usb_serial_generic_deregister(void);
 extern void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
 						 gfp_t mem_flags);
-extern int usb_serial_handle_sysrq_char(struct tty_struct *tty,
-					struct usb_serial_port *port,
-					unsigned int ch);
-extern int usb_serial_handle_break(struct usb_serial_port *port);
-
 
 extern int usb_serial_bus_register(struct usb_serial_driver *device);
 extern void usb_serial_bus_deregister(struct usb_serial_driver *device);
@@ -330,6 +325,35 @@ extern struct usb_serial_driver usb_seri
 extern struct bus_type usb_serial_bus_type;
 extern struct tty_driver *usb_serial_tty_driver;
 
+static inline int usb_serial_handle_sysrq_char(struct tty_struct *tty,
+					struct usb_serial_port *port,
+					unsigned int ch)
+{
+#ifdef CONFIG_MAGIC_SYSRQ
+	if (port->sysrq && port->console) {
+		if (ch && time_before(jiffies, port->sysrq)) {
+			handle_sysrq(ch, tty);
+			port->sysrq = 0;
+			return 1;
+		}
+		port->sysrq = 0;
+	}
+#endif /* CONFIG_MAGIC_SYSRQ */
+	return 0;
+}
+
+static inline int usb_serial_handle_break(struct usb_serial_port *port)
+{
+#ifdef CONFIG_MAGIC_SYSRQ
+	if (!port->sysrq) {
+		port->sysrq = jiffies + HZ*5;
+		return 1;
+	}
+	port->sysrq = 0;
+#endif /* CONFIG_MAGIC_SYSRQ */
+	return 0;
+}
+
 static inline void usb_serial_debug_data(int debug,
 					 struct device *dev,
 					 const char *function, int size,

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux