Commit 36dc98ed authored by André Breiler's avatar André Breiler Committed by Greg Kroah-Hartman

[PATCH] io_edgeport.c diff to fix endianess bugs

attached a fix for the io_edgeport usb serial driver
This diff fixes endianess issues which prevented the driver to work on
bigendian machines (e.g. sparc).
parent c67ed241
...@@ -522,7 +522,7 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) ...@@ -522,7 +522,7 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
case EDGE_DOWNLOAD_FILE_I930: case EDGE_DOWNLOAD_FILE_I930:
BootMajorVersion = BootCodeImageVersion_GEN1.MajorVersion; BootMajorVersion = BootCodeImageVersion_GEN1.MajorVersion;
BootMinorVersion = BootCodeImageVersion_GEN1.MinorVersion; BootMinorVersion = BootCodeImageVersion_GEN1.MinorVersion;
BootBuildNumber = BootCodeImageVersion_GEN1.BuildNumber; BootBuildNumber = cpu_to_le16(BootCodeImageVersion_GEN1.BuildNumber);
BootImage = &BootCodeImage_GEN1[0]; BootImage = &BootCodeImage_GEN1[0];
BootSize = sizeof( BootCodeImage_GEN1 ); BootSize = sizeof( BootCodeImage_GEN1 );
break; break;
...@@ -530,7 +530,7 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) ...@@ -530,7 +530,7 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
case EDGE_DOWNLOAD_FILE_80251: case EDGE_DOWNLOAD_FILE_80251:
BootMajorVersion = BootCodeImageVersion_GEN2.MajorVersion; BootMajorVersion = BootCodeImageVersion_GEN2.MajorVersion;
BootMinorVersion = BootCodeImageVersion_GEN2.MinorVersion; BootMinorVersion = BootCodeImageVersion_GEN2.MinorVersion;
BootBuildNumber = BootCodeImageVersion_GEN2.BuildNumber; BootBuildNumber = cpu_to_le16(BootCodeImageVersion_GEN2.BuildNumber);
BootImage = &BootCodeImage_GEN2[0]; BootImage = &BootCodeImage_GEN2[0];
BootSize = sizeof( BootCodeImage_GEN2 ); BootSize = sizeof( BootCodeImage_GEN2 );
break; break;
...@@ -542,26 +542,26 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) ...@@ -542,26 +542,26 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
// Check Boot Image Version // Check Boot Image Version
BootCurVer = (edge_serial->boot_descriptor.MajorVersion << 24) + BootCurVer = (edge_serial->boot_descriptor.MajorVersion << 24) +
(edge_serial->boot_descriptor.MinorVersion << 16) + (edge_serial->boot_descriptor.MinorVersion << 16) +
edge_serial->boot_descriptor.BuildNumber; le16_to_cpu(edge_serial->boot_descriptor.BuildNumber);
BootNewVer = (BootMajorVersion << 24) + BootNewVer = (BootMajorVersion << 24) +
(BootMinorVersion << 16) + (BootMinorVersion << 16) +
BootBuildNumber; le16_to_cpu(BootBuildNumber);
dbg("Current Boot Image version %d.%d.%d", dbg("Current Boot Image version %d.%d.%d",
edge_serial->boot_descriptor.MajorVersion, edge_serial->boot_descriptor.MajorVersion,
edge_serial->boot_descriptor.MinorVersion, edge_serial->boot_descriptor.MinorVersion,
edge_serial->boot_descriptor.BuildNumber); le16_to_cpu(edge_serial->boot_descriptor.BuildNumber));
if (BootNewVer > BootCurVer) { if (BootNewVer > BootCurVer) {
dbg("**Update Boot Image from %d.%d.%d to %d.%d.%d", dbg("**Update Boot Image from %d.%d.%d to %d.%d.%d",
edge_serial->boot_descriptor.MajorVersion, edge_serial->boot_descriptor.MajorVersion,
edge_serial->boot_descriptor.MinorVersion, edge_serial->boot_descriptor.MinorVersion,
edge_serial->boot_descriptor.BuildNumber, le16_to_cpu(edge_serial->boot_descriptor.BuildNumber),
BootMajorVersion, BootMajorVersion,
BootMinorVersion, BootMinorVersion,
BootBuildNumber); le16_to_cpu(BootBuildNumber));
dbg("Downloading new Boot Image"); dbg("Downloading new Boot Image");
...@@ -570,12 +570,12 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) ...@@ -570,12 +570,12 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
for (;;) { for (;;) {
record = (struct edge_firmware_image_record *)firmware; record = (struct edge_firmware_image_record *)firmware;
response = rom_write (edge_serial->serial, record->ExtAddr, record->Addr, record->Len, &record->Data[0]); response = rom_write (edge_serial->serial, le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len), &record->Data[0]);
if (response < 0) { if (response < 0) {
dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", record->ExtAddr, record->Addr, record->Len); dev_err(&edge_serial->serial->dev->dev, "rom_write failed (%x, %x, %d)\n", le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len));
break; break;
} }
firmware += sizeof (struct edge_firmware_image_record) + record->Len; firmware += sizeof (struct edge_firmware_image_record) + le16_to_cpu(record->Len);
if (firmware >= &BootImage[BootSize]) { if (firmware >= &BootImage[BootSize]) {
break; break;
} }
...@@ -678,12 +678,12 @@ static void get_product_info(struct edgeport_serial *edge_serial) ...@@ -678,12 +678,12 @@ static void get_product_info(struct edgeport_serial *edge_serial)
if (edge_serial->serial->dev->descriptor.idProduct & ION_DEVICE_ID_GENERATION_2) { if (edge_serial->serial->dev->descriptor.idProduct & ION_DEVICE_ID_GENERATION_2) {
product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN2.MajorVersion; product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN2.MajorVersion;
product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN2.MinorVersion; product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN2.MinorVersion;
product_info->FirmwareBuildNumber = OperationalCodeImageVersion_GEN2.BuildNumber; product_info->FirmwareBuildNumber = cpu_to_le16(OperationalCodeImageVersion_GEN2.BuildNumber);
product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251; product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251;
} else { } else {
product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN1.MajorVersion; product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN1.MajorVersion;
product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN1.MinorVersion; product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN1.MinorVersion;
product_info->FirmwareBuildNumber = OperationalCodeImageVersion_GEN1.BuildNumber; product_info->FirmwareBuildNumber = cpu_to_le16(OperationalCodeImageVersion_GEN1.BuildNumber);
product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930; product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930;
} }
...@@ -729,10 +729,10 @@ static void get_product_info(struct edgeport_serial *edge_serial) ...@@ -729,10 +729,10 @@ static void get_product_info(struct edgeport_serial *edge_serial)
dbg(" BoardRev %x", product_info->BoardRev); dbg(" BoardRev %x", product_info->BoardRev);
dbg(" BootMajorVersion %d.%d.%d", product_info->BootMajorVersion, dbg(" BootMajorVersion %d.%d.%d", product_info->BootMajorVersion,
product_info->BootMinorVersion, product_info->BootMinorVersion,
product_info->BootBuildNumber); le16_to_cpu(product_info->BootBuildNumber));
dbg(" FirmwareMajorVersion %d.%d.%d", product_info->FirmwareMajorVersion, dbg(" FirmwareMajorVersion %d.%d.%d", product_info->FirmwareMajorVersion,
product_info->FirmwareMinorVersion, product_info->FirmwareMinorVersion,
product_info->FirmwareBuildNumber); le16_to_cpu(product_info->FirmwareBuildNumber));
dbg(" ManufactureDescDate %d/%d/%d", product_info->ManufactureDescDate[0], dbg(" ManufactureDescDate %d/%d/%d", product_info->ManufactureDescDate[0],
product_info->ManufactureDescDate[1], product_info->ManufactureDescDate[1],
product_info->ManufactureDescDate[2]+1900); product_info->ManufactureDescDate[2]+1900);
...@@ -2326,7 +2326,7 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u ...@@ -2326,7 +2326,7 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u
__u16 current_length; __u16 current_length;
unsigned char *transfer_buffer; unsigned char *transfer_buffer;
// dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length);
transfer_buffer = kmalloc (64, GFP_KERNEL); transfer_buffer = kmalloc (64, GFP_KERNEL);
if (!transfer_buffer) { if (!transfer_buffer) {
...@@ -2811,12 +2811,13 @@ static void change_port_settings (struct edgeport_port *edge_port, struct termio ...@@ -2811,12 +2811,13 @@ static void change_port_settings (struct edgeport_port *edge_port, struct termio
* Turns a string from Unicode into ASCII. * Turns a string from Unicode into ASCII.
* Doesn't do a good job with any characters that are outside the normal * Doesn't do a good job with any characters that are outside the normal
* ASCII range, but it's only for debugging... * ASCII range, but it's only for debugging...
* NOTE: expects the unicode in LE format
****************************************************************************/ ****************************************************************************/
static void unicode_to_ascii (char *string, short *unicode, int unicode_size) static void unicode_to_ascii (char *string, short *unicode, int unicode_size)
{ {
int i; int i;
for (i = 0; i < unicode_size; ++i) { for (i = 0; i < unicode_size; ++i) {
string[i] = (char)(unicode[i]); string[i] = (char)(le16_to_cpu(unicode[i]));
} }
string[unicode_size] = 0x00; string[unicode_size] = 0x00;
} }
...@@ -2880,11 +2881,11 @@ static void get_boot_desc (struct edgeport_serial *edge_serial) ...@@ -2880,11 +2881,11 @@ static void get_boot_desc (struct edgeport_serial *edge_serial)
dev_err(&edge_serial->serial->dev->dev, "error in getting boot descriptor\n"); dev_err(&edge_serial->serial->dev->dev, "error in getting boot descriptor\n");
} else { } else {
dbg("**Boot Descriptor:"); dbg("**Boot Descriptor:");
dbg(" BootCodeLength: %d", edge_serial->boot_descriptor.BootCodeLength); dbg(" BootCodeLength: %d", le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength));
dbg(" MajorVersion: %d", edge_serial->boot_descriptor.MajorVersion); dbg(" MajorVersion: %d", edge_serial->boot_descriptor.MajorVersion);
dbg(" MinorVersion: %d", edge_serial->boot_descriptor.MinorVersion); dbg(" MinorVersion: %d", edge_serial->boot_descriptor.MinorVersion);
dbg(" BuildNumber: %d", edge_serial->boot_descriptor.BuildNumber); dbg(" BuildNumber: %d", le16_to_cpu(edge_serial->boot_descriptor.BuildNumber));
dbg(" Capabilities: 0x%x", edge_serial->boot_descriptor.Capabilities); dbg(" Capabilities: 0x%x", le16_to_cpu(edge_serial->boot_descriptor.Capabilities));
dbg(" UConfig0: %d", edge_serial->boot_descriptor.UConfig0); dbg(" UConfig0: %d", edge_serial->boot_descriptor.UConfig0);
dbg(" UConfig1: %d", edge_serial->boot_descriptor.UConfig1); dbg(" UConfig1: %d", edge_serial->boot_descriptor.UConfig1);
} }
...@@ -2936,12 +2937,12 @@ static void load_application_firmware (struct edgeport_serial *edge_serial) ...@@ -2936,12 +2937,12 @@ static void load_application_firmware (struct edgeport_serial *edge_serial)
for (;;) { for (;;) {
record = (struct edge_firmware_image_record *)firmware; record = (struct edge_firmware_image_record *)firmware;
response = sram_write (edge_serial->serial, record->ExtAddr, record->Addr, record->Len, &record->Data[0]); response = sram_write (edge_serial->serial, le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len), &record->Data[0]);
if (response < 0) { if (response < 0) {
dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", record->ExtAddr, record->Addr, record->Len); dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), record->Len);
break; break;
} }
firmware += sizeof (struct edge_firmware_image_record) + record->Len; firmware += sizeof (struct edge_firmware_image_record) + le16_to_cpu(record->Len);
if (firmware >= &FirmwareImage[ImageSize]) { if (firmware >= &FirmwareImage[ImageSize]) {
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment