[Pdbg] [PATCH 1/3] libpdbg: use i2ctools lib
Alistair Popple
alistair at popple.id.au
Mon Apr 15 13:56:32 AEST 2019
> --- a/libpdbg/libpdbg.h
> +++ b/libpdbg/libpdbg.h
> @@ -123,6 +123,9 @@ struct pdbg_target *pdbg_address_absolute(struct
> pdbg_target *target, uint64_t * int fsi_read(struct pdbg_target *target,
> uint32_t addr, uint32_t *val); int fsi_write(struct pdbg_target *target,
> uint32_t addr, uint32_t val);
>
> +int i2c_read(struct pdbg_target *target, uint16_t port, uint32_t addr,
> + uint16_t size, uint8_t *data);
I don't think you need the `port` argument but I will address that in comments
for the next patch. The fixes to this patch look pretty good.
<snip>
> +uint8_t *parse_number8(const char *argv)
Is this function actually used? From a review nit-pick perspective it would be
nice if adding the parser was split into a seperate patch. It's probably also
worth noting that a I2C device address is limited to 7-bits ;-)
> +{
> + unsigned long long tmp;
> + uint8_t *n = malloc(sizeof(*n));
> + char *endptr;
> +
> + if (!argv)
> + return NULL;
> +
> + errno = 0;
> + tmp = strtoul(argv, &endptr, 0);
> + if (errno || *endptr != '\0' || tmp > UINT8_MAX)
> + return NULL;
> +
> + *n = tmp;
> + return n;
> +}
> +
> /* Parse an 8-bit number that is a power of 2 */
> uint8_t *parse_number8_pow2(const char *argv)
> {
> diff --git a/src/parsers.h b/src/parsers.h
> index ba52178..27ada1f 100644
> --- a/src/parsers.h
> +++ b/src/parsers.h
> @@ -9,6 +9,7 @@
> #define DATA (parse_number64, NULL)
> #define DATA32 (parse_number32, NULL)
> #define DATA16 (parse_number16, NULL)
> +#define DATA8 (parse_number8, NULL)
> #define DEFAULT_DATA(default) (parse_number64, default)
> #define GPR (parse_gpr, NULL)
> #define SPR (parse_spr, NULL)
> @@ -16,6 +17,7 @@
> uint64_t *parse_number64(const char *argv);
> uint32_t *parse_number32(const char *argv);
> uint16_t *parse_number16(const char *argv);
> +uint8_t *parse_number8(const char *argv);
> uint8_t *parse_number8_pow2(const char *argv);
> int *parse_gpr(const char *argv);
> int *parse_spr(const char *argv);
More information about the Pdbg
mailing list