From: Oleksij Rempel <o.rempel@pengutronix.de> To: barebox@lists.infradead.org Cc: Oleksij Rempel <o.rempel@pengutronix.de> Subject: [PATCH v1 1/2] add device state flags and add error state Date: Sun, 6 Jun 2021 14:23:59 +0200 [thread overview] Message-ID: <20210606122400.22418-1-o.rempel@pengutronix.de> (raw) Add state flags for each registered device and set error state on each dev_err print. This states can be used by users to identify erroneous device. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> --- include/driver.h | 13 +++++++++++++ include/printk.h | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/driver.h b/include/driver.h index d84fe35d50..b64a8e258c 100644 --- a/include/driver.h +++ b/include/driver.h @@ -88,6 +88,9 @@ struct device_d { * when the driver should actually detect client devices */ int (*detect) (struct device_d *); + +#define DEV_ERR BIT(0) + u32 run_flags; }; /** @brief Describes a driver present in the system */ @@ -361,6 +364,16 @@ static inline int dev_close_default(struct device_d *dev, struct filep *f) return 0; } +static inline void dev_set_err(struct device_d *dev) +{ + dev->run_flags |= DEV_ERR; +} + +static inline bool dev_have_err(struct device_d *dev) +{ + return !!(dev->run_flags & DEV_ERR); +} + struct bus_type { char *name; int (*match)(struct device_d *dev, struct driver_d *drv); diff --git a/include/printk.h b/include/printk.h index f83ad3bf07..6c563be3e6 100644 --- a/include/printk.h +++ b/include/printk.h @@ -61,7 +61,10 @@ static inline int pr_print(int level, const char *format, ...) #define dev_crit(dev, format, arg...) \ __dev_printf(2, (dev) , format , ## arg) #define dev_err(dev, format, arg...) \ - __dev_printf(3, (dev) , format , ## arg) + ({ \ + dev_set_err(dev); \ + __dev_printf(3, (dev) , format , ## arg); \ + }) #define dev_warn(dev, format, arg...) \ __dev_printf(4, (dev) , format , ## arg) #define dev_notice(dev, format, arg...) \ -- 2.29.2 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2021-06-06 12:26 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-06 12:23 Oleksij Rempel [this message] 2021-06-06 12:24 ` [PATCH v1 2/2] devinfo: print only devices with errors Oleksij Rempel 2021-06-16 7:59 ` Sascha Hauer 2021-06-16 8:19 ` Oleksij Rempel 2021-06-21 8:07 ` [PATCH v1 1/2] add device state flags and add error state Ahmad Fatoum 2021-06-21 8:24 ` Bartosz Bilas
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=20210606122400.22418-1-o.rempel@pengutronix.de \ --to=o.rempel@pengutronix.de \ --cc=barebox@lists.infradead.org \ --subject='Re: [PATCH v1 1/2] add device state flags and add error state' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox