summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-09-01 09:43:54 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-09-01 09:43:54 +0200
commite582374ce333cb46a9f3f3ab3d75288f5caac0b3 (patch)
treee21c0ca3d6bb989f33a01a76222d4a94ab371eb9
parent60fc3e99b52e7ac3282e80ed4124a9a6d1276b23 (diff)
parent1a176434334acddc1232e66057dad54897101f6b (diff)
downloadbarebox-e582374ce333cb46a9f3f3ab3d75288f5caac0b3.tar.gz
barebox-e582374ce333cb46a9f3f3ab3d75288f5caac0b3.tar.xz
Merge branch 'for-next/of_path'
-rw-r--r--Documentation/devicetree/bindings/barebox/barebox,environment.rst5
-rw-r--r--arch/arm/dts/imx27-phytec-phycore-rdk.dts8
-rw-r--r--arch/arm/dts/imx51-babbage.dts4
-rw-r--r--arch/arm/dts/imx53-qsb-common.dtsi4
-rw-r--r--arch/arm/dts/imx6dl-eltec-hipercam.dts4
-rw-r--r--arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi8
-rw-r--r--arch/arm/dts/imx6q-sabresd.dts2
-rw-r--r--arch/arm/dts/imx6q-var-custom.dts2
-rw-r--r--arch/arm/dts/imx6q-var-som.dtsi2
-rw-r--r--arch/arm/dts/imx6qdl-sabresd.dtsi2
-rw-r--r--arch/arm/dts/imx6s-riotboard.dts4
-rw-r--r--drivers/of/of_path.c14
-rw-r--r--drivers/of/partition.c4
-rw-r--r--fs/devfs-core.c13
-rw-r--r--include/driver.h2
15 files changed, 49 insertions, 29 deletions
diff --git a/Documentation/devicetree/bindings/barebox/barebox,environment.rst b/Documentation/devicetree/bindings/barebox/barebox,environment.rst
index d472f66398..d5e52ead04 100644
--- a/Documentation/devicetree/bindings/barebox/barebox,environment.rst
+++ b/Documentation/devicetree/bindings/barebox/barebox,environment.rst
@@ -8,8 +8,9 @@ Required properties:
* ``compatible``: should be ``barebox,environment``
* ``device-path``: path to the environment
-The device-path is a multistring property. The first string should be a
-nodepath to the node containing the physical device of the environment.
+The device-path is a multistring property. The first string should contain
+a nodepath to the node containing the physical device of the environment or
+a nodepath to a partition described by the OF partition binding.
The subsequent strings are of the form <type>:<options> to further describe
the path to the environment. Supported values for <type>:
diff --git a/arch/arm/dts/imx27-phytec-phycore-rdk.dts b/arch/arm/dts/imx27-phytec-phycore-rdk.dts
index 9d216afa3a..f602045c7e 100644
--- a/arch/arm/dts/imx27-phytec-phycore-rdk.dts
+++ b/arch/arm/dts/imx27-phytec-phycore-rdk.dts
@@ -10,13 +10,13 @@
environment-nor {
compatible = "barebox,environment";
- device-path = &nor, "partname:env";
+ device-path = &environment_nor;
status = "disabled";
};
environment-nand {
compatible = "barebox,environment";
- device-path = &nfc, "partname:env";
+ device-path = &environment_nand;
status = "disabled";
};
};
@@ -32,7 +32,7 @@
reg = <0x00000000 0x00080000>;
};
- partition@1 {
+ environment_nand: partition@1 {
label = "env";
reg = <0x00080000 0x00020000>;
};
@@ -54,7 +54,7 @@
reg = <0x00000000 0x00080000>;
};
- partition@1 {
+ environment_nor: partition@1 {
label = "env";
reg = <0x00080000 0x00020000>;
};
diff --git a/arch/arm/dts/imx51-babbage.dts b/arch/arm/dts/imx51-babbage.dts
index 909774bd52..f8402ca8fa 100644
--- a/arch/arm/dts/imx51-babbage.dts
+++ b/arch/arm/dts/imx51-babbage.dts
@@ -18,7 +18,7 @@
environment@0 {
compatible = "barebox,environment";
- device-path = &esdhc1, "partname:barebox-environment";
+ device-path = &environment_esdhc1;
};
};
};
@@ -27,7 +27,7 @@
#address-cells = <1>;
#size-cells = <1>;
- partition@0 {
+ environment_esdhc1: partition@0 {
label = "barebox-environment";
reg = <0x80000 0x20000>;
};
diff --git a/arch/arm/dts/imx53-qsb-common.dtsi b/arch/arm/dts/imx53-qsb-common.dtsi
index 4007a092a8..bf634e49d4 100644
--- a/arch/arm/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/dts/imx53-qsb-common.dtsi
@@ -16,7 +16,7 @@
environment@0 {
compatible = "barebox,environment";
- device-path = &esdhc1, "partname:barebox-environment";
+ device-path = &bareboxenv;
};
};
};
@@ -25,7 +25,7 @@
#address-cells = <1>;
#size-cells = <1>;
- partition@0 {
+ bareboxenv: partition@0 {
label = "barebox-environment";
reg = <0x80000 0x20000>;
};
diff --git a/arch/arm/dts/imx6dl-eltec-hipercam.dts b/arch/arm/dts/imx6dl-eltec-hipercam.dts
index 737752f0b1..166f8f1244 100644
--- a/arch/arm/dts/imx6dl-eltec-hipercam.dts
+++ b/arch/arm/dts/imx6dl-eltec-hipercam.dts
@@ -15,7 +15,7 @@
environment@0 {
compatible = "barebox,environment";
- device-path = &norflash0, "partname:bareboxenv";
+ device-path = &environment_nor0;
};
};
};
@@ -39,7 +39,7 @@
reg = <0x0 0xc0000>;
};
- partition@1 {
+ environment_nor0: partition@1 {
label = "bareboxenv";
reg = <0xc0000 0x8000>;
};
diff --git a/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi b/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi
index 6435ab791d..97cf78a73c 100644
--- a/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi
+++ b/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi
@@ -19,13 +19,13 @@
chosen {
environment-sd {
compatible = "barebox,environment";
- device-path = &usdhc3, "partname:barebox-environment";
+ device-path = &environment_usdhc3;
status = "disabled";
};
environment-nand {
compatible = "barebox,environment";
- device-path = &gpmi, "partname:barebox-environment";
+ device-path = &environment_nand;
status = "disabled";
};
};
@@ -139,7 +139,7 @@
reg = <0x0 0x400000>;
};
- partition@1 {
+ environment_nand: partition@1 {
label = "barebox-environment";
reg = <0x400000 0x20000>;
};
@@ -183,7 +183,7 @@
label = "barebox";
reg = <0x0 0x80000>;
};
- partition@1 {
+ environment_usdhc3: partition@1 {
label = "barebox-environment";
reg = <0x80000 0x80000>;
};
diff --git a/arch/arm/dts/imx6q-sabresd.dts b/arch/arm/dts/imx6q-sabresd.dts
index 71ca855251..1f92c15242 100644
--- a/arch/arm/dts/imx6q-sabresd.dts
+++ b/arch/arm/dts/imx6q-sabresd.dts
@@ -25,7 +25,7 @@
environment@0 {
compatible = "barebox,environment";
- device-path = &usdhc3, "partname:barebox-environment";
+ device-path = &environment_usdhc3;
};
};
};
diff --git a/arch/arm/dts/imx6q-var-custom.dts b/arch/arm/dts/imx6q-var-custom.dts
index 795114d841..ef6981e3bc 100644
--- a/arch/arm/dts/imx6q-var-custom.dts
+++ b/arch/arm/dts/imx6q-var-custom.dts
@@ -30,7 +30,7 @@
environment@0 {
compatible = "barebox,environment";
- device-path = &gpmi, "partname:barebox-environment";
+ device-path = &environment_nand;
};
};
diff --git a/arch/arm/dts/imx6q-var-som.dtsi b/arch/arm/dts/imx6q-var-som.dtsi
index 792691191e..d005f319d6 100644
--- a/arch/arm/dts/imx6q-var-som.dtsi
+++ b/arch/arm/dts/imx6q-var-som.dtsi
@@ -42,7 +42,7 @@
reg = <0x0 0x200000>;
};
- partition@1 {
+ environment_nand: partition@1 {
label = "barebox-environment";
reg = <0x200000 0x20000>;
};
diff --git a/arch/arm/dts/imx6qdl-sabresd.dtsi b/arch/arm/dts/imx6qdl-sabresd.dtsi
index 54201bdb7e..32318cf389 100644
--- a/arch/arm/dts/imx6qdl-sabresd.dtsi
+++ b/arch/arm/dts/imx6qdl-sabresd.dtsi
@@ -34,7 +34,7 @@
reg = <0x0 0x80000>;
};
- partition@1 {
+ environment_usdhc3: partition@1 {
label = "barebox-environment";
reg = <0x80000 0x80000>;
};
diff --git a/arch/arm/dts/imx6s-riotboard.dts b/arch/arm/dts/imx6s-riotboard.dts
index 117c00a575..a522dd9934 100644
--- a/arch/arm/dts/imx6s-riotboard.dts
+++ b/arch/arm/dts/imx6s-riotboard.dts
@@ -17,7 +17,7 @@
environment@0 {
compatible = "barebox,environment";
- device-path = &usdhc4, "partname:barebox-environment";
+ device-path = &environment_usdhc4;
};
};
@@ -232,7 +232,7 @@
reg = <0x0 0x80000>;
};
- partition@1 {
+ environment_usdhc4: partition@1 {
label = "barebox-environment";
reg = <0x80000 0x80000>;
};
diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
index 2dc784851d..992972c9b5 100644
--- a/drivers/of/of_path.c
+++ b/drivers/of/of_path.c
@@ -117,7 +117,8 @@ out:
* @flags: use OF_FIND_PATH_FLAGS_BB to return the .bb device if available
*
* paths in the devicetree have the form of a multistring property. The first
- * string contains the full path to the physical device containing the path.
+ * string contains the full path to the physical device containing the path or
+ * a full path to a partition described by the OF partition binding.
* The remaining strings have the form "<type>:<options>". Currently supported
* for <type> are:
*
@@ -129,6 +130,7 @@ out:
*
* device-path = &mmc0, "partname:0";
* device-path = &norflash, "partname:barebox-environment";
+ * device-path = &environment_nor;
*/
int of_find_path(struct device_node *node, const char *propname, char **outpath, unsigned flags)
{
@@ -147,13 +149,15 @@ int of_find_path(struct device_node *node, const char *propname, char **outpath,
return -ENODEV;
op.dev = of_find_device_by_node_path(rnode->full_name);
- if (!op.dev)
- return -ENODEV;
+ if (!op.dev) {
+ op.dev = of_find_device_by_node_path(rnode->parent->full_name);
+ if (!op.dev)
+ return -ENODEV;
+ }
device_detect(op.dev);
- if (list_is_singular(&op.dev->cdevs))
- op.cdev = list_first_entry(&op.dev->cdevs, struct cdev, devices_list);
+ op.cdev = cdev_by_device_node(rnode);
i = 1;
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index 3dce84404f..6017897b02 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -64,8 +64,8 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
if (IS_ERR(new))
new = NULL;
- if (new && new->dev)
- new->dev->device_node = node;
+ if (new)
+ new->device_node = node;;
free(filename);
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index f45f8cadf1..62571fb8a3 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -57,6 +57,19 @@ struct cdev *cdev_by_name(const char *filename)
return NULL;
}
+struct cdev *cdev_by_device_node(struct device_node *node)
+{
+ struct cdev *cdev;
+
+ list_for_each_entry(cdev, &cdev_list, list) {
+ if (!cdev->device_node)
+ continue;
+ if (cdev->device_node == node)
+ return cdev;
+ }
+ return NULL;
+}
+
/**
* device_find_partition - find a partition belonging to a physical device
*
diff --git a/include/driver.h b/include/driver.h
index 728f8abb49..046dd9079d 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -436,6 +436,7 @@ struct cdev {
struct file_operations *ops;
void *priv;
struct device_d *dev;
+ struct device_node *device_node;
struct list_head list;
struct list_head devices_list;
char *name; /* filename under /dev/ */
@@ -456,6 +457,7 @@ int devfs_remove(struct cdev *);
int cdev_find_free_index(const char *);
struct cdev *device_find_partition(struct device_d *dev, const char *name);
struct cdev *cdev_by_name(const char *filename);
+struct cdev *cdev_by_device_node(struct device_node *node);
struct cdev *cdev_open(const char *name, unsigned long flags);
int cdev_do_open(struct cdev *, unsigned long flags);
void cdev_close(struct cdev *cdev);