Skip to contentSkip to conversation

staging: greybus: gbphy: fix up const issue with the match callback

PATCH Superseded Greg Kroah-Hartman 2 participants 3 messages May 21, 2025 – May 22, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/1 staging: greybus: gbphy: fix up const issue with the match callback

gbphy_dev_match_id() should be taking a const pointer, as the pointer passed to it from the container_of() call was const to start with (it was accidentally cast away with the call.) Fix this all up by correctly marking the pointer types.

---
 drivers/staging/greybus/gbphy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/greybus/gbphy.c +4 -4
index 6adcad286633..ab8a1af36808 100644
@@ -102,8 +102,8 @@ static int gbphy_dev_uevent(const struct device *dev, struct kobj_uevent_env *en
 }
 
 static const struct gbphy_device_id *
-gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
-		   struct gbphy_driver *gbphy_drv)
+gbphy_dev_match_id(const struct gbphy_device *gbphy_dev,
+		   const struct gbphy_driver *gbphy_drv)
 {
 	const struct gbphy_device_id *id = gbphy_drv->id_table;
 
@@ -119,8 +119,8 @@ gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
 
 static int gbphy_dev_match(struct device *dev, const struct device_driver *drv)
 {
-	struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
-	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+	const struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
+	const struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
 	const struct gbphy_device_id *id;
 
 	id = gbphy_dev_match_id(gbphy_dev, gbphy_drv);
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Greg Kroah-Hartman

gbphy_dev_match_id() should be taking a const pointer, as the pointer passed to it from the container_of() call was const to start with (it was accidentally cast away with the call.) Fix this all up by correctly marking the pointer types.

This one too should have a:

Fixes d69d80484598 ("driver core: have match() callback in struct bus_type take a const *")
Quoted 21 lines
---
 drivers/staging/greybus/gbphy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/greybus/gbphy.c +2 -2
index 6adcad286633..ab8a1af36808 100644
@@ -102,8 +102,8 @@ static int gbphy_dev_uevent(const struct device *dev, struct kobj_uevent_env *en
 }
 
 static const struct gbphy_device_id *
-gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
-		   struct gbphy_driver *gbphy_drv)
+gbphy_dev_match_id(const struct gbphy_device *gbphy_dev,
+		   const struct gbphy_driver *gbphy_drv)
 {
 	const struct gbphy_device_id *id = gbphy_drv->id_table;
 

drivers/staging/greybus/gbphy.c gbphy_dev_match_id(struct gbphy_device *gbphy_dev, · line 123

Quoted 7 lines
drivers/staging/greybus/gbphy.c +2 -2
@@ -119,8 +119,8 @@ gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
 
 static int gbphy_dev_match(struct device *dev, const struct device_driver *drv)
 {
-	struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
-	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+	const struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
+	const struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);

Making the dev pointers const is arguably a separate change, but I guess it's related enough:

Johan

author maintainer
#2 lore raw
Quoted 32 lines · Johan Hovold
Quoted 4 lines · Greg Kroah-Hartman

gbphy_dev_match_id() should be taking a const pointer, as the pointer passed to it from the container_of() call was const to start with (it was accidentally cast away with the call.) Fix this all up by correctly marking the pointer types.

This one too should have a:

Fixes d69d80484598 ("driver core: have match() callback in struct bus_type take a const *")
Quoted 22 lines
---
 drivers/staging/greybus/gbphy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/greybus/gbphy.c +2 -2
index 6adcad286633..ab8a1af36808 100644
@@ -102,8 +102,8 @@ static int gbphy_dev_uevent(const struct device *dev, struct kobj_uevent_env *en
 }
 
 static const struct gbphy_device_id *
-gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
-		   struct gbphy_driver *gbphy_drv)
+gbphy_dev_match_id(const struct gbphy_device *gbphy_dev,
+		   const struct gbphy_driver *gbphy_drv)
 {
 	const struct gbphy_device_id *id = gbphy_drv->id_table;
 
@@ -119,8 +119,8 @@ gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
 
Quoted 9 lines

drivers/staging/greybus/gbphy.c gbphy_dev_match_id(struct gbphy_device *gbphy_dev, · line 123

Quoted 6 lines
drivers/staging/greybus/gbphy.c +2 -2
 static int gbphy_dev_match(struct device *dev, const struct device_driver *drv)
 {
-	struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
-	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+	const struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
+	const struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);

Making the dev pointers const is arguably a separate change, but I guess it's related enough:

Oops, nope, you are right, the dev pointer should not be const here, or anywhere else, that's not needed, I got too energetic. I'll respin this and add the fixes: tag, thanks!

greg k-h