linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Zijun Hu <zijun_hu@icloud.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Tejun Heo <tj@kernel.org>, Josef Bacik <josef@toxicpanda.com>,
	Jens Axboe <axboe@kernel.dk>, Boris Burkov <boris@bur.io>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Dave Jiang <dave.jiang@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	<linux-kernel@vger.kernel.org>, <cgroups@vger.kernel.org>,
	<linux-block@vger.kernel.org>, <linux-cxl@vger.kernel.org>,
	Zijun Hu <quic_zijuhu@quicinc.com>
Subject: Re: [PATCH v4 8/8] driver core: Move 2 one line device finding APIs to header
Date: Mon, 23 Dec 2024 20:11:52 +0000	[thread overview]
Message-ID: <20241223201152.000012d1@huawei.com> (raw)
In-Reply-To: <20241218-class_fix-v4-8-3c40f098356b@quicinc.com>

On Wed, 18 Dec 2024 08:01:38 +0800
Zijun Hu <zijun_hu@icloud.com> wrote:

> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> The following device finding APIs only have one line code in function body
> device_find_child_by_name()
> device_find_any_child()
> 
> Move them to header as static inline function.
Why drop the docs?

> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
>  drivers/base/core.c    | 32 --------------------------------
>  include/linux/device.h | 14 +++++++++++---
>  2 files changed, 11 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 930e43a970952b20cd1c71856bdef889698f51b4..3f37a2aecb1d11561f4edd72e973a1c43368de04 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4100,38 +4100,6 @@ struct device *device_find_child(struct device *parent, const void *data,
>  }
>  EXPORT_SYMBOL_GPL(device_find_child);
>  
> -/**
> - * device_find_child_by_name - device iterator for locating a child device.
> - * @parent: parent struct device
> - * @name: name of the child device
> - *
> - * This is similar to the device_find_child() function above, but it
> - * returns a reference to a device that has the name @name.
> - *
> - * NOTE: you will need to drop the reference with put_device() after use.
> - */
> -struct device *device_find_child_by_name(struct device *parent,
> -					 const char *name)
> -{
> -	return device_find_child(parent, name, device_match_name);
> -}
> -EXPORT_SYMBOL_GPL(device_find_child_by_name);
> -
> -/**
> - * device_find_any_child - device iterator for locating a child device, if any.
> - * @parent: parent struct device
> - *
> - * This is similar to the device_find_child() function above, but it
> - * returns a reference to a child device, if any.
> - *
> - * NOTE: you will need to drop the reference with put_device() after use.
> - */
> -struct device *device_find_any_child(struct device *parent)
> -{
> -	return device_find_child(parent, NULL, device_match_any);
> -}
> -EXPORT_SYMBOL_GPL(device_find_any_child);
> -
>  int __init devices_init(void)
>  {
>  	devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 36d1a1607712f5a6b0668ac02a6cf6b2d0651a2d..d1871a764be62e6857595bc10b9e54862c99dfa2 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1083,9 +1083,17 @@ int device_for_each_child_reverse_from(struct device *parent,
>  				       device_iter_t fn);
>  struct device *device_find_child(struct device *parent, const void *data,
>  				 device_match_t match);
> -struct device *device_find_child_by_name(struct device *parent,
> -					 const char *name);
> -struct device *device_find_any_child(struct device *parent);
> +
> +static inline struct device *device_find_child_by_name(struct device *parent,
> +						       const char *name)
> +{
> +	return device_find_child(parent, name, device_match_name);
> +}
> +
> +static inline struct device *device_find_any_child(struct device *parent)
> +{
> +	return device_find_child(parent, NULL, device_match_any);
> +}
>  
>  int device_rename(struct device *dev, const char *new_name);
>  int device_move(struct device *dev, struct device *new_parent,
> 


  reply	other threads:[~2024-12-23 20:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18  0:01 [PATCH v4 0/8] driver core: class: Fix bug and code improvements for class APIs Zijun Hu
2024-12-18  0:01 ` [PATCH v4 1/8] driver core: class: Fix wild pointer dereferences in API class_dev_iter_next() Zijun Hu
2024-12-23 20:09   ` Jonathan Cameron
2024-12-18  0:01 ` [PATCH v4 2/8] blk-cgroup: Fix class @block_class's subsystem refcount leakage Zijun Hu
2024-12-18 16:39   ` Tejun Heo
2024-12-18  0:01 ` [PATCH v4 3/8] driver core: Move true expression out of if condition in 3 device finding APIs Zijun Hu
2024-12-18  0:01 ` [PATCH v4 4/8] driver core: Rename declaration parameter name for API device_find_child() cluster Zijun Hu
2024-12-18  0:01 ` [PATCH v4 5/8] driver core: Correct parameter check for API device_for_each_child_reverse_from() Zijun Hu
2024-12-18  0:01 ` [PATCH v4 6/8] driver core: Correct API device_for_each_child_reverse_from() prototype Zijun Hu
2024-12-18  0:01 ` [PATCH v4 7/8] driver core: Introduce device_iter_t for device iterating APIs Zijun Hu
2024-12-18  0:01 ` [PATCH v4 8/8] driver core: Move 2 one line device finding APIs to header Zijun Hu
2024-12-23 20:11   ` Jonathan Cameron [this message]
2024-12-24 12:33     ` Zijun Hu
2024-12-24 16:21       ` Jonathan Cameron

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=20241223201152.000012d1@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=axboe@kernel.dk \
    --cc=boris@bur.io \
    --cc=cgroups@vger.kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=ira.weiny@intel.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_zijuhu@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=tj@kernel.org \
    --cc=vishal.l.verma@intel.com \
    --cc=zijun_hu@icloud.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).