projects/linux·blob master · refs

45 lines · 1.3 KiB

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
9struct module;
10struct request;
11
12struct 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)
31int __scsi_register_driver(struct scsi_driver *, struct module *);
32#define scsi_unregister_driver(drv) \
33 driver_unregister(&(drv)->gendrv);
34
35extern 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 */
40static 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 */