Skip to content
Snippets Groups Projects
Commit 692a73c6 authored by Alessandro Rubini's avatar Alessandro Rubini
Browse files

channel struct: rename current_block to user_block


Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: default avatarFederico Vaga <federico.vaga@gmail.com>
parent 369995bb
Branches
Tags
No related merge requests found
...@@ -243,7 +243,7 @@ struct zio_channel { ...@@ -243,7 +243,7 @@ struct zio_channel {
struct device *ctrl_dev; /* control char device */ struct device *ctrl_dev; /* control char device */
struct device *data_dev; /* data char device */ struct device *data_dev; /* data char device */
struct zio_block *current_block; /* the one being transferred */ struct zio_block *user_block; /* being transferred w/ user */
void *t_priv; /* used by trigger */ void *t_priv; /* used by trigger */
}; };
......
...@@ -288,22 +288,22 @@ static int __zio_read_allowed(struct zio_f_priv *priv) ...@@ -288,22 +288,22 @@ static int __zio_read_allowed(struct zio_f_priv *priv)
struct zio_bi *bi = chan->bi; struct zio_bi *bi = chan->bi;
const int can_read = POLLIN | POLLRDNORM; const int can_read = POLLIN | POLLRDNORM;
if (!chan->current_block) if (!chan->user_block)
chan->current_block = bi->b_op->retr_block(bi); chan->user_block = bi->b_op->retr_block(bi);
if (!chan->current_block) if (!chan->user_block)
return 0; return 0;
/* We have a block. So there is data and possibly control too */ /* We have a block. So there is data and possibly control too */
if (likely(priv->type == ZIO_CDEV_DATA)) if (likely(priv->type == ZIO_CDEV_DATA))
return can_read; return can_read;
if (!zio_is_cdone(chan->current_block)) if (!zio_is_cdone(chan->user_block))
return POLLIN | POLLRDNORM; return POLLIN | POLLRDNORM;
/* There's a block, but we want to re-read control. Get a new block */ /* There's a block, but we want to re-read control. Get a new block */
bi->b_op->free_block(bi, chan->current_block); bi->b_op->free_block(bi, chan->user_block);
chan->current_block = bi->b_op->retr_block(bi); chan->user_block = bi->b_op->retr_block(bi);
if (!chan->current_block) if (!chan->user_block)
return 0; return 0;
return POLLIN | POLLRDNORM; return POLLIN | POLLRDNORM;
} }
...@@ -339,9 +339,9 @@ static int __zio_write_allowed(struct zio_f_priv *priv) ...@@ -339,9 +339,9 @@ static int __zio_write_allowed(struct zio_f_priv *priv)
} }
/* We want to write data. If we have no control, retrieve one */ /* We want to write data. If we have no control, retrieve one */
if (!chan->current_block) if (!chan->user_block)
chan->current_block = __zio_write_allocblock(bi, NULL); chan->user_block = __zio_write_allocblock(bi, NULL);
block = chan->current_block; block = chan->user_block;
if (!block) if (!block)
return 0; return 0;
...@@ -354,8 +354,8 @@ static int __zio_write_allowed(struct zio_f_priv *priv) ...@@ -354,8 +354,8 @@ static int __zio_write_allowed(struct zio_f_priv *priv)
return 0; return 0;
/* We sent it: get a new one for this new data */ /* We sent it: get a new one for this new data */
chan->current_block = __zio_write_allocblock(bi, NULL); chan->user_block = __zio_write_allocblock(bi, NULL);
return chan->current_block ? can_write : 0; return chan->user_block ? can_write : 0;
} }
/* /*
...@@ -389,7 +389,7 @@ ssize_t zio_generic_read(struct file *f, char __user *ubuf, ...@@ -389,7 +389,7 @@ ssize_t zio_generic_read(struct file *f, char __user *ubuf,
if (signal_pending(current)) if (signal_pending(current))
return -ERESTARTSYS; return -ERESTARTSYS;
} }
block = chan->current_block; block = chan->user_block;
/* So, it's readable */ /* So, it's readable */
if (unlikely(priv->type == ZIO_CDEV_CTRL)) { if (unlikely(priv->type == ZIO_CDEV_CTRL)) {
...@@ -408,7 +408,7 @@ ssize_t zio_generic_read(struct file *f, char __user *ubuf, ...@@ -408,7 +408,7 @@ ssize_t zio_generic_read(struct file *f, char __user *ubuf,
*offp += count; *offp += count;
block->uoff += count; block->uoff += count;
if (block->uoff == block->datalen) { if (block->uoff == block->datalen) {
chan->current_block = NULL; chan->user_block = NULL;
bi->b_op->free_block(bi, block); bi->b_op->free_block(bi, block);
} }
return count; return count;
...@@ -442,7 +442,7 @@ ssize_t zio_generic_write(struct file *f, const char __user *ubuf, ...@@ -442,7 +442,7 @@ ssize_t zio_generic_write(struct file *f, const char __user *ubuf,
if (likely(priv->type == ZIO_CDEV_DATA)) { if (likely(priv->type == ZIO_CDEV_DATA)) {
/* Data is writeable, so we have space in this block */ /* Data is writeable, so we have space in this block */
block = chan->current_block; block = chan->user_block;
if (count > block->datalen - block->uoff) if (count > block->datalen - block->uoff)
count = block->datalen - block->uoff; count = block->datalen - block->uoff;
if (copy_from_user(block->data + block->uoff, ubuf, count)) if (copy_from_user(block->data + block->uoff, ubuf, count))
...@@ -450,7 +450,7 @@ ssize_t zio_generic_write(struct file *f, const char __user *ubuf, ...@@ -450,7 +450,7 @@ ssize_t zio_generic_write(struct file *f, const char __user *ubuf,
block->uoff += count; block->uoff += count;
if (block->uoff == block->datalen) if (block->uoff == block->datalen)
if (bi->b_op->store_block(bi, block) == 0) if (bi->b_op->store_block(bi, block) == 0)
chan->current_block = NULL; chan->user_block = NULL;
return count; return count;
} }
...@@ -459,9 +459,9 @@ ssize_t zio_generic_write(struct file *f, const char __user *ubuf, ...@@ -459,9 +459,9 @@ ssize_t zio_generic_write(struct file *f, const char __user *ubuf,
return -EINVAL; return -EINVAL;
count = ZIO_CONTROL_SIZE; count = ZIO_CONTROL_SIZE;
if (chan->current_block) if (chan->user_block)
bi->b_op->free_block(bi, chan->current_block); bi->b_op->free_block(bi, chan->user_block);
chan->current_block = NULL; chan->user_block = NULL;
ctrl = zio_alloc_control(GFP_KERNEL); ctrl = zio_alloc_control(GFP_KERNEL);
if (!ctrl) if (!ctrl)
return -ENOMEM; return -ENOMEM;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment