// userspace
uint8_t value = 5;
write (fd, (const char *)&value, 1);
// kernel driver
static ssize_t sysfs_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
{
u8 val;
sscanf(buf, "%hhu" , &val);
// val should be 5 here but bizarrely its 255
pr_info("sysfs_store %s %hhu", attr->attr.name, val);
...
}
I checked that buf contains the value 5, so the issue is in driver only with sscanf. please help!