linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Daniel Scally <djrscally@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	"open list:ACPI COMPONENT ARCHITECTURE (ACPICA)"
	<devel@acpica.org>, "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	yong.zhi@intel.com, Sakari Ailus <sakari.ailus@linux.intel.com>,
	Bingbu Cao <bingbu.cao@intel.com>,
	tian.shu.qiu@intel.com, Robert Moore <robert.moore@intel.com>,
	Erik Kaneda <erik.kaneda@intel.com>,
	Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	hverkuil-cisco@xs4all.nl, m.felsch@pengutronix.de,
	Niklas Soderlund <niklas.soderlund+renesas@ragnatech.se>,
	prabhakar.mahadev-lad.rj@bp.renesas.com,
	Steve Longerbeam <slongerbeam@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>
Subject: Re: [PATCH v5 13/15] ACPI / bus: Add acpi_dev_get_next_match_dev() and helper macro
Date: Tue, 12 Jan 2021 20:25:02 +0100	[thread overview]
Message-ID: <CAJZ5v0jWCT6koRvW8AGMs3ODX_10b-fCaQgMXG7kfq1DoDfeBA@mail.gmail.com> (raw)
In-Reply-To: <20210107132838.396641-14-djrscally@gmail.com>

On Thu, Jan 7, 2021 at 2:31 PM Daniel Scally <djrscally@gmail.com> wrote:
>
> To ensure we handle situations in which multiple sensors of the same
> model (and therefore _HID) are present in a system, we need to be able
> to iterate over devices matching a known _HID but unknown _UID and _HRV
>  - add acpi_dev_get_next_match_dev() to accommodate that possibility and
> change acpi_dev_get_first_match_dev() to simply call the new function
> with a NULL starting point. Add an iterator macro for convenience.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Daniel Scally <djrscally@gmail.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
> Changes in v5:
>
>         - Changed commit subject
>
>  drivers/acpi/utils.c    | 30 ++++++++++++++++++++++++++----
>  include/acpi/acpi_bus.h |  7 +++++++
>  2 files changed, 33 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index d5411a166685..ddca1550cce6 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -843,12 +843,13 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
>  EXPORT_SYMBOL(acpi_dev_present);
>
>  /**
> - * acpi_dev_get_first_match_dev - Return the first match of ACPI device
> + * acpi_dev_get_next_match_dev - Return the next match of ACPI device
> + * @adev: Pointer to the previous acpi_device matching this @hid, @uid and @hrv
>   * @hid: Hardware ID of the device.
>   * @uid: Unique ID of the device, pass NULL to not check _UID
>   * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
>   *
> - * Return the first match of ACPI device if a matching device was present
> + * Return the next match of ACPI device if another matching device was present
>   * at the moment of invocation, or NULL otherwise.
>   *
>   * The caller is responsible to call put_device() on the returned device.
> @@ -856,8 +857,9 @@ EXPORT_SYMBOL(acpi_dev_present);
>   * See additional information in acpi_dev_present() as well.
>   */
>  struct acpi_device *
> -acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
> +acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv)
>  {
> +       struct device *start = adev ? &adev->dev : NULL;
>         struct acpi_dev_match_info match = {};
>         struct device *dev;
>
> @@ -865,9 +867,29 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
>         match.uid = uid;
>         match.hrv = hrv;
>
> -       dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
> +       dev = bus_find_device(&acpi_bus_type, start, &match, acpi_dev_match_cb);
>         return dev ? to_acpi_device(dev) : NULL;
>  }
> +EXPORT_SYMBOL(acpi_dev_get_next_match_dev);
> +
> +/**
> + * acpi_dev_get_first_match_dev - Return the first match of ACPI device
> + * @hid: Hardware ID of the device.
> + * @uid: Unique ID of the device, pass NULL to not check _UID
> + * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
> + *
> + * Return the first match of ACPI device if a matching device was present
> + * at the moment of invocation, or NULL otherwise.
> + *
> + * The caller is responsible to call put_device() on the returned device.
> + *
> + * See additional information in acpi_dev_present() as well.
> + */
> +struct acpi_device *
> +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
> +{
> +       return acpi_dev_get_next_match_dev(NULL, hid, uid, hrv);
> +}
>  EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
>
>  /*
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index 6d1879bf9440..02a716a0af5d 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -683,9 +683,16 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
>
>  bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
>
> +struct acpi_device *
> +acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv);
>  struct acpi_device *
>  acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
>
> +#define for_each_acpi_dev_match(adev, hid, uid, hrv)                   \
> +       for (adev = acpi_dev_get_first_match_dev(hid, uid, hrv);        \
> +            adev;                                                      \
> +            adev = acpi_dev_get_next_match_dev(adev, hid, uid, hrv))
> +
>  static inline void acpi_dev_put(struct acpi_device *adev)
>  {
>         put_device(&adev->dev);
> --
> 2.25.1
>

  parent reply	other threads:[~2021-01-12 19:26 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07 13:28 [PATCH v5 00/15] Add functionality to ipu3-cio2 driver allowing software_node connections to sensors on platforms designed for Windows Daniel Scally
2021-01-07 13:28 ` [PATCH v5 01/15] software_node: Fix refcounts in software_node_get_next_child() Daniel Scally
2021-01-07 13:45   ` Heikki Krogerus
2021-01-10 15:09   ` Greg KH
2021-01-07 13:28 ` [PATCH v5 02/15] media: ipu3-cio2: Add headers that ipu3-cio2.h is direct user of Daniel Scally
2021-01-07 13:28 ` [PATCH v5 03/15] device property: Return true in fwnode_device_is_available for NULL ops Daniel Scally
2021-01-07 13:47   ` Heikki Krogerus
2021-01-10 15:09   ` Greg KH
2021-01-07 13:28 ` [PATCH v5 04/15] device property: Call fwnode_graph_get_endpoint_by_id() for fwnode->secondary Daniel Scally
2021-01-10 15:09   ` Greg KH
2021-01-07 13:28 ` [PATCH v5 05/15] software_node: Enforce parent before child ordering of nodes arrays Daniel Scally
2021-01-07 14:04   ` Heikki Krogerus
2021-01-10 15:09   ` Greg KH
2021-01-07 13:28 ` [PATCH v5 06/15] software_node: unregister software_nodes in reverse order Daniel Scally
2021-01-07 14:05   ` Heikki Krogerus
2021-01-10 15:09   ` Greg KH
2021-01-07 13:28 ` [PATCH v5 07/15] device property: Define format macros for ports and endpoints Daniel Scally
2021-01-07 14:06   ` Heikki Krogerus
2021-01-09  2:05   ` Laurent Pinchart
2021-01-12 19:30     ` Rafael J. Wysocki
2021-01-12 19:29   ` Rafael J. Wysocki
2021-01-07 13:28 ` [PATCH v5 08/15] software_node: Add support for fwnode_graph*() family of functions Daniel Scally
2021-01-10 15:08   ` Greg KH
2021-01-07 13:28 ` [PATCH v5 09/15] lib/test_printf.c: Use helper function to unwind array of software_nodes Daniel Scally
2021-01-09  2:01   ` Laurent Pinchart
     [not found]     ` <CAHp75VeLiMdzXL3Awhco-w6JwJhZNVao_uj7F6bmuty_aW0SNQ@mail.gmail.com>
2021-01-10 11:16       ` Laurent Pinchart
2021-01-10 15:38         ` Andy Shevchenko
2021-01-10 15:52           ` Laurent Pinchart
2021-01-13 13:23     ` Sakari Ailus
2021-01-27  9:25       ` Geert Uytterhoeven
2021-01-07 13:28 ` [PATCH v5 10/15] ipu3-cio2: Add T: entry to MAINTAINERS Daniel Scally
2021-01-07 13:28 ` [PATCH v5 11/15] ipu3-cio2: Rename ipu3-cio2.c Daniel Scally
2021-01-07 13:28 ` [PATCH v5 12/15] media: v4l2-core: v4l2-async: Check sd->fwnode->secondary in match_fwnode() Daniel Scally
2021-01-07 13:28 ` [PATCH v5 13/15] ACPI / bus: Add acpi_dev_get_next_match_dev() and helper macro Daniel Scally
2021-01-09  1:54   ` Laurent Pinchart
2021-01-12 19:26     ` Rafael J. Wysocki
2021-01-12 19:25   ` Rafael J. Wysocki [this message]
2021-01-07 13:28 ` [PATCH v5 14/15] media: v4l2-fwnode: Include v4l2_fwnode_bus_type Daniel Scally
2021-01-07 13:28 ` [PATCH v5 15/15] ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver Daniel Scally
2021-01-07 14:05   ` Andy Shevchenko
2021-01-07 14:05     ` Andy Shevchenko
2021-01-07 14:07   ` Daniel Scally
2021-01-09  2:08 ` [PATCH v5 00/15] Add functionality to ipu3-cio2 driver allowing software_node connections to sensors on platforms designed for Windows Laurent Pinchart
2021-01-10 15:08   ` Greg Kroah-Hartman
2021-01-12 19:34 ` Rafael J. Wysocki
2021-01-12 23:35   ` Daniel Scally
2021-01-13 11:42     ` Sakari Ailus

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=CAJZ5v0jWCT6koRvW8AGMs3ODX_10b-fCaQgMXG7kfq1DoDfeBA@mail.gmail.com \
    --to=rafael@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bingbu.cao@intel.com \
    --cc=devel@acpica.org \
    --cc=djrscally@gmail.com \
    --cc=erik.kaneda@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=m.felsch@pengutronix.de \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=pmladek@suse.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=rjw@rjwysocki.net \
    --cc=robert.moore@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=slongerbeam@gmail.com \
    --cc=tian.shu.qiu@intel.com \
    --cc=yong.zhi@intel.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 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).