linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Zhang Rui <rui.zhang@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-pm <linux-pm@lists.linux-foundation.org>,
	linux-i2c <linux-i2c@vger.kernel.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"Len, Brown" <lenb@kernel.org>, "Rafael J. Wysocki" <rjw@sisk.pl>,
	Grant Likely <grant.likely@secretlab.ca>,
	Dirk Brandewie <dirk.brandewie@gmail.com>
Subject: Re: [RFC PATCH 1/6] Introduce acpi_match_device_id().
Date: Fri, 28 Sep 2012 17:13:47 +0300	[thread overview]
Message-ID: <20120928141347.GC15548@intel.com> (raw)
In-Reply-To: <1348817910.10877.321.camel@rui.sh.intel.com>

On Fri, Sep 28, 2012 at 03:38:30PM +0800, Zhang Rui wrote:
> >From 72df5d1f51fb27a4ba7f70a3b07df759d32b8288 Mon Sep 17 00:00:00 2001
> From: Zhang Rui <rui.zhang@intel.com>
> Date: Thu, 27 Sep 2012 15:11:55 +0800
> Subject: [RFC PATCH 1/6] Introduce acpi_match_device_id().
> 
> This API is used to check if a device id string is compatible
> with an ACPI device,
> either PNP id exported via _HID or compatible ids exported
> via _CID control method.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/acpi/scan.c     |   22 ++++++++++++++++++++++
>  include/acpi/acpi_bus.h |    6 ++++++
>  2 files changed, 28 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index d1ecca2..936a7c9 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -312,6 +312,28 @@ int acpi_match_device_ids(struct acpi_device *device,
>  }
>  EXPORT_SYMBOL(acpi_match_device_ids);
>  
> +int acpi_match_device_id(const struct device *dev, const char *id)

Would be good idea to implement this in terms of of_match_device() so that
it returns pointer to the matched id. This way drivers can get the
->driver_data pretty easily if needed.

> +{
> +	acpi_handle handle = DEVICE_ACPI_HANDLE(dev);

If the device is not bound to an ACPI handle this will return NULL. And I
don't see you doing that in this series meaning that..

> +	struct acpi_device *device;
> +	struct acpi_hardware_id *hwid;
> +	acpi_status status;
> +
> +	if (!handle || !id)
> +		return -ENODEV;

..you always return -ENODEV here, right?

> +
> +	status = acpi_bus_get_device(handle, &device);
> +	if (ACPI_FAILURE(status))
> +		return -ENODEV;
> +
> +	list_for_each_entry(hwid, &device->pnp.ids, list)
> +		if (!strcmp(id, hwid->id))
> +			return 0;
> +
> +	return -ENODEV;
> +}
> +EXPORT_SYMBOL(acpi_match_device_id);

  reply	other threads:[~2012-09-28 14:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-28  7:38 [RFC PATCH 1/6] Introduce acpi_match_device_id() Zhang Rui
2012-09-28 14:13 ` Mika Westerberg [this message]
     [not found]   ` <20120928141347.GC15548-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2012-09-29 13:31     ` Zhang, Rui
2012-10-01  6:37       ` Mika Westerberg
     [not found]         ` <20121001063753.GE15548-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2012-10-01 13:56           ` Zhang, Rui
2012-10-02  6:10             ` Mika Westerberg

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=20120928141347.GC15548@intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=dirk.brandewie@gmail.com \
    --cc=grant.likely@secretlab.ca \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=rjw@sisk.pl \
    --cc=rui.zhang@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).