mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 04:15:07 +07:00
5e844cc37a
SPI driver probing currently comprises two steps, whereas removal comprises only one step: spi_alloc_master() spi_register_controller() spi_unregister_controller() That's because spi_unregister_controller() calls device_unregister() instead of device_del(), thereby releasing the reference on the spi_controller which was obtained by spi_alloc_master(). An SPI driver's private data is contained in the same memory allocation as the spi_controller struct. Thus, once spi_unregister_controller() has been called, the private data is inaccessible. But some drivers need to access it after spi_unregister_controller() to perform further teardown steps. Introduce devm_spi_alloc_master() and devm_spi_alloc_slave(), which release a reference on the spi_controller struct only after the driver has unbound, thereby keeping the memory allocation accessible. Change spi_unregister_controller() to not release a reference if the spi_controller was allocated by one of these new devm functions. The present commit is small enough to be backportable to stable. It allows fixing drivers which use the private data in their ->remove() hook after it's been freed. It also allows fixing drivers which neglect to release a reference on the spi_controller in the probe error path. Long-term, most SPI drivers shall be moved over to the devm functions introduced herein. The few that can't shall be changed in a treewide commit to explicitly release the last reference on the controller. That commit shall amend spi_unregister_controller() to no longer release a reference, thereby completing the migration. As a result, the behaviour will be less surprising and more consistent with subsystems such as IIO, which also includes the private data in the allocation of the generic iio_dev struct, but calls device_del() in iio_device_unregister(). Signed-off-by: Lukas Wunner <lukas@wunner.de> Link: https://lore.kernel.org/r/272bae2ef08abd21388c98e23729886663d19192.1605121038.git.lukas@wunner.de Signed-off-by: Mark Brown <broonie@kernel.org> |
||
---|---|---|
.. | ||
ad7877.h | ||
ads7846.h | ||
altera.h | ||
at73c213.h | ||
at86rf230.h | ||
cc2520.h | ||
corgi_lcd.h | ||
ds1305.h | ||
eeprom.h | ||
flash.h | ||
ifx_modem.h | ||
libertas_spi.h | ||
lms283gf05.h | ||
max7301.h | ||
mc33880.h | ||
mmc_spi.h | ||
mxs-spi.h | ||
pxa2xx_spi.h | ||
rspi.h | ||
s3c24xx-fiq.h | ||
s3c24xx.h | ||
sh_hspi.h | ||
sh_msiof.h | ||
spi_bitbang.h | ||
spi_gpio.h | ||
spi_oc_tiny.h | ||
spi-fsl-dspi.h | ||
spi-mem.h | ||
spi.h | ||
tdo24m.h | ||
tle62x0.h | ||
xilinx_spi.h |