i2c: Change the type of the data parameter to uint8_t.

Data is intended to be a byte array, so it should be described by a type which
has a fixed size equal to an 8 bit byte. Also, the data passed to write
shouldn't be modified and can be const.

Change-Id: I6466303d962998f6c37c2d4006a39c2d79a235c1
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Reviewed-on: http://review.coreboot.org/3721
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Gabe Black 2013-06-30 03:47:33 -07:00 committed by Stefan Reinauer
parent 3858b3f698
commit a5dc091129
3 changed files with 14 additions and 11 deletions

View File

@ -347,7 +347,7 @@ static int i2c_transfer(struct s3c24x0_i2c *i2c,
} }
int i2c_read(unsigned bus, unsigned chip, unsigned addr, int i2c_read(unsigned bus, unsigned chip, unsigned addr,
unsigned alen, unsigned char *buf, unsigned len) unsigned alen, uint8_t *buf, unsigned len)
{ {
struct s3c24x0_i2c_bus *i2c; struct s3c24x0_i2c_bus *i2c;
unsigned char xaddr[4]; unsigned char xaddr[4];
@ -376,7 +376,7 @@ int i2c_read(unsigned bus, unsigned chip, unsigned addr,
} }
int i2c_write(unsigned bus, unsigned chip, unsigned addr, int i2c_write(unsigned bus, unsigned chip, unsigned addr,
unsigned alen, unsigned char *buf, unsigned len) unsigned alen, const uint8_t *buf, unsigned len)
{ {
struct s3c24x0_i2c_bus *i2c; struct s3c24x0_i2c_bus *i2c;
unsigned char xaddr[4]; unsigned char xaddr[4];
@ -397,7 +397,7 @@ int i2c_write(unsigned bus, unsigned chip, unsigned addr,
i2c = &i2c_buses[bus]; i2c = &i2c_buses[bus];
ret = i2c_transfer(i2c->regs, I2C_WRITE, chip << 1, &xaddr[4 - alen], ret = i2c_transfer(i2c->regs, I2C_WRITE, chip << 1, &xaddr[4 - alen],
alen, buf, len); alen, (void *)buf, len);
return ret != 0; return ret != 0;
} }

View File

@ -408,7 +408,8 @@ static int hsi2c_wait_for_transfer(struct exynos5_hsi2c *i2c)
return 0; return 0;
} }
static int hsi2c_senddata(struct exynos5_hsi2c *i2c, uint8_t *data, int len) static int hsi2c_senddata(struct exynos5_hsi2c *i2c, const uint8_t *data,
int len)
{ {
while (!hsi2c_check_transfer(i2c) && len) { while (!hsi2c_check_transfer(i2c) && len) {
if (!(read32(&i2c->usi_fifo_stat) & HSI2C_TX_FIFO_FULL)) { if (!(read32(&i2c->usi_fifo_stat) & HSI2C_TX_FIFO_FULL)) {
@ -434,7 +435,7 @@ static int hsi2c_write(struct exynos5_hsi2c *i2c,
unsigned char chip, unsigned char chip,
unsigned char addr[], unsigned char addr[],
unsigned char alen, unsigned char alen,
unsigned char data[], const uint8_t data[],
unsigned short len) unsigned short len)
{ {
uint32_t i2c_auto_conf; uint32_t i2c_auto_conf;
@ -470,7 +471,7 @@ static int hsi2c_read(struct exynos5_hsi2c *i2c,
unsigned char chip, unsigned char chip,
unsigned char addr[], unsigned char addr[],
unsigned char alen, unsigned char alen,
unsigned char data[], uint8_t data[],
unsigned short len, unsigned short len,
int check) int check)
{ {
@ -632,7 +633,7 @@ bailout:
} }
int i2c_read(unsigned bus, unsigned chip, unsigned addr, int i2c_read(unsigned bus, unsigned chip, unsigned addr,
unsigned alen, unsigned char *buf, unsigned len) unsigned alen, uint8_t *buf, unsigned len)
{ {
struct s3c24x0_i2c_bus *i2c; struct s3c24x0_i2c_bus *i2c;
unsigned char xaddr[4]; unsigned char xaddr[4];
@ -667,7 +668,7 @@ int i2c_read(unsigned bus, unsigned chip, unsigned addr,
} }
int i2c_write(unsigned bus, unsigned chip, unsigned addr, int i2c_write(unsigned bus, unsigned chip, unsigned addr,
unsigned alen, unsigned char *buf, unsigned len) unsigned alen, const uint8_t *buf, unsigned len)
{ {
struct s3c24x0_i2c_bus *i2c; struct s3c24x0_i2c_bus *i2c;
unsigned char xaddr[4]; unsigned char xaddr[4];
@ -692,7 +693,7 @@ int i2c_write(unsigned bus, unsigned chip, unsigned addr,
alen, buf, len); alen, buf, len);
else else
ret = i2c_transfer(i2c->regs, I2C_WRITE, chip << 1, ret = i2c_transfer(i2c->regs, I2C_WRITE, chip << 1,
&xaddr[4 - alen], alen, buf, len); &xaddr[4 - alen], alen, (void *)buf, len);
if (ret != 0) { if (ret != 0) {

View File

@ -20,10 +20,12 @@
#ifndef _DEVICE_I2C_H_ #ifndef _DEVICE_I2C_H_
#define _DEVICE_I2C_H_ #define _DEVICE_I2C_H_
#include <stdint.h>
/* note: chip is the 7-bit I2C address */ /* note: chip is the 7-bit I2C address */
int i2c_read(unsigned bus, unsigned chip, unsigned addr, int i2c_read(unsigned bus, unsigned chip, unsigned addr,
unsigned alen, unsigned char *buf, unsigned len); unsigned alen, uint8_t *buf, unsigned len);
int i2c_write(unsigned bus, unsigned chip, unsigned addr, int i2c_write(unsigned bus, unsigned chip, unsigned addr,
unsigned alen, unsigned char *buf, unsigned len); unsigned alen, const uint8_t *buf, unsigned len);
#endif /* _DEVICE_I2C_H_ */ #endif /* _DEVICE_I2C_H_ */