* [PATCH v2 01/32] driver core: Constify API device_find_child()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 02/32] driver core: Introduce device_match_type() to match device with a device type Zijun Hu
` (11 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
Constify the following 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);
with the following reasons:
- Protect caller's match data @*data which is for comparison and lookup
and the API does not actually need to modify @*data.
- Make the API's parameters (@match)() and @data have the same type as
all of other device finding APIs (bus|class|driver)_find_device().
- All kinds of existing device match functions can be directly taken
as the API's argument, they were exported by driver core.
Now, no (*match)() argument of the API usages is modifying @*data in
current kernel tree, so it is safe to constify the API.
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 94865c9d8adcf5f2ce5002ffd7bf0ef4fc85e4d7..a122ea1d84a3b08fce16dd1abdfa7746d31dc430 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4079,8 +4079,8 @@ EXPORT_SYMBOL_GPL(device_for_each_child_reverse_from);
*
* 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;
@@ -4125,11 +4125,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
@@ -4141,7 +4136,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 667cb6db9019349c9db0233acf9e78ff6a6d9625..0e0bc9bfe0d15a8734bf3d34106300f4df6b5364 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1081,8 +1081,8 @@ int device_for_each_child_reverse(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 *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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 02/32] driver core: Introduce device_match_type() to match device with a device type
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
2024-12-03 0:33 ` [PATCH v2 01/32] driver core: Constify API device_find_child() Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 03/32] drm/mediatek: Adapt for constified device_find_child() Zijun Hu
` (10 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
Introduce device_match_type() to simplify operations below:
- Test if a device matches with specified device type.
- Find a device with specified device type via various device finding APIs.
device_find_child() will use it as argument to simplify operations later.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/base/core.c | 6 ++++++
include/linux/device/bus.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a122ea1d84a3b08fce16dd1abdfa7746d31dc430..5bda2edcd83149decd50bb5e9a0ed4267b1f8f6c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -5239,6 +5239,12 @@ int device_match_name(struct device *dev, const void *name)
}
EXPORT_SYMBOL_GPL(device_match_name);
+int device_match_type(struct device *dev, const void *type)
+{
+ return dev->type == type;
+}
+EXPORT_SYMBOL_GPL(device_match_type);
+
int device_match_of_node(struct device *dev, const void *np)
{
return dev->of_node == np;
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index cdc4757217f9bb4b36b5c3b8a48bab45737e44c5..bc3fd74bb763e6d2d862859bd2ec3f0d443f2d7a 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -131,6 +131,7 @@ typedef int (*device_match_t)(struct device *dev, const void *data);
/* Generic device matching functions that all busses can use to match with */
int device_match_name(struct device *dev, const void *name);
+int device_match_type(struct device *dev, const void *type);
int device_match_of_node(struct device *dev, const void *np);
int device_match_fwnode(struct device *dev, const void *fwnode);
int device_match_devt(struct device *dev, const void *pdevt);
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 03/32] drm/mediatek: Adapt for constified device_find_child()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
2024-12-03 0:33 ` [PATCH v2 01/32] driver core: Constify API device_find_child() Zijun Hu
2024-12-03 0:33 ` [PATCH v2 02/32] driver core: Introduce device_match_type() to match device with a device type Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 04/32] hwmon: " Zijun Hu
` (9 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
device_find_child() has been constified to take new match function type:
typedef int (*device_match_t)(struct device *dev, const void *data);
Make mtk_drm_match() take a const pointer to adapt for the new type.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/gpu/drm/mediatek/mtk_drm_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 9a8ef8558da921c75c1ab1986795bbc0a394899d..7a276c3965cd0e9147dffb28693fd9d1a1053fc7 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -359,7 +359,7 @@ static const struct of_device_id mtk_drm_of_ids[] = {
};
MODULE_DEVICE_TABLE(of, mtk_drm_of_ids);
-static int mtk_drm_match(struct device *dev, void *data)
+static int mtk_drm_match(struct device *dev, const void *data)
{
if (!strncmp(dev_name(dev), "mediatek-drm", sizeof("mediatek-drm") - 1))
return true;
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 04/32] hwmon: Adapt for constified device_find_child()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (2 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 03/32] drm/mediatek: Adapt for constified device_find_child() Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 05/32] media: pci: mgb4: " Zijun Hu
` (8 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
device_find_child() has been constified to take new match function type:
typedef int (*device_match_t)(struct device *dev, const void *data);
Make hwmon_match_device() take a const pointer to adapt for the new type.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/hwmon/hwmon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 49b366254529fe6c03e8af6870ebd269cdcfd70c..9325bec83ae52d6519bcbd72b2e6213cfaee0b6d 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -341,7 +341,7 @@ static int hwmon_attr_base(enum hwmon_sensor_types type)
static DEFINE_MUTEX(hwmon_pec_mutex);
-static int hwmon_match_device(struct device *dev, void *data)
+static int hwmon_match_device(struct device *dev, const void *data)
{
return dev->class == &hwmon_class;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 05/32] media: pci: mgb4: Adapt for constified device_find_child()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (3 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 04/32] hwmon: " Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 06/32] thunderbolt: " Zijun Hu
` (7 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
device_find_child() has been constified to take new match function type:
typedef int (*device_match_t)(struct device *dev, const void *data);
Make its match functions take a const pointer to adapt for the new type.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/media/pci/mgb4/mgb4_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/pci/mgb4/mgb4_core.c b/drivers/media/pci/mgb4/mgb4_core.c
index bc63dc81bcae0d20924174be74b93a2139d5879f..697d50bedfe285d74c702efde61e510df87c1229 100644
--- a/drivers/media/pci/mgb4/mgb4_core.c
+++ b/drivers/media/pci/mgb4/mgb4_core.c
@@ -123,7 +123,7 @@ static const struct hwmon_chip_info temp_chip_info = {
};
#endif
-static int match_i2c_adap(struct device *dev, void *data)
+static int match_i2c_adap(struct device *dev, const void *data)
{
return i2c_verify_adapter(dev) ? 1 : 0;
}
@@ -139,7 +139,7 @@ static struct i2c_adapter *get_i2c_adap(struct platform_device *pdev)
return dev ? to_i2c_adapter(dev) : NULL;
}
-static int match_spi_adap(struct device *dev, void *data)
+static int match_spi_adap(struct device *dev, const void *data)
{
return to_spi_device(dev) ? 1 : 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 06/32] thunderbolt: Adapt for constified device_find_child()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (4 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 05/32] media: pci: mgb4: " Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 07/32] gpio: sim: Remove gpio_sim_dev_match_fwnode() Zijun Hu
` (6 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
device_find_child() has been constified to take new match function type:
typedef int (*device_match_t)(struct device *dev, const void *data);
Make its match functions take a const pointer to adapt for the new type.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/thunderbolt/retimer.c | 2 +-
drivers/thunderbolt/xdomain.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c
index 89d2919d0193e8f5c68e669d054f3efc7abf78c8..21d2902c6102f0f593fb0c6d645acaff31ebb274 100644
--- a/drivers/thunderbolt/retimer.c
+++ b/drivers/thunderbolt/retimer.c
@@ -461,7 +461,7 @@ struct tb_retimer_lookup {
u8 index;
};
-static int retimer_match(struct device *dev, void *data)
+static int retimer_match(struct device *dev, const void *data)
{
const struct tb_retimer_lookup *lookup = data;
struct tb_retimer *rt = tb_to_retimer(dev);
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index 11a50c86a1e4302968f44dafeab47977bac01dd5..b0630e6d94726f9069c20017876ec7e212071686 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -1026,7 +1026,7 @@ static int remove_missing_service(struct device *dev, void *data)
return 0;
}
-static int find_service(struct device *dev, void *data)
+static int find_service(struct device *dev, const void *data)
{
const struct tb_property *p = data;
struct tb_service *svc;
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 07/32] gpio: sim: Remove gpio_sim_dev_match_fwnode()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (5 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 06/32] thunderbolt: " Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 08/32] net: dsa: Adapt for constified device_find_child() Zijun Hu
` (5 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
device_find_child() has been constified to take new match function type:
typedef int (*device_match_t)(struct device *dev, const void *data);
So device_match_fwnode() is applicable for the new type directly, and
remove its unnecessary wrapper gpio_sim_dev_match_fwnode().
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/gpio/gpio-sim.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index f387dad81f2960b5ec3c1b5fd04081ee501cc75b..b1f33cbaaaa78aca324f99c45a868e7e79a9d672 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -413,11 +413,6 @@ static int gpio_sim_setup_sysfs(struct gpio_sim_chip *chip)
return devm_add_action_or_reset(dev, gpio_sim_sysfs_remove, chip);
}
-static int gpio_sim_dev_match_fwnode(struct device *dev, void *data)
-{
- return device_match_fwnode(dev, data);
-}
-
static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
{
struct gpio_sim_chip *chip;
@@ -503,7 +498,7 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
if (ret)
return ret;
- chip->dev = device_find_child(dev, swnode, gpio_sim_dev_match_fwnode);
+ chip->dev = device_find_child(dev, swnode, device_match_fwnode);
if (!chip->dev)
return -ENODEV;
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 08/32] net: dsa: Adapt for constified device_find_child()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (6 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 07/32] gpio: sim: Remove gpio_sim_dev_match_fwnode() Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 09/32] pwm: " Zijun Hu
` (4 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
device_find_child() has been constified to take new match function type:
typedef int (*device_match_t)(struct device *dev, const void *data);
Make dev_is_class() take a const pointer to adapt for the new type.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
net/dsa/dsa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 5a7c0e565a894545ee14f0e0186ed3c46b809b16..e827775baf2ee1d0e1c0ce5807c2cca5c372fc75 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -1367,7 +1367,7 @@ static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *dn)
return dsa_switch_parse_ports_of(ds, dn);
}
-static int dev_is_class(struct device *dev, void *class)
+static int dev_is_class(struct device *dev, const void *class)
{
if (dev->class != NULL && !strcmp(dev->class->name, class))
return 1;
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 09/32] pwm: Adapt for constified device_find_child()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (7 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 08/32] net: dsa: Adapt for constified device_find_child() Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 10/32] nvdimm: " Zijun Hu
` (3 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
device_find_child() has been constified to take new match function type:
typedef int (*device_match_t)(struct device *dev, const void *data);
Make pwm_unexport_match() take a const pointer to adapt for the new type.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/pwm/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 9c733877e98e47ac6548932cb040e91dd1008f81..6edceb89de30af0bde94de59b1c714971dbf9664 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -1276,7 +1276,7 @@ static int pwm_export_child(struct device *pwmchip_dev, struct pwm_device *pwm)
return 0;
}
-static int pwm_unexport_match(struct device *pwm_dev, void *data)
+static int pwm_unexport_match(struct device *pwm_dev, const void *data)
{
return pwm_from_dev(pwm_dev) == data;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 10/32] nvdimm: Adapt for constified device_find_child()
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (8 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 09/32] pwm: " Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 0:33 ` [PATCH v2 11/32] libnvdimm: Simplify nd_namespace_store() implementation Zijun Hu
` (2 subsequent siblings)
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
device_find_child() has been constified to take new match function type:
typedef int (*device_match_t)(struct device *dev, const void *data);
Make match_dimm() take a const pointer to adapt for the new type.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/nvdimm/bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 2237715e42eb32a14a4134746739a0df5ca27414..0ccf4a9e523a52ef52a96a339ecff0bcb51b214b 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1212,7 +1212,7 @@ enum nd_ioctl_mode {
DIMM_IOCTL,
};
-static int match_dimm(struct device *dev, void *data)
+static int match_dimm(struct device *dev, const void *data)
{
long id = (long) data;
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 11/32] libnvdimm: Simplify nd_namespace_store() implementation
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (9 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 10/32] nvdimm: " Zijun Hu
@ 2024-12-03 0:33 ` Zijun Hu
2024-12-03 2:29 ` [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages quic_zijuhu
2024-12-03 12:00 ` Uwe Kleine-König
12 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 0:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: Zijun Hu, linux-kernel, dri-devel, linux-mediatek,
linux-arm-kernel, linux-hwmon, linux-media, linux-usb, linux-gpio,
netdev, linux-pwm, nvdimm, linux1394-devel, linux-serial,
linux-sound, open-iscsi, linux-scsi, linux-cxl, sparclinux,
linux-block, arm-scmi, linux-efi, linux-remoteproc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
Simplify nd_namespace_store() implementation by device_find_child_by_name()
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/nvdimm/claim.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/nvdimm/claim.c b/drivers/nvdimm/claim.c
index 030dbde6b0882050c90fb8db106ec15b1baef7ca..9e84ab411564f9d5e7ceb687c6491562564552e3 100644
--- a/drivers/nvdimm/claim.c
+++ b/drivers/nvdimm/claim.c
@@ -67,13 +67,6 @@ bool nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach,
return claimed;
}
-static int namespace_match(struct device *dev, void *data)
-{
- char *name = data;
-
- return strcmp(name, dev_name(dev)) == 0;
-}
-
static bool is_idle(struct device *dev, struct nd_namespace_common *ndns)
{
struct nd_region *nd_region = to_nd_region(dev->parent);
@@ -168,7 +161,7 @@ ssize_t nd_namespace_store(struct device *dev,
goto out;
}
- found = device_find_child(dev->parent, name, namespace_match);
+ found = device_find_child_by_name(dev->parent, name);
if (!found) {
dev_dbg(dev, "'%s' not found under %s\n", name,
dev_name(dev->parent));
--
2.34.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (10 preceding siblings ...)
2024-12-03 0:33 ` [PATCH v2 11/32] libnvdimm: Simplify nd_namespace_store() implementation Zijun Hu
@ 2024-12-03 2:29 ` quic_zijuhu
2024-12-03 12:00 ` Uwe Kleine-König
12 siblings, 0 replies; 24+ messages in thread
From: quic_zijuhu @ 2024-12-03 2:29 UTC (permalink / raw)
To: Zijun Hu, Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Uwe Kleine-König, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Takashi Sakamoto, Jiri Slaby,
Heikki Krogerus, Srinivas Kandagatla, Lee Duncan, Chris Leech,
Mike Christie, James E.J. Bottomley, Martin K. Petersen,
Nilesh Javali, Manish Rangankar, GR-QLogic-Storage-Upstream,
Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Andreas Larsson, Stuart Yoder, Laurentiu Tudor, Jens Axboe,
Sudeep Holla, Cristian Marussi, Ard Biesheuvel, Bjorn Andersson,
Mathieu Poirier
Cc: linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
linux-hwmon, linux-media, linux-usb, linux-gpio, netdev,
linux-pwm, nvdimm, linux1394-devel, linux-serial, linux-sound,
open-iscsi, linux-scsi, linux-cxl, sparclinux, linux-block,
arm-scmi, linux-efi, linux-remoteproc
On 12/3/2024 8:33 AM, Zijun Hu wrote:
> This patch series is to constify the following 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);
>
> Why to constify the API?
>
> - Protect caller's match data @*data which is for comparison and lookup
> and the API does not actually need to modify @*data.
>
> - Make the API's parameters (@match)() and @data have the same type as
> all of other device finding APIs (bus|class|driver)_find_device().
>
> - All kinds of existing device matching functions can be directly taken
> as the API's argument, they were exported by driver core.
>
> How to constify the API?
>
> - Now, no (@match)() argument of the API usages is modifying its match
> data @*data after previous cleanup, so it is easy and safe to make its
> parameter @data take const void * as type.
>
> - Simplify involved codes further if it is possbile with benefits
> brought by constifying the API.
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> Changes in v2:
> - Series v1 have no code review comments and are posted a long time ago, so may ignore differences.
> - Link to v1: https://lore.kernel.org/r/20240811-const_dfc_done-
> v1-0-9d85e3f943cb@quicinc.com
> - Motivation link: https://lore.kernel.org/lkml/917359cc-a421-41dd-93f4-d28937fe2325@icloud.com
>
> ---
> Zijun Hu (32):
> driver core: Constify API device_find_child()
> driver core: Introduce device_match_type() to match device with a device type
> drm/mediatek: Adapt for constified device_find_child()
> hwmon: Adapt for constified device_find_child()
> media: pci: mgb4: Adapt for constified device_find_child()
> thunderbolt: Adapt for constified device_find_child()
> gpio: sim: Remove gpio_sim_dev_match_fwnode()
> net: dsa: Adapt for constified device_find_child()
> pwm: Adapt for constified device_find_child()
> nvdimm: Adapt for constified device_find_child()
> libnvdimm: Simplify nd_namespace_store() implementation
> firewire: core: Adapt for constified device_find_child()
> serial: core: Adapt for constified device_find_child()
> usb: typec: class: Remove both cable_match() and partner_match()
> usb: typec: class: Adapt for constified device_find_child()
> slimbus: core: Simplify of_find_slim_device() implementation
> slimbus: core: Constify slim_eaddr_equal()
> slimbus: core: Adapt for constified device_find_child()
> scsi: iscsi: Constify API iscsi_find_flashnode_sess()
> scsi: qla4xxx: Adapt for constified iscsi_find_flashnode_sess()
> scsi: iscsi: Adapt for constified device_find_child()
> cxl/region: Adapt for constified device_find_child()
> cxl/pmem: Remove match_nvdimm_bridge()
> cxl/core/pci: Adapt for constified device_find_child()
> cxl/test: Adapt for constified device_find_child()
> sparc: vio: Adapt for constified device_find_child()
> bus: fsl-mc: Adapt for constified device_find_child()
> block: sunvdc: Adapt for constified device_find_child()
> firmware: arm_scmi: Adapt for constified device_find_child()
> efi: dev-path-parser: Adapt for constified device_find_child()
> rpmsg: core: Adapt for constified device_find_child()
> driver core: Simplify API device_find_child_by_name() implementation
sorry for that only part of this series [0/32, 11/32] were sent out due
to mail account capability limitation.
will solve the limitation and send out whole patch series as v3.
thanks (^^)
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 0:33 [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages Zijun Hu
` (11 preceding siblings ...)
2024-12-03 2:29 ` [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages quic_zijuhu
@ 2024-12-03 12:00 ` Uwe Kleine-König
2024-12-03 12:23 ` Zijun Hu
12 siblings, 1 reply; 24+ messages in thread
From: Uwe Kleine-König @ 2024-12-03 12:00 UTC (permalink / raw)
To: Zijun Hu
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
James E.J. Bottomley, Martin K. Petersen, Nilesh Javali,
Manish Rangankar, GR-QLogic-Storage-Upstream, Davidlohr Bueso,
Jonathan Cameron, Alison Schofield, Andreas Larsson, Stuart Yoder,
Laurentiu Tudor, Jens Axboe, Sudeep Holla, Cristian Marussi,
Ard Biesheuvel, Bjorn Andersson, Mathieu Poirier, linux-kernel,
dri-devel, linux-mediatek, linux-arm-kernel, linux-hwmon,
linux-media, linux-usb, linux-gpio, netdev, linux-pwm, nvdimm,
linux1394-devel, linux-serial, linux-sound, open-iscsi,
linux-scsi, linux-cxl, sparclinux, linux-block, arm-scmi,
linux-efi, linux-remoteproc, Zijun Hu
[-- Attachment #1: Type: text/plain, Size: 2679 bytes --]
Hello,
On Tue, Dec 03, 2024 at 08:33:22AM +0800, Zijun Hu wrote:
> This patch series is to constify the following 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);
This series isn't bisectible. With only the first two patches applied I
hit:
CC drivers/pwm/core.o
drivers/pwm/core.c: In function ‘pwm_unexport_child’:
drivers/pwm/core.c:1292:55: error: passing argument 3 of ‘device_find_child’ from incompatible pointer type [-Wincompatible-pointer-types]
1292 | pwm_dev = device_find_child(pwmchip_dev, pwm, pwm_unexport_match);
| ^~~~~~~~~~~~~~~~~~
| |
| int (*)(struct device *, void *)
In file included from include/linux/acpi.h:14,
from drivers/pwm/core.c:11:
include/linux/device.h:1085:49: note: expected ‘device_match_t’ {aka ‘int (*)(struct device *, const void *)’} but argument is of type ‘int (*)(struct device *, void *)’
1085 | device_match_t match);
| ~~~~~~~~~~~~~~~^~~~~
drivers/pwm/core.c: In function ‘pwm_class_get_state’:
drivers/pwm/core.c:1386:55: error: passing argument 3 of ‘device_find_child’ from incompatible pointer type [-Wincompatible-pointer-types]
1386 | pwm_dev = device_find_child(pwmchip_dev, pwm, pwm_unexport_match);
| ^~~~~~~~~~~~~~~~~~
| |
| int (*)(struct device *, void *)
include/linux/device.h:1085:49: note: expected ‘device_match_t’ {aka ‘int (*)(struct device *, const void *)’} but argument is of type ‘int (*)(struct device *, void *)’
1085 | device_match_t match);
| ~~~~~~~~~~~~~~~^~~~~
make[5]: *** [scripts/Makefile.build:194: drivers/pwm/core.o] Error 1
make[4]: *** [scripts/Makefile.build:440: drivers/pwm] Error 2
make[3]: *** [scripts/Makefile.build:440: drivers] Error 2
make[2]: *** [Makefile:1989: .] Error 2
make[1]: *** [Makefile:372: __build_one_by_one] Error 2
make: *** [Makefile:251: __sub-make] Error 2
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 12:00 ` Uwe Kleine-König
@ 2024-12-03 12:23 ` Zijun Hu
2024-12-03 12:41 ` Greg Kroah-Hartman
0 siblings, 1 reply; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 12:23 UTC (permalink / raw)
To: Uwe Kleine-König, Greg Kroah-Hartman
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
James E.J. Bottomley, Martin K. Petersen, Nilesh Javali,
Manish Rangankar, GR-QLogic-Storage-Upstream, Davidlohr Bueso,
Jonathan Cameron, Alison Schofield, Andreas Larsson, Stuart Yoder,
Laurentiu Tudor, Jens Axboe, Sudeep Holla, Cristian Marussi,
Ard Biesheuvel, Bjorn Andersson, Mathieu Poirier, linux-kernel,
dri-devel, linux-mediatek, linux-arm-kernel, linux-hwmon,
linux-media, linux-usb, linux-gpio, netdev, linux-pwm, nvdimm,
linux1394-devel, linux-serial, linux-sound, open-iscsi,
linux-scsi, linux-cxl, sparclinux, linux-block, arm-scmi,
linux-efi, linux-remoteproc, Zijun Hu
On 2024/12/3 20:00, Uwe Kleine-König wrote:
> Hello,
>
> On Tue, Dec 03, 2024 at 08:33:22AM +0800, Zijun Hu wrote:
>> This patch series is to constify the following 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);
>
> This series isn't bisectible. With only the first two patches applied I
> hit:
yes. such patch series needs to be merge as atomic way.
Hi Greg,
is it possible to ONLY merge such patch series by atomic way into your
driver-core tree?
or squash such patch series into a single patch ?
various subsystem maintainers may not like squashing way.
>
> CC drivers/pwm/core.o
> drivers/pwm/core.c: In function ‘pwm_unexport_child’:
> drivers/pwm/core.c:1292:55: error: passing argument 3 of ‘device_find_child’ from incompatible pointer type [-Wincompatible-pointer-types]
> 1292 | pwm_dev = device_find_child(pwmchip_dev, pwm, pwm_unexport_match);
> | ^~~~~~~~~~~~~~~~~~
> | |
> | int (*)(struct device *, void *)
> In file included from include/linux/acpi.h:14,
> from drivers/pwm/core.c:11:
> include/linux/device.h:1085:49: note: expected ‘device_match_t’ {aka ‘int (*)(struct device *, const void *)’} but argument is of type ‘int (*)(struct device *, void *)’
> 1085 | device_match_t match);
> | ~~~~~~~~~~~~~~~^~~~~
> drivers/pwm/core.c: In function ‘pwm_class_get_state’:
> drivers/pwm/core.c:1386:55: error: passing argument 3 of ‘device_find_child’ from incompatible pointer type [-Wincompatible-pointer-types]
> 1386 | pwm_dev = device_find_child(pwmchip_dev, pwm, pwm_unexport_match);
> | ^~~~~~~~~~~~~~~~~~
> | |
> | int (*)(struct device *, void *)
> include/linux/device.h:1085:49: note: expected ‘device_match_t’ {aka ‘int (*)(struct device *, const void *)’} but argument is of type ‘int (*)(struct device *, void *)’
> 1085 | device_match_t match);
> | ~~~~~~~~~~~~~~~^~~~~
> make[5]: *** [scripts/Makefile.build:194: drivers/pwm/core.o] Error 1
> make[4]: *** [scripts/Makefile.build:440: drivers/pwm] Error 2
> make[3]: *** [scripts/Makefile.build:440: drivers] Error 2
> make[2]: *** [Makefile:1989: .] Error 2
> make[1]: *** [Makefile:372: __build_one_by_one] Error 2
> make: *** [Makefile:251: __sub-make] Error 2
>
> Best regards
> Uwe
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 12:23 ` Zijun Hu
@ 2024-12-03 12:41 ` Greg Kroah-Hartman
2024-12-03 13:02 ` Zijun Hu
0 siblings, 1 reply; 24+ messages in thread
From: Greg Kroah-Hartman @ 2024-12-03 12:41 UTC (permalink / raw)
To: Zijun Hu
Cc: Uwe Kleine-König, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
James E.J. Bottomley, Martin K. Petersen, Nilesh Javali,
Manish Rangankar, GR-QLogic-Storage-Upstream, Davidlohr Bueso,
Jonathan Cameron, Alison Schofield, Andreas Larsson, Stuart Yoder,
Laurentiu Tudor, Jens Axboe, Sudeep Holla, Cristian Marussi,
Ard Biesheuvel, Bjorn Andersson, Mathieu Poirier, linux-kernel,
dri-devel, linux-mediatek, linux-arm-kernel, linux-hwmon,
linux-media, linux-usb, linux-gpio, netdev, linux-pwm, nvdimm,
linux1394-devel, linux-serial, linux-sound, open-iscsi,
linux-scsi, linux-cxl, sparclinux, linux-block, arm-scmi,
linux-efi, linux-remoteproc, Zijun Hu
On Tue, Dec 03, 2024 at 08:23:45PM +0800, Zijun Hu wrote:
> On 2024/12/3 20:00, Uwe Kleine-König wrote:
> > Hello,
> >
> > On Tue, Dec 03, 2024 at 08:33:22AM +0800, Zijun Hu wrote:
> >> This patch series is to constify the following 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);
> >
> > This series isn't bisectible. With only the first two patches applied I
> > hit:
>
> yes. such patch series needs to be merge as atomic way.
>
> Hi Greg,
>
> is it possible to ONLY merge such patch series by atomic way into your
> driver-core tree?
Nope!
> or squash such patch series into a single patch ?
>
> various subsystem maintainers may not like squashing way.
Agreed, so look into either doing it in a bisectable way if at all
possible. As I don't see a full series here, I can't suggest how it
needs to happen :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 12:41 ` Greg Kroah-Hartman
@ 2024-12-03 13:02 ` Zijun Hu
2024-12-03 13:58 ` James Bottomley
0 siblings, 1 reply; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 13:02 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Uwe Kleine-König, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
James E.J. Bottomley, Martin K. Petersen, Nilesh Javali,
Manish Rangankar, GR-QLogic-Storage-Upstream, Davidlohr Bueso,
Jonathan Cameron, Alison Schofield, Andreas Larsson, Stuart Yoder,
Laurentiu Tudor, Jens Axboe, Sudeep Holla, Cristian Marussi,
Ard Biesheuvel, Bjorn Andersson, Mathieu Poirier, linux-kernel,
dri-devel, linux-mediatek, linux-arm-kernel, linux-hwmon,
linux-media, linux-usb, linux-gpio, netdev, linux-pwm, nvdimm,
linux1394-devel, linux-serial, linux-sound, open-iscsi,
linux-scsi, linux-cxl, sparclinux, linux-block, arm-scmi,
linux-efi, linux-remoteproc, Zijun Hu
On 2024/12/3 20:41, Greg Kroah-Hartman wrote:
> On Tue, Dec 03, 2024 at 08:23:45PM +0800, Zijun Hu wrote:
>> On 2024/12/3 20:00, Uwe Kleine-König wrote:
>>> Hello,
>>>
>>> On Tue, Dec 03, 2024 at 08:33:22AM +0800, Zijun Hu wrote:
>>>> This patch series is to constify the following 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);
>>>
>>> This series isn't bisectible. With only the first two patches applied I
>>> hit:
>>
>> yes. such patch series needs to be merge as atomic way.
>>
>> Hi Greg,
>>
>> is it possible to ONLY merge such patch series by atomic way into your
>> driver-core tree?
>
> Nope!
>
>> or squash such patch series into a single patch ?
>>
>> various subsystem maintainers may not like squashing way.
>
> Agreed, so look into either doing it in a bisectable way if at all
> possible. As I don't see a full series here, I can't suggest how it
> needs to happen :(
>
let me send you a full series later and discuss how to solve this issue.
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 13:02 ` Zijun Hu
@ 2024-12-03 13:58 ` James Bottomley
2024-12-03 14:07 ` Thomas Weißschuh
0 siblings, 1 reply; 24+ messages in thread
From: James Bottomley @ 2024-12-03 13:58 UTC (permalink / raw)
To: Zijun Hu, Greg Kroah-Hartman
Cc: Uwe Kleine-König, Rafael J. Wysocki, Chun-Kuang Hu,
Philipp Zabel, David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, Jean Delvare, Guenter Roeck,
Martin Tuma, Mauro Carvalho Chehab, Andreas Noever, Michael Jamet,
Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
Martin K. Petersen, Nilesh Javali, Manish Rangankar,
GR-QLogic-Storage-Upstream, Davidlohr Bueso, Jonathan Cameron,
Alison Schofield, Andreas Larsson, Stuart Yoder, Laurentiu Tudor,
Jens Axboe, Sudeep Holla, Cristian Marussi, Ard Biesheuvel,
Bjorn Andersson, Mathieu Poirier, linux-kernel, dri-devel,
linux-mediatek, linux-arm-kernel, linux-hwmon, linux-media,
linux-usb, linux-gpio, netdev, linux-pwm, nvdimm, linux1394-devel,
linux-serial, linux-sound, open-iscsi, linux-scsi, linux-cxl,
sparclinux, linux-block, arm-scmi, linux-efi, linux-remoteproc,
Zijun Hu
On Tue, 2024-12-03 at 21:02 +0800, Zijun Hu wrote:
> On 2024/12/3 20:41, Greg Kroah-Hartman wrote:
> > On Tue, Dec 03, 2024 at 08:23:45PM +0800, Zijun Hu wrote:
[...]
> > > or squash such patch series into a single patch ?
> > >
> > > various subsystem maintainers may not like squashing way.
> >
> > Agreed, so look into either doing it in a bisectable way if at all
> > possible. As I don't see a full series here, I can't suggest how
> > it needs to happen :(
> >
>
> let me send you a full series later and discuss how to solve this
> issue.
It's only slightly more complex than what we normally do: modify all
instances and then change the API. In this case you have an additional
problem because the prototype "const void *" will cause a mismatch if a
function has "void *". The easiest way to solve this is probably to
make device_find_child a macro that coerces its function argument to
having a non const "void *" and then passes off to the real function.
If you do that in the first patch, then you can constify all the
consumers and finally remove the macro coercion in the last patch.
James
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 13:58 ` James Bottomley
@ 2024-12-03 14:07 ` Thomas Weißschuh
2024-12-03 14:56 ` Zijun Hu
0 siblings, 1 reply; 24+ messages in thread
From: Thomas Weißschuh @ 2024-12-03 14:07 UTC (permalink / raw)
To: James Bottomley
Cc: Zijun Hu, Greg Kroah-Hartman, Uwe Kleine-König,
Rafael J. Wysocki, Chun-Kuang Hu, Philipp Zabel, David Airlie,
Simona Vetter, Matthias Brugger, AngeloGioacchino Del Regno,
Jean Delvare, Guenter Roeck, Martin Tuma, Mauro Carvalho Chehab,
Andreas Noever, Michael Jamet, Mika Westerberg, Yehezkel Bernat,
Linus Walleij, Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
Martin K. Petersen, Nilesh Javali, Manish Rangankar,
GR-QLogic-Storage-Upstream, Davidlohr Bueso, Jonathan Cameron,
Alison Schofield, Andreas Larsson, Stuart Yoder, Laurentiu Tudor,
Jens Axboe, Sudeep Holla, Cristian Marussi, Ard Biesheuvel,
Bjorn Andersson, Mathieu Poirier, linux-kernel, dri-devel,
linux-mediatek, linux-arm-kernel, linux-hwmon, linux-media,
linux-usb, linux-gpio, netdev, linux-pwm, nvdimm, linux1394-devel,
linux-serial, linux-sound, open-iscsi, linux-scsi, linux-cxl,
sparclinux, linux-block, arm-scmi, linux-efi, linux-remoteproc,
Zijun Hu
On 2024-12-03 08:58:26-0500, James Bottomley wrote:
> On Tue, 2024-12-03 at 21:02 +0800, Zijun Hu wrote:
> > On 2024/12/3 20:41, Greg Kroah-Hartman wrote:
> > > On Tue, Dec 03, 2024 at 08:23:45PM +0800, Zijun Hu wrote:
> [...]
> > > > or squash such patch series into a single patch ?
> > > >
> > > > various subsystem maintainers may not like squashing way.
> > >
> > > Agreed, so look into either doing it in a bisectable way if at all
> > > possible. As I don't see a full series here, I can't suggest how
> > > it needs to happen :(
> > >
> >
> > let me send you a full series later and discuss how to solve this
> > issue.
>
> It's only slightly more complex than what we normally do: modify all
> instances and then change the API. In this case you have an additional
> problem because the prototype "const void *" will cause a mismatch if a
> function has "void *". The easiest way to solve this is probably to
> make device_find_child a macro that coerces its function argument to
> having a non const "void *" and then passes off to the real function.
> If you do that in the first patch, then you can constify all the
> consumers and finally remove the macro coercion in the last patch.
Casting function pointers like that should be detected and trapped by
control flow integrity checking (KCFI).
Another possibility would be to use a macro and _Generic to dispatch to
two different backing functions. See __BIN_ATTR() in
include/linux/sysfs.h for an inspiration.
This also enables an incremental migration.
Thomas
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 14:07 ` Thomas Weißschuh
@ 2024-12-03 14:56 ` Zijun Hu
2024-12-03 15:34 ` James Bottomley
0 siblings, 1 reply; 24+ messages in thread
From: Zijun Hu @ 2024-12-03 14:56 UTC (permalink / raw)
To: Thomas Weißschuh, James Bottomley
Cc: Greg Kroah-Hartman, Uwe Kleine-König, Rafael J. Wysocki,
Chun-Kuang Hu, Philipp Zabel, David Airlie, Simona Vetter,
Matthias Brugger, AngeloGioacchino Del Regno, Jean Delvare,
Guenter Roeck, Martin Tuma, Mauro Carvalho Chehab, Andreas Noever,
Michael Jamet, Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
Martin K. Petersen, Nilesh Javali, Manish Rangankar,
GR-QLogic-Storage-Upstream, Davidlohr Bueso, Jonathan Cameron,
Alison Schofield, Andreas Larsson, Stuart Yoder, Laurentiu Tudor,
Jens Axboe, Sudeep Holla, Cristian Marussi, Ard Biesheuvel,
Bjorn Andersson, Mathieu Poirier, linux-kernel, dri-devel,
linux-mediatek, linux-arm-kernel, linux-hwmon, linux-media,
linux-usb, linux-gpio, netdev, linux-pwm, nvdimm, linux1394-devel,
linux-serial, linux-sound, open-iscsi, linux-scsi, linux-cxl,
sparclinux, linux-block, arm-scmi, linux-efi, linux-remoteproc,
Zijun Hu
On 2024/12/3 22:07, Thomas Weißschuh wrote:
> On 2024-12-03 08:58:26-0500, James Bottomley wrote:
>> On Tue, 2024-12-03 at 21:02 +0800, Zijun Hu wrote:
>>> On 2024/12/3 20:41, Greg Kroah-Hartman wrote:
>>>> On Tue, Dec 03, 2024 at 08:23:45PM +0800, Zijun Hu wrote:
>> [...]
>>>>> or squash such patch series into a single patch ?
>>>>>
>>>>> various subsystem maintainers may not like squashing way.
>>>>
>>>> Agreed, so look into either doing it in a bisectable way if at all
>>>> possible. As I don't see a full series here, I can't suggest how
>>>> it needs to happen :(
>>>>
>>>
>>> let me send you a full series later and discuss how to solve this
>>> issue.
>>
>> It's only slightly more complex than what we normally do: modify all
>> instances and then change the API. In this case you have an additional
>> problem because the prototype "const void *" will cause a mismatch if a
>> function has "void *". The easiest way to solve this is probably to
>> make device_find_child a macro that coerces its function argument to
>> having a non const "void *" and then passes off to the real function.
>> If you do that in the first patch, then you can constify all the
>> consumers and finally remove the macro coercion in the last patch.
>
> Casting function pointers like that should be detected and trapped by
> control flow integrity checking (KCFI).
>
> Another possibility would be to use a macro and _Generic to dispatch to
> two different backing functions. See __BIN_ATTR() in
> include/linux/sysfs.h for an inspiration.
this way may fix building error issue but does not achieve our purpose.
our purpose is that there are only constified device_find_child().
> This also enables an incremental migration.
>
>
change the API prototype from:
device_find_child(..., void *data_0, int (*match)(struct device *dev,
void *data));
to:
device_find_child(..., const void *data_0, int (*match)(struct device
*dev, const void *data));
For @data_0, void * -> const void * is okay.
but for @match, the problem is function pointer type incompatibility.
there are two solutions base on discussions.
1) squashing likewise Greg mentioned.
Do all of the "prep work" first, and then
do the const change at the very end, all at once.
2) as changing platform_driver's remove() prototype.
Commit: e70140ba0d2b ("Get rid of 'remove_new' relic from platform
driver struct")
introduce extra device_find_child_new() which is constified -> use
*_new() replace ALL device_find_child() instances one by one -> remove
device_find_child() -> rename *_new() to device_find_child() once.
> Thomas
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 14:56 ` Zijun Hu
@ 2024-12-03 15:34 ` James Bottomley
2024-12-04 12:26 ` Zijun Hu
0 siblings, 1 reply; 24+ messages in thread
From: James Bottomley @ 2024-12-03 15:34 UTC (permalink / raw)
To: Zijun Hu, Thomas Weißschuh
Cc: Greg Kroah-Hartman, Uwe Kleine-König, Rafael J. Wysocki,
Chun-Kuang Hu, Philipp Zabel, David Airlie, Simona Vetter,
Matthias Brugger, AngeloGioacchino Del Regno, Jean Delvare,
Guenter Roeck, Martin Tuma, Mauro Carvalho Chehab, Andreas Noever,
Michael Jamet, Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
Martin K. Petersen, Nilesh Javali, Manish Rangankar,
GR-QLogic-Storage-Upstream, Davidlohr Bueso, Jonathan Cameron,
Alison Schofield, Andreas Larsson, Stuart Yoder, Laurentiu Tudor,
Jens Axboe, Sudeep Holla, Cristian Marussi, Ard Biesheuvel,
Bjorn Andersson, Mathieu Poirier, linux-kernel, dri-devel,
linux-mediatek, linux-arm-kernel, linux-hwmon, linux-media,
linux-usb, linux-gpio, netdev, linux-pwm, nvdimm, linux1394-devel,
linux-serial, linux-sound, open-iscsi, linux-scsi, linux-cxl,
sparclinux, linux-block, arm-scmi, linux-efi, linux-remoteproc,
Zijun Hu
On Tue, 2024-12-03 at 22:56 +0800, Zijun Hu wrote:
> On 2024/12/3 22:07, Thomas Weißschuh wrote:
> > On 2024-12-03 08:58:26-0500, James Bottomley wrote:
> > > On Tue, 2024-12-03 at 21:02 +0800, Zijun Hu wrote:
> > > > On 2024/12/3 20:41, Greg Kroah-Hartman wrote:
> > > > > On Tue, Dec 03, 2024 at 08:23:45PM +0800, Zijun Hu wrote:
> > > [...]
> > > > > > or squash such patch series into a single patch ?
> > > > > >
> > > > > > various subsystem maintainers may not like squashing way.
> > > > >
> > > > > Agreed, so look into either doing it in a bisectable way if
> > > > > at all possible. As I don't see a full series here, I can't
> > > > > suggest how it needs to happen :(
> > > > >
> > > >
> > > > let me send you a full series later and discuss how to solve
> > > > this issue.
> > >
> > > It's only slightly more complex than what we normally do: modify
> > > all instances and then change the API. In this case you have an
> > > additional problem because the prototype "const void *" will
> > > cause a mismatch if a function has "void *". The easiest way to
> > > solve this is probably to make device_find_child a macro that
> > > coerces its function argument to having a non const "void *" and
> > > then passes off to the real function. If you do that in the
> > > first patch, then you can constify all the consumers and finally
> > > remove the macro coercion in the last patch.
> >
> > Casting function pointers like that should be detected and trapped
> > by control flow integrity checking (KCFI).
> >
> > Another possibility would be to use a macro and _Generic to
> > dispatch to two different backing functions. See __BIN_ATTR() in
> > include/linux/sysfs.h for an inspiration.
That's way over complicated for this conversion: done properly there
should be no need for _Generic() compile time type matching at all.
> this way may fix building error issue but does not achieve our
> purpose. our purpose is that there are only constified
> device_find_child().
>
>
> > This also enables an incremental migration.
>
> change the API prototype from:
> device_find_child(..., void *data_0, int (*match)(struct device *dev,
> void *data));
>
> to:
> device_find_child(..., const void *data_0, int (*match)(struct device
> *dev, const void *data));
>
> For @data_0, void * -> const void * is okay.
> but for @match, the problem is function pointer type incompatibility.
>
> there are two solutions base on discussions.
>
> 1) squashing likewise Greg mentioned.
> Do all of the "prep work" first, and then
> do the const change at the very end, all at once.
>
> 2) as changing platform_driver's remove() prototype.
> Commit: e70140ba0d2b ("Get rid of 'remove_new' relic from platform
> driver struct")
>
> introduce extra device_find_child_new() which is constified -> use
> *_new() replace ALL device_find_child() instances one by one ->
> remove device_find_child() -> rename *_new() to device_find_child()
> once.
Why bother with the last step, which churns the entire code base again?
Why not call the new function device_find_child_const() and simply keep
it (it's descriptive of its function). That way you can have a patch
series without merging and at the end simply remove the old function.
Regards,
James
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-03 15:34 ` James Bottomley
@ 2024-12-04 12:26 ` Zijun Hu
2024-12-04 16:42 ` James Bottomley
0 siblings, 1 reply; 24+ messages in thread
From: Zijun Hu @ 2024-12-04 12:26 UTC (permalink / raw)
To: James Bottomley, Thomas Weißschuh
Cc: Greg Kroah-Hartman, Uwe Kleine-König, Rafael J. Wysocki,
Chun-Kuang Hu, Philipp Zabel, David Airlie, Simona Vetter,
Matthias Brugger, AngeloGioacchino Del Regno, Jean Delvare,
Guenter Roeck, Martin Tuma, Mauro Carvalho Chehab, Andreas Noever,
Michael Jamet, Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
Martin K. Petersen, Nilesh Javali, Manish Rangankar,
GR-QLogic-Storage-Upstream, Davidlohr Bueso, Jonathan Cameron,
Alison Schofield, Andreas Larsson, Stuart Yoder, Laurentiu Tudor,
Jens Axboe, Sudeep Holla, Cristian Marussi, Ard Biesheuvel,
Bjorn Andersson, Mathieu Poirier, linux-kernel, dri-devel,
linux-mediatek, linux-arm-kernel, linux-hwmon, linux-media,
linux-usb, linux-gpio, netdev, linux-pwm, nvdimm, linux1394-devel,
linux-serial, linux-sound, open-iscsi, linux-scsi, linux-cxl,
sparclinux, linux-block, arm-scmi, linux-efi, linux-remoteproc,
Zijun Hu
On 2024/12/3 23:34, James Bottomley wrote:
>>> This also enables an incremental migration.
>> change the API prototype from:
>> device_find_child(..., void *data_0, int (*match)(struct device *dev,
>> void *data));
>>
>> to:
>> device_find_child(..., const void *data_0, int (*match)(struct device
>> *dev, const void *data));
>>
>> For @data_0, void * -> const void * is okay.
>> but for @match, the problem is function pointer type incompatibility.
>>
>> there are two solutions base on discussions.
>>
>> 1) squashing likewise Greg mentioned.
>> Do all of the "prep work" first, and then
>> do the const change at the very end, all at once.
>>
>> 2) as changing platform_driver's remove() prototype.
>> Commit: e70140ba0d2b ("Get rid of 'remove_new' relic from platform
>> driver struct")
>>
>> introduce extra device_find_child_new() which is constified -> use
>> *_new() replace ALL device_find_child() instances one by one ->
>> remove device_find_child() -> rename *_new() to device_find_child()
>> once.
> Why bother with the last step, which churns the entire code base again?
keep the good API name device_find_child().
> Why not call the new function device_find_child_const() and simply keep
> it (it's descriptive of its function). That way you can have a patch
> series without merging and at the end simply remove the old function.
device_find_child is a good name for the API, 'find' already means const.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-04 12:26 ` Zijun Hu
@ 2024-12-04 16:42 ` James Bottomley
2024-12-05 0:07 ` Zijun Hu
0 siblings, 1 reply; 24+ messages in thread
From: James Bottomley @ 2024-12-04 16:42 UTC (permalink / raw)
To: Zijun Hu, Thomas Weißschuh
Cc: Greg Kroah-Hartman, Uwe Kleine-König, Rafael J. Wysocki,
Chun-Kuang Hu, Philipp Zabel, David Airlie, Simona Vetter,
Matthias Brugger, AngeloGioacchino Del Regno, Jean Delvare,
Guenter Roeck, Martin Tuma, Mauro Carvalho Chehab, Andreas Noever,
Michael Jamet, Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
Martin K. Petersen, Nilesh Javali, Manish Rangankar,
GR-QLogic-Storage-Upstream, Davidlohr Bueso, Jonathan Cameron,
Alison Schofield, Andreas Larsson, Stuart Yoder, Laurentiu Tudor,
Jens Axboe, Sudeep Holla, Cristian Marussi, Ard Biesheuvel,
Bjorn Andersson, Mathieu Poirier, linux-kernel, dri-devel,
linux-mediatek, linux-arm-kernel, linux-hwmon, linux-media,
linux-usb, linux-gpio, netdev, linux-pwm, nvdimm, linux1394-devel,
linux-serial, linux-sound, open-iscsi, linux-scsi, linux-cxl,
sparclinux, linux-block, arm-scmi, linux-efi, linux-remoteproc,
Zijun Hu
On Wed, 2024-12-04 at 20:26 +0800, Zijun Hu wrote:
> On 2024/12/3 23:34, James Bottomley wrote:
> > > > This also enables an incremental migration.
> > > change the API prototype from:
> > > device_find_child(..., void *data_0, int (*match)(struct device
> > > *dev, void *data));
> > >
> > > to:
> > > device_find_child(..., const void *data_0, int (*match)(struct
> > > device *dev, const void *data));
> > >
> > > For @data_0, void * -> const void * is okay.
> > > but for @match, the problem is function pointer type
> > > incompatibility.
> > >
> > > there are two solutions base on discussions.
> > >
> > > 1) squashing likewise Greg mentioned.
> > > Do all of the "prep work" first, and then
> > > do the const change at the very end, all at once.
> > >
> > > 2) as changing platform_driver's remove() prototype.
> > > Commit: e70140ba0d2b ("Get rid of 'remove_new' relic from
> > > platform driver struct")
> > >
> > > introduce extra device_find_child_new() which is constified ->
> > > use *_new() replace ALL device_find_child() instances one by one
> > > -> remove device_find_child() -> rename *_new() to
> > > device_find_child() once.
> > Why bother with the last step, which churns the entire code base
> > again?
>
> keep the good API name device_find_child().
Well, I think it's a good opportunity to rename the API better, but if
that's the goal, you can still do it with _Generic() without churning
the code base a second time. The example is in
slab.h:kmem_cache_create
> > Why not call the new function device_find_child_const() and simply
> > keep it (it's descriptive of its function). That way you can have
> > a patch series without merging and at the end simply remove the old
> > function.
>
> device_find_child is a good name for the API, 'find' already means
> const.
Not to me it doesn't, but that's actually not what I think is wrong
with the API name: it actually only returns the first match, so I'd
marginally prefer it to be called device_find_first_child() ... not
enough to churn the code to change it, but since you're doing that
anyway it might make sense as an update.
Regards,
James
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 00/32] driver core: Constify API device_find_child() and adapt for various existing usages
2024-12-04 16:42 ` James Bottomley
@ 2024-12-05 0:07 ` Zijun Hu
0 siblings, 0 replies; 24+ messages in thread
From: Zijun Hu @ 2024-12-05 0:07 UTC (permalink / raw)
To: James Bottomley, Thomas Weißschuh
Cc: Greg Kroah-Hartman, Uwe Kleine-König, Rafael J. Wysocki,
Chun-Kuang Hu, Philipp Zabel, David Airlie, Simona Vetter,
Matthias Brugger, AngeloGioacchino Del Regno, Jean Delvare,
Guenter Roeck, Martin Tuma, Mauro Carvalho Chehab, Andreas Noever,
Michael Jamet, Mika Westerberg, Yehezkel Bernat, Linus Walleij,
Bartosz Golaszewski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Takashi Sakamoto, Jiri Slaby, Heikki Krogerus,
Srinivas Kandagatla, Lee Duncan, Chris Leech, Mike Christie,
Martin K. Petersen, Nilesh Javali, Manish Rangankar,
GR-QLogic-Storage-Upstream, Davidlohr Bueso, Jonathan Cameron,
Alison Schofield, Andreas Larsson, Stuart Yoder, Laurentiu Tudor,
Jens Axboe, Sudeep Holla, Cristian Marussi, Ard Biesheuvel,
Bjorn Andersson, Mathieu Poirier, linux-kernel, dri-devel,
linux-mediatek, linux-arm-kernel, linux-hwmon, linux-media,
linux-usb, linux-gpio, netdev, linux-pwm, nvdimm, linux1394-devel,
linux-serial, linux-sound, open-iscsi, linux-scsi, linux-cxl,
sparclinux, linux-block, arm-scmi, linux-efi, linux-remoteproc,
Zijun Hu
On 2024/12/5 00:42, James Bottomley wrote:
>>>> introduce extra device_find_child_new() which is constified ->
>>>> use *_new() replace ALL device_find_child() instances one by one
>>>> -> remove device_find_child() -> rename *_new() to
>>>> device_find_child() once.
>>> Why bother with the last step, which churns the entire code base
>>> again?
>> keep the good API name device_find_child().
> Well, I think it's a good opportunity to rename the API better, but if
> that's the goal, you can still do it with _Generic() without churning
> the code base a second time. The example is in
> slab.h:kmem_cache_create
>
i understand these solutions _Generic()/_new/squashing.
every solutions have its advantages and disadvantages.
i decide to use squashing solution for this concrete scenario after some
considerations since:
1) it has the minimal patch count to achieve target.
2) every patch is valuable, but other solutions needs to undo beginning
patch finally.
3) for the squashing patch, i will only make the least and simplest
changes for various match functions, that will compensate its
disadvantages.
>>> Why not call the new function device_find_child_const() and simply
>>> keep it (it's descriptive of its function). That way you can have
>>> a patch series without merging and at the end simply remove the old
>>> function.
>> device_find_child is a good name for the API, 'find' already means
>> const.
> Not to me it doesn't, but that's actually not what I think is wrong
> with the API name: it actually only returns the first match, so I'd
> marginally prefer it to be called device_find_first_child() ... not
> enough to churn the code to change it, but since you're doing that
> anyway it might make sense as an update.
name device_find_child appeared 18 years ago, it is good to keep this
name developers known about.
the API only return one device *, it should be obvious that it is the
first device which meet matching condition.
Other device finding APIs (bus|class|driver)_find_device() does not have
concern about 'first'
So, IMO, current name is good.
^ permalink raw reply [flat|nested] 24+ messages in thread