[PATCH] mfd: twl-core: export twl_get_regmap
Russell King - ARM Linux
linux at armlinux.org.uk
Mon Nov 21 01:31:45 PST 2016
On Mon, Nov 21, 2016 at 09:23:39AM +0000, Lee Jones wrote:
> It's common place to pass shared resources such as 'regmap' though
> device data. You can find many examples of *__set_drvdata throughout
> the kernel.
Passing data between drivers using *_set_drvdata() is a layering
violation:
1. Driver data is supposed to be driver private data associated with
the currently bound driver.
2. The driver data pointer is NULL'd when the driver unbinds from the
device. See __device_release_driver() and the
dev_set_drvdata(dev, NULL).
3. It will break with CONFIG_DEBUG_TEST_DRIVER_REMOVE enabled for a
similar reason to (2).
So, do not pass data between drivers using *_set_drvdata() - any
examples in the kernel already are founded on bad practice, are
fragile, and are already broken for some kernel configurations.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
More information about the linux-arm-kernel
mailing list