From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Mon, 21 Jun 2021 10:25:34 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1lvFFO-00004q-1o for lore@lore.pengutronix.de; Mon, 21 Jun 2021 10:25:34 +0200 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvFFN-0007p4-1z for lore@pengutronix.de; Mon, 21 Jun 2021 10:25:33 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From:Cc: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SNAcqqV0JxfjrQi9EMi13RoMIAZzl2xwUUlwYLy+s40=; b=0syCKWzjs2EgvO2f9OPrWoiGU3 pjcebNPSJ/OKqGd93qE9IQ1o1/CeYB9dl+9PsWK2/vkMn7mYArp0cfjDL9oGm+XjxW2wHqJ+IziMl wGNsiemLltpKV6/wkHe376kkghdHRuSBi6d/Z+MYt6ePubImy9ZoY0UbiDQXBQ4GuJloX/t7chcB8 K85Ue0DRzqNF9/ZIKNO+MhPfIkr3/+5eMjeuC5Kdqm8k/bw7BUbGSvr46++SfcGpZ9i2I4UewDC95 MGd4avhwhHq7AA44AoKZ60uCrPobgJS18uWXimlzosZU7cHilMqcjwDbqrqZ3Q2oAktIZ47+tSFxx ECvmh7uw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvFE9-002ffM-Kw; Mon, 21 Jun 2021 08:24:17 +0000 Received: from mail.grinn-global.com ([77.55.128.204]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvFE3-002fd2-Oz for barebox@lists.infradead.org; Mon, 21 Jun 2021 08:24:13 +0000 X-Virus-Scanned: by amavisd-new using ClamAV (3) Received: from [192.168.10.50] (host-81-161-202-4.oxylion.net.pl [81.161.202.4]) by server220076.nazwa.pl (Postfix) with ESMTP id 08F031C4024; Mon, 21 Jun 2021 10:24:04 +0200 (CEST) To: Ahmad Fatoum References: <20210606122400.22418-1-o.rempel@pengutronix.de> <5792bbab-5d62-e534-c8c3-8838ad953a5f@pengutronix.de> Cc: barebox@lists.infradead.org, Oleksij Rempel From: Bartosz Bilas Message-ID: <28da9ab3-af43-eec8-8b2b-3f2957d8d393@grinn-global.com> Date: Mon, 21 Jun 2021 10:24:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <5792bbab-5d62-e534-c8c3-8838ad953a5f@pengutronix.de> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210621_012412_057261_AC771F32 X-CRM114-Status: GOOD ( 24.18 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:e::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-4.9 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: Re: [PATCH v1 1/2] add device state flags and add error state X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) Hello, On 21.06.2021 10:07, Ahmad Fatoum wrote: > On 06.06.21 14:23, Oleksij Rempel wrote: >> 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. > I thought this over a bit. We have dev_err calls when: > > - probes are permanently deferred > - have actual probe (!= -ENODEV, != -ENXIO, != -EPROBE_DEFER) > - after probe something fails (e.g. you got the regulator, but couldn't enable it) > > So, I think the hook point is appropriate. Board code could extend this > and get a device and do some extra tests and use dev_set_err as appropriate. > > So feel free to add: > > Acked-by: Ahmad Fatoum > >> Signed-off-by: Oleksij Rempel >> --- >> 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; > Just turn it into a bit field instead? > >> }; >> >> /** @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); Isn't return dev->run_flags & DEV_ERR enough here? Best Bartek >> +} >> + >> 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) >> + ({ \ > You're already using statement expressions, so you could add a > struct device_d *__dev = (dev); > here and use that. > >> + 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...) \ >> _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox