Skip to contentSkip to conversation

usb: typec: ucsi: Changing the driver data type to void

PATCH In review Heikki Krogerus 2 participants 4 messages Jun 18, 2024

Subsystems (2)
lore
Share & tools
lore

Heikki Krogerus

author maintainer
#0 lore raw

PATCH 1/1 usb: typec: ucsi: Changing the driver data type to void

Let's use the same data type as struct device.

---
 drivers/usb/typec/ucsi/ucsi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.h +1 -1
index 97eda8cd63df..1280cac314fe 100644
@@ -395,7 +395,7 @@ struct ucsi_debugfs_entry {
 struct ucsi {
 	u16 version;
 	struct device *dev;
-	struct driver_data *driver_data;
+	void *driver_data;
 
 	const struct ucsi_operations *ops;
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 12 lines · Heikki Krogerus

Let's use the same data type as struct device.

---
 drivers/usb/typec/ucsi/ucsi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.h +0 -0
index 97eda8cd63df..1280cac314fe 100644

drivers/usb/typec/ucsi/ucsi.h struct ucsi_debugfs_entry { · line 398

Quoted 5 lines
drivers/usb/typec/ucsi/ucsi.h +1 -1
@@ -395,7 +395,7 @@ struct ucsi_debugfs_entry {
 struct ucsi {
 	u16 version;
 	struct device *dev;
-	struct driver_data *driver_data;
+	void *driver_data;

Nice, but why?

And how was this building? I don't see a "struct driver_data" defined anywhere here.

thanks,

greg k-h

author maintainer
#2 lore raw
Quoted 21 lines · Greg Kroah-Hartman
Quoted 12 lines · Heikki Krogerus

Let's use the same data type as struct device.

---
 drivers/usb/typec/ucsi/ucsi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.h +0 -0
index 97eda8cd63df..1280cac314fe 100644

drivers/usb/typec/ucsi/ucsi.h struct ucsi_debugfs_entry { · line 398

Quoted 5 lines
drivers/usb/typec/ucsi/ucsi.h +1 -1
@@ -395,7 +395,7 @@ struct ucsi_debugfs_entry {
 struct ucsi {
 	u16 version;
 	struct device *dev;
-	struct driver_data *driver_data;
+	void *driver_data;

Nice, but why?

Quoted 2 lines

And how was this building? I don't see a "struct driver_data" defined anywhere here.

I had not even thought about that, but that's weird.

I can write anything after "struct" there, and it will just build without any warnings or errors. The complier does not seem to even check the type in this case, since the member is always assigned a void pointer.

So this is actually a bug, no?

thanks,

Signature · 1 line
heikki
#3 lore raw
Quoted 25 lines · Heikki Krogerus
Quoted 21 lines · Greg Kroah-Hartman
Quoted 12 lines · Heikki Krogerus

Let's use the same data type as struct device.

---
 drivers/usb/typec/ucsi/ucsi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.h +0 -0
index 97eda8cd63df..1280cac314fe 100644

drivers/usb/typec/ucsi/ucsi.h struct ucsi_debugfs_entry { · line 398

Quoted 5 lines
drivers/usb/typec/ucsi/ucsi.h +1 -1
@@ -395,7 +395,7 @@ struct ucsi_debugfs_entry {
 struct ucsi {
 	u16 version;
 	struct device *dev;
-	struct driver_data *driver_data;
+	void *driver_data;

Nice, but why?

Quoted 2 lines

And how was this building? I don't see a "struct driver_data" defined anywhere here.

Quoted 6 lines

I had not even thought about that, but that's weird.

I can write anything after "struct" there, and it will just build without any warnings or errors. The complier does not seem to even check the type in this case, since the member is always assigned a void pointer.

Ah, I guess the compiler never actually has to look up what 'struct driver_data' is if it is never referenced (i.e. you are only casting void * to it.)

Quoted 1 line

So this is actually a bug, no?

Kind of? But it works, so let's just leave it alone :)

I'll take this patch as it is "obviously correct" now, but sure looked odd to start with.

thanks,

greg k-h