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 B5D9AEB64D9 for ; Mon, 19 Jun 2023 14:48:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A767865C0; Mon, 19 Jun 2023 16:48:45 +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="mK48cRUU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 54EB4865C0; Mon, 19 Jun 2023 16:48:24 +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 0A40C8637D for ; Mon, 19 Jun 2023 16:42:27 +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 (mtl.collabora.ca [66.171.169.34]) (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 BB05866003B0; Mon, 19 Jun 2023 15:42:26 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687185747; bh=/v5QcZeTooZ5C46gELbaJzoI9nhj5gSVjGojdnNgFfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mK48cRUUFo8ukUNuhEjugM+bbH2JCYODbWxd60kqgMGmnaEe4/z6TMfgrMHQyhHuj uEqYLz2ey0gmzkOfynTAVBULANgS6sRLfp7n6668ZzF86upte6zpHgr+7BaR8gEtvZ V0sPj0b6v479blPcikMjHsVqrauTrvE3tNuOre4JX09plUJiRAdcWxxVtfC8ISqz6J lPCNv5uXBAWPY3OUJ1fAscPbWV9meRWHmkD5NVFB7r8EQl3N/5ZiLQzQfT1L//CnoZ wYzs3dBPsjbt13sTciSwvFzzW2ohlfnapxfn+843Mg9enAosvPW/SwJJKWUZ0qlFbE bA3Hvk09JgbFQ== 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: Mon, 19 Jun 2023 10:42:28 -0400 Message-ID: <5716916.DvuYhMxLoT@arisu> In-Reply-To: <446b6cc4-2bd5-156f-7bc4-e0a9ddb2e872@mailbox.org> References: <20230616152122.588168-1-detlev.casanova@collabora.com> <20230616152122.588168-4-detlev.casanova@collabora.com> <446b6cc4-2bd5-156f-7bc4-e0a9ddb2e872@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 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. > [...]