mirror of
https://gitlab.com/manzerbredes/ina260-sysfs-driver.git
synced 2025-04-29 00:27:46 +00:00
Minor changes
This commit is contained in:
parent
71ffc9684c
commit
4db195b0d6
1 changed files with 6 additions and 13 deletions
19
ina260.c
19
ina260.c
|
@ -50,18 +50,15 @@ static int ina260_read_register(struct client_data* cdata, unsigned char reg, in
|
|||
unsigned char bytes[2];
|
||||
if(cdata->reg == reg){
|
||||
//printk("Cache\n");
|
||||
if(i2c_master_recv(cdata->client,bytes,2)<0){
|
||||
if(i2c_master_recv(cdata->client,bytes,2)<0)
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
//printk("No cache\n");
|
||||
if(i2c_master_send(cdata->client,®,1)<0){
|
||||
if(i2c_master_send(cdata->client,®,1)<0)
|
||||
return 1;
|
||||
}
|
||||
cdata->reg = reg;
|
||||
if(i2c_master_recv(cdata->client,bytes,2)<0){
|
||||
if(i2c_master_recv(cdata->client,bytes,2)<0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
*value=(bytes[0]<<8) | bytes[1];
|
||||
return 0;
|
||||
|
@ -72,9 +69,8 @@ static int ina260_write_register(struct client_data* cdata, unsigned char reg, i
|
|||
data[0]=reg;
|
||||
data[1]=(value>>8) & 0xFF; // MSB
|
||||
data[2]=value & 0xFF; // LSB
|
||||
if(i2c_master_send(cdata->client,data,3)<0){
|
||||
if(i2c_master_send(cdata->client,data,3)<0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -395,12 +391,10 @@ static struct kobj_type ina260_ktype = {
|
|||
|
||||
static int ina260_probe_register(struct i2c_client *client, unsigned char reg, int value){
|
||||
unsigned char bytes[2];
|
||||
if(i2c_master_send(client,®,1)<0){
|
||||
if(i2c_master_send(client,®,1)<0)
|
||||
return 1;
|
||||
}
|
||||
if(i2c_master_recv(client,bytes,2)<0){
|
||||
if(i2c_master_recv(client,bytes,2)<0)
|
||||
return 1;
|
||||
}
|
||||
return ((bytes[0]<<8) | bytes[1])!=value;
|
||||
}
|
||||
|
||||
|
@ -428,7 +422,6 @@ static int ina260_probe_new(struct i2c_client *client){
|
|||
kfree(p);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue