From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH v2 2/7] filetype: Allow specifying cdev's filetype explicitly
Date: Mon, 3 Jun 2019 22:19:58 -0700 [thread overview]
Message-ID: <20190604052003.3189-3-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190604052003.3189-1-andrew.smirnov@gmail.com>
Allow specifying cdev's filetype explicitly to support the cases where
the type of a cdev is known apriori, yet cannot be determined by
reading the cdev's content.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
common/filetype.c | 6 ++++++
include/driver.h | 2 ++
2 files changed, 8 insertions(+)
diff --git a/common/filetype.c b/common/filetype.c
index 429911533..e4c8005b5 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -425,6 +425,11 @@ enum filetype cdev_detect_type(const char *name)
if (!cdev)
return type;
+ if (cdev->filetype != filetype_unknown) {
+ type = cdev->filetype;
+ goto cdev_close;
+ }
+
buf = xzalloc(FILE_TYPE_SAFE_BUFSIZE);
ret = cdev_read(cdev, buf, FILE_TYPE_SAFE_BUFSIZE, 0, 0);
if (ret < 0)
@@ -434,6 +439,7 @@ enum filetype cdev_detect_type(const char *name)
err_out:
free(buf);
+cdev_close:
cdev_close(cdev);
return type;
}
diff --git a/include/driver.h b/include/driver.h
index 26ec413bd..fe2d30ab5 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -22,6 +22,7 @@
#include <linux/list.h>
#include <linux/ioport.h>
#include <of.h>
+#include <filetype.h>
#define FORMAT_DRIVER_NAME_ID "%s%d"
@@ -464,6 +465,7 @@ struct cdev {
struct list_head link_entry, links;
struct list_head partition_entry, partitions;
struct cdev *master;
+ enum filetype filetype;
};
int devfs_create(struct cdev *);
--
2.21.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-06-04 5:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 5:19 [PATCH v2 0/7] U-Boot environment data as a filesystem Andrey Smirnov
2019-06-04 5:19 ` [PATCH v2 1/7] filetype: Add "U-Boot environmemnt variable data" filetype Andrey Smirnov
2019-06-04 5:19 ` Andrey Smirnov [this message]
2019-06-04 5:19 ` [PATCH v2 3/7] drivers: Introduce late_platform_driver() Andrey Smirnov
2019-06-04 5:20 ` [PATCH v2 4/7] misc: Add a driver to expose U-Boot environment variable data Andrey Smirnov
2019-06-04 5:20 ` [PATCH v2 5/7] fs: Add a driver to access U-Boot environment variables Andrey Smirnov
2019-06-04 5:20 ` [PATCH v2 6/7] ARM: rdu2: Add U-Boot environment partitions Andrey Smirnov
2019-06-04 5:20 ` [PATCH v2 7/7] ARM: rdu1: Add U-Boot environment partition Andrey Smirnov
2019-06-07 7:05 ` [PATCH v2 0/7] U-Boot environment data as a filesystem Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190604052003.3189-3-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox