Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359391
b: refs/heads/master
c: 3c94ce6
h: refs/heads/master
i:
  359389: 80a836b
  359387: 9ca3766
  359383: 7e24e06
  359375: edb997b
  359359: 5a16415
v: v3
  • Loading branch information
Dae S. Kim authored and Linus Torvalds committed Feb 28, 2013
1 parent 180040f commit 0bfa4a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 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: f2afae4629d74287aaac39d0532aac5819e77e70
refs/heads/master: 3c94ce6f48f484bbc4dba83c0ed1f98f5e10957c
16 changes: 9 additions & 7 deletions trunk/drivers/char/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,12 @@ static const struct file_operations misc_fops = {

int misc_register(struct miscdevice * misc)
{
struct miscdevice *c;
dev_t dev;
int err = 0;

INIT_LIST_HEAD(&misc->list);

mutex_lock(&misc_mtx);
list_for_each_entry(c, &misc_list, list) {
if (c->minor == misc->minor) {
mutex_unlock(&misc_mtx);
return -EBUSY;
}
}

if (misc->minor == MISC_DYNAMIC_MINOR) {
int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
Expand All @@ -205,6 +198,15 @@ int misc_register(struct miscdevice * misc)
}
misc->minor = DYNAMIC_MINORS - i - 1;
set_bit(i, misc_minors);
} else {
struct miscdevice *c;

list_for_each_entry(c, &misc_list, list) {
if (c->minor == misc->minor) {
mutex_unlock(&misc_mtx);
return -EBUSY;
}
}
}

dev = MKDEV(MISC_MAJOR, misc->minor);
Expand Down

0 comments on commit 0bfa4a8

Please sign in to comment.