static ssize_t wilc_debug_level_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos) { int flag = 0; int ret; ret = kstrtouint_from_user(buf, count, 16, &flag); if (ret) return ret; if (flag > DBG_LEVEL_ALL) { pr_info("%s, value (0x%08x) is out of range, stay previous flag (0x%08x)\n", __func__, flag, atomic_read(&WILC_DEBUG_LEVEL)); return -EINVAL; } atomic_set(&WILC_DEBUG_LEVEL, (int)flag); if (flag == 0) pr_info("Debug-level disabled\n"); else pr_info("Debug-level enabled\n"); return count; }
static ssize_t diag_gpiomask_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { int err = kstrtouint_from_user(buf, count, 0, &gpiomask); if (err) return err; if (platform.buttons) { unregister_buttons(platform.buttons); register_buttons(platform.buttons); } if (platform.leds) { unregister_leds(platform.leds); register_leds(platform.leds); } return count; }
static ssize_t gss_lk_proc_dl_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { unsigned int val; int rc; rc = kstrtouint_from_user(buffer, count, 0, &val); if (rc < 0) return rc; if (val > 4) return -ERANGE; gss_lk_debug_level = val; return count; }
/** * lttng_filter_event_write - trigger a lttng_test_filter_event * @file: file pointer * @user_buf: user string * @count: length to copy * * Return -1 on error, with EFAULT errno. Returns count on success. */ static ssize_t lttng_test_filter_event_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { unsigned int nr_iter; ssize_t written; int ret; /* Get the number of iterations */ ret = kstrtouint_from_user(user_buf, count, 10, &nr_iter); if (ret) { written = ret; goto end; } /* Trace the event */ trace_test_event(nr_iter); written = count; *ppos += written; end: return written; }