mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
staging: most: core: use structure to pack driver specific data
This patch introduces the structure "mostcore" to bundle core specific data structures. Signed-off-by: Christian Gromm <christian.gromm@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f898f98955
commit
14ae5f0383
@ -26,11 +26,19 @@
|
|||||||
#define MAX_CHANNELS 64
|
#define MAX_CHANNELS 64
|
||||||
#define STRING_SIZE 80
|
#define STRING_SIZE 80
|
||||||
|
|
||||||
static struct class *most_class;
|
|
||||||
static struct device core_dev;
|
|
||||||
static struct ida mdev_id;
|
static struct ida mdev_id;
|
||||||
static int dummy_num_buffers;
|
static int dummy_num_buffers;
|
||||||
|
|
||||||
|
static struct mostcore {
|
||||||
|
struct device dev;
|
||||||
|
struct device_driver drv;
|
||||||
|
struct bus_type bus;
|
||||||
|
struct class *class;
|
||||||
|
struct list_head mod_list;
|
||||||
|
} mc;
|
||||||
|
|
||||||
|
#define to_driver(d) container_of(d, struct mostcore, drv);
|
||||||
|
|
||||||
struct pipe {
|
struct pipe {
|
||||||
struct most_aim *aim;
|
struct most_aim *aim;
|
||||||
int refs;
|
int refs;
|
||||||
@ -777,22 +785,6 @@ int most_match(struct device *dev, struct device_driver *drv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiation of the MOST bus
|
|
||||||
*/
|
|
||||||
static struct bus_type most_bus = {
|
|
||||||
.name = "most",
|
|
||||||
.match = most_match,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiation of the core driver
|
|
||||||
*/
|
|
||||||
static struct device_driver mostcore = {
|
|
||||||
.name = "mostcore",
|
|
||||||
.bus = &most_bus,
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline void trash_mbo(struct mbo *mbo)
|
static inline void trash_mbo(struct mbo *mbo)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
@ -1293,8 +1285,8 @@ int most_register_aim(struct most_aim *aim)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
aim->dev.init_name = aim->name;
|
aim->dev.init_name = aim->name;
|
||||||
aim->dev.bus = &most_bus;
|
aim->dev.bus = &mc.bus;
|
||||||
aim->dev.parent = &core_dev;
|
aim->dev.parent = &mc.dev;
|
||||||
aim->dev.groups = aim_attr_groups;
|
aim->dev.groups = aim_attr_groups;
|
||||||
aim->dev.release = release_aim;
|
aim->dev.release = release_aim;
|
||||||
ret = device_register(&aim->dev);
|
ret = device_register(&aim->dev);
|
||||||
@ -1391,8 +1383,8 @@ int most_register_interface(struct most_interface *iface)
|
|||||||
list_add_tail(&inst->list, &instance_list);
|
list_add_tail(&inst->list, &instance_list);
|
||||||
snprintf(name, STRING_SIZE, "mdev%d", id);
|
snprintf(name, STRING_SIZE, "mdev%d", id);
|
||||||
iface->dev.init_name = name;
|
iface->dev.init_name = name;
|
||||||
iface->dev.bus = &most_bus;
|
iface->dev.bus = &mc.bus;
|
||||||
iface->dev.parent = &core_dev;
|
iface->dev.parent = &mc.dev;
|
||||||
iface->dev.groups = interface_attr_groups;
|
iface->dev.groups = interface_attr_groups;
|
||||||
iface->dev.release = release_interface;
|
iface->dev.release = release_interface;
|
||||||
if (device_register(&iface->dev)) {
|
if (device_register(&iface->dev)) {
|
||||||
@ -1555,28 +1547,31 @@ static int __init most_init(void)
|
|||||||
INIT_LIST_HEAD(&instance_list);
|
INIT_LIST_HEAD(&instance_list);
|
||||||
ida_init(&mdev_id);
|
ida_init(&mdev_id);
|
||||||
|
|
||||||
err = bus_register(&most_bus);
|
mc.bus.name = "most",
|
||||||
|
mc.bus.match = most_match,
|
||||||
|
mc.drv.name = "most_core",
|
||||||
|
mc.drv.bus = &mc.bus,
|
||||||
|
|
||||||
|
err = bus_register(&mc.bus);
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_info("Cannot register most bus\n");
|
pr_info("Cannot register most bus\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
mc.class = class_create(THIS_MODULE, "most");
|
||||||
most_class = class_create(THIS_MODULE, "most");
|
if (IS_ERR(mc.class)) {
|
||||||
if (IS_ERR(most_class)) {
|
|
||||||
pr_info("No udev support.\n");
|
pr_info("No udev support.\n");
|
||||||
err = PTR_ERR(most_class);
|
err = PTR_ERR(mc.class);
|
||||||
goto exit_bus;
|
goto exit_bus;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = driver_register(&mostcore);
|
err = driver_register(&mc.drv);
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_info("Cannot register core driver\n");
|
pr_info("Cannot register core driver\n");
|
||||||
goto exit_class;
|
goto exit_class;
|
||||||
}
|
}
|
||||||
|
mc.dev.init_name = "most_bus";
|
||||||
core_dev.init_name = "most_bus";
|
mc.dev.release = release_most_sub;
|
||||||
core_dev.release = release_most_sub;
|
if (device_register(&mc.dev)) {
|
||||||
if (device_register(&core_dev)) {
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto exit_driver;
|
goto exit_driver;
|
||||||
}
|
}
|
||||||
@ -1584,21 +1579,21 @@ static int __init most_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
exit_driver:
|
exit_driver:
|
||||||
driver_unregister(&mostcore);
|
driver_unregister(&mc.drv);
|
||||||
exit_class:
|
exit_class:
|
||||||
class_destroy(most_class);
|
class_destroy(mc.class);
|
||||||
exit_bus:
|
exit_bus:
|
||||||
bus_unregister(&most_bus);
|
bus_unregister(&mc.bus);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit most_exit(void)
|
static void __exit most_exit(void)
|
||||||
{
|
{
|
||||||
pr_info("exit core module\n");
|
pr_info("exit core module\n");
|
||||||
device_unregister(&core_dev);
|
device_unregister(&mc.dev);
|
||||||
driver_unregister(&mostcore);
|
driver_unregister(&mc.drv);
|
||||||
class_destroy(most_class);
|
class_destroy(mc.class);
|
||||||
bus_unregister(&most_bus);
|
bus_unregister(&mc.bus);
|
||||||
ida_destroy(&mdev_id);
|
ida_destroy(&mdev_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user