mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 2/4] fs: Introduce devpath_to_name()
Date: Mon,  4 Dec 2017 07:37:24 -0800	[thread overview]
Message-ID: <20171204153726.11479-3-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20171204153726.11479-1-andrew.smirnov@gmail.com>

Add a simple function to simplify the task of accepting both full path
in "/dev" and just device name as a parameter.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 include/fs.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/fs.h b/include/fs.h
index d7fa7714b..79ae404bb 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -10,6 +10,7 @@
 #include <driver.h>
 #include <filetype.h>
 #include <linux/fs.h>
+#include <linux/string.h>
 
 #define PATH_MAX       1024        /* include/linux/limits.h */
 
@@ -151,4 +152,12 @@ void mount_all(void);
 void fsdev_set_linux_rootarg(struct fs_device_d *fsdev, const char *str);
 char *path_get_linux_rootarg(const char *path);
 
+static inline const char *devpath_to_name(const char *devpath)
+{
+	if (devpath && !strncmp(devpath, "/dev/", 5))
+		return devpath + 5;
+
+	return devpath;
+}
+
 #endif /* __FS_H */
-- 
2.14.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-12-04 15:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-04 15:37 [PATCH 0/4] A bit more consistent interface for "miitool" Andrey Smirnov
2017-12-04 15:37 ` [PATCH 1/4] commands: miitool: Constify 'phydevname' in mdiobus_show() Andrey Smirnov
2017-12-04 15:37 ` Andrey Smirnov [this message]
2017-12-04 15:37 ` [PATCH 3/4] i.MX: imu-bbu-internal: Make use of devpath_to_name() Andrey Smirnov
2017-12-04 15:37 ` [PATCH 4/4] commands/miitool: Allow specifying PHY by their full path Andrey Smirnov
2017-12-06 14:55 ` [PATCH 0/4] A bit more consistent interface for "miitool" 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=20171204153726.11479-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