mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +00:00
led: introduce led_bind_generic()
All existing drivers in drivers/led/ contain a .bind method that does exactly the same thing, with just the actual driver name differing. Create a helper so all those individual methods can be changed to one-liners. Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
This commit is contained in:
parent
067e4ce35b
commit
3bf0515a07
2 changed files with 26 additions and 0 deletions
|
@ -11,9 +11,27 @@
|
|||
#include <errno.h>
|
||||
#include <led.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/lists.h>
|
||||
#include <dm/root.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
|
||||
int led_bind_generic(struct udevice *parent, const char *driver_name)
|
||||
{
|
||||
struct udevice *dev;
|
||||
ofnode node;
|
||||
int ret;
|
||||
|
||||
dev_for_each_subnode(node, parent) {
|
||||
ret = device_bind_driver_to_node(parent, driver_name,
|
||||
ofnode_get_name(node),
|
||||
node, &dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_get_by_label(const char *label, struct udevice **devp)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
|
|
@ -110,4 +110,12 @@ enum led_state_t led_get_state(struct udevice *dev);
|
|||
*/
|
||||
int led_set_period(struct udevice *dev, int period_ms);
|
||||
|
||||
/**
|
||||
* led_bind_generic() - bind children of parent to given driver
|
||||
*
|
||||
* @parent: Top-level LED device
|
||||
* @driver_name: Driver for handling individual child nodes
|
||||
*/
|
||||
int led_bind_generic(struct udevice *parent, const char *driver_name);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue