diff options
author | Alexandre Bounine <alexandre.bounine@idt.com> | 2016-03-22 17:26:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-22 18:36:02 -0400 |
commit | b74ec56e8ae8759d83448528bde587d00908b4a9 (patch) | |
tree | 2b12c3fd56de19cd8504e21bb83f4647e72952d9 | |
parent | f41e2472ba115275438161fd72d40b2448963658 (diff) |
rapidio: rework common RIO device add/delete routines
This patch moves per-net device list handling from rio-scan to common
RapidIO core and adds a matching device deletion routine. This makes
device object creation/removal available to other implementations of
enumeration/discovery process.
Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/rapidio/rio-scan.c | 13 | ||||
-rw-r--r-- | drivers/rapidio/rio.c | 33 | ||||
-rw-r--r-- | drivers/rapidio/rio.h | 2 |
3 files changed, 36 insertions, 12 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index d6a126c17c03..c46763185849 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c | |||
@@ -449,9 +449,6 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, | |||
449 | 449 | ||
450 | if (do_enum) | 450 | if (do_enum) |
451 | rio_route_clr_table(rdev, RIO_GLOBAL_TABLE, 0); | 451 | rio_route_clr_table(rdev, RIO_GLOBAL_TABLE, 0); |
452 | |||
453 | list_add_tail(&rswitch->node, &net->switches); | ||
454 | |||
455 | } else { | 452 | } else { |
456 | if (do_enum) | 453 | if (do_enum) |
457 | /*Enable Input Output Port (transmitter reviever)*/ | 454 | /*Enable Input Output Port (transmitter reviever)*/ |
@@ -463,11 +460,7 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, | |||
463 | 460 | ||
464 | rdev->dev.parent = &port->dev; | 461 | rdev->dev.parent = &port->dev; |
465 | rio_attach_device(rdev); | 462 | rio_attach_device(rdev); |
466 | |||
467 | device_initialize(&rdev->dev); | ||
468 | rdev->dev.release = rio_release_dev; | 463 | rdev->dev.release = rio_release_dev; |
469 | rio_dev_get(rdev); | ||
470 | |||
471 | rdev->dma_mask = DMA_BIT_MASK(32); | 464 | rdev->dma_mask = DMA_BIT_MASK(32); |
472 | rdev->dev.dma_mask = &rdev->dma_mask; | 465 | rdev->dev.dma_mask = &rdev->dma_mask; |
473 | rdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); | 466 | rdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
@@ -480,6 +473,8 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, | |||
480 | if (ret) | 473 | if (ret) |
481 | goto cleanup; | 474 | goto cleanup; |
482 | 475 | ||
476 | rio_dev_get(rdev); | ||
477 | |||
483 | return rdev; | 478 | return rdev; |
484 | 479 | ||
485 | cleanup: | 480 | cleanup: |
@@ -621,8 +616,6 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
621 | rdev = rio_setup_device(net, port, RIO_ANY_DESTID(port->sys_size), | 616 | rdev = rio_setup_device(net, port, RIO_ANY_DESTID(port->sys_size), |
622 | hopcount, 1); | 617 | hopcount, 1); |
623 | if (rdev) { | 618 | if (rdev) { |
624 | /* Add device to the global and bus/net specific list. */ | ||
625 | list_add_tail(&rdev->net_list, &net->devices); | ||
626 | rdev->prev = prev; | 619 | rdev->prev = prev; |
627 | if (prev && rio_is_switch(prev)) | 620 | if (prev && rio_is_switch(prev)) |
628 | prev->rswitch->nextdev[prev_port] = rdev; | 621 | prev->rswitch->nextdev[prev_port] = rdev; |
@@ -778,8 +771,6 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid, | |||
778 | 771 | ||
779 | /* Setup new RIO device */ | 772 | /* Setup new RIO device */ |
780 | if ((rdev = rio_setup_device(net, port, destid, hopcount, 0))) { | 773 | if ((rdev = rio_setup_device(net, port, destid, hopcount, 0))) { |
781 | /* Add device to the global and bus/net specific list. */ | ||
782 | list_add_tail(&rdev->net_list, &net->devices); | ||
783 | rdev->prev = prev; | 774 | rdev->prev = prev; |
784 | if (prev && rio_is_switch(prev)) | 775 | if (prev && rio_is_switch(prev)) |
785 | prev->rswitch->nextdev[prev_port] = rdev; | 776 | prev->rswitch->nextdev[prev_port] = rdev; |
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index c72f4da8065e..0be86f4eea5d 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c | |||
@@ -96,12 +96,18 @@ int rio_add_device(struct rio_dev *rdev) | |||
96 | { | 96 | { |
97 | int err; | 97 | int err; |
98 | 98 | ||
99 | err = device_add(&rdev->dev); | 99 | err = device_register(&rdev->dev); |
100 | if (err) | 100 | if (err) |
101 | return err; | 101 | return err; |
102 | 102 | ||
103 | spin_lock(&rio_global_list_lock); | 103 | spin_lock(&rio_global_list_lock); |
104 | list_add_tail(&rdev->global_list, &rio_devices); | 104 | list_add_tail(&rdev->global_list, &rio_devices); |
105 | if (rdev->net) { | ||
106 | list_add_tail(&rdev->net_list, &rdev->net->devices); | ||
107 | if (rdev->pef & RIO_PEF_SWITCH) | ||
108 | list_add_tail(&rdev->rswitch->node, | ||
109 | &rdev->net->switches); | ||
110 | } | ||
105 | spin_unlock(&rio_global_list_lock); | 111 | spin_unlock(&rio_global_list_lock); |
106 | 112 | ||
107 | rio_create_sysfs_dev_files(rdev); | 113 | rio_create_sysfs_dev_files(rdev); |
@@ -110,6 +116,31 @@ int rio_add_device(struct rio_dev *rdev) | |||
110 | } | 116 | } |
111 | EXPORT_SYMBOL_GPL(rio_add_device); | 117 | EXPORT_SYMBOL_GPL(rio_add_device); |
112 | 118 | ||
119 | /* | ||
120 | * rio_del_device - removes a RIO device from the device model | ||
121 | * @rdev: RIO device | ||
122 | * | ||
123 | * Removes the RIO device to the kernel device list and subsystem's device list. | ||
124 | * Clears sysfs entries for the removed device. | ||
125 | */ | ||
126 | void rio_del_device(struct rio_dev *rdev) | ||
127 | { | ||
128 | pr_debug("RIO: %s: removing %s\n", __func__, rio_name(rdev)); | ||
129 | spin_lock(&rio_global_list_lock); | ||
130 | list_del(&rdev->global_list); | ||
131 | if (rdev->net) { | ||
132 | list_del(&rdev->net_list); | ||
133 | if (rdev->pef & RIO_PEF_SWITCH) { | ||
134 | list_del(&rdev->rswitch->node); | ||
135 | kfree(rdev->rswitch->route_table); | ||
136 | } | ||
137 | } | ||
138 | spin_unlock(&rio_global_list_lock); | ||
139 | rio_remove_sysfs_dev_files(rdev); | ||
140 | device_unregister(&rdev->dev); | ||
141 | } | ||
142 | EXPORT_SYMBOL_GPL(rio_del_device); | ||
143 | |||
113 | /** | 144 | /** |
114 | * rio_request_inb_mbox - request inbound mailbox service | 145 | * rio_request_inb_mbox - request inbound mailbox service |
115 | * @mport: RIO master port from which to allocate the mailbox resource | 146 | * @mport: RIO master port from which to allocate the mailbox resource |
diff --git a/drivers/rapidio/rio.h b/drivers/rapidio/rio.h index 2d0550e08ea2..da0f604a834e 100644 --- a/drivers/rapidio/rio.h +++ b/drivers/rapidio/rio.h | |||
@@ -28,6 +28,7 @@ extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid, | |||
28 | extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, | 28 | extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, |
29 | u8 hopcount); | 29 | u8 hopcount); |
30 | extern int rio_create_sysfs_dev_files(struct rio_dev *rdev); | 30 | extern int rio_create_sysfs_dev_files(struct rio_dev *rdev); |
31 | extern void rio_remove_sysfs_dev_files(struct rio_dev *rdev); | ||
31 | extern int rio_lock_device(struct rio_mport *port, u16 destid, | 32 | extern int rio_lock_device(struct rio_mport *port, u16 destid, |
32 | u8 hopcount, int wait_ms); | 33 | u8 hopcount, int wait_ms); |
33 | extern int rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount); | 34 | extern int rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount); |
@@ -39,6 +40,7 @@ extern int rio_route_clr_table(struct rio_dev *rdev, u16 table, int lock); | |||
39 | extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock); | 40 | extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock); |
40 | extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from); | 41 | extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from); |
41 | extern int rio_add_device(struct rio_dev *rdev); | 42 | extern int rio_add_device(struct rio_dev *rdev); |
43 | extern void rio_del_device(struct rio_dev *rdev); | ||
42 | extern int rio_enable_rx_tx_port(struct rio_mport *port, int local, u16 destid, | 44 | extern int rio_enable_rx_tx_port(struct rio_mport *port, int local, u16 destid, |
43 | u8 hopcount, u8 port_num); | 45 | u8 hopcount, u8 port_num); |
44 | extern int rio_register_scan(int mport_id, struct rio_scan *scan_ops); | 46 | extern int rio_register_scan(int mport_id, struct rio_scan *scan_ops); |