Commit 6d3471ed authored by Johan Hovold's avatar Johan Hovold

USB: serial: mos7840: drop paranoid serial checks

Drop the likewise paranoid serial structure sanity checks.

USB serial core sets the serial pointer in the port structures at
initialisation and it is never cleared, and similar for the serial
structure type.
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent ce039bd4
...@@ -446,28 +446,11 @@ static void mos7840_led_activity(struct usb_serial_port *port) ...@@ -446,28 +446,11 @@ static void mos7840_led_activity(struct usb_serial_port *port)
jiffies + msecs_to_jiffies(LED_ON_MS)); jiffies + msecs_to_jiffies(LED_ON_MS));
} }
/* Inline functions to check the sanity of a pointer that is passed to us */
static int mos7840_serial_paranoia_check(struct usb_serial *serial,
const char *function)
{
if (!serial) {
pr_debug("%s - serial == NULL\n", function);
return -1;
}
if (!serial->type) {
pr_debug("%s - serial->type == NULL!\n", function);
return -1;
}
return 0;
}
static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port, static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port,
const char *function) const char *function)
{ {
/* if no port was specified, or it fails a paranoia check */ /* if no port was specified */
if (!port || if (!port) {
mos7840_serial_paranoia_check(port->serial, function)) {
/* then say that we don't have a valid usb_serial thing, /* then say that we don't have a valid usb_serial thing,
* which will end up genrating -ENODEV return values */ * which will end up genrating -ENODEV return values */
return NULL; return NULL;
...@@ -586,9 +569,6 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -586,9 +569,6 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
int status; int status;
struct moschip_port *mos7840_port; struct moschip_port *mos7840_port;
if (mos7840_serial_paranoia_check(serial, __func__))
return -ENODEV;
mos7840_port = mos7840_get_port_private(port); mos7840_port = mos7840_get_port_private(port);
if (mos7840_port == NULL) if (mos7840_port == NULL)
return -ENODEV; return -ENODEV;
...@@ -966,9 +946,6 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -966,9 +946,6 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
/* __u16 Data; */ /* __u16 Data; */
const unsigned char *current_position = data; const unsigned char *current_position = data;
if (mos7840_serial_paranoia_check(serial, __func__))
return -1;
mos7840_port = mos7840_get_port_private(port); mos7840_port = mos7840_get_port_private(port);
if (mos7840_port == NULL) if (mos7840_port == NULL)
return -1; return -1;
...@@ -1248,9 +1225,6 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, ...@@ -1248,9 +1225,6 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
__u16 Data; __u16 Data;
__u16 clk_sel_val; __u16 clk_sel_val;
if (mos7840_serial_paranoia_check(port->serial, __func__))
return -1;
dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudRate); dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudRate);
/* reset clk_uart_sel in spregOffset */ /* reset clk_uart_sel in spregOffset */
if (baudRate > 115200) { if (baudRate > 115200) {
...@@ -1347,9 +1321,6 @@ static void mos7840_change_port_settings(struct tty_struct *tty, ...@@ -1347,9 +1321,6 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
int status; int status;
__u16 Data; __u16 Data;
if (mos7840_serial_paranoia_check(port->serial, __func__))
return;
if (!mos7840_port->open) { if (!mos7840_port->open) {
dev_dbg(&port->dev, "%s - port not opened\n", __func__); dev_dbg(&port->dev, "%s - port not opened\n", __func__);
return; return;
...@@ -1488,14 +1459,9 @@ static void mos7840_set_termios(struct tty_struct *tty, ...@@ -1488,14 +1459,9 @@ static void mos7840_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct usb_serial_port *port,
struct ktermios *old_termios) struct ktermios *old_termios)
{ {
struct usb_serial *serial = port->serial;
int status; int status;
struct moschip_port *mos7840_port; struct moschip_port *mos7840_port;
if (mos7840_serial_paranoia_check(serial, __func__))
return;
mos7840_port = mos7840_get_port_private(port); mos7840_port = mos7840_get_port_private(port);
if (mos7840_port == NULL) if (mos7840_port == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment