- down(&phone_lock);
- if (phone_device[pfd->minor] != pfd)
- panic("phone: bad unregister");
- devfs_remove("phone/%d", pfd->minor);
- phone_device[pfd->minor] = NULL;
- up(&phone_lock);
+ mutex_lock(&phone_lock);
+ if (likely(phone_device[pfd->minor] == pfd))
+ phone_device[pfd->minor] = NULL;
+ mutex_unlock(&phone_lock);