diff options
Diffstat (limited to 'drivers/scsi/osd/osd_initiator.c')
-rw-r--r-- | drivers/scsi/osd/osd_initiator.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c index 7a117c18114c..60b7ca1e9bc0 100644 --- a/drivers/scsi/osd/osd_initiator.c +++ b/drivers/scsi/osd/osd_initiator.c | |||
@@ -73,7 +73,8 @@ static const char *_osd_ver_desc(struct osd_request *or) | |||
73 | 73 | ||
74 | #define ATTR_DEF_RI(id, len) ATTR_DEF(OSD_APAGE_ROOT_INFORMATION, id, len) | 74 | #define ATTR_DEF_RI(id, len) ATTR_DEF(OSD_APAGE_ROOT_INFORMATION, id, len) |
75 | 75 | ||
76 | static int _osd_print_system_info(struct osd_dev *od, void *caps) | 76 | static int _osd_get_print_system_info(struct osd_dev *od, |
77 | void *caps, struct osd_dev_info *odi) | ||
77 | { | 78 | { |
78 | struct osd_request *or; | 79 | struct osd_request *or; |
79 | struct osd_attr get_attrs[] = { | 80 | struct osd_attr get_attrs[] = { |
@@ -137,8 +138,12 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps) | |||
137 | OSD_INFO("PRODUCT_SERIAL_NUMBER [%s]\n", | 138 | OSD_INFO("PRODUCT_SERIAL_NUMBER [%s]\n", |
138 | (char *)pFirst); | 139 | (char *)pFirst); |
139 | 140 | ||
140 | pFirst = get_attrs[a].val_ptr; | 141 | odi->osdname_len = get_attrs[a].len; |
141 | OSD_INFO("OSD_NAME [%s]\n", (char *)pFirst); | 142 | /* Avoid NULL for memcmp optimization 0-length is good enough */ |
143 | odi->osdname = kzalloc(odi->osdname_len + 1, GFP_KERNEL); | ||
144 | if (odi->osdname_len) | ||
145 | memcpy(odi->osdname, get_attrs[a].val_ptr, odi->osdname_len); | ||
146 | OSD_INFO("OSD_NAME [%s]\n", odi->osdname); | ||
142 | a++; | 147 | a++; |
143 | 148 | ||
144 | pFirst = get_attrs[a++].val_ptr; | 149 | pFirst = get_attrs[a++].val_ptr; |
@@ -171,6 +176,14 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps) | |||
171 | sid_dump, sizeof(sid_dump), true); | 176 | sid_dump, sizeof(sid_dump), true); |
172 | OSD_INFO("OSD_SYSTEM_ID(%d)\n" | 177 | OSD_INFO("OSD_SYSTEM_ID(%d)\n" |
173 | " [%s]\n", len, sid_dump); | 178 | " [%s]\n", len, sid_dump); |
179 | |||
180 | if (unlikely(len > sizeof(odi->systemid))) { | ||
181 | OSD_ERR("OSD Target error: OSD_SYSTEM_ID too long(%d). " | ||
182 | "device idetification might not work\n", len); | ||
183 | len = sizeof(odi->systemid); | ||
184 | } | ||
185 | odi->systemid_len = len; | ||
186 | memcpy(odi->systemid, get_attrs[a].val_ptr, len); | ||
174 | a++; | 187 | a++; |
175 | } | 188 | } |
176 | out: | 189 | out: |
@@ -178,16 +191,17 @@ out: | |||
178 | return ret; | 191 | return ret; |
179 | } | 192 | } |
180 | 193 | ||
181 | int osd_auto_detect_ver(struct osd_dev *od, void *caps) | 194 | int osd_auto_detect_ver(struct osd_dev *od, |
195 | void *caps, struct osd_dev_info *odi) | ||
182 | { | 196 | { |
183 | int ret; | 197 | int ret; |
184 | 198 | ||
185 | /* Auto-detect the osd version */ | 199 | /* Auto-detect the osd version */ |
186 | ret = _osd_print_system_info(od, caps); | 200 | ret = _osd_get_print_system_info(od, caps, odi); |
187 | if (ret) { | 201 | if (ret) { |
188 | osd_dev_set_ver(od, OSD_VER1); | 202 | osd_dev_set_ver(od, OSD_VER1); |
189 | OSD_DEBUG("converting to OSD1\n"); | 203 | OSD_DEBUG("converting to OSD1\n"); |
190 | ret = _osd_print_system_info(od, caps); | 204 | ret = _osd_get_print_system_info(od, caps, odi); |
191 | } | 205 | } |
192 | 206 | ||
193 | return ret; | 207 | return ret; |