aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo
diff options
context:
space:
mode:
authorKeith <keith@rhizomatica.org>2018-03-29 13:11:45 +0200
committerKeith <keith@rhizomatica.org>2018-04-03 11:35:44 +0200
commit091fcf147ae83d8daec92b2506d14e5e5ad35f80 (patch)
tree3616a0d6792ddb66f2d17eb5bd1a0c87b891cd94 /src/osmo-bts-sysmo
parentf038b735209b48734b39484e15b4391a8db6652c (diff)
osmo-bts-sysmo eeprom.c Restore ability to read/write EEPROM
This commit restores ability to read write to the SuperFemto EEPROM. Use offsetof() instead of casts to pointers when calculating the address to pass to eeprom_read() and eeprom_write() Fixes: 7cf144b27d75fadfb4ec65019985bb10660a066a Change-Id: Iaa7318387ad7bb248c261b1f428019244039e7d2
Diffstat (limited to 'src/osmo-bts-sysmo')
-rw-r--r--src/osmo-bts-sysmo/eeprom.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/osmo-bts-sysmo/eeprom.c b/src/osmo-bts-sysmo/eeprom.c
index a7f3d77a..472b78e2 100644
--- a/src/osmo-bts-sysmo/eeprom.c
+++ b/src/osmo-bts-sysmo/eeprom.c
@@ -59,6 +59,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <stddef.h>
#include <string.h>
#include "eeprom.h"
@@ -495,7 +496,7 @@ eeprom_Error_t eeprom_ReadSysInfo( eeprom_SysInfo_t *pSysInfo )
case EEPROM_HDR_V2:
{
// Get a copy of the EEPROM section
- err = eeprom_read( EEPROM_CFG_START_ADDR + ((uint32_t*)&ee.cfg.v1.sysInfo - (uint32_t*)&ee), sizeof(ee.cfg.v1.sysInfo), (char *)&ee.cfg.v1.sysInfo );
+ err = eeprom_read( EEPROM_CFG_START_ADDR + offsetof(eeprom_Cfg_t, cfg.v1.sysInfo), sizeof(ee.cfg.v1.sysInfo), (char *)&ee.cfg.v1.sysInfo );
if ( err != sizeof(ee.cfg.v1.sysInfo) )
{
PERROR( "Error while reading the EEPROM content (%d)\n", err );
@@ -602,7 +603,7 @@ eeprom_Error_t eeprom_WriteSysInfo( const eeprom_SysInfo_t *pSysInfo )
ee.cfg.v1.sysInfo.u16Crc = eeprom_crc( (uint8_t *)&ee.cfg.v1.sysInfo.u32Time, sizeof(ee.cfg.v1.sysInfo) - 2 * sizeof(uint16_t) );
// Write it to the EEPROM
- err = eeprom_write( EEPROM_CFG_START_ADDR + ((uint32_t*)&ee.cfg.v1.sysInfo - (uint32_t*)&ee), sizeof(ee.cfg.v1.sysInfo), (const char *) &ee.cfg.v1.sysInfo );
+ err = eeprom_write( EEPROM_CFG_START_ADDR + offsetof(eeprom_Cfg_t, cfg.v1.sysInfo), sizeof(ee.cfg.v1.sysInfo), (const char *) &ee.cfg.v1.sysInfo );
if ( err != sizeof(ee.cfg.v1.sysInfo) )
{
PERROR( "Error while writing to the EEPROM (%d)\n", err );
@@ -660,7 +661,7 @@ eeprom_Error_t eeprom_ReadRfClockCal( eeprom_RfClockCal_t *pRfClockCal )
case EEPROM_HDR_V2:
{
// Get a copy of the EEPROM section
- err = eeprom_read( EEPROM_CFG_START_ADDR + ((uint32_t*)&ee.cfg.v1.rfClk - (uint32_t*)&ee), sizeof(ee.cfg.v1.rfClk), (char *)&ee.cfg.v1.rfClk );
+ err = eeprom_read( EEPROM_CFG_START_ADDR + offsetof(eeprom_Cfg_t, cfg.v1.rfClk), sizeof(ee.cfg.v1.rfClk), (char *)&ee.cfg.v1.rfClk );
if ( err != sizeof(ee.cfg.v1.rfClk) )
{
PERROR( "Error while reading the EEPROM content (%d)\n", err );
@@ -755,7 +756,7 @@ eeprom_Error_t eeprom_WriteRfClockCal( const eeprom_RfClockCal_t *pRfClockCal )
ee.cfg.v1.rfClk.u16Crc = eeprom_crc( (uint8_t *)&ee.cfg.v1.rfClk.u32Time, sizeof(ee.cfg.v1.rfClk) - 2 * sizeof(uint16_t) );
// Write it to the EEPROM
- err = eeprom_write( EEPROM_CFG_START_ADDR + ((uint32_t*)&ee.cfg.v1.rfClk - (uint32_t*)&ee), sizeof(ee.cfg.v1.rfClk), (const char *) &ee.cfg.v1.rfClk );
+ err = eeprom_write( EEPROM_CFG_START_ADDR + offsetof(eeprom_Cfg_t, cfg.v1.rfClk), sizeof(ee.cfg.v1.rfClk), (const char *) &ee.cfg.v1.rfClk );
if ( err != sizeof(ee.cfg.v1.rfClk) )
{
PERROR( "Error while writing to the EEPROM (%d)\n", err );
@@ -1099,7 +1100,7 @@ eeprom_Error_t eeprom_WriteTxCal( int iBand, const eeprom_TxCal_t *pTxCal )
pCfgTxCal->u16Crc = eeprom_crc( (uint8_t *)&pCfgTxCal->u32Time, size - 2 * sizeof(uint16_t) );
// Write it to the EEPROM
- err = eeprom_write( EEPROM_CFG_START_ADDR + ((uint32_t*)pCfgTxCal - (uint32_t*)&ee), size, (const char *)pCfgTxCal );
+ err = eeprom_write( EEPROM_CFG_START_ADDR + ((uint8_t*)pCfgTxCal - (uint8_t*)&ee), size, (const char *)pCfgTxCal );
if ( err != size )
{
PERROR( "Error while writing to the EEPROM (%d)\n", err );
@@ -1592,7 +1593,7 @@ eeprom_Error_t eeprom_WriteRxCal( int iBand, int iUplink, const eeprom_RxCal_t *
pCfgRxCal->u16Crc = eeprom_crc( (uint8_t *)&pCfgRxCal->u32Time, size - 2 * sizeof(uint16_t) );
// Write it to the EEPROM
- err = eeprom_write( EEPROM_CFG_START_ADDR + ((uint32_t*)pCfgRxCal - (uint32_t*)&ee), size, (const char *)pCfgRxCal );
+ err = eeprom_write( EEPROM_CFG_START_ADDR + ((uint8_t*)pCfgRxCal - (uint8_t*)&ee), size, (const char *)pCfgRxCal );
if ( err != size )
{
PERROR( "Error while writing to the EEPROM (%d)\n", err );