Patchwork [v2,1/3] hw: import bitmap operations in qdev-core header

login
register
mail settings
Submitter Marcel Apfelbaum
Date July 29, 2013, 7:07 a.m.
Message ID <1375081655-28541-2-git-send-email-marcel.a@redhat.com>
Download mbox | patch
Permalink /patch/262693/
State New
Headers show

Comments

Marcel Apfelbaum - July 29, 2013, 7:07 a.m.
Made small tweaks in code to prevent compilation issues
when importing qemu/bitmap.h in qdev-core

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/core/qdev-properties.c | 4 ++--
 hw/net/eepro100.c         | 1 -
 include/hw/qdev-core.h    | 1 +
 3 files changed, 3 insertions(+), 3 deletions(-)
Michael S. Tsirkin - July 29, 2013, 7:42 a.m.
On Mon, Jul 29, 2013 at 10:07:33AM +0300, Marcel Apfelbaum wrote:
> Made small tweaks in code to prevent compilation issues
> when importing qemu/bitmap.h in qdev-core
> 
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> ---
>  hw/core/qdev-properties.c | 4 ++--
>  hw/net/eepro100.c         | 1 -
>  include/hw/qdev-core.h    | 1 +
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 3a324fb..01b27eb 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -91,7 +91,7 @@ static void get_bit(Object *obj, Visitor *v, void *opaque,
>      visit_type_bool(v, &value, name, errp);
>  }
>  
> -static void set_bit(Object *obj, Visitor *v, void *opaque,
> +static void prop_set_bit(Object *obj, Visitor *v, void *opaque,
>                      const char *name, Error **errp)
>  {
>      DeviceState *dev = DEVICE(obj);
> @@ -117,7 +117,7 @@ PropertyInfo qdev_prop_bit = {
>      .legacy_name  = "on/off",
>      .print = print_bit,
>      .get   = get_bit,
> -    .set   = set_bit,
> +    .set   = prop_set_bit,
>  };
>  
>  /* --- bool --- */

Other code uses qdev_prop prefix, which makes sense I think.
Let's also update get_bit and print_bit, keep it consistent.

> diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> index e0befb2..3dc4937 100644
> --- a/hw/net/eepro100.c
> +++ b/hw/net/eepro100.c
> @@ -105,7 +105,6 @@
>  #define PCI_IO_SIZE             64
>  #define PCI_FLASH_SIZE          (128 * KiB)
>  
> -#define BIT(n) (1 << (n))
>  #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
>  
>  /* The SCB accepts the following controls for the Tx and Rx units: */

Please #include "qemu/bitops.h" - don't rely on other headers
pulling it in.

> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 7fbffcb..e8b89b1 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -4,6 +4,7 @@
>  #include "qemu/queue.h"
>  #include "qemu/option.h"
>  #include "qemu/typedefs.h"
> +#include "qemu/bitmap.h"
>  #include "qom/object.h"
>  #include "hw/irq.h"
>  #include "qapi/error.h"
> -- 
> 1.8.3.1
Marcel Apfelbaum - July 29, 2013, 8:01 a.m.
On Mon, 2013-07-29 at 10:42 +0300, Michael S. Tsirkin wrote:
> On Mon, Jul 29, 2013 at 10:07:33AM +0300, Marcel Apfelbaum wrote:
> > Made small tweaks in code to prevent compilation issues
> > when importing qemu/bitmap.h in qdev-core
> > 
> > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > ---
> >  hw/core/qdev-properties.c | 4 ++--
> >  hw/net/eepro100.c         | 1 -
> >  include/hw/qdev-core.h    | 1 +
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> > index 3a324fb..01b27eb 100644
> > --- a/hw/core/qdev-properties.c
> > +++ b/hw/core/qdev-properties.c
> > @@ -91,7 +91,7 @@ static void get_bit(Object *obj, Visitor *v, void *opaque,
> >      visit_type_bool(v, &value, name, errp);
> >  }
> >  
> > -static void set_bit(Object *obj, Visitor *v, void *opaque,
> > +static void prop_set_bit(Object *obj, Visitor *v, void *opaque,
> >                      const char *name, Error **errp)
> >  {
> >      DeviceState *dev = DEVICE(obj);
> > @@ -117,7 +117,7 @@ PropertyInfo qdev_prop_bit = {
> >      .legacy_name  = "on/off",
> >      .print = print_bit,
> >      .get   = get_bit,
> > -    .set   = set_bit,
> > +    .set   = prop_set_bit,
> >  };
> >  
> >  /* --- bool --- */
> 
> Other code uses qdev_prop prefix, which makes sense I think.
> Let's also update get_bit and print_bit, keep it consistent.
Sure
> 
> > diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> > index e0befb2..3dc4937 100644
> > --- a/hw/net/eepro100.c
> > +++ b/hw/net/eepro100.c
> > @@ -105,7 +105,6 @@
> >  #define PCI_IO_SIZE             64
> >  #define PCI_FLASH_SIZE          (128 * KiB)
> >  
> > -#define BIT(n) (1 << (n))
> >  #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
> >  
> >  /* The SCB accepts the following controls for the Tx and Rx units: */
> 
> Please #include "qemu/bitops.h" - don't rely on other headers
> pulling it in.
Thanks
Marcel
> 
> > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > index 7fbffcb..e8b89b1 100644
> > --- a/include/hw/qdev-core.h
> > +++ b/include/hw/qdev-core.h
> > @@ -4,6 +4,7 @@
> >  #include "qemu/queue.h"
> >  #include "qemu/option.h"
> >  #include "qemu/typedefs.h"
> > +#include "qemu/bitmap.h"
> >  #include "qom/object.h"
> >  #include "hw/irq.h"
> >  #include "qapi/error.h"
> > -- 
> > 1.8.3.1

Patch

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3a324fb..01b27eb 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -91,7 +91,7 @@  static void get_bit(Object *obj, Visitor *v, void *opaque,
     visit_type_bool(v, &value, name, errp);
 }
 
-static void set_bit(Object *obj, Visitor *v, void *opaque,
+static void prop_set_bit(Object *obj, Visitor *v, void *opaque,
                     const char *name, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -117,7 +117,7 @@  PropertyInfo qdev_prop_bit = {
     .legacy_name  = "on/off",
     .print = print_bit,
     .get   = get_bit,
-    .set   = set_bit,
+    .set   = prop_set_bit,
 };
 
 /* --- bool --- */
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index e0befb2..3dc4937 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -105,7 +105,6 @@ 
 #define PCI_IO_SIZE             64
 #define PCI_FLASH_SIZE          (128 * KiB)
 
-#define BIT(n) (1 << (n))
 #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
 
 /* The SCB accepts the following controls for the Tx and Rx units: */
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 7fbffcb..e8b89b1 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -4,6 +4,7 @@ 
 #include "qemu/queue.h"
 #include "qemu/option.h"
 #include "qemu/typedefs.h"
+#include "qemu/bitmap.h"
 #include "qom/object.h"
 #include "hw/irq.h"
 #include "qapi/error.h"