Commit 5b37ee81 authored by Jody McIntyre's avatar Jody McIntyre

Move simple class to ieee1394 core and register as

/sys/class/ieee1394_protocol.
Add sysfs/udev support to video1394 and dv1394 using simple class
ieee1394_protocol.
Signed-off-by: default avatarDan Dennedy <dan@dennedy.org>
Signed-off-by: default avatarJody McIntyre <scjody@modernduck.com>
parent ab9b4d79
......@@ -2343,6 +2343,8 @@ static void dv1394_remove_host (struct hpsb_host *host)
dv1394_un_init(video);
} while (video != NULL);
class_simple_device_remove(MKDEV(
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)));
devfs_remove("ieee1394/dv/host%d/NTSC", id);
devfs_remove("ieee1394/dv/host%d/PAL", id);
devfs_remove("ieee1394/dv/host%d", id);
......@@ -2359,6 +2361,9 @@ static void dv1394_add_host (struct hpsb_host *host)
ohci = (struct ti_ohci *)host->hostdata;
class_simple_device_add(hpsb_protocol_class, MKDEV(
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
NULL, "dv1394-%d", id);
devfs_mk_dir("ieee1394/dv/host%d", id);
devfs_mk_dir("ieee1394/dv/host%d/NTSC", id);
devfs_mk_dir("ieee1394/dv/host%d/PAL", id);
......
......@@ -61,6 +61,7 @@ MODULE_LICENSE("GPL");
/* Some globals used */
const char *hpsb_speedto_str[] = { "S100", "S200", "S400", "S800", "S1600", "S3200" };
struct class_simple *hpsb_protocol_class;
#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
static void dump_packet(const char *text, quadlet_t *data, int size)
......@@ -1059,7 +1060,6 @@ static int hpsbpkt_thread(void *__hi)
complete_and_exit(&khpsbpkt_complete, 0);
}
static int __init ieee1394_init(void)
{
int i, ret;
......@@ -1114,11 +1114,17 @@ static int __init ieee1394_init(void)
if (ret < 0)
goto release_all_bus;
hpsb_protocol_class = class_simple_create(THIS_MODULE, "ieee1394_protocol");
if (IS_ERR(hpsb_protocol_class)) {
ret = PTR_ERR(hpsb_protocol_class);
goto release_class_host;
}
ret = init_csr();
if (ret) {
HPSB_INFO("init csr failed");
ret = -ENOMEM;
goto release_class;
goto release_class_protocol;
}
if (disable_nodemgr) {
......@@ -1136,7 +1142,9 @@ static int __init ieee1394_init(void)
cleanup_csr:
cleanup_csr();
release_class:
release_class_protocol:
class_simple_destroy(hpsb_protocol_class);
release_class_host:
class_unregister(&hpsb_host_class);
release_all_bus:
for (i = 0; fw_bus_attrs[i]; i++)
......@@ -1165,6 +1173,7 @@ static void __exit ieee1394_cleanup(void)
cleanup_csr();
class_simple_destroy(hpsb_protocol_class);
class_unregister(&hpsb_host_class);
for (i = 0; fw_bus_attrs[i]; i++)
bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
......@@ -1196,6 +1205,7 @@ EXPORT_SYMBOL(hpsb_update_config_rom_image);
/** ieee1394_core.c **/
EXPORT_SYMBOL(hpsb_speedto_str);
EXPORT_SYMBOL(hpsb_protocol_class);
EXPORT_SYMBOL(hpsb_set_packet_complete_task);
EXPORT_SYMBOL(hpsb_alloc_packet);
EXPORT_SYMBOL(hpsb_free_packet);
......
......@@ -222,5 +222,6 @@ static inline unsigned char ieee1394_file_to_instance(struct file *file)
/* Our sysfs bus entry */
extern struct bus_type ieee1394_bus_type;
extern struct class hpsb_host_class;
extern struct class_simple *hpsb_protocol_class;
#endif /* _IEEE1394_CORE_H */
......@@ -78,7 +78,6 @@ static atomic_t iso_buffer_size;
static const int iso_buffer_max = 4 * 1024 * 1024; /* 4 MB */
static struct hpsb_highlevel raw1394_highlevel;
static struct class_simple *raw1394_class;
static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
u64 addr, size_t length, u16 flags);
......@@ -2901,20 +2900,16 @@ static int __init init_raw1394(void)
hpsb_register_highlevel(&raw1394_highlevel);
raw1394_class = class_simple_create(THIS_MODULE, "raw1394");
if (IS_ERR(raw1394_class)) {
ret = PTR_ERR(raw1394_class);
if (IS_ERR(class_simple_device_add(hpsb_protocol_class, MKDEV(
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
NULL, RAW1394_DEVICE_NAME))) {
ret = -EFAULT;
goto out_unreg;
}
class_simple_device_add(raw1394_class,
MKDEV(IEEE1394_MAJOR,
IEEE1394_MINOR_BLOCK_RAW1394 * 16), NULL,
RAW1394_DEVICE_NAME);
ret =
devfs_mk_cdev(MKDEV
(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
ret = devfs_mk_cdev(MKDEV(
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
if (ret)
goto out_class;
......@@ -2938,25 +2933,21 @@ static int __init init_raw1394(void)
goto out;
out_dev:
out_dev:
devfs_remove(RAW1394_DEVICE_NAME);
out_class:
class_simple_device_remove(MKDEV
(IEEE1394_MAJOR,
IEEE1394_MINOR_BLOCK_RAW1394 * 16));
class_simple_destroy(raw1394_class);
out_unreg:
out_class:
class_simple_device_remove(MKDEV(
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16));
out_unreg:
hpsb_unregister_highlevel(&raw1394_highlevel);
out:
out:
return ret;
}
static void __exit cleanup_raw1394(void)
{
class_simple_device_remove(MKDEV
(IEEE1394_MAJOR,
IEEE1394_MINOR_BLOCK_RAW1394 * 16));
class_simple_destroy(raw1394_class);
class_simple_device_remove(MKDEV(
IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16));
hpsb_unregister_protocol(&raw1394_driver);
cdev_del(&raw1394_cdev);
devfs_remove(RAW1394_DEVICE_NAME);
......
......@@ -1332,6 +1332,9 @@ static void video1394_add_host (struct hpsb_host *host)
hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
class_simple_device_add(hpsb_protocol_class, MKDEV(
IEEE1394_MAJOR, minor),
NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor),
S_IFCHR | S_IRUSR | S_IWUSR,
"%s/%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
......@@ -1342,9 +1345,12 @@ static void video1394_remove_host (struct hpsb_host *host)
{
struct ti_ohci *ohci = hpsb_get_hostinfo(&video1394_highlevel, host);
if (ohci)
if (ohci) {
class_simple_device_remove(MKDEV(IEEE1394_MAJOR,
IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id));
devfs_remove("%s/%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
}
return;
}
......
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