From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
rafael@kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 14/28] drivers: Introduce class_find_device_by_fwnode() helper
Date: Tue, 18 Jun 2019 13:42:59 +0300 [thread overview]
Message-ID: <20190618104259.GA25441@kuha.fi.intel.com> (raw)
In-Reply-To: <1560534863-15115-15-git-send-email-suzuki.poulose@arm.com>
On Fri, Jun 14, 2019 at 06:54:09PM +0100, Suzuki K Poulose wrote:
> Add a wrapper to class_find_device() to search for a device
> by the fwnode pointer, reusing the generic match function.
> Also convert the existing users to make use of the new helper.
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/roles/class.c | 8 +-------
> drivers/usb/typec/class.c | 8 +-------
> include/linux/device.h | 13 +++++++++++++
> 3 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index 07aaa96..5cd87d8 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -85,11 +85,6 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw)
> }
> EXPORT_SYMBOL_GPL(usb_role_switch_get_role);
>
> -static int switch_fwnode_match(struct device *dev, const void *fwnode)
> -{
> - return dev_fwnode(dev) == fwnode;
> -}
> -
> static void *usb_role_switch_match(struct device_connection *con, int ep,
> void *data)
> {
> @@ -99,8 +94,7 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
> if (!fwnode_property_present(con->fwnode, con->id))
> return NULL;
>
> - dev = class_find_device(role_class, NULL, con->fwnode,
> - switch_fwnode_match);
> + dev = class_find_device_by_fwnode(role_class, con->fwnode);
> } else {
> dev = class_find_device_by_name(role_class, con->endpoint[ep]);
> }
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 18a0687..af4fb73 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -205,11 +205,6 @@ static void typec_altmode_put_partner(struct altmode *altmode)
> put_device(&adev->dev);
> }
>
> -static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
> -{
> - return dev_fwnode(dev) == fwnode;
> -}
> -
> static void *typec_port_match(struct device_connection *con, int ep, void *data)
> {
> struct device *dev;
> @@ -219,8 +214,7 @@ static void *typec_port_match(struct device_connection *con, int ep, void *data)
> * we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
> */
> if (con->fwnode)
> - return class_find_device(typec_class, NULL, con->fwnode,
> - typec_port_fwnode_match);
> + return class_find_device_by_fwnode(typec_class, con->fwnode);
>
> dev = class_find_device_by_name(typec_class, con->endpoint[ep]);
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 9228502..52ac911 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -509,6 +509,19 @@ class_find_device_by_of_node(struct class *class, const struct device_node *np)
> return class_find_device(class, NULL, np, device_match_of_node);
> }
>
> +/**
> + * class_find_device_by_fwnode : device iterator for locating a particular device
> + * matching the fwnode.
> + * @class: class type
> + * @fwnode: fwnode of the device to match.
> + */
> +static inline struct device *
> +class_find_device_by_fwnode(struct class *class,
> + const struct fwnode_handle *fwnode)
> +{
> + return class_find_device(class, NULL, fwnode, device_match_fwnode);
> +}
> +
> struct class_attribute {
> struct attribute attr;
> ssize_t (*show)(struct class *class, struct class_attribute *attr,
> --
> 2.7.4
thanks,
--
heikki
next prev parent reply other threads:[~2019-06-18 10:43 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com>
2019-06-14 17:53 ` [PATCH v2 01/28] staging: most-core: Use bus_find_device_by_name Suzuki K Poulose
2019-06-14 17:53 ` [PATCH v2 02/28] mfd: Remove unused helper syscon_regmap_lookup_by_pdevname Suzuki K Poulose
2019-07-25 10:50 ` Lee Jones
2019-06-14 17:53 ` [PATCH v2 03/28] acpi: utils: Cleanup acpi_dev_match_cb Suzuki K Poulose
2019-06-17 22:08 ` Rafael J. Wysocki
2019-06-24 3:20 ` Greg Kroah-Hartman
2019-06-14 17:53 ` [PATCH v2 04/28] bus_find_device: Unify the match callback with class_find_device Suzuki K Poulose
2019-06-14 20:30 ` Rob Herring
2019-06-14 20:30 ` Wolfram Sang
2019-06-14 17:54 ` [PATCH v2 05/28] driver_find_device: Unify the match function with class_find_device() Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 06/28] drivers: Add generic helper to match by of_node Suzuki K Poulose
2019-06-14 20:31 ` Wolfram Sang
2019-06-17 9:59 ` Suzuki K Poulose
2019-06-17 10:06 ` Wolfram Sang
2019-06-14 17:54 ` [PATCH v2 07/28] drivers: Add generic helper to match by fwnode Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 08/28] drivers: Add generic helper to match by device type Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
2019-06-17 22:07 ` Rafael J. Wysocki
2019-06-18 8:38 ` Suzuki K Poulose
2019-06-18 8:40 ` Rafael J. Wysocki
2019-06-14 17:54 ` [PATCH v2 10/28] drivers: Add generic helper to match by name Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 11/28] drivers: Add generic helper to match any device Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 12/28] drivers: Introduce class_find_device_by_name() helper Suzuki K Poulose
2019-06-21 11:02 ` Pavel Machek
2019-06-24 10:08 ` Alexandre Belloni
2019-06-14 17:54 ` [PATCH v2 13/28] drivers: Introduce class_find_device_by_of_node() helper Suzuki K Poulose
2019-06-22 5:25 ` Peter Rosin
2019-06-24 8:34 ` Suzuki K Poulose
2019-06-24 14:07 ` Peter Rosin
2019-06-24 15:19 ` Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 14/28] drivers: Introduce class_find_device_by_fwnode() helper Suzuki K Poulose
2019-06-18 10:42 ` Heikki Krogerus [this message]
2019-06-14 17:54 ` [PATCH v2 15/28] drivers: Introduce class_find_device_by_devt() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 16/28] drivers: Introduce class_find_device_by_acpi_dev() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper Suzuki K Poulose
2019-06-14 20:32 ` Wolfram Sang
2019-07-09 16:19 ` Rob Herring
2019-06-14 17:54 ` [PATCH v2 18/28] drivers: Introduce bus_find_device_by_fwnode() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 19/28] drivers: Introduce bus_find_device_by_devt() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 20/28] drivers: Introduce bus_find_next_device() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 21/28] drivers: Introduce bus_find_device_by_acpi_dev() helper Suzuki K Poulose
2019-06-14 18:08 ` Mark Brown
2019-06-17 9:39 ` Mika Westerberg
2019-06-17 10:07 ` Wolfram Sang
2019-06-14 17:54 ` [PATCH v2 22/28] drivers: Introduce driver_find_device_by_name() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 23/28] drivers: Introduce driver_find_device_by_of_node() helper Suzuki K Poulose
2019-07-25 10:51 ` Lee Jones
2019-07-25 13:38 ` Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 24/28] drivers: Introduce driver_find_device_by_fwnode() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 25/28] drivers: Introduce driver_find_device_by_devt() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 26/28] drivers: Introduce driver_find_next_device() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 27/28] drivers: Introduce driver_find_device_by_acpi_dev() helper Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 28/28] platform: Add platform_find_device_by_driver() helper Suzuki K Poulose
2019-06-14 18:24 ` [PATCH v2 00/28] drivers: Consolidate device lookup helpers Joe Perches
2019-06-17 10:07 ` Suzuki K Poulose
[not found] ` <20190624032348.GA28919@kroah.com>
2019-06-24 8:31 ` Suzuki K Poulose
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=20190618104259.GA25441@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=suzuki.poulose@arm.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