[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240824-const_dfc_prepare-v3-0-32127ea32bba@quicinc.com>
Date: Sat, 24 Aug 2024 17:07:42 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Davidlohr Bueso <dave@...olabs.net>,
Jonathan Cameron <jonathan.cameron@...wei.com>,
Dave Jiang <dave.jiang@...el.com>,
Alison Schofield <alison.schofield@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>, Ira Weiny <ira.weiny@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Takashi Sakamoto <o-takashi@...amocchi.jp>, Timur Tabi <timur@...nel.org>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>
Cc: Zijun Hu <zijun_hu@...oud.com>, linux-kernel@...r.kernel.org,
linux-cxl@...r.kernel.org, netdev@...r.kernel.org,
Zijun Hu <quic_zijuhu@...cinc.com>
Subject: [PATCH v3 0/3] driver core: Prevent device_find_child() from
modifying caller's match data
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));
Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.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 (3):
driver core: Make parameter check consistent for API cluster device_(for_each|find)_child()
cxl/region: Find free cxl decoder by device_for_each_child()
net: qcom/emac: Prevent device_find_child() from modifying caller's match data
drivers/base/core.c | 6 ++---
drivers/cxl/core/region.c | 30 ++++++++++++++++++++-----
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 22 +++++++++++++-----
3 files changed, 44 insertions(+), 14 deletions(-)
---
base-commit: 888f67e621dda5c2804a696524e28d0ca4cf0a80
change-id: 20240811-const_dfc_prepare-3ff23c6598e5
Best regards,
--
Zijun Hu <quic_zijuhu@...cinc.com>
Powered by blists - more mailing lists