sd.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef _SCSI_DISK_H
  2. #define _SCSI_DISK_H
  3. /*
  4. * More than enough for everybody ;) The huge number of majors
  5. * is a leftover from 16bit dev_t days, we don't really need that
  6. * much numberspace.
  7. */
  8. #define SD_MAJORS 16
  9. /*
  10. * This is limited by the naming scheme enforced in sd_probe,
  11. * add another character to it if you really need more disks.
  12. */
  13. #define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26)
  14. /*
  15. * Time out in seconds for disks and Magneto-opticals (which are slower).
  16. */
  17. #define SD_TIMEOUT (30 * HZ)
  18. #define SD_MOD_TIMEOUT (75 * HZ)
  19. /*
  20. * Number of allowed retries
  21. */
  22. #define SD_MAX_RETRIES 5
  23. #define SD_PASSTHROUGH_RETRIES 1
  24. /*
  25. * Size of the initial data buffer for mode and read capacity data
  26. */
  27. #define SD_BUF_SIZE 512
  28. struct scsi_disk {
  29. struct scsi_driver *driver; /* always &sd_template */
  30. struct scsi_device *device;
  31. struct class_device cdev;
  32. struct gendisk *disk;
  33. unsigned int openers; /* protected by BKL for now, yuck */
  34. sector_t capacity; /* size in 512-byte sectors */
  35. u32 index;
  36. u8 media_present;
  37. u8 write_prot;
  38. unsigned WCE : 1; /* state of disk WCE bit */
  39. unsigned RCD : 1; /* state of disk RCD bit, unused */
  40. unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
  41. };
  42. #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
  43. static int sd_revalidate_disk(struct gendisk *disk);
  44. static void sd_rw_intr(struct scsi_cmnd * SCpnt);
  45. static int sd_probe(struct device *);
  46. static int sd_remove(struct device *);
  47. static void sd_shutdown(struct device *dev);
  48. static int sd_suspend(struct device *dev, pm_message_t state);
  49. static int sd_resume(struct device *dev);
  50. static void sd_rescan(struct device *);
  51. static int sd_init_command(struct scsi_cmnd *);
  52. static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
  53. static void scsi_disk_release(struct class_device *cdev);
  54. static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
  55. static void sd_print_result(struct scsi_disk *, int);
  56. #define sd_printk(prefix, sdsk, fmt, a...) \
  57. (sdsk)->disk ? \
  58. sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \
  59. (sdsk)->disk->disk_name, ##a) : \
  60. sdev_printk(prefix, (sdsk)->device, fmt, ##a)
  61. #endif /* _SCSI_DISK_H */