[SCSI] osduld: Use device->release instead of internal kref
authorBoaz Harrosh <bharrosh@panasas.com>
Sun, 29 Nov 2009 14:25:26 +0000 (16:25 +0200)
committerJames Bottomley <James.Bottomley@suse.de>
Fri, 4 Dec 2009 18:01:45 +0000 (12:01 -0600)
commitd6ae4333e648492721a098bdc329bbd82d25eb67
tree88a78be7ebd13ac3d1cfb386dd1a9bb68ba9aa1f
parent89f5e1f2f13b1079b8d7ff7d3ade345b7ad7c009
[SCSI] osduld: Use device->release instead of internal kref

The true logic of this patch will be clear in the next patch where we
use the class_find_device() API. When doing so the use of an internal
kref leaves us a narrow window where a find is started while the actual
object can go away. Using the device's kobj reference solves this
problem because now the same kref is used for both operations. (Remove
and find)

Core changes
* Embed a struct device in uld_ structure and use device_register
  instead of devie_create. Set __remove to be the device release
  function.
* __uld_get/put is just get_/put_device. Now every thing is accounted
  for on the device object. Internal kref is removed.
* At __remove() we can safely de-allocate the uld_ structure. (The
  function has moved to avoid forward declaration)

Some cleanups
* Use class register/unregister is cleaner for this driver now.
* cdev ref-counting games are no longer necessary

I have incremented the device version string in case of new bugs.

Note: Previous bugfix of taking the reference around fput() still
      applies.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/osd/osd_uld.c
include/scsi/osd_initiator.h