1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
5 * Based on led-uclass.c
8 #define LOG_CATEGORY UCLASS_BUTTON
13 #include <dm/uclass-internal.h>
15 int button_get_by_label(const char *label, struct udevice **devp)
20 uclass_id_foreach_dev(UCLASS_BUTTON, dev, uc) {
21 struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev);
23 /* Ignore the top-level button node */
24 if (uc_plat->label && !strcmp(label, uc_plat->label))
25 return uclass_get_device_tail(dev, 0, devp);
31 enum button_state_t button_get_state(struct udevice *dev)
33 struct button_ops *ops = button_get_ops(dev);
38 return ops->get_state(dev);
41 UCLASS_DRIVER(button) = {
44 .per_device_plat_auto = sizeof(struct button_uc_plat),