summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-02-13 20:31:47 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-02-13 20:31:47 +0100
commit2a17e75a976d11c1712972d29813094b8020ac35 (patch)
treeea0e991c927752937803d72a5411f7159365aa83 /commands
parenta5f75fe8175aefec5b7cefaadc5359096c8eb22c (diff)
parent7185b353c96e1e831533eeaaada06ad9bebf84a2 (diff)
downloadbarebox-2a17e75a976d11c1712972d29813094b8020ac35.tar.gz
Merge branch 'for-next/misc'
Diffstat (limited to 'commands')
-rw-r--r--commands/i2c.c26
-rw-r--r--commands/ls.c12
2 files changed, 25 insertions, 13 deletions
diff --git a/commands/i2c.c b/commands/i2c.c
index 2f7f820..77d65e3 100644
--- a/commands/i2c.c
+++ b/commands/i2c.c
@@ -24,19 +24,19 @@
static void i2c_probe_range(struct i2c_adapter *adapter, int startaddr, int stopaddr)
{
- struct i2c_client client = {};
int addr;
- int ret;
- u8 reg;
-
- client.adapter = adapter;
printf("probing i2c%d range 0x%02x-0x%02x: ", adapter->nr, startaddr, stopaddr);
for (addr = startaddr; addr <= stopaddr && !ctrlc(); addr++) {
- client.addr = addr;
- ret = i2c_write_reg(&client, 0x00, &reg, 0);
- if (ret == 0)
+ struct i2c_msg msg = {
+ .addr = addr,
+ .buf = NULL,
+ .len = 0,
+ };
+ int ret = i2c_transfer(adapter, &msg, 1);
+ if (ret == 1)
printf("0x%02x ", addr);
+
}
printf("\n");
}
@@ -44,7 +44,7 @@ static void i2c_probe_range(struct i2c_adapter *adapter, int startaddr, int stop
static int do_i2c_probe(int argc, char *argv[])
{
struct i2c_adapter *adapter = NULL;
- int startaddr = 0, stopaddr = 0x7f;
+ int startaddr = 4, stopaddr = 0x77;
if (argc > 1) {
adapter = i2c_get_adapter(simple_strtoul(argv[1], NULL, 0));
@@ -57,13 +57,15 @@ static int do_i2c_probe(int argc, char *argv[])
if (argc > 3)
stopaddr = simple_strtol(argv[3], NULL, 0);
+ if (stopaddr > 0x7f)
+ stopaddr = 0x7f;
+
+ if (startaddr < 0)
+ startaddr = 0;
if (startaddr > stopaddr)
return COMMAND_ERROR_USAGE;
- if (stopaddr > 0x7F)
- stopaddr = 0x7F;
-
if (adapter) {
i2c_probe_range(adapter, startaddr, stopaddr);
} else {
diff --git a/commands/ls.c b/commands/ls.c
index e549918..e5e37d7 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -26,6 +26,15 @@
#include <getopt.h>
#include <stringlist.h>
+/*
+ * SIZELEN = strlen(itoa(MAX_LFS_FILESIZE)) + 1;
+ */
+#ifdef CONFIG_CPU_64
+#define SIZELEN 20
+#else
+#define SIZELEN 14
+#endif
+
static void ls_one(const char *path, const char* fullname)
{
char modestr[11];
@@ -38,7 +47,8 @@ static void ls_one(const char *path, const char* fullname)
return;
mkmodestr(s.st_mode, modestr);
- printf("%s %14llu %*.*s", modestr, s.st_size, namelen, namelen, path);
+ printf("%s %*llu %*.*s", modestr, SIZELEN, s.st_size, namelen,
+ namelen, path);
if (S_ISLNK(s.st_mode)) {
char realname[PATH_MAX];