hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/target/target_core_pscsi.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*******************************************************************************
23 * Filename: target_core_pscsi.c
34 *
....@@ -6,20 +7,6 @@
67 * (c) Copyright 2003-2013 Datera, Inc.
78 *
89 * 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.
2310 *
2411 ******************************************************************************/
2512
....@@ -179,20 +166,20 @@
179166 static void
180167 pscsi_set_inquiry_info(struct scsi_device *sdev, struct t10_wwn *wwn)
181168 {
182
- unsigned char *buf;
183
-
184169 if (sdev->inquiry_len < INQUIRY_LEN)
185170 return;
186
-
187
- buf = sdev->inquiry;
188
- if (!buf)
189
- return;
190171 /*
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()
192173 */
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);
196183 }
197184
198185 static int
....@@ -812,7 +799,6 @@
812799 struct scsi_device *sd = pdv->pdv_sd;
813800 unsigned char host_id[16];
814801 ssize_t bl;
815
- int i;
816802
817803 if (phv->phv_mode == PHV_VIRTUAL_HOST_ID)
818804 snprintf(host_id, 16, "%d", pdv->pdv_host_id);
....@@ -825,29 +811,12 @@
825811 host_id);
826812
827813 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);
851820 }
852821 return bl;
853822 }
....@@ -1103,16 +1072,16 @@
11031072 break;
11041073 }
11051074
1106
- __blk_put_request(req->q, req);
1075
+ blk_put_request(req);
11071076 kfree(pt);
11081077 }
11091078
11101079 static const struct target_backend_ops pscsi_ops = {
11111080 .name = "pscsi",
11121081 .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,
11161085 .attach_hba = pscsi_attach_hba,
11171086 .detach_hba = pscsi_detach_hba,
11181087 .pmode_enable_hba = pscsi_pmode_enable_hba,