All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org, "Yanan Wang" <wangyanan55@huawei.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH 3/3] hw/sysbus: Document GPIO related functions
Date: Thu, 6 Jan 2022 15:38:39 +0000	[thread overview]
Message-ID: <CAFEAcA-WowtqsMoCX_TyMgv79DtGJKOjUMHQcn6zOU=DL3_3gA@mail.gmail.com> (raw)
In-Reply-To: <20211229225206.171882-4-philmd@redhat.com>

On Wed, 29 Dec 2021 at 22:52, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Similarly to cd07d7f9f51 ("qdev: Document GPIO related functions"),
> add documentation comments for the various sysbus functions
> related to creating and connecting GPIO lines.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  include/hw/sysbus.h | 67 +++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 64 insertions(+), 3 deletions(-)
>
> diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
> index 24645ee7996..7b2b7c7faaa 100644
> --- a/include/hw/sysbus.h
> +++ b/include/hw/sysbus.h
> @@ -69,14 +69,75 @@ typedef void FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque);
>
>  void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
>  MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
> -void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
> -void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
> -void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size);
>
> +/**
> + * sysbus_init_irq: Create an output GPIO line
> + * @dev: Sysbus device to create output GPIO for
> + * @irq: Pointer to qemu_irq for the GPIO lines
> + *
> + * Sysbus devices should use this function in their instance_init
> + * or realize methods to create any output GPIO lines they need.

It's true that this works with a qemu_irq which can be used
as an arbitrary GPIO line. But mostly we use sysbus_init_irq() when
creating things which are actually outbound IRQ lines, and
qdev_init_gpio_out{,_named}() when creating generic output
GPIO lines. So we should phrase the documentation of these
functions to steer readers towards following that convention.

(Looking at the code, I discover that under the hood the
"sysbus irq" code is really using a named output GPIO
array with a specific name (SYSBUS_DEVICE_GPIO_IRQ,
aka "sysbus-irq"). The only functional difference is that
a sysbus device can be notified when one of its IRQs is
connected, which is a nasty hack for the benefit of platform vfio.)

> + *
> + * The @irq argument should be a pointer to either a "qemu_irq" in
> + * the device's state structure.

Missing "or ..." clause, or should "either" be deleted ?

> The device implementation can then raise
> + * and lower the GPIO line by calling qemu_set_irq(). (If anything is
> + * connected to the other end of the GPIO this will cause the handler
> + * function for that input GPIO to be called.)
> + *
> + * See sysbus_connect_irq() for how code that uses such a device can
> + * connect to one of its output GPIO lines.
> + *
> + * There is no need to release the @pins allocated array because it
> + * will be automatically released when @dev calls its instance_finalize()
> + * handler.
> + */

thanks
-- PMM


      reply	other threads:[~2022-01-06 15:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-29 22:52 [PATCH 0/3] hw/sysbus: Document GPIO related functions Philippe Mathieu-Daudé
2021-12-29 22:52 ` [PATCH 1/3] hw/qdev: Restrict qdev_get_gpio_out_connector() to qdev-internal.h Philippe Mathieu-Daudé
2021-12-31  7:30   ` wangyanan (Y) via
2021-12-31 12:11     ` Philippe Mathieu-Daudé
2022-01-03  9:15       ` wangyanan (Y) via
2021-12-29 22:52 ` [PATCH 2/3] hw/sysbus: Restrict sysbus_get_connected_irq() to sysbus-internal.h Philippe Mathieu-Daudé
2021-12-31  7:34   ` wangyanan (Y) via
2021-12-29 22:52 ` [PATCH 3/3] hw/sysbus: Document GPIO related functions Philippe Mathieu-Daudé
2022-01-06 15:38   ` Peter Maydell [this message]

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='CAFEAcA-WowtqsMoCX_TyMgv79DtGJKOjUMHQcn6zOU=DL3_3gA@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=wangyanan55@huawei.com \
    /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.