static ssize_t store_wakeup_ms(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int ret; ret = kstrtouint(buf, 10, &wakeup_ms); if (ret) { pr_err("%s: Trying to set invalid wakeup timer\n", KBUILD_MODNAME); return ret; } if (wakeup_ms > 0) { thermal_rtc_setup(); pr_debug("%s: Timer started for %ums\n", KBUILD_MODNAME, wakeup_ms); } else { ret = alarm_cancel(&thermal_rtc); if (ret) pr_debug("%s: Timer canceled\n", KBUILD_MODNAME); else pr_debug("%s: No active timer present to cancel\n", KBUILD_MODNAME); } return count; }
static ssize_t xgbe_common_write(const char __user *buffer, size_t count, loff_t *ppos, unsigned int *value) { char workarea[32]; ssize_t len; int ret; if (*ppos != 0) return -EINVAL; if (count >= sizeof(workarea)) return -ENOSPC; len = simple_write_to_buffer(workarea, sizeof(workarea) - 1, ppos, buffer, count); if (len < 0) return len; workarea[len] = '\0'; ret = kstrtouint(workarea, 16, value); if (ret) return -EIO; return len; }
static ssize_t i2cster_write_hex(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) { struct i2cster_event * tmp_event = container_of(kobj, struct i2cster_event, kobj); struct i2c_client *client = to_i2c_client(container_of(kobj->parent, struct device, kobj)); struct i2cster_data * data = i2c_get_clientdata(client); int status; char tmp; char tmp2[3]; int i; // char *tmp_buf = strim((char *)buf); tmp2[2] = 0; // i2c_smbus_write_byte_data (client, tmp_event->reg); for(i = 0; i < count; i=i+2) { tmp2[0] = buf[i]; tmp2[1] = buf[i+1]; status = kstrtouint(tmp2, 16, &tmp); if (status == 0) tmp = i2c_smbus_write_byte_data(client, i/2, tmp); else return status; } return count; }
static ssize_t __ref store_cpus_offlined(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int ret = 0; uint32_t val = 0; int cpu; mutex_lock(&core_control_mutex); ret = kstrtouint(buf, 10, &val); if (ret) { pr_err("%s: Invalid input %s\n", KBUILD_MODNAME, buf); goto done_cc; } if (enabled) { pr_err("%s: Ignoring request; polling thread is enabled.\n", KBUILD_MODNAME); goto done_cc; } for_each_possible_cpu(cpu) { if (!(msm_thermal_info.core_control_mask & BIT(cpu))) continue; cpus[cpu].user_offline = !!(val & BIT(cpu)); } if (hotplug_task) complete(&hotplug_notify_complete); else pr_err("%s: Hotplug task is not initialized\n", KBUILD_MODNAME); done_cc: mutex_unlock(&core_control_mutex); return count; }
/* backlight mapping mode */ static ssize_t lm3639_bled_mode_store(struct device *dev, struct device_attribute *devAttr, const char *buf, size_t size) { ssize_t ret; struct lm3639_chip_data *pchip = dev_get_drvdata(dev); unsigned int state; ret = kstrtouint(buf, 10, &state); if (ret) goto out_input; if (!state) ret = regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x10, 0x00); else ret = regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x10, 0x10); if (ret < 0) goto out; return size; out: dev_err(pchip->dev, "%s:i2c access fail to register\n", __func__); return ret; out_input: dev_err(pchip->dev, "%s:input conversion fail\n", __func__); return ret; }
/* strobe pin config for lm3642*/ static ssize_t lm3642_strobe_pin_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { ssize_t ret; struct led_classdev *led_cdev = dev_get_drvdata(dev); struct lm3642_chip_data *chip = container_of(led_cdev, struct lm3642_chip_data, cdev_indicator); unsigned int state; ret = kstrtouint(buf, 10, &state); if (ret) goto out_strtoint; if (state != 0) state = 0x01 << STROBE_PIN_EN_SHIFT; chip->strobe_pin = state; ret = regmap_update_bits(chip->regmap, REG_ENABLE, STROBE_PIN_EN_MASK << STROBE_PIN_EN_SHIFT, state); if (ret < 0) goto out; return size; out: dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); return ret; out_strtoint: dev_err(chip->dev, "%s: fail to change str to int\n", __func__); return ret; }
static ssize_t __cpuinit store_cpus_offlined(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int ret = 0; uint32_t val = 0; mutex_lock(&core_control_mutex); ret = kstrtouint(buf, 10, &val); if (ret) { pr_err("%s: Invalid input %s\n", KBUILD_MODNAME, buf); goto done_cc; } if (enabled) { pr_err("%s: Ignoring request; polling thread is enabled.\n", KBUILD_MODNAME); goto done_cc; } if (cpus_offlined == val) goto done_cc; update_offline_cores(val); done_cc: mutex_unlock(&core_control_mutex); return count; }
static int __init resumedelay_setup(char *str) { int rc = kstrtouint(str, 0, &resume_delay); if (rc) return rc; return 1; }
static int __init hung_task_panic_setup(char *str) { int rc = kstrtouint(str, 0, &sysctl_hung_task_panic); if (rc) return rc; return 1; }
static __init int setup_boot_mode(char *opt) { unsigned int bootmode; if (!kstrtouint(opt, 0, &bootmode)) sec_bootmode = bootmode; return 0; }
int __init setup_androidboot_radio_init(char *s) { int retval = kstrtouint(s, 16, &androidboot_radio); if (retval < 0) return 0; return 1; }
/*---------------------------------------------------------------------------*/ int parse_cmdline(struct xio_test_config *test_config, char **argv) { uint32_t tmp = 0; if (!argv[1]) { usage(argv[0]); pr_err("NO IP was given\n"); return -1; } sprintf(test_config->server_addr, "%s", argv[1]); if (argv[2]) { if (kstrtouint(argv[2], 0, &tmp)) pr_err("parse error\n"); test_config->server_port = (uint16_t)tmp; } if (argv[3]) sprintf(test_config->transport, "%s", argv[3]); if (argv[4]) if (kstrtouint(argv[4], 0, &test_config->hdr_len)) pr_err("parse error\n"); if (argv[5]) if (kstrtouint(argv[5], 0, &test_config->data_len)) pr_err("parse error\n"); if (argv[6]) { tmp = 0; if (kstrtouint(argv[6], 0, &tmp)) pr_err("parse error\n"); test_config->finite_run = (uint16_t)tmp; } if (argv[7]) { if (kstrtoull(argv[7], 16, &test_config->cpu_mask)) pr_err("parse error\n"); } return 0; }
static ssize_t sec_logger_level_store(struct debug *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned int level; if (!kstrtouint(buf, 0, &level)) sec_logger_level = level; return count; }
static int __init espresso_set_vendor_type(char *str) { unsigned int vendor; if (kstrtouint(str, 0, &vendor)) return 0; if (vendor == 0) sec_vendor = SEC_MACHINE_ESPRESSO_USA_BBY; return 0; }
static size_t wakeup_keys_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int err; unsigned int base = 0; err = kstrtouint(buf, 0, &base); wakeup_keys_status = base; return count; }
static ssize_t iso_res_realize_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { unsigned int bw; unsigned int ult = 4; char buff[50]; char *val, *s; int ret; struct tegra_bbc_proxy *bbc = dev_get_drvdata(dev); strlcpy(buff, buf, sizeof(buff)); s = strim(buff); /* first param is bw */ val = strsep(&s, ","); ret = kstrtouint(val, 10, &bw); if (ret) { pr_err("invalid bw setting\n"); return -EINVAL; } /* second param is latency */ if (s) { ret = kstrtouint(s, 10, &ult); if (ret) { pr_err("invalid latency setting\n"); return -EINVAL; } } mutex_lock(&bbc->iso_lock); bbc->last_bw = bw; bbc->last_ult = ult; ret = bbc_bw_request_unlocked(dev, 0, bw, ult, bbc->margin); mutex_unlock(&bbc->iso_lock); return ret ? ret : size; }
static int do_register(char * args) { // parse registration information char * str_pid = strsep(&args, DELIMITER); char * str_per = strsep(&args, DELIMITER); char * str_cmp = strsep(&args, DELIMITER); unsigned int pid; unsigned int period; unsigned int comp_time; int parse_failure = 0; parse_failure |= kstrtouint(str_pid, 10, &pid); parse_failure |= kstrtouint(str_per, 10, &period); parse_failure |= kstrtouint(str_cmp, 10, &comp_time); if(parse_failure) return parse_failure; printk(KERN_ALERT "Registered %d (period %d).\n", pid, period); register_task((pid_t) pid, period, comp_time); return 0; }
static ssize_t sequence_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct ec_params_lightbar *param; struct cros_ec_command *msg; unsigned int num; int ret, len; struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, class_dev); for (len = 0; len < count; len++) if (!isalnum(buf[len])) break; for (num = 0; num < ARRAY_SIZE(seqname); num++) if (!strncasecmp(seqname[num], buf, len)) break; if (num >= ARRAY_SIZE(seqname)) { ret = kstrtouint(buf, 0, &num); if (ret) return ret; } msg = alloc_lightbar_cmd_msg(ec); if (!msg) return -ENOMEM; param = (struct ec_params_lightbar *)msg->data; param->cmd = LIGHTBAR_CMD_SEQ; param->seq.num = num; ret = lb_throttle(); if (ret) goto exit; ret = cros_ec_cmd_xfer(ec->ec_dev, msg); if (ret < 0) goto exit; if (msg->result != EC_RES_SUCCESS) { ret = -EINVAL; goto exit; } ret = count; exit: kfree(msg); return ret; }
static int do_deregister(char * args) { // parse registration information char * str_pid = strsep(&args, DELIMITER); unsigned int pid; int parse_failure = kstrtouint(str_pid, 10, &pid); if(parse_failure) return parse_failure; printk(KERN_ALERT "Deregistered %d.\n", pid); deregister_task(pid); return 0; }
static ssize_t wl1251_set_ps_rate_thr(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct wl1251 *wl = dev_get_drvdata(dev); unsigned int val; int ret; ret = kstrtouint(buf, 10, &val); if (ret < 0) return ret; wl->ps_rate_threshold = val; return count; }
/* * Allow an override of the IOPort. Stupid BIOSes do not tell us about * the PMTimer, but we might know where it is. */ static int __init parse_pmtmr(char *arg) { unsigned int base; int ret; ret = kstrtouint(arg, 16, &base); if (ret) return ret; pr_info("PMTMR IOPort override: 0x%04x -> 0x%04x\n", pmtmr_ioport, base); pmtmr_ioport = base; return 1; }
static int param_set_uint_minmax(const char *val, const struct kernel_param *kp, unsigned int min, unsigned int max) { unsigned int num; int ret; if (!val) return -EINVAL; ret = kstrtouint(val, 0, &num); if (ret < 0 || num < min || num > max) return -EINVAL; *((unsigned int *)kp->arg) = num; return 0; }
static ssize_t bcm_hsotg_mdio5_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned int val; int err; err = kstrtouint(buf, 0, &val); bcm_hsotgctrl_mdio_register_write(5, (int)val); pr_info("Set USB PHY MDIO Register 5 to %x\n", val); return count; }
static ssize_t store_cpuctl(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned val; int ret; ret = kstrtouint(buf, 10, &val); if (ret < 0) return ret; ret = cpu_config_on_each_cpu(val); if (ret < 0) return ret; return count; }
static ssize_t sd_store_max_medium_access_timeouts(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct scsi_disk *sdkp = to_scsi_disk(dev); int err; if (!capable(CAP_SYS_ADMIN)) return -EACCES; err = kstrtouint(buf, 10, &sdkp->max_medium_access_timeouts); return err ? err : count; }
static ssize_t mc96fr1196c_ir_send_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct mc96fr116c_data *data = dev_get_drvdata(dev); unsigned int value; char *string, *pstring; int signal_length = 2; /* By default, 2 bytes for data length */ int ir_sum = 0; int number_freq = 0; int ret; if (data->mode != MC96FR116C_USER_IR_MODE) { dev_err(&data->client->dev, "%s: Not user IR mode.\n", __func__); return -EINVAL; } if (!mutex_trylock(&data->signal_mutex)) return -EBUSY; string = (char*)kmalloc(size + 1, GFP_KERNEL); strlcpy(string, buf, size); pstring = strim(string); while (pstring) { char *curr_string; curr_string = strsep(&pstring, " ,"); if (*curr_string == '\0') continue; ret = kstrtouint(curr_string, 0, &value); if (!value) break; if (ret < 0) { dev_err(dev, "Error: Invalid argument. Could not convert.\n"); goto out; } if (signal_length == 2) { data->carrier_freq = value; data->signal[2] = (value >> 16) & 0xFF; data->signal[3] = (value >> 8) & 0xFF; data->signal[4] = value & 0xFF; signal_length += 3; } else {
static ssize_t led_delay_off_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct max77828_rgb *max77828_rgb = dev_get_drvdata(dev); unsigned int time; if (kstrtouint(buf, 0, &time)) { dev_err(dev, "can not write led_delay_off\n"); return count; } max77828_rgb->delay_off_times_ms = time; return count; }
static ssize_t ad7879_disable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct ad7879 *ts = dev_get_drvdata(dev); unsigned int val; int error; error = kstrtouint(buf, 10, &val); if (error) return error; ad7879_toggle(ts, val); return count; }
static int get_cache_sram_params(struct sram_parameters *sram_params) { unsigned long long addr; unsigned int size; if (!sram_size || (kstrtouint(sram_size, 0, &size) < 0)) return -EINVAL; if (!sram_offset || (kstrtoull(sram_offset, 0, &addr) < 0)) return -EINVAL; sram_params->sram_offset = addr; sram_params->sram_size = size; return 0; }
static ssize_t static_uintvalue_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) { struct static_lustre_uintvalue_attr *lattr = (void *)attr; int rc; unsigned int val; rc = kstrtouint(buffer, 10, &val); if (rc) return rc; *lattr->value = val; return count; }