diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-04-18 11:43:14 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-04-22 16:16:32 -0400 |
commit | 97f46ae45c70857e459b7f8df1fc2807e7bd90a9 (patch) | |
tree | 7e7245349c433f67be23c6a75c3936c0466b59d6 /include/linux/bsg.h | |
parent | 643eb2d932c97a0583381629d632d486934cf7ee (diff) |
[SCSI] bsg: add release callback support
This patch adds release callback support, which is called when a bsg
device goes away. bsg_register_queue() takes a pointer to a callback
function. This feature is useful for stuff like sas_host that can't
use the release callback in struct device.
If a caller doesn't need bsg's release callback, it can call
bsg_register_queue() with NULL pointer (e.g. scsi devices can use
release callback in struct device so they don't need bsg's callback).
With this patch, bsg uses kref for refcounts on bsg devices instead of
get/put_device in fops->open/release. bsg calls put_device and the
caller's release callback (if it was registered) in kref_put's
release.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'include/linux/bsg.h')
-rw-r--r-- | include/linux/bsg.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/include/linux/bsg.h b/include/linux/bsg.h index e8406c55c6d3..cf0303a60611 100644 --- a/include/linux/bsg.h +++ b/include/linux/bsg.h | |||
@@ -56,19 +56,25 @@ struct sg_io_v4 { | |||
56 | #if defined(CONFIG_BLK_DEV_BSG) | 56 | #if defined(CONFIG_BLK_DEV_BSG) |
57 | struct bsg_class_device { | 57 | struct bsg_class_device { |
58 | struct device *class_dev; | 58 | struct device *class_dev; |
59 | struct device *dev; | 59 | struct device *parent; |
60 | int minor; | 60 | int minor; |
61 | struct request_queue *queue; | 61 | struct request_queue *queue; |
62 | struct kref ref; | ||
63 | void (*release)(struct device *); | ||
62 | }; | 64 | }; |
63 | 65 | ||
64 | extern int bsg_register_queue(struct request_queue *, struct device *, const char *); | 66 | extern int bsg_register_queue(struct request_queue *q, |
67 | struct device *parent, const char *name, | ||
68 | void (*release)(struct device *)); | ||
65 | extern void bsg_unregister_queue(struct request_queue *); | 69 | extern void bsg_unregister_queue(struct request_queue *); |
66 | #else | 70 | #else |
67 | static inline int bsg_register_queue(struct request_queue * rq, struct device *dev, const char *name) | 71 | static inline int bsg_register_queue(struct request_queue *q, |
72 | struct device *parent, const char *name, | ||
73 | void (*release)(struct device *)) | ||
68 | { | 74 | { |
69 | return 0; | 75 | return 0; |
70 | } | 76 | } |
71 | static inline void bsg_unregister_queue(struct request_queue *rq) | 77 | static inline void bsg_unregister_queue(struct request_queue *q) |
72 | { | 78 | { |
73 | } | 79 | } |
74 | #endif | 80 | #endif |