scsi_driver.h 1.2 KB

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