]> git.baikalelectronics.ru Git - kernel.git/commit
usb: max-3421: Use driver data instead of maintaining a list of bound devices
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 18 Oct 2021 20:40:28 +0000 (22:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Nov 2021 08:49:07 +0000 (09:49 +0100)
commit20556b8a4ef33e54fa4e431deb2d6c0acf8e7407
tree04d07850faf18c87b09fd2ffccfda6a1bfd87a51
parentce4abc9aa53e0e61213ba2a8f7ac31015b33dd0c
usb: max-3421: Use driver data instead of maintaining a list of bound devices

commit 5d1061394e764debae20dc255ab1f0539e4c92b9 upstream.

Instead of maintaining a single-linked list of devices that must be
searched linearly in .remove() just use spi_set_drvdata() to remember the
link between the spi device and the driver struct. Then the global list
and the next member can be dropped.

This simplifies the driver, reduces the memory footprint and the time to
search the list. Also it makes obvious that there is always a corresponding
driver struct for a given device in .remove(), so the error path for
!max3421_hcd can be dropped, too.

As a side effect this fixes a data inconsistency when .probe() races with
itself for a second max3421 device in manipulating max3421_hcd_list. A
similar race is fixed in .remove(), too.

Fixes: 6cb52f04231c ("Add support for using a MAX3421E chip as a host driver.")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20211018204028.2914597-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/max3421-hcd.c