Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 86357
b: refs/heads/master
c: 96b1906
h: refs/heads/master
i:
  86355: c484942
v: v3
  • Loading branch information
Stefan Richter committed Feb 16, 2008
1 parent 0745cba commit 694283e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 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: 1b9c12ba2fdf802a23630f70eddb0e821296634e
refs/heads/master: 96b19062e741b715cf399312c30e0672d8889569
8 changes: 5 additions & 3 deletions trunk/drivers/firewire/fw-cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,17 @@ static int fw_device_op_open(struct inode *inode, struct file *file)
struct client *client;
unsigned long flags;

device = fw_device_from_devt(inode->i_rdev);
device = fw_device_get_by_devt(inode->i_rdev);
if (device == NULL)
return -ENODEV;

client = kzalloc(sizeof(*client), GFP_KERNEL);
if (client == NULL)
if (client == NULL) {
fw_device_put(device);
return -ENOMEM;
}

client->device = fw_device_get(device);
client->device = device;
INIT_LIST_HEAD(&client->event_list);
INIT_LIST_HEAD(&client->resource_list);
spin_lock_init(&client->lock);
Expand Down
20 changes: 14 additions & 6 deletions trunk/drivers/firewire/fw-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,14 @@ static DECLARE_RWSEM(idr_rwsem);
static DEFINE_IDR(fw_device_idr);
int fw_cdev_major;

struct fw_device *fw_device_from_devt(dev_t devt)
struct fw_device *fw_device_get_by_devt(dev_t devt)
{
struct fw_device *device;

down_read(&idr_rwsem);
device = idr_find(&fw_device_idr, MINOR(devt));
if (device)
fw_device_get(device);
up_read(&idr_rwsem);

return device;
Expand All @@ -627,13 +629,14 @@ static void fw_device_shutdown(struct work_struct *work)
container_of(work, struct fw_device, work.work);
int minor = MINOR(device->device.devt);

down_write(&idr_rwsem);
idr_remove(&fw_device_idr, minor);
up_write(&idr_rwsem);

fw_device_cdev_remove(device);
device_for_each_child(&device->device, NULL, shutdown_unit);
device_unregister(&device->device);

down_write(&idr_rwsem);
idr_remove(&fw_device_idr, minor);
up_write(&idr_rwsem);
fw_device_put(device);
}

static struct device_type fw_device_type = {
Expand Down Expand Up @@ -682,10 +685,13 @@ static void fw_device_init(struct work_struct *work)
}

err = -ENOMEM;

fw_device_get(device);
down_write(&idr_rwsem);
if (idr_pre_get(&fw_device_idr, GFP_KERNEL))
err = idr_get_new(&fw_device_idr, device, &minor);
up_write(&idr_rwsem);

if (err < 0)
goto error;

Expand Down Expand Up @@ -741,7 +747,9 @@ static void fw_device_init(struct work_struct *work)
idr_remove(&fw_device_idr, minor);
up_write(&idr_rwsem);
error:
put_device(&device->device);
fw_device_put(device); /* fw_device_idr's reference */

put_device(&device->device); /* our reference */
}

static int update_unit(struct device *dev, void *data)
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/firewire/fw-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ fw_device_is_shutdown(struct fw_device *device)
}

struct fw_device *fw_device_get(struct fw_device *device);
struct fw_device *fw_device_get_by_devt(dev_t devt);
void fw_device_put(struct fw_device *device);
int fw_device_enable_phys_dma(struct fw_device *device);

void fw_device_cdev_update(struct fw_device *device);
void fw_device_cdev_remove(struct fw_device *device);

struct fw_device *fw_device_from_devt(dev_t devt);
extern int fw_cdev_major;

struct fw_unit {
Expand Down

0 comments on commit 694283e

Please sign in to comment.