aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sctp/command.h
diff options
context:
space:
mode:
authorDavid Laight <David.Laight@ACULAB.COM>2014-07-04 10:35:51 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-08 17:38:48 -0400
commitbe1f4f48cef17c6ea9350db04c774dc8eb252158 (patch)
tree64352a351a16a0ff3eb9bdbe850f68868d5dd263 /include/net/sctp/command.h
parent63ae88949bc7f6b56438d430c55060d9eda981af (diff)
net: sctp: Inline the functions from command.c
sctp_init_cmd_seq() and sctp_next_cmd() are only called from one place. The call sequence for sctp_add_cmd_sf() is likely to be longer than the inlined code. With sctp_add_cmd_sf() inlined the compiler can optimise repeated calls. Signed-off-by: David Laight <david.laight@aculab.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sctp/command.h')
-rw-r--r--include/net/sctp/command.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 4b7cd695e431..0e91a42065db 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -210,19 +210,38 @@ typedef struct {
210/* Initialize a block of memory as a command sequence. 210/* Initialize a block of memory as a command sequence.
211 * Return 0 if the initialization fails. 211 * Return 0 if the initialization fails.
212 */ 212 */
213int sctp_init_cmd_seq(sctp_cmd_seq_t *seq); 213static inline int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
214{
215 memset(seq, 0, sizeof(sctp_cmd_seq_t));
216 return 1; /* We always succeed. */
217}
218
214 219
215/* Add a command to an sctp_cmd_seq_t. 220/* Add a command to an sctp_cmd_seq_t.
216 * 221 *
217 * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above 222 * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
218 * to wrap data which goes in the obj argument. 223 * to wrap data which goes in the obj argument.
219 */ 224 */
220void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj); 225static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb,
226 sctp_arg_t obj)
227{
228 BUG_ON(seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS);
229
230 seq->cmds[seq->next_free_slot].verb = verb;
231 seq->cmds[seq->next_free_slot++].obj = obj;
232}
221 233
222/* Return the next command structure in an sctp_cmd_seq. 234/* Return the next command structure in an sctp_cmd_seq.
223 * Return NULL at the end of the sequence. 235 * Return NULL at the end of the sequence.
224 */ 236 */
225sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq); 237static inline sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
238{
239 sctp_cmd_t *retval = NULL;
226 240
227#endif /* __net_sctp_command_h__ */ 241 if (seq->next_cmd < seq->next_free_slot)
242 retval = &seq->cmds[seq->next_cmd++];
243
244 return retval;
245}
228 246
247#endif /* __net_sctp_command_h__ */