From patchwork Sat Aug 20 19:15:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 110784 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 55E77B6F7C for ; Sun, 21 Aug 2011 05:15:41 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B924D2807E; Sat, 20 Aug 2011 21:15:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cYxwc0m2KQJX; Sat, 20 Aug 2011 21:15:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 012FF280AB; Sat, 20 Aug 2011 21:15:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37D0828091 for ; Sat, 20 Aug 2011 21:15:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K+r+x6jaIXDC for ; Sat, 20 Aug 2011 21:15:23 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by theia.denx.de (Postfix) with ESMTPS id 107902807E for ; Sat, 20 Aug 2011 21:15:21 +0200 (CEST) Received: by fxe6 with SMTP id 6so2591694fxe.3 for ; Sat, 20 Aug 2011 12:15:21 -0700 (PDT) Received: by 10.223.56.129 with SMTP id y1mr1108164fag.33.1313867721367; Sat, 20 Aug 2011 12:15:21 -0700 (PDT) Received: from mashiro.lan ([188.175.35.25]) by mx.google.com with ESMTPS id d1sm3632992fai.4.2011.08.20.12.15.19 (version=SSLv3 cipher=OTHER); Sat, 20 Aug 2011 12:15:20 -0700 (PDT) From: Marek Vasut To: u-boot@lists.denx.de Date: Sat, 20 Aug 2011 21:15:13 +0200 Message-Id: <1313867713-20949-2-git-send-email-marek.vasut@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1313867713-20949-1-git-send-email-marek.vasut@gmail.com> References: <1313867713-20949-1-git-send-email-marek.vasut@gmail.com> Subject: [U-Boot] [PATCH 2/2 V2] IDE: Fix complaints about strict aliasing in cmd_ide.c X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Marek Vasut Acked-by: Mike Frysinger --- common/cmd_ide.c | 51 +++++++++++++++++++++++++-------------------------- 1 files changed, 25 insertions(+), 26 deletions(-) V2: Fix comment, drop alignment diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 2e8c6e0..da5189c 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -985,9 +985,8 @@ input_data(int dev, ulong *sect_buf, int words) */ static void ide_ident (block_dev_desc_t *dev_desc) { - ulong iobuf[ATA_SECTORWORDS]; unsigned char c; - hd_driveid_t *iop = (hd_driveid_t *)iobuf; + hd_driveid_t iop; #ifdef CONFIG_ATAPI int retries = 0; @@ -1073,11 +1072,11 @@ static void ide_ident (block_dev_desc_t *dev_desc) return; #endif - input_swap_data (device, iobuf, ATA_SECTORWORDS); + input_swap_data (device, (ulong *)&iop, ATA_SECTORWORDS); - ident_cpy ((unsigned char*)dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision)); - ident_cpy ((unsigned char*)dev_desc->vendor, iop->model, sizeof(dev_desc->vendor)); - ident_cpy ((unsigned char*)dev_desc->product, iop->serial_no, sizeof(dev_desc->product)); + ident_cpy ((unsigned char*)dev_desc->revision, iop.fw_rev, sizeof(dev_desc->revision)); + ident_cpy ((unsigned char*)dev_desc->vendor, iop.model, sizeof(dev_desc->vendor)); + ident_cpy ((unsigned char*)dev_desc->product, iop.serial_no, sizeof(dev_desc->product)); #ifdef __LITTLE_ENDIAN /* * firmware revision, model, and serial number have Big Endian Byte @@ -1092,14 +1091,14 @@ static void ide_ident (block_dev_desc_t *dev_desc) strswab (dev_desc->product); #endif /* __LITTLE_ENDIAN */ - if ((iop->config & 0x0080)==0x0080) + if ((iop.config & 0x0080) == 0x0080) dev_desc->removable = 1; else dev_desc->removable = 0; #ifdef CONFIG_TUNE_PIO /* Mode 0 - 2 only, are directly determined by word 51. */ - pio_mode = iop->tPIO; + pio_mode = iop.tPIO; if (pio_mode > 2) { printf("WARNING: Invalid PIO (word 51 = %d).\n", pio_mode); pio_mode = 0; /* Force it to dead slow, and hope for the best... */ @@ -1109,18 +1108,18 @@ static void ide_ident (block_dev_desc_t *dev_desc) * shall set bit 1 of word 53 to one and support the fields contained * in words 64 through 70. */ - if (iop->field_valid & 0x02) { + if (iop.field_valid & 0x02) { /* Mode 3 and above are possible. Check in order from slow * to fast, so we wind up with the highest mode allowed. */ - if (iop->eide_pio_modes & 0x01) + if (iop.eide_pio_modes & 0x01) pio_mode = 3; - if (iop->eide_pio_modes & 0x02) + if (iop.eide_pio_modes & 0x02) pio_mode = 4; - if (ata_id_is_cfa((u16 *)iop)) { - if ((iop->cf_advanced_caps & 0x07) == 0x01) + if (ata_id_is_cfa((u16 *)&iop)) { + if ((iop.cf_advanced_caps & 0x07) == 0x01) pio_mode = 5; - if ((iop->cf_advanced_caps & 0x07) == 0x02) + if ((iop.cf_advanced_caps & 0x07) == 0x02) pio_mode = 6; } } @@ -1133,19 +1132,19 @@ static void ide_ident (block_dev_desc_t *dev_desc) /* * Drive PIO mode autoselection */ - mode = iop->tPIO; + mode = iop.tPIO; printf ("tPIO = 0x%02x = %d\n",mode, mode); if (mode > 2) { /* 2 is maximum allowed tPIO value */ mode = 2; debug ("Override tPIO -> 2\n"); } - if (iop->field_valid & 2) { /* drive implements ATA2? */ + if (iop.field_valid & 2) { /* drive implements ATA2? */ debug ("Drive implements ATA2\n"); - if (iop->capability & 8) { /* drive supports use_iordy? */ - cycle_time = iop->eide_pio_iordy; + if (iop.capability & 8) { /* drive supports use_iordy? */ + cycle_time = iop.eide_pio_iordy; } else { - cycle_time = iop->eide_pio; + cycle_time = iop.eide_pio; } debug ("cycle time = %d\n", cycle_time); mode = 4; @@ -1166,7 +1165,7 @@ static void ide_ident (block_dev_desc_t *dev_desc) #ifdef __BIG_ENDIAN /* swap shorts */ - dev_desc->lba = (iop->lba_capacity << 16) | (iop->lba_capacity >> 16); + dev_desc->lba = (iop.lba_capacity << 16) | (iop.lba_capacity >> 16); #else /* ! __BIG_ENDIAN */ /* * do not swap shorts on little endian @@ -1174,16 +1173,16 @@ static void ide_ident (block_dev_desc_t *dev_desc) * See CF+ and CompactFlash Specification Revision 2.0: * 6.2.1.6: Identfy Drive, Table 39, Word Address 57-58 for details. */ - dev_desc->lba = iop->lba_capacity; + dev_desc->lba = iop.lba_capacity; #endif /* __BIG_ENDIAN */ #ifdef CONFIG_LBA48 - if (iop->command_set_2 & 0x0400) { /* LBA 48 support */ + if (iop.command_set_2 & 0x0400) { /* LBA 48 support */ dev_desc->lba48 = 1; - dev_desc->lba = (unsigned long long)iop->lba48_capacity[0] | - ((unsigned long long)iop->lba48_capacity[1] << 16) | - ((unsigned long long)iop->lba48_capacity[2] << 32) | - ((unsigned long long)iop->lba48_capacity[3] << 48); + dev_desc->lba = (unsigned long long)iop.lba48_capacity[0] | + ((unsigned long long)iop.lba48_capacity[1] << 16) | + ((unsigned long long)iop.lba48_capacity[2] << 32) | + ((unsigned long long)iop.lba48_capacity[3] << 48); } else { dev_desc->lba48 = 0; }