[coreboot-gerrit] New patch to review for coreboot: c7d45e5 drivers/spi: Sanitize headers from preprocessor abuse

Edward O'Callaghan (eocallaghan@alterapraxis.com) gerrit at coreboot.org
Thu Jun 26 07:05:28 CEST 2014


Edward O'Callaghan (eocallaghan at alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6114

-gerrit

commit c7d45e5131644cb0c89930fcd9277fba7cd9ee12
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date:   Thu Jun 26 15:02:40 2014 +1000

    drivers/spi: Sanitize headers from preprocessor abuse
    
    Continuing on from the rational given in:
    
    a173a62 Remove guarding #includes by CONFIG_FOO combinations
    
    Change-Id: I35c636ee7c0b106323b3e4b90629f7262750f8bd
    Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
 src/drivers/spi/adesto.c             | 1 +
 src/drivers/spi/amic.c               | 1 +
 src/drivers/spi/eon.c                | 1 +
 src/drivers/spi/gigadevice.c         | 1 +
 src/drivers/spi/macronix.c           | 1 +
 src/drivers/spi/spansion.c           | 1 +
 src/drivers/spi/spi_flash.c          | 7 +++----
 src/drivers/spi/spi_flash_internal.h | 5 +++++
 src/drivers/spi/sst.c                | 1 +
 src/drivers/spi/stmicro.c            | 1 +
 src/drivers/spi/winbond.c            | 1 +
 src/include/cpu/x86/smm.h            | 7 ++++---
 12 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c
index 83be8b8..669050d 100644
--- a/src/drivers/spi/adesto.c
+++ b/src/drivers/spi/adesto.c
@@ -12,6 +12,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 /* at25dfxx-specific commands */
diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c
index fa17036..042efbe 100644
--- a/src/drivers/spi/amic.c
+++ b/src/drivers/spi/amic.c
@@ -10,6 +10,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 /* A25L-specific commands */
diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c
index 5a74b84..85567eb 100644
--- a/src/drivers/spi/eon.c
+++ b/src/drivers/spi/eon.c
@@ -6,6 +6,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 /* EN25Q128-specific commands */
diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c
index 5a8f82f..8cac2d4 100644
--- a/src/drivers/spi/gigadevice.c
+++ b/src/drivers/spi/gigadevice.c
@@ -28,6 +28,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 /* GD25Pxx-specific commands */
diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c
index bbc3704..602f7fc 100644
--- a/src/drivers/spi/macronix.c
+++ b/src/drivers/spi/macronix.c
@@ -31,6 +31,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 /* MX25xx-specific commands */
diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c
index 6dd6df9..fc96e40 100644
--- a/src/drivers/spi/spansion.c
+++ b/src/drivers/spi/spansion.c
@@ -27,6 +27,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 /* S25FLxx-specific commands */
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 33588d5..f13a5f8 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -7,14 +7,13 @@
  * Licensed under the GPL-2 or later.
  */
 
+#include <cpu/x86/smm.h>
+#include <delay.h>
 #include <stdlib.h>
 #include <string.h>
 #include <spi-generic.h>
 #include <spi_flash.h>
-#include <delay.h>
-#ifdef __SMM__
-#include <cpu/x86/smm.h>
-#endif
+
 #include "spi_flash_internal.h"
 
 static void spi_flash_addr(u32 addr, u8 *cmd)
diff --git a/src/drivers/spi/spi_flash_internal.h b/src/drivers/spi/spi_flash_internal.h
index e696948..6f18484 100644
--- a/src/drivers/spi/spi_flash_internal.h
+++ b/src/drivers/spi/spi_flash_internal.h
@@ -4,6 +4,9 @@
  * Copyright (C) 2008 Atmel Corporation
  */
 
+#ifndef SPI_FLASH_INTERNAL_H
+#define SPI_FLASH_INTERNAL_H
+
 /* Common parameters -- kind of high, but they should only occur when there
  * is a problem (and well your system already is broken), so err on the side
  * of caution in case we're dealing with slower SPI buses and/or processors.
@@ -83,3 +86,5 @@ struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi,
 					     u8 *idcode);
 struct spi_flash *spi_flash_probe_adesto(struct spi_slave *spi, u8 *idcode);
 struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode);
+
+#endif /* SPI_FLASH_INTERNAL_H */
diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c
index 3cf6c50..d81888a 100644
--- a/src/drivers/spi/sst.c
+++ b/src/drivers/spi/sst.c
@@ -14,6 +14,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 #define CMD_SST_WREN		0x06	/* Write Enable */
diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c
index af23853..b35851f 100644
--- a/src/drivers/spi/stmicro.c
+++ b/src/drivers/spi/stmicro.c
@@ -29,6 +29,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 /* M25Pxx-specific commands */
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index 52c7b61..029248f 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -6,6 +6,7 @@
 
 #include <stdlib.h>
 #include <spi_flash.h>
+
 #include "spi_flash_internal.h"
 
 /* M25Pxx-specific commands */
diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h
index f63420f..7b529e0 100644
--- a/src/include/cpu/x86/smm.h
+++ b/src/include/cpu/x86/smm.h
@@ -24,6 +24,9 @@
 #ifndef CPU_X86_SMM_H
 #define CPU_X86_SMM_H
 
+#include <arch/cpu.h>
+#include <types.h>
+
 #define SMM_DEFAULT_BASE 0x30000
 #define SMM_DEFAULT_SIZE 0x10000
 
@@ -33,8 +36,6 @@
 #define SMM_ENTRY_OFFSET 0x8000
 #define SMM_SAVE_STATE_BEGIN(x) (SMM_ENTRY_OFFSET + (x))
 
-#include <arch/cpu.h>
-#include <types.h>
 typedef struct {
 	u16	es_selector;
 	u16	es_attributes;
@@ -581,4 +582,4 @@ int smm_load_module(void *smram, int size, struct smm_loader_params *params);
 void *backup_default_smm_area(void);
 void restore_default_smm_area(void *smm_save_area);
 
-#endif
+#endif /* CPU_X86_SMM_H */



More information about the coreboot-gerrit mailing list