of: add helper function to retrive match data
It's a common operation for device drivers to retrive the data member from of_device_id struct in their probe function. Most driver end up doing: const struct of_device_id *match; match = of_match_device(driver_of_match, &pdev->dev); driver->data = match->data; With the of_device_get_match_data helper function all this can done in one go. Signed-off-by: Joachim Eastwood <manabian@gmail.com> [robh: add missing inline to dummmy declaration] Signed-off-by: Rob Herring <robh@kernel.org>
This commit is contained in:

committed by
Rob Herring

parent
31712c98f8
commit
3386e0fa90
@@ -163,6 +163,18 @@ void of_device_unregister(struct platform_device *ofdev)
|
||||
}
|
||||
EXPORT_SYMBOL(of_device_unregister);
|
||||
|
||||
const void *of_device_get_match_data(const struct device *dev)
|
||||
{
|
||||
const struct of_device_id *match;
|
||||
|
||||
match = of_match_device(dev->driver->of_match_table, dev);
|
||||
if (!match)
|
||||
return NULL;
|
||||
|
||||
return match->data;
|
||||
}
|
||||
EXPORT_SYMBOL(of_device_get_match_data);
|
||||
|
||||
ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
|
||||
{
|
||||
const char *compat;
|
||||
|
Reference in New Issue
Block a user