mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: "Edmund Henniges" <eh@emlix.com>, "Daniel Glöckner" <dg@emlix.com>
Subject: [PATCH 01/11] poller: Give pollers a name
Date: Wed, 22 Apr 2020 09:54:42 +0200	[thread overview]
Message-ID: <20200422075452.25226-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20200422075452.25226-1-s.hauer@pengutronix.de>

It helps debugging when pollers have a name, so give them one.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/poller.c                | 8 +++++---
 common/ratp/ratp.c             | 2 +-
 drivers/input/gpio_keys.c      | 2 +-
 drivers/input/imx_keypad.c     | 2 +-
 drivers/input/input.c          | 2 +-
 drivers/input/qt1070.c         | 2 +-
 drivers/input/twl6030_pwrbtn.c | 2 +-
 drivers/led/core.c             | 2 +-
 drivers/usb/gadget/udc-core.c  | 2 +-
 drivers/watchdog/wd_core.c     | 2 +-
 include/poller.h               | 5 +++--
 11 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/common/poller.c b/common/poller.c
index 32795b641f..b1a2122f91 100644
--- a/common/poller.c
+++ b/common/poller.c
@@ -16,11 +16,12 @@
 static LIST_HEAD(poller_list);
 static int poller_active;
 
-int poller_register(struct poller_struct *poller)
+int poller_register(struct poller_struct *poller, const char *name)
 {
 	if (poller->registered)
 		return -EBUSY;
 
+	poller->name = xstrdup(name);
 	list_add_tail(&poller->list, &poller_list);
 	poller->registered = 1;
 
@@ -35,6 +36,7 @@ int poller_unregister(struct poller_struct *poller)
 
 	list_del(&poller->list);
 	poller->registered = 0;
+	free(poller->name);
 
 	return 0;
 }
@@ -92,12 +94,12 @@ int poller_call_async(struct poller_async *pa, uint64_t delay_ns,
 	return 0;
 }
 
-int poller_async_register(struct poller_async *pa)
+int poller_async_register(struct poller_async *pa, const char *name)
 {
 	pa->poller.func = poller_async_callback;
 	pa->active = 0;
 
-	return poller_register(&pa->poller);
+	return poller_register(&pa->poller, name);
 }
 
 int poller_async_unregister(struct poller_async *pa)
diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
index e84ad22167..9625a31b18 100644
--- a/common/ratp/ratp.c
+++ b/common/ratp/ratp.c
@@ -454,7 +454,7 @@ int barebox_ratp(struct console_device *cdev)
 	if (ret < 0)
 		goto out;
 
-	ret = poller_register(&ctx->poller);
+	ret = poller_register(&ctx->poller, "ratp");
 	if (ret)
 		goto out1;
 
diff --git a/drivers/input/gpio_keys.c b/drivers/input/gpio_keys.c
index 38c0f11535..11d598c402 100644
--- a/drivers/input/gpio_keys.c
+++ b/drivers/input/gpio_keys.c
@@ -166,7 +166,7 @@ static int __init gpio_keys_probe(struct device_d *dev)
 	if (ret)
 		return ret;
 
-	ret = poller_register(&gk->poller);
+	ret = poller_register(&gk->poller, dev_name(dev));
 	if (ret)
 		return ret;
 
diff --git a/drivers/input/imx_keypad.c b/drivers/input/imx_keypad.c
index 44ff9b7856..6757fac72b 100644
--- a/drivers/input/imx_keypad.c
+++ b/drivers/input/imx_keypad.c
@@ -410,7 +410,7 @@ static int __init imx_keypad_probe(struct device_d *dev)
 
 	keypad->poller.func = imx_keypad_check_for_events;
 
-	ret = poller_register(&keypad->poller);
+	ret = poller_register(&keypad->poller, dev_name(dev));
 	if (ret)
 		return ret;
 
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1e8f6e178e..bcc8667417 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -201,7 +201,7 @@ static int input_init(void)
 	ic->fifo = kfifo_alloc(32);
 	ic->notifier.notify = input_console_notify;
 	input_register_notfier(&ic->notifier);
-	poller_async_register(&ic->poller);
+	poller_async_register(&ic->poller, "input");
 
 	return console_register(&ic->console);
 }
diff --git a/drivers/input/qt1070.c b/drivers/input/qt1070.c
index 59acee5c39..9e1dcc57ee 100644
--- a/drivers/input/qt1070.c
+++ b/drivers/input/qt1070.c
@@ -269,7 +269,7 @@ static int qt1070_probe(struct device_d *dev)
 
 	console_register(&data->cdev);
 
-	ret = poller_register(&data->poller);
+	ret = poller_register(&data->poller, dev_name(dev));
 	if (ret)
 		goto err;
 
diff --git a/drivers/input/twl6030_pwrbtn.c b/drivers/input/twl6030_pwrbtn.c
index fc4c728778..481688b4a9 100644
--- a/drivers/input/twl6030_pwrbtn.c
+++ b/drivers/input/twl6030_pwrbtn.c
@@ -97,7 +97,7 @@ static int __init twl6030_pwrbtn_probe(struct device_d *dev)
 	idata->cdev.getc = twl6030_pwrbtn_getc;
 	console_register(&idata->cdev);
 
-	return poller_register(&idata->poller);
+	return poller_register(&idata->poller, dev_name(dev));
 }
 
 static struct driver_d twl6030_pwrbtn_driver = {
diff --git a/drivers/led/core.c b/drivers/led/core.c
index e727148a24..4cce5dfc97 100644
--- a/drivers/led/core.c
+++ b/drivers/led/core.c
@@ -212,7 +212,7 @@ static struct poller_struct led_poller = {
 
 static int led_blink_init(void)
 {
-	return poller_register(&led_poller);
+	return poller_register(&led_poller, "led");
 }
 late_initcall(led_blink_init);
 
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 096f05ed48..126d76e8bb 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -319,7 +319,7 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
 
 	if (udc->gadget->ops->udc_poll) {
 		udc->poller.func = udc_poll_driver;
-		ret = poller_register(&udc->poller);
+		ret = poller_register(&udc->poller, dev_name(&udc->dev));
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 34040408f7..a17234f4b6 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -116,7 +116,7 @@ static int watchdog_register_poller(struct watchdog *wd)
 	struct param_d *p;
 	int ret;
 
-	ret = poller_async_register(&wd->poller);
+	ret = poller_async_register(&wd->poller, dev_name(&wd->dev));
 	if (ret)
 		return ret;
 
diff --git a/include/poller.h b/include/poller.h
index b22b8a1b89..886557252b 100644
--- a/include/poller.h
+++ b/include/poller.h
@@ -12,9 +12,10 @@ struct poller_struct {
 	void (*func)(struct poller_struct *poller);
 	int registered;
 	struct list_head list;
+	char *name;
 };
 
-int poller_register(struct poller_struct *poller);
+int poller_register(struct poller_struct *poller, const char *name);
 int poller_unregister(struct poller_struct *poller);
 
 struct poller_async;
@@ -27,7 +28,7 @@ struct poller_async {
 	int active;
 };
 
-int poller_async_register(struct poller_async *pa);
+int poller_async_register(struct poller_async *pa, const char *name);
 int poller_async_unregister(struct poller_async *pa);
 
 int poller_call_async(struct poller_async *pa, uint64_t delay_ns,
-- 
2.26.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-04-22  7:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22  7:54 [PATCH v4 00/11] Protect code from pollers Sascha Hauer
2020-04-22  7:54 ` Sascha Hauer [this message]
2020-04-22  7:54 ` [PATCH 02/11] poller: Add a poller command Sascha Hauer
2020-04-22  7:54 ` [PATCH 03/11] Introduce slices Sascha Hauer
2020-05-08 18:01   ` Daniel Glöckner
2020-05-11  6:40     ` Sascha Hauer
2020-04-22  7:54 ` [PATCH 04/11] net: Add a slice to struct eth_device Sascha Hauer
2020-04-22  7:54 ` [PATCH 05/11] net: mdiobus: Add slice Sascha Hauer
2020-04-22  7:54 ` [PATCH 06/11] usb: Add a slice to usb host controllers Sascha Hauer
2020-04-22  7:54 ` [PATCH 07/11] usbnet: Add slice Sascha Hauer
2020-04-22  7:54 ` [PATCH 08/11] net: Call net_poll() in a poller Sascha Hauer
2020-04-22  7:54 ` [PATCH 09/11] net: reply to ping requests Sascha Hauer
2020-04-22  7:54 ` [PATCH 10/11] usbnet: Be more friendly in the receive path Sascha Hauer
2020-04-22  7:54 ` [PATCH 11/11] poller: Allow to run pollers inside of pollers Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200422075452.25226-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=dg@emlix.com \
    --cc=eh@emlix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox