qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: Kevin Wolf <kwolf@redhat.com>,
	peter.maydell@linaro.org, qemu-trivial@nongnu.org,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	edgar.iglesias@gmail.com
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH v1 1/5] block/nand: Factor out common code
Date: Wed, 19 Jun 2013 18:13:57 +1000	[thread overview]
Message-ID: <CAEgOgz4rOGjnaHEV9v88SiLS3MpWTrpfaf2B7yw9mU-B5GYq9Q@mail.gmail.com> (raw)
In-Reply-To: <51C16755.9050700@msgid.tls.msk.ru>

Hi Michael,

On Wed, Jun 19, 2013 at 6:09 PM, Michael Tokarev <mjt@tls.msk.ru> wrote:
> 18.06.2013 15:08, peter.crosthwaite@xilinx.com wrote:
>> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>
>> Most of this computation of s->iolen is the same for both the if and
>> else paths here. Factor out the common parts outside the if.
>>
>> Cc: qemu-trivial@nongnu.org
>>
>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>> ---
>>
>>  hw/block/nand.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/block/nand.c b/hw/block/nand.c
>> index 087ca14..6309f93 100644
>> --- a/hw/block/nand.c
>> +++ b/hw/block/nand.c
>> @@ -272,10 +272,10 @@ static void nand_command(NANDFlashState *s)
>>              break;
>>          offset = s->addr & ((1 << s->addr_shift) - 1);
>>          s->blk_load(s, s->addr, offset);
>> -        if (s->gnd)
>> -            s->iolen = (1 << s->page_shift) - offset;
>> -        else
>> -            s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
>> +        s->iolen = (1 << s->page_shift) - offset;
>> +        if (!s->gnd) {
>> +            s->iolen += 1 << s->oob_shift;
>> +        }
>
> Hm.  Can s->iolen become negative here?
>
> addr_shift can be either less or greather than page_shift.  When addr_shift
> is larger than page_shift (addr_shift=16, page_shift=11), offset may be up
> to 65535, in which case s->iolen may be -63487, even without additional
> oob_shift.
>
> I dunno if this is a concern, just.. asking.
>
> Besides, exactly the same expression is used in nand_getio() down this file,
> maybe a common function is in order? :)
>
> And looking at this file, I think it deserves some good type changes.  For
> example, all these _shift are unsigned, and most are actually used as masks,
> in form (1<<shift), instead of directly (except of erase_shift).
>

All sounds fair. Ill have another look in the context of type
changing, and factoring out some commonality. Your able to take P2
without conflict? :)

Regards,
Peter

> Thanks,
>
> /mjt
>

  reply	other threads:[~2013-06-19  8:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 11:07 [Qemu-devel] [PATCH v1 0/5] Nand Cleanup peter.crosthwaite
2013-06-18 11:08 ` [Qemu-devel] [PATCH v1 1/5] block/nand: Factor out common code peter.crosthwaite
2013-06-19  8:09   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-06-19  8:13     ` Peter Crosthwaite [this message]
2013-06-19  8:47       ` Michael Tokarev
2013-07-31 23:49     ` Peter Crosthwaite
2013-06-19  8:54   ` [Qemu-devel] " Peter Maydell
2013-06-18 11:08 ` [Qemu-devel] [PATCH v1 2/5] block/nand: Formatting sweep peter.crosthwaite
2013-06-19  7:53   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-06-18 11:10 ` [Qemu-devel] [PATCH v1 3/5] block/nand: QOM casting sweep peter.crosthwaite
2013-06-19 10:52   ` Andreas Färber
2013-06-18 11:11 ` [Qemu-devel] [PATCH v1 4/5] block/nand: Convert Sysbus::init to Device::realize peter.crosthwaite
2013-06-19 10:56   ` Andreas Färber
2013-06-18 11:12 ` [Qemu-devel] [PATCH v1 5/5] nand: Don't inherit from Sysbus peter.crosthwaite
2013-06-19 11:06   ` Andreas Färber
2013-06-25 18:16 ` [Qemu-devel] [PATCH v1 0/5] Nand Cleanup Peter Maydell
2013-06-26  0:37   ` Peter Crosthwaite

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=CAEgOgz4rOGjnaHEV9v88SiLS3MpWTrpfaf2B7yw9mU-B5GYq9Q@mail.gmail.com \
    --to=peter.crosthwaite@xilinx.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).