mirror of
https://gitlab.com/manzerbredes/ina260-sysfs-driver.git
synced 2025-04-19 04:09:45 +00:00
Minor changes
This commit is contained in:
parent
3f3e67f8ed
commit
0b4b81e273
1 changed files with 17 additions and 0 deletions
17
ina260.c
17
ina260.c
|
@ -233,6 +233,23 @@ static int ina260_set_register_3bits(struct client_data *cdata, unsigned char re
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ina260_set_register_1bit(struct client_data *cdata, unsigned char reg, unsigned char n, int bit){
|
||||||
|
int mask, value;
|
||||||
|
if(bit==0 || bit == 1){
|
||||||
|
if(ina260_read_register(cdata,reg,&value)){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
mask=~(1<< n);
|
||||||
|
value &= mask; // clear bits
|
||||||
|
value |= bit << n;
|
||||||
|
if(ina260_write_register(cdata,reg,value)){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t attr_field_store(struct kobject *_kobj,
|
static ssize_t attr_field_store(struct kobject *_kobj,
|
||||||
struct kobj_attribute *attr,
|
struct kobj_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue