RATP i2c and GPIO support
v2 cover RATP i2c and GPIO support
This series of patches implements support for i2c and GPIO operations via RATP.
It addresses most of the comments from the first series review, except for Sascha's suggestion to implement name resolving for the i2c buses and Andrey's suggestion to prepare a new helper method to initialize the i2c_client structure. I already have a patch for the latter, but will send it for review once these have been accepted and merged, as it's really a bit orthogonal to the whole RATP logic.
Another different w.r.t. v1 apart from addressing the comments is the review is that I made the RATP i2c support depend on CONFIG_I2C and the RATP GPIO support on CONFIG_GENERIC_GPIO. That was missing, and was breaking build if RATP was selected but no i2c or GPIO support was included in the build.
Comments welcome!
Aleksander Morgado (7):
ratp: implement i2c read/write support
bbremote: implement i2c read/write support
ratp: implement support for GPIO commands
bbremote: implement support for GPIO operations
ratp: use __packed instead of the full form
ratp: use pr_ macros to print messages
ratp: fix incorrect whitespaces in method calls
common/ratp/Kconfig | 15 ++ common/ratp/Makefile | 2 + common/ratp/getenv.c | 12 +- common/ratp/gpio.c | 144 ++++++++++++++++++ common/ratp/i2c.c | 284 +++++++++++++++++++++++++++++++++++ common/ratp/md.c | 24 +-- common/ratp/mw.c | 24 +-- common/ratp/reset.c | 10 +- include/ratp_bb.h | 10 ++ scripts/remote/controller.py | 60 ++++++++ scripts/remote/main.py | 74 +++++++++ scripts/remote/messages.py | 179 ++++++++++++++++++++++ 12 files changed, 806 insertions(+), 32 deletions(-) create mode 100644 common/ratp/gpio.c create mode 100644 common/ratp/i2c.c
Signature · 7 lines
2.19.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/7 ratp: implement i2c read/write support
Introduce two new RATP commands that allow running i2c read/write operations, very similar in format to the already existing md/mw RATP commands.
The messages are defined with a fixed 16-bit long register field, but it will only be treated as a 16-bit address if I2C_FLAG_WIDE_ADDRESS is set in the message flags field. If this flag is unset, the start register address is assumed 8-bit long.
If the message includes the I2C_FLAG_MASTER_MODE flag, the start register field is ignored and a i2c master send/receive operation is performed.
--- common/ratp/Kconfig | 7 ++ common/ratp/Makefile | 1 + common/ratp/i2c.c | 284 +++++++++++++++++++++++++++++++++++++++++++ include/ratp_bb.h | 4 + 4 files changed, 296 insertions(+) create mode 100644 common/ratp/i2c.c
common/ratp/Kconfig +7 -0
@@ -12,3 +12,10 @@ config CONSOLE_RATP this option adds a machine readable interface for controlling barebox. Say yes here if you want to control barebox from a remote host. +config RATP_CMD_I2C + bool + depends on RATP + depends on I2C + prompt "RATP i2c support" + help + This option adds support for i2c read/write commands via RATP.
common/ratp/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-y += getenv.o obj-y += md.o obj-y += mw.o obj-y += reset.o +obj-$(CONFIG_RATP_CMD_I2C) += i2c.o
common/ratp/i2c.c new file +284 -0
284 lines not on this page · raw message
include/ratp_bb.h +4 -0
@@ -17,6 +17,10 @@#define BB_RATP_TYPE_MW 12#define BB_RATP_TYPE_MW_RETURN 13#define BB_RATP_TYPE_RESET 14 +#define BB_RATP_TYPE_I2C_READ 15 +#define BB_RATP_TYPE_I2C_READ_RETURN 16 +#define BB_RATP_TYPE_I2C_WRITE 17 +#define BB_RATP_TYPE_I2C_WRITE_RETURN 18struct ratp_bb {uint16_t type;
Signature · 7 lines
2.19.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/7 bbremote: implement i2c read/write support
In reply to Aleksander MorgadoExtend the bbremote script with operations to perform binary i2c read/write operations.
E.g.:
barebox:/ i2c_read -b 0 -a 0x68 -r 0x06A0 -c 4 -w
0x8f 0x30 0x00 0x00
barebox:/ i2c_write -b 0 -a 0x68 -r 0x06A0 -w 0x87 0x30 0x00 0x00
barebox:/ i2c_read -b 0 -a 0x68 -r 0x06A0 -c 4 -w
0x87 0x30 0x00 0x00
barebox:/ i2c_write -b 0 -a 0x68 -r 0x06A0 -w 0x8f 0x30 0x00 0x00
barebox:/ i2c_read -b 0 -a 0x68 -r 0x06A0 -c 4 -w
0x8f 0x30 0x00 0x00
===================================================================
$ ./scripts/bbremote --port /dev/ttyUSB2 i2c-read 0x00 0x68 0x06A0 0x01 4
8f300000
$ ./scripts/bbremote --port /dev/ttyUSB2 i2c-write 0x00 0x68 0x06A0 0x01 "87300000"
4 bytes written
$ ./scripts/bbremote --port /dev/ttyUSB2 i2c-read 0x00 0x68 0x06A0 0x01 4
87300000
$ ./scripts/bbremote --port /dev/ttyUSB2 i2c-write 0x00 0x68 0x06A0 0x01 "8f300000"
4 bytes written
$ ./scripts/bbremote --port /dev/ttyUSB2 i2c-read 0x00 0x68 0x06A0 0x01 4
8f300000--- scripts/remote/controller.py | 24 ++++++++++ scripts/remote/main.py | 37 ++++++++++++++++ scripts/remote/messages.py | 86 ++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+)
scripts/remote/controller.py +24 -0
@@ -61,6 +61,18 @@ def unpack(data): elif p_type == BBType.reset: logging.debug("received: reset") return BBPacketReset(raw=data) + elif p_type == BBType.i2c_read: + logging.debug("received: i2c_read") + return BBPacketI2cRead(raw=data) + elif p_type == BBType.i2c_read_return: + logging.debug("received: i2c_read_return") + return BBPacketI2cReadReturn(raw=data) + elif p_type == BBType.i2c_write: + logging.debug("received: i2c_write") + return BBPacketI2cWrite(raw=data) + elif p_type == BBType.i2c_write_return: + logging.debug("received: i2c_write_return") + return BBPacketI2cWriteReturn(raw=data) else: logging.debug("received: UNKNOWN") return BBPacket(raw=data)
@@ -139,6 +151,18 @@ class Controller(Thread): logging.info("Mw return: %r", r) return (r.exit_code,r.written) + def i2c_read(self, bus, addr, reg, flags, size): + self._send(BBPacketI2cRead(bus=bus, addr=addr, reg=reg, flags=flags, size=size)) + r = self._expect(BBPacketI2cReadReturn) + logging.info("i2c read return: %r", r) + return (r.exit_code,r.data) + + def i2c_write(self, bus, addr, reg, flags, data): + self._send(BBPacketI2cWrite(bus=bus, addr=addr, reg=reg, flags=flags, data=data)) + r = self._expect(BBPacketI2cWriteReturn) + logging.info("i2c write return: %r", r) + return (r.exit_code,r.written) + def reset(self, force): self._send(BBPacketReset(force=force))
scripts/remote/main.py +37 -0
@@ -98,6 +98,27 @@ def handle_mw(args): return res +def handle_i2c_read(args): + ctrl = get_controller(args) + (res,data) = ctrl.i2c_read(args.bus, args.address, args.reg, args.flags, args.size) + if res == 0: + print(binascii.hexlify(data)) + ctrl.close() + return res + + +def handle_i2c_write(args): + ctrl = get_controller(args) + data=args.data + if ((len(data) % 2) != 0): + data="0"+data + (res,written) = ctrl.i2c_write(args.bus, args.address, args.reg, args.flags, binascii.unhexlify(data)) + if res == 0: + print("%i bytes written" % written) + ctrl.close() + return res + + def handle_reset(args): ctrl = get_controller(args) ctrl.reset(args.force)
@@ -188,6 +209,22 @@ parser_mw.add_argument('address', type=auto_int, help="address") parser_mw.add_argument('data', help="data") parser_mw.set_defaults(func=handle_mw) +parser_i2c_read = subparsers.add_parser('i2c-read', help="run i2c read command") +parser_i2c_read.add_argument('bus', type=auto_int, help="bus") +parser_i2c_read.add_argument('address', type=auto_int, help="address") +parser_i2c_read.add_argument('reg', type=auto_int, help="reg") +parser_i2c_read.add_argument('flags', type=auto_int, help="flags") +parser_i2c_read.add_argument('size', type=auto_int, help="size") +parser_i2c_read.set_defaults(func=handle_i2c_read) + +parser_i2c_write = subparsers.add_parser('i2c-write', help="run i2c write command") +parser_i2c_write.add_argument('bus', type=auto_int, help="bus") +parser_i2c_write.add_argument('address', type=auto_int, help="address") +parser_i2c_write.add_argument('reg', type=auto_int, help="reg") +parser_i2c_write.add_argument('flags', type=auto_int, help="flags") +parser_i2c_write.add_argument('data', help="data") +parser_i2c_write.set_defaults(func=handle_i2c_write) + parser_reset = subparsers.add_parser('reset', help="run reset command") parser_reset_force = parser_reset.add_mutually_exclusive_group(required=False) parser_reset_force.add_argument('--force', dest='force', action='store_true')
scripts/remote/messages.py +86 -0
95 lines not on this page · raw message
Signature · 7 lines
2.19.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/7 ratp: implement support for GPIO commands
In reply to Aleksander MorgadoIntroduce three new RATP commands that allow getting and setting GPIO values as well as configuring the direction of the GPIO pins.
--- common/ratp/Kconfig | 10 ++- common/ratp/Makefile | 1 + common/ratp/gpio.c | 144 +++++++++++++++++++++++++++++++++++++++++++ include/ratp_bb.h | 6 ++ 4 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 common/ratp/gpio.c
common/ratp/Kconfig +9 -1
@@ -18,4 +18,12 @@ config RATP_CMD_I2C depends on I2C prompt "RATP i2c support" help - This option adds support for i2c read/write commands via RATP. + This option adds support for i2c read/write commands via RATP. + +config RATP_CMD_GPIO + bool + depends on RATP + depends on GENERIC_GPIO + prompt "RATP GPIO support" + help + This option adds support for GPIO get/set/direction commands via RATP.
common/ratp/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-y += md.o obj-y += mw.o obj-y += reset.o obj-$(CONFIG_RATP_CMD_I2C) += i2c.o +obj-$(CONFIG_RATP_CMD_GPIO) += gpio.o
common/ratp/gpio.c new file +144 -0
144 lines not on this page · raw message
include/ratp_bb.h +6 -0
@@ -21,6 +21,12 @@#define BB_RATP_TYPE_I2C_READ_RETURN 16#define BB_RATP_TYPE_I2C_WRITE 17#define BB_RATP_TYPE_I2C_WRITE_RETURN 18 +#define BB_RATP_TYPE_GPIO_GET_VALUE 19 +#define BB_RATP_TYPE_GPIO_GET_VALUE_RETURN 20 +#define BB_RATP_TYPE_GPIO_SET_VALUE 21 +#define BB_RATP_TYPE_GPIO_SET_VALUE_RETURN 22 +#define BB_RATP_TYPE_GPIO_SET_DIRECTION 23 +#define BB_RATP_TYPE_GPIO_SET_DIRECTION_RETURN 24struct ratp_bb {uint16_t type;
Signature · 7 lines
2.19.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 4/7 bbremote: implement support for GPIO operations
In reply to Aleksander Morgado--- scripts/remote/controller.py | 36 ++++++++++++++ scripts/remote/main.py | 37 ++++++++++++++ scripts/remote/messages.py | 93 ++++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+)
scripts/remote/controller.py +36 -0
@@ -73,6 +73,24 @@ def unpack(data): elif p_type == BBType.i2c_write_return: logging.debug("received: i2c_write_return") return BBPacketI2cWriteReturn(raw=data) + elif p_type == BBType.gpio_get_value: + logging.debug("received: gpio_get_value") + return BBPacketGpioGetValue(raw=data) + elif p_type == BBType.gpio_get_value_return: + logging.debug("received: gpio_get_value_return") + return BBPacketGpioGetValueReturn(raw=data) + elif p_type == BBType.gpio_set_value: + logging.debug("received: gpio_set_value") + return BBPacketGpioSetValue(raw=data) + elif p_type == BBType.gpio_set_value_return: + logging.debug("received: gpio_set_value_return") + return BBPacketGpioSetValueReturn(raw=data) + elif p_type == BBType.gpio_set_direction: + logging.debug("received: gpio_set_direction") + return BBPacketGpioSetDirection(raw=data) + elif p_type == BBType.gpio_set_direction_return: + logging.debug("received: gpio_set_direction_return") + return BBPacketGpioSetDirectionReturn(raw=data) else: logging.debug("received: UNKNOWN") return BBPacket(raw=data)
@@ -163,6 +181,24 @@ class Controller(Thread): logging.info("i2c write return: %r", r) return (r.exit_code,r.written) + def gpio_get_value(self, gpio): + self._send(BBPacketGpioGetValue(gpio=gpio)) + r = self._expect(BBPacketGpioGetValueReturn) + logging.info("gpio get value return: %r", r) + return r.value + + def gpio_set_value(self, gpio, value): + self._send(BBPacketGpioSetValue(gpio=gpio, value=value)) + r = self._expect(BBPacketGpioSetValueReturn) + logging.info("gpio set value return: %r", r) + return 0 + + def gpio_set_direction(self, gpio, direction, value): + self._send(BBPacketGpioSetDirection(gpio=gpio, direction=direction, value=value)) + r = self._expect(BBPacketGpioSetDirectionReturn) + logging.info("gpio set direction return: %r", r) + return r.exit_code + def reset(self, force): self._send(BBPacketReset(force=force))
scripts/remote/main.py +37 -0
@@ -119,6 +119,28 @@ def handle_i2c_write(args): return res +def handle_gpio_get_value(args): + ctrl = get_controller(args) + value = ctrl.gpio_get_value(args.gpio) + print ("%u" % value); + ctrl.close() + return 0 + + +def handle_gpio_set_value(args): + ctrl = get_controller(args) + ctrl.gpio_set_value(args.gpio, args.value) + ctrl.close() + return 0 + + +def handle_gpio_set_direction(args): + ctrl = get_controller(args) + res = ctrl.gpio_set_direction(args.gpio, args.direction, args.value) + ctrl.close() + return res + + def handle_reset(args): ctrl = get_controller(args) ctrl.reset(args.force)
@@ -225,6 +247,21 @@ parser_i2c_write.add_argument('flags', type=auto_int, help="flags") parser_i2c_write.add_argument('data', help="data") parser_i2c_write.set_defaults(func=handle_i2c_write) +parser_gpio_get_value = subparsers.add_parser('gpio-get-value', help="run gpio get value command") +parser_gpio_get_value.add_argument('gpio', type=auto_int, help="gpio") +parser_gpio_get_value.set_defaults(func=handle_gpio_get_value) + +parser_gpio_set_value = subparsers.add_parser('gpio-set-value', help="run gpio set value command") +parser_gpio_set_value.add_argument('gpio', type=auto_int, help="gpio") +parser_gpio_set_value.add_argument('value', type=auto_int, help="value") +parser_gpio_set_value.set_defaults(func=handle_gpio_set_value) + +parser_gpio_set_direction = subparsers.add_parser('gpio-set-direction', help="run gpio set direction command") +parser_gpio_set_direction.add_argument('gpio', type=auto_int, help="gpio") +parser_gpio_set_direction.add_argument('direction', type=auto_int, help="direction (0: input, 1: output)") +parser_gpio_set_direction.add_argument('value', type=auto_int, help="value (if output)") +parser_gpio_set_direction.set_defaults(func=handle_gpio_set_direction) + parser_reset = subparsers.add_parser('reset', help="run reset command") parser_reset_force = parser_reset.add_mutually_exclusive_group(required=False) parser_reset_force.add_argument('--force', dest='force', action='store_true')
scripts/remote/messages.py +93 -0
102 lines not on this page · raw message
Signature · 7 lines
2.19.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 5/7 ratp: use __packed instead of the full form
In reply to Aleksander MorgadoJust a minor coding style change to follow the suggestions given in patch reviews for other RATP commands.
--- common/ratp/md.c | 4 ++-- common/ratp/mw.c | 4 ++-- common/ratp/reset.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
common/ratp/md.c +2 -2
@@ -46,7 +46,7 @@ struct ratp_bb_md_request {uint16_t path_size;uint16_t path_offset;uint8_t buffer[]; -} __attribute__((packed)); +} __packed;struct ratp_bb_md_response {struct ratp_bb header;
@@ -55,7 +55,7 @@ struct ratp_bb_md_response {uint16_t data_size;uint16_t data_offset;uint8_t buffer[]; -} __attribute__((packed)); +} __packed;extern char *mem_rw_buf;
common/ratp/mw.c +2 -2
@@ -47,7 +47,7 @@ struct ratp_bb_mw_request {uint16_t data_size;uint16_t data_offset;uint8_t buffer[]; -} __attribute__((packed)); +} __packed;struct ratp_bb_mw_response {struct ratp_bb header;
@@ -55,7 +55,7 @@ struct ratp_bb_mw_response {uint32_t errno;uint16_t written;uint8_t buffer[]; -} __attribute__((packed)); +} __packed;static int ratp_cmd_mw (const struct ratp_bb *req,int req_len,struct ratp_bb **rsp,int *rsp_len)
common/ratp/reset.c +1 -1
@@ -27,7 +27,7 @@struct ratp_bb_reset {struct ratp_bb header;uint8_t force; -} __attribute__((packed)); +} __packed;static int ratp_cmd_reset (const struct ratp_bb *req,int req_len,struct ratp_bb **rsp,int *rsp_len)
Signature · 7 lines
2.19.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 6/7 ratp: use pr_ macros to print messages
In reply to Aleksander MorgadoFollowing suggestions in other patch reviews, the RAPT commands are updated to use pr_err() instead of plain printf() to report errors to the user.
--- common/ratp/md.c | 12 +++++++----- common/ratp/mw.c | 14 ++++++++------ common/ratp/reset.c | 6 ++++-- 3 files changed, 19 insertions(+), 13 deletions(-)
common/ratp/md.c +7 -5
@@ -15,6 +15,8 @@* */ +#define pr_fmt (fmt) "barebox-ratp: md: " fmt +#include <common.h> #include <ratp_bb.h> #include <init.h>
@@ -121,7 +123,7 @@ static int ratp_cmd_md(const struct ratp_bb *req, int req_len,/* At least message header should be valid */ if (req_len <sizeof (*md_req)) { -printf ("ratp md ignored: size mismatch (%d < %zu)\n" , +pr_err ("ignored: size mismatch (%d < %zu)\n" , req_len,sizeof (*md_req)); ret = -EINVAL ; goto out;
@@ -130,7 +132,7 @@ static int ratp_cmd_md(const struct ratp_bb *req, int req_len,/* Validate buffer position and size */ buffer_offset =be16_to_cpu (md_req->buffer_offset);if (req_len < buffer_offset) { -printf ("ratp md ignored: invalid buffer offset (%d < %hu)\n" , +pr_err ("ignored: invalid buffer offset (%d < %hu)\n" , req_len, buffer_offset); ret = -EINVAL ; goto out;
@@ -141,20 +143,20 @@ static int ratp_cmd_md(const struct ratp_bb *req, int req_len,/* Validate path position and size */ path_offset =be16_to_cpu (md_req->path_offset);if (path_offset !=0 ) { -printf ("ratp md ignored: invalid path offset\n" ); +pr_err ("ignored: invalid path offset\n" ); ret = -EINVAL ; goto out; } path_size =be16_to_cpu (md_req->path_size);if (!path_size) { -printf ("ratp md ignored: no filepath given\n" ); +pr_err ("ignored: no filepath given\n" ); ret = -EINVAL ; goto out; }/* Validate buffer size */ if (buffer_size < path_size) { -printf ("ratp mw ignored: size mismatch (%d < %hu): path may not be fully given\n" , +pr_err ("ignored: size mismatch (%d < %hu): path may not be fully given\n" , req_len, path_size); ret = -EINVAL ; goto out;
common/ratp/mw.c +8 -6
@@ -16,6 +16,8 @@* */ +#define pr_fmt (fmt) "barebox-ratp: mw: " fmt +#include <common.h> #include <ratp_bb.h> #include <init.h>
@@ -77,7 +79,7 @@ static int ratp_cmd_mw(const struct ratp_bb *req, int req_len,/* At least message header should be valid */ if (req_len <sizeof (*mw_req)) { -printf ("ratp mw ignored: size mismatch (%d < %zu)\n" , +pr_err ("ignored: size mismatch (%d < %zu)\n" , req_len,sizeof (*mw_req)); ret = -EINVAL ; goto out;
@@ -86,7 +88,7 @@ static int ratp_cmd_mw(const struct ratp_bb *req, int req_len,/* Validate buffer position and size */ buffer_offset =be16_to_cpu (mw_req->buffer_offset);if (req_len < buffer_offset) { -printf ("ratp mw ignored: invalid buffer offset (%d < %hu)\n" , +pr_err ("ignored: invalid buffer offset (%d < %hu)\n" , req_len, buffer_offset); ret = -EINVAL ; goto out;
@@ -97,13 +99,13 @@ static int ratp_cmd_mw(const struct ratp_bb *req, int req_len,/* Validate path position and size */ path_offset =be16_to_cpu (mw_req->path_offset);if (path_offset !=0 ) { -printf ("ratp mw ignored: invalid path offset\n" ); +pr_err ("ignored: invalid path offset\n" ); ret = -EINVAL ; goto out; } path_size =be16_to_cpu (mw_req->path_size);if (!path_size) { -printf ("ratp mw ignored: no filepath given\n" ); +pr_err ("ignored: no filepath given\n" ); ret = -EINVAL ; goto out; }
@@ -111,7 +113,7 @@ static int ratp_cmd_mw(const struct ratp_bb *req, int req_len,/* Validate data position and size */ data_offset =be16_to_cpu (mw_req->data_offset);if (data_offset != (path_offset + path_size)) { -printf ("ratp mw ignored: invalid path offset\n" ); +pr_err ("ignored: invalid path offset\n" ); ret = -EINVAL ; goto out; }
@@ -123,7 +125,7 @@ static int ratp_cmd_mw(const struct ratp_bb *req, int req_len,/* Validate buffer size */ if (buffer_size < (path_size + data_size)) { -printf ("ratp mw ignored: size mismatch (%d < %hu): path or data not be fully given\n" , +pr_err ("ignored: size mismatch (%d < %hu): path or data not be fully given\n" , req_len, path_size + data_size); ret = -EINVAL ; goto out;
common/ratp/reset.c +4 -2
@@ -17,6 +17,8 @@* */ +#define pr_fmt (fmt) "barebox-ratp: reset: " fmt +#include <common.h> #include <command.h> #include <ratp_bb.h>
@@ -35,11 +37,11 @@ static int ratp_cmd_reset(const struct ratp_bb *req, int req_len,struct ratp_bb_reset *reset_req = (struct ratp_bb_reset *)req;if (req_len <sizeof (*reset_req)) { -printf ("ratp reset ignored: size mismatch (%d < %zu)\n" , req_len,sizeof (*reset_req)); +pr_err ("ignored: size mismatch (%d < %zu)\n" , req_len,sizeof (*reset_req));return 2 ; } -debug ("running reset %s\n" , reset_req->force ?"(forced)" :"" ); +pr_debug ("running %s\n" , reset_req->force ?"(forced)" :"" );if (!reset_req->force)shutdown_barebox ();
Signature · 7 lines
2.19.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 7/7 ratp: fix incorrect whitespaces in method calls
In reply to Aleksander MorgadoThis is a simple coding style fix to avoid the whitespace before the open-parenthesis in method calls.
--- common/ratp/getenv.c | 12 ++++++------ common/ratp/md.c | 8 ++++---- common/ratp/mw.c | 6 +++--- common/ratp/reset.c | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-)
common/ratp/getenv.c +6 -6
@@ -27,20 +27,20 @@static int ratp_cmd_getenv (const struct ratp_bb *req,int req_len,struct ratp_bb **rsp,int *rsp_len) { -int dlen = req_len -sizeof (struct ratp_bb ); +int dlen = req_len -sizeof (struct ratp_bb );char *varname;const char *value; - varname =xstrndup ((const char *)req->data, dlen); - value =getenv (varname); -free (varname); + varname =xstrndup ((const char *)req->data, dlen); + value =getenv (varname); +free (varname); - dlen =strlen (value); + dlen =strlen (value); *rsp_len =sizeof (struct ratp_bb ) + dlen; *rsp =xzalloc (*rsp_len); (*rsp)->type =cpu_to_be16 (BB_RATP_TYPE_GETENV_RETURN ); -memcpy ((*rsp)->data, value, dlen); +memcpy ((*rsp)->data, value, dlen);return 0 ; }
common/ratp/md.c +4 -4
@@ -124,7 +124,7 @@ static int ratp_cmd_md(const struct ratp_bb *req, int req_len,/* At least message header should be valid */ if (req_len <sizeof (*md_req)) {pr_err ("ignored: size mismatch (%d < %zu)\n" , - req_len,sizeof (*md_req)); + req_len,sizeof (*md_req)); ret = -EINVAL ; goto out; }
@@ -162,8 +162,8 @@ static int ratp_cmd_md(const struct ratp_bb *req, int req_len, goto out; } - addr =be16_to_cpu (md_req->addr); - size =be16_to_cpu (md_req->size); + addr =be16_to_cpu (md_req->addr); + size =be16_to_cpu (md_req->size); path =xstrndup ((const char *)&buffer[path_offset], path_size); out:
@@ -193,7 +193,7 @@ out: *rsp = (struct ratp_bb *)md_rsp; *rsp_len = md_rsp_len; -free (path); +free (path);return ret; }
common/ratp/mw.c +3 -3
@@ -80,7 +80,7 @@ static int ratp_cmd_mw(const struct ratp_bb *req, int req_len,/* At least message header should be valid */ if (req_len <sizeof (*mw_req)) {pr_err ("ignored: size mismatch (%d < %zu)\n" , - req_len,sizeof (*mw_req)); + req_len,sizeof (*mw_req)); ret = -EINVAL ; goto out; }
@@ -131,7 +131,7 @@ static int ratp_cmd_mw(const struct ratp_bb *req, int req_len, goto out; } - addr =be16_to_cpu (mw_req->addr); + addr =be16_to_cpu (mw_req->addr); path =xstrndup ((const char *)&buffer[path_offset], path_size); fd =open_and_lseek (path,O_RWSIZE_1 |O_WRONLY , addr);
@@ -164,7 +164,7 @@ out: *rsp = (struct ratp_bb *)mw_rsp; *rsp_len =sizeof (*mw_rsp); -free (path); +free (path);return ret; }
common/ratp/reset.c +2 -2
@@ -36,8 +36,8 @@ static int ratp_cmd_reset(const struct ratp_bb *req, int req_len, {struct ratp_bb_reset *reset_req = (struct ratp_bb_reset *)req; -if (req_len <sizeof (*reset_req)) { -pr_err ("ignored: size mismatch (%d < %zu)\n" , req_len,sizeof (*reset_req)); +if (req_len <sizeof (*reset_req)) { +pr_err ("ignored: size mismatch (%d < %zu)\n" , req_len,sizeof (*reset_req));return 2 ; }
Signature · 7 lines
2.19.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 8 lines · Aleksander Morgado
This series of patches implements support for i2c and GPIO operations via RATP.
It addresses most of the comments from the first series review, except for Sascha's suggestion to implement name resolving for the i2c buses and Andrey's suggestion to prepare a new helper method to initialize the
i2c_clientstructure. I already have a patch for the latter, but will send it for review once these have been accepted and merged, as it's really a bit orthogonal to the whole RATP logic.Another different w.r.t. v1 apart from addressing the comments is the review is that I made the RATP i2c support depend on
CONFIG_I2Cand the RATP GPIO support onCONFIG_GENERIC_GPIO. That was missing, and was breaking build if RATP was selected but no i2c or GPIO support was included in the build.Comments welcome!
Quoted 8 lines
Aleksander Morgado (7):
ratp: implement i2c read/write support
bbremote: implement i2c read/write support
ratp: implement support for GPIO commands
bbremote: implement support for GPIO operations
ratp: use__packedinstead of the full form
ratp: usepr_macros to print messages
ratp: fix incorrect whitespaces in method calls
Applied, thanks
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox