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 549ABEB64DA for ; Mon, 19 Jun 2023 18:27:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77E1D85FE2; Mon, 19 Jun 2023 20:27:40 +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="H1EdRXvZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 62B9485FE2; Mon, 19 Jun 2023 20:27:38 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (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 055EA8550A for ; Mon, 19 Jun 2023 20:27:36 +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 EDB236606F91; Mon, 19 Jun 2023 19:27:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687199255; bh=jf5Brx7c3ixMOTgnyjgdCpbeBBO+lAYe8zs8Tk07lWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H1EdRXvZXPFA4DK8eGGd9uBQpddpTRk/mBeinE5CiYaRF8vm/QYGPktM5Z+hpzqUc +/PBRAv5YwAo6QW5AFojCnZRr5thwwg0/mWG0glSzqYLO3OjUIyP1Nv20DyBDjI75v rRbbSjzpNFPXcScbN4gOCoV+oxx8Fmk1irdjKDTKktMuo9jKi1vF8KSTk8aLIRARLE UhEuwfhOVQav3tINYsYEO5v1hB+envONCdzIIW5mA86FZa2A6ih+KfetdRX3bXb2Ek YaUWsxKaP/GY99OLthTUN2KhaapAnMlldvqlV3aLytuZOd0KacorLZn59w2ZY/iOsd gzfcRY5+MAYoA== 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 14:27:37 -0400 Message-ID: <4842991.GXAFRqVoOG@arisu> In-Reply-To: <33abeadc-14d0-267c-130e-224539383044@mailbox.org> References: <20230616152122.588168-1-detlev.casanova@collabora.com> <5716916.DvuYhMxLoT@arisu> <33abeadc-14d0-267c-130e-224539383044@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 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 ?