]> git.sur5r.net Git - u-boot/blobdiff - board/w7o/vpd.c
mx51evk: Fix CONFIG_SYS_FSL_ESDHC_ADDR
[u-boot] / board / w7o / vpd.c
index d248c97bfefd7abc626a4a685acb12974802192b..fbcc3944dc5fa71cfe674e34cd07e3e903f4297e 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2001
  * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #if defined(VXWORKS)
@@ -165,8 +149,8 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf)
                printf("Error: VPD EEPROM 0x%x missing CRC\n", dev_addr);
                return 0;
        }
-       stored_crc16 = *((ushort *) packet->data);
-       *(ushort *) packet->data = 0;
+       memcpy(&stored_crc16, packet->data, sizeof(ushort));
+       memset(packet->data, 0, sizeof(ushort));
 
        /* OK, lets calculate the CRC and check it */
 #if defined(VXWORKS)
@@ -175,7 +159,7 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf)
        calc_crc16 = (0xffff & crc32(0, buf, num_bytes));
 #endif
        /* Now restore the CRC */
-       *(ushort *) packet->data = stored_crc16;
+       memcpy(packet->data, &stored_crc16, sizeof(ushort));
        if (stored_crc16 != calc_crc16) {
                printf("Error: VPD EEPROM 0x%x has bad CRC 0x%x\n",
                       dev_addr, stored_crc16);
@@ -277,8 +261,9 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo)
                        break;
                case VPD_PID_SN:
                        if (size_ok(packet, sizeof(unsigned long))) {
-                               vpdInfo->serialNum =
-                                       *(unsigned long *) packet->data;
+                               memcpy(&vpdInfo->serialNum,
+                                       packet->data,
+                                       sizeof(unsigned long));
                        }
                        break;
                case VPD_PID_MANID:
@@ -287,19 +272,22 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo)
                        break;
                case VPD_PID_PCO:
                        if (size_ok(packet, sizeof(unsigned long))) {
-                               vpdInfo->configOpt =
-                                       *(unsigned long *) packet->data;
+                               memcpy(&vpdInfo->configOpt,
+                                       packet->data,
+                                       sizeof(unsigned long));
                        }
                        break;
                case VPD_PID_SYSCLK:
                        if (size_ok(packet, sizeof(unsigned long)))
-                               vpdInfo->sysClk =
-                                       *(unsigned long *) packet->data;
+                               memcpy(&vpdInfo->sysClk,
+                                       packet->data,
+                                       sizeof(unsigned long));
                        break;
                case VPD_PID_SERCLK:
                        if (size_ok(packet, sizeof(unsigned long)))
-                               vpdInfo->serClk =
-                                       *(unsigned long *) packet->data;
+                               memcpy(&vpdInfo->serClk,
+                                       packet->data,
+                                       sizeof(unsigned long));
                        break;
                case VPD_PID_FLASH:
                        if (size_ok(packet, 9)) {       /* XXX - hardcoded,