Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Christoph Hellwig | 17cb960 | 2018-03-13 17:28:41 +0100 | [diff] [blame] | 2 | #ifndef _LINUX_BSG_H |
| 3 | #define _LINUX_BSG_H |
Jens Axboe | 3d6392c | 2007-07-09 12:38:05 +0200 | [diff] [blame] | 4 | |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 5 | #include <uapi/linux/bsg.h> |
Douglas Gilbert | 4ab3b73 | 2009-03-09 10:51:38 -0400 | [diff] [blame] | 6 | |
Christoph Hellwig | 17cb960 | 2018-03-13 17:28:41 +0100 | [diff] [blame] | 7 | struct request; |
FUJITA Tomonori | 45977d0e | 2006-12-20 11:19:32 +0100 | [diff] [blame] | 8 | |
Christoph Hellwig | 17cb960 | 2018-03-13 17:28:41 +0100 | [diff] [blame] | 9 | #ifdef CONFIG_BLK_DEV_BSG |
| 10 | struct bsg_ops { |
| 11 | int (*check_proto)(struct sg_io_v4 *hdr); |
| 12 | int (*fill_hdr)(struct request *rq, struct sg_io_v4 *hdr, |
| 13 | fmode_t mode); |
| 14 | int (*complete_rq)(struct request *rq, struct sg_io_v4 *hdr); |
| 15 | void (*free_rq)(struct request *rq); |
| 16 | }; |
| 17 | |
Jens Axboe | 3d6392c | 2007-07-09 12:38:05 +0200 | [diff] [blame] | 18 | struct bsg_class_device { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 19 | struct device *class_dev; |
FUJITA Tomonori | 97f46ae | 2008-04-19 00:43:14 +0900 | [diff] [blame] | 20 | struct device *parent; |
Jens Axboe | 3d6392c | 2007-07-09 12:38:05 +0200 | [diff] [blame] | 21 | int minor; |
FUJITA Tomonori | d351af0 | 2007-07-09 12:40:35 +0200 | [diff] [blame] | 22 | struct request_queue *queue; |
FUJITA Tomonori | 97f46ae | 2008-04-19 00:43:14 +0900 | [diff] [blame] | 23 | struct kref ref; |
Christoph Hellwig | 17cb960 | 2018-03-13 17:28:41 +0100 | [diff] [blame] | 24 | const struct bsg_ops *ops; |
FUJITA Tomonori | 97f46ae | 2008-04-19 00:43:14 +0900 | [diff] [blame] | 25 | void (*release)(struct device *); |
Jens Axboe | 3d6392c | 2007-07-09 12:38:05 +0200 | [diff] [blame] | 26 | }; |
| 27 | |
Christoph Hellwig | 17cb960 | 2018-03-13 17:28:41 +0100 | [diff] [blame] | 28 | int bsg_register_queue(struct request_queue *q, struct device *parent, |
| 29 | const char *name, const struct bsg_ops *ops, |
| 30 | void (*release)(struct device *)); |
| 31 | int bsg_scsi_register_queue(struct request_queue *q, struct device *parent); |
| 32 | void bsg_unregister_queue(struct request_queue *q); |
Jens Axboe | 3d6392c | 2007-07-09 12:38:05 +0200 | [diff] [blame] | 33 | #else |
Christoph Hellwig | 17cb960 | 2018-03-13 17:28:41 +0100 | [diff] [blame] | 34 | static inline int bsg_scsi_register_queue(struct request_queue *q, |
| 35 | struct device *parent) |
James Bottomley | a4ee0df | 2007-07-23 09:53:51 -0500 | [diff] [blame] | 36 | { |
| 37 | return 0; |
| 38 | } |
FUJITA Tomonori | 97f46ae | 2008-04-19 00:43:14 +0900 | [diff] [blame] | 39 | static inline void bsg_unregister_queue(struct request_queue *q) |
James Bottomley | a4ee0df | 2007-07-23 09:53:51 -0500 | [diff] [blame] | 40 | { |
| 41 | } |
Christoph Hellwig | 17cb960 | 2018-03-13 17:28:41 +0100 | [diff] [blame] | 42 | #endif /* CONFIG_BLK_DEV_BSG */ |
| 43 | #endif /* _LINUX_BSG_H */ |