Skip to contentSkip to conversation

block: Fix id of xsysace with missing port-number

PATCH RESEND In review Gernot Vormayr 2 participants 2 messages May 2, 2013 – May 7, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 block: Fix id of xsysace with missing port-number

If the port number is missing from the device-tree the device gets named xs` instead of xsa. This fixes the check for missing ids.

Tested on ml507 board.

---
 drivers/block/xsysace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/xsysace.c +1 -2
index 1f38643..6b5807a 100644
@@ -1161,8 +1161,7 @@ static int ace_probe(struct platform_device *dev)
 	dev_dbg(&dev->dev, "ace_probe(%p)\n", dev);
 
 	/* device id and bus width */
-	of_property_read_u32(dev->dev.of_node, "port-number", &id);
-	if (id < 0)
+	if (of_property_read_u32(dev->dev.of_node, "port-number", &id))
 		id = 0;
 	if (of_find_property(dev->dev.of_node, "8-bit", NULL))
 		bus_width = ACE_BUS_WIDTH_8;
Signature · 1 line
1.8.2.2
#1 lore raw
Quoted 15 lines · On Thu, 2 May 2013 22:27:45 +0200 Gernot Vormayr <[email protected]> wrote:

If the port number is missing from the device-tree the device gets named xs` instead of xsa. This fixes the check for missing ids.

Tested on ml507 board.

---
 drivers/block/xsysace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/xsysace.c +0 -0
index 1f38643..6b5807a 100644

drivers/block/xsysace.c static int ace_probe(struct platform_device *dev) · line 1167

Quoted 9 lines
drivers/block/xsysace.c +1 -2
@@ -1161,8 +1161,7 @@ static int ace_probe(struct platform_device *dev)
 	dev_dbg(&dev->dev, "ace_probe(%p)\n", dev);
 
 	/* device id and bus width */
-	of_property_read_u32(dev->dev.of_node, "port-number", &id);
-	if (id < 0)
+	if (of_property_read_u32(dev->dev.of_node, "port-number", &id))
 		id = 0;
 	if (of_find_property(dev->dev.of_node, "8-bit", NULL))
 		bus_width = ACE_BUS_WIDTH_8;

err, yes. If of_property_read_u32() fails to locate the property, id' remains unaltered. That code appears to believe that of_property_read_u32() puts its errno into id'.

AFAICT, it is always a bug to fail to check the of_property_read() return value (unless the caller somehow *knows* the property exists?). Perhaps these functions should be marked __must_check to locate and prevent such bugs.