Skip to contentSkip to conversation

cdev: When creating a new cdev, initialize device_node

PATCH Applied Trent Piepho 2 participants 2 messages Dec 11, 2015 – Dec 14, 2015

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

PATCH 1/1 cdev: When creating a new cdev, initialize device_node

If a new cdev doesn't have a device_node defined when passed to devfs_create(), set it to the device_node of the parent device, if one exists.

For non-partitions, like ocotp or eeprom devices, this is the correct thing to do. Partitions need to use, and do use, a different node.

The code from commit 274e0b8dc48956babeaa2faf70bf8066e656b621 to set device_node in ocotp can be removed.

---
Tested this to work for loading the env from an at24 eeprom. Should work for any other non-partitioned device too.

 arch/arm/mach-imx/ocotp.c | 1 -
 fs/devfs-core.c           | 5 ++++-
 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/mach-imx/ocotp.c +0 -1
index 6ff5ee4..c99a003 100644
@@ -426,7 +426,6 @@ static int imx_ocotp_probe(struct device_d *dev)
 	cdev->priv	= priv;
 	cdev->size	= 192;
 	cdev->name	= "imx-ocotp";
-	cdev->device_node = dev->device_node;
 
 	ret = devfs_create(cdev);
 
fs/devfs-core.c +4 -1
index 2541ea3..a5ac5a3 100644
@@ -260,8 +260,11 @@ int devfs_create(struct cdev *new)
 		return -EEXIST;
 
 	list_add_tail(&new->list, &cdev_list);
-	if (new->dev)
+	if (new->dev) {
 		list_add_tail(&new->devices_list, &new->dev->cdevs);
+		if (!new->device_node)
+			new->device_node = new->dev->device_node;
+	}
 
 	return 0;
 }
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer Applied
#1 lore raw
Quoted 7 lines · Trent Piepho

If a new cdev doesn't have a device_node defined when passed to devfs_create(), set it to the device_node of the parent device, if one exists.

For non-partitions, like ocotp or eeprom devices, this is the correct thing to do. Partitions need to use, and do use, a different node.

Quoted 7 lines

The code from commit 274e0b8dc48956babeaa2faf70bf8066e656b621 to set device_node in ocotp can be removed.

---
Tested this to work for loading the env from an at24 eeprom. Should work for any other non-partitioned device too.

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox