EEPROM max_power build/decode inconsistency
authorDaniel Kirkham <dk2@kirkham.id.au>
Sat, 12 May 2012 09:32:38 +0000 (19:32 +1000)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Tue, 15 May 2012 10:11:41 +0000 (12:11 +0200)
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 <dk2@kirkham.id.au>
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
src/ftdi.c
src/ftdi_i.h

diff --git a/AUTHORS b/AUTHORS
index aad2fe7..9762dc3 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -13,7 +13,7 @@ see Changelog for full details:
   Aurelien Jarno <aurelien@aurel32.net>
   Chris Zeh <chris.w.zeh@gmail.com>
   Clifford Wolf <clifford@clifford.at>
-  Daniel Kirkham <d.kirkham@telstra.com>
+  Daniel Kirkham <dk2@kirkham.id.au>
   David Challis <dchallis@qsimaging.com>
   Emil <emil@datel.co.uk>
   Evan Nemerson <evan@coeus-group.com>
index 8650be2..07687e8 100644 (file)
@@ -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);
index 8d8c77e..1427f05 100644 (file)
@@ -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
 */