Skip to contentSkip to conversation

zorro: Improve handling of pointers in zorro_device_id::driver_data

PATCH In review Uwe Kleine-König (The Capable Hub) 8 participants 27 messages May 26 – Jun 5

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover zorro: Improve handling of pointers in zorro_device_id::driver_data

Hello,

this series is about improving the handling of pointers in struct zorro_device_id's driver_data.

While it's ok on all current Linux platforms to store a pointer in an unsigned long variable, it involves casting that loses type information. This can be nicely seen in patch #7 where after profiting from patch #6 the compiler notices a missing const.

Preparing for that change, all zorro_device_ids are converted to use named initializers, which is also a nice cleanup that could stand for itself, as it improves readability for humans. (That is necessary because an anonymous union can be initialized by name, but not using a list initializer.)

My motivation for this series is the CHERI hardware extension. With that pointers are bigger than longs and thus you cannot store pointers in zorro_device_id::driver_data. So this series is also about getting support for CHERI into the mainline, but I hope the clean up effects mentioned above are justification enough to accept this series.

The dependencies in this series are as follows:

- Patch #5 depends on #1, #2
- Patches #7 and #8 depend on patch #6.

So if the ata maintainers agreed to merge their patch #1 via scsi, and Geert agrees to patch #5 and that it's also merged via scsi, patches #1, #2, #6 and #7 can go in without further coordination.

Patches #3, #4 and #5 are only about using the same initialization style for all zorro_device_id and can go in without coordination.

Best regards
Uwe

Uwe Kleine-König (The Capable Hub) (8):
ata: pata_budda: Use named initializer for zorro_device_id
scsi: Use named initializer for zorro_device_id
net: Use named initializer for zorro_device_id arrays
i2c: icy: Use named initializer for zorro_device_id arrays
video: fm2fb: Use named initializer for zorro_device_id array
zorro: Simplify storing pointers in device id struct
scsi: zorro7xx: Make use of struct zorro_device_id::driver_data_ptr
video: cirrusfb: Make use of struct zorro_device_id::driver_data_ptr

 drivers/ata/pata_buddha.c             |  8 ++++----
 drivers/i2c/busses/i2c-icy.c          |  4 ++--
 drivers/net/ethernet/8390/hydra.c     |  4 ++--
 drivers/net/ethernet/8390/xsurf100.c  |  4 ++--
 drivers/net/ethernet/8390/zorro8390.c |  6 +++---
 drivers/net/ethernet/amd/a2065.c      |  8 ++++----
 drivers/net/ethernet/amd/ariadne.c    |  4 ++--
 drivers/scsi/a2091.c                  |  6 +++---
 drivers/scsi/gvp11.c                  | 17 ++++++++--------
 drivers/scsi/zorro7xx.c               | 16 +++++++--------
 drivers/scsi/zorro_esp.c              |  2 +-
 drivers/video/fbdev/cirrusfb.c        | 28 +++++++++++++--------------
 drivers/video/fbdev/fm2fb.c           |  6 +++---
 include/linux/mod_devicetable.h       |  6 +++++-
 14 files changed, 62 insertions(+), 57 deletions(-)

base-commit: d387b06f7c15b4639244ad66b4b0900c6a02b430

Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/8 ata: pata_budda: Use named initializer for zorro_device_id

Using named initializers is more explicit and thus easier to parse for a human.

It's also more robust to changes in the struct definition. This robustness is relevant for a planned change to struct zorro_device_id that replaces .driver_data by an anonymous union.

This change doesn't introduce changes to the compiled zorro_device_id array.

---
 drivers/ata/pata_buddha.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ata/pata_buddha.c +4 -4
index c36ee991d5e5..3b1f0ee2f875 100644
@@ -253,9 +253,9 @@ static void pata_buddha_remove(struct zorro_dev *z)
 }
 
 static const struct zorro_device_id pata_buddha_zorro_tbl[] = {
-	{ ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA, BOARD_BUDDHA},
-	{ ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL, BOARD_CATWEASEL},
-	{ 0 }
+	{ .id = ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA, .driver_data = BOARD_BUDDHA },
+	{ .id = ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL, .driver_data = BOARD_CATWEASEL },
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, pata_buddha_zorro_tbl);
 
@@ -282,7 +282,7 @@ static int __init pata_buddha_late_init(void)
 	/* Manually bind to all X-Surf boards */
 	while ((z = zorro_find_device(ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, z))) {
 		static struct zorro_device_id xsurf_ent = {
-			ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, BOARD_XSURF
+			.id = ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, .driver_data = BOARD_XSURF
 		};
 
 		pata_buddha_probe(z, &xsurf_ent);
Signature · 1 line
2.47.3
maintainer Acked-by on v1 1/8
#2 lore raw

Re: [PATCH v1 1/8] ata: pata_budda: Use named initializer for zorro_device_id

Quoted 44 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

It's also more robust to changes in the struct definition. This robustness is relevant for a planned change to struct zorro_device_id that replaces .driver_data by an anonymous union.

This change doesn't introduce changes to the compiled zorro_device_id array.

---
 drivers/ata/pata_buddha.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ata/pata_buddha.c +4 -4
index c36ee991d5e5..3b1f0ee2f875 100644
@@ -253,9 +253,9 @@ static void pata_buddha_remove(struct zorro_dev *z)
 }
 
 static const struct zorro_device_id pata_buddha_zorro_tbl[] = {
-	{ ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA, BOARD_BUDDHA},
-	{ ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL, BOARD_CATWEASEL},
-	{ 0 }
+	{ .id = ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA, .driver_data = BOARD_BUDDHA },
+	{ .id = ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL, .driver_data = BOARD_CATWEASEL },
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, pata_buddha_zorro_tbl);
 
@@ -282,7 +282,7 @@ static int __init pata_buddha_late_init(void)
 	/* Manually bind to all X-Surf boards */
 	while ((z = zorro_find_device(ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, z))) {
 		static struct zorro_device_id xsurf_ent = {
-			ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, BOARD_XSURF
+			.id = ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, .driver_data = BOARD_XSURF
 		};
 
 		pata_buddha_probe(z, &xsurf_ent);
Signature · 1 line
2.47.3

Okay for this patch to go via SCSI as suggested by Uwe in the cover-letter:

maintainer Acked-by on v1 1/8
#3 lore raw

Re: [PATCH v1 1/8] ata: pata_budda: Use named initializer for zorro_device_id

In reply to Uwe Kleine-König (The Capable Hub)
Quoted 11 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

It's also more robust to changes in the struct definition. This robustness is relevant for a planned change to struct zorro_device_id that replaces .driver_data by an anonymous union.

This change doesn't introduce changes to the compiled zorro_device_id array.

Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v1 1/8
#4 lore raw

Re: [PATCH v1 1/8] ata: pata_budda: Use named initializer for zorro_device_id

In reply to Uwe Kleine-König (The Capable Hub)
Quoted 11 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

It's also more robust to changes in the struct definition. This robustness is relevant for a planned change to struct zorro_device_id that replaces .driver_data by an anonymous union.

This change doesn't introduce changes to the compiled zorro_device_id array.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#5 lore raw

PATCH 2/8 scsi: Use named initializer for zorro_device_id

In reply to Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

It's also more robust to changes in the struct definition. This robustness is relevant for a planned change to struct zorro_device_id that replaces .driver_data by an anonymous union.

While touching these arrays, drop explicit zeros from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id arrays.

---
 drivers/scsi/a2091.c     |  6 +++---
 drivers/scsi/gvp11.c     | 17 +++++++++--------
 drivers/scsi/zorro7xx.c  |  2 +-
 drivers/scsi/zorro_esp.c |  2 +-
 4 files changed, 14 insertions(+), 13 deletions(-)
drivers/scsi/a2091.c +3 -3
index 204448bfd04b..f81e53b53e20 100644
@@ -275,9 +275,9 @@ static void a2091_remove(struct zorro_dev *z)
 }
 
 static struct zorro_device_id a2091_zorro_tbl[] = {
-	{ ZORRO_PROD_CBM_A590_A2091_1 },
-	{ ZORRO_PROD_CBM_A590_A2091_2 },
-	{ 0 }
+	{ .id = ZORRO_PROD_CBM_A590_A2091_1 },
+	{ .id = ZORRO_PROD_CBM_A590_A2091_2 },
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, a2091_zorro_tbl);
 
drivers/scsi/gvp11.c +9 -8
index 0420bfe9bd42..79bd64e12adc 100644
@@ -442,14 +442,15 @@ static void gvp11_remove(struct zorro_dev *z)
 	 */
 
 static struct zorro_device_id gvp11_zorro_tbl[] = {
-	{ ZORRO_PROD_GVP_COMBO_030_R3_SCSI,	~0x00ffffff },
-	{ ZORRO_PROD_GVP_SERIES_II,		~0x00ffffff },
-	{ ZORRO_PROD_GVP_GFORCE_030_SCSI,	~0x01ffffff },
-	{ ZORRO_PROD_GVP_A530_SCSI,		~0x01ffffff },
-	{ ZORRO_PROD_GVP_COMBO_030_R4_SCSI,	~0x01ffffff },
-	{ ZORRO_PROD_GVP_A1291,			~0x07ffffff },
-	{ ZORRO_PROD_GVP_GFORCE_040_SCSI_1,	~0x07ffffff },
-	{ 0 }
+	/* .driver_data specifies the DMA mask */
+	{ .id = ZORRO_PROD_GVP_COMBO_030_R3_SCSI,	.driver_data = ~0x00ffffff },
+	{ .id = ZORRO_PROD_GVP_SERIES_II,		.driver_data = ~0x00ffffff },
+	{ .id = ZORRO_PROD_GVP_GFORCE_030_SCSI,		.driver_data = ~0x01ffffff },
+	{ .id = ZORRO_PROD_GVP_A530_SCSI,		.driver_data = ~0x01ffffff },
+	{ .id = ZORRO_PROD_GVP_COMBO_030_R4_SCSI,	.driver_data = ~0x01ffffff },
+	{ .id = ZORRO_PROD_GVP_A1291,			.driver_data = ~0x07ffffff },
+	{ .id = ZORRO_PROD_GVP_GFORCE_040_SCSI_1,	.driver_data = ~0x07ffffff },
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, gvp11_zorro_tbl);
 
drivers/scsi/zorro7xx.c +1 -1
index 6aca9897b231..1f74586f0428 100644
@@ -68,7 +68,7 @@ static struct zorro_device_id zorro7xx_zorro_tbl[] = {
 		.id = ZORRO_PROD_GVP_GFORCE_040_060,
 		.driver_data = (unsigned long)&zorro7xx_driver_data[3],
 	},
-	{ 0 }
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, zorro7xx_zorro_tbl);
 
drivers/scsi/zorro_esp.c +1 -1
index 1622285c9aec..178d46140674 100644
@@ -706,7 +706,7 @@ static const struct zorro_device_id zorro_esp_zorro_tbl[] = {
 		.id = ZORRO_ID(PHASE5, 0x19, 0),
 		.driver_data = ZORRO_CYBERII,
 	},
-	{ 0 }
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, zorro_esp_zorro_tbl);
 
Signature · 1 line
2.47.3
Reviewed-by on v1 2/8
#6 lore raw

Re: [PATCH v1 2/8] scsi: Use named initializer for zorro_device_id

Quoted 7 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

It's also more robust to changes in the struct definition. This robustness is relevant for a planned change to struct zorro_device_id that replaces .driver_data by an anonymous union.

Quoted 6 lines

While touching these arrays, drop explicit zeros from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id arrays.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#7 lore raw

PATCH 3/8 net: Use named initializer for zorro_device_id arrays

In reply to Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

While touching these arrays, drop explicit zeros from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id arrays.

---
 drivers/net/ethernet/8390/hydra.c     | 4 ++--
 drivers/net/ethernet/8390/xsurf100.c  | 4 ++--
 drivers/net/ethernet/8390/zorro8390.c | 6 +++---
 drivers/net/ethernet/amd/a2065.c      | 8 ++++----
 drivers/net/ethernet/amd/ariadne.c    | 4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/8390/hydra.c +2 -2
index fd9dcdc356e6..9a59915436d2 100644
@@ -66,8 +66,8 @@ static void hydra_block_output(struct net_device *dev, int count,
 static void hydra_remove_one(struct zorro_dev *z);
 
 static struct zorro_device_id hydra_zorro_tbl[] = {
-    { ZORRO_PROD_HYDRA_SYSTEMS_AMIGANET },
-    { 0 }
+    { .id = ZORRO_PROD_HYDRA_SYSTEMS_AMIGANET },
+    { }
 };
 MODULE_DEVICE_TABLE(zorro, hydra_zorro_tbl);
 
drivers/net/ethernet/8390/xsurf100.c +2 -2
index fe7a74707aa4..370c19aa5fb9 100644
@@ -357,8 +357,8 @@ static void xsurf100_remove(struct zorro_dev *zdev)
 }
 
 static const struct zorro_device_id xsurf100_zorro_tbl[] = {
-	{ ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100, },
-	{ 0 }
+	{ .id = ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100 },
+	{ }
 };
 
 MODULE_DEVICE_TABLE(zorro, xsurf100_zorro_tbl);
drivers/net/ethernet/8390/zorro8390.c +3 -3
index c24dd4fe7a10..cb1d5ed20874 100644
@@ -262,9 +262,9 @@ static void zorro8390_remove_one(struct zorro_dev *z)
 }
 
 static struct zorro_device_id zorro8390_zorro_tbl[] = {
-	{ ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2, },
-	{ ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, },
-	{ 0 }
+	{ .id = ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2 },
+	{ .id = ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF },
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, zorro8390_zorro_tbl);
 
drivers/net/ethernet/amd/a2065.c +4 -4
index ce9445425045..672c4996b30e 100644
@@ -647,10 +647,10 @@ static void a2065_remove_one(struct zorro_dev *z);
 
 
 static const struct zorro_device_id a2065_zorro_tbl[] = {
-	{ ZORRO_PROD_CBM_A2065_1 },
-	{ ZORRO_PROD_CBM_A2065_2 },
-	{ ZORRO_PROD_AMERISTAR_A2065 },
-	{ 0 }
+	{ .id = ZORRO_PROD_CBM_A2065_1 },
+	{ .id = ZORRO_PROD_CBM_A2065_2 },
+	{ .id = ZORRO_PROD_AMERISTAR_A2065 },
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, a2065_zorro_tbl);
 
drivers/net/ethernet/amd/ariadne.c +2 -2
index fa201da567ed..ec6e7e8c14fe 100644
@@ -693,8 +693,8 @@ static void ariadne_remove_one(struct zorro_dev *z)
 }
 
 static const struct zorro_device_id ariadne_zorro_tbl[] = {
-	{ ZORRO_PROD_VILLAGE_TRONIC_ARIADNE },
-	{ 0 }
+	{ .id = ZORRO_PROD_VILLAGE_TRONIC_ARIADNE },
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, ariadne_zorro_tbl);
 
Signature · 1 line
2.47.3
Reviewed-by on v1 3/8
#8 lore raw

Re: [PATCH v1 net-next 3/8] net: Use named initializer for zorro_device_id arrays

Quoted 9 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

While touching these arrays, drop explicit zeros from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id arrays.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#9 lore raw

PATCH 4/8 i2c: icy:pick Use named initializer for zorro_device_id arrays

In reply to Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

While touching this array, drop explicit zeros from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id array.

---
 drivers/i2c/busses/i2c-icy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-icy.c +2 -2
index febcb6f01d4d..55496e48ccd1 100644
@@ -193,8 +193,8 @@ static void icy_remove(struct zorro_dev *z)
 }
 
 static const struct zorro_device_id icy_zorro_tbl[] = {
-	{ ZORRO_ID(VMC, 15, 0), },
-	{ 0 }
+	{ .id = ZORRO_ID(VMC, 15, 0) },
+	{ }
 };
 
 MODULE_DEVICE_TABLE(zorro, icy_zorro_tbl);
Signature · 1 line
2.47.3
Reviewed-by on v1 4/8
#10 lore raw

Re: [PATCH v1 4/8] i2c: icy:pick Use named initializer for zorro_device_id arrays

Quoted 9 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

While touching this array, drop explicit zeros from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id array.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Reviewed-by on v1 4/8
#11 lore raw

Re: [PATCH v1 4/8] i2c: icy:pick Use named initializer for zorro_device_id arrays

In reply to Uwe Kleine-König (The Capable Hub)
Quoted 9 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

While touching this array, drop explicit zeros from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id array.

Thanks Uwe!

maintainer
#12 lore raw

Re: [PATCH v1 4/8] i2c: icy:pick Use named initializer for zorro_device_id arrays

In reply to Uwe Kleine-König (The Capable Hub)

Hi Uwe,

Quoted 9 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

While touching this array, drop explicit zeros from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id array.

just this patch merged to i2c/i2c-host.

Thanks,
Andi

#13 lore raw

PATCH 5/8 video: fm2fb: Use named initializer for zorro_device_id array

In reply to Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

While touching this array, drop the explicit zero from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id array.

---
 drivers/video/fbdev/fm2fb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/video/fbdev/fm2fb.c +3 -3
index 25d2e716edf2..a62c8d86bf69 100644
@@ -212,9 +212,9 @@ static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
 static int fm2fb_probe(struct zorro_dev *z, const struct zorro_device_id *id);
 
 static const struct zorro_device_id fm2fb_devices[] = {
-	{ ZORRO_PROD_BSC_FRAMEMASTER_II },
-	{ ZORRO_PROD_HELFRICH_RAINBOW_II },
-	{ 0 }
+	{ .id = ZORRO_PROD_BSC_FRAMEMASTER_II },
+	{ .id = ZORRO_PROD_HELFRICH_RAINBOW_II },
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, fm2fb_devices);
 
Signature · 1 line
2.47.3
Reviewed-by on v1 5/8
#14 lore raw

Re: [PATCH v1 5/8] video: fm2fb: Use named initializer for zorro_device_id array

Quoted 9 lines · Uwe Kleine-König (The Capable Hub)

Using named initializers is more explicit and thus easier to parse for a human.

While touching this array, drop the explicit zero from the list terminator.

This change doesn't introduce changes to the compiled zorro_device_id array.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#15 lore raw

PATCH 6/8 zorro: Simplify storing pointers in device id struct

In reply to Uwe Kleine-König (The Capable Hub)

Technically it is fine (on all current Linux architectures) to store a pointer in an unsigned long variable. However this needs explicit casting which is an easy source for type mismatches.

By replacing the plain unsigned long .driver_data in struct zorro_device_id by an anonymous union, most of the casting can be dropped. There is still some implicit casting involved (between a void * and a driver specific pointer type), but that's better than the approach to store a pointer in an unsigned long variable as this doesn't lose the information that the data being pointed to is const.

All users of struct zorro_device_id are initialized in a way that is compatible with the new definition, so no adaptions are needed there.

---
 include/linux/mod_devicetable.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/mod_devicetable.h +5 -1
index 3b0c9a251a2e..2673a1bd82c4 100644
@@ -640,7 +640,11 @@ struct mdio_device_id {
 
 struct zorro_device_id {
 	__u32 id;			/* Device ID or ZORRO_WILDCARD */
-	kernel_ulong_t driver_data;	/* Data private to the driver */
+	union {
+		/* Data private to the driver */
+		kernel_ulong_t driver_data;
+		const void *driver_data_ptr;
+	};
 };
 
 #define ZORRO_WILDCARD			(0xffffffff)	/* not official */
Signature · 1 line
2.47.3
Reviewed-by Acked-by on v1 6/8
#16 lore raw

Re: [PATCH v1 6/8] zorro: Simplify storing pointers in device id struct

Quoted 11 lines · Uwe Kleine-König (The Capable Hub)

Technically it is fine (on all current Linux architectures) to store a pointer in an unsigned long variable. However this needs explicit casting which is an easy source for type mismatches.

By replacing the plain unsigned long .driver_data in struct zorro_device_id by an anonymous union, most of the casting can be dropped. There is still some implicit casting involved (between a void * and a driver specific pointer type), but that's better than the approach to store a pointer in an unsigned long variable as this doesn't lose the information that the data being pointed to is const.

Quoted 4 lines

All users of struct zorro_device_id are initialized in a way that is compatible with the new definition, so no adaptions are needed there.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Reviewed-by on v1 6/8
#17 lore raw

Re: [PATCH v1 6/8] zorro: Simplify storing pointers in device id struct

In reply to Uwe Kleine-König (The Capable Hub)
Quoted 11 lines · Uwe Kleine-König (The Capable Hub)

Technically it is fine (on all current Linux architectures) to store a pointer in an unsigned long variable. However this needs explicit casting which is an easy source for type mismatches.

By replacing the plain unsigned long .driver_data in struct zorro_device_id by an anonymous union, most of the casting can be dropped. There is still some implicit casting involved (between a void * and a driver specific pointer type), but that's better than the approach to store a pointer in an unsigned long variable as this doesn't lose the information that the data being pointed to is const.

Quoted 4 lines

All users of struct zorro_device_id are initialized in a way that is compatible with the new definition, so no adaptions are needed there.

Thanks Uwe!

#18 lore raw

PATCH 7/8 scsi: zorro7xx: Make use of struct zorro_device_id::driver_data_ptr

In reply to Uwe Kleine-König (The Capable Hub)

Usage of .driver_data_ptr allows to drop several casts. A nice upside of that is that now the constness of the linked structures is kept and the compiler warns about zdd missing a const. So add this missing const, too.

While touching the zorro_device_id array, drop an unneeded explicit zero in the list terminator.

---
 drivers/scsi/zorro7xx.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/scsi/zorro7xx.c +7 -7
index 1f74586f0428..21c769dc1ecb 100644
@@ -50,23 +50,23 @@ static struct zorro_driver_data {
 static struct zorro_device_id zorro7xx_zorro_tbl[] = {
 	{
 		.id = ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS,
-		.driver_data = (unsigned long)&zorro7xx_driver_data[0],
+		.driver_data_ptr = &zorro7xx_driver_data[0],
 	},
 	{
 		.id = ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx,
-		.driver_data = (unsigned long)&zorro7xx_driver_data[1],
+		.driver_data_ptr = &zorro7xx_driver_data[1],
 	},
 	{
 		.id = ZORRO_PROD_CBM_A4091_1,
-		.driver_data = (unsigned long)&zorro7xx_driver_data[2],
+		.driver_data_ptr = &zorro7xx_driver_data[2],
 	},
 	{
 		.id = ZORRO_PROD_CBM_A4091_2,
-		.driver_data = (unsigned long)&zorro7xx_driver_data[2],
+		.driver_data_ptr = &zorro7xx_driver_data[2],
 	},
 	{
 		.id = ZORRO_PROD_GVP_GFORCE_040_060,
-		.driver_data = (unsigned long)&zorro7xx_driver_data[3],
+		.driver_data_ptr = &zorro7xx_driver_data[3],
 	},
 	{ }
 };
@@ -77,11 +77,11 @@ static int zorro7xx_init_one(struct zorro_dev *z,
 {
 	struct Scsi_Host *host;
 	struct NCR_700_Host_Parameters *hostdata;
-	struct zorro_driver_data *zdd;
+	const struct zorro_driver_data *zdd;
 	unsigned long board, ioaddr;
 
 	board = zorro_resource_start(z);
-	zdd = (struct zorro_driver_data *)ent->driver_data;
+	zdd = ent->driver_data_ptr;
 
 	if (zdd->absolute) {
 		ioaddr = zdd->offset;
Signature · 1 line
2.47.3
Reviewed-by on v1 7/8
#19 lore raw

Re: [PATCH v1 7/8] scsi: zorro7xx: Make use of struct zorro_device_id::driver_data_ptr

Quoted 8 lines · Uwe Kleine-König (The Capable Hub)

Usage of .driver_data_ptr allows to drop several casts. A nice upside of that is that now the constness of the linked structures is kept and the compiler warns about zdd missing a const. So add this missing const, too.

While touching the zorro_device_id array, drop an unneeded explicit zero in the list terminator.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#20 lore raw

PATCH 8/8 video: cirrusfb: Make use of struct zorro_device_id::driver_data_ptr

In reply to Uwe Kleine-König (The Capable Hub)

Usage of .driver_data_ptr allows to drop several casts and so make the driver a bit more type safe.

While touching the zorro_device_id array, drop an unneeded explicit zero in the list terminator.

---
 drivers/video/fbdev/cirrusfb.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/video/fbdev/cirrusfb.c +14 -14
index 2693b5cc053f..7e07e775b393 100644
@@ -321,25 +321,25 @@ static const struct zorrocl zcl_picasso4_z2 = {
 
 static const struct zorro_device_id cirrusfb_zorro_table[] = {
 	{
-		.id		= ZORRO_PROD_HELFRICH_SD64_REG,
-		.driver_data	= (unsigned long)&zcl_sd64,
+		.id = ZORRO_PROD_HELFRICH_SD64_REG,
+		.driver_data_ptr = &zcl_sd64,
 	}, {
-		.id		= ZORRO_PROD_HELFRICH_PICCOLO_REG,
-		.driver_data	= (unsigned long)&zcl_piccolo,
+		.id = ZORRO_PROD_HELFRICH_PICCOLO_REG,
+		.driver_data_ptr = &zcl_piccolo,
 	}, {
-		.id	= ZORRO_PROD_VILLAGE_TRONIC_PICASSO_II_II_PLUS_REG,
-		.driver_data	= (unsigned long)&zcl_picasso,
+		.id = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_II_II_PLUS_REG,
+		.driver_data_ptr = &zcl_picasso,
 	}, {
-		.id		= ZORRO_PROD_GVP_EGS_28_24_SPECTRUM_REG,
-		.driver_data	= (unsigned long)&zcl_spectrum,
+		.id = ZORRO_PROD_GVP_EGS_28_24_SPECTRUM_REG,
+		.driver_data_ptr = &zcl_spectrum,
 	}, {
-		.id		= ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z3,
-		.driver_data	= (unsigned long)&zcl_picasso4_z3,
+		.id = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z3,
+		.driver_data_ptr = &zcl_picasso4_z3,
 	}, {
-		.id		= ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z2_REG,
-		.driver_data	= (unsigned long)&zcl_picasso4_z2,
+		.id = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z2_REG,
+		.driver_data_ptr = &zcl_picasso4_z2,
 	},
-	{ 0 }
+	{ }
 };
 MODULE_DEVICE_TABLE(zorro, cirrusfb_zorro_table);
 #endif /* CONFIG_ZORRO */
@@ -2208,7 +2208,7 @@ static int cirrusfb_zorro_register(struct zorro_dev *z,
 	if (!info)
 		return -ENOMEM;
 
-	zcl = (const struct zorrocl *)ent->driver_data;
+	zcl = ent->driver_data_ptr;
 	btype = zcl->type;
 	regbase = zorro_resource_start(z) + zcl->regoffset;
 	ramsize = zcl->ramsize;
Signature · 1 line
2.47.3
Reviewed-by on v1 8/8
#21 lore raw

Re: [PATCH v1 8/8] video: cirrusfb: Make use of struct zorro_device_id::driver_data_ptr

Quoted 7 lines · Uwe Kleine-König (The Capable Hub)

Usage of .driver_data_ptr allows to drop several casts and so make the driver a bit more type safe.

While touching the zorro_device_id array, drop an unneeded explicit zero in the list terminator.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#22 lore raw
In reply to Uwe Kleine-König (The Capable Hub)

Hi Uwe,

Quoted 14 lines · Uwe Kleine-König (The Capable Hub)

this series is about improving the handling of pointers in struct zorro_device_id's driver_data.

While it's ok on all current Linux platforms to store a pointer in an unsigned long variable, it involves casting that loses type information. This can be nicely seen in patch #7 where after profiting from patch #6 the compiler notices a missing const.

Preparing for that change, all zorro_device_ids are converted to use named initializers, which is also a nice cleanup that could stand for itself, as it improves readability for humans. (That is necessary because an anonymous union can be initialized by name, but not using a list initializer.)

Quoted 5 lines

My motivation for this series is the CHERI hardware extension. With that pointers are bigger than longs and thus you cannot store pointers in zorro_device_id::driver_data. So this series is also about getting support for CHERI into the mainline, but I hope the clean up effects mentioned above are justification enough to accept this series.

Thanks for your series!

Quoted 3 lines

The dependencies in this series are as follows:

- Patch #5 depends on #1, #2

s/5/6/?

Quoted 4 lines

- Patches #7 and #8 depend on patch #6.

So if the ata maintainers agreed to merge their patch #1 via scsi, and Geert agrees to patch #5 and that it's also merged via scsi, patches #1,

s/5/6/?

Quoted 8 lines

#2, #6 and #7 can go in without further coordination.

Patches #3, #4 and #5 are only about using the same initialization style for all zorro_device_id and can go in without coordination.

Best regards
Uwe

Quoted 9 lines

Uwe Kleine-König (The Capable Hub) (8):
ata: pata_budda: Use named initializer for zorro_device_id
scsi: Use named initializer for zorro_device_id
net: Use named initializer for zorro_device_id arrays
i2c: icy: Use named initializer for zorro_device_id arrays
video: fm2fb: Use named initializer for zorro_device_id array
zorro: Simplify storing pointers in device id struct
scsi: zorro7xx: Make use of struct zorro_device_id::driver_data_ptr
video: cirrusfb: Make use of struct zorro_device_id::driver_data_ptr

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#23 lore raw
Quoted 30 lines · Geert Uytterhoeven

Hi Uwe,

Quoted 14 lines · Uwe Kleine-König (The Capable Hub)

this series is about improving the handling of pointers in struct zorro_device_id's driver_data.

While it's ok on all current Linux platforms to store a pointer in an unsigned long variable, it involves casting that loses type information. This can be nicely seen in patch #7 where after profiting from patch #6 the compiler notices a missing const.

Preparing for that change, all zorro_device_ids are converted to use named initializers, which is also a nice cleanup that could stand for itself, as it improves readability for humans. (That is necessary because an anonymous union can be initialized by name, but not using a list initializer.)

Quoted 5 lines

My motivation for this series is the CHERI hardware extension. With that pointers are bigger than longs and thus you cannot store pointers in zorro_device_id::driver_data. So this series is also about getting support for CHERI into the mainline, but I hope the clean up effects mentioned above are justification enough to accept this series.

Thanks for your series!

Quoted 3 lines

The dependencies in this series are as follows:

- Patch #5 depends on #1, #2

Quoted 8 lines

s/5/6/?

Quoted 4 lines

- Patches #7 and #8 depend on patch #6.

So if the ata maintainers agreed to merge their patch #1 via scsi, and Geert agrees to patch #5 and that it's also merged via scsi, patches #1,

s/5/6/?

Yes, indeed. And I tried so hard to get all the numbers right :-\

Best regards
Uwe

#24 lore raw
In reply to Uwe Kleine-König (The Capable Hub)
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Tue, 26 May 2026 16:17:26 +0200 you wrote:

Hello,

this series is about improving the handling of pointers in struct zorro_device_id's driver_data.

While it's ok on all current Linux platforms to store a pointer in an unsigned long variable, it involves casting that loses type information. This can be nicely seen in patch #7 where after profiting from patch #6 the compiler notices a missing const.

[...]

Here is the summary with links:
- [v1,net-next,3/8] net: Use named initializer for zorro_device_id arrays

    https://git.kernel.org/netdev/net-next/c/4933a658369a

- [v1,6/8] zorro: Simplify storing pointers in device id struct (no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
maintainer Acked-by on the v1 series
#25 lore raw
In reply to Uwe Kleine-König (The Capable Hub)

Hi Uwe,

Quoted 47 lines · Uwe Kleine-König (The Capable Hub)

Hello,

this series is about improving the handling of pointers in struct zorro_device_id's driver_data.

While it's ok on all current Linux platforms to store a pointer in an unsigned long variable, it involves casting that loses type information. This can be nicely seen in patch #7 where after profiting from patch #6 the compiler notices a missing const.

Preparing for that change, all zorro_device_ids are converted to use named initializers, which is also a nice cleanup that could stand for itself, as it improves readability for humans. (That is necessary because an anonymous union can be initialized by name, but not using a list initializer.)

My motivation for this series is the CHERI hardware extension. With that pointers are bigger than longs and thus you cannot store pointers in zorro_device_id::driver_data. So this series is also about getting support for CHERI into the mainline, but I hope the clean up effects mentioned above are justification enough to accept this series.

The dependencies in this series are as follows:

- Patch #5 depends on #1, #2
- Patches #7 and #8 depend on patch #6.

So if the ata maintainers agreed to merge their patch #1 via scsi, and Geert agrees to patch #5 and that it's also merged via scsi, patches #1, #2, #6 and #7 can go in without further coordination.

Patches #3, #4 and #5 are only about using the same initialization style for all zorro_device_id and can go in without coordination.

Best regards
Uwe

Uwe Kleine-König (The Capable Hub) (8):
ata: pata_budda: Use named initializer for zorro_device_id
scsi: Use named initializer for zorro_device_id
net: Use named initializer for zorro_device_id arrays
i2c: icy: Use named initializer for zorro_device_id arrays
video: fm2fb: Use named initializer for zorro_device_id array
zorro: Simplify storing pointers in device id struct
scsi: zorro7xx: Make use of struct zorro_device_id::driver_data_ptr
video: cirrusfb: Make use of struct zorro_device_id::driver_data_ptr

Quoted 15 lines
  drivers/ata/pata_buddha.c             |  8 ++++----
  drivers/i2c/busses/i2c-icy.c          |  4 ++--
  drivers/net/ethernet/8390/hydra.c     |  4 ++--
  drivers/net/ethernet/8390/xsurf100.c  |  4 ++--
  drivers/net/ethernet/8390/zorro8390.c |  6 +++---
  drivers/net/ethernet/amd/a2065.c      |  8 ++++----
  drivers/net/ethernet/amd/ariadne.c    |  4 ++--
  drivers/scsi/a2091.c                  |  6 +++---
  drivers/scsi/gvp11.c                  | 17 ++++++++--------
  drivers/scsi/zorro7xx.c               | 16 +++++++--------
  drivers/scsi/zorro_esp.c              |  2 +-
  drivers/video/fbdev/cirrusfb.c        | 28 +++++++++++++--------------
  drivers/video/fbdev/fm2fb.c           |  6 +++---
  include/linux/mod_devicetable.h       |  6 +++++-
  14 files changed, 62 insertions(+), 57 deletions(-)

you may add to the series:

Since it touches various subtrees, I assume you will merge it though your tree?

Helge

#26 lore raw

Hello Helge,

Quoted 1 line · Helge Deller

On 5/26/26 16:17, Uwe Kleine-König (The Capable Hub) wrote:

Your MUA seems to interpret my UTF-8 encoded name as latin1 and converted it to UTF-8 making my ö appear as ö. I *think* the problem is on your side.

Quoted 61 lines
Quoted 45 lines

this series is about improving the handling of pointers in struct zorro_device_id's driver_data.

While it's ok on all current Linux platforms to store a pointer in an unsigned long variable, it involves casting that loses type information. This can be nicely seen in patch #7 where after profiting from patch #6 the compiler notices a missing const.

Preparing for that change, all zorro_device_ids are converted to use named initializers, which is also a nice cleanup that could stand for itself, as it improves readability for humans. (That is necessary because an anonymous union can be initialized by name, but not using a list initializer.)

My motivation for this series is the CHERI hardware extension. With that pointers are bigger than longs and thus you cannot store pointers in zorro_device_id::driver_data. So this series is also about getting support for CHERI into the mainline, but I hope the clean up effects mentioned above are justification enough to accept this series.

The dependencies in this series are as follows:

- Patch #5 depends on #1, #2
- Patches #7 and #8 depend on patch #6.

So if the ata maintainers agreed to merge their patch #1 via scsi, and Geert agrees to patch #5 and that it's also merged via scsi, patches #1, #2, #6 and #7 can go in without further coordination.

Patches #3, #4 and #5 are only about using the same initialization style for all zorro_device_id and can go in without coordination.

Best regards
Uwe

Uwe Kleine-König (The Capable Hub) (8):
ata: pata_budda: Use named initializer for zorro_device_id
scsi: Use named initializer for zorro_device_id
net: Use named initializer for zorro_device_id arrays
i2c: icy: Use named initializer for zorro_device_id arrays
video: fm2fb: Use named initializer for zorro_device_id array
zorro: Simplify storing pointers in device id struct
scsi: zorro7xx: Make use of struct zorro_device_id::driver_data_ptr
video: cirrusfb: Make use of struct zorro_device_id::driver_data_ptr

Quoted 15 lines
  drivers/ata/pata_buddha.c             |  8 ++++----
  drivers/i2c/busses/i2c-icy.c          |  4 ++--
  drivers/net/ethernet/8390/hydra.c     |  4 ++--
  drivers/net/ethernet/8390/xsurf100.c  |  4 ++--
  drivers/net/ethernet/8390/zorro8390.c |  6 +++---
  drivers/net/ethernet/amd/a2065.c      |  8 ++++----
  drivers/net/ethernet/amd/ariadne.c    |  4 ++--
  drivers/scsi/a2091.c                  |  6 +++---
  drivers/scsi/gvp11.c                  | 17 ++++++++--------
  drivers/scsi/zorro7xx.c               | 16 +++++++--------
  drivers/scsi/zorro_esp.c              |  2 +-
  drivers/video/fbdev/cirrusfb.c        | 28 +++++++++++++--------------
  drivers/video/fbdev/fm2fb.c           |  6 +++---
  include/linux/mod_devicetable.h       |  6 +++++-
  14 files changed, 62 insertions(+), 57 deletions(-)
Quoted 2 lines

you may add to the series:

Thanks!

Quoted 1 line

Since it touches various subtrees, I assume you will merge it though your tree?

Well, my plan is that the scsi maintainers pick up patches #1, #2, #6 and #7 and I remind you once #6 (i.e. the dependency for #8) is in Linus' tree. But with your ack the two fb patches can also go in via scsi.

To James and Martin: I didn't hear from you about my merge suggestion up to now. The other affected maintainers agreed so far that (assuming you're using b4) and interpreting Helge's ack as agreement that you also pick up the fb patches, you can go for

	b4 am -l -t -3 -P1,2,5-8 [email protected]

If you like I can also pick up these patches (then with your ack please) and send them to Linus for the next merge window. Just tell me about your preference.

Best regards
Uwe