mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 14:11:15 +02:00
parallel: Drop explicit fallback_chip_X boilerplate
A NULL func pointer is necessary and sufficient for the condition `NULL func pointer => fallback_chip_X' as to not need this explicit specification. Therefore drop the explicit need to specify these fallback callback function pointer in the par_master struct. This is a reasonable default for every driver in the tree. Furthermore, move the 'fallback_chip_X()' func from the generic programmer.c register logic into its relevant home of parallel.c and make static local to clean up link-time symbol space. This simplifies the code and driver development. Change-Id: If25c0048a07057aa72be6ffa8d8ad7f0a568dcf7 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/71745 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:

committed by
Edward O'Callaghan

parent
4ae3ac3062
commit
a031c81f51
51
programmer.c
51
programmer.c
@ -17,57 +17,6 @@
|
||||
#include "flash.h"
|
||||
#include "programmer.h"
|
||||
|
||||
/* Little-endian fallback for drivers not supporting 16 bit accesses */
|
||||
void fallback_chip_writew(const struct flashctx *flash, uint16_t val,
|
||||
chipaddr addr)
|
||||
{
|
||||
chip_writeb(flash, val & 0xff, addr);
|
||||
chip_writeb(flash, (val >> 8) & 0xff, addr + 1);
|
||||
}
|
||||
|
||||
/* Little-endian fallback for drivers not supporting 16 bit accesses */
|
||||
uint16_t fallback_chip_readw(const struct flashctx *flash, const chipaddr addr)
|
||||
{
|
||||
uint16_t val;
|
||||
val = chip_readb(flash, addr);
|
||||
val |= chip_readb(flash, addr + 1) << 8;
|
||||
return val;
|
||||
}
|
||||
|
||||
/* Little-endian fallback for drivers not supporting 32 bit accesses */
|
||||
void fallback_chip_writel(const struct flashctx *flash, uint32_t val,
|
||||
chipaddr addr)
|
||||
{
|
||||
chip_writew(flash, val & 0xffff, addr);
|
||||
chip_writew(flash, (val >> 16) & 0xffff, addr + 2);
|
||||
}
|
||||
|
||||
/* Little-endian fallback for drivers not supporting 32 bit accesses */
|
||||
uint32_t fallback_chip_readl(const struct flashctx *flash, const chipaddr addr)
|
||||
{
|
||||
uint32_t val;
|
||||
val = chip_readw(flash, addr);
|
||||
val |= chip_readw(flash, addr + 2) << 16;
|
||||
return val;
|
||||
}
|
||||
|
||||
void fallback_chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < len; i++)
|
||||
chip_writeb(flash, buf[i], addr + i);
|
||||
return;
|
||||
}
|
||||
|
||||
void fallback_chip_readn(const struct flashctx *flash, uint8_t *buf,
|
||||
chipaddr addr, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < len; i++)
|
||||
buf[i] = chip_readb(flash, addr + i);
|
||||
return;
|
||||
}
|
||||
|
||||
/* The limit of 4 is totally arbitrary. */
|
||||
#define MASTERS_MAX 4
|
||||
struct registered_master registered_masters[MASTERS_MAX];
|
||||
|
Reference in New Issue
Block a user