misc: i2c_eeprom: Add fallbacks
Add some fallback functions for when i2c_eeprom is disabled. This allows code to reference i2c_eeprom_* functions without needing to check whether support has been compiled in. Signed-off-by: Sean Anderson <sean.anderson@seco.com>
This commit is contained in:
parent
dda3b38920
commit
42f477f0ab
1 changed files with 24 additions and 0 deletions
|
@ -6,6 +6,8 @@
|
||||||
#ifndef __I2C_EEPROM
|
#ifndef __I2C_EEPROM
|
||||||
#define __I2C_EEPROM
|
#define __I2C_EEPROM
|
||||||
|
|
||||||
|
struct udevice;
|
||||||
|
|
||||||
struct i2c_eeprom_ops {
|
struct i2c_eeprom_ops {
|
||||||
int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size);
|
int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size);
|
||||||
int (*write)(struct udevice *dev, int offset, const uint8_t *buf,
|
int (*write)(struct udevice *dev, int offset, const uint8_t *buf,
|
||||||
|
@ -20,6 +22,7 @@ struct i2c_eeprom {
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(I2C_EEPROM)
|
||||||
/*
|
/*
|
||||||
* i2c_eeprom_read() - read bytes from an I2C EEPROM chip
|
* i2c_eeprom_read() - read bytes from an I2C EEPROM chip
|
||||||
*
|
*
|
||||||
|
@ -54,4 +57,25 @@ int i2c_eeprom_write(struct udevice *dev, int offset, const uint8_t *buf,
|
||||||
*/
|
*/
|
||||||
int i2c_eeprom_size(struct udevice *dev);
|
int i2c_eeprom_size(struct udevice *dev);
|
||||||
|
|
||||||
|
#else /* !I2C_EEPROM */
|
||||||
|
|
||||||
|
static inline int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf,
|
||||||
|
int size)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int i2c_eeprom_write(struct udevice *dev, int offset,
|
||||||
|
const uint8_t *buf, int size)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int i2c_eeprom_size(struct udevice *dev)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* I2C_EEPROM */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue