| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /******************************************************************************* |
|---|
| 2 | 3 | * Filename: target_core_pscsi.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * (c) Copyright 2003-2013 Datera, Inc. |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * Nicholas A. Bellinger <nab@kernel.org> |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 12 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | | - * (at your option) any later version. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | | - * GNU General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program; if not, write to the Free Software |
|---|
| 22 | | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 23 | 10 | * |
|---|
| 24 | 11 | ******************************************************************************/ |
|---|
| 25 | 12 | |
|---|
| .. | .. |
|---|
| 179 | 166 | static void |
|---|
| 180 | 167 | pscsi_set_inquiry_info(struct scsi_device *sdev, struct t10_wwn *wwn) |
|---|
| 181 | 168 | { |
|---|
| 182 | | - unsigned char *buf; |
|---|
| 183 | | - |
|---|
| 184 | 169 | if (sdev->inquiry_len < INQUIRY_LEN) |
|---|
| 185 | 170 | return; |
|---|
| 186 | | - |
|---|
| 187 | | - buf = sdev->inquiry; |
|---|
| 188 | | - if (!buf) |
|---|
| 189 | | - return; |
|---|
| 190 | 171 | /* |
|---|
| 191 | | - * Use sdev->inquiry from drivers/scsi/scsi_scan.c:scsi_alloc_sdev() |
|---|
| 172 | + * Use sdev->inquiry data from drivers/scsi/scsi_scan.c:scsi_add_lun() |
|---|
| 192 | 173 | */ |
|---|
| 193 | | - memcpy(&wwn->vendor[0], &buf[8], sizeof(wwn->vendor)); |
|---|
| 194 | | - memcpy(&wwn->model[0], &buf[16], sizeof(wwn->model)); |
|---|
| 195 | | - memcpy(&wwn->revision[0], &buf[32], sizeof(wwn->revision)); |
|---|
| 174 | + BUILD_BUG_ON(sizeof(wwn->vendor) != INQUIRY_VENDOR_LEN + 1); |
|---|
| 175 | + snprintf(wwn->vendor, sizeof(wwn->vendor), |
|---|
| 176 | + "%." __stringify(INQUIRY_VENDOR_LEN) "s", sdev->vendor); |
|---|
| 177 | + BUILD_BUG_ON(sizeof(wwn->model) != INQUIRY_MODEL_LEN + 1); |
|---|
| 178 | + snprintf(wwn->model, sizeof(wwn->model), |
|---|
| 179 | + "%." __stringify(INQUIRY_MODEL_LEN) "s", sdev->model); |
|---|
| 180 | + BUILD_BUG_ON(sizeof(wwn->revision) != INQUIRY_REVISION_LEN + 1); |
|---|
| 181 | + snprintf(wwn->revision, sizeof(wwn->revision), |
|---|
| 182 | + "%." __stringify(INQUIRY_REVISION_LEN) "s", sdev->rev); |
|---|
| 196 | 183 | } |
|---|
| 197 | 184 | |
|---|
| 198 | 185 | static int |
|---|
| .. | .. |
|---|
| 812 | 799 | struct scsi_device *sd = pdv->pdv_sd; |
|---|
| 813 | 800 | unsigned char host_id[16]; |
|---|
| 814 | 801 | ssize_t bl; |
|---|
| 815 | | - int i; |
|---|
| 816 | 802 | |
|---|
| 817 | 803 | if (phv->phv_mode == PHV_VIRTUAL_HOST_ID) |
|---|
| 818 | 804 | snprintf(host_id, 16, "%d", pdv->pdv_host_id); |
|---|
| .. | .. |
|---|
| 825 | 811 | host_id); |
|---|
| 826 | 812 | |
|---|
| 827 | 813 | if (sd) { |
|---|
| 828 | | - bl += sprintf(b + bl, " "); |
|---|
| 829 | | - bl += sprintf(b + bl, "Vendor: "); |
|---|
| 830 | | - for (i = 0; i < 8; i++) { |
|---|
| 831 | | - if (ISPRINT(sd->vendor[i])) /* printable character? */ |
|---|
| 832 | | - bl += sprintf(b + bl, "%c", sd->vendor[i]); |
|---|
| 833 | | - else |
|---|
| 834 | | - bl += sprintf(b + bl, " "); |
|---|
| 835 | | - } |
|---|
| 836 | | - bl += sprintf(b + bl, " Model: "); |
|---|
| 837 | | - for (i = 0; i < 16; i++) { |
|---|
| 838 | | - if (ISPRINT(sd->model[i])) /* printable character ? */ |
|---|
| 839 | | - bl += sprintf(b + bl, "%c", sd->model[i]); |
|---|
| 840 | | - else |
|---|
| 841 | | - bl += sprintf(b + bl, " "); |
|---|
| 842 | | - } |
|---|
| 843 | | - bl += sprintf(b + bl, " Rev: "); |
|---|
| 844 | | - for (i = 0; i < 4; i++) { |
|---|
| 845 | | - if (ISPRINT(sd->rev[i])) /* printable character ? */ |
|---|
| 846 | | - bl += sprintf(b + bl, "%c", sd->rev[i]); |
|---|
| 847 | | - else |
|---|
| 848 | | - bl += sprintf(b + bl, " "); |
|---|
| 849 | | - } |
|---|
| 850 | | - bl += sprintf(b + bl, "\n"); |
|---|
| 814 | + bl += sprintf(b + bl, " Vendor: %." |
|---|
| 815 | + __stringify(INQUIRY_VENDOR_LEN) "s", sd->vendor); |
|---|
| 816 | + bl += sprintf(b + bl, " Model: %." |
|---|
| 817 | + __stringify(INQUIRY_MODEL_LEN) "s", sd->model); |
|---|
| 818 | + bl += sprintf(b + bl, " Rev: %." |
|---|
| 819 | + __stringify(INQUIRY_REVISION_LEN) "s\n", sd->rev); |
|---|
| 851 | 820 | } |
|---|
| 852 | 821 | return bl; |
|---|
| 853 | 822 | } |
|---|
| .. | .. |
|---|
| 1103 | 1072 | break; |
|---|
| 1104 | 1073 | } |
|---|
| 1105 | 1074 | |
|---|
| 1106 | | - __blk_put_request(req->q, req); |
|---|
| 1075 | + blk_put_request(req); |
|---|
| 1107 | 1076 | kfree(pt); |
|---|
| 1108 | 1077 | } |
|---|
| 1109 | 1078 | |
|---|
| 1110 | 1079 | static const struct target_backend_ops pscsi_ops = { |
|---|
| 1111 | 1080 | .name = "pscsi", |
|---|
| 1112 | 1081 | .owner = THIS_MODULE, |
|---|
| 1113 | | - .transport_flags = TRANSPORT_FLAG_PASSTHROUGH | |
|---|
| 1114 | | - TRANSPORT_FLAG_PASSTHROUGH_ALUA | |
|---|
| 1115 | | - TRANSPORT_FLAG_PASSTHROUGH_PGR, |
|---|
| 1082 | + .transport_flags_default = TRANSPORT_FLAG_PASSTHROUGH | |
|---|
| 1083 | + TRANSPORT_FLAG_PASSTHROUGH_ALUA | |
|---|
| 1084 | + TRANSPORT_FLAG_PASSTHROUGH_PGR, |
|---|
| 1116 | 1085 | .attach_hba = pscsi_attach_hba, |
|---|
| 1117 | 1086 | .detach_hba = pscsi_detach_hba, |
|---|
| 1118 | 1087 | .pmode_enable_hba = pscsi_pmode_enable_hba, |
|---|