static ssize_t wait_state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { unsigned int input; int ret; u8 port = 0; ret = sscanf(buf, "%u", &input); if (ret != 1) return -EINVAL; host_port_id_target(kobj, &port); dram_host_port_wait_state_set(port, input); return count; }
static ssize_t wait_state_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { u8 state, port = 0; if(strlen(buf) < 2 || strlen(buf) > 3) return -EINVAL; if(strlen(buf) == 2) { if(buf[0] < '0' || buf[0] > '9') return -EINVAL; } else { if(buf[0] != '1') return -EINVAL; if(buf[1] < '0' || buf[1] > '5') return -EINVAL; } state = simple_strtoul(buf, NULL, 10); host_port_id_target(kobj, &port); dram_host_port_wait_state_set(port, state); return count; }