Пример #1
0
/* Reading the proc file will show status (not the firmware contents) */
static ssize_t rtas_flash_read(struct file *file, char __user *buf,
			       size_t count, loff_t *ppos)
{
	struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
	struct rtas_update_flash_t *uf;
	char msg[RTAS_MSG_MAXLEN];
	int msglen;

	uf = (struct rtas_update_flash_t *) dp->data;

	if (!strcmp(dp->name, FIRMWARE_FLASH_NAME)) {
		get_flash_status_msg(uf->status, msg);
	} else {	   /* FIRMWARE_UPDATE_NAME */
		sprintf(msg, "%d\n", uf->status);
	}
	msglen = strlen(msg);
	if (msglen > count)
		msglen = count;

	if (ppos && *ppos != 0)
		return 0;	/* be cheap */

	if (!access_ok(VERIFY_WRITE, buf, msglen))
		return -EINVAL;

	if (copy_to_user(buf, msg, msglen))
		return -EFAULT;

	if (ppos)
		*ppos = msglen;
	return msglen;
}
/* Reading the proc file will show status (not the firmware contents) */
static ssize_t rtas_flash_read_msg(struct file *file, char __user *buf,
				   size_t count, loff_t *ppos)
{
	struct rtas_update_flash_t *const uf = &rtas_update_flash_data;
	char msg[RTAS_MSG_MAXLEN];
	size_t len;
	int status;

	mutex_lock(&rtas_update_flash_mutex);
	status = uf->status;
	mutex_unlock(&rtas_update_flash_mutex);

	/* Read as text message */
	len = get_flash_status_msg(status, msg);
	return simple_read_from_buffer(buf, count, ppos, msg, len);
}
Пример #3
0
/* Reading the proc file will show status (not the firmware contents) */
static ssize_t rtas_flash_read(struct file *file, char __user *buf,
			       size_t count, loff_t *ppos)
{
	struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
	struct rtas_update_flash_t *uf;
	char msg[RTAS_MSG_MAXLEN];

	uf = dp->data;

	if (!strcmp(dp->name, FIRMWARE_FLASH_NAME)) {
		get_flash_status_msg(uf->status, msg);
	} else {	   /* FIRMWARE_UPDATE_NAME */
		sprintf(msg, "%d\n", uf->status);
	}

	return simple_read_from_buffer(buf, count, ppos, msg, strlen(msg));
}