firmware: raspberrypi: Keep count of all consumers
authorNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Mon, 18 Jan 2021 12:32:34 +0000 (13:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Sep 2021 07:50:41 +0000 (09:50 +0200)
commit60831f5ae6c713afceb6d29f40899ed112f36059
tree081d4dd0cc7bbf7e02a5667c9c87ab1f84faaae3
parent5c68b7795b4c7bdbd54148c9343b5a5edeb476d7
firmware: raspberrypi: Keep count of all consumers

[ Upstream commit 1e7c57355a3bc617fc220234889e49fe722a6305 ]

When unbinding the firmware device we need to make sure it has no
consumers left. Otherwise we'd leave them with a firmware handle
pointing at freed memory.

Keep a reference count of all consumers and introduce rpi_firmware_put()
which will permit automatically decrease the reference count upon
unbinding consumer drivers.

Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/raspberrypi.c
include/soc/bcm2835/raspberrypi-firmware.h