aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2016-12-18 04:19:28 -0500
committerJohan Hovold <johan@kernel.org>2017-01-02 04:31:08 -0500
commit427157631648c980e8bba4d73a21508b9e1a47ec (patch)
tree7a72996439dd2c52ba443262a4af93628ed151d9 /drivers/usb
parent0c744ea4f77d72b3dcebb7a8f2684633ec79be88 (diff)
USB: serial: f81534: detect errors from f81534_logic_to_phy_port()
With gcc 4.1.2: drivers/usb/serial/f81534.c: In function ‘f81534_port_probe’: drivers/usb/serial/f81534.c:1250: warning: comparison is always false due to limited range of data type f81534_logic_to_phy_port() may return a negative error value, which is ignored by assigning it to u8 f81534_port_private.phy_num. Use an intermediate variable of type int to fix this. While at it, forward the actual error code instead of converting it to -ENODEV, and drop the useless check for F81534_NUM_PORT, as the callee always returns a valid port number in case of success. Fixes: 0c9bd6004d258d46 ("USB: serial: add Fintek F81532/534 driver") Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/f81534.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 8282a6a18fee..22f23a429a95 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -1237,6 +1237,7 @@ static int f81534_attach(struct usb_serial *serial)
1237static int f81534_port_probe(struct usb_serial_port *port) 1237static int f81534_port_probe(struct usb_serial_port *port)
1238{ 1238{
1239 struct f81534_port_private *port_priv; 1239 struct f81534_port_private *port_priv;
1240 int ret;
1240 1241
1241 port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL); 1242 port_priv = devm_kzalloc(&port->dev, sizeof(*port_priv), GFP_KERNEL);
1242 if (!port_priv) 1243 if (!port_priv)
@@ -1246,10 +1247,11 @@ static int f81534_port_probe(struct usb_serial_port *port)
1246 mutex_init(&port_priv->mcr_mutex); 1247 mutex_init(&port_priv->mcr_mutex);
1247 1248
1248 /* Assign logic-to-phy mapping */ 1249 /* Assign logic-to-phy mapping */
1249 port_priv->phy_num = f81534_logic_to_phy_port(port->serial, port); 1250 ret = f81534_logic_to_phy_port(port->serial, port);
1250 if (port_priv->phy_num < 0 || port_priv->phy_num >= F81534_NUM_PORT) 1251 if (ret < 0)
1251 return -ENODEV; 1252 return ret;
1252 1253
1254 port_priv->phy_num = ret;
1253 usb_set_serial_port_data(port, port_priv); 1255 usb_set_serial_port_data(port, port_priv);
1254 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__, 1256 dev_dbg(&port->dev, "%s: port_number: %d, phy_num: %d\n", __func__,
1255 port->port_number, port_priv->phy_num); 1257 port->port_number, port_priv->phy_num);