]> git.baikalelectronics.ru Git - kernel.git/commit
usb: typec: ucsi: add a common function ucsi_unregister_connectors()
authorLinyu Yuan <quic_linyyuan@quicinc.com>
Mon, 25 Apr 2022 10:18:05 +0000 (18:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Apr 2022 11:44:57 +0000 (13:44 +0200)
commit42d51c349ca057f88d95f3a9b39012ab2e82fb6a
tree8576bc6fbef62f38225c759bcb9665d58def63b7
parenta5367790a8f2a9516cadb5938e7e2e80f7efbadb
usb: typec: ucsi: add a common function ucsi_unregister_connectors()

In error path of ucsi_init(), it will unregister all valid ucsi connectors,
and similar operation also happen in ucsi_unregister(),
add a common function ucsi_unregister_connectors() for two places,
inside this function, if con->wq is NULL, it will break the loop,
if other kind of error happen after con->wq allocated,
ucsi/typec related API is safe to unregister.

Also in ucsi_init(), it allocate number of (ucsi->cap.num_connectors + 1)
connectors, there is one extra as the ending,
ucsi_unregister_connectors() is safe to unregister all ucsi connectors
according ucsi->cap.num_connectors,
remove the extra one connector to save memory.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Link: https://lore.kernel.org/r/1650881886-25530-2-git-send-email-quic_linyyuan@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/ucsi/ucsi.c