blob: 0c7dd9ceb139e53a241d23bb60d1d9591ab480ae [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;
FUJITA Tomonori97f46ae2008-04-19 00:43:14 +090020 struct device *parent;
Jens Axboe3d6392c2007-07-09 12:38:05 +020021 int minor;
FUJITA Tomonorid351af02007-07-09 12:40:35 +020022 struct request_queue *queue;
FUJITA Tomonori97f46ae2008-04-19 00:43:14 +090023 struct kref ref;
Christoph Hellwig17cb9602018-03-13 17:28:41 +010024 const struct bsg_ops *ops;
FUJITA Tomonori97f46ae2008-04-19 00:43:14 +090025 void (*release)(struct device *);
Jens Axboe3d6392c2007-07-09 12:38:05 +020026};
27
Christoph Hellwig17cb9602018-03-13 17:28:41 +010028int bsg_register_queue(struct request_queue *q, struct device *parent,
29 const char *name, const struct bsg_ops *ops,
30 void (*release)(struct device *));
31int bsg_scsi_register_queue(struct request_queue *q, struct device *parent);
32void bsg_unregister_queue(struct request_queue *q);
Jens Axboe3d6392c2007-07-09 12:38:05 +020033#else
Christoph Hellwig17cb9602018-03-13 17:28:41 +010034static inline int bsg_scsi_register_queue(struct request_queue *q,
35 struct device *parent)
James Bottomleya4ee0df2007-07-23 09:53:51 -050036{
37 return 0;
38}
FUJITA Tomonori97f46ae2008-04-19 00:43:14 +090039static inline void bsg_unregister_queue(struct request_queue *q)
James Bottomleya4ee0df2007-07-23 09:53:51 -050040{
41}
Christoph Hellwig17cb9602018-03-13 17:28:41 +010042#endif /* CONFIG_BLK_DEV_BSG */
43#endif /* _LINUX_BSG_H */