diff options
| author | Alexandre Bounine <alexandre.bounine@idt.com> | 2012-10-10 18:54:01 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-10 19:50:15 -0400 |
| commit | 4ed134beee42a5c9fc4b439f1e498363066e2516 (patch) | |
| tree | d2d2dc5515f15c19b0a51882e656176f9d72aef1 /drivers/rapidio | |
| parent | 2574740d1fe946803caa6b0c06fbb4bf397af35d (diff) | |
rapidio: update for destination ID allocation
Address comments provided by Andrew Morton:
https://lkml.org/lkml/2012/10/3/550
- Keeps consistent kerneldoc compatible comments style for new static
functions.
- Removes unnecessary complexity from destination ID allocation
routine.
- Uses kcalloc() for code clarity.
Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Li Yang <leoli@freescale.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rapidio')
| -rw-r--r-- | drivers/rapidio/rio-scan.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 05f0ed9f8b1e..07da58bb495c 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c | |||
| @@ -55,9 +55,9 @@ static int rio_mport_phys_table[] = { | |||
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | /* | 58 | /** |
| 59 | * rio_destid_alloc - Allocate next available destID for given network | 59 | * rio_destid_alloc - Allocate next available destID for given network |
| 60 | * net: RIO network | 60 | * @net: RIO network |
| 61 | * | 61 | * |
| 62 | * Returns next available device destination ID for the specified RIO network. | 62 | * Returns next available device destination ID for the specified RIO network. |
| 63 | * Marks allocated ID as one in use. | 63 | * Marks allocated ID as one in use. |
| @@ -69,14 +69,9 @@ static u16 rio_destid_alloc(struct rio_net *net) | |||
| 69 | struct rio_id_table *idtab = &net->destid_table; | 69 | struct rio_id_table *idtab = &net->destid_table; |
| 70 | 70 | ||
| 71 | spin_lock(&idtab->lock); | 71 | spin_lock(&idtab->lock); |
| 72 | destid = find_next_zero_bit(idtab->table, idtab->max, idtab->next); | 72 | destid = find_first_zero_bit(idtab->table, idtab->max); |
| 73 | if (destid >= idtab->max) | ||
| 74 | destid = find_first_zero_bit(idtab->table, idtab->max); | ||
| 75 | 73 | ||
| 76 | if (destid < idtab->max) { | 74 | if (destid < idtab->max) { |
| 77 | idtab->next = destid + 1; | ||
| 78 | if (idtab->next >= idtab->max) | ||
| 79 | idtab->next = 0; | ||
| 80 | set_bit(destid, idtab->table); | 75 | set_bit(destid, idtab->table); |
| 81 | destid += idtab->start; | 76 | destid += idtab->start; |
| 82 | } else | 77 | } else |
| @@ -86,10 +81,10 @@ static u16 rio_destid_alloc(struct rio_net *net) | |||
| 86 | return (u16)destid; | 81 | return (u16)destid; |
| 87 | } | 82 | } |
| 88 | 83 | ||
| 89 | /* | 84 | /** |
| 90 | * rio_destid_reserve - Reserve the specivied destID | 85 | * rio_destid_reserve - Reserve the specivied destID |
| 91 | * net: RIO network | 86 | * @net: RIO network |
| 92 | * destid: destID to reserve | 87 | * @destid: destID to reserve |
| 93 | * | 88 | * |
| 94 | * Tries to reserve the specified destID. | 89 | * Tries to reserve the specified destID. |
| 95 | * Returns 0 if successfull. | 90 | * Returns 0 if successfull. |
| @@ -106,10 +101,10 @@ static int rio_destid_reserve(struct rio_net *net, u16 destid) | |||
| 106 | return oldbit; | 101 | return oldbit; |
| 107 | } | 102 | } |
| 108 | 103 | ||
| 109 | /* | 104 | /** |
| 110 | * rio_destid_free - free a previously allocated destID | 105 | * rio_destid_free - free a previously allocated destID |
| 111 | * net: RIO network | 106 | * @net: RIO network |
| 112 | * destid: destID to free | 107 | * @destid: destID to free |
| 113 | * | 108 | * |
| 114 | * Makes the specified destID available for use. | 109 | * Makes the specified destID available for use. |
| 115 | */ | 110 | */ |
| @@ -123,9 +118,9 @@ static void rio_destid_free(struct rio_net *net, u16 destid) | |||
| 123 | spin_unlock(&idtab->lock); | 118 | spin_unlock(&idtab->lock); |
| 124 | } | 119 | } |
| 125 | 120 | ||
| 126 | /* | 121 | /** |
| 127 | * rio_destid_first - return first destID in use | 122 | * rio_destid_first - return first destID in use |
| 128 | * net: RIO network | 123 | * @net: RIO network |
| 129 | */ | 124 | */ |
| 130 | static u16 rio_destid_first(struct rio_net *net) | 125 | static u16 rio_destid_first(struct rio_net *net) |
| 131 | { | 126 | { |
| @@ -142,10 +137,10 @@ static u16 rio_destid_first(struct rio_net *net) | |||
| 142 | return (u16)destid; | 137 | return (u16)destid; |
| 143 | } | 138 | } |
| 144 | 139 | ||
| 145 | /* | 140 | /** |
| 146 | * rio_destid_next - return next destID in use | 141 | * rio_destid_next - return next destID in use |
| 147 | * net: RIO network | 142 | * @net: RIO network |
| 148 | * from: destination ID from which search shall continue | 143 | * @from: destination ID from which search shall continue |
| 149 | */ | 144 | */ |
| 150 | static u16 rio_destid_next(struct rio_net *net, u16 from) | 145 | static u16 rio_destid_next(struct rio_net *net, u16 from) |
| 151 | { | 146 | { |
| @@ -1163,8 +1158,8 @@ static struct rio_net __devinit *rio_alloc_net(struct rio_mport *port, | |||
| 1163 | 1158 | ||
| 1164 | net = kzalloc(sizeof(struct rio_net), GFP_KERNEL); | 1159 | net = kzalloc(sizeof(struct rio_net), GFP_KERNEL); |
| 1165 | if (net && do_enum) { | 1160 | if (net && do_enum) { |
| 1166 | net->destid_table.table = kzalloc( | 1161 | net->destid_table.table = kcalloc( |
| 1167 | BITS_TO_LONGS(RIO_MAX_ROUTE_ENTRIES(port->sys_size)) * | 1162 | BITS_TO_LONGS(RIO_MAX_ROUTE_ENTRIES(port->sys_size)), |
| 1168 | sizeof(long), | 1163 | sizeof(long), |
| 1169 | GFP_KERNEL); | 1164 | GFP_KERNEL); |
| 1170 | 1165 | ||
| @@ -1174,7 +1169,6 @@ static struct rio_net __devinit *rio_alloc_net(struct rio_mport *port, | |||
| 1174 | net = NULL; | 1169 | net = NULL; |
| 1175 | } else { | 1170 | } else { |
| 1176 | net->destid_table.start = start; | 1171 | net->destid_table.start = start; |
| 1177 | net->destid_table.next = 0; | ||
| 1178 | net->destid_table.max = | 1172 | net->destid_table.max = |
| 1179 | RIO_MAX_ROUTE_ENTRIES(port->sys_size); | 1173 | RIO_MAX_ROUTE_ENTRIES(port->sys_size); |
| 1180 | spin_lock_init(&net->destid_table.lock); | 1174 | spin_lock_init(&net->destid_table.lock); |
