]> git.baikalelectronics.ru Git - kernel.git/commit
device property: Allow error pointer to be passed to fwnode APIs
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 8 Apr 2022 18:48:40 +0000 (21:48 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 13 Apr 2022 18:04:02 +0000 (20:04 +0200)
commit4da9d1af59c80cd7d8f8ffb7c1cf0af385b37855
tree68a6816d0421e36c4c02ee9b842ed5b363302b2c
parentee14f97e074ffee9618bd1ab79abe993bfdfe270
device property: Allow error pointer to be passed to fwnode APIs

Some of the fwnode APIs might return an error pointer instead of NULL
or valid fwnode handle. The result of such API call may be considered
optional and hence the test for it is usually done in a form of

fwnode = fwnode_find_reference(...);
if (IS_ERR(fwnode))
...error handling...

Nevertheless the resulting fwnode may have bumped the reference count
and hence caller of the above API is obliged to call fwnode_handle_put().
Since fwnode may be not valid either as NULL or error pointer the check
has to be performed there. This approach uglifies the code and adds
a point of making a mistake, i.e. forgetting about error point case.

To prevent this, allow an error pointer to be passed to the fwnode APIs.

Fixes: eb426081d926 ("device property: Introduce fwnode_find_reference()")
Reported-by: Nuno Sá <nuno.sa@analog.com>
Tested-by: Nuno Sá <nuno.sa@analog.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Michael Walle <michael@walle.cc>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/property.c
include/linux/fwnode.h