Skip to contentSkip to conversation

drivers/block/xsysace - revert "id" type from "u32" back to "int"

PATCH New Alexey Brodkin 1 participant 1 message Feb 7, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/block/xsysace - revert "id" type from "u32" back to "int"

On addition of new device specified in devicetree device's "id" is set by default to "-1" (it's in "of_device_add").

During probing of xsysace itself driver wants to determine his instance number (used later for example for device naming). It is done simply by reading "dev->id" (which is "-1" by default).

Then driver tries to get "id" from devicetree description reading specific "port-number" property with "of_property_read_u32". And if no property "port-number" was found "id" won't be changed (so if it was "-1" it remains the same).

And later we check it with "if (id < 0) id = 0;" to escape negative values.

But if "id" is "u32" it's always > 0 and later this value "-1" is used for example for generation of device name. And instead of "xsa" it will be "xs'" (ASCII "'" is "a" - 1). Which I believe is not expected.

---
 drivers/block/xsysace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/xsysace.c +1 -1
index 1f38643..32cc0a1 100644
@@ -1154,7 +1154,7 @@ static int ace_probe(struct platform_device *dev)
 {
 	resource_size_t physaddr = 0;
 	int bus_width = ACE_BUS_WIDTH_16; /* FIXME: should not be hard coded */
-	u32 id = dev->id;
+	int id = dev->id;
 	int irq = 0;
 	int i;
 
Signature · 1 line
1.7.10.4