linux-stable/drivers/extcon
Alvin Šipraga 2445a35d05 extcon: usbc-tusb320: Unregister typec port on driver removal
[ Upstream commit 3adbaa30d9 ]

The driver can register a typec port if suitable firmware properties are
present. But if the driver is removed through sysfs unbind, rmmod or
similar, then it does not clean up after itself and the typec port
device remains registered. This can be seen in sysfs, where stale typec
ports get left over in /sys/class/typec.

In order to fix this we have to add an i2c_driver remove function and
call typec_unregister_port(), which is a no-op in the case where no
typec port is created and the pointer remains NULL.

In the process we should also put the fwnode_handle when the typec port
isn't registered anymore, including if an error occurs during probe. The
typec subsystem does not increase or decrease the reference counter for
us, so we track it in the driver's private data.

Note that the conditional check on TYPEC_PWR_MODE_PD was removed in the
probe path because a call to tusb320_set_adv_pwr_mode() will perform an
even more robust validation immediately after, hence there is no
functional change here.

Fixes: bf7571c00d ("extcon: usbc-tusb320: Add USB TYPE-C support")
Cc: stable@vger.kernel.org
Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-07-19 16:22:08 +02:00
..
devres.c
extcon-adc-jack.c
extcon-axp288.c
extcon-fsa9480.c
extcon-gpio.c
extcon-intel-cht-wc.c
extcon-intel-int3496.c
extcon-intel-mrfld.c
extcon-intel.h
extcon-max3355.c
extcon-max8997.c
extcon-max14577.c
extcon-max77693.c
extcon-max77843.c
extcon-palmas.c
extcon-ptn5150.c
extcon-qcom-spmi-misc.c
extcon-rt8973a.c
extcon-rt8973a.h
extcon-sm5502.c
extcon-sm5502.h
extcon-usb-gpio.c
extcon-usbc-cros-ec.c
extcon-usbc-tusb320.c extcon: usbc-tusb320: Unregister typec port on driver removal 2023-07-19 16:22:08 +02:00
extcon.c
extcon.h
Kconfig
Makefile