Ejemplo n.º 1
0
static ssize_t ssm_store_request_next_suspend_prepare_notification(
		struct device *pdev, struct device_attribute *attr,
		const char *pbuf, size_t count)
{
	int rc;
	u8 val;
	struct ssm_data *sd = dev_get_drvdata(pdev);

	dev_dbg(sd->dev, "%s: %s\n", __func__, pbuf);

	rc = kstrtou8(pbuf, 2, &val);
	if (!rc) {
		mutex_lock(&sd->lock);
		if (sd->enabled) {
			sd->notify_next_suspend_prepare = !!val;
		} else {
			rc = -EINVAL;
			dev_err(sd->dev, "%s: Notifications are not enabled\n",
				__func__);
		}
		mutex_unlock(&sd->lock);
	}

	return rc == 0 ? count : rc;
}
Ejemplo n.º 2
0
static ssize_t ds2780_set_pio_pin(struct device *dev,
	struct device_attribute *attr,
	const char *buf,
	size_t count)
{
	int ret;
	u8 new_setting;
	struct power_supply *psy = to_power_supply(dev);
	struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);

	ret = kstrtou8(buf, 0, &new_setting);
	if (ret < 0)
		return ret;

	if ((new_setting != 0) && (new_setting != 1)) {
		dev_err(dev_info->dev, "Invalid pio_pin setting (0 or 1)\n");
		return -EINVAL;
	}

	ret = ds2780_write(dev_info, &new_setting,
				DS2780_SFR_REG, sizeof(u8));
	if (ret < 0)
		return ret;

	return count;
}
Ejemplo n.º 3
0
static ssize_t ds2780_set_pmod_enabled(struct device *dev,
	struct device_attribute *attr,
	const char *buf,
	size_t count)
{
	int ret;
	u8 control_reg, new_setting;
	struct power_supply *psy = to_power_supply(dev);
	struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);

	/* Set power mode */
	ret = ds2780_get_control_register(dev_info, &control_reg);
	if (ret < 0)
		return ret;

	ret = kstrtou8(buf, 0, &new_setting);
	if (ret < 0)
		return ret;

	if ((new_setting != 0) && (new_setting != 1)) {
		dev_err(dev_info->dev, "Invalid pmod setting (0 or 1)\n");
		return -EINVAL;
	}

	if (new_setting)
		control_reg |= DS2780_CONTROL_REG_PMOD;
	else
		control_reg &= ~DS2780_CONTROL_REG_PMOD;

	ret = ds2780_set_control_register(dev_info, control_reg);
	if (ret < 0)
		return ret;

	return count;
}
static ssize_t k303c_acc_enable_store(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	u8 enable;
	int ret, pre_enable;
	struct k303c_acc_p *data = dev_get_drvdata(dev);

	ret = kstrtou8(buf, 2, &enable);
	if (ret) {
		pr_err("%s - Invalid Argument\n", __func__);
		return ret;
	}

	pre_enable = atomic_read(&data->enable);
	pr_info("%s new=%u, pre=%u\n", __func__, enable, pre_enable);

	if (enable) {
		if (pre_enable == OFF) {
			k303c_acc_open_calibration(data);
			k303c_acc_set_range(data, K303C_RANGE_2G);

			k303c_acc_set_enable(data, ON);
			k303c_acc_set_mode(data, K303C_MODE_NORMAL);
			atomic_set(&data->enable, ON);
		}
	} else {
		if (pre_enable == ON) {
			atomic_set(&data->enable, OFF);
			k303c_acc_set_mode(data, K303C_MODE_SUSPEND);
			k303c_acc_set_enable(data, OFF);
		}
	}

	return size;
}
Ejemplo n.º 5
0
static ssize_t light_enable_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	u8 enable;
	int ret;
	struct cm3323_p *data = dev_get_drvdata(dev);

	ret = kstrtou8(buf, 2, &enable);
	if (ret) {
		pr_err("[SENSOR]: %s - Invalid Argument\n", __func__);
		return ret;
	}

	pr_info("[SENSOR]: %s - new_value = %u\n", __func__, enable);
	if (enable && !(data->power_state & LIGHT_ENABLED)) {
		data->power_state |= LIGHT_ENABLED;
		cm3323_light_enable(data);
#ifdef CONFIG_SENSORS_ESD_DEFENCE
		data->zero_cnt = 0;
		data->reset_cnt = 0;
#endif
	} else if (!enable && (data->power_state & LIGHT_ENABLED)) {
		cm3323_light_disable(data);
		data->power_state &= ~LIGHT_ENABLED;
	}

	return size;
}
Ejemplo n.º 6
0
static ssize_t proximity_thresh_diff_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t size)
{
	struct gp2a_data *gp2a = dev_get_drvdata(dev);
	struct gp2a_platform_data *pdata = gp2a->pdata;
	u8 threshold_diff = 0;
	int err;

	err = kstrtou8(buf, 10, &threshold_diff);
	if (err) {
		pr_err("%s, conversion %s to number.\n",
			__func__, buf);
		return err;
	}

	if ((threshold_diff > 0) && (threshold_diff < 5)) { /* update diff */
		gp2a->thresh_diff = threshold_diff;
	} else if (threshold_diff == 0) { /* reset to default */
		pdata->gp2a_get_threshold(&gp2a->thresh_diff);
	} else {
		pr_err("%s: invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}

	gp2a_update_threshold(gp2a, is_gp2a030a() ?
			gp2a_original_image_030a : gp2a_original_image,
			(is_gp2a030a() ?
			gp2a_original_image_030a[3][1] :
			gp2a_original_image[3][1]), true);

	return size;
}
Ejemplo n.º 7
0
/**
 * zynqmp_ocm_edac_inject_cebitpos_store - Set CE bit postion
 * @dci:	Pointer to the edac device struct
 * @data:	Pointer to user data
 * @count:	read the size bytes from buffer
 *
 * Set any one bit to inject CE error
 * Return: Number of bytes copied.
 */
static ssize_t zynqmp_ocm_edac_inject_cebitpos_store(
		struct edac_device_ctl_info *dci, const char *data,
		size_t count)
{
	struct zynqmp_ocm_edac_priv *priv = dci->pvt_info;

	if (!data)
		return -EFAULT;

	if (kstrtou8(data, 0, &priv->ce_bitpos))
		return -EINVAL;

	if (priv->ce_bitpos >= 0 && priv->ce_bitpos <= 31) {
		writel(1 << priv->ce_bitpos, priv->baseaddr + OCM_FID0_OFST);
		writel(0, priv->baseaddr + OCM_FID1_OFST);
	} else if (priv->ce_bitpos >= 32 && priv->ce_bitpos <= 63) {
		writel(1 << (priv->ce_bitpos - 32),
				priv->baseaddr + OCM_FID1_OFST);
		writel(0, priv->baseaddr + OCM_FID0_OFST);
	} else {
		edac_printk(KERN_ERR, EDAC_DEVICE,
			"Bit number > 64 is not valid\n");
	}

	return count;
}
Ejemplo n.º 8
0
static ssize_t overlay_zorder_store(struct omap_overlay *ovl,
		const char *buf, size_t size)
{
	int r;
	u8 zorder;
	struct omap_overlay_info info;

	if ((ovl->caps & OMAP_DSS_OVL_CAP_ZORDER) == 0)
		return -ENODEV;

	r = kstrtou8(buf, 0, &zorder);
	if (r)
		return r;

	ovl->get_overlay_info(ovl, &info);

	info.zorder = zorder;

	r = ovl->set_overlay_info(ovl, &info);
	if (r)
		return r;

	if (ovl->manager) {
		r = ovl->manager->apply(ovl->manager);
		if (r)
			return r;
	}

	return size;
}
Ejemplo n.º 9
0
static ssize_t overlay_pre_mult_alpha_store(struct omap_overlay *ovl,
		const char *buf, size_t size)
{
	int r;
	u8 alpha;
	struct omap_overlay_info info;

	if ((ovl->caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0)
		return -ENODEV;

	r = kstrtou8(buf, 0, &alpha);
	if (r)
		return r;

	ovl->get_overlay_info(ovl, &info);

	info.pre_mult_alpha = alpha;

	r = ovl->set_overlay_info(ovl, &info);
	if (r)
		return r;

	if (ovl->manager) {
		r = ovl->manager->apply(ovl->manager);
		if (r)
			return r;
	}

	return size;
}
Ejemplo n.º 10
0
static ssize_t proximity_thresh_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t size)
{
	struct gp2a_data *data = dev_get_drvdata(dev);
	u8 threshold = 0;
	int err = 0;

	err = kstrtou8(buf, 10, &threshold);

	if (err) {
		pr_err("%s, conversion %s to number.\n",
			__func__, buf);
		return err;
	}

	err = gp2a_update_threshold(data, is_gp2a030a() ?
			gp2a_original_image_030a : gp2a_original_image,
			threshold, true);

	if (err) {
		pr_err("gp2a threshold(with register) update fail.\n");
		return err;
	}

	return size;
}
Ejemplo n.º 11
0
static ssize_t store_led_b(struct device *dev,
	struct device_attribute *devattr, const char *buf, size_t count)
{
	struct ktd2026_data *data = dev_get_drvdata(dev);
	char buff[10] = {0,};
	int cnt, ret;
	u8 brightness;

	cnt = count;
	cnt = (buf[cnt-1] == '\n') ? cnt-1 : cnt;
	memcpy(buff, buf, cnt);
	buff[cnt] = '\0';

	ret = kstrtou8(buff, 0, &brightness);
	if (ret != 0) {
		dev_err(&data->client->dev, "fail to get brightness.\n");
		goto out;
	}

	if (brightness == 0)
		ktd2026_leds_on(LED_B, LED_EN_OFF, 0);
	else
		ktd2026_leds_on(LED_B, LED_EN_ON, brightness);

	leds_i2c_write_all(data->client);
out:
	return count;

}
Ejemplo n.º 12
0
static ssize_t lcdi2c_backlight(struct device* dev,
				struct device_attribute* attr,
				const char* buf, size_t count)
{
    u8 res;
    int er;

    CRIT_BEG(data, ERESTARTSYS);

    er = kstrtou8(buf, 10, &res);
    if (er == 0)
    {
        lcdsetbacklight(data,  res);
        er = count;
    }
    else if (er == -ERANGE)
        dev_err(dev, "Brightness parameter out of range (0-255).");
    else if (er == -EINVAL)
        dev_err(dev, "Brightness parameter has numerical value. \"%s\" was given", buf);
    else
        dev_err(dev, "Brightness parameter wasn't properly converted! err: %d", er);

    CRIT_END(data);
    return er;
}
static ssize_t light_enable_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	u8 enable;
	int ret;
	struct cm3323_p *data = dev_get_drvdata(dev);

	ret = kstrtou8(buf, 2, &enable);
	if (ret) {
		pr_err("[SENSOR]: %s - Invalid Argument\n", __func__);
		return ret;
	}

	pr_info("[SENSOR]: %s - new_value = %u\n", __func__, enable);
	mutex_lock(&data->power_lock);
	if (enable && !(data->power_state & LIGHT_ENABLED)) {
		data->power_state |= LIGHT_ENABLED;
		cm3323_light_enable(data);
	} else if (!enable && (data->power_state & LIGHT_ENABLED)) {
		cm3323_light_disable(data);
		data->power_state &= ~LIGHT_ENABLED;
	}
	mutex_unlock(&data->power_lock);

	return size;
}
Ejemplo n.º 14
0
static ssize_t ad7152_store_filter_rate_setup(struct device *dev,
        struct device_attribute *attr,
        const char *buf,
        size_t len)
{
    struct iio_dev *indio_dev = dev_to_iio_dev(dev);
    struct ad7152_chip_info *chip = iio_priv(indio_dev);
    u8 data;
    int ret, i;

    ret = kstrtou8(buf, 10, &data);
    if (ret < 0)
        return ret;

    for (i = 0; i < ARRAY_SIZE(ad7152_filter_rate_table); i++)
        if (data >= ad7152_filter_rate_table[i][0])
            break;

    if (i >= ARRAY_SIZE(ad7152_filter_rate_table))
        i = ARRAY_SIZE(ad7152_filter_rate_table) - 1;

    mutex_lock(&indio_dev->mlock);
    ret = i2c_smbus_write_byte_data(chip->client,
                                    AD7152_REG_CFG2, AD7152_CFG2_OSR(i));
    if (ret < 0) {
        mutex_unlock(&indio_dev->mlock);
        return ret;
    }

    chip->filter_rate_setup = i;
    mutex_unlock(&indio_dev->mlock);

    return len;
}
static ssize_t store_enable(struct kobject *kobj,
			    struct kobj_attribute *attr,
			    const char *buf,
			    size_t count)
{
	struct femto_modem_data *drv = TO_DRV(attr, kobj_attr_enable);
	u8 enable_val;
	int ret;

	if (!drv)
		return -EINVAL;

	if (kstrtou8(buf, 0, &enable_val))
		return -EINVAL;

	if (enable_val > 1)
		return -EINVAL;

	/* Only start/stop if it's different. */
	if (enable_val != drv->enable) {
		if (enable_val)
			ret = pil_femto_modem_start(drv);
		else
			ret = pil_femto_modem_stop(drv);
		if (ret)
			return ret;
		SET_SYSFS_VALUE(drv, enable, enable_val);
	}

	return count;
}
static ssize_t store_max77843_rgb_brightness(struct device *dev,
					struct device_attribute *devattr,
					const char *buf, size_t count)
{
	int ret;
	u8 brightness;
	pr_info("leds-max77843-rgb: %s\n", __func__);

	ret = kstrtou8(buf, 0, &brightness);
	if (ret != 0) {
		dev_err(dev, "fail to get led_brightness.\n");
		return count;
	}

	led_lowpower_mode = 0;

	if (brightness > LED_MAX_CURRENT)
		brightness = LED_MAX_CURRENT;

	led_dynamic_current = brightness;

	dev_dbg(dev, "led brightness set to %i\n", brightness);

	return count;
}
Ejemplo n.º 17
0
static ssize_t store_fastsleep_workaround_applyonce(struct device *dev,
		struct device_attribute *attr, const char *buf,
		size_t count)
{
	cpumask_t primary_thread_mask;
	int err;
	u8 val;

	if (kstrtou8(buf, 0, &val) || val != 1)
		return -EINVAL;

	if (fastsleep_workaround_applyonce == 1)
		return count;

	/*
	 * fastsleep_workaround_applyonce = 1 implies
	 * fastsleep workaround needs to be left in 'applied' state on all
	 * the cores. Do this by-
	 * 1. Patching out the call to 'undo' workaround in fastsleep exit path
	 * 2. Sending ipi to all the cores which have at least one online thread
	 * 3. Patching out the call to 'apply' workaround in fastsleep entry
	 * path
	 * There is no need to send ipi to cores which have all threads
	 * offlined, as last thread of the core entering fastsleep or deeper
	 * state would have applied workaround.
	 */
	err = patch_instruction(
		(unsigned int *)pnv_fastsleep_workaround_at_exit,
		PPC_INST_NOP);
	if (err) {
		pr_err("fastsleep_workaround_applyonce change failed while patching pnv_fastsleep_workaround_at_exit");
		goto fail;
	}

	get_online_cpus();
	primary_thread_mask = cpu_online_cores_map();
	on_each_cpu_mask(&primary_thread_mask,
				pnv_fastsleep_workaround_apply,
				&err, 1);
	put_online_cpus();
	if (err) {
		pr_err("fastsleep_workaround_applyonce change failed while running pnv_fastsleep_workaround_apply");
		goto fail;
	}

	err = patch_instruction(
		(unsigned int *)pnv_fastsleep_workaround_at_entry,
		PPC_INST_NOP);
	if (err) {
		pr_err("fastsleep_workaround_applyonce change failed while patching pnv_fastsleep_workaround_at_entry");
		goto fail;
	}

	fastsleep_workaround_applyonce = 1;

	return count;
fail:
	return -EIO;
}
Ejemplo n.º 18
0
/**
 * zynqmp_ocm_edac_inject_uebitposition1_store - Set UE second bit postion
 * @dci:	Pointer to the edac device struct
 * @data:	Pointer to user data
 * @count:	read the size bytes from buffer
 *
 * Set the second bit postion for UE Error generation,we need to configure
 * any two bitpositions to inject UE Error
 * Return: Number of bytes copied.
 */
static ssize_t zynqmp_ocm_edac_inject_uebitpos1_store(
		struct edac_device_ctl_info *dci, const char *data,
		size_t count)
{
	struct zynqmp_ocm_edac_priv *priv = dci->pvt_info;
	u32 mask;

	if (!data)
		return -EFAULT;

	if (kstrtou8(data, 0, &priv->ue_bitpos1))
		return -EINVAL;

	if (priv->ue_bitpos0 == priv->ue_bitpos1) {
		edac_printk(KERN_ERR, EDAC_DEVICE,
				"Bit positions should not be equal\n");
		return -EINVAL;
	}

	/* If both bit postions are referring to 32 bit data, then configure
	 * only FID0 register or if it is 64 bit data, then configure only
	 * FID1 register.
	 */
	if ((priv->ue_bitpos0 >= 0 && priv->ue_bitpos0 <= 31) &&
			(priv->ue_bitpos1 >= 0 && priv->ue_bitpos1 <= 31)) {
		mask = (1 << priv->ue_bitpos0);
		mask |= (1 << priv->ue_bitpos1);
		writel(mask, priv->baseaddr + OCM_FID0_OFST);
		writel(0, priv->baseaddr + OCM_FID1_OFST);
	} else if ((priv->ue_bitpos0 >= 32 && priv->ue_bitpos0 <= 63) &&
			(priv->ue_bitpos1 >= 32 && priv->ue_bitpos1 <= 63)) {
		mask = (1 << (priv->ue_bitpos0 - 32));
		mask |= (1 << (priv->ue_bitpos1 - 32));
		writel(mask, priv->baseaddr + OCM_FID1_OFST);
		writel(0, priv->baseaddr + OCM_FID0_OFST);
	}

	/* If one bit position is referring a bit in 32 bit data and other in
	 * 64 bit data, just configure FID0/FID1 based on uebitpos1.
	 */
	if ((priv->ue_bitpos0 >= 0 && priv->ue_bitpos0 <= 31) &&
			(priv->ue_bitpos1 >= 32 && priv->ue_bitpos1 <= 63)) {
		writel(1 << (priv->ue_bitpos1 - 32),
				priv->baseaddr + OCM_FID1_OFST);
	} else if ((priv->ue_bitpos0 >= 32 && priv->ue_bitpos0 <= 63) &&
			(priv->ue_bitpos1 >= 0 && priv->ue_bitpos1 <= 31)) {
		writel(1 << priv->ue_bitpos1,
				priv->baseaddr + OCM_FID0_OFST);
	} else {
		edac_printk(KERN_ERR, EDAC_DEVICE,
			"Bit position > 64 is not valid, Valid bits:[63:0]\n");
	}

	edac_printk(KERN_INFO, EDAC_DEVICE,
			"UE at Bit Position0: %d Bit Position1: %d\n",
			priv->ue_bitpos0, priv->ue_bitpos1);
	return count;
}
/*
 **************************************************************************
 * FunctionName: scharger_led_torch_mode_set_brightness;
 * Description : get torch lum level;
 * Input       : buf, lum level to set (0 --turn off, 1~8 turn on);
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
static ssize_t scharger_led_torch_mode_set_brightness(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	int ret = 0;
	u8 level = 0;

	print_info("enter %s, previes level:%d", __func__, brightness_level);

	if(kstrtou8(buf,0,&level))
	{
		printk("fail to recover str to U8 %s\n",__func__);
		return -1;
	}

	if(brightness_level == level)
	{
		return count;
	}
	print_info("level is :%d", level);

	SAFE_DOWN(&busy_lock);

	if (flash_init == false)
	{
		scharger_flash_init();
	}

	if (0 == level)//close torch
	{
		brightness_level = level;
		scharger_flash_exit();
	}
	else//turn on torch
	{
		if(level >= TORCH_LUM_LEVEL_NUM)
		{
			print_error("Input the wrong number\n");
			ret = -1;
			goto out;
		}
		scharger_flash_turn_off();//turn off first if we want to change lum

		ret = scharger_flash_turn_on(TORCH_MODE, level);
		if(ret < 0) {
			print_error("set light level error");
			ret = -1;
			goto out;
		}
		brightness_level = level;
	}

	ret = count;

out:
	SAFE_UP(&busy_lock);
	return ret;
}
Ejemplo n.º 20
0
static ssize_t pmu_reg_store(struct device *dev, struct device_attribute *attr,
			     const char *buf, size_t count)
{
	int ret;
	int addr;
	uint8_t value;
	char *arg[3] = {}, *para, *buf_work, *p;
	int i;

	buf_work = kstrdup(buf, GFP_KERNEL);
	p = buf_work;
	for (i = 0; i < 3; i++) {
		para = strsep(&p, " ");
		if (para == NULL)
			break;
		arg[i] = para;
	}
	if (i < 2 || i > 3) {
		ret = 1;
		goto error;
	}
	switch (arg[0][0]) {
	case 'r':
		ret = kstrtoint(arg[1], 16, &addr);
		ret = aml1216_read(addr, &value);
		if (!ret)
			pr_info("reg[0x%02x] = 0x%02x\n", addr, value);
		break;

	case 'w':
		if (i != 3) {   /* parameter is not enough */
			ret = 1;
			break;
		}
		ret = kstrtoint(arg[1], 16, &addr);
		ret = kstrtou8(arg[2], 16, &value);
		ret   = aml1216_write(addr, value);
		if (!ret)
			pr_info("set reg[0x%02x] to 0x%02x\n", addr, value);
		break;

	default:
		ret = 1;
		break;
	}
error:
	kfree(buf_work);
	if (ret == 1)
		printf_usage();
	return count;
}
Ejemplo n.º 21
0
static ssize_t usb2_lpm_besl_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t count)
{
	struct usb_device *udev = to_usb_device(dev);
	u8 besl;

	if (kstrtou8(buf, 0, &besl) || besl > 15)
		return -EINVAL;

	udev->l1_params.besl = besl;

	return count;
}
Ejemplo n.º 22
0
static ssize_t ieee80211_if_parse_tdls_wider_bw(
	struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
{
	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
	u8 val;
	int ret;

	ret = kstrtou8(buf, 0, &val);
	if (ret)
		return ret;

	ifmgd->tdls_wider_bw_prohibited = !val;
	return buflen;
}
static ssize_t pm830_dump_write(struct file *file,
				const char __user *user_buf,
				size_t count, loff_t *ppos)
{
	u8 reg_val;
	struct pm830_chip *chip = file->private_data;
	int i = 0;
	int ret;

	char messages[20];
	memset(messages, '\0', 20);

	if (copy_from_user(messages, user_buf, count))
		return -EFAULT;

	if ('+' == messages[0]) {
		/* enable to get all the reg value */
		reg_pm830 = 0xffff;
		pr_info("read all reg enabled!\n");
	} else {
		if (messages[1] != 'x') {
			pr_err("Right format: 0x[addr]\n");
			return -EINVAL;
		}

		if (strlen(messages) > 5) {
			while (messages[i] != ' ')
				i++;
			messages[i] = '\0';
			if (kstrtouint(messages, 16, &reg_pm830) < 0)
				return -EINVAL;
			i++;
			if (kstrtou8(messages + i, 16, &reg_val) < 0)
				return -EINVAL;
			ret = regmap_write(chip->regmap, reg_pm830,
					   reg_val & 0xff);
			if (ret < 0) {
				pr_err("write reg error!\n");
				return -EINVAL;
			}
		} else {
			if (kstrtouint(messages, 16, &reg_pm830) < 0)
				return -EINVAL;
		}
	}

	return count;
}
ssize_t temphumidity_send_accuracy(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	struct ssp_data *data = dev_get_drvdata(dev);
	u8 accuracy;

	if (kstrtou8(buf, 10, &accuracy) < 0) {
		pr_err("[SSP] %s - read buf is fail(%s)\n", __func__, buf);
		return size;
	}

	if (accuracy == DONE_CAL)
		ssp_send_cmd(data, MSG2SSP_AP_TEMPHUMIDITY_CAL_DONE);
	pr_info("[SSP] %s - accuracy = %d\n", __func__, accuracy);

	return size;
}
Ejemplo n.º 25
0
static ssize_t store_pwm(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t len)
{
	struct lm3533_bl *bl = dev_get_drvdata(dev);
	u8 val;
	int ret;

	if (kstrtou8(buf, 0, &val))
		return -EINVAL;

	ret = lm3533_ctrlbank_set_pwm(&bl->cb, val);
	if (ret)
		return ret;

	return len;
}
/**
 * ipv4str_to_be32 - ipv4 string to be32 (big endian 32bits integer)
 * @return: return zero when errors occurred
 */
__be32 ipv4str_to_be32(const char *ipv4str, size_t count)
{
    unsigned char ip[4];
    char ipstr[16]; /* == strlen("xxx.xxx.xxx.xxx") + 1 */
    char *next = ipstr;
    char *p;
    int i;

    strncpy(ipstr, ipv4str, ARRAY_SIZE(ipstr));

    for (i = 0; i < 4; i++) {
        p = strsep(&next, ".");
        if (kstrtou8(p, 10, &ip[i]) < 0)
            return 0; /* == 0.0.0.0 */
    }

    return *((__be32 *)ip);
}
Ejemplo n.º 27
0
static ssize_t ieee80211_if_parse_uapsd_queues(
	struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
{
	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
	u8 val;
	int ret;

	ret = kstrtou8(buf, 0, &val);
	if (ret)
		return ret;

	if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK)
		return -ERANGE;

	ifmgd->uapsd_queues = val;

	return buflen;
}
Ejemplo n.º 28
0
static ssize_t ak09911c_enable_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	u8 enable;
	int ret;
	struct ak09911c_p *data = dev_get_drvdata(dev);

	ret = kstrtou8(buf, 2, &enable);
	if (ret) {
		pr_err("%s Invalid Argument\n", __func__);
		return ret;
	}

	pr_info("%s new_value = %u\n", __func__, enable);
	if ((enable == 0) || (enable == 1))
		ak09911c_set_enable(data, (int)enable);

	return size;
}
static ssize_t store_max77828_rgb_lowpower(struct device *dev,
					struct device_attribute *devattr,
					const char *buf, size_t count)
{
	int ret;
	u8 led_lowpower;

	ret = kstrtou8(buf, 0, &led_lowpower);
	if (ret != 0) {
		dev_err(dev, "fail to get led_lowpower.\n");
		return count;
	}

	led_lowpower_mode = led_lowpower;

	dev_dbg(dev, "led_lowpower mode set to %i\n", led_lowpower);

	return count;
}
Ejemplo n.º 30
0
static ssize_t proximity_thresh_store(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	struct ssp_data *data = dev_get_drvdata(dev);
	u8 uNewThresh = 0x09;
	int iRet = 0;

	iRet = kstrtou8(buf, 10, &uNewThresh);
	if (iRet < 0)
		pr_err("[SSP]: %s - kstrtoint failed.", __func__);

	data->uProxThresh = uNewThresh;
	set_proximity_threshold(data);

	ssp_dbg("[SSP]: %s - new prox threshold = 0x%x\n",
		__func__, data->uProxThresh);

	return size;
}