* [PATCH 2/8] cdev: add diskuuid support
2022-02-07 9:49 [PATCH 1/8] cdev: rename partuuid to uuid Sascha Hauer
@ 2022-02-07 9:49 ` Sascha Hauer
2022-02-07 9:49 ` [PATCH 3/8] rename cdev_open() -> cdev_open_name() Sascha Hauer
` (5 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2022-02-07 9:49 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Olbrich, Michael Olbrich
From: Michael Olbrich <m.olbrich@pengutronix.de>
This allows identifying disks by UUID. For disks with GPT the disk GUID is
used. For DOS partition tables the NT signature ist used, similar to how
the partuuid is generated.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Link: https://lore.barebox.org/20220124100458.2924679-3-m.olbrich@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/partitions/dos.c | 3 +++
common/partitions/efi.c | 2 ++
fs/devfs-core.c | 14 ++++++++++++++
include/driver.h | 1 +
4 files changed, 20 insertions(+)
diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 597d7bf9bc..566c8dd949 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -182,6 +182,9 @@ static void dos_partition(void *buf, struct block_device *blk,
struct disk_signature_priv *dsp;
uint32_t signature = get_unaligned_le32(buf + 0x1b8);
+ if (signature)
+ sprintf(blk->cdev.uuid, "%08x", signature);
+
table = (struct partition_entry *)&buffer[446];
for (i = 0; i < 4; i++) {
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 6d811bfb3b..0787b93f12 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -445,6 +445,8 @@ static void efi_partition(void *buf, struct block_device *blk,
return;
}
+ snprintf(blk->cdev.uuid, sizeof(blk->cdev.uuid), "%pUl", &gpt->disk_guid);
+
nb_part = le32_to_cpu(gpt->num_partition_entries);
if (nb_part > MAX_PARTITION) {
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 82e4811b38..2475ab959a 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -107,6 +107,20 @@ struct cdev *cdev_by_partuuid(const char *partuuid)
return NULL;
}
+struct cdev *cdev_by_diskuuid(const char *diskuuid)
+{
+ struct cdev *cdev;
+
+ if (!diskuuid)
+ return NULL;
+
+ list_for_each_entry(cdev, &cdev_list, list) {
+ if (!cdev->master && !strcasecmp(cdev->uuid, diskuuid))
+ 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 62a1782847..3ef8bfb8a3 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -488,6 +488,7 @@ struct cdev *lcdev_by_name(const char *filename);
struct cdev *cdev_readlink(struct cdev *cdev);
struct cdev *cdev_by_device_node(struct device_node *node);
struct cdev *cdev_by_partuuid(const char *partuuid);
+struct cdev *cdev_by_diskuuid(const char *partuuid);
struct cdev *cdev_open(const char *name, unsigned long flags);
struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset);
void cdev_remove_loop(struct cdev *cdev);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/8] rename cdev_open() -> cdev_open_name()
2022-02-07 9:49 [PATCH 1/8] cdev: rename partuuid to uuid Sascha Hauer
2022-02-07 9:49 ` [PATCH 2/8] cdev: add diskuuid support Sascha Hauer
@ 2022-02-07 9:49 ` Sascha Hauer
2022-02-07 10:43 ` Ahmad Fatoum
2022-02-07 9:49 ` [PATCH 4/8] cdev: implement cdev_open() Sascha Hauer
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Sascha Hauer @ 2022-02-07 9:49 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Olbrich
The cdev_* functions normally take a struct cdev * argument, with the
exception of cdev_open(). Rename cdev_open() to cdev_open_name() to
be able to implement cdev_open() with the expected semantics in the next
step.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-mxs/ocotp.c | 2 +-
arch/arm/mach-omap/xload.c | 4 ++--
common/filetype.c | 2 +-
fs/devfs-core.c | 2 +-
fs/fs.c | 4 ++--
include/driver.h | 2 +-
lib/bootstrap/devfs.c | 4 ++--
7 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c
index 5f78d9d773..466f8886cd 100644
--- a/arch/arm/mach-mxs/ocotp.c
+++ b/arch/arm/mach-mxs/ocotp.c
@@ -229,7 +229,7 @@ int mxs_ocotp_read(void *buf, int count, int offset)
struct cdev *cdev;
int ret;
- cdev = cdev_open(DRIVERNAME, O_RDONLY);
+ cdev = cdev_open_name(DRIVERNAME, O_RDONLY);
if (!cdev)
return -ENODEV;
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 0fe78883d1..edb094f36f 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -38,7 +38,7 @@ static void *read_image_head(const char *name)
struct cdev *cdev;
int ret;
- cdev = cdev_open(name, O_RDONLY);
+ cdev = cdev_open_name(name, O_RDONLY);
if (!cdev) {
printf("failed to open %s\n", name);
return NULL;
@@ -86,7 +86,7 @@ static void *read_mtd_barebox(const char *partition)
to = xmalloc(size);
- cdev = cdev_open(partition, O_RDONLY);
+ cdev = cdev_open_name(partition, O_RDONLY);
if (!cdev) {
printf("failed to open partition\n");
return NULL;
diff --git a/common/filetype.c b/common/filetype.c
index 8ffcd6adcd..a955d88bc3 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -438,7 +438,7 @@ enum filetype cdev_detect_type(const char *name)
struct cdev *cdev;
void *buf;
- cdev = cdev_open(name, O_RDONLY);
+ cdev = cdev_open_name(name, O_RDONLY);
if (!cdev)
return type;
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 2475ab959a..6350c3fa8b 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -169,7 +169,7 @@ int cdev_find_free_index(const char *basename)
return -EBUSY; /* all indexes are used */
}
-struct cdev *cdev_open(const char *name, unsigned long flags)
+struct cdev *cdev_open_name(const char *name, unsigned long flags)
{
struct cdev *cdev;
int ret;
diff --git a/fs/fs.c b/fs/fs.c
index 968e77b808..20362c3889 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -800,7 +800,7 @@ int fsdev_open_cdev(struct fs_device_d *fsdev)
fsdev->cdev = cdev_create_loop(fsdev->backingstore, O_RDWR, offset);
} else {
- fsdev->cdev = cdev_open(fsdev->backingstore, O_RDWR);
+ fsdev->cdev = cdev_open_name(fsdev->backingstore, O_RDWR);
}
if (!fsdev->cdev) {
path_put(&path);
@@ -3048,7 +3048,7 @@ int umount(const char *pathname)
path_put(&path);
if (!fsdev) {
- struct cdev *cdev = cdev_open(pathname, O_RDWR);
+ struct cdev *cdev = cdev_open_name(pathname, O_RDWR);
if (cdev) {
cdev_close(cdev);
diff --git a/include/driver.h b/include/driver.h
index 3ef8bfb8a3..b4fae477a6 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -489,7 +489,7 @@ struct cdev *cdev_readlink(struct cdev *cdev);
struct cdev *cdev_by_device_node(struct device_node *node);
struct cdev *cdev_by_partuuid(const char *partuuid);
struct cdev *cdev_by_diskuuid(const char *partuuid);
-struct cdev *cdev_open(const char *name, unsigned long flags);
+struct cdev *cdev_open_name(const char *name, unsigned long flags);
struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset);
void cdev_remove_loop(struct cdev *cdev);
int cdev_do_open(struct cdev *, unsigned long flags);
diff --git a/lib/bootstrap/devfs.c b/lib/bootstrap/devfs.c
index 6d28b1cb4d..e26a3d831d 100644
--- a/lib/bootstrap/devfs.c
+++ b/lib/bootstrap/devfs.c
@@ -32,7 +32,7 @@ static void *read_image_head(const char *name)
struct cdev *cdev;
int ret;
- cdev = cdev_open(name, O_RDONLY);
+ cdev = cdev_open_name(name, O_RDONLY);
if (!cdev) {
bootstrap_err("failed to open partition\n");
goto free_header;
@@ -124,7 +124,7 @@ void* bootstrap_read_devfs(char *devname, bool use_bb, int offset,
to = xmalloc(size);
- cdev = cdev_open(partname, O_RDONLY);
+ cdev = cdev_open_name(partname, O_RDONLY);
if (!cdev) {
bootstrap_err("%s: failed to open %s\n", devname, partname);
goto free_memory;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/8] rename cdev_open() -> cdev_open_name()
2022-02-07 9:49 ` [PATCH 3/8] rename cdev_open() -> cdev_open_name() Sascha Hauer
@ 2022-02-07 10:43 ` Ahmad Fatoum
0 siblings, 0 replies; 14+ messages in thread
From: Ahmad Fatoum @ 2022-02-07 10:43 UTC (permalink / raw)
To: Sascha Hauer, Barebox List; +Cc: Michael Olbrich
On 07.02.22 10:49, Sascha Hauer wrote:
> The cdev_* functions normally take a struct cdev * argument, with the
> exception of cdev_open(). Rename cdev_open() to cdev_open_name() to
> be able to implement cdev_open() with the expected semantics in the next
> step.
Nitpick: cdev_open_by_name would align it more with the naming style
elsewhere in barebox.
Otherwise,
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> arch/arm/mach-mxs/ocotp.c | 2 +-
> arch/arm/mach-omap/xload.c | 4 ++--
> common/filetype.c | 2 +-
> fs/devfs-core.c | 2 +-
> fs/fs.c | 4 ++--
> include/driver.h | 2 +-
> lib/bootstrap/devfs.c | 4 ++--
> 7 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c
> index 5f78d9d773..466f8886cd 100644
> --- a/arch/arm/mach-mxs/ocotp.c
> +++ b/arch/arm/mach-mxs/ocotp.c
> @@ -229,7 +229,7 @@ int mxs_ocotp_read(void *buf, int count, int offset)
> struct cdev *cdev;
> int ret;
>
> - cdev = cdev_open(DRIVERNAME, O_RDONLY);
> + cdev = cdev_open_name(DRIVERNAME, O_RDONLY);
> if (!cdev)
> return -ENODEV;
>
> diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
> index 0fe78883d1..edb094f36f 100644
> --- a/arch/arm/mach-omap/xload.c
> +++ b/arch/arm/mach-omap/xload.c
> @@ -38,7 +38,7 @@ static void *read_image_head(const char *name)
> struct cdev *cdev;
> int ret;
>
> - cdev = cdev_open(name, O_RDONLY);
> + cdev = cdev_open_name(name, O_RDONLY);
> if (!cdev) {
> printf("failed to open %s\n", name);
> return NULL;
> @@ -86,7 +86,7 @@ static void *read_mtd_barebox(const char *partition)
>
> to = xmalloc(size);
>
> - cdev = cdev_open(partition, O_RDONLY);
> + cdev = cdev_open_name(partition, O_RDONLY);
> if (!cdev) {
> printf("failed to open partition\n");
> return NULL;
> diff --git a/common/filetype.c b/common/filetype.c
> index 8ffcd6adcd..a955d88bc3 100644
> --- a/common/filetype.c
> +++ b/common/filetype.c
> @@ -438,7 +438,7 @@ enum filetype cdev_detect_type(const char *name)
> struct cdev *cdev;
> void *buf;
>
> - cdev = cdev_open(name, O_RDONLY);
> + cdev = cdev_open_name(name, O_RDONLY);
> if (!cdev)
> return type;
>
> diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> index 2475ab959a..6350c3fa8b 100644
> --- a/fs/devfs-core.c
> +++ b/fs/devfs-core.c
> @@ -169,7 +169,7 @@ int cdev_find_free_index(const char *basename)
> return -EBUSY; /* all indexes are used */
> }
>
> -struct cdev *cdev_open(const char *name, unsigned long flags)
> +struct cdev *cdev_open_name(const char *name, unsigned long flags)
> {
> struct cdev *cdev;
> int ret;
> diff --git a/fs/fs.c b/fs/fs.c
> index 968e77b808..20362c3889 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -800,7 +800,7 @@ int fsdev_open_cdev(struct fs_device_d *fsdev)
>
> fsdev->cdev = cdev_create_loop(fsdev->backingstore, O_RDWR, offset);
> } else {
> - fsdev->cdev = cdev_open(fsdev->backingstore, O_RDWR);
> + fsdev->cdev = cdev_open_name(fsdev->backingstore, O_RDWR);
> }
> if (!fsdev->cdev) {
> path_put(&path);
> @@ -3048,7 +3048,7 @@ int umount(const char *pathname)
> path_put(&path);
>
> if (!fsdev) {
> - struct cdev *cdev = cdev_open(pathname, O_RDWR);
> + struct cdev *cdev = cdev_open_name(pathname, O_RDWR);
>
> if (cdev) {
> cdev_close(cdev);
> diff --git a/include/driver.h b/include/driver.h
> index 3ef8bfb8a3..b4fae477a6 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -489,7 +489,7 @@ struct cdev *cdev_readlink(struct cdev *cdev);
> struct cdev *cdev_by_device_node(struct device_node *node);
> struct cdev *cdev_by_partuuid(const char *partuuid);
> struct cdev *cdev_by_diskuuid(const char *partuuid);
> -struct cdev *cdev_open(const char *name, unsigned long flags);
> +struct cdev *cdev_open_name(const char *name, unsigned long flags);
> struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset);
> void cdev_remove_loop(struct cdev *cdev);
> int cdev_do_open(struct cdev *, unsigned long flags);
> diff --git a/lib/bootstrap/devfs.c b/lib/bootstrap/devfs.c
> index 6d28b1cb4d..e26a3d831d 100644
> --- a/lib/bootstrap/devfs.c
> +++ b/lib/bootstrap/devfs.c
> @@ -32,7 +32,7 @@ static void *read_image_head(const char *name)
> struct cdev *cdev;
> int ret;
>
> - cdev = cdev_open(name, O_RDONLY);
> + cdev = cdev_open_name(name, O_RDONLY);
> if (!cdev) {
> bootstrap_err("failed to open partition\n");
> goto free_header;
> @@ -124,7 +124,7 @@ void* bootstrap_read_devfs(char *devname, bool use_bb, int offset,
>
> to = xmalloc(size);
>
> - cdev = cdev_open(partname, O_RDONLY);
> + cdev = cdev_open_name(partname, O_RDONLY);
> if (!cdev) {
> bootstrap_err("%s: failed to open %s\n", devname, partname);
> goto free_memory;
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/8] cdev: implement cdev_open()
2022-02-07 9:49 [PATCH 1/8] cdev: rename partuuid to uuid Sascha Hauer
2022-02-07 9:49 ` [PATCH 2/8] cdev: add diskuuid support Sascha Hauer
2022-02-07 9:49 ` [PATCH 3/8] rename cdev_open() -> cdev_open_name() Sascha Hauer
@ 2022-02-07 9:49 ` Sascha Hauer
2022-02-07 10:46 ` Ahmad Fatoum
2022-02-07 9:49 ` [PATCH 5/8] driver: Add functions to free devices Sascha Hauer
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Sascha Hauer @ 2022-02-07 9:49 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Olbrich
Implement cdev_open() with the expected semantics that takes a struct
cdev * argument. We already have an unimplemented prototype
cdev_do_open(), remove this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/devfs-core.c | 16 +++++++++++-----
include/driver.h | 2 +-
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 6350c3fa8b..dd6a9585bc 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -169,6 +169,14 @@ int cdev_find_free_index(const char *basename)
return -EBUSY; /* all indexes are used */
}
+int cdev_open(struct cdev *cdev, unsigned long flags)
+{
+ if (cdev->ops->open)
+ return cdev->ops->open(cdev, flags);
+
+ return 0;
+}
+
struct cdev *cdev_open_name(const char *name, unsigned long flags)
{
struct cdev *cdev;
@@ -178,11 +186,9 @@ struct cdev *cdev_open_name(const char *name, unsigned long flags)
if (!cdev)
return NULL;
- if (cdev->ops->open) {
- ret = cdev->ops->open(cdev, flags);
- if (ret)
- return NULL;
- }
+ ret = cdev_open(cdev, flags);
+ if (ret)
+ return NULL;
return cdev;
}
diff --git a/include/driver.h b/include/driver.h
index b4fae477a6..4f97b943c8 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -492,7 +492,7 @@ struct cdev *cdev_by_diskuuid(const char *partuuid);
struct cdev *cdev_open_name(const char *name, unsigned long flags);
struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset);
void cdev_remove_loop(struct cdev *cdev);
-int cdev_do_open(struct cdev *, unsigned long flags);
+int cdev_open(struct cdev *, unsigned long flags);
void cdev_close(struct cdev *cdev);
int cdev_flush(struct cdev *cdev);
ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/8] cdev: implement cdev_open()
2022-02-07 9:49 ` [PATCH 4/8] cdev: implement cdev_open() Sascha Hauer
@ 2022-02-07 10:46 ` Ahmad Fatoum
0 siblings, 0 replies; 14+ messages in thread
From: Ahmad Fatoum @ 2022-02-07 10:46 UTC (permalink / raw)
To: Sascha Hauer, Barebox List; +Cc: Michael Olbrich
On 07.02.22 10:49, Sascha Hauer wrote:
> Implement cdev_open() with the expected semantics that takes a struct
> cdev * argument. We already have an unimplemented prototype
> cdev_do_open(), remove this.
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> fs/devfs-core.c | 16 +++++++++++-----
> include/driver.h | 2 +-
> 2 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> index 6350c3fa8b..dd6a9585bc 100644
> --- a/fs/devfs-core.c
> +++ b/fs/devfs-core.c
> @@ -169,6 +169,14 @@ int cdev_find_free_index(const char *basename)
> return -EBUSY; /* all indexes are used */
> }
>
> +int cdev_open(struct cdev *cdev, unsigned long flags)
> +{
> + if (cdev->ops->open)
> + return cdev->ops->open(cdev, flags);
> +
> + return 0;
> +}
> +
> struct cdev *cdev_open_name(const char *name, unsigned long flags)
> {
> struct cdev *cdev;
> @@ -178,11 +186,9 @@ struct cdev *cdev_open_name(const char *name, unsigned long flags)
> if (!cdev)
> return NULL;
>
> - if (cdev->ops->open) {
> - ret = cdev->ops->open(cdev, flags);
> - if (ret)
> - return NULL;
> - }
> + ret = cdev_open(cdev, flags);
> + if (ret)
> + return NULL;
>
> return cdev;
> }
> diff --git a/include/driver.h b/include/driver.h
> index b4fae477a6..4f97b943c8 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -492,7 +492,7 @@ struct cdev *cdev_by_diskuuid(const char *partuuid);
> struct cdev *cdev_open_name(const char *name, unsigned long flags);
> struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset);
> void cdev_remove_loop(struct cdev *cdev);
> -int cdev_do_open(struct cdev *, unsigned long flags);
> +int cdev_open(struct cdev *, unsigned long flags);
> void cdev_close(struct cdev *cdev);
> int cdev_flush(struct cdev *cdev);
> ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags);
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 5/8] driver: Add functions to free devices
2022-02-07 9:49 [PATCH 1/8] cdev: rename partuuid to uuid Sascha Hauer
` (2 preceding siblings ...)
2022-02-07 9:49 ` [PATCH 4/8] cdev: implement cdev_open() Sascha Hauer
@ 2022-02-07 9:49 ` Sascha Hauer
2022-02-07 9:49 ` [PATCH 6/8] cdev: Create missing cdev_* functions Sascha Hauer
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2022-02-07 9:49 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Olbrich
struct device_d has some dynamically allocated members, namely .name and
.unique_name. These are normally not freed when a device is freed. Add
two functions to free these resources. free_device_res() only frees the
allocated members, but not the device itself. This is suitable for cases
where the device is embedded in another struct. free_device() frees the
allocated members along with the device itself. This can be called when
the device itself has been directly allocated.
Some users which should use these functions are also fixed in this
patch.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/base/driver.c | 30 ++++++++++++++++++++++++++++++
drivers/of/base.c | 2 +-
drivers/of/platform.c | 3 ++-
drivers/usb/core/usb.c | 1 +
include/driver.h | 4 ++++
5 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index f54f4d0b37..2347b5c71f 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -270,6 +270,36 @@ int unregister_device(struct device_d *old_dev)
}
EXPORT_SYMBOL(unregister_device);
+/**
+ * free_device_res - free dynamically allocated device members
+ * @dev: The device
+ *
+ * This frees dynamically allocated resources allocated during device
+ * lifetime, but not the device itself.
+ */
+void free_device_res(struct device_d *dev)
+{
+ free(dev->name);
+ dev->name = NULL;
+ free(dev->unique_name);
+ dev->unique_name = NULL;
+}
+EXPORT_SYMBOL(free_device_res);
+
+/**
+ * free_device - free a device
+ * @dev: The device
+ *
+ * This frees dynamically allocated resources allocated during device
+ * lifetime and finally the device itself.
+ */
+void free_device(struct device_d *dev)
+{
+ free_device_res(dev);
+ free(dev);
+}
+EXPORT_SYMBOL(free_device);
+
/*
* Loop over list of deferred devices as long as at least one
* device is successfully probed. Devices that again request
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 80465d6d50..2591610c3f 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2383,7 +2383,7 @@ static void of_platform_device_create_root(struct device_node *np)
ret = platform_device_register(dev);
if (ret)
- free(dev);
+ free_device(dev);
}
static const struct of_device_id reserved_mem_matches[] = {
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 3a82809cb3..0e718469db 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -155,7 +155,7 @@ struct device_d *of_platform_device_create(struct device_node *np,
np->dev = NULL;
- free(dev);
+ free_device(dev);
if (num_reg)
free(res);
return NULL;
@@ -278,6 +278,7 @@ static struct device_d *of_amba_device_create(struct device_node *np)
return &dev->dev;
amba_err_free:
+ free_device_res(&dev->dev);
free(dev);
return NULL;
}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4eede13a11..34a0f004f7 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -534,6 +534,7 @@ void usb_free_device(struct usb_device *usbdev)
{
dma_free(usbdev->descriptor);
dma_free(usbdev->setup_packet);
+ free_device_res(&usbdev->dev);
free(usbdev);
}
diff --git a/include/driver.h b/include/driver.h
index 4f97b943c8..93de4f676e 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -141,6 +141,10 @@ void device_detect_all(void);
*/
int unregister_device(struct device_d *);
+void free_device_res(struct device_d *dev);
+void free_device(struct device_d *dev);
+
+
/* Iterate over a devices children
*/
#define device_for_each_child(dev, child) \
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 6/8] cdev: Create missing cdev_* functions
2022-02-07 9:49 [PATCH 1/8] cdev: rename partuuid to uuid Sascha Hauer
` (3 preceding siblings ...)
2022-02-07 9:49 ` [PATCH 5/8] driver: Add functions to free devices Sascha Hauer
@ 2022-02-07 9:49 ` Sascha Hauer
2022-02-07 9:49 ` [PATCH 7/8] cdev: create iterator for cdev list Sascha Hauer
2022-02-07 9:49 ` [PATCH 8/8] misc: Add storage-by-uuid driver Sascha Hauer
6 siblings, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2022-02-07 9:49 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Olbrich
We have several functions like cdev_read(), cdev_write() and others. For
consistency create the remaining functions: cdev_lseek(),
cdev_protect(), cdev_discard_range(), cdev_memmap() and cdev_truncate()
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/devfs-core.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
fs/devfs.c | 46 +++++-------------------------------
include/driver.h | 5 ++++
3 files changed, 72 insertions(+), 40 deletions(-)
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index dd6a9585bc..c9a8529737 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -239,6 +239,67 @@ int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset)
return cdev->ops->erase(cdev, count, cdev->offset + offset);
}
+int cdev_lseek(struct cdev *cdev, loff_t pos)
+{
+ int ret;
+
+ if (cdev->ops->lseek) {
+ ret = cdev->ops->lseek(cdev, pos + cdev->offset);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+int cdev_protect(struct cdev *cdev, size_t count, loff_t offset, int prot)
+{
+ if (!cdev->ops->protect)
+ return -ENOSYS;
+
+ return cdev->ops->protect(cdev, count, offset + cdev->offset, prot);
+}
+
+int cdev_discard_range(struct cdev *cdev, loff_t count, loff_t offset)
+{
+ if (!cdev->ops->discard_range)
+ return -ENOSYS;
+
+ if (cdev->flags & DEVFS_PARTITION_READONLY)
+ return -EPERM;
+
+ if (offset >= cdev->size)
+ return 0;
+
+ if (count + offset > cdev->size)
+ count = cdev->size - offset;
+
+ return cdev->ops->discard_range(cdev, count, offset + cdev->offset);
+}
+
+int cdev_memmap(struct cdev *cdev, void **map, int flags)
+{
+ int ret = -ENOSYS;
+
+ if (!cdev->ops->memmap)
+ return -EINVAL;
+
+ ret = cdev->ops->memmap(cdev, map, flags);
+
+ if (!ret)
+ *map = (void *)((unsigned long)*map + (unsigned long)cdev->offset);
+
+ return ret;
+}
+
+int cdev_truncate(struct cdev *cdev, size_t size)
+{
+ if (cdev->ops->truncate)
+ return cdev->ops->truncate(cdev, size);
+
+ return -EPERM;
+}
+
int devfs_create(struct cdev *new)
{
struct cdev *cdev;
diff --git a/fs/devfs.c b/fs/devfs.c
index df229cca48..d205881765 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -57,15 +57,8 @@ static int devfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t s
static int devfs_lseek(struct device_d *_dev, FILE *f, loff_t pos)
{
struct cdev *cdev = f->priv;
- int ret;
- if (cdev->ops->lseek) {
- ret = cdev->ops->lseek(cdev, pos + cdev->offset);
- if (ret < 0)
- return ret;
- }
-
- return 0;
+ return cdev_lseek(cdev, pos);
}
static int devfs_erase(struct device_d *_dev, FILE *f, loff_t count, loff_t offset)
@@ -81,14 +74,11 @@ static int devfs_erase(struct device_d *_dev, FILE *f, loff_t count, loff_t offs
return cdev_erase(cdev, count, offset);
}
-static int devfs_protect(struct device_d *_dev, FILE *f, size_t count, loff_t offset, int prot)
+static int devfs_protect(struct device_d *dev, FILE *f, size_t count, loff_t offset, int prot)
{
struct cdev *cdev = f->priv;
- if (!cdev->ops->protect)
- return -ENOSYS;
-
- return cdev->ops->protect(cdev, count, offset + cdev->offset, prot);
+ return cdev_protect(cdev, count, offset, prot);
}
static int devfs_discard_range(struct device_d *dev, FILE *f, loff_t count,
@@ -96,35 +86,14 @@ static int devfs_discard_range(struct device_d *dev, FILE *f, loff_t count,
{
struct cdev *cdev = f->priv;
- if (!cdev->ops->discard_range)
- return -ENOSYS;
-
- if (cdev->flags & DEVFS_PARTITION_READONLY)
- return -EPERM;
-
- if (offset >= cdev->size)
- return 0;
-
- if (count + offset > cdev->size)
- count = cdev->size - offset;
-
- return cdev->ops->discard_range(cdev, count, offset + cdev->offset);
+ return cdev_discard_range(cdev, count, offset);
}
static int devfs_memmap(struct device_d *_dev, FILE *f, void **map, int flags)
{
struct cdev *cdev = f->priv;
- int ret = -ENOSYS;
- if (!cdev->ops->memmap)
- return -EINVAL;
-
- ret = cdev->ops->memmap(cdev, map, flags);
-
- if (!ret)
- *map = (void *)((unsigned long)*map + (unsigned long)cdev->offset);
-
- return ret;
+ return cdev_memmap(cdev, map, flags);
}
static int devfs_open(struct device_d *_dev, FILE *f, const char *filename)
@@ -183,10 +152,7 @@ static int devfs_truncate(struct device_d *dev, FILE *f, loff_t size)
{
struct cdev *cdev = f->priv;
- if (cdev->ops->truncate)
- return cdev->ops->truncate(cdev, size);
-
- return -EPERM;
+ return cdev_truncate(cdev, size);
}
static struct inode *devfs_alloc_inode(struct super_block *sb)
diff --git a/include/driver.h b/include/driver.h
index 93de4f676e..b9b0b8497d 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -503,6 +503,11 @@ ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulo
ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags);
int cdev_ioctl(struct cdev *cdev, int cmd, void *buf);
int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset);
+int cdev_lseek(struct cdev*, loff_t);
+int cdev_protect(struct cdev*, size_t count, loff_t offset, int prot);
+int cdev_discard_range(struct cdev*, loff_t count, loff_t offset);
+int cdev_memmap(struct cdev*, void **map, int flags);
+int cdev_truncate(struct cdev*, size_t size);
loff_t cdev_unallocated_space(struct cdev *cdev);
#define DEVFS_PARTITION_FIXED (1U << 0)
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 7/8] cdev: create iterator for cdev list
2022-02-07 9:49 [PATCH 1/8] cdev: rename partuuid to uuid Sascha Hauer
` (4 preceding siblings ...)
2022-02-07 9:49 ` [PATCH 6/8] cdev: Create missing cdev_* functions Sascha Hauer
@ 2022-02-07 9:49 ` Sascha Hauer
2022-02-07 9:49 ` [PATCH 8/8] misc: Add storage-by-uuid driver Sascha Hauer
6 siblings, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2022-02-07 9:49 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Olbrich
This creates an iterator to iterate over all availabe cdevs.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/devfs-core.c | 10 +++++-----
fs/devfs.c | 4 +---
include/driver.h | 4 ++++
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index c9a8529737..2f2882dcc8 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -37,7 +37,7 @@ int devfs_partition_complete(struct string_list *sl, char *instr)
len = strlen(instr);
- list_for_each_entry(cdev, &cdev_list, list) {
+ for_each_cdev(cdev) {
if (cdev->master &&
!strncmp(instr, cdev->name, len)) {
string_list_add_asprintf(sl, "%s ", cdev->name);
@@ -62,7 +62,7 @@ struct cdev *lcdev_by_name(const char *filename)
{
struct cdev *cdev;
- list_for_each_entry(cdev, &cdev_list, list) {
+ for_each_cdev(cdev) {
if (!strcmp(cdev->name, filename))
return cdev;
}
@@ -84,7 +84,7 @@ struct cdev *cdev_by_device_node(struct device_node *node)
{
struct cdev *cdev;
- list_for_each_entry(cdev, &cdev_list, list) {
+ for_each_cdev(cdev) {
if (!cdev->device_node)
continue;
if (cdev->device_node == node)
@@ -100,7 +100,7 @@ struct cdev *cdev_by_partuuid(const char *partuuid)
if (!partuuid)
return NULL;
- list_for_each_entry(cdev, &cdev_list, list) {
+ for_each_cdev(cdev) {
if (cdev->master && !strcasecmp(cdev->uuid, partuuid))
return cdev;
}
@@ -114,7 +114,7 @@ struct cdev *cdev_by_diskuuid(const char *diskuuid)
if (!diskuuid)
return NULL;
- list_for_each_entry(cdev, &cdev_list, list) {
+ for_each_cdev(cdev) {
if (!cdev->master && !strcasecmp(cdev->uuid, diskuuid))
return cdev;
}
diff --git a/fs/devfs.c b/fs/devfs.c
index d205881765..deb244feea 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -35,8 +35,6 @@ struct devfs_inode {
struct cdev *cdev;
};
-extern struct list_head cdev_list;
-
static int devfs_read(struct device_d *_dev, FILE *f, void *buf, size_t size)
{
struct cdev *cdev = f->priv;
@@ -179,7 +177,7 @@ static int devfs_iterate(struct file *file, struct dir_context *ctx)
dir_emit_dots(file, ctx);
- list_for_each_entry(cdev, &cdev_list, list) {
+ for_each_cdev(cdev) {
dir_emit(ctx, cdev->name, strlen(cdev->name),
1 /* FIXME */, DT_REG);
}
diff --git a/include/driver.h b/include/driver.h
index b9b0b8497d..79d287ec31 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -510,6 +510,10 @@ int cdev_memmap(struct cdev*, void **map, int flags);
int cdev_truncate(struct cdev*, size_t size);
loff_t cdev_unallocated_space(struct cdev *cdev);
+extern struct list_head cdev_list;
+#define for_each_cdev(c) \
+ list_for_each_entry(cdev, &cdev_list, list)
+
#define DEVFS_PARTITION_FIXED (1U << 0)
#define DEVFS_PARTITION_READONLY (1U << 1)
#define DEVFS_IS_CHARACTER_DEV (1U << 3)
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 8/8] misc: Add storage-by-uuid driver
2022-02-07 9:49 [PATCH 1/8] cdev: rename partuuid to uuid Sascha Hauer
` (5 preceding siblings ...)
2022-02-07 9:49 ` [PATCH 7/8] cdev: create iterator for cdev list Sascha Hauer
@ 2022-02-07 9:49 ` Sascha Hauer
2022-02-07 9:52 ` Sascha Hauer
` (2 more replies)
6 siblings, 3 replies; 14+ messages in thread
From: Sascha Hauer @ 2022-02-07 9:49 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Olbrich
This adds a driver which matches to a "barebox,storage-by-uuid"
compatible node. The driver looks for a storage device matching the
given UUID and when found registers a new cdev for the device.
This driver solved a very specific problem. On EFI the storage devices
are not connected to any device tree node. barebox-state however expects
a node to use as its backend. The obvious solution would be to create
a partition with a specific partuuid and use that for state, in our
special usecase though the storage device is partitioned with a MBR
which doesn't have any space left to create a new partition. As this
driver parses the of partition binding we can use that to create
a partition in an unallocated are of the disk which is then used for
state.
This driver has the problem that it depends on storage devices which
are not described in the device tree. This means it cannot work with
deep probe. This is not a problem on EFI though. It's a special purpose
driver, it's not recommended for general use.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/misc/Kconfig | 23 ++++
drivers/misc/Makefile | 1 +
drivers/misc/storage-by-uuid.c | 199 +++++++++++++++++++++++++++++++++
3 files changed, 223 insertions(+)
create mode 100644 drivers/misc/storage-by-uuid.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 5ab0506cd9..78c9c193d8 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -47,4 +47,27 @@ config STARFIVE_PWRSEQ
be accessed over /dev/mem or used from kernels which still depend
on bootloader for initialization.
+config STORAGE_BY_UUID
+ bool "storage by UUID"
+ depends on OFDEVICE
+ help
+ This adds a driver which matches to a "barebox,storage-by-uuid"
+ compatible node. The driver looks for a storage device matching the
+ given UUID and when found registers a new cdev for the device.
+
+ This driver solved a very specific problem. On EFI the storage devices
+ are not connected to any device tree node. barebox-state however expects
+ a node to use as its backend. The obvious solution would be to create
+ a partition with a specific partuuid and use that for state, in our
+ special usecase though the storage device is partitioned with a MBR
+ which doesn't have any space left to create a new partition. As this
+ driver parses the of partition binding we can use that to create
+ a partition in an unallocated are of the disk which is then used for
+ state.
+
+ This driver has the problem that it depends on storage devices which
+ are not described in the device tree. This means it cannot work with
+ deep probe. This is not a problem on EFI though. It's a special purpose
+ driver, it's not recommended for general use.
+
endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 6326e784fc..986f7b1b38 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_STATE_DRV) += state.o
obj-$(CONFIG_DEV_MEM) += mem.o
obj-$(CONFIG_UBOOTVAR) += ubootvar.o
obj-$(CONFIG_STARFIVE_PWRSEQ) += starfive-pwrseq.o
+obj-$(CONFIG_STORAGE_BY_UUID) += storage-by-uuid.o
diff --git a/drivers/misc/storage-by-uuid.c b/drivers/misc/storage-by-uuid.c
new file mode 100644
index 0000000000..c9dd6e9793
--- /dev/null
+++ b/drivers/misc/storage-by-uuid.c
@@ -0,0 +1,199 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <of.h>
+#include <malloc.h>
+#include <partition.h>
+#include <envfs.h>
+#include <fs.h>
+
+static LIST_HEAD(sbu_list);
+
+struct sbu {
+ char *uuid;
+ struct device_d *dev;
+ struct cdev *rcdev;
+ struct cdev cdev;
+ struct list_head list;
+};
+
+void storage_by_uuid_check_exist(struct cdev *cdev);
+
+static ssize_t sbu_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_read(sbu->rcdev, buf, count, offset, flags);
+}
+
+static ssize_t sbu_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_write(sbu->rcdev, buf, count, offset, flags);
+}
+
+static int sbu_ioctl(struct cdev *cdev, int request, void *buf)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_ioctl(sbu->rcdev, request, buf);
+}
+
+static int sbu_open(struct cdev *cdev, unsigned long flags)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_open(sbu->rcdev, flags);
+}
+
+static int sbu_close(struct cdev *cdev)
+{
+ struct sbu *sbu = cdev->priv;
+
+ cdev_close(sbu->rcdev);
+
+ return 0;
+}
+
+static int sbu_flush(struct cdev *cdev)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_flush(sbu->rcdev);
+}
+
+static int sbu_erase(struct cdev *cdev, loff_t count, loff_t offset)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_erase(sbu->rcdev, count, offset);
+}
+
+static int sbu_protect(struct cdev *cdev, size_t count, loff_t offset, int prot)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_protect(sbu->rcdev, count, offset, prot);
+}
+
+static int sbu_discard_range(struct cdev *cdev, loff_t count, loff_t offset)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_discard_range(sbu->rcdev, count, offset);
+}
+
+static int sbu_memmap(struct cdev *cdev, void **map, int flags)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_memmap(sbu->rcdev, map, flags);
+}
+
+static int sbu_truncate(struct cdev *cdev, size_t size)
+{
+ struct sbu *sbu = cdev->priv;
+
+ return cdev_truncate(sbu->rcdev, size);
+}
+
+static struct cdev_operations sbu_ops = {
+ .read = sbu_read,
+ .write = sbu_write,
+ .ioctl = sbu_ioctl,
+ .open = sbu_open,
+ .close = sbu_close,
+ .flush = sbu_flush,
+ .erase = sbu_erase,
+ .protect = sbu_protect,
+ .discard_range = sbu_discard_range,
+ .memmap = sbu_memmap,
+ .truncate = sbu_truncate,
+};
+
+static void storage_by_uuid_add_partitions(struct sbu *sbu, struct cdev *rcdev)
+{
+ int ret;
+
+ if (sbu->rcdev)
+ return;
+
+ sbu->rcdev = rcdev;
+ sbu->cdev.name = sbu->uuid;
+ sbu->cdev.size = rcdev->size;
+ sbu->cdev.ops = &sbu_ops;
+ sbu->cdev.dev = sbu->dev;
+ sbu->cdev.priv = sbu;
+
+ ret = devfs_create(&sbu->cdev);
+ if (ret) {
+ dev_err(sbu->dev, "Failed to create cdev: %s\n", strerror(-ret));
+ return;
+ }
+
+ of_parse_partitions(&sbu->cdev, sbu->dev->device_node);
+}
+
+static void check_exist(struct sbu *sbu)
+{
+ struct cdev *cdev;
+
+ for_each_cdev(cdev) {
+ if (!strcmp(cdev->uuid, sbu->uuid)) {
+ dev_dbg(sbu->dev, "Found %s %s\n", cdev->name, cdev->uuid);
+ storage_by_uuid_add_partitions(sbu, cdev);
+ }
+ }
+}
+
+static int sbu_detect(struct device_d *dev)
+{
+ struct sbu *sbu = dev->priv;
+
+ dev_dbg(dev, "%s\n", __func__);
+
+ check_exist(sbu);
+
+ return 0;
+}
+
+static int storage_by_uuid_probe(struct device_d *dev)
+{
+ struct sbu *sbu;
+ int ret;
+ const char *uuid;
+
+ sbu = xzalloc(sizeof(*sbu));
+
+ ret = of_property_read_string(dev->device_node, "uuid", &uuid);
+ if (ret)
+ return ret;
+
+ sbu->dev = dev;
+ sbu->uuid = xstrdup(uuid);
+
+ list_add_tail(&sbu->list, &sbu_list);
+
+ check_exist(sbu);
+ dev->priv = sbu;
+ dev->detect = sbu_detect;
+
+ return 0;
+}
+
+static struct of_device_id storage_by_uuid_dt_ids[] = {
+ {
+ .compatible = "barebox,storage-by-uuid",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d storage_by_uuid_driver = {
+ .name = "storage-by-uuid",
+ .probe = storage_by_uuid_probe,
+ .of_compatible = storage_by_uuid_dt_ids,
+};
+device_platform_driver(storage_by_uuid_driver);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 8/8] misc: Add storage-by-uuid driver
2022-02-07 9:49 ` [PATCH 8/8] misc: Add storage-by-uuid driver Sascha Hauer
@ 2022-02-07 9:52 ` Sascha Hauer
2022-02-07 10:59 ` [PATCH] efi: probe devices from the device-tree Michael Olbrich
2022-02-08 9:29 ` [PATCH 8/8] misc: Add storage-by-uuid driver Michael Olbrich
2 siblings, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2022-02-07 9:52 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Olbrich
On Mon, Feb 07, 2022 at 10:49:53AM +0100, Sascha Hauer wrote:
> This adds a driver which matches to a "barebox,storage-by-uuid"
> compatible node. The driver looks for a storage device matching the
> given UUID and when found registers a new cdev for the device.
>
> This driver solved a very specific problem. On EFI the storage devices
> are not connected to any device tree node. barebox-state however expects
> a node to use as its backend. The obvious solution would be to create
> a partition with a specific partuuid and use that for state, in our
> special usecase though the storage device is partitioned with a MBR
> which doesn't have any space left to create a new partition. As this
> driver parses the of partition binding we can use that to create
> a partition in an unallocated are of the disk which is then used for
> state.
>
> This driver has the problem that it depends on storage devices which
> are not described in the device tree. This means it cannot work with
> deep probe. This is not a problem on EFI though. It's a special purpose
> driver, it's not recommended for general use.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/misc/Kconfig | 23 ++++
> drivers/misc/Makefile | 1 +
> drivers/misc/storage-by-uuid.c | 199 +++++++++++++++++++++++++++++++++
> 3 files changed, 223 insertions(+)
> create mode 100644 drivers/misc/storage-by-uuid.c
>
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 5ab0506cd9..78c9c193d8 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -47,4 +47,27 @@ config STARFIVE_PWRSEQ
> be accessed over /dev/mem or used from kernels which still depend
> on bootloader for initialization.
>
> +static struct of_device_id storage_by_uuid_dt_ids[] = {
> + {
> + .compatible = "barebox,storage-by-uuid",
> + }, {
NAK. Don't add new device tree bindings without adding documentation to
Documentation/devicetree/bindings/ :(
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] efi: probe devices from the device-tree
2022-02-07 9:49 ` [PATCH 8/8] misc: Add storage-by-uuid driver Sascha Hauer
2022-02-07 9:52 ` Sascha Hauer
@ 2022-02-07 10:59 ` Michael Olbrich
2022-02-08 9:29 ` [PATCH 8/8] misc: Add storage-by-uuid driver Michael Olbrich
2 siblings, 0 replies; 14+ messages in thread
From: Michael Olbrich @ 2022-02-07 10:59 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich
The state device-tree may contain devices. For example block devices with a
'barebox,storage-by-uuid' compatible. Probing is necessary to ensure that
those devices are available.
Call barebox_register_of() instead of of_set_root_node(). It probes the
devices after setting the root node.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
I've tested the series and with this aditional patch it works on EFI, so
Tested-by: Michael Olbrich <m.olbrich@pengutronix.de>
Michael
common/efi/payload/init.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/efi/payload/init.c b/common/efi/payload/init.c
index 6db6b2389540..1541683186fb 100644
--- a/common/efi/payload/init.c
+++ b/common/efi/payload/init.c
@@ -349,7 +349,9 @@ static int efi_late_init(void)
if (IS_ERR(root))
return PTR_ERR(root);
- of_set_root_node(root);
+ ret = barebox_register_of(root);
+ if (ret)
+ pr_warn("Failed to register device-tree: %pe\n", ERR_PTR(ret));
np = of_find_node_by_alias(root, "state");
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 8/8] misc: Add storage-by-uuid driver
2022-02-07 9:49 ` [PATCH 8/8] misc: Add storage-by-uuid driver Sascha Hauer
2022-02-07 9:52 ` Sascha Hauer
2022-02-07 10:59 ` [PATCH] efi: probe devices from the device-tree Michael Olbrich
@ 2022-02-08 9:29 ` Michael Olbrich
2022-02-08 12:27 ` Sascha Hauer
2 siblings, 1 reply; 14+ messages in thread
From: Michael Olbrich @ 2022-02-08 9:29 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
On Mon, Feb 07, 2022 at 10:49:53AM +0100, Sascha Hauer wrote:
> This adds a driver which matches to a "barebox,storage-by-uuid"
> compatible node. The driver looks for a storage device matching the
> given UUID and when found registers a new cdev for the device.
>
> This driver solved a very specific problem. On EFI the storage devices
> are not connected to any device tree node. barebox-state however expects
> a node to use as its backend. The obvious solution would be to create
> a partition with a specific partuuid and use that for state, in our
> special usecase though the storage device is partitioned with a MBR
> which doesn't have any space left to create a new partition. As this
> driver parses the of partition binding we can use that to create
> a partition in an unallocated are of the disk which is then used for
> state.
>
> This driver has the problem that it depends on storage devices which
> are not described in the device tree. This means it cannot work with
> deep probe. This is not a problem on EFI though. It's a special purpose
> driver, it's not recommended for general use.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/misc/Kconfig | 23 ++++
> drivers/misc/Makefile | 1 +
> drivers/misc/storage-by-uuid.c | 199 +++++++++++++++++++++++++++++++++
> 3 files changed, 223 insertions(+)
> create mode 100644 drivers/misc/storage-by-uuid.c
>
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 5ab0506cd9..78c9c193d8 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -47,4 +47,27 @@ config STARFIVE_PWRSEQ
> be accessed over /dev/mem or used from kernels which still depend
> on bootloader for initialization.
>
> +config STORAGE_BY_UUID
> + bool "storage by UUID"
> + depends on OFDEVICE
> + help
> + This adds a driver which matches to a "barebox,storage-by-uuid"
> + compatible node. The driver looks for a storage device matching the
> + given UUID and when found registers a new cdev for the device.
> +
> + This driver solved a very specific problem. On EFI the storage devices
> + are not connected to any device tree node. barebox-state however expects
> + a node to use as its backend. The obvious solution would be to create
> + a partition with a specific partuuid and use that for state, in our
> + special usecase though the storage device is partitioned with a MBR
> + which doesn't have any space left to create a new partition. As this
> + driver parses the of partition binding we can use that to create
> + a partition in an unallocated are of the disk which is then used for
> + state.
> +
> + This driver has the problem that it depends on storage devices which
> + are not described in the device tree. This means it cannot work with
> + deep probe. This is not a problem on EFI though. It's a special purpose
> + driver, it's not recommended for general use.
> +
> endmenu
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index 6326e784fc..986f7b1b38 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -9,3 +9,4 @@ obj-$(CONFIG_STATE_DRV) += state.o
> obj-$(CONFIG_DEV_MEM) += mem.o
> obj-$(CONFIG_UBOOTVAR) += ubootvar.o
> obj-$(CONFIG_STARFIVE_PWRSEQ) += starfive-pwrseq.o
> +obj-$(CONFIG_STORAGE_BY_UUID) += storage-by-uuid.o
> diff --git a/drivers/misc/storage-by-uuid.c b/drivers/misc/storage-by-uuid.c
> new file mode 100644
> index 0000000000..c9dd6e9793
> --- /dev/null
> +++ b/drivers/misc/storage-by-uuid.c
> @@ -0,0 +1,199 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include <common.h>
> +#include <init.h>
> +#include <io.h>
> +#include <of.h>
> +#include <malloc.h>
> +#include <partition.h>
> +#include <envfs.h>
> +#include <fs.h>
> +
> +static LIST_HEAD(sbu_list);
> +
> +struct sbu {
> + char *uuid;
> + struct device_d *dev;
> + struct cdev *rcdev;
> + struct cdev cdev;
> + struct list_head list;
> +};
> +
> +void storage_by_uuid_check_exist(struct cdev *cdev);
> +
> +static ssize_t sbu_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_read(sbu->rcdev, buf, count, offset, flags);
> +}
> +
> +static ssize_t sbu_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_write(sbu->rcdev, buf, count, offset, flags);
> +}
> +
> +static int sbu_ioctl(struct cdev *cdev, int request, void *buf)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_ioctl(sbu->rcdev, request, buf);
> +}
> +
> +static int sbu_open(struct cdev *cdev, unsigned long flags)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_open(sbu->rcdev, flags);
> +}
> +
> +static int sbu_close(struct cdev *cdev)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + cdev_close(sbu->rcdev);
> +
> + return 0;
> +}
> +
> +static int sbu_flush(struct cdev *cdev)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_flush(sbu->rcdev);
> +}
> +
> +static int sbu_erase(struct cdev *cdev, loff_t count, loff_t offset)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_erase(sbu->rcdev, count, offset);
> +}
> +
> +static int sbu_protect(struct cdev *cdev, size_t count, loff_t offset, int prot)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_protect(sbu->rcdev, count, offset, prot);
> +}
> +
> +static int sbu_discard_range(struct cdev *cdev, loff_t count, loff_t offset)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_discard_range(sbu->rcdev, count, offset);
> +}
> +
> +static int sbu_memmap(struct cdev *cdev, void **map, int flags)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_memmap(sbu->rcdev, map, flags);
> +}
> +
> +static int sbu_truncate(struct cdev *cdev, size_t size)
> +{
> + struct sbu *sbu = cdev->priv;
> +
> + return cdev_truncate(sbu->rcdev, size);
> +}
> +
> +static struct cdev_operations sbu_ops = {
> + .read = sbu_read,
> + .write = sbu_write,
> + .ioctl = sbu_ioctl,
> + .open = sbu_open,
> + .close = sbu_close,
> + .flush = sbu_flush,
> + .erase = sbu_erase,
> + .protect = sbu_protect,
> + .discard_range = sbu_discard_range,
> + .memmap = sbu_memmap,
> + .truncate = sbu_truncate,
Should be indented with tabs, right?
Michael
> +};
> +
> +static void storage_by_uuid_add_partitions(struct sbu *sbu, struct cdev *rcdev)
> +{
> + int ret;
> +
> + if (sbu->rcdev)
> + return;
> +
> + sbu->rcdev = rcdev;
> + sbu->cdev.name = sbu->uuid;
> + sbu->cdev.size = rcdev->size;
> + sbu->cdev.ops = &sbu_ops;
> + sbu->cdev.dev = sbu->dev;
> + sbu->cdev.priv = sbu;
> +
> + ret = devfs_create(&sbu->cdev);
> + if (ret) {
> + dev_err(sbu->dev, "Failed to create cdev: %s\n", strerror(-ret));
> + return;
> + }
> +
> + of_parse_partitions(&sbu->cdev, sbu->dev->device_node);
> +}
> +
> +static void check_exist(struct sbu *sbu)
> +{
> + struct cdev *cdev;
> +
> + for_each_cdev(cdev) {
> + if (!strcmp(cdev->uuid, sbu->uuid)) {
> + dev_dbg(sbu->dev, "Found %s %s\n", cdev->name, cdev->uuid);
> + storage_by_uuid_add_partitions(sbu, cdev);
> + }
> + }
> +}
> +
> +static int sbu_detect(struct device_d *dev)
> +{
> + struct sbu *sbu = dev->priv;
> +
> + dev_dbg(dev, "%s\n", __func__);
> +
> + check_exist(sbu);
> +
> + return 0;
> +}
> +
> +static int storage_by_uuid_probe(struct device_d *dev)
> +{
> + struct sbu *sbu;
> + int ret;
> + const char *uuid;
> +
> + sbu = xzalloc(sizeof(*sbu));
> +
> + ret = of_property_read_string(dev->device_node, "uuid", &uuid);
> + if (ret)
> + return ret;
> +
> + sbu->dev = dev;
> + sbu->uuid = xstrdup(uuid);
> +
> + list_add_tail(&sbu->list, &sbu_list);
> +
> + check_exist(sbu);
> + dev->priv = sbu;
> + dev->detect = sbu_detect;
> +
> + return 0;
> +}
> +
> +static struct of_device_id storage_by_uuid_dt_ids[] = {
> + {
> + .compatible = "barebox,storage-by-uuid",
> + }, {
> + /* sentinel */
> + }
> +};
> +
> +static struct driver_d storage_by_uuid_driver = {
> + .name = "storage-by-uuid",
> + .probe = storage_by_uuid_probe,
> + .of_compatible = storage_by_uuid_dt_ids,
> +};
> +device_platform_driver(storage_by_uuid_driver);
> --
> 2.30.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 8/8] misc: Add storage-by-uuid driver
2022-02-08 9:29 ` [PATCH 8/8] misc: Add storage-by-uuid driver Michael Olbrich
@ 2022-02-08 12:27 ` Sascha Hauer
0 siblings, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2022-02-08 12:27 UTC (permalink / raw)
To: Michael Olbrich; +Cc: Barebox List
On Tue, Feb 08, 2022 at 10:29:31AM +0100, Michael Olbrich wrote:
> On Mon, Feb 07, 2022 at 10:49:53AM +0100, Sascha Hauer wrote:
> > This adds a driver which matches to a "barebox,storage-by-uuid"
> > compatible node. The driver looks for a storage device matching the
> > given UUID and when found registers a new cdev for the device.
> >
> > This driver solved a very specific problem. On EFI the storage devices
> > are not connected to any device tree node. barebox-state however expects
> > a node to use as its backend. The obvious solution would be to create
> > a partition with a specific partuuid and use that for state, in our
> > special usecase though the storage device is partitioned with a MBR
> > which doesn't have any space left to create a new partition. As this
> > driver parses the of partition binding we can use that to create
> > a partition in an unallocated are of the disk which is then used for
> > state.
> >
> > This driver has the problem that it depends on storage devices which
> > are not described in the device tree. This means it cannot work with
> > deep probe. This is not a problem on EFI though. It's a special purpose
> > driver, it's not recommended for general use.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> > drivers/misc/Kconfig | 23 ++++
> > drivers/misc/Makefile | 1 +
> > drivers/misc/storage-by-uuid.c | 199 +++++++++++++++++++++++++++++++++
> > 3 files changed, 223 insertions(+)
> > create mode 100644 drivers/misc/storage-by-uuid.c
> >
> > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > index 5ab0506cd9..78c9c193d8 100644
> > --- a/drivers/misc/Kconfig
> > +++ b/drivers/misc/Kconfig
> > @@ -47,4 +47,27 @@ config STARFIVE_PWRSEQ
> > be accessed over /dev/mem or used from kernels which still depend
> > on bootloader for initialization.
> >
> > +config STORAGE_BY_UUID
> > + bool "storage by UUID"
> > + depends on OFDEVICE
> > + help
> > + This adds a driver which matches to a "barebox,storage-by-uuid"
> > + compatible node. The driver looks for a storage device matching the
> > + given UUID and when found registers a new cdev for the device.
> > +
> > + This driver solved a very specific problem. On EFI the storage devices
> > + are not connected to any device tree node. barebox-state however expects
> > + a node to use as its backend. The obvious solution would be to create
> > + a partition with a specific partuuid and use that for state, in our
> > + special usecase though the storage device is partitioned with a MBR
> > + which doesn't have any space left to create a new partition. As this
> > + driver parses the of partition binding we can use that to create
> > + a partition in an unallocated are of the disk which is then used for
> > + state.
> > +
> > + This driver has the problem that it depends on storage devices which
> > + are not described in the device tree. This means it cannot work with
> > + deep probe. This is not a problem on EFI though. It's a special purpose
> > + driver, it's not recommended for general use.
> > +
> > endmenu
> > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > index 6326e784fc..986f7b1b38 100644
> > --- a/drivers/misc/Makefile
> > +++ b/drivers/misc/Makefile
> > @@ -9,3 +9,4 @@ obj-$(CONFIG_STATE_DRV) += state.o
> > obj-$(CONFIG_DEV_MEM) += mem.o
> > obj-$(CONFIG_UBOOTVAR) += ubootvar.o
> > obj-$(CONFIG_STARFIVE_PWRSEQ) += starfive-pwrseq.o
> > +obj-$(CONFIG_STORAGE_BY_UUID) += storage-by-uuid.o
> > diff --git a/drivers/misc/storage-by-uuid.c b/drivers/misc/storage-by-uuid.c
> > new file mode 100644
> > index 0000000000..c9dd6e9793
> > --- /dev/null
> > +++ b/drivers/misc/storage-by-uuid.c
> > @@ -0,0 +1,199 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +#include <common.h>
> > +#include <init.h>
> > +#include <io.h>
> > +#include <of.h>
> > +#include <malloc.h>
> > +#include <partition.h>
> > +#include <envfs.h>
> > +#include <fs.h>
> > +
> > +static LIST_HEAD(sbu_list);
> > +
> > +struct sbu {
> > + char *uuid;
> > + struct device_d *dev;
> > + struct cdev *rcdev;
> > + struct cdev cdev;
> > + struct list_head list;
> > +};
> > +
> > +void storage_by_uuid_check_exist(struct cdev *cdev);
> > +
> > +static ssize_t sbu_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_read(sbu->rcdev, buf, count, offset, flags);
> > +}
> > +
> > +static ssize_t sbu_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_write(sbu->rcdev, buf, count, offset, flags);
> > +}
> > +
> > +static int sbu_ioctl(struct cdev *cdev, int request, void *buf)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_ioctl(sbu->rcdev, request, buf);
> > +}
> > +
> > +static int sbu_open(struct cdev *cdev, unsigned long flags)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_open(sbu->rcdev, flags);
> > +}
> > +
> > +static int sbu_close(struct cdev *cdev)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + cdev_close(sbu->rcdev);
> > +
> > + return 0;
> > +}
> > +
> > +static int sbu_flush(struct cdev *cdev)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_flush(sbu->rcdev);
> > +}
> > +
> > +static int sbu_erase(struct cdev *cdev, loff_t count, loff_t offset)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_erase(sbu->rcdev, count, offset);
> > +}
> > +
> > +static int sbu_protect(struct cdev *cdev, size_t count, loff_t offset, int prot)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_protect(sbu->rcdev, count, offset, prot);
> > +}
> > +
> > +static int sbu_discard_range(struct cdev *cdev, loff_t count, loff_t offset)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_discard_range(sbu->rcdev, count, offset);
> > +}
> > +
> > +static int sbu_memmap(struct cdev *cdev, void **map, int flags)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_memmap(sbu->rcdev, map, flags);
> > +}
> > +
> > +static int sbu_truncate(struct cdev *cdev, size_t size)
> > +{
> > + struct sbu *sbu = cdev->priv;
> > +
> > + return cdev_truncate(sbu->rcdev, size);
> > +}
> > +
> > +static struct cdev_operations sbu_ops = {
> > + .read = sbu_read,
> > + .write = sbu_write,
> > + .ioctl = sbu_ioctl,
> > + .open = sbu_open,
> > + .close = sbu_close,
> > + .flush = sbu_flush,
> > + .erase = sbu_erase,
> > + .protect = sbu_protect,
> > + .discard_range = sbu_discard_range,
> > + .memmap = sbu_memmap,
> > + .truncate = sbu_truncate,
>
> Should be indented with tabs, right?
Right, fixed that.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 14+ messages in thread