Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 279086
b: refs/heads/master
c: c79be45
h: refs/heads/master
v: v3
  • Loading branch information
Allan Stephens authored and Paul Gortmaker committed Dec 27, 2011
1 parent ed8e534 commit 0c46958
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 706767da1bd0726d8fbc62e4818cb29193676a74
refs/heads/master: c79be4549ae39edc026aa67eb64a25424542943f
40 changes: 21 additions & 19 deletions trunk/net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@ static struct media *media_find(const char *name)
return NULL;
}

/**
* media_find_id - locates specified media object by type identifier
*/

static struct media *media_find_id(u8 type)
{
u32 i;

for (i = 0; i < media_count; i++) {
if (media_list[i].type_id == type)
return &media_list[i];
}
return NULL;
}

/**
* tipc_register_media - register a media type
*
Expand All @@ -88,8 +103,6 @@ static struct media *media_find(const char *name)

int tipc_register_media(struct media *m_ptr)
{
u32 media_id;
u32 i;
int res = -EINVAL;

write_lock_bh(&tipc_net_lock);
Expand Down Expand Up @@ -121,29 +134,18 @@ int tipc_register_media(struct media *m_ptr)
goto exit;
}

media_id = media_count++;
if (media_id >= MAX_MEDIA) {
if (media_count >= MAX_MEDIA) {
warn("Media <%s> rejected, media limit reached (%u)\n",
m_ptr->name, MAX_MEDIA);
media_count--;
goto exit;
}
for (i = 0; i < media_id; i++) {
if (media_list[i].type_id == m_ptr->type_id) {
warn("Media <%s> rejected, duplicate type (%u)\n",
m_ptr->name, m_ptr->type_id);
media_count--;
goto exit;
}
if (!strcmp(m_ptr->name, media_list[i].name)) {
warn("Media <%s> rejected, duplicate name\n",
m_ptr->name);
media_count--;
goto exit;
}
if (media_find(m_ptr->name) || media_find_id(m_ptr->type_id)) {
warn("Media <%s> rejected, already registered\n", m_ptr->name);
goto exit;
}

media_list[media_id] = *m_ptr;
media_list[media_count] = *m_ptr;
media_count++;
res = 0;
exit:
write_unlock_bh(&tipc_net_lock);
Expand Down

0 comments on commit 0c46958

Please sign in to comment.