Skip to content

Commit

Permalink
Merge tag 'usb-6.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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'
  • Loading branch information
Linus Torvalds committed Aug 11, 2024
2 parents 42b34a8 + 65ba8ce commit cb2e5ee
Show file tree
Hide file tree
Showing 21 changed files with 119 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ properties:
- usb424,2412
- usb424,2417
- usb424,2514
- usb424,2517

reg: true

Expand Down
32 changes: 20 additions & 12 deletions drivers/usb/gadget/function/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3734,11 +3734,9 @@ static int ffs_func_set_alt(struct usb_function *f,
if (alt > MAX_ALT_SETTINGS)
return -EINVAL;

if (alt != (unsigned)-1) {
intf = ffs_func_revmap_intf(func, interface);
if (intf < 0)
return intf;
}
intf = ffs_func_revmap_intf(func, interface);
if (intf < 0)
return intf;

if (ffs->func)
ffs_func_eps_disable(ffs->func);
Expand All @@ -3753,12 +3751,6 @@ static int ffs_func_set_alt(struct usb_function *f,
if (ffs->state != FFS_ACTIVE)
return -ENODEV;

if (alt == (unsigned)-1) {
ffs->func = NULL;
ffs_event_add(ffs, FUNCTIONFS_DISABLE);
return 0;
}

ffs->func = func;
ret = ffs_func_eps_enable(func);
if (ret >= 0) {
Expand All @@ -3770,7 +3762,23 @@ static int ffs_func_set_alt(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,
Expand Down
21 changes: 15 additions & 6 deletions drivers/usb/gadget/function/f_midi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,21 @@ static void process_ump_stream_msg(struct f_midi2_ep *ep, const u32 *data)
if (format)
return; // invalid
blk = (*data >> 8) & 0xff;
if (blk >= ep->num_blks)
return;
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);
if (blk == 0xff) {
/* inquiry for all blocks */
for (blk = 0; blk < ep->num_blks; blk++) {
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);
}
} 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;
}
}
Expand Down
42 changes: 34 additions & 8 deletions drivers/usb/gadget/function/u_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,16 +592,25 @@ int u_audio_start_capture(struct g_audio *audio_dev)
struct usb_ep *ep, *ep_fback;
struct uac_rtd_params *prm;
struct uac_params *params = &audio_dev->params;
int req_len, i;
int req_len, i, ret;

prm = &uac->c_prm;
dev_dbg(dev, "start capture with rate %d\n", prm->srate);
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;

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++) {
if (!prm->reqs[i]) {
Expand Down Expand Up @@ -629,9 +638,18 @@ int u_audio_start_capture(struct g_audio *audio_dev)
return 0;

/* 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;
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_fback = usb_ep_alloc_request(ep_fback, GFP_ATOMIC);
Expand Down Expand Up @@ -687,13 +705,17 @@ int u_audio_start_playback(struct g_audio *audio_dev)
struct uac_params *params = &audio_dev->params;
unsigned int factor;
const struct usb_endpoint_descriptor *ep_desc;
int req_len, i;
int req_len, i, ret;
unsigned int p_pktsize;

prm = &uac->p_prm;
dev_dbg(dev, "start playback with rate %d\n", prm->srate);
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;
/*
Expand All @@ -720,7 +742,11 @@ int u_audio_start_playback(struct g_audio *audio_dev)
uac->p_residue_mil = 0;

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++) {
if (!prm->reqs[i]) {
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/gadget/function/u_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ void gserial_suspend(struct gserial *gser)
spin_lock(&port->port_lock);
spin_unlock(&serial_port_lock);
port->suspended = true;
port->start_delayed = true;
spin_unlock_irqrestore(&port->port_lock, flags);
}
EXPORT_SYMBOL_GPL(gserial_suspend);
Expand Down
10 changes: 4 additions & 6 deletions drivers/usb/gadget/udc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ int usb_ep_enable(struct usb_ep *ep)
goto out;

/* UDC drivers can't handle endpoints with maxpacket size 0 */
if (usb_endpoint_maxp(ep->desc) == 0) {
/*
* We should log an error message here, but we can't call
* dev_err() because there's no way to find the gadget
* given only ep.
*/
if (!ep->desc || usb_endpoint_maxp(ep->desc) == 0) {
WARN_ONCE(1, "%s: ep%d (%s) has %s\n", __func__, ep->address, ep->name,
(!ep->desc) ? "NULL descriptor" : "maxpacket 0");

ret = -EINVAL;
goto out;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/serial/ch341.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,4 +863,5 @@ static struct usb_serial_driver * const serial_drivers[] = {

module_usb_serial_driver(serial_drivers, id_table);

MODULE_DESCRIPTION("Winchiphead CH341 USB Serial driver");
MODULE_LICENSE("GPL v2");
5 changes: 2 additions & 3 deletions drivers/usb/serial/garmin_gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct garmin_packet {
int seq;
/* the real size of the data array, always > 0 */
int size;
__u8 data[];
__u8 data[] __counted_by(size);
};

/* structure used to keep the current state of the driver */
Expand Down Expand Up @@ -267,8 +267,7 @@ static int pkt_add(struct garmin_data *garmin_data_p,

/* process only packets containing data ... */
if (data_length) {
pkt = kmalloc(sizeof(struct garmin_packet)+data_length,
GFP_ATOMIC);
pkt = kmalloc(struct_size(pkt, data, data_length), GFP_ATOMIC);
if (!pkt)
return 0;

Expand Down
1 change: 1 addition & 0 deletions drivers/usb/serial/mxuport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,4 +1315,5 @@ module_usb_serial_driver(serial_drivers, mxuport_idtable);

MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
MODULE_AUTHOR("<support@moxa.com>");
MODULE_DESCRIPTION("Moxa UPORT USB Serial driver");
MODULE_LICENSE("GPL");
1 change: 1 addition & 0 deletions drivers/usb/serial/navman.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ static struct usb_serial_driver * const serial_drivers[] = {

module_usb_serial_driver(serial_drivers, id_table);

MODULE_DESCRIPTION("Navman USB Serial driver");
MODULE_LICENSE("GPL v2");
1 change: 1 addition & 0 deletions drivers/usb/serial/qcaux.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ static struct usb_serial_driver * const serial_drivers[] = {
};

module_usb_serial_driver(serial_drivers, id_table);
MODULE_DESCRIPTION("Qualcomm USB Auxiliary Serial Port driver");
MODULE_LICENSE("GPL v2");
10 changes: 0 additions & 10 deletions drivers/usb/serial/spcp8x5.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ static const struct usb_device_id 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 */
#define MCR_CONTROL_LINE_RTS 0x02
#define MCR_CONTROL_LINE_DTR 0x01
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/serial/symbolserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,5 @@ static struct usb_serial_driver * const serial_drivers[] = {

module_usb_serial_driver(serial_drivers, id_table);

MODULE_DESCRIPTION("Symbol USB barcode to serial driver");
MODULE_LICENSE("GPL v2");
1 change: 1 addition & 0 deletions drivers/usb/serial/usb-serial-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,5 @@ static const struct usb_device_id id_table[] = {
MODULE_DEVICE_TABLE(usb, id_table);

module_usb_serial_driver(serial_drivers, id_table);
MODULE_DESCRIPTION("USB Serial 'Simple' driver");
MODULE_LICENSE("GPL v2");
8 changes: 8 additions & 0 deletions drivers/usb/serial/usb_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ static void usb_debug_process_read_urb(struct 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 = {
.driver = {
.owner = THIS_MODULE,
Expand All @@ -85,6 +90,7 @@ static struct usb_serial_driver debug_device = {
.num_ports = 1,
.bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE,
.break_ctl = usb_debug_break_ctl,
.init_termios = usb_debug_init_termios,
.process_read_urb = usb_debug_process_read_urb,
};

Expand All @@ -96,6 +102,7 @@ static struct usb_serial_driver dbc_device = {
.id_table = dbc_id_table,
.num_ports = 1,
.break_ctl = usb_debug_break_ctl,
.init_termios = usb_debug_init_termios,
.process_read_urb = usb_debug_process_read_urb,
};

Expand All @@ -104,4 +111,5 @@ static struct usb_serial_driver * const serial_drivers[] = {
};

module_usb_serial_driver(serial_drivers, id_table_combined);
MODULE_DESCRIPTION("USB Debug cable driver");
MODULE_LICENSE("GPL v2");
14 changes: 14 additions & 0 deletions drivers/usb/typec/mux/fsa4480.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include <linux/usb/typec_dp.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_SELECT 0x05
#define FSA4480_SWITCH_STATUS1 0x07
Expand Down Expand Up @@ -251,6 +255,7 @@ static int fsa4480_probe(struct i2c_client *client)
struct typec_switch_desc sw_desc = { };
struct typec_mux_desc mux_desc = { };
struct fsa4480 *fsa;
int val = 0;
int ret;

fsa = devm_kzalloc(dev, sizeof(*fsa), GFP_KERNEL);
Expand All @@ -268,6 +273,15 @@ static int fsa4480_probe(struct i2c_client *client)
if (IS_ERR(fsa->regmap))
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 */
fsa->cur_enable = FSA4480_ENABLE_DEVICE | FSA4480_ENABLE_USB;
fsa->mode = TYPEC_STATE_SAFE;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/typec/tcpm/tcpci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

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;
int ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/typec/tcpm/tcpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4515,7 +4515,7 @@ static inline enum tcpm_state hard_reset_state(struct tcpm_port *port)
return ERROR_RECOVERY;
if (port->pwr_role == TYPEC_SOURCE)
return SRC_UNATTACHED;
if (port->state == SNK_WAIT_CAPABILITIES)
if (port->state == SNK_WAIT_CAPABILITIES_TIMEOUT)
return SNK_READY;
return SNK_UNATTACHED;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/typec/tipd/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,14 +1191,14 @@ static int tps6598x_apply_patch(struct tps6598x *tps)
dev_info(tps->dev, "Firmware update succeeded\n");

release_fw:
release_firmware(fw);
if (ret) {
dev_err(tps->dev, "Failed to write patch %s of %zu bytes\n",
firmware_name, fw->size);
}
release_firmware(fw);

return ret;
};
}

static int cd321x_init(struct tps6598x *tps)
{
Expand Down
11 changes: 4 additions & 7 deletions drivers/usb/typec/ucsi/ucsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,10 @@ static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd,
mutex_lock(&ucsi->ppm_lock);

ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack);
if (cci & UCSI_CCI_BUSY) {
ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false);
return ret ? ret : -EBUSY;
}

if (cci & UCSI_CCI_ERROR)
return ucsi_read_error(ucsi, connector_num);
if (cci & UCSI_CCI_BUSY)
ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false) ?: -EBUSY;
else if (cci & UCSI_CCI_ERROR)
ret = ucsi_read_error(ucsi, connector_num);

mutex_unlock(&ucsi->ppm_lock);
return ret;
Expand Down
Loading

0 comments on commit cb2e5ee

Please sign in to comment.