[coreboot-gerrit] Change in coreboot[master]: southbridge/amd/cimx/sb900: Fix coding style
Elyes HAOUAS (Code Review)
gerrit at coreboot.org
Sat Feb 3 01:08:34 CET 2018
Elyes HAOUAS has uploaded this change for review. ( https://review.coreboot.org/23579
Change subject: southbridge/amd/cimx/sb900: Fix coding style
......................................................................
southbridge/amd/cimx/sb900: Fix coding style
Change-Id: I5448004da37db02ba3ae5ac2677bfcf45b12418d
Signed-off-by: Elyes HAOUAS <ehaouas at noos.fr>
---
M src/southbridge/amd/cimx/sb900/smbus_spd.c
1 file changed, 73 insertions(+), 92 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/79/23579/1
diff --git a/src/southbridge/amd/cimx/sb900/smbus_spd.c b/src/southbridge/amd/cimx/sb900/smbus_spd.c
index 3fd4439..2f766e3 100644
--- a/src/southbridge/amd/cimx/sb900/smbus_spd.c
+++ b/src/southbridge/amd/cimx/sb900/smbus_spd.c
@@ -35,29 +35,20 @@
#define SMBUS_BASE_ADDR 0xB00
-STATIC
-VOID
-WritePmReg (
- IN UINT8 Reg,
- IN UINT8 Data
- )
+static void WritePmReg(int Reg, int Data)
{
- __outbyte (0xCD6, Reg);
- __outbyte (0xCD7, Data);
+ __outbyte(0xCD6, Reg);
+ __outbyte(0xCD7, Data);
}
-STATIC
-VOID
-SetupFch (
- IN UINT16
- IN IoBase
- )
+
+static void SetupFch(int IoBase)
{
- WritePmReg (0x2D, IoBase >> 8);
- WritePmReg (0x2C, IoBase | 1);
- WritePmReg (0x29, 0x80);
- WritePmReg (0x28, 0x61);
- /* set SMBus clock to 400 KHz */
- __outbyte (IoBase + 0x0E, 66000000 / 400000 / 4);
+ WritePmReg(0x2D, IoBase >> 8);
+ WritePmReg(0x2C, IoBase | 1);
+ WritePmReg(0x29, 0x80);
+ WritePmReg(0x28, 0x61);
+ /* set SMBus clock to 400 KHz */
+ __outbyte(IoBase + 0x0E, 66000000 / 400000 / 4);
}
/*
@@ -66,40 +57,37 @@
*
*/
-STATIC
-AGESA_STATUS
-ReadSmbusByteData (
- IN UINT16 Iobase,
- IN UINT8 Address,
- OUT UINT8 *Buffer,
- IN UINTN Offset
- )
+static int ReadSmbusByteData(int Iobase, int Address, char *Buffer, int Offset)
{
- UINTN Status;
- UINT64 Limit;
+ unsigned int Status;
+ UINT64 Limit;
- Address |= 1; // set read bit
+ Address |= 1; // set read bit
- __outbyte (Iobase + 0, 0xFF); // clear error status
- __outbyte (Iobase + 1, 0x1F); // clear error status
- __outbyte (Iobase + 3, Offset); // offset in eeprom
- __outbyte (Iobase + 4, Address); // slave address and read bit
- __outbyte (Iobase + 2, 0x48); // read byte command
+ __outbyte(Iobase + 0, 0xFF); // clear error status
+ __outbyte(Iobase + 1, 0x1F); // clear error status
+ __outbyte(Iobase + 3, Offset); // offset in eeprom
+ __outbyte(Iobase + 4, Address); // slave address and read bit
+ __outbyte(Iobase + 2, 0x48); // read byte command
- /* time limit to avoid hanging for unexpected error status (should never happen) */
- Limit = __rdtsc () + 2000000000 / 10;
- for (;;) {
- Status = __inbyte (Iobase);
- if (__rdtsc () > Limit) break;
- if ((Status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
- if ((Status & 1) == 1) continue; // HostBusy set, keep waiting
- break;
- }
+ /* time limit to avoid hanging for unexpected error status (should never happen) */
+ Limit = __rdtsc() + 2000000000 / 10;
+ for (;;) {
+ Status = __inbyte(Iobase);
+ if (__rdtsc() > Limit)
+ break;
+ if ((Status & 2) == 0)
+ continue; // SMBusInterrupt not set, keep waiting
+ if ((Status & 1) == 1)
+ continue; // HostBusy set, keep waiting
+ break;
+ }
- Buffer [0] = __inbyte (Iobase + 5);
- if (Status == 2) Status = 0; // check for done with no errors
- return Status;
- }
+ Buffer [0] = __inbyte(Iobase + 5);
+ if (Status == 2)
+ Status = 0; // check for done with no errors
+ return Status;
+}
/*
*
@@ -108,33 +96,31 @@
*
*/
-STATIC
-AGESA_STATUS
-ReadSmbusByte (
- IN UINT16 Iobase,
- IN UINT8 Address,
- OUT UINT8 *Buffer
- )
+static int ReadSmbusByte(int Iobase, int Address, char *Buffer)
{
- UINTN Status;
- UINT64 Limit;
+ unsigned int Status;
+ UINT64 Limit;
- __outbyte (Iobase + 0, 0xFF); // clear error status
- __outbyte (Iobase + 2, 0x44); // read command
+ __outbyte(Iobase + 0, 0xFF); // clear error status
+ __outbyte(Iobase + 2, 0x44); // read command
- // time limit to avoid hanging for unexpected error status
- Limit = __rdtsc () + 2000000000 / 10;
- for (;;) {
- Status = __inbyte (Iobase);
- if (__rdtsc () > Limit) break;
- if ((Status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
- if ((Status & 1) == 1) continue; // HostBusy set, keep waiting
- break;
- }
+ // time limit to avoid hanging for unexpected error status
+ Limit = __rdtsc() + 2000000000 / 10;
+ for (;;) {
+ Status = __inbyte(Iobase);
+ if (__rdtsc() > Limit)
+ break;
+ if ((Status & 2) == 0)
+ continue; // SMBusInterrupt not set, keep waiting
+ if ((Status & 1) == 1)
+ continue; // HostBusy set, keep waiting
+ break;
+ }
- Buffer [0] = __inbyte (Iobase + 5);
- if (Status == 2) Status = 0; // check for done with no errors
- return Status;
+ Buffer [0] = __inbyte(Iobase + 5);
+ if (Status == 2)
+ Status = 0; // check for done with no errors
+ return Status;
}
/*
@@ -147,31 +133,26 @@
*
*/
-STATIC
-AGESA_STATUS
-ReadSpd (
- IN UINT16 IoBase,
- IN UINT8 SmbusSlaveAddress,
- OUT UINT8 *Buffer,
- IN UINTN Count
- )
+static int ReadSpd(int IoBase, int SmbusSlaveAddress, char *Buffer, int Count)
{
- UINTN Index, Status;
+ int Index, Status;
- /* read the first byte using offset zero */
- Status = ReadSmbusByteData (IoBase, SmbusSlaveAddress, Buffer, 0);
- if (Status) return Status;
+ /* read the first byte using offset zero */
+ Status = ReadSmbusByteData(IoBase, SmbusSlaveAddress, Buffer, 0);
+ if (Status)
+ return Status;
- /* read the remaining bytes using auto-increment for speed */
- for (Index = 1; Index < Count; Index++){
- Status = ReadSmbusByte (IoBase, SmbusSlaveAddress, &Buffer [Index]);
- if (Status) return Status;
- }
- return 0;
+ /* read the remaining bytes using auto-increment for speed */
+ for (Index = 1; Index < Count; Index++){
+ Status = ReadSmbusByte(IoBase, SmbusSlaveAddress, &Buffer [Index]);
+ if (Status)
+ return Status;
+ }
+ return 0;
}
int smbus_readSpd(int spdAddress, char *buf, size_t len)
{
- SetupFch (SMBUS_BASE_ADDR);
- return ReadSpd (SMBUS_BASE_ADDR, spdAddress, (UINT8 *) buf, len);
+ SetupFch(SMBUS_BASE_ADDR);
+ return ReadSpd(SMBUS_BASE_ADDR, spdAddress, buf, len);
}
--
To view, visit https://review.coreboot.org/23579
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5448004da37db02ba3ae5ac2677bfcf45b12418d
Gerrit-Change-Number: 23579
Gerrit-PatchSet: 1
Gerrit-Owner: Elyes HAOUAS <ehaouas at noos.fr>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180203/cf30f9a4/attachment-0001.html>
More information about the coreboot-gerrit
mailing list