From mboxrd@z Thu Jan 1 00:00:00 1970 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 0241DEB64D7 for ; Tue, 20 Jun 2023 20:40:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C6F9856C4; Tue, 20 Jun 2023 22:40:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="oQNzQfGL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 11AF0860B4; Tue, 20 Jun 2023 22:40:15 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D557D84723 for ; Tue, 20 Jun 2023 22:40:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=detlev.casanova@collabora.com Received: from arisu.localnet (unknown [23.233.251.139]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id B67E56606F6C; Tue, 20 Jun 2023 21:40:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687293611; bh=x0ZN8qDbquQApndfGI4fXyKbrzRIE8XATmY0+hM+Oi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQNzQfGL41XHibQLgSCeT21R6TfnQMBJJtDDyO+P6JfJoZix7peJw177uilud3EyC QfWrzNxEOruo4FjtdrjFxLYLrRr+d9IWFB188q+WlGAWG5rI79uTMq6OHziyEgkCvh 28L+kkswwb0ExnsEppIsbVDXcCS1sUZ8WPJ+G8T2kULrGFQ3NqiESNpuQmKF+RZt25 3ow+RCfwuP9eCgvB41jCPspUOOuOeSjtCYOFjSds8Kiaigm2QBl5uaTq2X9vzjmIs2 o+cHXKiWz6CoMhRyqkNhh7vdTsXmwYR7TcfjQu5A1+5s3Ilm+4CqDy08efHKReLuX0 n+TKKX2JXFrHg== From: Detlev Casanova To: u-boot@lists.denx.de, Marek Vasut Cc: Marek Vasut , Hai Pham , Tam Nguyen Subject: Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION Date: Tue, 20 Jun 2023 16:40:13 -0400 Message-ID: <5945555.lOV4Wx5bFT@arisu> In-Reply-To: <8e9f0f5a-5203-dc5b-0921-f0e61df91f92@mailbox.org> References: <20230616152122.588168-1-detlev.casanova@collabora.com> <12231072.O9o76ZdvQC@arisu> <8e9f0f5a-5203-dc5b-0921-f0e61df91f92@mailbox.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean On Tuesday, June 20, 2023 4:03:18 P.M. EDT Marek Vasut wrote: > On 6/20/23 19:49, Detlev Casanova wrote: > > On Monday, June 19, 2023 5:54:44 P.M. EDT Marek Vasut wrote: > >> On 6/19/23 20:27, Detlev Casanova wrote: > >>> On Monday, June 19, 2023 12:11:18 P.M. EDT Marek Vasut wrote: > >>>> On 6/19/23 16:42, Detlev Casanova wrote: > >>>>> On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote: > >>>>>> On 6/16/23 17:21, Detlev Casanova wrote: > >>>>>>> Expose that information to the command shell to let scripts select > >>>>>>> the > >>>>>>> correct devicetree name. > >>>>>>> > >>>>>>> Signed-off-by: Detlev Casanova > >>>>>>> --- > >>>>>>> > >>>>>>> drivers/sysinfo/rcar3.c | 46 > >>>>>>> ++++++++++++++++++++++++++++++++--------- > >>>>>>> 1 file changed, 36 insertions(+), 10 deletions(-) > >>>>>>> > >>>>>>> diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c > >>>>>>> index 7b127986da7..89ad46c5422 100644 > >>>>>>> --- a/drivers/sysinfo/rcar3.c > >>>>>>> +++ b/drivers/sysinfo/rcar3.c > >>>>>>> @@ -32,6 +32,8 @@ > >>>>>>> > >>>>>>> */ > >>>>>>> > >>>>>>> struct sysinfo_rcar_priv { > >>>>>>> > >>>>>>> char boardmodel[64]; > >>>>>>> > >>>>>>> + u8 id; > >>>>>>> + char revision[4]; > >>>>>>> > >>>>>>> u8 val; > >>>>>>> > >>>>>>> }; > >>>>>>> > >>>>>>> @@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice > >>>>>>> *dev, > >>>>>>> int id, size_t size, char *> > >>>>>>> > >>>>>>> switch (id) { > >>>>>>> > >>>>>>> case SYSINFO_ID_BOARD_MODEL: > >>>>>>> - strncpy(val, priv->boardmodel, size); > >>>>>>> - val[size - 1] = '\0'; > >>>>>>> + strlcpy(val, priv->boardmodel, size); > >>>>>>> + break; > >>>>>>> + case SYSINFO_ID_BOARD_REVISION: > >>>>>>> + strlcpy(val, priv->revision, size); > >>>>>>> + break; > >>>>>>> + default: > >>>>>>> + return -EINVAL; > >>>>>>> + }; > >>>>>>> + > >>>>>>> + val[size - 1] = '\0'; > >>>>>>> + return 0; > >>>>>>> +} > >>>>>>> + > >>>>>>> +static int sysinfo_rcar_get_int(struct udevice *dev, int id, int > >>>>>>> *val) > >>>>>>> +{ > >>>>>>> + struct sysinfo_rcar_priv *priv = dev_get_priv(dev); > >>>>>>> + > >>>>>>> + switch (id) { > >>>>>>> + case SYSINFO_ID_BOARD_ID: > >>>>>>> + *val = priv->id; > >>>>>>> > >>>>>>> return 0; > >>>>>> > >>>>>> Why not return SYSINFO_ID_BOARD_REVISION as integer here ? > >>>>> > >>>>> Because the revision (on r-car3 boards at least) is in the format X.Y. > >>>>> It > >>>>> could be returned as "(X << 8) | Y" or split in major/minor. But > >>>>> different > >>>>> boards will use different revisions and I think that having a str is > >>>>> easier to deal with in a shell script. > >>>> > >>>> With rcar they are numbers, so lets go with major/minor integers > >>>> please. > >>> > >>> Ok for this part, but shouldn't the sysinfo command use a common > >>> interface > >>> for all boards ? Or should it also have rev_major/rev_minor arguments ? > >> > >> I would expect other boards to either report rev_major/rev_minor if > >> implemented, or errno if those boards don't implement this property. > > > > Another thing on rcar is that the revision is stored as 2 char values. > > Would you oppose a change form using a char (e.g. rev_major = '1') to > > using u8 values (e.g. rev_major = 1) instead ? > > Shouldn't those rev fields just be integer(s) to cover the generic case? On rcar, they are chars. I don't really see a reason for this except to show the '?.?' on unknown board ids. But that can be managed in other ways.