kernel-hacking-2024-linux-s.../include/linux/usb
Kees Cook 2bb6b10ebe usb: gadget: Use u16 types for 16-bit fields
Since the beginning of time, struct usb_ep::maxpacket was a bitfield,
and when new 16-bit members were added, the convention was followed:

1da177e4c3 (Linus Torvalds   2005-04-16 236) unsigned maxpacket:16;
e117e742d3 (Robert Baldyga   2013-12-13 237) unsigned maxpacket_limit:16;
a59d6b91cb (Tatyana Brokhman 2011-06-28 238) unsigned max_streams:16;

However, there is no need for this as a simple u16 can be used instead,
simplifying the struct and the resulting compiler binary output. Switch
to u16 for all three, and rearrange struct slightly to minimize holes.
No change in the final size of the struct results; the 2 byte gap is
just moved to the end, as seen with pahole:

-       /* XXX 2 bytes hole, try to pack */
        ...
        /* size: 72, cachelines: 2, members: 15 */
        ...
+       /* padding: 2 */

Changing this simplifies future introspection[1] of maxpacket's type during
allocations:

drivers/usb/gadget/function/f_tcm.c:330:24: error: 'typeof' applied to a bit-field
     330 |  fu->cmd.buf = kmalloc(fu->ep_out->maxpacket, GFP_KERNEL);

Link: https://lore.kernel.org/all/202407090928.6UaOAZAJ-lkp@intel.com [1]
Signed-off-by: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/r/20240709154953.work.953-kees@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-10 13:56:22 +02:00
..
audio-v2.h
audio-v3.h
audio.h
c67x00.h
ccid.h
cdc-wdm.h
cdc.h
cdc_ncm.h
ch9.h
chipidea.h
composite.h
ehci-dbgp.h
ehci_def.h
ehci_pdriver.h
ezusb.h
functionfs.h
g_hid.h
gadget.h usb: gadget: Use u16 types for 16-bit fields 2024-07-10 13:56:22 +02:00
gadget_configfs.h
hcd.h workqueue: BH workqueue conversions for v6.9 2024-03-11 13:05:19 -07:00
input.h
iowarrior.h
irda.h
isp116x.h
isp1301.h
isp1362.h
ljca.h
m66592.h
midi-v2.h
musb-ux500.h
musb.h
net2280.h
of.h usb: core: Set connect_type of ports based on DT node 2024-03-05 13:28:46 +00:00
ohci_pdriver.h
onboard_dev.h usb: misc: onboard_hub: rename to onboard_dev 2024-03-27 07:57:16 +01:00
otg-fsm.h
otg.h
pd.h
pd_ado.h
pd_bdo.h
pd_ext_sdb.h
pd_vdo.h usb: typec: pd: no opencoding of FIELD_GET 2024-03-05 13:09:59 +00:00
phy.h
phy_companion.h
quirks.h
r8a66597.h
r8152.h
renesas_usbhs.h usb: renesas_usbhs: Remove renesas_usbhs_get_info() wrapper 2024-04-18 16:47:49 +02:00
rndis_host.h
role.h
rzv2m_usb3drd.h
serial.h
sl811.h
storage.h
tcpci.h usb: typec: tcpci: add support to set connector orientation 2024-07-03 16:05:38 +02:00
tcpm.h usb: typec: tcpm: add support to set tcpc connector orientatition 2024-03-05 13:29:30 +00:00
tegra_usb_phy.h usb: phy: tegra: Replace of_gpio.h by proper one 2024-05-10 10:36:31 +01:00
typec.h usb: typec: Update sysfs when setting ops 2024-06-04 15:44:27 +02:00
typec_altmode.h
typec_dp.h usb: typec: pd: no opencoding of FIELD_GET 2024-03-05 13:09:59 +00:00
typec_mux.h
typec_retimer.h
typec_tbt.h USB: typec: no opencoding FIELD_GET 2024-03-02 20:20:41 +01:00
uas.h
ulpi.h
usb338x.h
usb_phy_generic.h
usbnet.h
uvc.h
webusb.h
xhci-dbgp.h