* [Qemu-devel] [PATCH] hw/pflash_cfi0[12]: Use host-utils.h ctz32()
@ 2012-09-18 13:53 Peter Maydell
2012-09-18 16:53 ` Stefan Weil
2012-09-19 19:51 ` Aurelien Jarno
0 siblings, 2 replies; 5+ messages in thread
From: Peter Maydell @ 2012-09-18 13:53 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, patches
Drop the private reimplementation of ctz32() from pflash_cfi0[12]
in favour of using the standard version from host-utils.h.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/pflash_cfi01.c | 37 +------------------------------------
hw/pflash_cfi02.c | 37 +------------------------------------
2 files changed, 2 insertions(+), 72 deletions(-)
diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c
index d1c7423..00f1cdd 100644
--- a/hw/pflash_cfi01.c
+++ b/hw/pflash_cfi01.c
@@ -41,6 +41,7 @@
#include "block.h"
#include "qemu-timer.h"
#include "exec-memory.h"
+#include "host-utils.h"
#define PFLASH_BUG(fmt, ...) \
do { \
@@ -543,42 +544,6 @@ static const MemoryRegionOps pflash_cfi01_ops_le = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-/* Count trailing zeroes of a 32 bits quantity */
-static int ctz32 (uint32_t n)
-{
- int ret;
-
- ret = 0;
- if (!(n & 0xFFFF)) {
- ret += 16;
- n = n >> 16;
- }
- if (!(n & 0xFF)) {
- ret += 8;
- n = n >> 8;
- }
- if (!(n & 0xF)) {
- ret += 4;
- n = n >> 4;
- }
- if (!(n & 0x3)) {
- ret += 2;
- n = n >> 2;
- }
- if (!(n & 0x1)) {
- ret++;
-#if 0 /* This is not necessary as n is never 0 */
- n = n >> 1;
-#endif
- }
-#if 0 /* This is not necessary as n is never 0 */
- if (!n)
- ret++;
-#endif
-
- return ret;
-}
-
pflash_t *pflash_cfi01_register(target_phys_addr_t base,
DeviceState *qdev, const char *name,
target_phys_addr_t size,
diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c
index 3e2002e..8cb1549 100644
--- a/hw/pflash_cfi02.c
+++ b/hw/pflash_cfi02.c
@@ -40,6 +40,7 @@
#include "qemu-timer.h"
#include "block.h"
#include "exec-memory.h"
+#include "host-utils.h"
//#define PFLASH_DEBUG
#ifdef PFLASH_DEBUG
@@ -575,42 +576,6 @@ static const MemoryRegionOps pflash_cfi02_ops_le = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-/* Count trailing zeroes of a 32 bits quantity */
-static int ctz32 (uint32_t n)
-{
- int ret;
-
- ret = 0;
- if (!(n & 0xFFFF)) {
- ret += 16;
- n = n >> 16;
- }
- if (!(n & 0xFF)) {
- ret += 8;
- n = n >> 8;
- }
- if (!(n & 0xF)) {
- ret += 4;
- n = n >> 4;
- }
- if (!(n & 0x3)) {
- ret += 2;
- n = n >> 2;
- }
- if (!(n & 0x1)) {
- ret++;
-#if 0 /* This is not necessary as n is never 0 */
- n = n >> 1;
-#endif
- }
-#if 0 /* This is not necessary as n is never 0 */
- if (!n)
- ret++;
-#endif
-
- return ret;
-}
-
pflash_t *pflash_cfi02_register(target_phys_addr_t base,
DeviceState *qdev, const char *name,
target_phys_addr_t size,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pflash_cfi0[12]: Use host-utils.h ctz32()
2012-09-18 13:53 [Qemu-devel] [PATCH] hw/pflash_cfi0[12]: Use host-utils.h ctz32() Peter Maydell
@ 2012-09-18 16:53 ` Stefan Weil
2012-09-18 17:11 ` Peter Maydell
2012-09-19 19:51 ` Aurelien Jarno
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Weil @ 2012-09-18 16:53 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-trivial, qemu-devel, patches
Am 18.09.2012 15:53, schrieb Peter Maydell:
> Drop the private reimplementation of ctz32() from pflash_cfi0[12]
> in favour of using the standard version from host-utils.h.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/pflash_cfi01.c | 37 +------------------------------------
> hw/pflash_cfi02.c | 37 +------------------------------------
> 2 files changed, 2 insertions(+), 72 deletions(-)
>
> diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c
> index d1c7423..00f1cdd 100644
> --- a/hw/pflash_cfi01.c
> +++ b/hw/pflash_cfi01.c
> @@ -41,6 +41,7 @@
> #include "block.h"
> #include "qemu-timer.h"
> #include "exec-memory.h"
> +#include "host-utils.h"
>
> #define PFLASH_BUG(fmt, ...) \
> do { \
> @@ -543,42 +544,6 @@ static const MemoryRegionOps pflash_cfi01_ops_le = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -/* Count trailing zeroes of a 32 bits quantity */
> -static int ctz32 (uint32_t n)
> -{
> - int ret;
> -
> - ret = 0;
> - if (!(n & 0xFFFF)) {
> - ret += 16;
> - n = n >> 16;
> - }
> - if (!(n & 0xFF)) {
> - ret += 8;
> - n = n >> 8;
> - }
> - if (!(n & 0xF)) {
> - ret += 4;
> - n = n >> 4;
> - }
> - if (!(n & 0x3)) {
> - ret += 2;
> - n = n >> 2;
> - }
> - if (!(n & 0x1)) {
> - ret++;
> -#if 0 /* This is not necessary as n is never 0 */
> - n = n >> 1;
> -#endif
> - }
> -#if 0 /* This is not necessary as n is never 0 */
> - if (!n)
> - ret++;
> -#endif
> -
> - return ret;
> -}
> -
> pflash_t *pflash_cfi01_register(target_phys_addr_t base,
> DeviceState *qdev, const char *name,
> target_phys_addr_t size,
> diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c
> index 3e2002e..8cb1549 100644
> --- a/hw/pflash_cfi02.c
> +++ b/hw/pflash_cfi02.c
> @@ -40,6 +40,7 @@
> #include "qemu-timer.h"
> #include "block.h"
> #include "exec-memory.h"
> +#include "host-utils.h"
>
> //#define PFLASH_DEBUG
> #ifdef PFLASH_DEBUG
> @@ -575,42 +576,6 @@ static const MemoryRegionOps pflash_cfi02_ops_le = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -/* Count trailing zeroes of a 32 bits quantity */
> -static int ctz32 (uint32_t n)
> -{
> - int ret;
> -
> - ret = 0;
> - if (!(n & 0xFFFF)) {
> - ret += 16;
> - n = n >> 16;
> - }
> - if (!(n & 0xFF)) {
> - ret += 8;
> - n = n >> 8;
> - }
> - if (!(n & 0xF)) {
> - ret += 4;
> - n = n >> 4;
> - }
> - if (!(n & 0x3)) {
> - ret += 2;
> - n = n >> 2;
> - }
> - if (!(n & 0x1)) {
> - ret++;
> -#if 0 /* This is not necessary as n is never 0 */
> - n = n >> 1;
> -#endif
> - }
> -#if 0 /* This is not necessary as n is never 0 */
> - if (!n)
> - ret++;
> -#endif
> -
> - return ret;
> -}
> -
> pflash_t *pflash_cfi02_register(target_phys_addr_t base,
> DeviceState *qdev, const char *name,
> target_phys_addr_t size,
Reviewed-by: Stefan Weil <sw@weilnetz.de>
What about moving the ctz32 function (or even all of host-utils.h) to
bitops.h?
- sw
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pflash_cfi0[12]: Use host-utils.h ctz32()
2012-09-18 16:53 ` Stefan Weil
@ 2012-09-18 17:11 ` Peter Maydell
2012-09-19 7:01 ` Markus Armbruster
0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2012-09-18 17:11 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel, patches
On 18 September 2012 17:53, Stefan Weil <sw@weilnetz.de> wrote:
> What about moving the ctz32 function (or even all of host-utils.h) to
> bitops.h?
I guess that would make some sense, though I'm not generally
a huge fan of shuffling code around.
(bitops.h and host-utils.h are not under the same license terms,
which might complicate things slightly.)
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pflash_cfi0[12]: Use host-utils.h ctz32()
2012-09-18 17:11 ` Peter Maydell
@ 2012-09-19 7:01 ` Markus Armbruster
0 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2012-09-19 7:01 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-trivial, Stefan Weil, qemu-devel, patches
Peter Maydell <peter.maydell@linaro.org> writes:
> On 18 September 2012 17:53, Stefan Weil <sw@weilnetz.de> wrote:
>> What about moving the ctz32 function (or even all of host-utils.h) to
>> bitops.h?
>
> I guess that would make some sense, though I'm not generally
> a huge fan of shuffling code around.
>
> (bitops.h and host-utils.h are not under the same license terms,
> which might complicate things slightly.)
Have a look at hw/hd-geometry.c for a suitable boilerplate comment.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pflash_cfi0[12]: Use host-utils.h ctz32()
2012-09-18 13:53 [Qemu-devel] [PATCH] hw/pflash_cfi0[12]: Use host-utils.h ctz32() Peter Maydell
2012-09-18 16:53 ` Stefan Weil
@ 2012-09-19 19:51 ` Aurelien Jarno
1 sibling, 0 replies; 5+ messages in thread
From: Aurelien Jarno @ 2012-09-19 19:51 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-trivial, qemu-devel, patches
On Tue, Sep 18, 2012 at 02:53:42PM +0100, Peter Maydell wrote:
> Drop the private reimplementation of ctz32() from pflash_cfi0[12]
> in favour of using the standard version from host-utils.h.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/pflash_cfi01.c | 37 +------------------------------------
> hw/pflash_cfi02.c | 37 +------------------------------------
> 2 files changed, 2 insertions(+), 72 deletions(-)
>
> diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c
> index d1c7423..00f1cdd 100644
> --- a/hw/pflash_cfi01.c
> +++ b/hw/pflash_cfi01.c
> @@ -41,6 +41,7 @@
> #include "block.h"
> #include "qemu-timer.h"
> #include "exec-memory.h"
> +#include "host-utils.h"
>
> #define PFLASH_BUG(fmt, ...) \
> do { \
> @@ -543,42 +544,6 @@ static const MemoryRegionOps pflash_cfi01_ops_le = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -/* Count trailing zeroes of a 32 bits quantity */
> -static int ctz32 (uint32_t n)
> -{
> - int ret;
> -
> - ret = 0;
> - if (!(n & 0xFFFF)) {
> - ret += 16;
> - n = n >> 16;
> - }
> - if (!(n & 0xFF)) {
> - ret += 8;
> - n = n >> 8;
> - }
> - if (!(n & 0xF)) {
> - ret += 4;
> - n = n >> 4;
> - }
> - if (!(n & 0x3)) {
> - ret += 2;
> - n = n >> 2;
> - }
> - if (!(n & 0x1)) {
> - ret++;
> -#if 0 /* This is not necessary as n is never 0 */
> - n = n >> 1;
> -#endif
> - }
> -#if 0 /* This is not necessary as n is never 0 */
> - if (!n)
> - ret++;
> -#endif
> -
> - return ret;
> -}
> -
> pflash_t *pflash_cfi01_register(target_phys_addr_t base,
> DeviceState *qdev, const char *name,
> target_phys_addr_t size,
> diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c
> index 3e2002e..8cb1549 100644
> --- a/hw/pflash_cfi02.c
> +++ b/hw/pflash_cfi02.c
> @@ -40,6 +40,7 @@
> #include "qemu-timer.h"
> #include "block.h"
> #include "exec-memory.h"
> +#include "host-utils.h"
>
> //#define PFLASH_DEBUG
> #ifdef PFLASH_DEBUG
> @@ -575,42 +576,6 @@ static const MemoryRegionOps pflash_cfi02_ops_le = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -/* Count trailing zeroes of a 32 bits quantity */
> -static int ctz32 (uint32_t n)
> -{
> - int ret;
> -
> - ret = 0;
> - if (!(n & 0xFFFF)) {
> - ret += 16;
> - n = n >> 16;
> - }
> - if (!(n & 0xFF)) {
> - ret += 8;
> - n = n >> 8;
> - }
> - if (!(n & 0xF)) {
> - ret += 4;
> - n = n >> 4;
> - }
> - if (!(n & 0x3)) {
> - ret += 2;
> - n = n >> 2;
> - }
> - if (!(n & 0x1)) {
> - ret++;
> -#if 0 /* This is not necessary as n is never 0 */
> - n = n >> 1;
> -#endif
> - }
> -#if 0 /* This is not necessary as n is never 0 */
> - if (!n)
> - ret++;
> -#endif
> -
> - return ret;
> -}
> -
> pflash_t *pflash_cfi02_register(target_phys_addr_t base,
> DeviceState *qdev, const char *name,
> target_phys_addr_t size,
Thanks, applied.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-19 19:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-18 13:53 [Qemu-devel] [PATCH] hw/pflash_cfi0[12]: Use host-utils.h ctz32() Peter Maydell
2012-09-18 16:53 ` Stefan Weil
2012-09-18 17:11 ` Peter Maydell
2012-09-19 7:01 ` Markus Armbruster
2012-09-19 19:51 ` Aurelien Jarno
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).