Commit d8b082e6 authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman

staging: most: rename variable channel

This patch renames the variable 'channel' to 'c'. This is needed to have
the code look more homogeneous and to prevent format violations.
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cdc293d5
...@@ -57,13 +57,13 @@ static inline bool ch_has_mbo(struct aim_channel *c) ...@@ -57,13 +57,13 @@ static inline bool ch_has_mbo(struct aim_channel *c)
static struct aim_channel *get_channel(struct most_interface *iface, int id) static struct aim_channel *get_channel(struct most_interface *iface, int id)
{ {
struct aim_channel *channel, *tmp; struct aim_channel *c, *tmp;
unsigned long flags; unsigned long flags;
int found_channel = 0; int found_channel = 0;
spin_lock_irqsave(&ch_list_lock, flags); spin_lock_irqsave(&ch_list_lock, flags);
list_for_each_entry_safe(channel, tmp, &channel_list, list) { list_for_each_entry_safe(c, tmp, &channel_list, list) {
if ((channel->iface == iface) && (channel->channel_id == id)) { if ((c->iface == iface) && (c->channel_id == id)) {
found_channel = 1; found_channel = 1;
break; break;
} }
...@@ -71,7 +71,7 @@ static struct aim_channel *get_channel(struct most_interface *iface, int id) ...@@ -71,7 +71,7 @@ static struct aim_channel *get_channel(struct most_interface *iface, int id)
spin_unlock_irqrestore(&ch_list_lock, flags); spin_unlock_irqrestore(&ch_list_lock, flags);
if (!found_channel) if (!found_channel)
return NULL; return NULL;
return channel; return c;
} }
static void stop_channel(struct aim_channel *c) static void stop_channel(struct aim_channel *c)
...@@ -108,29 +108,29 @@ static void destroy_cdev(struct aim_channel *c) ...@@ -108,29 +108,29 @@ static void destroy_cdev(struct aim_channel *c)
*/ */
static int aim_open(struct inode *inode, struct file *filp) static int aim_open(struct inode *inode, struct file *filp)
{ {
struct aim_channel *channel; struct aim_channel *c;
int ret; int ret;
channel = to_channel(inode->i_cdev); c = to_channel(inode->i_cdev);
filp->private_data = channel; filp->private_data = c;
if (((channel->cfg->direction == MOST_CH_RX) && if (((c->cfg->direction == MOST_CH_RX) &&
((filp->f_flags & O_ACCMODE) != O_RDONLY)) || ((filp->f_flags & O_ACCMODE) != O_RDONLY)) ||
((channel->cfg->direction == MOST_CH_TX) && ((c->cfg->direction == MOST_CH_TX) &&
((filp->f_flags & O_ACCMODE) != O_WRONLY))) { ((filp->f_flags & O_ACCMODE) != O_WRONLY))) {
pr_info("WARN: Access flags mismatch\n"); pr_info("WARN: Access flags mismatch\n");
return -EACCES; return -EACCES;
} }
if (!atomic_inc_and_test(&channel->access_ref)) { if (!atomic_inc_and_test(&c->access_ref)) {
pr_info("WARN: Device is busy\n"); pr_info("WARN: Device is busy\n");
atomic_dec(&channel->access_ref); atomic_dec(&c->access_ref);
return -EBUSY; return -EBUSY;
} }
ret = most_start_channel(channel->iface, channel->channel_id, ret = most_start_channel(c->iface, c->channel_id,
&cdev_aim); &cdev_aim);
if (ret) if (ret)
atomic_dec(&channel->access_ref); atomic_dec(&c->access_ref);
return ret; return ret;
} }
...@@ -143,20 +143,20 @@ static int aim_open(struct inode *inode, struct file *filp) ...@@ -143,20 +143,20 @@ static int aim_open(struct inode *inode, struct file *filp)
*/ */
static int aim_close(struct inode *inode, struct file *filp) static int aim_close(struct inode *inode, struct file *filp)
{ {
struct aim_channel *channel = to_channel(inode->i_cdev); struct aim_channel *c = to_channel(inode->i_cdev);
mutex_lock(&channel->io_mutex); mutex_lock(&c->io_mutex);
if (!channel->dev) { if (!c->dev) {
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
atomic_dec(&channel->access_ref); atomic_dec(&c->access_ref);
destroy_cdev(channel); destroy_cdev(c);
kfree(channel); kfree(c);
return 0; return 0;
} }
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
stop_channel(channel); stop_channel(c);
atomic_dec(&channel->access_ref); atomic_dec(&c->access_ref);
return 0; return 0;
} }
...@@ -175,38 +175,38 @@ static ssize_t aim_write(struct file *filp, const char __user *buf, ...@@ -175,38 +175,38 @@ static ssize_t aim_write(struct file *filp, const char __user *buf,
size_t max_len = 0; size_t max_len = 0;
ssize_t retval; ssize_t retval;
struct mbo *mbo; struct mbo *mbo;
struct aim_channel *channel = filp->private_data; struct aim_channel *c = filp->private_data;
mutex_lock(&channel->io_mutex); mutex_lock(&c->io_mutex);
if (unlikely(!channel->dev)) { if (unlikely(!c->dev)) {
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
return -EPIPE; return -EPIPE;
} }
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
mbo = most_get_mbo(channel->iface, channel->channel_id, &cdev_aim); mbo = most_get_mbo(c->iface, c->channel_id, &cdev_aim);
if (!mbo) { if (!mbo) {
if ((filp->f_flags & O_NONBLOCK)) if ((filp->f_flags & O_NONBLOCK))
return -EAGAIN; return -EAGAIN;
if (wait_event_interruptible( if (wait_event_interruptible(
channel->wq, c->wq,
(mbo = most_get_mbo(channel->iface, (mbo = most_get_mbo(c->iface,
channel->channel_id, c->channel_id,
&cdev_aim)) || &cdev_aim)) ||
(!channel->dev))) (!c->dev)))
return -ERESTARTSYS; return -ERESTARTSYS;
} }
mutex_lock(&channel->io_mutex); mutex_lock(&c->io_mutex);
if (unlikely(!channel->dev)) { if (unlikely(!c->dev)) {
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
err = -EPIPE; err = -EPIPE;
goto error; goto error;
} }
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
max_len = channel->cfg->buffer_size; max_len = c->cfg->buffer_size;
actual_len = min(count, max_len); actual_len = min(count, max_len);
mbo->buffer_length = actual_len; mbo->buffer_length = actual_len;
...@@ -240,47 +240,47 @@ aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) ...@@ -240,47 +240,47 @@ aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset)
{ {
size_t to_copy, not_copied, copied; size_t to_copy, not_copied, copied;
struct mbo *mbo; struct mbo *mbo;
struct aim_channel *channel = filp->private_data; struct aim_channel *c = filp->private_data;
if (channel->stacked_mbo) { if (c->stacked_mbo) {
mbo = channel->stacked_mbo; mbo = c->stacked_mbo;
goto start_copy; goto start_copy;
} }
while ((!kfifo_out(&channel->fifo, &mbo, 1)) && (channel->dev)) { while ((!kfifo_out(&c->fifo, &mbo, 1)) && (c->dev)) {
if (filp->f_flags & O_NONBLOCK) if (filp->f_flags & O_NONBLOCK)
return -EAGAIN; return -EAGAIN;
if (wait_event_interruptible(channel->wq, if (wait_event_interruptible(c->wq,
(!kfifo_is_empty(&channel->fifo) || (!kfifo_is_empty(&c->fifo) ||
(!channel->dev)))) (!c->dev))))
return -ERESTARTSYS; return -ERESTARTSYS;
} }
channel->stacked_mbo = mbo; c->stacked_mbo = mbo;
start_copy: start_copy:
/* make sure we don't submit to gone devices */ /* make sure we don't submit to gone devices */
mutex_lock(&channel->io_mutex); mutex_lock(&c->io_mutex);
if (unlikely(!channel->dev)) { if (unlikely(!c->dev)) {
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
return -EIO; return -EIO;
} }
to_copy = min_t(size_t, to_copy = min_t(size_t,
count, count,
mbo->processed_length - channel->mbo_offs); mbo->processed_length - c->mbo_offs);
not_copied = copy_to_user(buf, not_copied = copy_to_user(buf,
mbo->virt_address + channel->mbo_offs, mbo->virt_address + c->mbo_offs,
to_copy); to_copy);
copied = to_copy - not_copied; copied = to_copy - not_copied;
channel->mbo_offs += copied; c->mbo_offs += copied;
if (channel->mbo_offs >= mbo->processed_length) { if (c->mbo_offs >= mbo->processed_length) {
most_put_mbo(mbo); most_put_mbo(mbo);
channel->mbo_offs = 0; c->mbo_offs = 0;
channel->stacked_mbo = NULL; c->stacked_mbo = NULL;
} }
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
return copied; return copied;
} }
...@@ -323,26 +323,26 @@ static const struct file_operations channel_fops = { ...@@ -323,26 +323,26 @@ static const struct file_operations channel_fops = {
*/ */
static int aim_disconnect_channel(struct most_interface *iface, int channel_id) static int aim_disconnect_channel(struct most_interface *iface, int channel_id)
{ {
struct aim_channel *channel; struct aim_channel *c;
if (!iface) { if (!iface) {
pr_info("Bad interface pointer\n"); pr_info("Bad interface pointer\n");
return -EINVAL; return -EINVAL;
} }
channel = get_channel(iface, channel_id); c = get_channel(iface, channel_id);
if (!channel) if (!c)
return -ENXIO; return -ENXIO;
mutex_lock(&channel->io_mutex); mutex_lock(&c->io_mutex);
channel->dev = NULL; c->dev = NULL;
mutex_unlock(&channel->io_mutex); mutex_unlock(&c->io_mutex);
if (atomic_read(&channel->access_ref)) { if (atomic_read(&c->access_ref)) {
destroy_cdev(channel); destroy_cdev(c);
kfree(channel); kfree(c);
} else { } else {
wake_up_interruptible(&channel->wq); wake_up_interruptible(&c->wq);
} }
return 0; return 0;
} }
...@@ -356,21 +356,21 @@ static int aim_disconnect_channel(struct most_interface *iface, int channel_id) ...@@ -356,21 +356,21 @@ static int aim_disconnect_channel(struct most_interface *iface, int channel_id)
*/ */
static int aim_rx_completion(struct mbo *mbo) static int aim_rx_completion(struct mbo *mbo)
{ {
struct aim_channel *channel; struct aim_channel *c;
if (!mbo) if (!mbo)
return -EINVAL; return -EINVAL;
channel = get_channel(mbo->ifp, mbo->hdm_channel_id); c = get_channel(mbo->ifp, mbo->hdm_channel_id);
if (!channel) if (!c)
return -ENXIO; return -ENXIO;
kfifo_in(&channel->fifo, &mbo, 1); kfifo_in(&c->fifo, &mbo, 1);
#ifdef DEBUG_MESG #ifdef DEBUG_MESG
if (kfifo_is_full(&channel->fifo)) if (kfifo_is_full(&c->fifo))
pr_info("WARN: Fifo is full\n"); pr_info("WARN: Fifo is full\n");
#endif #endif
wake_up_interruptible(&channel->wq); wake_up_interruptible(&c->wq);
return 0; return 0;
} }
...@@ -383,7 +383,7 @@ static int aim_rx_completion(struct mbo *mbo) ...@@ -383,7 +383,7 @@ static int aim_rx_completion(struct mbo *mbo)
*/ */
static int aim_tx_completion(struct most_interface *iface, int channel_id) static int aim_tx_completion(struct most_interface *iface, int channel_id)
{ {
struct aim_channel *channel; struct aim_channel *c;
if (!iface) { if (!iface) {
pr_info("Bad interface pointer\n"); pr_info("Bad interface pointer\n");
...@@ -394,10 +394,10 @@ static int aim_tx_completion(struct most_interface *iface, int channel_id) ...@@ -394,10 +394,10 @@ static int aim_tx_completion(struct most_interface *iface, int channel_id)
return -EINVAL; return -EINVAL;
} }
channel = get_channel(iface, channel_id); c = get_channel(iface, channel_id);
if (!channel) if (!c)
return -ENXIO; return -ENXIO;
wake_up_interruptible(&channel->wq); wake_up_interruptible(&c->wq);
return 0; return 0;
} }
...@@ -419,7 +419,7 @@ static int aim_probe(struct most_interface *iface, int channel_id, ...@@ -419,7 +419,7 @@ static int aim_probe(struct most_interface *iface, int channel_id,
struct most_channel_config *cfg, struct most_channel_config *cfg,
struct kobject *parent, char *name) struct kobject *parent, char *name)
{ {
struct aim_channel *channel; struct aim_channel *c;
unsigned long cl_flags; unsigned long cl_flags;
int retval; int retval;
int current_minor; int current_minor;
...@@ -428,60 +428,60 @@ static int aim_probe(struct most_interface *iface, int channel_id, ...@@ -428,60 +428,60 @@ static int aim_probe(struct most_interface *iface, int channel_id,
pr_info("Probing AIM with bad arguments"); pr_info("Probing AIM with bad arguments");
return -EINVAL; return -EINVAL;
} }
channel = get_channel(iface, channel_id); c = get_channel(iface, channel_id);
if (channel) if (c)
return -EEXIST; return -EEXIST;
current_minor = ida_simple_get(&minor_id, 0, 0, GFP_KERNEL); current_minor = ida_simple_get(&minor_id, 0, 0, GFP_KERNEL);
if (current_minor < 0) if (current_minor < 0)
return current_minor; return current_minor;
channel = kzalloc(sizeof(*channel), GFP_KERNEL); c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!channel) { if (!c) {
retval = -ENOMEM; retval = -ENOMEM;
goto error_alloc_channel; goto error_alloc_channel;
} }
channel->devno = MKDEV(major, current_minor); c->devno = MKDEV(major, current_minor);
cdev_init(&channel->cdev, &channel_fops); cdev_init(&c->cdev, &channel_fops);
channel->cdev.owner = THIS_MODULE; c->cdev.owner = THIS_MODULE;
cdev_add(&channel->cdev, channel->devno, 1); cdev_add(&c->cdev, c->devno, 1);
channel->iface = iface; c->iface = iface;
channel->cfg = cfg; c->cfg = cfg;
channel->channel_id = channel_id; c->channel_id = channel_id;
channel->mbo_offs = 0; c->mbo_offs = 0;
atomic_set(&channel->access_ref, -1); atomic_set(&c->access_ref, -1);
INIT_KFIFO(channel->fifo); INIT_KFIFO(c->fifo);
retval = kfifo_alloc(&channel->fifo, cfg->num_buffers, GFP_KERNEL); retval = kfifo_alloc(&c->fifo, cfg->num_buffers, GFP_KERNEL);
if (retval) { if (retval) {
pr_info("failed to alloc channel kfifo"); pr_info("failed to alloc channel kfifo");
goto error_alloc_kfifo; goto error_alloc_kfifo;
} }
init_waitqueue_head(&channel->wq); init_waitqueue_head(&c->wq);
mutex_init(&channel->io_mutex); mutex_init(&c->io_mutex);
spin_lock_irqsave(&ch_list_lock, cl_flags); spin_lock_irqsave(&ch_list_lock, cl_flags);
list_add_tail(&channel->list, &channel_list); list_add_tail(&c->list, &channel_list);
spin_unlock_irqrestore(&ch_list_lock, cl_flags); spin_unlock_irqrestore(&ch_list_lock, cl_flags);
channel->dev = device_create(aim_class, c->dev = device_create(aim_class,
NULL, NULL,
channel->devno, c->devno,
NULL, NULL,
"%s", name); "%s", name);
retval = IS_ERR(channel->dev); retval = IS_ERR(c->dev);
if (retval) { if (retval) {
pr_info("failed to create new device node %s\n", name); pr_info("failed to create new device node %s\n", name);
goto error_create_device; goto error_create_device;
} }
kobject_uevent(&channel->dev->kobj, KOBJ_ADD); kobject_uevent(&c->dev->kobj, KOBJ_ADD);
return 0; return 0;
error_create_device: error_create_device:
kfifo_free(&channel->fifo); kfifo_free(&c->fifo);
list_del(&channel->list); list_del(&c->list);
error_alloc_kfifo: error_alloc_kfifo:
cdev_del(&channel->cdev); cdev_del(&c->cdev);
kfree(channel); kfree(c);
error_alloc_channel: error_alloc_channel:
ida_simple_remove(&minor_id, current_minor); ida_simple_remove(&minor_id, current_minor);
return retval; return retval;
...@@ -526,15 +526,15 @@ static int __init mod_init(void) ...@@ -526,15 +526,15 @@ static int __init mod_init(void)
static void __exit mod_exit(void) static void __exit mod_exit(void)
{ {
struct aim_channel *channel, *tmp; struct aim_channel *c, *tmp;
pr_info("exit module\n"); pr_info("exit module\n");
most_deregister_aim(&cdev_aim); most_deregister_aim(&cdev_aim);
list_for_each_entry_safe(channel, tmp, &channel_list, list) { list_for_each_entry_safe(c, tmp, &channel_list, list) {
destroy_cdev(channel); destroy_cdev(c);
kfree(channel); kfree(c);
} }
class_destroy(aim_class); class_destroy(aim_class);
unregister_chrdev_region(aim_devno, 1); unregister_chrdev_region(aim_devno, 1);
......
Markdown is supported
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