All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	"Andreas Färber" <afaerber@suse.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v1 13/16] qdev: gpio: Define qdev_pass_gpios()
Date: Fri, 15 Aug 2014 09:31:55 +0200	[thread overview]
Message-ID: <53EDB76B.7060209@suse.de> (raw)
In-Reply-To: <CAEgOgz7Y-BRAB5fPuyd0TEOEGyn1xp=KAUAd6A0_gWpFJf099Q@mail.gmail.com>


On 15.08.14 07:11, Peter Crosthwaite wrote:
> On Tue, Aug 12, 2014 at 8:55 PM, Alexander Graf <agraf@suse.de> wrote:
>> On 12.08.14 12:48, Peter Crosthwaite wrote:
>>> On Tue, Aug 12, 2014 at 7:24 PM, Alexander Graf <agraf@suse.de> wrote:
>>>> On 04.08.14 03:58, Peter Crosthwaite wrote:
>>>>> Allows a container to take ownership of GPIOs in a contained
>>>>> device and automatically connect them as GPIOs to the container.
>>>>>
>>>>> This prepares for deprecation of the SYSBUS IRQ functionality, which
>>>>> has this feature. We push it up to the device level instead of sysbus
>>>>> level. There's nothing sysbus specific about passing GPIOs to
>>>>> containers so its a legitimate device-level generic feature.
>>>>>
>>>>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>>>> ---
>>>>>
>>>>>     hw/core/qdev.c         | 28 ++++++++++++++++++++++++++++
>>>>>     include/hw/qdev-core.h |  3 +++
>>>>>     2 files changed, 31 insertions(+)
>>>>>
>>>>> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
>>>>> index bf2c227..708363f 100644
>>>>> --- a/hw/core/qdev.c
>>>>> +++ b/hw/core/qdev.c
>>>>> @@ -440,6 +440,34 @@ void qdev_connect_gpio_out(DeviceState * dev, int
>>>>> n,
>>>>> qemu_irq pin)
>>>>>         qdev_connect_gpio_out_named(dev, NULL, n, pin);
>>>>>     }
>>>>>     +void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
>>>>> +                     const char *name)
>>>>> +{
>>>>> +    int i;
>>>>> +    NamedGPIOList *ngl = qdev_get_named_gpio_list(dev, name);
>>>>> +
>>>>> +    for (i = 0; i < ngl->num_in; i++) {
>>>>> +        char *propname = g_strdup_printf("%s[%d]",
>>>>> +                                         ngl->name ? ngl->name :
>>>>> +                                                   "unnamed-gpio-in",
>>>>
>>>> Really just a minor nit, but I think the code flow would look a lot nicer
>>>> if
>>>> you did the name check in a separate variable.
>>>>
>>>>     const char *name = ngl->name ? ngl->name : "unnamed-gpio-in";
> Just done it this way. Although have used "nm" instead of "name"
> instead as "name" is already used.
>
>>> I think I may even go an extra step and get it macroified. How about:
>>>
>>> #define QDEV_GPIO_IN_NAME(a) ((a) ? (a) : "unnamed-gpio-io")
>>>
>>> and then you can continue to use it inline without extra variables or
>>> nasty "?:"?
>>
>> The variable will get optimized out, so for the sake of readability I would
>> still vote to have it around. Whether you declare it via a macro or with an
>> a ? a : b macro I don't really care much about :).
>>
>> In fact, it might make more sense to literally have the typical
>>
>>    (a ? a : b)
>>
>> flow macroified in a generic place somewhere.
>>
> Hmm not sure what this wins though? inline "? :" is concise and self
> documenting IMO. You just need to not stuff-up the "()"s (which is
> admittedly quite easy to do.
>
> Anyways, it's a patch for another day.

Yeah, probably not a big win really :).


Alex

  reply	other threads:[~2014-08-15  7:32 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04  1:51 [Qemu-devel] [PATCH v1 00/16] GPIO/IRQ QOMification: Phase 2 - Getting rid of SYSBUS IRQs Peter Crosthwaite
2014-08-04  1:52 ` [Qemu-devel] [PATCH v1 01/16] qdev: gpio: Don't allow name share between I and O Peter Crosthwaite
2014-08-04  1:52 ` [Qemu-devel] [PATCH v1 02/16] qdev: gpio: Register GPIO inputs as child objects Peter Crosthwaite
2014-08-04  1:53 ` [Qemu-devel] [PATCH v1 03/16] qdev: gpio: Register GPIO outputs as QOM links Peter Crosthwaite
2014-08-14  7:30   ` Peter Crosthwaite
2014-08-04  1:53 ` [Qemu-devel] [PATCH v1 04/16] qmp: qstring: Handle NULL strings Peter Crosthwaite
2014-08-04  1:54 ` [Qemu-devel] [PATCH v1 05/16] qom: Allow clearing of a Link property Peter Crosthwaite
2014-08-04  1:54 ` [Qemu-devel] [PATCH v1 06/16] qom: Demote already-has-a-parent to a regular error Peter Crosthwaite
2014-08-04  1:55 ` [Qemu-devel] [PATCH v1 07/16] qdev: gpio: Re-impement qdev_connect_gpio QOM style Peter Crosthwaite
2014-08-04  1:55 ` [Qemu-devel] [PATCH v1 08/16] qdev: gpio: Add API for intercepting an IRQ Peter Crosthwaite
2014-08-12  9:16   ` Alexander Graf
2014-08-12 10:40     ` Peter Crosthwaite
2014-08-04  1:56 ` [Qemu-devel] [PATCH v1 09/16] qtest/irq: Rework IRQ interception Peter Crosthwaite
2014-08-04  1:56 ` [Qemu-devel] [PATCH v1 10/16] irq: Remove qemu_irq_intercept_out Peter Crosthwaite
2014-08-04  1:57 ` [Qemu-devel] [PATCH v1 11/16] qdev: gpio: delete NamedGPIOList::out Peter Crosthwaite
2014-08-04  1:58 ` [Qemu-devel] [PATCH v1 12/16] qdev: gpio: Remove qdev_init_gpio_out x1 restriction Peter Crosthwaite
2014-08-12  9:19   ` Alexander Graf
2014-08-12 10:35     ` Peter Crosthwaite
2014-08-12 10:49       ` Alexander Graf
2014-08-04  1:58 ` [Qemu-devel] [PATCH v1 13/16] qdev: gpio: Define qdev_pass_gpios() Peter Crosthwaite
2014-08-12  9:24   ` Alexander Graf
2014-08-12 10:48     ` Peter Crosthwaite
2014-08-12 10:55       ` Alexander Graf
2014-08-15  5:11         ` Peter Crosthwaite
2014-08-15  7:31           ` Alexander Graf [this message]
2014-08-04  1:59 ` [Qemu-devel] [PATCH v1 14/16] ssi: xilinx_spi: Initialise CS GPIOs as NULL Peter Crosthwaite
2014-08-04  1:59 ` [Qemu-devel] [PATCH v1 15/16] ppc: convert g_new(qemu_irq usages to g_new0 Peter Crosthwaite
2014-08-12  9:26   ` Alexander Graf
2014-08-12 10:49     ` Peter Crosthwaite
2014-08-15  5:07     ` Peter Crosthwaite
2014-08-04  2:00 ` [Qemu-devel] [PATCH v1 16/16] sysbus: Use TYPE_DEVICE GPIO functionality Peter Crosthwaite
2014-08-12  7:51 ` [Qemu-devel] [PATCH v1 00/16] GPIO/IRQ QOMification: Phase 2 - Getting rid of SYSBUS IRQs Peter Crosthwaite
2014-08-12  9:29 ` Alexander Graf

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=53EDB76B.7060209@suse.de \
    --to=agraf@suse.de \
    --cc=afaerber@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --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.