diff options
Diffstat (limited to 'drivers/scsi/device_handler/scsi_dh_alua.c')
| -rw-r--r-- | drivers/scsi/device_handler/scsi_dh_alua.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 854b568b9931..cc2773b5de68 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c | |||
| @@ -62,7 +62,6 @@ | |||
| 62 | #define ALUA_OPTIMIZE_STPG 1 | 62 | #define ALUA_OPTIMIZE_STPG 1 |
| 63 | 63 | ||
| 64 | struct alua_dh_data { | 64 | struct alua_dh_data { |
| 65 | struct scsi_dh_data dh_data; | ||
| 66 | int group_id; | 65 | int group_id; |
| 67 | int rel_port; | 66 | int rel_port; |
| 68 | int tpgs; | 67 | int tpgs; |
| @@ -86,11 +85,6 @@ struct alua_dh_data { | |||
| 86 | static char print_alua_state(int); | 85 | static char print_alua_state(int); |
| 87 | static int alua_check_sense(struct scsi_device *, struct scsi_sense_hdr *); | 86 | static int alua_check_sense(struct scsi_device *, struct scsi_sense_hdr *); |
| 88 | 87 | ||
| 89 | static inline struct alua_dh_data *get_alua_data(struct scsi_device *sdev) | ||
| 90 | { | ||
| 91 | return container_of(sdev->scsi_dh_data, struct alua_dh_data, dh_data); | ||
| 92 | } | ||
| 93 | |||
| 94 | static int realloc_buffer(struct alua_dh_data *h, unsigned len) | 88 | static int realloc_buffer(struct alua_dh_data *h, unsigned len) |
| 95 | { | 89 | { |
| 96 | if (h->buff && h->buff != h->inq) | 90 | if (h->buff && h->buff != h->inq) |
| @@ -708,7 +702,7 @@ out: | |||
| 708 | */ | 702 | */ |
| 709 | static int alua_set_params(struct scsi_device *sdev, const char *params) | 703 | static int alua_set_params(struct scsi_device *sdev, const char *params) |
| 710 | { | 704 | { |
| 711 | struct alua_dh_data *h = get_alua_data(sdev); | 705 | struct alua_dh_data *h = sdev->handler_data; |
| 712 | unsigned int optimize = 0, argc; | 706 | unsigned int optimize = 0, argc; |
| 713 | const char *p = params; | 707 | const char *p = params; |
| 714 | int result = SCSI_DH_OK; | 708 | int result = SCSI_DH_OK; |
| @@ -746,7 +740,7 @@ MODULE_PARM_DESC(optimize_stpg, "Allow use of a non-optimized path, rather than | |||
| 746 | static int alua_activate(struct scsi_device *sdev, | 740 | static int alua_activate(struct scsi_device *sdev, |
| 747 | activate_complete fn, void *data) | 741 | activate_complete fn, void *data) |
| 748 | { | 742 | { |
| 749 | struct alua_dh_data *h = get_alua_data(sdev); | 743 | struct alua_dh_data *h = sdev->handler_data; |
| 750 | int err = SCSI_DH_OK; | 744 | int err = SCSI_DH_OK; |
| 751 | int stpg = 0; | 745 | int stpg = 0; |
| 752 | 746 | ||
| @@ -804,7 +798,7 @@ out: | |||
| 804 | */ | 798 | */ |
| 805 | static int alua_prep_fn(struct scsi_device *sdev, struct request *req) | 799 | static int alua_prep_fn(struct scsi_device *sdev, struct request *req) |
| 806 | { | 800 | { |
| 807 | struct alua_dh_data *h = get_alua_data(sdev); | 801 | struct alua_dh_data *h = sdev->handler_data; |
| 808 | int ret = BLKPREP_OK; | 802 | int ret = BLKPREP_OK; |
| 809 | 803 | ||
| 810 | if (h->state == TPGS_STATE_TRANSITIONING) | 804 | if (h->state == TPGS_STATE_TRANSITIONING) |
| @@ -819,23 +813,18 @@ static int alua_prep_fn(struct scsi_device *sdev, struct request *req) | |||
| 819 | 813 | ||
| 820 | } | 814 | } |
| 821 | 815 | ||
| 822 | static bool alua_match(struct scsi_device *sdev) | ||
| 823 | { | ||
| 824 | return (scsi_device_tpgs(sdev) != 0); | ||
| 825 | } | ||
| 826 | |||
| 827 | /* | 816 | /* |
| 828 | * alua_bus_attach - Attach device handler | 817 | * alua_bus_attach - Attach device handler |
| 829 | * @sdev: device to be attached to | 818 | * @sdev: device to be attached to |
| 830 | */ | 819 | */ |
| 831 | static struct scsi_dh_data *alua_bus_attach(struct scsi_device *sdev) | 820 | static int alua_bus_attach(struct scsi_device *sdev) |
| 832 | { | 821 | { |
| 833 | struct alua_dh_data *h; | 822 | struct alua_dh_data *h; |
| 834 | int err; | 823 | int err; |
| 835 | 824 | ||
| 836 | h = kzalloc(sizeof(*h) , GFP_KERNEL); | 825 | h = kzalloc(sizeof(*h) , GFP_KERNEL); |
| 837 | if (!h) | 826 | if (!h) |
| 838 | return ERR_PTR(-ENOMEM); | 827 | return -ENOMEM; |
| 839 | h->tpgs = TPGS_MODE_UNINITIALIZED; | 828 | h->tpgs = TPGS_MODE_UNINITIALIZED; |
| 840 | h->state = TPGS_STATE_OPTIMIZED; | 829 | h->state = TPGS_STATE_OPTIMIZED; |
| 841 | h->group_id = -1; | 830 | h->group_id = -1; |
| @@ -848,11 +837,11 @@ static struct scsi_dh_data *alua_bus_attach(struct scsi_device *sdev) | |||
| 848 | if (err != SCSI_DH_OK && err != SCSI_DH_DEV_OFFLINED) | 837 | if (err != SCSI_DH_OK && err != SCSI_DH_DEV_OFFLINED) |
| 849 | goto failed; | 838 | goto failed; |
| 850 | 839 | ||
| 851 | sdev_printk(KERN_NOTICE, sdev, "%s: Attached\n", ALUA_DH_NAME); | 840 | sdev->handler_data = h; |
| 852 | return &h->dh_data; | 841 | return 0; |
| 853 | failed: | 842 | failed: |
| 854 | kfree(h); | 843 | kfree(h); |
| 855 | return ERR_PTR(-EINVAL); | 844 | return -EINVAL; |
| 856 | } | 845 | } |
| 857 | 846 | ||
| 858 | /* | 847 | /* |
| @@ -861,10 +850,11 @@ failed: | |||
| 861 | */ | 850 | */ |
| 862 | static void alua_bus_detach(struct scsi_device *sdev) | 851 | static void alua_bus_detach(struct scsi_device *sdev) |
| 863 | { | 852 | { |
| 864 | struct alua_dh_data *h = get_alua_data(sdev); | 853 | struct alua_dh_data *h = sdev->handler_data; |
| 865 | 854 | ||
| 866 | if (h->buff && h->inq != h->buff) | 855 | if (h->buff && h->inq != h->buff) |
| 867 | kfree(h->buff); | 856 | kfree(h->buff); |
| 857 | sdev->handler_data = NULL; | ||
| 868 | kfree(h); | 858 | kfree(h); |
| 869 | } | 859 | } |
| 870 | 860 | ||
| @@ -877,7 +867,6 @@ static struct scsi_device_handler alua_dh = { | |||
| 877 | .check_sense = alua_check_sense, | 867 | .check_sense = alua_check_sense, |
| 878 | .activate = alua_activate, | 868 | .activate = alua_activate, |
| 879 | .set_params = alua_set_params, | 869 | .set_params = alua_set_params, |
| 880 | .match = alua_match, | ||
| 881 | }; | 870 | }; |
| 882 | 871 | ||
| 883 | static int __init alua_init(void) | 872 | static int __init alua_init(void) |
