global: Migrate CONFIG_STACKBASE to CFG
[platform/kernel/u-boot.git] / include / i2c_eeprom.h
index b96254a..32dcb03 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef __I2C_EEPROM
 #define __I2C_EEPROM
 
+struct udevice;
+
 struct i2c_eeprom_ops {
        int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size);
        int (*write)(struct udevice *dev, int offset, const uint8_t *buf,
@@ -16,12 +18,11 @@ struct i2c_eeprom_ops {
 struct i2c_eeprom {
        /* The EEPROM's page size in byte */
        unsigned long pagesize;
-       /* The EEPROM's page width in bits (pagesize = 2^pagewidth) */
-       unsigned pagewidth;
        /* The EEPROM's capacity in bytes */
        unsigned long size;
 };
 
+#if CONFIG_IS_ENABLED(I2C_EEPROM)
 /*
  * i2c_eeprom_read() - read bytes from an I2C EEPROM chip
  *
@@ -30,7 +31,7 @@ struct i2c_eeprom {
  * @buf:       Place to put data
  * @size:      Number of bytes to read
  *
- * @return 0 on success, -ve on failure
+ * Return: 0 on success, -ve on failure
  */
 int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size);
 
@@ -42,17 +43,39 @@ int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size);
  * @buf:       Buffer containing data to write
  * @size:      Number of bytes to write
  *
- * @return 0 on success, -ve on failure
+ * Return: 0 on success, -ve on failure
  */
-int i2c_eeprom_write(struct udevice *dev, int offset, uint8_t *buf, int size);
+int i2c_eeprom_write(struct udevice *dev, int offset, const uint8_t *buf,
+                    int size);
 
 /*
  * i2c_eeprom_size() - get size of I2C EEPROM chip
  *
  * @dev:       Chip to query
  *
- * @return +ve size in bytes on success, -ve on failure
+ * Return: +ve size in bytes on success, -ve on failure
  */
 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