if (client->flags & I2C_CLIENT_ALLOW_USE) {
if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE)
client->usage_count++;
- else {
- if(client->usage_count > 0)
- return -EBUSY;
- else
- client->usage_count++;
- }
+ else if (client->usage_count > 0)
+ return -EBUSY;
+ else
+ client->usage_count++;
}
i2c_inc_use_client(client);
I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, &data))
return -1;
else
- return 0x0FF & data.byte;
+ return data.byte;
}
extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value)
I2C_SMBUS_READ,command, I2C_SMBUS_BYTE_DATA,&data))
return -1;
else
- return 0x0FF & data.byte;
+ return data.byte;
}
extern s32 i2c_smbus_write_byte_data(struct i2c_client * client, u8 command,
I2C_SMBUS_READ,command, I2C_SMBUS_WORD_DATA, &data))
return -1;
else
- return 0x0FFFF & data.word;
+ return data.word;
}
extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
I2C_SMBUS_PROC_CALL, &data))
return -1;
else
- return 0x0FFFF & data.word;
+ return data.word;
}
/* Returns the number of read bytes */
else {
msg[0].len=3;
msgbuf0[1] = data->word & 0xff;
- msgbuf0[2] = (data->word >> 8) & 0xff;
+ msgbuf0[2] = data->word >> 8;
}
break;
case I2C_SMBUS_PROC_CALL:
msg[0].len = 3;
msg[1].len = 2;
msgbuf0[1] = data->word & 0xff;
- msgbuf0[2] = (data->word >> 8) & 0xff;
+ msgbuf0[2] = data->word >> 8;
break;
case I2C_SMBUS_BLOCK_DATA:
if (read_write == I2C_SMBUS_READ) {
#define THIS_MODULE NULL
#endif
-static int i2c_parse_reals(int *nrels, void *buffer, int bufsize,
+static int i2c_parse_reals(int *nrels, char *buffer, int bufsize,
long *results, int magnitude);
-static int i2c_write_reals(int nrels, void *buffer, int *bufsize,
+static int i2c_write_reals(int nrels, char *buffer, int *bufsize,
long *results, int magnitude);
static int i2c_proc_chips(ctl_table * ctl, int write,
struct file *filp, void *buffer,
WARNING! This is tricky code. I have tested it, but there may still be
hidden bugs in it, even leading to crashes and things!
*/
-int i2c_parse_reals(int *nrels, void *buffer, int bufsize,
+static int i2c_parse_reals(int *nrels, char *buffer, int bufsize,
long *results, int magnitude)
{
int maxels, min, mag;
/* Skip spaces at the start */
while (bufsize &&
- !((ret=get_user(nextchar, (char *) buffer))) &&
+ !((ret=get_user(nextchar, buffer))) &&
isspace((int) nextchar)) {
bufsize--;
- buffer = (char *) buffer + 1;
+ buffer++;
}
if (ret)
mag = magnitude;
/* Check for a minus */
- if (!((ret=get_user(nextchar, (char *) buffer)))
+ if (!((ret=get_user(nextchar, buffer)))
&& (nextchar == '-')) {
min = 1;
bufsize--;
- buffer = (char *) buffer + 1;
+ buffer++;
}
if (ret)
return -EFAULT;
/* Digits before a decimal dot */
while (bufsize &&
- !((ret=get_user(nextchar, (char *) buffer))) &&
+ !((ret=get_user(nextchar, buffer))) &&
isdigit((int) nextchar)) {
res = res * 10 + nextchar - '0';
bufsize--;
- buffer = (char *) buffer + 1;
+ buffer++;
}
if (ret)
return -EFAULT;
if (bufsize && (nextchar == '.')) {
/* Skip the dot */
bufsize--;
- buffer = (char *) buffer + 1;
+ buffer++;
/* Read digits while they are significant */
while (bufsize && (mag > 0) &&
- !((ret=get_user(nextchar, (char *) buffer))) &&
+ !((ret=get_user(nextchar, buffer))) &&
isdigit((int) nextchar)) {
res = res * 10 + nextchar - '0';
mag--;
bufsize--;
- buffer = (char *) buffer + 1;
+ buffer++;
}
if (ret)
return -EFAULT;
/* Skip everything until we hit whitespace */
while (bufsize &&
- !((ret=get_user(nextchar, (char *) buffer))) &&
+ !((ret=get_user(nextchar, buffer))) &&
!isspace((int) nextchar)) {
bufsize--;
- buffer = (char *) buffer + 1;
+ buffer++;
}
if (ret)
return -EFAULT;
return 0;
}
-int i2c_write_reals(int nrels, void *buffer, int *bufsize,
+static int i2c_write_reals(int nrels, char *buffer, int *bufsize,
long *results, int magnitude)
{
#define BUFLEN 20
mag = magnitude;
if (nr != 0) {
- if(put_user(' ', (char *) buffer))
+ if(put_user(' ', buffer))
return -EFAULT;
curbufsize++;
- buffer = (char *) buffer + 1;
+ buffer++;
}
/* Fill BUF with the representation of the next string */
if(copy_to_user(buffer, BUF, buflen))
return -EFAULT;
curbufsize += buflen;
- buffer = (char *) buffer + buflen;
+ buffer += buflen;
nr++;
}
if (curbufsize < *bufsize) {
- if(put_user('\n', (char *) buffer))
+ if(put_user('\n', buffer))
return -EFAULT;
curbufsize++;
}