本文整理汇总了C++中simple_write_to_buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ simple_write_to_buffer函数的具体用法?C++ simple_write_to_buffer怎么用?C++ simple_write_to_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了simple_write_to_buffer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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, &du);
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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}