* [PATCH v2] hw/gpio/pl061: Declare pullups/pulldowns as 8-bit types
@ 2025-10-21 14:53 Philippe Mathieu-Daudé
2025-10-23 14:18 ` Peter Maydell
2025-10-27 11:14 ` Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-21 14:53 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, qemu-arm, Peter Maydell, Alexander Graf,
Philippe Mathieu-Daudé
uint8_t is good enough to hold a property "between 0 and 0xff".
Define pullups/pulldowns properties using DEFINE_PROP_UINT8()
macro, remove unnecessary range checks in pl061_realize().
Update the two caller sites.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
v2: qdev_prop_set_uint32 -> qdev_prop_set_uint8 in callers (Peter)
---
hw/arm/virt.c | 4 ++--
hw/gpio/pl061.c | 16 ++++------------
hw/vmapple/vmapple.c | 4 ++--
3 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 175023897a7..28e842f22ea 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1133,8 +1133,8 @@ static void create_gpio_devices(const VirtMachineState *vms, int gpio,
pl061_dev = qdev_new("pl061");
/* Pull lines down to 0 if not driven by the PL061 */
- qdev_prop_set_uint32(pl061_dev, "pullups", 0);
- qdev_prop_set_uint32(pl061_dev, "pulldowns", 0xff);
+ qdev_prop_set_uint8(pl061_dev, "pullups", 0);
+ qdev_prop_set_uint8(pl061_dev, "pulldowns", 0xff);
s = SYS_BUS_DEVICE(pl061_dev);
sysbus_realize_and_unref(s, &error_fatal);
memory_region_add_subregion(mem, base, sysbus_mmio_get_region(s, 0));
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
index 1acca3f2f80..a3ac038c2f7 100644
--- a/hw/gpio/pl061.c
+++ b/hw/gpio/pl061.c
@@ -79,8 +79,8 @@ struct PL061State {
qemu_irq out[N_GPIOS];
const unsigned char *id;
/* Properties, for non-Luminary PL061 */
- uint32_t pullups;
- uint32_t pulldowns;
+ uint8_t pullups;
+ uint8_t pulldowns;
};
static const VMStateDescription vmstate_pl061 = {
@@ -547,14 +547,6 @@ static void pl061_realize(DeviceState *dev, Error **errp)
{
PL061State *s = PL061(dev);
- if (s->pullups > 0xff) {
- error_setg(errp, "pullups property must be between 0 and 0xff");
- return;
- }
- if (s->pulldowns > 0xff) {
- error_setg(errp, "pulldowns property must be between 0 and 0xff");
- return;
- }
if (s->pullups & s->pulldowns) {
error_setg(errp, "no bit may be set both in pullups and pulldowns");
return;
@@ -562,8 +554,8 @@ static void pl061_realize(DeviceState *dev, Error **errp)
}
static const Property pl061_props[] = {
- DEFINE_PROP_UINT32("pullups", PL061State, pullups, 0xff),
- DEFINE_PROP_UINT32("pulldowns", PL061State, pulldowns, 0x0),
+ DEFINE_PROP_UINT8("pullups", PL061State, pullups, 0xff),
+ DEFINE_PROP_UINT8("pulldowns", PL061State, pulldowns, 0x0),
};
static void pl061_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
index 1e4365f32c9..f3cff329244 100644
--- a/hw/vmapple/vmapple.c
+++ b/hw/vmapple/vmapple.c
@@ -326,8 +326,8 @@ static void create_gpio_devices(const VMAppleMachineState *vms, int gpio,
pl061_dev = qdev_new("pl061");
/* Pull lines down to 0 if not driven by the PL061 */
- qdev_prop_set_uint32(pl061_dev, "pullups", 0);
- qdev_prop_set_uint32(pl061_dev, "pulldowns", 0xff);
+ qdev_prop_set_uint8(pl061_dev, "pullups", 0);
+ qdev_prop_set_uint8(pl061_dev, "pulldowns", 0xff);
s = SYS_BUS_DEVICE(pl061_dev);
sysbus_realize_and_unref(s, &error_fatal);
memory_region_add_subregion(mem, base, sysbus_mmio_get_region(s, 0));
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] hw/gpio/pl061: Declare pullups/pulldowns as 8-bit types
2025-10-21 14:53 [PATCH v2] hw/gpio/pl061: Declare pullups/pulldowns as 8-bit types Philippe Mathieu-Daudé
@ 2025-10-23 14:18 ` Peter Maydell
2025-10-27 11:14 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2025-10-23 14:18 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Phil Dennis-Jordan, qemu-arm, Alexander Graf
On Tue, 21 Oct 2025 at 15:53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> uint8_t is good enough to hold a property "between 0 and 0xff".
>
> Define pullups/pulldowns properties using DEFINE_PROP_UINT8()
> macro, remove unnecessary range checks in pl061_realize().
> Update the two caller sites.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> v2: qdev_prop_set_uint32 -> qdev_prop_set_uint8 in callers (Peter)
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] hw/gpio/pl061: Declare pullups/pulldowns as 8-bit types
2025-10-21 14:53 [PATCH v2] hw/gpio/pl061: Declare pullups/pulldowns as 8-bit types Philippe Mathieu-Daudé
2025-10-23 14:18 ` Peter Maydell
@ 2025-10-27 11:14 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2025-10-27 11:14 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Phil Dennis-Jordan, qemu-arm, Alexander Graf
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
On Tue, 21 Oct 2025 at 15:53, Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:
>
> uint8_t is good enough to hold a property "between 0 and 0xff".
>
> Define pullups/pulldowns properties using DEFINE_PROP_UINT8()
> macro, remove unnecessary range checks in pl061_realize().
> Update the two caller sites.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> v2: qdev_prop_set_uint32 -> qdev_prop_set_uint8 in callers (Peter)
Applied to target-arm.next, thanks.
-- PMM
[-- Attachment #2: Type: text/html, Size: 750 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-27 11:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 14:53 [PATCH v2] hw/gpio/pl061: Declare pullups/pulldowns as 8-bit types Philippe Mathieu-Daudé
2025-10-23 14:18 ` Peter Maydell
2025-10-27 11:14 ` Peter Maydell
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).