Commit cb2e5ee8 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'usb-6.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are a number of small USB driver fixes for reported issues for
  6.11-rc3. Included in here are:

   - usb serial driver MODULE_DESCRIPTION() updates

   - usb serial driver fixes

   - typec driver fixes

   - usb-ip driver fix

   - gadget driver fixes

   - dt binding update

  All of these have been in linux-next with no reported issues"

* tag 'usb-6.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  usb: typec: ucsi: Fix a deadlock in ucsi_send_command_common()
  usb: typec: tcpm: avoid sink goto SNK_UNATTACHED state if not received source capability message
  usb: gadget: f_fs: pull out f->disable() from ffs_func_set_alt()
  usb: gadget: f_fs: restore ffs_func_disable() functionality
  USB: serial: debug: do not echo input by default
  usb: typec: tipd: Delete extra semi-colon
  usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch()
  usb: gadget: u_serial: Set start_delayed during suspend
  usb: typec: tcpci: Fix error code in tcpci_check_std_output_cap()
  usb: typec: fsa4480: Check if the chip is really there
  usb: gadget: core: Check for unset descriptor
  usb: vhci-hcd: Do not drop references before new references are gained
  usb: gadget: u_audio: Check return codes from usb_ep_enable and config_ep_by_speed.
  usb: gadget: midi2: Fix the response for FB info with block 0xff
  dt-bindings: usb: microchip,usb2514: Add USB2517 compatible
  USB: serial: garmin_gps: use struct_size() to allocate pkt
  USB: serial: garmin_gps: annotate struct garmin_packet with __counted_by
  USB: serial: add missing MODULE_DESCRIPTION() macros
  USB: serial: spcp8x5: remove unused struct 'spcp8x5_usb_ctrl_arg'
parents 42b34a8d 65ba8cef
...@@ -18,6 +18,7 @@ properties: ...@@ -18,6 +18,7 @@ properties:
- usb424,2412 - usb424,2412
- usb424,2417 - usb424,2417
- usb424,2514 - usb424,2514
- usb424,2517
reg: true reg: true
......
...@@ -3734,11 +3734,9 @@ static int ffs_func_set_alt(struct usb_function *f, ...@@ -3734,11 +3734,9 @@ static int ffs_func_set_alt(struct usb_function *f,
if (alt > MAX_ALT_SETTINGS) if (alt > MAX_ALT_SETTINGS)
return -EINVAL; return -EINVAL;
if (alt != (unsigned)-1) { intf = ffs_func_revmap_intf(func, interface);
intf = ffs_func_revmap_intf(func, interface); if (intf < 0)
if (intf < 0) return intf;
return intf;
}
if (ffs->func) if (ffs->func)
ffs_func_eps_disable(ffs->func); ffs_func_eps_disable(ffs->func);
...@@ -3753,12 +3751,6 @@ static int ffs_func_set_alt(struct usb_function *f, ...@@ -3753,12 +3751,6 @@ static int ffs_func_set_alt(struct usb_function *f,
if (ffs->state != FFS_ACTIVE) if (ffs->state != FFS_ACTIVE)
return -ENODEV; return -ENODEV;
if (alt == (unsigned)-1) {
ffs->func = NULL;
ffs_event_add(ffs, FUNCTIONFS_DISABLE);
return 0;
}
ffs->func = func; ffs->func = func;
ret = ffs_func_eps_enable(func); ret = ffs_func_eps_enable(func);
if (ret >= 0) { if (ret >= 0) {
...@@ -3770,7 +3762,23 @@ static int ffs_func_set_alt(struct usb_function *f, ...@@ -3770,7 +3762,23 @@ static int ffs_func_set_alt(struct usb_function *f,
static void ffs_func_disable(struct usb_function *f) static void ffs_func_disable(struct usb_function *f)
{ {
ffs_func_set_alt(f, 0, (unsigned)-1); struct ffs_function *func = ffs_func_from_usb(f);
struct ffs_data *ffs = func->ffs;
if (ffs->func)
ffs_func_eps_disable(ffs->func);
if (ffs->state == FFS_DEACTIVATED) {
ffs->state = FFS_CLOSING;
INIT_WORK(&ffs->reset_work, ffs_reset_work);
schedule_work(&ffs->reset_work);
return;
}
if (ffs->state == FFS_ACTIVE) {
ffs->func = NULL;
ffs_event_add(ffs, FUNCTIONFS_DISABLE);
}
} }
static int ffs_func_setup(struct usb_function *f, static int ffs_func_setup(struct usb_function *f,
......
...@@ -642,12 +642,21 @@ static void process_ump_stream_msg(struct f_midi2_ep *ep, const u32 *data) ...@@ -642,12 +642,21 @@ static void process_ump_stream_msg(struct f_midi2_ep *ep, const u32 *data)
if (format) if (format)
return; // invalid return; // invalid
blk = (*data >> 8) & 0xff; blk = (*data >> 8) & 0xff;
if (blk >= ep->num_blks) if (blk == 0xff) {
return; /* inquiry for all blocks */
if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO) for (blk = 0; blk < ep->num_blks; blk++) {
reply_ump_stream_fb_info(ep, blk); if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO)
if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME) reply_ump_stream_fb_info(ep, blk);
reply_ump_stream_fb_name(ep, blk); if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME)
reply_ump_stream_fb_name(ep, blk);
}
} else if (blk < ep->num_blks) {
/* only the specified block */
if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO)
reply_ump_stream_fb_info(ep, blk);
if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME)
reply_ump_stream_fb_name(ep, blk);
}
return; return;
} }
} }
......
...@@ -592,16 +592,25 @@ int u_audio_start_capture(struct g_audio *audio_dev) ...@@ -592,16 +592,25 @@ int u_audio_start_capture(struct g_audio *audio_dev)
struct usb_ep *ep, *ep_fback; struct usb_ep *ep, *ep_fback;
struct uac_rtd_params *prm; struct uac_rtd_params *prm;
struct uac_params *params = &audio_dev->params; struct uac_params *params = &audio_dev->params;
int req_len, i; int req_len, i, ret;
prm = &uac->c_prm; prm = &uac->c_prm;
dev_dbg(dev, "start capture with rate %d\n", prm->srate); dev_dbg(dev, "start capture with rate %d\n", prm->srate);
ep = audio_dev->out_ep; ep = audio_dev->out_ep;
config_ep_by_speed(gadget, &audio_dev->func, ep); ret = config_ep_by_speed(gadget, &audio_dev->func, ep);
if (ret < 0) {
dev_err(dev, "config_ep_by_speed for out_ep failed (%d)\n", ret);
return ret;
}
req_len = ep->maxpacket; req_len = ep->maxpacket;
prm->ep_enabled = true; prm->ep_enabled = true;
usb_ep_enable(ep); ret = usb_ep_enable(ep);
if (ret < 0) {
dev_err(dev, "usb_ep_enable failed for out_ep (%d)\n", ret);
return ret;
}
for (i = 0; i < params->req_number; i++) { for (i = 0; i < params->req_number; i++) {
if (!prm->reqs[i]) { if (!prm->reqs[i]) {
...@@ -629,9 +638,18 @@ int u_audio_start_capture(struct g_audio *audio_dev) ...@@ -629,9 +638,18 @@ int u_audio_start_capture(struct g_audio *audio_dev)
return 0; return 0;
/* Setup feedback endpoint */ /* Setup feedback endpoint */
config_ep_by_speed(gadget, &audio_dev->func, ep_fback); ret = config_ep_by_speed(gadget, &audio_dev->func, ep_fback);
if (ret < 0) {
dev_err(dev, "config_ep_by_speed in_ep_fback failed (%d)\n", ret);
return ret; // TODO: Clean up out_ep
}
prm->fb_ep_enabled = true; prm->fb_ep_enabled = true;
usb_ep_enable(ep_fback); ret = usb_ep_enable(ep_fback);
if (ret < 0) {
dev_err(dev, "usb_ep_enable failed for in_ep_fback (%d)\n", ret);
return ret; // TODO: Clean up out_ep
}
req_len = ep_fback->maxpacket; req_len = ep_fback->maxpacket;
req_fback = usb_ep_alloc_request(ep_fback, GFP_ATOMIC); req_fback = usb_ep_alloc_request(ep_fback, GFP_ATOMIC);
...@@ -687,13 +705,17 @@ int u_audio_start_playback(struct g_audio *audio_dev) ...@@ -687,13 +705,17 @@ int u_audio_start_playback(struct g_audio *audio_dev)
struct uac_params *params = &audio_dev->params; struct uac_params *params = &audio_dev->params;
unsigned int factor; unsigned int factor;
const struct usb_endpoint_descriptor *ep_desc; const struct usb_endpoint_descriptor *ep_desc;
int req_len, i; int req_len, i, ret;
unsigned int p_pktsize; unsigned int p_pktsize;
prm = &uac->p_prm; prm = &uac->p_prm;
dev_dbg(dev, "start playback with rate %d\n", prm->srate); dev_dbg(dev, "start playback with rate %d\n", prm->srate);
ep = audio_dev->in_ep; ep = audio_dev->in_ep;
config_ep_by_speed(gadget, &audio_dev->func, ep); ret = config_ep_by_speed(gadget, &audio_dev->func, ep);
if (ret < 0) {
dev_err(dev, "config_ep_by_speed for in_ep failed (%d)\n", ret);
return ret;
}
ep_desc = ep->desc; ep_desc = ep->desc;
/* /*
...@@ -720,7 +742,11 @@ int u_audio_start_playback(struct g_audio *audio_dev) ...@@ -720,7 +742,11 @@ int u_audio_start_playback(struct g_audio *audio_dev)
uac->p_residue_mil = 0; uac->p_residue_mil = 0;
prm->ep_enabled = true; prm->ep_enabled = true;
usb_ep_enable(ep); ret = usb_ep_enable(ep);
if (ret < 0) {
dev_err(dev, "usb_ep_enable failed for in_ep (%d)\n", ret);
return ret;
}
for (i = 0; i < params->req_number; i++) { for (i = 0; i < params->req_number; i++) {
if (!prm->reqs[i]) { if (!prm->reqs[i]) {
......
...@@ -1441,6 +1441,7 @@ void gserial_suspend(struct gserial *gser) ...@@ -1441,6 +1441,7 @@ void gserial_suspend(struct gserial *gser)
spin_lock(&port->port_lock); spin_lock(&port->port_lock);
spin_unlock(&serial_port_lock); spin_unlock(&serial_port_lock);
port->suspended = true; port->suspended = true;
port->start_delayed = true;
spin_unlock_irqrestore(&port->port_lock, flags); spin_unlock_irqrestore(&port->port_lock, flags);
} }
EXPORT_SYMBOL_GPL(gserial_suspend); EXPORT_SYMBOL_GPL(gserial_suspend);
......
...@@ -118,12 +118,10 @@ int usb_ep_enable(struct usb_ep *ep) ...@@ -118,12 +118,10 @@ int usb_ep_enable(struct usb_ep *ep)
goto out; goto out;
/* UDC drivers can't handle endpoints with maxpacket size 0 */ /* UDC drivers can't handle endpoints with maxpacket size 0 */
if (usb_endpoint_maxp(ep->desc) == 0) { if (!ep->desc || usb_endpoint_maxp(ep->desc) == 0) {
/* WARN_ONCE(1, "%s: ep%d (%s) has %s\n", __func__, ep->address, ep->name,
* We should log an error message here, but we can't call (!ep->desc) ? "NULL descriptor" : "maxpacket 0");
* dev_err() because there's no way to find the gadget
* given only ep.
*/
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
......
...@@ -863,4 +863,5 @@ static struct usb_serial_driver * const serial_drivers[] = { ...@@ -863,4 +863,5 @@ static struct usb_serial_driver * const serial_drivers[] = {
module_usb_serial_driver(serial_drivers, id_table); module_usb_serial_driver(serial_drivers, id_table);
MODULE_DESCRIPTION("Winchiphead CH341 USB Serial driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -104,7 +104,7 @@ struct garmin_packet { ...@@ -104,7 +104,7 @@ struct garmin_packet {
int seq; int seq;
/* the real size of the data array, always > 0 */ /* the real size of the data array, always > 0 */
int size; int size;
__u8 data[]; __u8 data[] __counted_by(size);
}; };
/* structure used to keep the current state of the driver */ /* structure used to keep the current state of the driver */
...@@ -267,8 +267,7 @@ static int pkt_add(struct garmin_data *garmin_data_p, ...@@ -267,8 +267,7 @@ static int pkt_add(struct garmin_data *garmin_data_p,
/* process only packets containing data ... */ /* process only packets containing data ... */
if (data_length) { if (data_length) {
pkt = kmalloc(sizeof(struct garmin_packet)+data_length, pkt = kmalloc(struct_size(pkt, data, data_length), GFP_ATOMIC);
GFP_ATOMIC);
if (!pkt) if (!pkt)
return 0; return 0;
......
...@@ -1315,4 +1315,5 @@ module_usb_serial_driver(serial_drivers, mxuport_idtable); ...@@ -1315,4 +1315,5 @@ module_usb_serial_driver(serial_drivers, mxuport_idtable);
MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>"); MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
MODULE_AUTHOR("<support@moxa.com>"); MODULE_AUTHOR("<support@moxa.com>");
MODULE_DESCRIPTION("Moxa UPORT USB Serial driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -112,4 +112,5 @@ static struct usb_serial_driver * const serial_drivers[] = { ...@@ -112,4 +112,5 @@ static struct usb_serial_driver * const serial_drivers[] = {
module_usb_serial_driver(serial_drivers, id_table); module_usb_serial_driver(serial_drivers, id_table);
MODULE_DESCRIPTION("Navman USB Serial driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -84,4 +84,5 @@ static struct usb_serial_driver * const serial_drivers[] = { ...@@ -84,4 +84,5 @@ static struct usb_serial_driver * const serial_drivers[] = {
}; };
module_usb_serial_driver(serial_drivers, id_table); module_usb_serial_driver(serial_drivers, id_table);
MODULE_DESCRIPTION("Qualcomm USB Auxiliary Serial Port driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -49,16 +49,6 @@ static const struct usb_device_id id_table[] = { ...@@ -49,16 +49,6 @@ static const struct usb_device_id id_table[] = {
}; };
MODULE_DEVICE_TABLE(usb, id_table); MODULE_DEVICE_TABLE(usb, id_table);
struct spcp8x5_usb_ctrl_arg {
u8 type;
u8 cmd;
u8 cmd_type;
u16 value;
u16 index;
u16 length;
};
/* spcp8x5 spec register define */ /* spcp8x5 spec register define */
#define MCR_CONTROL_LINE_RTS 0x02 #define MCR_CONTROL_LINE_RTS 0x02
#define MCR_CONTROL_LINE_DTR 0x01 #define MCR_CONTROL_LINE_DTR 0x01
......
...@@ -190,4 +190,5 @@ static struct usb_serial_driver * const serial_drivers[] = { ...@@ -190,4 +190,5 @@ static struct usb_serial_driver * const serial_drivers[] = {
module_usb_serial_driver(serial_drivers, id_table); module_usb_serial_driver(serial_drivers, id_table);
MODULE_DESCRIPTION("Symbol USB barcode to serial driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -163,4 +163,5 @@ static const struct usb_device_id id_table[] = { ...@@ -163,4 +163,5 @@ static const struct usb_device_id id_table[] = {
MODULE_DEVICE_TABLE(usb, id_table); MODULE_DEVICE_TABLE(usb, id_table);
module_usb_serial_driver(serial_drivers, id_table); module_usb_serial_driver(serial_drivers, id_table);
MODULE_DESCRIPTION("USB Serial 'Simple' driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -76,6 +76,11 @@ static void usb_debug_process_read_urb(struct urb *urb) ...@@ -76,6 +76,11 @@ static void usb_debug_process_read_urb(struct urb *urb)
usb_serial_generic_process_read_urb(urb); usb_serial_generic_process_read_urb(urb);
} }
static void usb_debug_init_termios(struct tty_struct *tty)
{
tty->termios.c_lflag &= ~(ECHO | ECHONL);
}
static struct usb_serial_driver debug_device = { static struct usb_serial_driver debug_device = {
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -85,6 +90,7 @@ static struct usb_serial_driver debug_device = { ...@@ -85,6 +90,7 @@ static struct usb_serial_driver debug_device = {
.num_ports = 1, .num_ports = 1,
.bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE, .bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE,
.break_ctl = usb_debug_break_ctl, .break_ctl = usb_debug_break_ctl,
.init_termios = usb_debug_init_termios,
.process_read_urb = usb_debug_process_read_urb, .process_read_urb = usb_debug_process_read_urb,
}; };
...@@ -96,6 +102,7 @@ static struct usb_serial_driver dbc_device = { ...@@ -96,6 +102,7 @@ static struct usb_serial_driver dbc_device = {
.id_table = dbc_id_table, .id_table = dbc_id_table,
.num_ports = 1, .num_ports = 1,
.break_ctl = usb_debug_break_ctl, .break_ctl = usb_debug_break_ctl,
.init_termios = usb_debug_init_termios,
.process_read_urb = usb_debug_process_read_urb, .process_read_urb = usb_debug_process_read_urb,
}; };
...@@ -104,4 +111,5 @@ static struct usb_serial_driver * const serial_drivers[] = { ...@@ -104,4 +111,5 @@ static struct usb_serial_driver * const serial_drivers[] = {
}; };
module_usb_serial_driver(serial_drivers, id_table_combined); module_usb_serial_driver(serial_drivers, id_table_combined);
MODULE_DESCRIPTION("USB Debug cable driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
#include <linux/usb/typec_dp.h> #include <linux/usb/typec_dp.h>
#include <linux/usb/typec_mux.h> #include <linux/usb/typec_mux.h>
#define FSA4480_DEVICE_ID 0x00
#define FSA4480_DEVICE_ID_VENDOR_ID GENMASK(7, 6)
#define FSA4480_DEVICE_ID_VERSION_ID GENMASK(5, 3)
#define FSA4480_DEVICE_ID_REV_ID GENMASK(2, 0)
#define FSA4480_SWITCH_ENABLE 0x04 #define FSA4480_SWITCH_ENABLE 0x04
#define FSA4480_SWITCH_SELECT 0x05 #define FSA4480_SWITCH_SELECT 0x05
#define FSA4480_SWITCH_STATUS1 0x07 #define FSA4480_SWITCH_STATUS1 0x07
...@@ -251,6 +255,7 @@ static int fsa4480_probe(struct i2c_client *client) ...@@ -251,6 +255,7 @@ static int fsa4480_probe(struct i2c_client *client)
struct typec_switch_desc sw_desc = { }; struct typec_switch_desc sw_desc = { };
struct typec_mux_desc mux_desc = { }; struct typec_mux_desc mux_desc = { };
struct fsa4480 *fsa; struct fsa4480 *fsa;
int val = 0;
int ret; int ret;
fsa = devm_kzalloc(dev, sizeof(*fsa), GFP_KERNEL); fsa = devm_kzalloc(dev, sizeof(*fsa), GFP_KERNEL);
...@@ -268,6 +273,15 @@ static int fsa4480_probe(struct i2c_client *client) ...@@ -268,6 +273,15 @@ static int fsa4480_probe(struct i2c_client *client)
if (IS_ERR(fsa->regmap)) if (IS_ERR(fsa->regmap))
return dev_err_probe(dev, PTR_ERR(fsa->regmap), "failed to initialize regmap\n"); return dev_err_probe(dev, PTR_ERR(fsa->regmap), "failed to initialize regmap\n");
ret = regmap_read(fsa->regmap, FSA4480_DEVICE_ID, &val);
if (ret || !val)
return dev_err_probe(dev, -ENODEV, "FSA4480 not found\n");
dev_dbg(dev, "Found FSA4480 v%lu.%lu (Vendor ID = %lu)\n",
FIELD_GET(FSA4480_DEVICE_ID_VERSION_ID, val),
FIELD_GET(FSA4480_DEVICE_ID_REV_ID, val),
FIELD_GET(FSA4480_DEVICE_ID_VENDOR_ID, val));
/* Safe mode */ /* Safe mode */
fsa->cur_enable = FSA4480_ENABLE_DEVICE | FSA4480_ENABLE_USB; fsa->cur_enable = FSA4480_ENABLE_DEVICE | FSA4480_ENABLE_USB;
fsa->mode = TYPEC_STATE_SAFE; fsa->mode = TYPEC_STATE_SAFE;
......
...@@ -67,7 +67,7 @@ static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val) ...@@ -67,7 +67,7 @@ static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val)
return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u16)); return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u16));
} }
static bool tcpci_check_std_output_cap(struct regmap *regmap, u8 mask) static int tcpci_check_std_output_cap(struct regmap *regmap, u8 mask)
{ {
unsigned int reg; unsigned int reg;
int ret; int ret;
......
...@@ -4515,7 +4515,7 @@ static inline enum tcpm_state hard_reset_state(struct tcpm_port *port) ...@@ -4515,7 +4515,7 @@ static inline enum tcpm_state hard_reset_state(struct tcpm_port *port)
return ERROR_RECOVERY; return ERROR_RECOVERY;
if (port->pwr_role == TYPEC_SOURCE) if (port->pwr_role == TYPEC_SOURCE)
return SRC_UNATTACHED; return SRC_UNATTACHED;
if (port->state == SNK_WAIT_CAPABILITIES) if (port->state == SNK_WAIT_CAPABILITIES_TIMEOUT)
return SNK_READY; return SNK_READY;
return SNK_UNATTACHED; return SNK_UNATTACHED;
} }
......
...@@ -1191,14 +1191,14 @@ static int tps6598x_apply_patch(struct tps6598x *tps) ...@@ -1191,14 +1191,14 @@ static int tps6598x_apply_patch(struct tps6598x *tps)
dev_info(tps->dev, "Firmware update succeeded\n"); dev_info(tps->dev, "Firmware update succeeded\n");
release_fw: release_fw:
release_firmware(fw);
if (ret) { if (ret) {
dev_err(tps->dev, "Failed to write patch %s of %zu bytes\n", dev_err(tps->dev, "Failed to write patch %s of %zu bytes\n",
firmware_name, fw->size); firmware_name, fw->size);
} }
release_firmware(fw);
return ret; return ret;
}; }
static int cd321x_init(struct tps6598x *tps) static int cd321x_init(struct tps6598x *tps)
{ {
......
...@@ -238,13 +238,10 @@ static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd, ...@@ -238,13 +238,10 @@ static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd,
mutex_lock(&ucsi->ppm_lock); mutex_lock(&ucsi->ppm_lock);
ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack); ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack);
if (cci & UCSI_CCI_BUSY) { if (cci & UCSI_CCI_BUSY)
ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false); ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false) ?: -EBUSY;
return ret ? ret : -EBUSY; else if (cci & UCSI_CCI_ERROR)
} ret = ucsi_read_error(ucsi, connector_num);
if (cci & UCSI_CCI_ERROR)
return ucsi_read_error(ucsi, connector_num);
mutex_unlock(&ucsi->ppm_lock); mutex_unlock(&ucsi->ppm_lock);
return ret; return ret;
......
...@@ -745,6 +745,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag ...@@ -745,6 +745,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
* *
*/ */
if (usb_pipedevice(urb->pipe) == 0) { if (usb_pipedevice(urb->pipe) == 0) {
struct usb_device *old;
__u8 type = usb_pipetype(urb->pipe); __u8 type = usb_pipetype(urb->pipe);
struct usb_ctrlrequest *ctrlreq = struct usb_ctrlrequest *ctrlreq =
(struct usb_ctrlrequest *) urb->setup_packet; (struct usb_ctrlrequest *) urb->setup_packet;
...@@ -755,14 +756,15 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag ...@@ -755,14 +756,15 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
goto no_need_xmit; goto no_need_xmit;
} }
old = vdev->udev;
switch (ctrlreq->bRequest) { switch (ctrlreq->bRequest) {
case USB_REQ_SET_ADDRESS: case USB_REQ_SET_ADDRESS:
/* set_address may come when a device is reset */ /* set_address may come when a device is reset */
dev_info(dev, "SetAddress Request (%d) to port %d\n", dev_info(dev, "SetAddress Request (%d) to port %d\n",
ctrlreq->wValue, vdev->rhport); ctrlreq->wValue, vdev->rhport);
usb_put_dev(vdev->udev);
vdev->udev = usb_get_dev(urb->dev); vdev->udev = usb_get_dev(urb->dev);
usb_put_dev(old);
spin_lock(&vdev->ud.lock); spin_lock(&vdev->ud.lock);
vdev->ud.status = VDEV_ST_USED; vdev->ud.status = VDEV_ST_USED;
...@@ -781,8 +783,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag ...@@ -781,8 +783,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
usbip_dbg_vhci_hc( usbip_dbg_vhci_hc(
"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n"); "Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
usb_put_dev(vdev->udev);
vdev->udev = usb_get_dev(urb->dev); vdev->udev = usb_get_dev(urb->dev);
usb_put_dev(old);
goto out; goto out;
default: default:
...@@ -1067,6 +1069,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) ...@@ -1067,6 +1069,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
static void vhci_device_reset(struct usbip_device *ud) static void vhci_device_reset(struct usbip_device *ud)
{ {
struct vhci_device *vdev = container_of(ud, struct vhci_device, ud); struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
struct usb_device *old = vdev->udev;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&ud->lock, flags); spin_lock_irqsave(&ud->lock, flags);
...@@ -1074,8 +1077,8 @@ static void vhci_device_reset(struct usbip_device *ud) ...@@ -1074,8 +1077,8 @@ static void vhci_device_reset(struct usbip_device *ud)
vdev->speed = 0; vdev->speed = 0;
vdev->devid = 0; vdev->devid = 0;
usb_put_dev(vdev->udev);
vdev->udev = NULL; vdev->udev = NULL;
usb_put_dev(old);
if (ud->tcp_socket) { if (ud->tcp_socket) {
sockfd_put(ud->tcp_socket); sockfd_put(ud->tcp_socket);
......
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