[PATCH] ARM: rmobile: Clean up rmobile_cpuinfo_idx()
Paul Barker
paul.barker.ct at bp.renesas.com
Sun Aug 20 10:34:52 CEST 2023
On 19/08/2023 15:39, Marek Vasut wrote:
> Clean the function up a bit further. Return immediatelly on match
> and return ARRAY_SIZE() - 1 on failure. Add proper comment in that
> case.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> ---
> Cc: Biju Das <biju.das.jz at bp.renesas.com>
> Cc: Paul Barker <paul.barker.ct at bp.renesas.com>
> ---
> arch/arm/mach-rmobile/cpu_info.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/mach-rmobile/cpu_info.c b/arch/arm/mach-rmobile/cpu_info.c
> index 7651e43bd0f..6804b1da2cd 100644
> --- a/arch/arm/mach-rmobile/cpu_info.c
> +++ b/arch/arm/mach-rmobile/cpu_info.c
> @@ -83,14 +83,15 @@ static const struct {
>
> static int rmobile_cpuinfo_idx(void)
> {
> - int i = 0;
> u32 cpu_type = rmobile_get_cpu_type();
> + int i;
>
> - for (; i < ARRAY_SIZE(rmobile_cpuinfo) - 1; i++)
> + for (i = 0; i < ARRAY_SIZE(rmobile_cpuinfo) - 1; i++)
> if (rmobile_cpuinfo[i].cpu_type == cpu_type)
> - break;
> + return i;
>
> - return i;
> + /* Unknown "CPU" entry */
> + return ARRAY_SIZE(rmobile_cpuinfo) - 1;
> }
>
> static const u8 *get_cpu_name(int idx)
Reviewed-by: Paul Barker <paul.barker.ct at bp.renesas.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x27F4B3459F002257.asc
Type: application/pgp-keys
Size: 3520 bytes
Desc: OpenPGP public key
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20230820/4550b658/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20230820/4550b658/attachment.sig>
More information about the U-Boot
mailing list