Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33038C433F5 for ; Tue, 14 Dec 2021 23:50:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5D0DF811D8; Wed, 15 Dec 2021 00:50:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 7957C8129B; Wed, 15 Dec 2021 00:50:05 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 6142E80FF4 for ; Wed, 15 Dec 2021 00:50:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 98D806D; Tue, 14 Dec 2021 15:50:00 -0800 (PST) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BDA033F774; Tue, 14 Dec 2021 15:49:59 -0800 (PST) Date: Tue, 14 Dec 2021 23:49:50 +0000 From: Andre Przywara To: Javad Rahimi Cc: u-boot@lists.denx.de, jagan@amarulasolutions.com, hdegoede@redhat.com Subject: Re: [RFC PATCH v2] Cubieboard2:Enable early LED support Message-ID: <20211214234950.7372c612@slackpad.fritz.box> In-Reply-To: <20211212072213.55584-1-javad321javad@gmail.com> References: <20211212072213.55584-1-javad321javad@gmail.com> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Sun, 12 Dec 2021 10:52:13 +0330 Javad Rahimi wrote: Hi, > This patch removes the "status_led_init_done" global variable. > By removing that variable, it is possible > to use LEDs early in SPL, in architectures > where .BSS is placed in DRAM area. (For example A20 series) > > Signed-off-by: Javad Rahimi This patch is on top of the other patch you sent, but which was dismissed. Please squash the two patches into one (for instance with "git rebase -i"), and resend. Cheers, Andre > --- > > Changes in v2: > - "initialized" variable removed from "led_dev_t" > - "state" variable is used as initialization flag > - Helper macros defined for initialization > - Initialization is checked at begining of LED operations > > drivers/misc/status_led.c | 28 +++++++++++----------------- > 1 file changed, 11 insertions(+), 17 deletions(-) > > diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c > index 7d30355423..23d932ec6e 100644 > --- a/drivers/misc/status_led.c > +++ b/drivers/misc/status_led.c > @@ -23,7 +23,6 @@ typedef struct { > int state; > int period; > int cnt; > - int initialized:1; > } led_dev_t; > > led_dev_t led_dev[] = { > @@ -31,14 +30,12 @@ led_dev_t led_dev[] = { > CONFIG_LED_STATUS_STATE, > LED_STATUS_PERIOD, > 0, > - 0, > }, > #if defined(CONFIG_LED_STATUS1) > { CONFIG_LED_STATUS_BIT1, > CONFIG_LED_STATUS_STATE1, > LED_STATUS_PERIOD1, > 0, > - 0, > }, > #endif > #if defined(CONFIG_LED_STATUS2) > @@ -46,7 +43,6 @@ led_dev_t led_dev[] = { > CONFIG_LED_STATUS_STATE2, > LED_STATUS_PERIOD2, > 0, > - 0, > }, > #endif > #if defined(CONFIG_LED_STATUS3) > @@ -54,7 +50,6 @@ led_dev_t led_dev[] = { > CONFIG_LED_STATUS_STATE3, > LED_STATUS_PERIOD3, > 0, > - 0, > }, > #endif > #if defined(CONFIG_LED_STATUS4) > @@ -62,7 +57,6 @@ led_dev_t led_dev[] = { > CONFIG_LED_STATUS_STATE4, > LED_STATUS_PERIOD4, > 0, > - 0, > }, > #endif > #if defined(CONFIG_LED_STATUS5) > @@ -70,13 +64,17 @@ led_dev_t led_dev[] = { > CONFIG_LED_STATUS_STATE5, > LED_STATUS_PERIOD5, > 0, > - 0, > }, > #endif > }; > > #define MAX_LED_DEV (sizeof(led_dev)/sizeof(led_dev_t)) > +#define LED_INITIALIZED_BIT 0x8 > +#define LED_STATE_MASK 0x3 > > +#define LED_IS_INITIALIZED(x) (!!((x) & LED_INITIALIZED_BIT)) > +#define LED_INITIALIZE(x) ((x) |= (LED_INITIALIZED_BIT)) > +#define LED_GET_STATE(x) ((x) & LED_STATE_MASK) > > void status_led_init(void) > { > @@ -85,11 +83,8 @@ void status_led_init(void) > > for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) { > __led_init (ld->mask, ld->state); > - ld->initialized = 1; > + LED_INITIALIZE(ld->state); > } > - > - return 0; > - > } > > void status_led_tick(ulong timestamp) > @@ -99,8 +94,8 @@ void status_led_tick(ulong timestamp) > > for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) { > > - if (!ld->initialized) > - continue; > + if (!LED_IS_INITIALIZED(ld->state)) > + status_led_init(); > > if (ld->state != CONFIG_LED_STATUS_BLINKING) > continue; > @@ -109,7 +104,6 @@ void status_led_tick(ulong timestamp) > __led_toggle (ld->mask); > ld->cnt -= ld->period; > } > - > } > } > > @@ -122,10 +116,10 @@ void status_led_set(int led, int state) > > ld = &led_dev[led]; > > - if (!ld->initialized) > - return; > + if (!LED_IS_INITIALIZED(ld->state)) > + status_led_init(); > > - ld->state = state; > + ld->state = LED_GET_STATE(ld->state); > if (state == CONFIG_LED_STATUS_BLINKING) { > ld->cnt = 0; /* always start with full period */ > state = CONFIG_LED_STATUS_ON; /* always start with LED _ON_ */