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 v3 8/9] driver core: Correct API device_for_each_child_reverse_from() prototype
Date: Mon, 16 Dec 2024 15:30:06 +0000 [thread overview]
Message-ID: <20241216153006.000009b4@huawei.com> (raw)
In-Reply-To: <20241212-class_fix-v3-8-04e20c4f0971@quicinc.com>
On Thu, 12 Dec 2024 21:38:44 +0800
Zijun Hu <zijun_hu@icloud.com> wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> For API device_for_each_child_reverse_from(..., const void *data,
> int (*fn)(struct device *dev, const void *data))
>
> - Type of @data is const pointer, and means caller's data @*data is not
> allowed to be modified, but that usually is not proper for such non
> finding device iterating API.
>
> - Types for both @data and @fn are not consistent with all other
> for_each device iterating APIs device_for_each_child(_reverse)(),
> bus_for_each_dev() and (driver|class)_for_each_device().
>
> Correct its prototype by removing const from parameter types, then adapt
> for various existing usages.
>
> An dedicated typedef device_iter_t will be introduced as @fn() type for
> various for_each device interating APIs later.
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
This inconsistency is indeed weird. So this changes seems reasonable to me.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Dan, this was your function. There is nothing about the const
in the original commit. Did you intend it to be different from
device_for_each_child_reverse() etc?
Jonathan
> ---
> drivers/base/core.c | 4 ++--
> drivers/cxl/core/hdm.c | 2 +-
> drivers/cxl/core/region.c | 2 +-
> include/linux/device.h | 4 ++--
> 4 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 34fb13f914b3db47e6a047fdabf3c9b18ecc08cc..7be9c732bec1b060a477b362f555c3e87c8c7b91 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4043,8 +4043,8 @@ EXPORT_SYMBOL_GPL(device_for_each_child_reverse);
> * device_for_each_child_reverse_from();
> */
> int device_for_each_child_reverse_from(struct device *parent,
> - struct device *from, const void *data,
> - int (*fn)(struct device *, const void *))
> + struct device *from, void *data,
> + int (*fn)(struct device *, void *))
> {
> struct klist_iter i;
> struct device *child;
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index 28edd5822486851912393f066478252b20abc19d..50e6a45b30ba260c066a0781b9ed3a2f6f3462d7 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -703,7 +703,7 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld)
> return 0;
> }
>
> -static int commit_reap(struct device *dev, const void *data)
> +static int commit_reap(struct device *dev, void *data)
> {
> struct cxl_port *port = to_cxl_port(dev->parent);
> struct cxl_decoder *cxld;
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index bfecd71040c2f4373645380b4c31327d8b42d095..a4cff4c266e7a7dd6a3feb1513bf14b7d3f9afa2 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -778,7 +778,7 @@ static size_t show_targetN(struct cxl_region *cxlr, char *buf, int pos)
> return rc;
> }
>
> -static int check_commit_order(struct device *dev, const void *data)
> +static int check_commit_order(struct device *dev, void *data)
> {
> struct cxl_decoder *cxld = to_cxl_decoder(dev);
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index a9d928398895b062094b94f2c188cbe9951d7ac1..025bac08fca7b2513acb1fbcb666be1dc64f03d1 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1079,8 +1079,8 @@ int device_for_each_child(struct device *parent, void *data,
> int device_for_each_child_reverse(struct device *parent, void *data,
> int (*fn)(struct device *dev, void *data));
> int device_for_each_child_reverse_from(struct device *parent,
> - struct device *from, const void *data,
> - int (*fn)(struct device *, const void *));
> + struct device *from, void *data,
> + int (*fn)(struct device *, void *));
> 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,
>
next prev parent reply other threads:[~2024-12-16 15:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 13:38 [PATCH v3 0/9] driver core: class: Fix bug and code improvements for class APIs Zijun Hu
2024-12-12 13:38 ` [PATCH v3 1/9] driver core: class: Fix wild pointer dereferences in API class_dev_iter_next() Zijun Hu
2024-12-16 15:36 ` Jonathan Cameron
2024-12-17 14:09 ` Zijun Hu
2024-12-12 13:38 ` [PATCH v3 2/9] blk-cgroup: Fix class @block_class's subsystem refcount leakage Zijun Hu
2024-12-17 10:53 ` Michal Koutný
2024-12-12 13:38 ` [PATCH v3 3/9] driver core: bus: Move true expression out of if condition in API bus_find_device() Zijun Hu
2024-12-16 15:14 ` Jonathan Cameron
2024-12-12 13:38 ` [PATCH v3 4/9] driver core: Move true expression out of if condition in API driver_find_device() Zijun Hu
2024-12-16 15:18 ` Jonathan Cameron
2024-12-16 18:01 ` Fan Ni
2024-12-17 14:13 ` Zijun Hu
2024-12-12 13:38 ` [PATCH v3 5/9] driver core: Move true expression out of if condition in API device_find_child() Zijun Hu
2024-12-16 15:19 ` Jonathan Cameron
2024-12-16 18:02 ` Fan Ni
2024-12-12 13:38 ` [PATCH v3 6/9] driver core: Rename declaration parameter name for API device_find_child() cluster Zijun Hu
2024-12-16 15:21 ` Jonathan Cameron
2024-12-16 18:02 ` Fan Ni
2024-12-12 13:38 ` [PATCH v3 7/9] driver core: Correct parameter check for API device_for_each_child_reverse_from() Zijun Hu
2024-12-16 15:23 ` Jonathan Cameron
2024-12-17 14:18 ` Zijun Hu
2024-12-12 13:38 ` [PATCH v3 8/9] driver core: Correct API device_for_each_child_reverse_from() prototype Zijun Hu
2024-12-16 15:30 ` Jonathan Cameron [this message]
2024-12-12 13:38 ` [PATCH v3 9/9] driver core: Introduce device_iter_t for device iterating APIs Zijun Hu
2024-12-16 15:33 ` 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=20241216153006.000009b4@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 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.