public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] driver core: Prevent device_find_child() from modifying caller's match data
@ 2024-09-05  0:36 Zijun Hu
  2024-09-05  0:36 ` [PATCH v4 1/2] cxl/region: Find free cxl decoder by device_for_each_child() Zijun Hu
  2024-09-05  0:36 ` [PATCH v4 2/2] net: qcom/emac: Find sgmii_ops " Zijun Hu
  0 siblings, 2 replies; 22+ messages in thread
From: Zijun Hu @ 2024-09-05  0:36 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Dan Williams, Timur Tabi,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Greg Kroah-Hartman
  Cc: Zijun Hu, linux-cxl, linux-kernel, netdev, Zijun Hu

This patch series is to prepare for constifying 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,
		int (*match)(struct device *dev, const void *data));

How to constify the API ?
There are total 30 usages of the API in kernel tree:

For 2/30 usages, the API's match function (*match)() will modify
caller's match data @*data, and this patch series will clean up them.

For remaining 28/30, the following patch series will simply change its
relevant parameter type to const void *.
https://lore.kernel.org/all/20240811-const_dfc_done-v1-1-9d85e3f943cb@quicinc.com/

Why to constify the API ?

(1) It normally does not make sense, also does not need to, for
such device finding operation to modify caller's match data which
is mainly used for comparison.

(2) It will make the API's match function and match data parameter
have the same type as all other APIs (bus|class|driver)_find_device().

(3) It will give driver author hints about choice between this API and
the following one:
int device_for_each_child(struct device *dev, void *data,
		int (*fn)(struct device *dev, void *data));
 

To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Zijun Hu <zijun_hu@icloud.com>

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
Changes in v4:
- Drop driver core patch
- Correct commit message for cxl/region patch
- Correct title and commit message for qcom/emac patch
- Link to v3: https://lore.kernel.org/r/20240824-const_dfc_prepare-v3-0-32127ea32bba@quicinc.com

Changes in v3:
- Git rebase
- Correct commit message for the driver core patch
- Use changes suggested by Ira Weiny cxl/region
- Drop firewire core patch
- Make qcom/emac follow cxl/region solution suggested by Greg
- Link to v2: https://lore.kernel.org/r/20240815-const_dfc_prepare-v2-0-8316b87b8ff9@quicinc.com

Changes in v2:
- Give up introducing the API constify_device_find_child_helper()
- Correct commit message and inline comments
- Implement a driver specific and equivalent one instead of device_find_child()
- Link to v1: https://lore.kernel.org/r/20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com

---
Zijun Hu (2):
      cxl/region: Find free cxl decoder by device_for_each_child()
      net: qcom/emac: Find sgmii_ops by device_for_each_child()

 drivers/cxl/core/region.c                       | 30 ++++++++++++++++++++-----
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 22 +++++++++++++-----
 2 files changed, 41 insertions(+), 11 deletions(-)
---
base-commit: fea64fa04c31426eae512751e0c5342345c5741c
change-id: 20240811-const_dfc_prepare-3ff23c6598e5

Best regards,
-- 
Zijun Hu <quic_zijuhu@quicinc.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-10-10 13:47 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05  0:36 [PATCH v4 0/2] driver core: Prevent device_find_child() from modifying caller's match data Zijun Hu
2024-09-05  0:36 ` [PATCH v4 1/2] cxl/region: Find free cxl decoder by device_for_each_child() Zijun Hu
2024-09-05  5:32   ` Greg Kroah-Hartman
2024-09-05  8:48     ` quic_zijuhu
2024-09-05 11:18     ` Zijun Hu
2024-09-09 19:56     ` Ira Weiny
2024-09-10  0:45       ` Dan Williams
2024-09-10  3:17         ` quic_zijuhu
2024-09-10  4:15           ` Dan Williams
2024-09-10  4:20             ` Dan Williams
2024-09-10 11:46             ` Zijun Hu
2024-09-10 16:01               ` Dan Williams
2024-09-10 18:27                 ` Dan Williams
2024-09-11 12:14                   ` Zijun Hu
2024-10-10 13:47                   ` Zijun Hu
2024-09-11 11:52                 ` Zijun Hu
2024-09-05  0:36 ` [PATCH v4 2/2] net: qcom/emac: Find sgmii_ops " Zijun Hu
2024-09-05  5:29   ` Greg Kroah-Hartman
2024-09-05  5:33     ` Greg Kroah-Hartman
2024-09-05  9:09       ` quic_zijuhu
2024-09-06  0:29       ` Zijun Hu
2024-09-05  8:29     ` quic_zijuhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox