blob: dac37b6e00ecc8a328d5565573ebb8a689740379 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Christoph Hellwig17cb9602018-03-13 17:28:41 +01002#ifndef _LINUX_BSG_H
3#define _LINUX_BSG_H
Jens Axboe3d6392c2007-07-09 12:38:05 +02004
David Howells607ca462012-10-13 10:46:48 +01005#include <uapi/linux/bsg.h>
Douglas Gilbert4ab3b732009-03-09 10:51:38 -04006
Christoph Hellwig17cb9602018-03-13 17:28:41 +01007struct request;
FUJITA Tomonori45977d0e2006-12-20 11:19:32 +01008
Christoph Hellwig17cb9602018-03-13 17:28:41 +01009#ifdef CONFIG_BLK_DEV_BSG
10struct 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 Axboe3d6392c2007-07-09 12:38:05 +020018struct bsg_class_device {
Tony Jonesee959b02008-02-22 00:13:36 +010019 struct device *class_dev;
Jens Axboe3d6392c2007-07-09 12:38:05 +020020 int minor;
FUJITA Tomonorid351af02007-07-09 12:40:35 +020021 struct request_queue *queue;
Christoph Hellwig17cb9602018-03-13 17:28:41 +010022 const struct bsg_ops *ops;
Jens Axboe3d6392c2007-07-09 12:38:05 +020023};
24
Christoph Hellwig17cb9602018-03-13 17:28:41 +010025int bsg_register_queue(struct request_queue *q, struct device *parent,
Christoph Hellwig5de815a2018-05-29 08:40:23 +020026 const char *name, const struct bsg_ops *ops);
Christoph Hellwig17cb9602018-03-13 17:28:41 +010027int bsg_scsi_register_queue(struct request_queue *q, struct device *parent);
28void bsg_unregister_queue(struct request_queue *q);
Jens Axboe3d6392c2007-07-09 12:38:05 +020029#else
Christoph Hellwig17cb9602018-03-13 17:28:41 +010030static inline int bsg_scsi_register_queue(struct request_queue *q,
31 struct device *parent)
James Bottomleya4ee0df2007-07-23 09:53:51 -050032{
33 return 0;
34}
FUJITA Tomonori97f46ae2008-04-19 00:43:14 +090035static inline void bsg_unregister_queue(struct request_queue *q)
James Bottomleya4ee0df2007-07-23 09:53:51 -050036{
37}
Christoph Hellwig17cb9602018-03-13 17:28:41 +010038#endif /* CONFIG_BLK_DEV_BSG */
39#endif /* _LINUX_BSG_H */