netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] driver core: Prevent device_find_child() from modifying caller's match data
@ 2024-08-15 14:58 Zijun Hu
  2024-08-15 14:58 ` [PATCH v2 1/4] driver core: Make parameter check consistent for API cluster device_(for_each|find)_child() Zijun Hu
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Zijun Hu @ 2024-08-15 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Davidlohr Bueso,
	Jonathan Cameron, Dave Jiang, Alison Schofield, Vishal Verma,
	Ira Weiny, Dan Williams, Takashi Sakamoto, Timur Tabi,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Zijun Hu, linux-kernel, linux-cxl, linux1394-devel, 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 3/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 27/30, the other patch series will simply change its
relevant parameter type to const void *.

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));
 

Signed-off-by: Zijun Hu <quic_zijuhu@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 (4):
      driver core: Make parameter check consistent for API cluster device_(for_each|find)_child()
      cxl/region: Prevent device_find_child() from modifying caller's match data
      firewire: core: Prevent device_find_child() from modifying caller's match data
      net: qcom/emac: Prevent device_find_child() from modifying caller's match data

 drivers/base/core.c                             |  6 ++--
 drivers/cxl/core/region.c                       | 36 +++++++++++++++++++++++-
 drivers/firewire/core-device.c                  | 37 +++++++++++++++++++++++--
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 36 ++++++++++++++++++++++--
 4 files changed, 107 insertions(+), 8 deletions(-)
---
base-commit: bfa54a793ba77ef696755b66f3ac4ed00c7d1248
change-id: 20240811-const_dfc_prepare-3ff23c6598e5

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


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

end of thread, other threads:[~2024-08-24  7:11 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-15 14:58 [PATCH v2 0/4] driver core: Prevent device_find_child() from modifying caller's match data Zijun Hu
2024-08-15 14:58 ` [PATCH v2 1/4] driver core: Make parameter check consistent for API cluster device_(for_each|find)_child() Zijun Hu
2024-08-20 12:53   ` Ira Weiny
2024-08-20 13:40     ` Zijun Hu
2024-08-20 14:14       ` Ira Weiny
2024-08-21 14:44         ` Zijun Hu
2024-08-23 17:19           ` Ira Weiny
2024-08-23 21:45             ` Zijun Hu
2024-08-24  3:21           ` Greg Kroah-Hartman
2024-08-24  3:23   ` Greg Kroah-Hartman
2024-08-15 14:58 ` [PATCH v2 2/4] cxl/region: Prevent device_find_child() from modifying caller's match data Zijun Hu
2024-08-20 13:59   ` Ira Weiny
2024-08-21 12:46     ` Zijun Hu
2024-08-23 18:10       ` Ira Weiny
2024-08-23 22:18         ` Zijun Hu
2024-08-24  3:29     ` Greg Kroah-Hartman
2024-08-15 14:58 ` [PATCH v2 3/4] firewire: core: " Zijun Hu
2024-08-17  9:57   ` Takashi Sakamoto
2024-08-18 14:24     ` Zijun Hu
2024-08-19  8:58       ` Takashi Sakamoto
2024-08-19 11:41         ` Zijun Hu
2024-08-15 14:58 ` [PATCH v2 4/4] net: qcom/emac: " Zijun Hu
2024-08-24  3:29   ` Greg Kroah-Hartman
2024-08-24  7:11     ` Zijun Hu

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).