From: Heinrich Schuchardt Date: Tue, 15 Dec 2020 20:07:49 +0100 Subject: [PATCH v2 6/7 RESEND] cmd: button: store button state in the 'button' env In-Reply-To: <20201215165439.13165-1-m.szyprowski@samsung.com> References: <20201215144230.9235-7-m.szyprowski@samsung.com> <20201215165439.13165-1-m.szyprowski@samsung.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 12/15/20 5:54 PM, Marek Szyprowski wrote: > Save examined button state in 'button' environment variable to enable > checking button state in the scripts. > > Signed-off-by: Marek Szyprowski > --- > Resend reason: get rid of the Change-Id tag, that was still in v2. > --- > cmd/button.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/cmd/button.c b/cmd/button.c > index 64c5a8fa04..8da911068a 100644 > --- a/cmd/button.c > +++ b/cmd/button.c > @@ -23,8 +23,10 @@ static int show_button_state(struct udevice *dev) > ret = button_get_state(dev); > if (ret >= BUTTON_COUNT) > ret = -EINVAL; > - if (ret >= 0) > + if (ret >= 0) { > printf("%s\n", state_label[ret]); > + env_set("button", state_label[ret]); Using a hard coded environment variable does not make much sense to me. The button command has a return value. So just use button mybutton; setenv myvar $? Best regards Heinrich > + } > > return ret; > } >