aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/most
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/most')
-rw-r--r--drivers/staging/most/cdev/cdev.c12
-rw-r--r--drivers/staging/most/core.c49
-rw-r--r--drivers/staging/most/net/net.c2
-rw-r--r--drivers/staging/most/usb/usb.c55
-rw-r--r--drivers/staging/most/video/video.c4
5 files changed, 74 insertions, 48 deletions
diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index 4569838f27a0..ea64aabda94e 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -447,7 +447,7 @@ static int comp_probe(struct most_interface *iface, int channel_id,
c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!c) {
retval = -ENOMEM;
- goto error_alloc_channel;
+ goto err_remove_ida;
}
c->devno = MKDEV(comp.major, current_minor);
@@ -463,7 +463,7 @@ static int comp_probe(struct most_interface *iface, int channel_id,
retval = kfifo_alloc(&c->fifo, cfg->num_buffers, GFP_KERNEL);
if (retval) {
pr_info("failed to alloc channel kfifo");
- goto error_alloc_kfifo;
+ goto err_del_cdev_and_free_channel;
}
init_waitqueue_head(&c->wq);
mutex_init(&c->io_mutex);
@@ -475,18 +475,18 @@ static int comp_probe(struct most_interface *iface, int channel_id,
if (IS_ERR(c->dev)) {
retval = PTR_ERR(c->dev);
pr_info("failed to create new device node %s\n", name);
- goto error_create_device;
+ goto err_free_kfifo_and_del_list;
}
kobject_uevent(&c->dev->kobj, KOBJ_ADD);
return 0;
-error_create_device:
+err_free_kfifo_and_del_list:
kfifo_free(&c->fifo);
list_del(&c->list);
-error_alloc_kfifo:
+err_del_cdev_and_free_channel:
cdev_del(&c->cdev);
kfree(c);
-error_alloc_channel:
+err_remove_ida:
ida_simple_remove(&comp.minor_id, current_minor);
return retval;
}
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index f4c464625a67..6a18cf73c85e 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -442,6 +442,24 @@ static ssize_t set_dbr_size_store(struct device *dev,
return count;
}
+#define to_dev_attr(a) container_of(a, struct device_attribute, attr)
+static umode_t channel_attr_is_visible(struct kobject *kobj,
+ struct attribute *attr, int index)
+{
+ struct device_attribute *dev_attr = to_dev_attr(attr);
+ struct device *dev = kobj_to_dev(kobj);
+ struct most_channel *c = to_channel(dev);
+
+ if (!strcmp(dev_attr->attr.name, "set_dbr_size") &&
+ (c->iface->interface != ITYPE_MEDIALB_DIM2))
+ return 0;
+ if (!strcmp(dev_attr->attr.name, "set_packets_per_xact") &&
+ (c->iface->interface != ITYPE_USB))
+ return 0;
+
+ return attr->mode;
+}
+
#define DEV_ATTR(_name) (&dev_attr_##_name.attr)
static DEVICE_ATTR_RO(available_directions);
@@ -479,6 +497,7 @@ static struct attribute *channel_attrs[] = {
static struct attribute_group channel_attr_group = {
.attrs = channel_attrs,
+ .is_visible = channel_attr_is_visible,
};
static const struct attribute_group *channel_attr_groups[] = {
@@ -1216,7 +1235,7 @@ int most_start_channel(struct most_interface *iface, int id,
if (c->iface->configure(c->iface, c->channel_id, &c->cfg)) {
pr_info("channel configuration failed. Go check settings...\n");
ret = -EINVAL;
- goto error;
+ goto err_put_module;
}
init_waitqueue_head(&c->hdm_fifo_wq);
@@ -1229,12 +1248,12 @@ int most_start_channel(struct most_interface *iface, int id,
most_write_completion);
if (unlikely(!num_buffer)) {
ret = -ENOMEM;
- goto error;
+ goto err_put_module;
}
ret = run_enqueue_thread(c, id);
if (ret)
- goto error;
+ goto err_put_module;
c->is_starving = 0;
c->pipe0.num_buffers = c->cfg.num_buffers / 2;
@@ -1249,7 +1268,7 @@ out:
mutex_unlock(&c->start_mutex);
return 0;
-error:
+err_put_module:
module_put(iface->mod);
mutex_unlock(&c->start_mutex);
return ret;
@@ -1430,7 +1449,7 @@ int most_register_interface(struct most_interface *iface)
c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!c)
- goto free_instance;
+ goto err_free_resources;
if (!name_suffix)
snprintf(c->name, STRING_SIZE, "ch%d", i);
else
@@ -1439,10 +1458,6 @@ int most_register_interface(struct most_interface *iface)
c->dev.parent = &iface->dev;
c->dev.groups = channel_attr_groups;
c->dev.release = release_channel;
- if (device_register(&c->dev)) {
- pr_err("registering c->dev failed\n");
- goto free_instance_nodev;
- }
iface->p->channel[i] = c;
c->is_starving = 0;
c->iface = iface;
@@ -1465,15 +1480,19 @@ int most_register_interface(struct most_interface *iface)
mutex_init(&c->start_mutex);
mutex_init(&c->nq_mutex);
list_add_tail(&c->list, &iface->p->channel_list);
+ if (device_register(&c->dev)) {
+ pr_err("registering c->dev failed\n");
+ goto err_free_most_channel;
+ }
}
pr_info("registered new device mdev%d (%s)\n",
id, iface->description);
return 0;
-free_instance_nodev:
+err_free_most_channel:
kfree(c);
-free_instance:
+err_free_resources:
while (i > 0) {
c = iface->p->channel[--i];
device_unregister(&c->dev);
@@ -1594,20 +1613,20 @@ static int __init most_init(void)
err = driver_register(&mc.drv);
if (err) {
pr_info("Cannot register core driver\n");
- goto exit_bus;
+ goto err_unregister_bus;
}
mc.dev.init_name = "most_bus";
mc.dev.release = release_most_sub;
if (device_register(&mc.dev)) {
err = -ENOMEM;
- goto exit_driver;
+ goto err_unregister_driver;
}
return 0;
-exit_driver:
+err_unregister_driver:
driver_unregister(&mc.drv);
-exit_bus:
+err_unregister_bus:
bus_unregister(&mc.bus);
return err;
}
diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
index 30d816b7e165..e20584b1b112 100644
--- a/drivers/staging/most/net/net.c
+++ b/drivers/staging/most/net/net.c
@@ -75,7 +75,7 @@ static struct core_component comp;
static int skb_to_mamac(const struct sk_buff *skb, struct mbo *mbo)
{
u8 *buff = mbo->virt_address;
- const u8 broadcast[] = { 0x03, 0xFF };
+ static const u8 broadcast[] = { 0x03, 0xFF };
const u8 *dest_addr = skb->data + 4;
const u8 *eth_type = skb->data + 12;
unsigned int payload_len = skb->len - ETH_HLEN;
diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index bc820f90bcb1..c0293d8d5934 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -568,19 +568,19 @@ static int hdm_enqueue(struct most_interface *iface, int channel,
mutex_lock(&mdev->io_mutex);
if (!mdev->usb_device) {
retval = -ENODEV;
- goto _exit;
+ goto unlock_io_mutex;
}
urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_ATOMIC);
if (!urb) {
retval = -ENOMEM;
- goto _exit;
+ goto unlock_io_mutex;
}
if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] &&
hdm_add_padding(mdev, channel, mbo)) {
retval = -EIO;
- goto _error;
+ goto err_free_urb;
}
urb->transfer_dma = mbo->bus_address;
@@ -615,15 +615,15 @@ static int hdm_enqueue(struct most_interface *iface, int channel,
if (retval) {
dev_err(&mdev->usb_device->dev,
"URB submit failed with error %d.\n", retval);
- goto _error_1;
+ goto err_unanchor_urb;
}
- goto _exit;
+ goto unlock_io_mutex;
-_error_1:
+err_unanchor_urb:
usb_unanchor_urb(urb);
-_error:
+err_free_urb:
usb_free_urb(urb);
-_exit:
+unlock_io_mutex:
mutex_unlock(&mdev->io_mutex);
return retval;
}
@@ -1015,6 +1015,13 @@ static const struct attribute_group *dci_attr_groups[] = {
NULL,
};
+static void release_dci(struct device *dev)
+{
+ struct most_dci_obj *dci = to_dci_obj(dev);
+
+ kfree(dci);
+}
+
/**
* hdm_probe - probe function of USB device driver
* @interface: Interface of the attached USB device
@@ -1041,7 +1048,7 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
int ret = 0;
if (!mdev)
- goto exit_ENOMEM;
+ goto err_out_of_memory;
usb_set_intfdata(interface, mdev);
num_endpoints = usb_iface_desc->desc.bNumEndpoints;
@@ -1073,22 +1080,22 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
mdev->conf = kcalloc(num_endpoints, sizeof(*mdev->conf), GFP_KERNEL);
if (!mdev->conf)
- goto exit_free;
+ goto err_free_mdev;
mdev->cap = kcalloc(num_endpoints, sizeof(*mdev->cap), GFP_KERNEL);
if (!mdev->cap)
- goto exit_free1;
+ goto err_free_conf;
mdev->iface.channel_vector = mdev->cap;
mdev->ep_address =
kcalloc(num_endpoints, sizeof(*mdev->ep_address), GFP_KERNEL);
if (!mdev->ep_address)
- goto exit_free2;
+ goto err_free_cap;
mdev->busy_urbs =
kcalloc(num_endpoints, sizeof(*mdev->busy_urbs), GFP_KERNEL);
if (!mdev->busy_urbs)
- goto exit_free3;
+ goto err_free_ep_address;
tmp_cap = mdev->cap;
for (i = 0; i < num_endpoints; i++) {
@@ -1129,7 +1136,7 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
ret = most_register_interface(&mdev->iface);
if (ret)
- goto exit_free4;
+ goto err_free_busy_urbs;
mutex_lock(&mdev->io_mutex);
if (le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81118 ||
@@ -1140,35 +1147,36 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
mutex_unlock(&mdev->io_mutex);
most_deregister_interface(&mdev->iface);
ret = -ENOMEM;
- goto exit_free4;
+ goto err_free_busy_urbs;
}
mdev->dci->dev.init_name = "dci";
mdev->dci->dev.parent = &mdev->iface.dev;
mdev->dci->dev.groups = dci_attr_groups;
+ mdev->dci->dev.release = release_dci;
if (device_register(&mdev->dci->dev)) {
mutex_unlock(&mdev->io_mutex);
most_deregister_interface(&mdev->iface);
ret = -ENOMEM;
- goto exit_free5;
+ goto err_free_dci;
}
mdev->dci->usb_device = mdev->usb_device;
}
mutex_unlock(&mdev->io_mutex);
return 0;
-exit_free5:
+err_free_dci:
kfree(mdev->dci);
-exit_free4:
+err_free_busy_urbs:
kfree(mdev->busy_urbs);
-exit_free3:
+err_free_ep_address:
kfree(mdev->ep_address);
-exit_free2:
+err_free_cap:
kfree(mdev->cap);
-exit_free1:
+err_free_conf:
kfree(mdev->conf);
-exit_free:
+err_free_mdev:
kfree(mdev);
-exit_ENOMEM:
+err_out_of_memory:
if (ret == 0 || ret == -ENOMEM) {
ret = -ENOMEM;
dev_err(dev, "out of memory\n");
@@ -1198,7 +1206,6 @@ static void hdm_disconnect(struct usb_interface *interface)
cancel_work_sync(&mdev->poll_work_obj);
device_unregister(&mdev->dci->dev);
- kfree(mdev->dci);
most_deregister_interface(&mdev->iface);
kfree(mdev->busy_urbs);
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index cf342eb58e10..ad7e28ab9a4f 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -530,7 +530,7 @@ static int comp_disconnect_channel(struct most_interface *iface,
return 0;
}
-static struct core_component comp_info = {
+static struct core_component comp = {
.name = "video",
.probe_channel = comp_probe_channel,
.disconnect_channel = comp_disconnect_channel,
@@ -565,7 +565,7 @@ static void __exit comp_exit(void)
}
spin_unlock_irq(&list_lock);
- most_deregister_component(&comp_info);
+ most_deregister_component(&comp);
BUG_ON(!list_empty(&video_devices));
}