xref: /linux/include/scsi/scsi_driver.h (revision 69050f8d6d075dc01af7a5f2f550a8067510366f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _SCSI_SCSI_DRIVER_H
3 #define _SCSI_SCSI_DRIVER_H
4 
5 #include <linux/blk_types.h>
6 #include <linux/device.h>
7 #include <scsi/scsi_cmnd.h>
8 
9 struct module;
10 struct request;
11 
12 struct scsi_driver {
13 	struct device_driver	gendrv;
14 
15 	int (*probe)(struct scsi_device *);
16 	void (*remove)(struct scsi_device *);
17 	void (*shutdown)(struct scsi_device *);
18 	int (*resume)(struct device *);
19 	void (*rescan)(struct device *);
20 	blk_status_t (*init_command)(struct scsi_cmnd *);
21 	void (*uninit_command)(struct scsi_cmnd *);
22 	int (*done)(struct scsi_cmnd *);
23 	int (*eh_action)(struct scsi_cmnd *, int);
24 	void (*eh_reset)(struct scsi_cmnd *);
25 };
26 #define to_scsi_driver(drv) \
27 	container_of((drv), struct scsi_driver, gendrv)
28 
29 #define scsi_register_driver(drv) \
30 	__scsi_register_driver(drv, THIS_MODULE)
31 int __scsi_register_driver(struct scsi_driver *, struct module *);
32 #define scsi_unregister_driver(drv) \
33 	driver_unregister(&(drv)->gendrv);
34 
35 extern int scsi_register_interface(struct class_interface *);
36 #define scsi_unregister_interface(intf) \
37 	class_interface_unregister(intf)
38 
39 /* make sure not to use it with passthrough commands */
40 static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
41 {
42 	return to_scsi_driver(cmd->device->sdev_gendev.driver);
43 }
44 
45 #endif /* _SCSI_SCSI_DRIVER_H */
46