All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Zijun Hu <zijun_hu@icloud.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org, Zijun Hu <quic_zijuhu@quicinc.com>
Subject: Re: [PATCH 01/27] driver core: Constify driver API device_find_child()
Date: Tue, 13 Aug 2024 11:48:51 +0200	[thread overview]
Message-ID: <2024081359-dart-transpire-8143@gregkh> (raw)
In-Reply-To: <20240811-const_dfc_done-v1-1-9d85e3f943cb@quicinc.com>

On Sun, Aug 11, 2024 at 10:24:52AM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> Constify the following driver API:
> struct device *device_find_child(struct device *dev, void *data,
> 		int (*match)(struct device *dev, void *data));
> to
> struct device *device_find_child(struct device *dev, const void *data,
>                                  device_match_t match);
> typedef int (*device_match_t)(struct device *dev, const void *data);
> Since it should not modify caller's match data @*data.
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
>  drivers/base/core.c    | 11 +++--------
>  include/linux/device.h |  4 ++--
>  2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 3f3ebdb5aa0b..f152e0f8fb03 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4062,8 +4062,8 @@ EXPORT_SYMBOL_GPL(device_for_each_child_reverse);
>   *
>   * NOTE: you will need to drop the reference with put_device() after use.
>   */
> -struct device *device_find_child(struct device *parent, void *data,
> -				 int (*match)(struct device *dev, void *data))
> +struct device *device_find_child(struct device *parent, const void *data,
> +				 device_match_t match)
>  {
>  	struct klist_iter i;
>  	struct device *child;
> @@ -4108,11 +4108,6 @@ struct device *device_find_child_by_name(struct device *parent,
>  }
>  EXPORT_SYMBOL_GPL(device_find_child_by_name);
>  
> -static int match_any(struct device *dev, void *unused)
> -{
> -	return 1;
> -}
> -
>  /**
>   * device_find_any_child - device iterator for locating a child device, if any.
>   * @parent: parent struct device
> @@ -4124,7 +4119,7 @@ static int match_any(struct device *dev, void *unused)
>   */
>  struct device *device_find_any_child(struct device *parent)
>  {
> -	return device_find_child(parent, NULL, match_any);
> +	return device_find_child(parent, NULL, device_match_any);
>  }
>  EXPORT_SYMBOL_GPL(device_find_any_child);
>  
> diff --git a/include/linux/device.h b/include/linux/device.h
> index b2423fca3d45..76f10bdbb4ea 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1073,8 +1073,8 @@ int device_for_each_child(struct device *dev, void *data,
>  			  int (*fn)(struct device *dev, void *data));
>  int device_for_each_child_reverse(struct device *dev, void *data,
>  				  int (*fn)(struct device *dev, void *data));
> -struct device *device_find_child(struct device *dev, void *data,
> -				 int (*match)(struct device *dev, void *data));
> +struct device *device_find_child(struct device *dev, 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);
> 
> -- 
> 2.34.1
> 

This patch breaks the build:

./include/linux/device.h:1077:6: error: unknown type name 'device_match_t'
 1077 |                                  device_match_t match);
      |                                  ^
1 error generated.
make[2]: *** [scripts/Makefile.build:117: arch/x86/kernel/asm-offsets.s] Error 1
make[1]: *** [/mnt/fast_t2/linux/work/driver-core/Makefile:1193: prepare0] Error 2

How did you test it?

And as you are changing the parameters here, doesn't the build break
also because of that?

thanks,

greg k-h

  reply	other threads:[~2024-08-13  9:48 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-11  2:24 [PATCH 00/27] driver core: Make device_find_child()'s match function take a const pointer Zijun Hu
2024-08-11  2:24 ` [PATCH 01/27] driver core: Constify driver API device_find_child() Zijun Hu
2024-08-13  9:48   ` Greg Kroah-Hartman [this message]
2024-08-13 10:39     ` quic_zijuhu
2024-08-13 10:52       ` Greg Kroah-Hartman
2024-08-11  2:24 ` [PATCH 02/27] Bluetooth: hci_sysfs: Make device_find_child()'s match function take a const pointer Zijun Hu
2024-08-11  2:24 ` [PATCH 03/27] serial: core: " Zijun Hu
2024-08-11  2:24 ` [PATCH 04/27] usb: typec: class: " Zijun Hu
2024-08-11  2:24 ` [PATCH 05/27] gpio: sim: " Zijun Hu
2024-08-11  2:24 ` [PATCH 06/27] slimbus: core: " Zijun Hu
2024-08-11  2:24 ` [PATCH 07/27] scsi: iscsi: " Zijun Hu
2024-08-11  2:24 ` [PATCH 08/27] scsi: iscsi: Constify driver API iscsi_find_flashnode_sess() Zijun Hu
2024-08-11  2:25 ` [PATCH 09/27] scsi: qla4xxx: Make iscsi_find_flashnode_sess()'s match function take a const pointer Zijun Hu
2024-08-11  2:25 ` [PATCH 10/27] pwm: Make device_find_child()'s " Zijun Hu
2024-08-11  2:25 ` [PATCH 11/27] media: pci: mgb4: " Zijun Hu
2024-08-11  2:25 ` [PATCH 12/27] range.h: Make range_contains() take const struct range * as parameter type Zijun Hu
2024-08-11  2:25 ` [PATCH 13/27] cxl/region: Make device_find_child()'s match function take a const pointer Zijun Hu
2024-08-11  2:25 ` [PATCH 14/27] cxl/pmem: " Zijun Hu
2024-08-11  2:25 ` [PATCH 15/27] cxl/core/pci: " Zijun Hu
2024-08-11  2:25 ` [PATCH 16/27] sparc: vio: " Zijun Hu
2024-08-11  2:25 ` [PATCH 17/27] bus: fsl-mc: " Zijun Hu
2024-08-11  2:25 ` [PATCH 18/27] block: sunvdc: " Zijun Hu
2024-08-11  2:25 ` [PATCH 19/27] firmware: arm_scmi: " Zijun Hu
2024-08-11  2:25 ` [PATCH 20/27] efi: dev-path-parser: " Zijun Hu
2024-08-11  2:25 ` [PATCH 21/27] drm/mediatek: " Zijun Hu
2024-08-11  2:25 ` [PATCH 22/27] nvdimm: " Zijun Hu
2024-08-11  2:25 ` [PATCH 23/27] libnvdimm: " Zijun Hu
2024-08-11  2:25 ` [PATCH 24/27] rpmsg: core: " Zijun Hu
2024-08-11  2:25 ` [PATCH 25/27] thunderbolt: " Zijun Hu
2024-08-11  2:25 ` [PATCH 26/27] net: dsa: " Zijun Hu
2024-08-11  2:25 ` [PATCH 27/27] cxl/test: " Zijun Hu

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=2024081359-dart-transpire-8143@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_zijuhu@quicinc.com \
    --cc=rafael@kernel.org \
    --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.