static ssize_t radar_detection_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; int ret; u8 channel; ret = kstrtou8_from_user(user_buf, count, 10, &channel); if (ret < 0) { wl1271_warning("illegal channel"); return -EINVAL; } mutex_lock(&wl->mutex); if (unlikely(wl->state != WLCORE_STATE_ON)) goto out; ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out; ret = wlcore_radar_detection_debug(wl, channel); if (ret < 0) count = ret; wl1271_ps_elp_sleep(wl); out: mutex_unlock(&wl->mutex); return count; }
static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf, size_t count, loff_t *ppos) { u8 on; ssize_t ret; ret = kstrtou8_from_user(buf, count, 2, &on); if (ret) return ret; mutex_lock(&pstore_ftrace_lock); if (!on ^ pstore_ftrace_enabled) goto out; if (on) ret = register_ftrace_function(&pstore_ftrace_ops); else ret = unregister_ftrace_function(&pstore_ftrace_ops); if (ret) { pr_err("%s: unable to %sregister ftrace ops: %zd\n", __func__, on ? "" : "un", ret); goto err; } pstore_ftrace_enabled = on; out: ret = count; err: mutex_unlock(&pstore_ftrace_lock); return ret; }
static ssize_t vmm_pmic_i2cdev_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { if (kstrtou8_from_user(ubuf, count, 0, &i2cdev)) return -EFAULT; return count; }
static ssize_t vmm_pmic_val_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { if (kstrtou8_from_user(ubuf, count, 0, &val)) return -EFAULT; vmm_pmic_reg_write((i2cdev << 24) | regaddr, val); return count; }
static ssize_t ath6kl_max_num_sta_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { struct ath6kl *ar = file->private_data; int ret; u8 val; ret = kstrtou8_from_user(user_buf, count, 0, &val); if (ret) return ret; ret = ath6kl_wmi_ap_set_num_sta(ar->wmi, 0, val); if (ret) return ret; return count; }
static ssize_t uapsd_queues_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { struct ieee80211_local *local = file->private_data; u8 val; int ret; ret = kstrtou8_from_user(user_buf, count, 0, &val); if (ret) return ret; if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) return -ERANGE; local->uapsd_queues = val; return count; }
static ssize_t pstore_rtrace_knob_write(struct file *f, const char __user *buf, size_t count, loff_t *ppos) { u8 on; ssize_t ret; ret = kstrtou8_from_user(buf, count, 2, &on); if (ret) return ret; mutex_lock(&pstore_rtrace_lock); if (!on ^ rtrace.enabled) goto out; rtrace.enabled = on; out: ret = count; mutex_unlock(&pstore_rtrace_lock); return ret; }
static ssize_t write_file_tx99_power(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { struct ath_softc *sc = file->private_data; int r; u8 tx_power; r = kstrtou8_from_user(user_buf, count, 0, &tx_power); if (r) return r; if (tx_power > MAX_RATE_POWER) return -EINVAL; sc->tx99_power = tx_power; ath9k_ps_wakeup(sc); ath9k_hw_tx99_set_txpower(sc->sc_ah, sc->tx99_power); ath9k_ps_restore(sc); return count; }
/** * debugfs_capture_write() - * * @filp: File pointer * @buf: User space buffer * @count: Number of bytes to write * @f_pos: File position * * Returns number of bytes written or negative error code */ static int debugfs_capture_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { int ret = 0; unsigned char capture; struct b2r2_control *cont = filp->f_dentry->d_inode->i_private; ret = kstrtou8_from_user(buf, count, 16, &capture); if (ret < 0) return -EINVAL; mutex_lock(&cont->dump.lock); cont->dump.capture = capture > 0 ? true : false; if (cont->dump.buffers_valid) { /* Clean out active buffers */ dump_release_locked(cont); } mutex_unlock(&cont->dump.lock); *f_pos += count; ret = count; return ret; }