linux/drivers
Jack Pham 583eba64fe FROMGIT: usb: gadget: composite: Allow bMaxPower=0 if self-powered
Currently the composite driver encodes the MaxPower field of
the configuration descriptor by reading the c->MaxPower of the
usb_configuration only if it is non-zero, otherwise it falls back
to using the value hard-coded in CONFIG_USB_GADGET_VBUS_DRAW.
However, there are cases when a configuration must explicitly set
bMaxPower to 0, particularly if its bmAttributes also has the
Self-Powered bit set, which is a valid combination.

This is specifically called out in the USB PD specification section
9.1, in which a PDUSB device "shall report zero in the bMaxPower
field after negotiating a mutually agreeable Contract", and also
verified by the USB Type-C Functional Test TD.4.10.2 Sink Power
Precedence Test.

The fix allows the c->MaxPower to be used for encoding the bMaxPower
even if it is 0, if the self-powered bit is also set.  An example
usage of this would be for a ConfigFS gadget to be dynamically
updated by userspace when the Type-C connection is determined to be
operating in Power Delivery mode.

Co-developed-by: Ronak Vijay Raheja <rraheja@codeaurora.org>
Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Ronak Vijay Raheja <rraheja@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Link: https://lore.kernel.org/r/20210720080907.30292-1-jackp@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit bcacbf06c8
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Bug: 194455199
Change-Id: Ie2d04df6cf3c1c6cdaa9f0872774fd6e5788cade
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2021-07-24 16:20:13 +00:00
..
accessibility
acpi Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
amba Merge 5.10.20 into android12-5.10 2021-03-07 12:33:33 +01:00
android ANDROID: media: v4l2-core: Fix deadlock in vendor hook 2021-07-21 13:05:27 +00:00
ata ata: libahci_platform: fix IRQ check 2021-05-14 09:50:24 +02:00
atm atm: idt77252: fix null-ptr-dereference 2021-03-30 14:31:50 +02:00
auxdisplay auxdisplay: ht16k33: Fix refresh rate handling 2021-03-04 11:38:00 +01:00
base ANDROID: power: wakeup_reason: change abort log 2021-06-25 16:31:57 +00:00
bcma
block Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
bluetooth Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
bus bus: ti-sysc: Fix flakey idling of uarts and stop using swsup_sidle_act 2021-06-10 13:39:22 +02:00
cdrom cdrom: gdrom: initialize global variable at init time 2021-05-26 12:06:55 +02:00
char Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
clk Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
clocksource Revert "Revert "clocksource/drivers/timer-ti-dm: Handle dra7 timer wrap errata i940"" 2021-06-04 11:15:17 -07:00
connector
counter counter: stm32-timer-cnt: fix ceiling miss-alignment with reload register 2021-03-25 09:04:16 +01:00
cpufreq ANDROID: vendor_hooks: Add hooks for cpufreq_acct_update_power 2021-06-01 20:59:53 +08:00
cpuidle ANDROID: cpuidle: Allow for an early exit from cpuidle_enter_state() 2021-07-02 19:45:07 +00:00
crypto Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
dax device-dax: Fix default return code of range_parse() 2021-03-04 11:38:15 +01:00
dca
devfreq PM / devfreq: Use more accurate returned new_freq as resume_freq 2021-05-14 09:50:15 +02:00
dio
dma Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
dma-buf FROMGIT: dma_buf: remove dmabuf sysfs teardown before release 2021-07-21 02:07:51 +00:00
edac EDAC/amd64: Do not load on family 0x15, model 0x13 2021-03-07 12:34:08 +01:00
eisa
extcon extcon: arizona: Fix various races on driver unbind 2021-05-11 14:47:24 +02:00
firewire firewire: nosy: Fix a use-after-free bug in nosy_ioctl() 2021-04-07 15:00:11 +02:00
firmware Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
fpga fpga: fpga-mgr: xilinx-spi: fix error messages on -EPROBE_DEFER 2021-05-14 09:50:06 +02:00
fsi
gnss
gpio UPSTREAM: gpiolib: Fix error return code in gpiolib_dev_init() 2021-06-10 20:26:20 -07:00
gpu Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
greybus
hid Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
hsi HSI: core: fix resource leaks in hsi_add_client_from_dt() 2021-05-14 09:50:28 +02:00
hv Drivers: hv: vmbus: Increase wait time for VMbus unload 2021-05-14 09:50:21 +02:00
hwmon Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
hwspinlock
hwtracing ANDROID: coresight: Update ETE/TRBE to v6 merged upstream 2021-06-23 22:48:15 +00:00
i2c Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
i3c Revert "i3c master: fix missing destroy_workqueue() on error in i3c_master_register" 2021-05-14 09:50:05 +02:00
ide ide/falconide: Fix module unload 2021-03-04 11:38:21 +01:00
idle
iio iio: adc: ad7192: handle regulator voltage error first 2021-06-03 09:00:33 +02:00
infiniband RDMA/uverbs: Fix a NULL vs IS_ERR() bug 2021-05-26 12:06:49 +02:00
input This is the 5.10.39 stable release 2021-05-22 15:34:48 +02:00
interconnect interconnect: qcom: Add missing MODULE_DEVICE_TABLE 2021-06-03 09:00:46 +02:00
iommu ANDROID: iommu/io-pgtable-arm: Add IOMMU_CACHE_ICACHE_OCACHE_NWA 2021-06-30 08:29:33 +00:00
ipack
irqchip ANDROID: irqchip: gic-v3: Move struct gic_chip_data to header 2021-07-06 21:05:45 +00:00
isdn isdn: mISDN: correctly handle ph_info allocation failure in hfcsusb_ph_info 2021-06-03 09:00:42 +02:00
leds leds: lp5523: check return value of lp5xx_read and jump to cleanup code 2021-05-26 12:06:56 +02:00
lightnvm
macintosh macintosh/adb-iop: Use big-endian autopoll mask 2021-03-04 11:37:42 +01:00
mailbox mailbox: sprd: Introduce refcnt when clients requests/free channels 2021-05-14 09:50:27 +02:00
mcb
md Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
media ANDROID: media: v4l2-core: Fix deadlock in vendor hook 2021-07-21 13:05:27 +00:00
memory Merge 5.10.37 into android12-5.10 2021-05-15 09:28:55 +02:00
memstick
message
mfd UPSTREAM: mfd: syscon: Free the allocated name field of struct regmap_config 2021-07-20 23:53:31 +00:00
misc Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
mmc ANDROID: add kabi padding for structures for the android12 release 2021-07-14 20:51:51 -07:00
most
mtd mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init 2021-05-14 09:50:15 +02:00
mux
net FROMGIT: net: cdc_ncm: switch to eth%d interface naming 2021-07-08 04:01:26 +00:00
nfc nfc: pn533: prevent potential memory corruption 2021-05-14 09:50:32 +02:00
ntb
nubus
nvdimm libnvdimm/region: Fix nvdimm_has_flush() to handle ND_REGION_ASYNC 2021-04-21 13:00:55 +02:00
nvme nvmet: fix freeing unallocated p2pmem 2021-06-10 13:39:18 +02:00
nvmem drivers: nvmem: Fix voltage settings for QTI qfprom-efuse 2021-05-14 09:50:14 +02:00
of FROMGIT: of: Add stub for of_add_property() 2021-07-12 17:10:22 +00:00
opp Merge 5.10.20 into android12-5.10 2021-03-07 12:33:33 +01:00
oprofile
parisc
parport
pci This is the 5.10.39 stable release 2021-05-22 15:34:48 +02:00
pcmcia
perf perf/arm_pmu_platform: Fix error handling 2021-05-11 14:47:19 +02:00
phy phy: marvell: ARMADA375_USBCLUSTER_PHY should not default to y, unconditionally 2021-05-14 09:50:13 +02:00
pinctrl Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
platform Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
pnp
power Merge 5.10.37 into android12-5.10 2021-05-15 09:28:55 +02:00
powercap UPSTREAM: powercap/drivers/dtpm: Add the experimental label to the option description 2021-03-22 15:24:47 +00:00
pps
ps3
ptp ptp_qoriq: fix overflow in ptp_qoriq_adjfine() u64 calcalation 2021-04-10 13:36:09 +02:00
pwm Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
rapidio rapidio: handle create_workqueue() failure 2021-05-26 12:06:52 +02:00
ras RAS/CEC: Correct ce_add_elem()'s returned values 2021-04-14 08:42:12 +02:00
regulator UPSTREAM: regulator: qcom-rpmh: fix build after QCOM_COMMAND_DB is tristate 2021-06-10 20:26:00 -07:00
remoteproc ANDROID: rproc: Add vendor hook for recovery 2021-07-01 22:32:04 -07:00
reset FROMLIST: reset: reset-scmi: port driver to the new scmi_reset_proto_ops interface 2021-03-02 17:34:33 -08:00
rpmsg Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
rtc Merge 5.10.40 into android12-5.10 2021-05-27 08:36:46 +02:00
s390 Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
sbus
scsi FROMLIST: scsi: ufs: Fix memory corruption by ufshcd_read_desc_param() 2021-07-22 11:47:45 -07:00
sfi
sh
siox
slimbus
soc Merge 5.10.37 into android12-5.10 2021-05-15 09:28:55 +02:00
soundwire soundwire: stream: fix memory leak in stream config error path 2021-05-14 09:50:14 +02:00
spi Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
spmi spmi: spmi-pmic-arb: Fix hw_irq overflow 2021-03-04 11:38:40 +01:00
ssb
staging ANDROID: ashmem: Export is_ashmem_file 2021-07-13 15:48:06 +00:00
target scsi: target: tcmu: Return from tcmu_handle_completions() if cmd_id not found 2021-05-22 11:40:54 +02:00
tc
tee optee: use export_uuid() to copy client UUID 2021-06-10 13:39:21 +02:00
thermal Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
thunderbolt thunderbolt: dma_port: Fix NVM read buffer bounds and offset issue 2021-06-03 09:00:32 +02:00
tty Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
uio uio_hv_generic: Fix a memory leak in error handling paths 2021-05-26 12:06:52 +02:00
usb FROMGIT: usb: gadget: composite: Allow bMaxPower=0 if self-powered 2021-07-24 16:20:13 +00:00
vdpa {net,vdpa}/mlx5: Configure interface MAC into mpfs L2 table 2021-06-03 09:00:36 +02:00
vfio Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
vhost vhost-vdpa: fix vm_flags for virtqueue doorbell mapping 2021-05-11 14:47:12 +02:00
video Merge 5.10.40 into android12-5.10 2021-05-27 08:36:46 +02:00
virt nitro_enclaves: Fix stale file descriptors on failed usercopy 2021-05-11 14:47:11 +02:00
virtio ANDROID: mm: add cma allocation statistics 2021-07-14 11:54:48 -07:00
visorbus
vlynq
vme
w1 w1: w1_therm: Fix conversion result for negative temperatures 2021-03-04 11:37:18 +01:00
watchdog Merge 5.10.20 into android12-5.10 2021-03-07 12:33:33 +01:00
xen xen-pciback: reconfigure also from backend watch handler 2021-05-26 12:06:54 +02:00
zorro
Kconfig
Makefile