• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ simple_write_to_buffer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中simple_write_to_buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ simple_write_to_buffer函数的具体用法?C++ simple_write_to_buffer怎么用?C++ simple_write_to_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了simple_write_to_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: char_write

static ssize_t char_write(struct file* file, const char __user *buf,
                          size_t count, loff_t *ppos)
{
    ssize_t num_wr;
    printk( KERN_INFO "char_test, called char_write");

    memset( payload, 0, SIZE);

    if( count > (SIZE-1) )
      num_wr = simple_write_to_buffer(payload, SIZE-1, ppos, buf, count);
    else
      num_wr = simple_write_to_buffer(payload, strlen(buf), ppos, buf, count);
    
    return num_wr;
}
开发者ID:mpasko,项目名称:cpp_real_time_krk_31,代码行数:15,代码来源:char_test.c


示例2: snapshot_write

static ssize_t snapshot_write(struct file *filp, const char __user *buf,
                              size_t count, loff_t *offp)
{
	struct snapshot_data *data;
	ssize_t res;
	loff_t pg_offp = *offp & ~PAGE_MASK;

	mutex_lock(&pm_mutex);

	data = filp->private_data;

	if (!pg_offp) {
		res = snapshot_write_next(&data->handle);
		if (res <= 0)
			goto unlock;
	} else {
		res = PAGE_SIZE - pg_offp;
	}

	res = simple_write_to_buffer(data_of(data->handle), res, &pg_offp,
			buf, count);
	if (res > 0)
		*offp += res;
unlock:
	mutex_unlock(&pm_mutex);

	return res;
}
开发者ID:LorDClockaN,项目名称:htc_spade_2.6.35,代码行数:28,代码来源:user.c


示例3: xgbe_common_write

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;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:25,代码来源:xgbe-debugfs.c


示例4: data_write

static ssize_t data_write(struct file *file, const char __user *data, size_t count, loff_t *ppos)
{
	ssize_t size;
	struct regulator_dev *rdev = file->private_data;
	struct s2mps13_info *info = rdev_get_drvdata(rdev);
	int reg_id = rdev_get_id(rdev);
	char buffer[9];

	size = simple_write_to_buffer(buffer, ARRAY_SIZE(buffer), ppos, data, count);

	if (size > 0) {
		if (strncasecmp("OFF", buffer, sizeof("OFF") - 1) == 0) {
			info->opmode[reg_id] = SEC_OPMODE_OFF << S2MPS13_ENABLE_SHIFT;
		} else if (strncasecmp("SUSPEND", buffer, sizeof("SUSPEND") - 1) == 0) {
			info->opmode[reg_id] = SEC_OPMODE_SUSPEND << S2MPS13_ENABLE_SHIFT;
		} else if (strncasecmp("LOWPOWER", buffer, sizeof("LOWPOWER") - 1) == 0) {
			info->opmode[reg_id] = SEC_OPMODE_LOWPOWER << S2MPS13_ENABLE_SHIFT;
		} else if (strncasecmp("ON", buffer, sizeof("ON") - 1) == 0) {
			info->opmode[reg_id] = SEC_OPMODE_ON << S2MPS13_ENABLE_SHIFT;
		} else {
			buffer[ARRAY_SIZE(buffer) - 1] = '\0';
			pr_err("%s is not recognizable.\n", buffer);
		}
	}

	s2m_enable(rdev);

	pr_debug("%s: size=%zd\n", __func__, size);
	return size;
}
开发者ID:qkdang,项目名称:m462,代码行数:30,代码来源:s2mps13.c


示例5: data_write_normalmode

static ssize_t data_write_normalmode(struct file *file, const char __user *data, size_t count, loff_t *ppos)
{
	ssize_t size = 0;
	char buffer[8];
	int* gpio = file->private_data;
	size = simple_write_to_buffer(buffer, ARRAY_SIZE(buffer), ppos, data, count);

	if(size > 0) {
		if(strncasecmp("ON",buffer,sizeof("ON")-1) == 0) {
			if (gpio_request(*gpio, "LED_CONTROL")) {
				pr_err("%s : GPIO_LED request port error\n", __func__);
			} else {
				gpio_direction_output(*gpio, 1);
				gpio_free(*gpio);
			}
		} else if (strncasecmp("OFF",buffer,sizeof("OFF")-1) == 0) {
			if (gpio_request(*gpio, "LED_CONTROL")) {
				pr_err("%s : GPIO_LED request port error\n", __func__);
			} else {
				gpio_direction_output(*gpio, 0);
				gpio_free(*gpio);
			}
		}
	}

	return size;
}
开发者ID:akvaro,项目名称:android_kernel_meizu_mx4pro,代码行数:27,代码来源:leds-S5430.c


示例6: data_write_sleepmode

static ssize_t data_write_sleepmode(struct file *file, const char __user *data, size_t count, loff_t *ppos)
{
	ssize_t size = 0;
	char buffer[8];
	int* gpio = file->private_data;
	size = simple_write_to_buffer(buffer, ARRAY_SIZE(buffer), ppos, data, count);

	printk("Led : because of sleep current, S5430 turn off LED\n");
	if(size > 0) {
		if(strncasecmp("ON",buffer,sizeof("ON")-1) == 0) {
			if (gpio_request(*gpio, "LED_CONTROL")) {
				pr_err("%s : GPIO_LED request port error\n", __func__);
			} else {
				gpio_free(*gpio);
			}
		} else if (strncasecmp("OFF",buffer,sizeof("OFF")-1) == 0) {
			if (gpio_request(*gpio, "LED_CONTROL")) {
				pr_err("%s : GPIO_LED request port error\n", __func__);
			} else {
				gpio_free(*gpio);
			}
		}
	}

	return size;
}
开发者ID:akvaro,项目名称:android_kernel_meizu_mx4pro,代码行数:26,代码来源:leds-S5430.c


示例7: wil_write_file_wmi

/* Write WMI command (w/o mbox header) to this file to send it
 * WMI starts from wil6210_mbox_hdr_wmi header
 */
static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
				  size_t len, loff_t *ppos)
{
	struct wil6210_priv *wil = file->private_data;
	struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev);
	struct wmi_cmd_hdr *wmi;
	void *cmd;
	int cmdlen = len - sizeof(struct wmi_cmd_hdr);
	u16 cmdid;
	int rc, rc1;

	if (cmdlen < 0)
		return -EINVAL;

	wmi = kmalloc(len, GFP_KERNEL);
	if (!wmi)
		return -ENOMEM;

	rc = simple_write_to_buffer(wmi, len, ppos, buf, len);
	if (rc < 0) {
		kfree(wmi);
		return rc;
	}

	cmd = (cmdlen > 0) ? &wmi[1] : NULL;
	cmdid = le16_to_cpu(wmi->command_id);

	rc1 = wmi_send(wil, cmdid, vif->mid, cmd, cmdlen);
	kfree(wmi);

	wil_info(wil, "0x%04x[%d] -> %d\n", cmdid, cmdlen, rc1);

	return rc;
}
开发者ID:lumag,项目名称:linux,代码行数:37,代码来源:debugfs.c


示例8: hifi_debug_level_store

static ssize_t hifi_debug_level_store(struct file *file, const char __user *buf,
		size_t size, loff_t *data)
{
	ssize_t ret = 0;
	char level_str[MAX_LEVEL_STR_LEN] = {0};
	loff_t pos = 0;

	if (NULL == buf) {
		loge("Input param buf is invalid\n");
		return -EINVAL;
	}
	ret = simple_write_to_buffer(level_str, MAX_LEVEL_STR_LEN - 1 , &pos, buf, size);
	if (ret != size) {
		loge("Input param buf read error, return value: %zd\n", ret);
		return -EINVAL;
	}

	if (!strchr("diwe", level_str[0])) {
		loge("Input param buf is error(valid: d,i,w,e): %s.\n", level_str);
		return -EINVAL;
	}
	if (level_str[1] != '\n') {
		loge("Input param buf is error, last char is not \\n .\n");
		return -EINVAL;
	}

	g_om_data.debug_level = hifi_get_debug_level_num(level_str[0]);
	return size;
}
开发者ID:debbiche,项目名称:android_kernel_huawei_p8,代码行数:29,代码来源:hifi_om.c


示例9: upgrade_proc_write

static ssize_t upgrade_proc_write(struct file *file, const char __user *buf, 
            size_t count, loff_t *ppos)
{
    struct partition_package *package;
    int err;
    size_t size;
    //int len;

    package = kzalloc(count, GFP_KERNEL);
    if (!package) {
        err = -ENOMEM;
        part_err("upgrade_proc_write: fail to malloc package\n");
        goto fail_malloc;
    }

    size = simple_write_to_buffer(package, sizeof(*package), ppos, buf, count);
    if (size < 0) {
        err = size;
        part_err("upgrade_proc_write: fail to receive data(%zu)\n", size);
        goto out;
    }

    err = upgrade_handler(package, size);
    
out:
    kfree(package);
fail_malloc:
    if (err)
        return err;
    else
        return count;
}
开发者ID:Jlsmily,项目名称:android_kernel_meilan2,代码行数:32,代码来源:partition.c


示例10: wil_write_file_wmi

/* Write WMI command (w/o mbox header) to this file to send it
 * WMI starts from wil6210_mbox_hdr_wmi header
 */
static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
				  size_t len, loff_t *ppos)
{
	struct wil6210_priv *wil = file->private_data;
	struct wil6210_mbox_hdr_wmi *wmi;
	void *cmd;
	int cmdlen = len - sizeof(struct wil6210_mbox_hdr_wmi);
	u16 cmdid;
	int rc, rc1;

	if (cmdlen <= 0)
		return -EINVAL;

	wmi = kmalloc(len, GFP_KERNEL);
	if (!wmi)
		return -ENOMEM;

	rc = simple_write_to_buffer(wmi, len, ppos, buf, len);
	if (rc < 0)
		return rc;

	cmd = &wmi[1];
	cmdid = le16_to_cpu(wmi->id);

	rc1 = wmi_send(wil, cmdid, cmd, cmdlen);
	kfree(wmi);

	wil_info(wil, "%s(0x%04x[%d]) -> %d\n", __func__, cmdid, cmdlen, rc1);

	return rc;
}
开发者ID:3null,项目名称:linux,代码行数:34,代码来源:debugfs.c


示例11: ath10k_write_htt_max_amsdu_ampdu

static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file,
						const char __user *user_buf,
						size_t count, loff_t *ppos)
{
	struct ath10k *ar = file->private_data;
	int res;
	char buf[64];
	unsigned int amsdu, ampdu;

	simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);

	/* make sure that buf is null terminated */
	buf[sizeof(buf) - 1] = 0;

	res = sscanf(buf, "%u %u", &amsdu, &ampdu);

	if (res != 2)
		return -EINVAL;

	mutex_lock(&ar->conf_mutex);

	res = ath10k_htt_h2t_aggr_cfg_msg(&ar->htt, ampdu, amsdu);
	if (res)
		goto out;

	res = count;
	ar->debug.htt_max_amsdu = amsdu;
	ar->debug.htt_max_ampdu = ampdu;

out:
	mutex_unlock(&ar->conf_mutex);
	return res;
}
开发者ID:AkyZero,项目名称:wrapfs-latest,代码行数:33,代码来源:debug.c


示例12: fop_write

static ssize_t
fop_write(struct file *file, const char __user *user_buf,
	  size_t count,
	  loff_t *ppos)
{
	int len;
	TfwDebugfsIoState *state = file->private_data;

	if (!state->is_input) {
		TFW_ERR("Can't write to this debugfs file: "
			"it was open()'ed only for reading\n");
		return -EPERM;
	}

	/* copy data from user-space */
	len = simple_write_to_buffer(state->buf, (state->buf_size - 1),
				     ppos,
				     user_buf, count);
	if (len > 0) {
		state->len += len;
		state->buf[state->len] = '\0';
	}

	return len;
}
开发者ID:twdow,项目名称:tempesta,代码行数:25,代码来源:debugfs.c


示例13: xenvif_write_io_ring

static ssize_t
xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count,
		     loff_t *ppos)
{
	struct xenvif_queue *queue =
		((struct seq_file *)filp->private_data)->private;
	int len;
	char write[BUFFER_SIZE];

	/* don't allow partial writes and check the length */
	if (*ppos != 0)
		return 0;
	if (count >= sizeof(write))
		return -ENOSPC;

	len = simple_write_to_buffer(write,
				     sizeof(write) - 1,
				     ppos,
				     buf,
				     count);
	if (len < 0)
		return len;

	write[len] = '\0';

	if (!strncmp(write, XENVIF_KICK_STR, sizeof(XENVIF_KICK_STR) - 1))
		xenvif_interrupt(0, (void *)queue);
	else {
		pr_warn("Unknown command to io_ring_q%d. Available: kick\n",
			queue->id);
		count = -EINVAL;
	}
	return count;
}
开发者ID:gxt,项目名称:linux,代码行数:34,代码来源:xenbus.c


示例14: baseline_debugfs_write

static ssize_t baseline_debugfs_write(struct file *filp,
		const char __user *buf, size_t count, loff_t *ppos)
{
	struct cyttsp5_device_access_debugfs_data *data = filp->private_data;
	struct cyttsp5_device_access_data *dad = data->dad;
	ssize_t length;
	int rc = 0;

	rc = simple_write_to_buffer(data->pr_buf, sizeof(data->pr_buf), ppos,
			buf, count);
	if (rc < 0)
		return rc;

	count = rc;

	mutex_lock(&dad->sysfs_lock);

	length = cyttsp5_ic_parse_input(dad->dev, buf, count, dad->ic_buf,
			CY_MAX_PRBUF_SIZE);
	if (length != 1) {
		dev_err(dad->dev, "%s: Malformed input\n", __func__);
		rc = -EINVAL;
		goto exit_unlock;
	}

	dad->baseline_sensing_mode = dad->ic_buf[0];

exit_unlock:
	mutex_unlock(&dad->sysfs_lock);

	if (rc)
		return rc;

	return count;
}
开发者ID:jemisa,项目名称:N939St_5.1_kenel,代码行数:35,代码来源:cyttsp5_device_access.c


示例15: tee_write_file_settings_tz

static ssize_t tee_write_file_settings_tz(struct file *file,
				       const char __user *user_buf,
				       size_t count, loff_t *ppos)
{
	struct device *dev = file->private_data;
	char *buf;
	char *str;
	int val;

	buf = devm_kzalloc(dev, count, GFP_KERNEL);
	if (!buf) {
		dev_err(dev, "can't allocate work buffer\n");
		return count;
	}

	val = simple_write_to_buffer(buf, count, ppos, user_buf, count);
	if (!val) {
		dev_err(dev, "no user data\n");
		goto out;
	}

	str = strstr(buf, STR_DUMP_ALLOCATOR);
	if (str)
		tee_shm_pool_dump(dev, TZop.Allocator, true);

	str = strstr(buf, STR_CMD_HIST);
	if (str)
		tee_debug_dump_cmd_hist(dev, NULL, 0);

out:
	devm_kfree(dev, buf);
	return count;
}
开发者ID:fhector,项目名称:optee_linuxdriver,代码行数:33,代码来源:tee_tz_debug.c


示例16: wil_write_file_ssid

static ssize_t wil_write_file_ssid(struct file *file, const char __user *buf,
				   size_t count, loff_t *ppos)
{
	struct wil6210_priv *wil = file->private_data;
	struct wireless_dev *wdev = wil_to_wdev(wil);
	struct net_device *ndev = wil_to_ndev(wil);

	if (*ppos != 0) {
		wil_err(wil, "Unable to set SSID substring from [%d]\n",
			(int)*ppos);
		return -EINVAL;
	}

	if (count > sizeof(wdev->ssid)) {
		wil_err(wil, "SSID too long, len = %d\n", (int)count);
		return -EINVAL;
	}
	if (netif_running(ndev)) {
		wil_err(wil, "Unable to change SSID on running interface\n");
		return -EINVAL;
	}

	wdev->ssid_len = count;
	return simple_write_to_buffer(wdev->ssid, wdev->ssid_len, ppos,
				      buf, count);
}
开发者ID:AICP,项目名称:kernel_moto_shamu,代码行数:26,代码来源:debugfs.c


示例17: mywriter

/* write file operation */
static ssize_t mywriter(struct file *fp, const char __user *user_buffer,
                                size_t count, loff_t *position)
{
        if(count > len )
                return -EINVAL;
 	printk("writing\n"); 
        return simple_write_to_buffer(ker_buf, len, position, user_buffer, count);
}
开发者ID:gokul-github,项目名称:linuxpedia,代码行数:9,代码来源:exp_debugfs.c


示例18: tool_peer_mw_write

static ssize_t tool_peer_mw_write(struct file *filep, const char __user *ubuf,
				  size_t size, loff_t *offp)
{
	struct tool_mw *mw = filep->private_data;

	if (!mw->peer)
		return -ENXIO;

	return simple_write_to_buffer(mw->peer, mw->size, offp, ubuf, size);
}
开发者ID:mdamt,项目名称:linux,代码行数:10,代码来源:ntb_tool.c


示例19: configfs_write_bin_file

static ssize_t
configfs_write_bin_file(struct file *file, const char __user *buf,
			size_t count, loff_t *ppos)
{
	struct configfs_buffer *buffer = file->private_data;
	struct dentry *dentry = file->f_path.dentry;
	struct configfs_bin_attribute *bin_attr = to_bin_attr(dentry);
	void *tbuf = NULL;
	ssize_t len;

	mutex_lock(&buffer->mutex);

	/* we don't support switching read/write modes */
	if (buffer->read_in_progress) {
		len = -ETXTBSY;
		goto out;
	}
	buffer->write_in_progress = 1;

	/* buffer grows? */
	if (*ppos + count > buffer->bin_buffer_size) {

		if (bin_attr->cb_max_size &&
			*ppos + count > bin_attr->cb_max_size) {
			len = -EFBIG;
		}

		tbuf = vmalloc(*ppos + count);
		if (tbuf == NULL) {
			len = -ENOMEM;
			goto out;
		}

		/* copy old contents */
		if (buffer->bin_buffer) {
			memcpy(tbuf, buffer->bin_buffer,
				buffer->bin_buffer_size);
			vfree(buffer->bin_buffer);
		}

		/* clear the new area */
		memset(tbuf + buffer->bin_buffer_size, 0,
			*ppos + count - buffer->bin_buffer_size);
		buffer->bin_buffer = tbuf;
		buffer->bin_buffer_size = *ppos + count;
	}

	len = simple_write_to_buffer(buffer->bin_buffer,
			buffer->bin_buffer_size, ppos, buf, count);
	if (len > 0)
		*ppos += len;
out:
	mutex_unlock(&buffer->mutex);
	return len;
}
开发者ID:a2hojsjsjs,项目名称:linux,代码行数:55,代码来源:file.c


示例20: wil_write_back

/* block ack control, write:
 * - "add <ringid> <agg_size> <timeout>" to trigger ADDBA
 * - "del_tx <ringid> <reason>" to trigger DELBA for Tx side
 * - "del_rx <CID> <TID> <reason>" to trigger DELBA for Rx side
 */
static ssize_t wil_write_back(struct file *file, const char __user *buf,
			      size_t len, loff_t *ppos)
{
	struct wil6210_priv *wil = file->private_data;
	int rc;
	char *kbuf = kmalloc(len + 1, GFP_KERNEL);
	char cmd[9];
	int p1, p2, p3;

	if (!kbuf)
		return -ENOMEM;

	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
	if (rc != len) {
		kfree(kbuf);
		return rc >= 0 ? -EIO : rc;
	}

	kbuf[len] = '\0';
	rc = sscanf(kbuf, "%8s %d %d %d", cmd, &p1, &p2, &p3);
	kfree(kbuf);

	if (rc < 0)
		return rc;
	if (rc < 2)
		return -EINVAL;

	if (0 == strcmp(cmd, "add")) {
		if (rc < 3) {
			wil_err(wil, "BACK: add require at least 2 params\n");
			return -EINVAL;
		}
		if (rc < 4)
			p3 = 0;
		wmi_addba(wil, p1, p2, p3);
	} else if (0 == strcmp(cmd, "del_tx")) {
		if (rc < 3)
			p2 = WLAN_REASON_QSTA_LEAVE_QBSS;
		wmi_delba_tx(wil, p1, p2);
	} else if (0 == strcmp(cmd, "del_rx")) {
		if (rc < 3) {
			wil_err(wil,
				"BACK: del_rx require at least 2 params\n");
			return -EINVAL;
		}
		if (rc < 4)
			p3 = WLAN_REASON_QSTA_LEAVE_QBSS;
		wmi_delba_rx(wil, mk_cidxtid(p1, p2), p3);
	} else {
		wil_err(wil, "BACK: Unrecognized command \"%s\"\n", cmd);
		return -EINVAL;
	}

	return len;
}
开发者ID:acton393,项目名称:linux,代码行数:60,代码来源:debugfs.c



注:本文中的simple_write_to_buffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ simplify函数代码示例发布时间:2022-05-30
下一篇:
C++ simple_unlock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap