1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_BSG_H
3 #define _LINUX_BSG_H
4 
5 #include <uapi/linux/bsg.h>
6 
7 struct request;
8 
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 
18 struct bsg_class_device {
19 	struct device *class_dev;
20 	int minor;
21 	struct request_queue *queue;
22 	const struct bsg_ops *ops;
23 };
24 
25 int bsg_register_queue(struct request_queue *q, struct device *parent,
26 		const char *name, const struct bsg_ops *ops);
27 int bsg_scsi_register_queue(struct request_queue *q, struct device *parent);
28 void bsg_unregister_queue(struct request_queue *q);
29 #else
bsg_scsi_register_queue(struct request_queue * q,struct device * parent)30 static inline int bsg_scsi_register_queue(struct request_queue *q,
31 		struct device *parent)
32 {
33 	return 0;
34 }
bsg_unregister_queue(struct request_queue * q)35 static inline void bsg_unregister_queue(struct request_queue *q)
36 {
37 }
38 #endif /* CONFIG_BLK_DEV_BSG */
39 #endif /* _LINUX_BSG_H */
40