summaryrefslogtreecommitdiff
path: root/drivers/staging/most/dim2
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2017-11-21 15:04:43 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-27 09:20:34 +0100
commit4d5f022f3a664ee5987118b754058ff31df03835 (patch)
tree2a95096b190dd0faa25854524e9dacd4d22ad659 /drivers/staging/most/dim2
parent2c22cdfb4e817a7be48419c3c7b1423ee8f5df38 (diff)
staging: most: remove proprietary kobjects
This patch removes the proprietary kobjects used by the driver modules and replaces them with device structs. The patch is needed to have the driver being integrated into the kernel's device model. Signed-off-by: Christian Gromm <christian.gromm@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/most/dim2')
-rw-r--r--drivers/staging/most/dim2/dim2.c19
-rw-r--r--drivers/staging/most/dim2/sysfs.c92
-rw-r--r--drivers/staging/most/dim2/sysfs.h6
3 files changed, 30 insertions, 87 deletions
diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
index 921db9880d80..2bd40abbc8c6 100644
--- a/drivers/staging/most/dim2/dim2.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -87,6 +87,7 @@ struct hdm_channel {
* @atx_idx: index of async tx channel
*/
struct dim2_hdm {
+ struct device dev;
struct hdm_channel hch[DMA_CHANNELS];
struct most_channel_capability capabilities[DMA_CHANNELS];
struct most_interface most_iface;
@@ -738,7 +739,6 @@ static int dim2_probe(struct platform_device *pdev)
struct dim2_hdm *dev;
struct resource *res;
int ret, i;
- struct kobject *kobj;
int irq;
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -826,17 +826,20 @@ static int dim2_probe(struct platform_device *pdev)
dev->most_iface.enqueue = enqueue;
dev->most_iface.poison_channel = poison_channel;
dev->most_iface.request_netinfo = request_netinfo;
+ dev->dev.init_name = "dim2_state";
+ dev->dev.parent = &dev->most_iface.dev;
- kobj = most_register_interface(&dev->most_iface);
- if (IS_ERR(kobj)) {
- ret = PTR_ERR(kobj);
+ ret = most_register_interface(&dev->most_iface);
+ if (ret) {
dev_err(&pdev->dev, "failed to register MOST interface\n");
goto err_stop_thread;
}
- ret = dim2_sysfs_probe(&dev->bus, kobj);
- if (ret)
+ ret = dim2_sysfs_probe(&dev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to create sysfs attribute\n");
goto err_unreg_iface;
+ }
ret = startup_dim(pdev);
if (ret) {
@@ -847,7 +850,7 @@ static int dim2_probe(struct platform_device *pdev)
return 0;
err_destroy_bus:
- dim2_sysfs_destroy(&dev->bus);
+ dim2_sysfs_destroy(&dev->dev);
err_unreg_iface:
most_deregister_interface(&dev->most_iface);
err_stop_thread:
@@ -875,7 +878,7 @@ static int dim2_remove(struct platform_device *pdev)
if (pdata && pdata->destroy)
pdata->destroy(pdata);
- dim2_sysfs_destroy(&dev->bus);
+ dim2_sysfs_destroy(&dev->dev);
most_deregister_interface(&dev->most_iface);
kthread_stop(dev->netinfo_task);
diff --git a/drivers/staging/most/dim2/sysfs.c b/drivers/staging/most/dim2/sysfs.c
index ec1f4cecf9e7..7ead7030c6b8 100644
--- a/drivers/staging/most/dim2/sysfs.c
+++ b/drivers/staging/most/dim2/sysfs.c
@@ -11,99 +11,39 @@
#include <linux/kernel.h>
#include "sysfs.h"
+#include <linux/device.h>
-struct bus_attr {
- struct attribute attr;
- ssize_t (*show)(struct medialb_bus *bus, char *buf);
- ssize_t (*store)(struct medialb_bus *bus, const char *buf,
- size_t count);
-};
-
-static ssize_t state_show(struct medialb_bus *bus, char *buf)
+static ssize_t state_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
bool state = dim2_sysfs_get_state_cb();
return sprintf(buf, "%s\n", state ? "locked" : "");
}
-static struct bus_attr state_attr = __ATTR_RO(state);
+DEVICE_ATTR_RO(state);
-static struct attribute *bus_default_attrs[] = {
- &state_attr.attr,
+static struct attribute *dev_attrs[] = {
+ &dev_attr_state.attr,
NULL,
};
-static const struct attribute_group bus_attr_group = {
- .attrs = bus_default_attrs,
+static struct attribute_group dev_attr_group = {
+ .attrs = dev_attrs,
};
-static void bus_kobj_release(struct kobject *kobj)
-{
-}
-
-static ssize_t bus_kobj_attr_show(struct kobject *kobj, struct attribute *attr,
- char *buf)
-{
- struct medialb_bus *bus =
- container_of(kobj, struct medialb_bus, kobj_group);
- struct bus_attr *xattr = container_of(attr, struct bus_attr, attr);
-
- if (!xattr->show)
- return -EIO;
-
- return xattr->show(bus, buf);
-}
-
-static ssize_t bus_kobj_attr_store(struct kobject *kobj, struct attribute *attr,
- const char *buf, size_t count)
-{
- struct medialb_bus *bus =
- container_of(kobj, struct medialb_bus, kobj_group);
- struct bus_attr *xattr = container_of(attr, struct bus_attr, attr);
-
- if (!xattr->store)
- return -EIO;
-
- return xattr->store(bus, buf, count);
-}
-
-static struct sysfs_ops const bus_kobj_sysfs_ops = {
- .show = bus_kobj_attr_show,
- .store = bus_kobj_attr_store,
-};
-
-static struct kobj_type bus_ktype = {
- .release = bus_kobj_release,
- .sysfs_ops = &bus_kobj_sysfs_ops,
+static const struct attribute_group *dev_attr_groups[] = {
+ &dev_attr_group,
+ NULL,
};
-int dim2_sysfs_probe(struct medialb_bus *bus, struct kobject *parent_kobj)
+int dim2_sysfs_probe(struct device *dev)
{
- int err;
-
- kobject_init(&bus->kobj_group, &bus_ktype);
- err = kobject_add(&bus->kobj_group, parent_kobj, "bus");
- if (err) {
- pr_err("kobject_add() failed: %d\n", err);
- goto err_kobject_add;
- }
-
- err = sysfs_create_group(&bus->kobj_group, &bus_attr_group);
- if (err) {
- pr_err("sysfs_create_group() failed: %d\n", err);
- goto err_create_group;
- }
-
- return 0;
-
-err_create_group:
- kobject_put(&bus->kobj_group);
-
-err_kobject_add:
- return err;
+ dev->groups = dev_attr_groups;
+ return device_register(dev);
}
-void dim2_sysfs_destroy(struct medialb_bus *bus)
+void dim2_sysfs_destroy(struct device *dev)
{
- kobject_put(&bus->kobj_group);
+ device_unregister(dev);
}
diff --git a/drivers/staging/most/dim2/sysfs.h b/drivers/staging/most/dim2/sysfs.h
index a33ebd8b45f5..33756a3bffe2 100644
--- a/drivers/staging/most/dim2/sysfs.h
+++ b/drivers/staging/most/dim2/sysfs.h
@@ -16,10 +16,10 @@ struct medialb_bus {
struct kobject kobj_group;
};
-struct dim2_hdm;
+struct device;
-int dim2_sysfs_probe(struct medialb_bus *bus, struct kobject *parent_kobj);
-void dim2_sysfs_destroy(struct medialb_bus *bus);
+int dim2_sysfs_probe(struct device *dev);
+void dim2_sysfs_destroy(struct device *dev);
/*
* callback,