mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/4] A bit more consistent interface for "miitool"
@ 2017-12-04 15:37 Andrey Smirnov
  2017-12-04 15:37 ` [PATCH 1/4] commands: miitool: Constify 'phydevname' in mdiobus_show() Andrey Smirnov
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andrey Smirnov @ 2017-12-04 15:37 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Hi everyone,

This patchset is intended to make miitools's -s option a bit more
consistnet with the rest of Barebox commands. It is inspired mostly by
users's feedback and personal frustration with inability to use
autocomplete in that command.

It's nice to have, IMHO, but if we decide not to have this change
that's fine too.

Thanks,
Andrey Smirnov

Andrey Smirnov (4):
  commands: miitool: Constify 'phydevname' in mdiobus_show()
  fs: Introduce devpath_to_name()
  i.MX: imu-bbu-internal: Make use of devpath_to_name()
  commands/miitool: Allow specifying PHY by their full path

 arch/arm/mach-imx/imx-bbu-internal.c | 3 +--
 commands/miitool.c                   | 9 ++++++---
 include/fs.h                         | 9 +++++++++
 3 files changed, 16 insertions(+), 5 deletions(-)

-- 
2.14.3


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] commands: miitool: Constify 'phydevname' in mdiobus_show()
  2017-12-04 15:37 [PATCH 0/4] A bit more consistent interface for "miitool" Andrey Smirnov
@ 2017-12-04 15:37 ` Andrey Smirnov
  2017-12-04 15:37 ` [PATCH 2/4] fs: Introduce devpath_to_name() Andrey Smirnov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andrey Smirnov @ 2017-12-04 15:37 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

It seems like mdiobus_show() doesn't need more than read-only to
'phydevname', so constify it to allow passing const stings in.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 commands/miitool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/commands/miitool.c b/commands/miitool.c
index 07bce1865..1a46037f2 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -225,7 +225,8 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev,
 	return 0;
 }
 
-static void mdiobus_show(struct device_d *dev, char *phydevname, int verbose)
+static void mdiobus_show(struct device_d *dev, const char *phydevname,
+			 int verbose)
 {
 	struct mii_bus *mii = to_mii_bus(dev);
 	int i;
-- 
2.14.3


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/4] fs: Introduce devpath_to_name()
  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
  2017-12-04 15:37 ` [PATCH 3/4] i.MX: imu-bbu-internal: Make use of devpath_to_name() Andrey Smirnov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andrey Smirnov @ 2017-12-04 15:37 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/4] i.MX: imu-bbu-internal: Make use of devpath_to_name()
  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 ` [PATCH 2/4] fs: Introduce devpath_to_name() Andrey Smirnov
@ 2017-12-04 15:37 ` 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
  4 siblings, 0 replies; 6+ messages in thread
From: Andrey Smirnov @ 2017-12-04 15:37 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Convert the code to use shared function from fs.h

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 51ec8b827..a139331a6 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -131,8 +131,7 @@ static int imx_bbu_check_prereq(struct bbu_data *data)
 	if (ret)
 		return ret;
 
-	if (!strncmp(data->devicefile, "/dev/", 5))
-		device_detect_by_name(data->devicefile + 5);
+	device_detect_by_name(devpath_to_name(data->devicefile));
 
 	return 0;
 }
-- 
2.14.3


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/4] commands/miitool: Allow specifying PHY by their full path
  2017-12-04 15:37 [PATCH 0/4] A bit more consistent interface for "miitool" Andrey Smirnov
                   ` (2 preceding siblings ...)
  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 ` Andrey Smirnov
  2017-12-06 14:55 ` [PATCH 0/4] A bit more consistent interface for "miitool" Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Andrey Smirnov @ 2017-12-04 15:37 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Make -s option to be a bit more consistent with how it is used in
other commands by allowing PHY device to be specified by either its
name of full path in /dev. This change also allows us to leverage
autocompletion since it will work as expected for paths in /dev.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 commands/miitool.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/commands/miitool.c b/commands/miitool.c
index 1a46037f2..dea4f853c 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -338,7 +338,9 @@ static int do_miitool(int argc, char *argv[])
 	case MIITOOL_SHOW:
 		for_each_mii_bus(mii) {
 			mdiobus_detect(&mii->dev);
-			mdiobus_show(&mii->dev, phydevname, verbose);
+			mdiobus_show(&mii->dev,
+				     devpath_to_name(phydevname),
+				     verbose);
 		}
 		break;
 	}
@@ -358,7 +360,7 @@ BAREBOX_CMD_HELP_TEXT("adapters use an MII to autonegotiate link speed and duple
 BAREBOX_CMD_HELP_TEXT("")
 BAREBOX_CMD_HELP_TEXT("Options:")
 BAREBOX_CMD_HELP_OPT("-v", "increase verbosity")
-BAREBOX_CMD_HELP_OPT("-s <devname>", "show PHY status (not providing PHY prints status of all)")
+BAREBOX_CMD_HELP_OPT("-s <devpath/devname>", "show PHY status (not providing PHY prints status of all)")
 BAREBOX_CMD_HELP_OPT("-r <busno>:<adr>", "register a PHY")
 BAREBOX_CMD_HELP_END
 
-- 
2.14.3


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] A bit more consistent interface for "miitool"
  2017-12-04 15:37 [PATCH 0/4] A bit more consistent interface for "miitool" Andrey Smirnov
                   ` (3 preceding siblings ...)
  2017-12-04 15:37 ` [PATCH 4/4] commands/miitool: Allow specifying PHY by their full path Andrey Smirnov
@ 2017-12-06 14:55 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2017-12-06 14:55 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Mon, Dec 04, 2017 at 07:37:22AM -0800, Andrey Smirnov wrote:
> Hi everyone,
> 
> This patchset is intended to make miitools's -s option a bit more
> consistnet with the rest of Barebox commands. It is inspired mostly by
> users's feedback and personal frustration with inability to use
> autocomplete in that command.
> 
> It's nice to have, IMHO, but if we decide not to have this change
> that's fine too.

Applied, thanks

Sascha

> 
> Thanks,
> Andrey Smirnov
> 
> Andrey Smirnov (4):
>   commands: miitool: Constify 'phydevname' in mdiobus_show()
>   fs: Introduce devpath_to_name()
>   i.MX: imu-bbu-internal: Make use of devpath_to_name()
>   commands/miitool: Allow specifying PHY by their full path
> 
>  arch/arm/mach-imx/imx-bbu-internal.c | 3 +--
>  commands/miitool.c                   | 9 ++++++---
>  include/fs.h                         | 9 +++++++++
>  3 files changed, 16 insertions(+), 5 deletions(-)
> 
> -- 
> 2.14.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-06 14:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/4] fs: Introduce devpath_to_name() Andrey Smirnov
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox