From a7c32c59a04044e70612b3ea598ab51b2cff3174 Mon Sep 17 00:00:00 2001 From: Daniel Kirkham Date: Sat, 12 May 2012 19:32:38 +1000 Subject: [PATCH] EEPROM max_power build/decode inconsistency Hello all, As promised, below is a patchset to make eeprom->max_power consistently express power (current) requirements in milliamperes. I've also updated my AUTHOR address. Regards, Daniel -- From 9e854c8111dba11ea71166e22ca464b474156150 Mon Sep 17 00:00:00 2001 From: Daniel Kirkham Date: Sat, 12 May 2012 19:23:57 +1000 Subject: [PATCH] Fix to make eeprom->max_power consistently express power (current) requirements in milliamperes. Updated AUTHOR address --- AUTHORS | 2 +- src/ftdi.c | 6 +++--- src/ftdi_i.h | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index aad2fe7..9762dc3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,7 +13,7 @@ see Changelog for full details: Aurelien Jarno Chris Zeh Clifford Wolf - Daniel Kirkham + Daniel Kirkham David Challis Emil Evan Nemerson diff --git a/src/ftdi.c b/src/ftdi.c index 8650be2..07687e8 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2577,7 +2577,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) output[0x08] = j; // Addr 09: Max power consumption: max power = value * 2 mA - output[0x09] = eeprom->max_power>>1; + output[0x09] = eeprom->max_power / MAX_POWER_MILLIAMP_PER_UNIT; if (ftdi->type != TYPE_AM) { @@ -3048,7 +3048,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) eeprom->remote_wakeup = buf[0x08] & 0x20; // Addr 09: Max power consumption: max power = value * 2 mA - eeprom->max_power = buf[0x09]; + eeprom->max_power = MAX_POWER_MILLIAMP_PER_UNIT * buf[0x09]; // Addr 0A: Chip configuration // Bit 7: 0 - reserved @@ -3264,7 +3264,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) if (eeprom->self_powered) fprintf(stdout, "Self-Powered%s", (eeprom->remote_wakeup)?", USB Remote Wake Up\n":"\n"); else - fprintf(stdout, "Bus Powered: %3d mA%s", eeprom->max_power * 2, + fprintf(stdout, "Bus Powered: %3d mA%s", eeprom->max_power, (eeprom->remote_wakeup)?" USB Remote Wake Up\n":"\n"); if (eeprom->manufacturer) fprintf(stdout, "Manufacturer: %s\n",eeprom->manufacturer); diff --git a/src/ftdi_i.h b/src/ftdi_i.h index 8d8c77e..1427f05 100644 --- a/src/ftdi_i.h +++ b/src/ftdi_i.h @@ -21,6 +21,9 @@ /* Even on 93xx66 at max 256 bytes are used (AN_121)*/ #define FTDI_MAX_EEPROM_SIZE 256 +/** Max Power adjustment factor. */ +#define MAX_POWER_MILLIAMP_PER_UNIT 2 + /** \brief FTDI eeprom structure */ -- 1.7.1