All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuval Shaia <yuval.shaia@oracle.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Marcel Apfelbaum <marcel@redhat.com>,
	qemu-devel@nongnu.org, ehabkost@redhat.com, mst@redhat.com,
	pbonzini@redhat.com, imammedo@redhat.com
Subject: Re: [Qemu-devel] [PATCH V2 1/5] pci/shpc: Move function to generic header file
Date: Sun, 17 Dec 2017 21:03:56 +0200	[thread overview]
Message-ID: <20171217190355.GA15664@yuvallap> (raw)
In-Reply-To: <2ff27216-1dc8-4025-0149-8d5321799120@amsat.org>

On Sun, Dec 17, 2017 at 03:16:15PM -0300, Philippe Mathieu-Daudé wrote:
> Hi Marcel, Yuval,
> 
> On 12/17/2017 09:54 AM, Marcel Apfelbaum wrote:
> > From: Yuval Shaia <yuval.shaia@oracle.com>
> > 
> > This function should be declared in generic header file so we can
> > utilize it.
> > 
> > Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> > Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> > ---
> >  hw/pci/shpc.c         | 11 +----------
> >  include/qemu/cutils.h | 10 ++++++++++
> >  2 files changed, 11 insertions(+), 10 deletions(-)
> > 
> > diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
> > index 69fc14b218..3d22424fd2 100644
> > --- a/hw/pci/shpc.c
> > +++ b/hw/pci/shpc.c
> > @@ -1,6 +1,7 @@
> >  #include "qemu/osdep.h"
> >  #include "qapi/error.h"
> >  #include "qemu-common.h"
> > +#include "qemu/cutils.h"
> >  #include "qemu/range.h"
> >  #include "qemu/error-report.h"
> >  #include "hw/pci/shpc.h"
> > @@ -122,16 +123,6 @@
> >  #define SHPC_PCI_TO_IDX(pci_slot) ((pci_slot) - 1)
> >  #define SHPC_IDX_TO_PHYSICAL(slot) ((slot) + 1)
> >  
> > -static int roundup_pow_of_two(int x)
> > -{
> > -    x |= (x >> 1);
> > -    x |= (x >> 2);
> > -    x |= (x >> 4);
> > -    x |= (x >> 8);
> > -    x |= (x >> 16);
> > -    return x + 1;
> > -}
> > -
> >  static uint16_t shpc_get_status(SHPCDevice *shpc, int slot, uint16_t msk)
> >  {
> >      uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot);
> > diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
> > index f0878eaafa..4895334645 100644
> > --- a/include/qemu/cutils.h
> > +++ b/include/qemu/cutils.h
> 
> I'd rather move this function below pow2ceil() in "qemu/host-utils.h"
> and rename it pow2roundup().
> 
> > @@ -164,4 +164,14 @@ bool test_buffer_is_zero_next_accel(void);
> >  int uleb128_encode_small(uint8_t *out, uint32_t n);
> >  int uleb128_decode_small(const uint8_t *in, uint32_t *n);
> >  
> > +static inline int roundup_pow_of_two(w x)
> > +{
> > +    x |= (x >> 1);
> > +    x |= (x >> 2);
> > +    x |= (x >> 4);
> > +    x |= (x >> 8);
> > +    x |= (x >> 16);
> 
> So this would be pow2roundup32(uint32_t value)...
> 
> Naming it pow2roundup() without specifying the integer size, I'd
> directly use a uint64_t argument, and:
> 
>        x |= (x >> 32);

Make sense, will do.

> 
> > +    return x + 1;
> > +}
> > +
> >  #endif
> 
> Naming it pow2roundup() in "qemu/host-utils.h" (regardless the arg size):
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Thanks.

> 
> Regards,
> 
> Phil.

  reply	other threads:[~2017-12-17 19:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-17 12:54 [Qemu-devel] [PATCH V2 0/5] hw/pvrdma: PVRDMA device implementation Marcel Apfelbaum
2017-12-17 12:54 ` [Qemu-devel] [PATCH V2 1/5] pci/shpc: Move function to generic header file Marcel Apfelbaum
2017-12-17 18:16   ` Philippe Mathieu-Daudé
2017-12-17 19:03     ` Yuval Shaia [this message]
2017-12-17 12:54 ` [Qemu-devel] [PATCH V2 2/5] mem: add share parameter to memory-backend-ram Marcel Apfelbaum
2017-12-17 12:54 ` [Qemu-devel] [PATCH V2 3/5] docs: add pvrdma device documentation Marcel Apfelbaum
2017-12-19 17:47   ` Michael S. Tsirkin
2017-12-20 14:45     ` Marcel Apfelbaum
2017-12-17 12:54 ` [Qemu-devel] [PATCH V2 4/5] pvrdma: initial implementation Marcel Apfelbaum
2017-12-19 16:12   ` Michael S. Tsirkin
2017-12-19 17:29     ` Marcel Apfelbaum
2017-12-19 17:48   ` Michael S. Tsirkin
2017-12-20 15:25     ` Yuval Shaia
2017-12-20 18:01       ` Michael S. Tsirkin
2017-12-19 19:13   ` Philippe Mathieu-Daudé
2017-12-20  4:08     ` Michael S. Tsirkin
2017-12-20 14:46       ` Marcel Apfelbaum
2017-12-17 12:54 ` [Qemu-devel] [PATCH V2 5/5] MAINTAINERS: add entry for hw/net/pvrdma Marcel Apfelbaum
2017-12-19 17:49   ` Michael S. Tsirkin
2017-12-19 18:05 ` [Qemu-devel] [PATCH V2 0/5] hw/pvrdma: PVRDMA device implementation Michael S. Tsirkin
2017-12-20 15:07   ` Marcel Apfelbaum
2017-12-21  0:05     ` Michael S. Tsirkin
2017-12-21  7:27       ` Yuval Shaia
2017-12-21 14:22         ` Michael S. Tsirkin
2017-12-21 15:59           ` Marcel Apfelbaum
2017-12-21 20:46             ` Michael S. Tsirkin
2017-12-21 22:30               ` Yuval Shaia
2017-12-22  4:58                 ` Marcel Apfelbaum
2017-12-20 17:56   ` Yuval Shaia
2017-12-20 18:05     ` Michael S. Tsirkin

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=20171217190355.GA15664@yuvallap \
    --to=yuval.shaia@oracle.com \
    --cc=ehabkost@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=imammedo@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@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.