Skip to content

Commit

Permalink
Audit <flash.h> inclusion
Browse files Browse the repository at this point in the history
A large number of files include <flash.h> as it used to be how various
SPI flash related functions were found, or for other reasons entirely.
In order to migrate some further CONFIG symbols to Kconfig we need to
not include flash.h in cases where we don't have a NOR flash of some
sort enabled.  Furthermore, in cases where we are in common code and it
doesn't make sense to try and further refactor the code itself in to new
files we need to guard this inclusion.

Signed-off-by: Tom Rini <trini@konsulko.com>
  • Loading branch information
trini committed Aug 4, 2022
1 parent 1d3ecda commit 17ead04
Show file tree
Hide file tree
Showing 36 changed files with 24 additions and 45 deletions.
3 changes: 1 addition & 2 deletions board/atmel/at91sam9263ek/at91sam9263ek.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <common.h>
#include <debug_uart.h>
#include <flash.h>
#include <init.h>
#include <net.h>
#include <vsprintf.h>
Expand Down Expand Up @@ -140,7 +139,7 @@ static void at91sam9263ek_lcd_hw_init(void)
#include <version.h>

#ifdef CONFIG_MTD_NOR_FLASH
extern flash_info_t flash_info[];
#include <flash.h>
#endif

void lcd_show_board_info(void)
Expand Down
1 change: 0 additions & 1 deletion board/buffalo/lsxl/lsxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <command.h>
#include <env.h>
#include <env_internal.h>
#include <flash.h>
#include <init.h>
#include <net.h>
#include <malloc.h>
Expand Down
3 changes: 2 additions & 1 deletion board/freescale/common/fsl_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <common.h>
#include <dm.h>
#include <flash.h>
#include <fsl_validate.h>
#include <fsl_secboot_err.h>
#include <fsl_sfp.h>
Expand Down Expand Up @@ -79,6 +78,8 @@ static u32 check_ie(struct fsl_secboot_img_priv *img)
* address
*/
#if defined(CONFIG_MPC85xx)
#include <flash.h>

int get_csf_base_addr(u32 *csf_addr, u32 *flash_base_addr)
{
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Expand Down
1 change: 0 additions & 1 deletion board/gardena/smart-gateway-mt7688/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <command.h>
#include <env.h>
#include <env_internal.h>
#include <flash.h>
#include <init.h>
#include <led.h>
#include <log.h>
Expand Down
1 change: 0 additions & 1 deletion board/logicpd/omap3som/omap3logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <init.h>
#include <net.h>
#include <ns16550.h>
#include <flash.h>
#include <nand.h>
#include <i2c.h>
#include <serial.h>
Expand Down
1 change: 0 additions & 1 deletion board/siemens/taurus/taurus.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <common.h>
#include <dm.h>
#include <env.h>
#include <flash.h>
#include <init.h>
#include <asm/global_data.h>
#include <asm/io.h>
Expand Down
2 changes: 0 additions & 2 deletions board/socrates/socrates.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

DECLARE_GLOBAL_DATA_PTR;

extern flash_info_t flash_info[]; /* FLASH chips info */

void local_bus_init (void);
ulong flash_get_size (ulong base, int banknum);

Expand Down
2 changes: 2 additions & 0 deletions board/toradex/common/tdx-cfg-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include <cli.h>
#include <console.h>
#include <env.h>
#ifdef CONFIG_TDX_CFG_BLOCK_IS_IN_NOR
#include <flash.h>
#endif
#include <malloc.h>
#include <mmc.h>
#include <nand.h>
Expand Down
1 change: 0 additions & 1 deletion cmd/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ static int image_info(unsigned long addr);
#if defined(CONFIG_CMD_IMLS)
#include <flash.h>
#include <mtd/cfi_flash.h>
extern flash_info_t flash_info[]; /* info for FLASH chips */
#endif

#if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
# define DEBUGF(fmt, args...)
#endif

#include <flash.h>

#ifndef CONFIG_MTD_NOR_FLASH
# define OFFSET_ADJUSTMENT 0
#else
#include <flash.h>
# define OFFSET_ADJUSTMENT (flash_info[id.num].start[0])
#endif

Expand Down
1 change: 0 additions & 1 deletion cmd/cros_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <command.h>
#include <cros_ec.h>
#include <dm.h>
#include <flash.h>
#include <log.h>
#include <dm/device-internal.h>
#include <dm/uclass-internal.h>
Expand Down
1 change: 0 additions & 1 deletion cmd/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ int find_dev_and_part(const char *id, struct mtd_device **dev,
#ifdef CONFIG_MTD_NOR_FLASH
#include <flash.h>
#include <mtd/cfi_flash.h>
extern flash_info_t flash_info[]; /* info for FLASH chips */

/*
* The user interface starts numbering for Flash banks with 1
Expand Down
5 changes: 2 additions & 3 deletions cmd/jffs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
#include <common.h>
#include <command.h>
#include <env.h>
#if defined(CONFIG_CMD_FLASH)
#include <flash.h>
#endif
#include <image.h>
#include <malloc.h>
#include <jffs2/jffs2.h>
Expand Down Expand Up @@ -156,7 +158,6 @@ static int mtd_device_validate(u8 type, u8 num, u32 *size)
if (type == MTD_DEV_TYPE_NOR) {
#if defined(CONFIG_CMD_FLASH)
if (num < CONFIG_SYS_MAX_FLASH_BANKS) {
extern flash_info_t flash_info[];
*size = flash_info[num].size;

return 0;
Expand Down Expand Up @@ -260,8 +261,6 @@ static inline u32 get_part_sector_size_nand(struct mtdids *id)
static inline u32 get_part_sector_size_nor(struct mtdids *id, struct part_info *part)
{
#if defined(CONFIG_CMD_FLASH)
extern flash_info_t flash_info[];

u32 end_phys, start_phys, sector_size = 0, size = 0;
int i;
flash_info_t *flash;
Expand Down
2 changes: 2 additions & 0 deletions cmd/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include <efi_loader.h>
#include <env.h>
#include <exports.h>
#ifdef CONFIG_MTD_NOR_FLASH
#include <flash.h>
#endif
#include <image.h>
#include <lmb.h>
#include <mapmem.h>
Expand Down
2 changes: 2 additions & 0 deletions cmd/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include <cli.h>
#include <command.h>
#include <console.h>
#ifdef CONFIG_MTD_NOR_FLASH
#include <flash.h>
#endif
#include <hash.h>
#include <log.h>
#include <mapmem.h>
Expand Down
1 change: 0 additions & 1 deletion cmd/mvebu/bubt.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <common.h>
#include <command.h>
#include <env.h>
#include <flash.h>
#include <image.h>
#include <net.h>
#include <vsprintf.h>
Expand Down
1 change: 0 additions & 1 deletion cmd/sf.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <command.h>
#include <div64.h>
#include <dm.h>
#include <flash.h>
#include <log.h>
#include <malloc.h>
#include <mapmem.h>
Expand Down
2 changes: 2 additions & 0 deletions common/board_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include <bootstage.h>
#include <cpu_func.h>
#include <exports.h>
#ifdef CONFIG_MTD_NOR_FLASH
#include <flash.h>
#endif
#include <hang.h>
#include <image.h>
#include <irq_func.h>
Expand Down
2 changes: 0 additions & 2 deletions common/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <mtd/cfi_flash.h>

extern flash_info_t flash_info[]; /* info for FLASH chips */

/*-----------------------------------------------------------------------
* Functions
*/
Expand Down
5 changes: 2 additions & 3 deletions common/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@

#include <command.h>
#include <env.h>
#include <flash.h>
#include <net.h>
#include <net/tftp.h>
#include <malloc.h>
#include <mapmem.h>
#include <dfu.h>
#include <errno.h>
#include <mtd/cfi_flash.h>

#if defined(CONFIG_DFU_TFTP) || defined(CONFIG_UPDATE_TFTP)
/* env variable holding the location of the update file */
Expand All @@ -49,7 +47,8 @@
extern ulong tftp_timeout_ms;
extern int tftp_timeout_count_max;
#ifdef CONFIG_MTD_NOR_FLASH
extern flash_info_t flash_info[];
#include <flash.h>
#include <mtd/cfi_flash.h>
static uchar *saved_prot_info;
#endif
static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
Expand Down
1 change: 0 additions & 1 deletion drivers/dfu/dfu_sf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

#include <common.h>
#include <flash.h>
#include <malloc.h>
#include <errno.h>
#include <div64.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/fastboot/fb_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <fastboot-internal.h>
#include <fb_mmc.h>
#include <fb_nand.h>
#include <flash.h>
#include <part.h>
#include <stdlib.h>

Expand Down
1 change: 0 additions & 1 deletion drivers/fastboot/fb_mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <fastboot.h>
#include <fastboot-internal.h>
#include <fb_mmc.h>
#include <flash.h>
#include <image-sparse.h>
#include <image.h>
#include <log.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/fastboot/fb_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <config.h>
#include <common.h>
#include <blk.h>
#include <flash.h>

#include <fastboot.h>
#include <image-sparse.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/misc/cros_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <common.h>
#include <command.h>
#include <dm.h>
#include <flash.h>
#include <i2c.h>
#include <cros_ec.h>
#include <fdtdec.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/mtd/spi/sf_dataflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <dm.h>
#include <errno.h>
#include <fdtdec.h>
#include <flash.h>
#include <log.h>
#include <spi.h>
#include <spi_flash.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/mtd/spi/sf_mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

#include <common.h>
#include <flash.h>
#include <malloc.h>
#include <linux/errno.h>
#include <linux/mtd/mtd.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/mtd/spi/spi-nor-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/

#include <common.h>
#include <flash.h>
#include <log.h>
#include <watchdog.h>
#include <dm.h>
Expand Down
2 changes: 1 addition & 1 deletion env/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <command.h>
#include <env.h>
#include <env_internal.h>
#include <flash.h>
#include <log.h>
#include <asm/global_data.h>
#include <linux/stddef.h>
Expand All @@ -26,6 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;

#ifndef CONFIG_SPL_BUILD
# if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_FLASH)
# include <flash.h>
# define CMD_SAVEENV
# elif defined(CONFIG_ENV_ADDR_REDUND)
# error CONFIG_ENV_ADDR_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH
Expand Down
1 change: 0 additions & 1 deletion env/sf.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <dm.h>
#include <env.h>
#include <env_internal.h>
#include <flash.h>
#include <malloc.h>
#include <spi.h>
#include <spi_flash.h>
Expand Down
3 changes: 1 addition & 2 deletions fs/cramfs/cramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/

#include <common.h>
#include <flash.h>
#include <malloc.h>
#include <asm/byteorder.h>
#include <linux/stat.h>
Expand All @@ -43,7 +42,7 @@ struct cramfs_super super;
/* CPU address space offset calculation macro, struct part_info offset is
* device address space offset, so we need to shift it by a device start address. */
#if defined(CONFIG_MTD_NOR_FLASH)
extern flash_info_t flash_info[];
#include <flash.h>
#define PART_OFFSET(x) ((ulong)x->offset + \
flash_info[x->dev->id->num].start[0])
#else
Expand Down
4 changes: 2 additions & 2 deletions fs/jffs2/jffs2_1pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@

#include <common.h>
#include <config.h>
#include <flash.h>
#include <malloc.h>
#include <div64.h>
#include <linux/compiler.h>
Expand Down Expand Up @@ -381,6 +380,8 @@ static void put_fl_mem_onenand(void *buf)


#if defined(CONFIG_CMD_FLASH)
#include <flash.h>

/*
* Support for jffs2 on top of NOR-flash
*
Expand All @@ -392,7 +393,6 @@ static inline void *get_fl_mem_nor(u32 off, u32 size, void *ext_buf)
u32 addr = off;
struct mtdids *id = current_part->dev->id;

extern flash_info_t flash_info[];
flash_info_t *flash = &flash_info[id->num];

addr += flash->start[0];
Expand Down
5 changes: 1 addition & 4 deletions include/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#ifndef _FLASH_H_
#define _FLASH_H_

#ifndef CONFIG_SYS_MAX_FLASH_SECT
#define CONFIG_SYS_MAX_FLASH_SECT 512
#endif

/*-----------------------------------------------------------------------
* FLASH Info: contains chip specific data, per FLASH bank
*/
Expand Down Expand Up @@ -91,6 +87,7 @@ int flash_sect_erase(ulong addr_first, ulong addr_last);
int flash_sect_protect(int flag, ulong addr_first, ulong addr_last);
int flash_sect_roundb(ulong *addr);
unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect);
void flash_cmd_reset(flash_info_t *info);
void flash_set_verbose(uint v);

/* common/flash.c */
Expand Down
1 change: 0 additions & 1 deletion include/mtd/cfi_flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ extern int cfi_flash_num_flash_banks;

phys_addr_t cfi_flash_bank_addr(int i);
unsigned long cfi_flash_bank_size(int i);
void flash_cmd_reset(flash_info_t *info);

#ifdef CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS
void flash_write8(u8 value, void *addr);
Expand Down
2 changes: 2 additions & 0 deletions net/nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

#include <common.h>
#include <command.h>
#ifdef CONFIG_SYS_DIRECT_FLASH_NFS
#include <flash.h>
#endif
#include <image.h>
#include <log.h>
#include <net.h>
Expand Down
Loading

0 comments on commit 17ead04

Please sign in to comment.