Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
On 6/20/23 22:40, Detlev Casanova wrote: 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; + charrevision[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. Yes I know, I am more concerned about other boards which might not have such short revision number, so why not just make the revision fields integer which covers very much anything ? Also, if you have those fields set to integer, then -EINVAL could be printed as '?' .
Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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 { > >>> > >>> charboardmodel[64]; > >>> > >>> + u8 id; > >>> + charrevision[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.
Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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; + charrevision[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?
Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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 { > > > > charboardmodel[64]; > > > > + u8 id; > > + charrevision[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 ?
Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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; + charrevision[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.
Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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 { > >>> > >>> charboardmodel[64]; > >>> > >>> + u8 id; > >>> + charrevision[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 ?
Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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; + charrevision[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.
Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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 { > > > > charboardmodel[64]; > > > > + u8 id; > > + charrevision[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. > [...]
Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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 { charboardmodel[64]; + u8 id; + charrevision[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 ? [...]
[PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
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 { charboardmodel[64]; + u8 id; + charrevision[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; default: return -EINVAL; }; + } static const struct sysinfo_ops sysinfo_rcar_ops = { .detect = sysinfo_rcar_detect, .get_str = sysinfo_rcar_get_str, + .get_int = sysinfo_rcar_get_int, }; static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) @@ -83,7 +105,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Salvator-X%s board rev %c.%c", salvator_xs ? "S" : "", rev_major, rev_minor); - return; + break; case BOARD_STARTER_KIT: if (!(board_rev & ~1)) { /* Only rev 0 and 1 is valid */ rev_major = (board_rev & BIT(0)) ? '3' : '1'; @@ -92,7 +114,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Starter Kit board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_STARTER_KIT_PRE: if (!(board_rev & ~3)) { /* Only rev 0..3 is valid */ rev_major = (board_rev & BIT(1)) ? '2' : '1'; @@ -101,7 +123,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Starter Kit Premier board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_EAGLE: if (!board_rev) { /* Only rev 0 is valid */ rev_major = '1'; @@ -110,7 +132,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Eagle board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_EBISU_4D: ebisu_4d = true; fallthrough; @@ -122,7 +144,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Ebisu%s board rev %c.%c", ebisu_4d ? "-4D" : "", rev_major, rev_minor); - return; + break; case BOARD_DRAAK: if (!board_rev) { /* Only rev 0 is valid */ rev_major = '1'; @@ -131,7 +153,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Draak board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_KRIEK: if (!board_rev) { /* Only rev 0 is valid */ rev_major = '1'; @@ -140,7 +162,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel), "Renesas Kriek board rev %c.%c", rev_major, rev_minor); - return; + break; case BOARD_CONDOR_I: condor_i = true; fallthrough; @@ -152,13 +174,17 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv) snprintf(priv->boardmodel, sizeof(priv->boardmodel),