All of lore.kernel.org
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	 Daniel Henrique Barboza <danielhb413@gmail.com>,
	 Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH 08/20] ppc4xx_sdram: Drop extra zeros for readability
Date: Wed, 7 Sep 2022 16:32:20 +0200 (CEST)	[thread overview]
Message-ID: <45322b4f-1b2e-3b49-2568-f67fe347458c@eik.bme.hu> (raw)
In-Reply-To: <19465d5c-6411-37cf-444b-98b643682c7e@kaod.org>

[-- Attachment #1: Type: text/plain, Size: 4923 bytes --]

On Wed, 7 Sep 2022, Cédric Le Goater wrote:
> On 8/19/22 18:55, BALATON Zoltan wrote:
>> Constants that are written zero padded for no good reason are hard to
>> read, it's easier to see what is meant if it's just 0 or 1 instead.
>
> I would keep the 0x prefix though.

I'm not a fan of 0x0 or 0x prefix for numbers below 0xa as it's more 
confusing than just having the simple number since these are the same in 
decimal and hex so I always think it might be 0xC or something not just 0 
when I see a prefix and have to double check. So unless there's a good 
reaon to write them in hex it's simpler to only use the 0x when really 
needed. Maybe if you really want the 0x I could keep it in the switch 
below just for consistency with other cases there but wouldn't have them 
elsewhere. Is it really not acceptable for you as in this patch?

Regards,
BALATON Zoltan

> Thanks,
>
> C.
>
>
>> 
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>>   hw/ppc/ppc4xx_devs.c | 40 ++++++++++++++++++++--------------------
>>   1 file changed, 20 insertions(+), 20 deletions(-)
>> 
>> diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
>> index 375834a52b..bfe7b2d3a6 100644
>> --- a/hw/ppc/ppc4xx_devs.c
>> +++ b/hw/ppc/ppc4xx_devs.c
>> @@ -49,31 +49,31 @@ static uint32_t sdram_ddr_bcr(hwaddr ram_base, hwaddr 
>> ram_size)
>>         switch (ram_size) {
>>       case 4 * MiB:
>> -        bcr = 0x00000000;
>> +        bcr = 0;
>>           break;
>>       case 8 * MiB:
>> -        bcr = 0x00020000;
>> +        bcr = 0x20000;
>>           break;
>>       case 16 * MiB:
>> -        bcr = 0x00040000;
>> +        bcr = 0x40000;
>>           break;
>>       case 32 * MiB:
>> -        bcr = 0x00060000;
>> +        bcr = 0x60000;
>>           break;
>>       case 64 * MiB:
>> -        bcr = 0x00080000;
>> +        bcr = 0x80000;
>>           break;
>>       case 128 * MiB:
>> -        bcr = 0x000A0000;
>> +        bcr = 0xA0000;
>>           break;
>>       case 256 * MiB:
>> -        bcr = 0x000C0000;
>> +        bcr = 0xC0000;
>>           break;
>>       default:
>>           qemu_log_mask(LOG_GUEST_ERROR,
>>                         "%s: invalid RAM size 0x%" HWADDR_PRIx "\n", 
>> __func__,
>>                         ram_size);
>> -        return 0x00000000;
>> +        return 0;
>>       }
>>       bcr |= ram_base & 0xFF800000;
>>       bcr |= 1;
>> @@ -104,7 +104,7 @@ static target_ulong sdram_size(uint32_t bcr)
>>   static void sdram_set_bcr(Ppc4xxSdramDdrState *sdram, int i,
>>                             uint32_t bcr, int enabled)
>>   {
>> -    if (sdram->bank[i].bcr & 0x00000001) {
>> +    if (sdram->bank[i].bcr & 1) {
>>           /* Unmap RAM */
>>           trace_ppc4xx_sdram_unmap(sdram_base(sdram->bank[i].bcr),
>>                                    sdram_size(sdram->bank[i].bcr));
>> @@ -115,7 +115,7 @@ static void sdram_set_bcr(Ppc4xxSdramDdrState *sdram, 
>> int i,
>>           object_unparent(OBJECT(&sdram->bank[i].container));
>>       }
>>       sdram->bank[i].bcr = bcr & 0xFFDEE001;
>> -    if (enabled && (bcr & 0x00000001)) {
>> +    if (enabled && (bcr & 1)) {
>>           trace_ppc4xx_sdram_map(sdram_base(bcr), sdram_size(bcr));
>>           memory_region_init(&sdram->bank[i].container, NULL, 
>> "sdram-container",
>>                              sdram_size(bcr));
>> @@ -136,7 +136,7 @@ static void sdram_map_bcr(Ppc4xxSdramDdrState *sdram)
>>               sdram_set_bcr(sdram, i, sdram_ddr_bcr(sdram->bank[i].base,
>>                                                     sdram->bank[i].size), 
>> 1);
>>           } else {
>> -            sdram_set_bcr(sdram, i, 0x00000000, 0);
>> +            sdram_set_bcr(sdram, i, 0, 0);
>>           }
>>       }
>>   }
>> @@ -213,7 +213,7 @@ static uint32_t sdram_ddr_dcr_read(void *opaque, int 
>> dcrn)
>>           break;
>>       default:
>>           /* Avoid gcc warning */
>> -        ret = 0x00000000;
>> +        ret = 0;
>>           break;
>>       }
>>   @@ -306,18 +306,18 @@ static void ppc4xx_sdram_ddr_reset(DeviceState 
>> *dev)
>>   {
>>       Ppc4xxSdramDdrState *sdram = PPC4xx_SDRAM_DDR(dev);
>>   -    sdram->addr = 0x00000000;
>> -    sdram->bear = 0x00000000;
>> -    sdram->besr0 = 0x00000000; /* No error */
>> -    sdram->besr1 = 0x00000000; /* No error */
>> -    sdram->cfg = 0x00000000;
>> -    sdram->ecccfg = 0x00000000; /* No ECC */
>> -    sdram->eccesr = 0x00000000; /* No error */
>> +    sdram->addr = 0;
>> +    sdram->bear = 0;
>> +    sdram->besr0 = 0; /* No error */
>> +    sdram->besr1 = 0; /* No error */
>> +    sdram->cfg = 0;
>> +    sdram->ecccfg = 0; /* No ECC */
>> +    sdram->eccesr = 0; /* No error */
>>       sdram->pmit = 0x07C00000;
>>       sdram->rtr = 0x05F00000;
>>       sdram->tr = 0x00854009;
>>       /* We pre-initialize RAM banks */
>> -    sdram->status = 0x00000000;
>> +    sdram->status = 0;
>>       sdram->cfg = 0x00800000;
>>   }
>> 
>
>
>

  reply	other threads:[~2022-09-07 14:33 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 16:55 [PATCH 00/20] ppc4xx_sdram QOMify and clean ups BALATON Zoltan
2022-08-19 16:55 ` [PATCH 01/20] ppc440_bamboo: Remove unnecessary memsets BALATON Zoltan
2022-08-19 16:55 ` [PATCH 02/20] ppc4xx: Introduce Ppc4xxSdramBank struct BALATON Zoltan
2022-09-04 11:44   ` Philippe Mathieu-Daudé via
2022-08-19 16:55 ` [PATCH 03/20] ppc4xx_sdram: Get rid of the init RAM hack BALATON Zoltan
2022-09-02 10:46   ` Cédric Le Goater
2022-09-02 15:48     ` BALATON Zoltan
2022-08-19 16:55 ` [PATCH 04/20] ppc4xx: Use Ppc4xxSdramBank in ppc4xx_sdram_banks() BALATON Zoltan
2022-09-02 10:49   ` Cédric Le Goater
2022-09-02 18:54     ` BALATON Zoltan
2022-09-09 19:32       ` BALATON Zoltan
2022-08-19 16:55 ` [PATCH 05/20] ppc440_bamboo: Add missing 4 MiB valid memory size BALATON Zoltan
2022-09-07 13:17   ` Cédric Le Goater
2022-08-19 16:55 ` [PATCH 06/20] ppc4xx_sdram: Move size check to ppc4xx_sdram_init() BALATON Zoltan
2022-09-07 13:24   ` Cédric Le Goater
2022-09-07 14:53     ` BALATON Zoltan
2022-08-19 16:55 ` [PATCH 07/20] ppc4xx_sdram: QOM'ify BALATON Zoltan
2022-09-07 13:29   ` Cédric Le Goater
2022-08-19 16:55 ` [PATCH 08/20] ppc4xx_sdram: Drop extra zeros for readability BALATON Zoltan
2022-09-07 13:30   ` Cédric Le Goater
2022-09-07 14:32     ` BALATON Zoltan [this message]
2022-08-19 16:55 ` [PATCH 09/20] ppc440_sdram: Split off map/unmap of sdram banks for later reuse BALATON Zoltan
2022-09-07 13:34   ` Cédric Le Goater
2022-09-07 14:34     ` BALATON Zoltan
2022-08-19 16:55 ` [PATCH 10/20] ppc440_sdram: Implement enable bit in the DDR2 SDRAM controller BALATON Zoltan
2022-09-04 11:53   ` Philippe Mathieu-Daudé via
2022-09-04 11:59     ` BALATON Zoltan
2022-09-07 13:38   ` Cédric Le Goater
2022-09-07 14:37     ` BALATON Zoltan
2022-08-19 16:55 ` [PATCH 11/20] ppc440_sdram: Get rid of the init RAM hack BALATON Zoltan
2022-08-19 16:55 ` [PATCH 12/20] ppc440_sdram: Rename local variable for readibility BALATON Zoltan
2022-09-07 13:46   ` Cédric Le Goater
2022-08-19 16:55 ` [PATCH 13/20] ppc4xx_sdram: Rename functions to prevent name clashes BALATON Zoltan
2022-09-07 13:47   ` Cédric Le Goater
2022-09-07 14:38     ` BALATON Zoltan
2022-08-19 16:55 ` [PATCH 14/20] ppc440_sdram: Move RAM size check to ppc440_sdram_init BALATON Zoltan
2022-09-07 13:51   ` Cédric Le Goater
2022-09-07 14:41     ` BALATON Zoltan
2022-08-19 16:55 ` [PATCH 15/20] ppc440_sdram: QOM'ify BALATON Zoltan
2022-09-07 13:52   ` Cédric Le Goater
2022-08-19 16:55 ` [PATCH 16/20] ppc4xx_sdram: Move ppc4xx DDR and DDR2 SDRAM controller models together BALATON Zoltan
2022-08-19 16:55 ` [PATCH 17/20] ppc4xx_sdram: Use hwaddr for memory bank size BALATON Zoltan
2022-09-04 11:57   ` Philippe Mathieu-Daudé via
2022-08-19 16:55 ` [PATCH 18/20] ppc4xx_sdram: Rename local state variable for brevity BALATON Zoltan
2022-08-19 16:55 ` [PATCH 19/20] ppc4xx_sdram: Generalise bank setup BALATON Zoltan
2022-08-19 16:55 ` [PATCH 20/20] ppc4xx_sdram: Convert DDR SDRAM controller to new bank handling BALATON Zoltan
2022-09-01 21:02 ` [PATCH 00/20] ppc4xx_sdram QOMify and clean ups BALATON Zoltan
2022-09-02  8:35   ` Cédric Le Goater
2022-09-02  8:41     ` Cédric Le Goater
2022-09-02 10:29       ` BALATON Zoltan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45322b4f-1b2e-3b49-2568-f67fe347458c@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.