aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2017-08-15 04:21:43 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2017-08-24 22:28:59 -0400
commitdc56ce12d50c0adc1243bd3d080133bc6b63f403 (patch)
treed54b518c84cfb34ac21f629243446d3ed503f872
parent81b59d7565b8703dfdf738e81e6dc0a417818000 (diff)
scsi: ses: make page2 support optional
Simple subenclosures do not need to support SES page 2, so make it optional. Signed-off-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/ses.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index c863c271c781..a3f935008cc1 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -51,6 +51,13 @@ struct ses_component {
51 u64 addr; 51 u64 addr;
52}; 52};
53 53
54static bool ses_page2_supported(struct enclosure_device *edev)
55{
56 struct ses_device *ses_dev = edev->scratch;
57
58 return (ses_dev->page2 != NULL);
59}
60
54static int ses_probe(struct device *dev) 61static int ses_probe(struct device *dev)
55{ 62{
56 struct scsi_device *sdev = to_scsi_device(dev); 63 struct scsi_device *sdev = to_scsi_device(dev);
@@ -204,6 +211,10 @@ static void ses_get_fault(struct enclosure_device *edev,
204{ 211{
205 unsigned char *desc; 212 unsigned char *desc;
206 213
214 if (!ses_page2_supported(edev)) {
215 ecomp->fault = 0;
216 return;
217 }
207 desc = ses_get_page2_descriptor(edev, ecomp); 218 desc = ses_get_page2_descriptor(edev, ecomp);
208 if (desc) 219 if (desc)
209 ecomp->fault = (desc[3] & 0x60) >> 4; 220 ecomp->fault = (desc[3] & 0x60) >> 4;
@@ -216,6 +227,9 @@ static int ses_set_fault(struct enclosure_device *edev,
216 unsigned char desc[4]; 227 unsigned char desc[4];
217 unsigned char *desc_ptr; 228 unsigned char *desc_ptr;
218 229
230 if (!ses_page2_supported(edev))
231 return -EINVAL;
232
219 desc_ptr = ses_get_page2_descriptor(edev, ecomp); 233 desc_ptr = ses_get_page2_descriptor(edev, ecomp);
220 234
221 if (!desc_ptr) 235 if (!desc_ptr)
@@ -243,6 +257,10 @@ static void ses_get_status(struct enclosure_device *edev,
243{ 257{
244 unsigned char *desc; 258 unsigned char *desc;
245 259
260 if (!ses_page2_supported(edev)) {
261 ecomp->status = 0;
262 return;
263 }
246 desc = ses_get_page2_descriptor(edev, ecomp); 264 desc = ses_get_page2_descriptor(edev, ecomp);
247 if (desc) 265 if (desc)
248 ecomp->status = (desc[0] & 0x0f); 266 ecomp->status = (desc[0] & 0x0f);
@@ -253,6 +271,10 @@ static void ses_get_locate(struct enclosure_device *edev,
253{ 271{
254 unsigned char *desc; 272 unsigned char *desc;
255 273
274 if (!ses_page2_supported(edev)) {
275 ecomp->locate = 0;
276 return;
277 }
256 desc = ses_get_page2_descriptor(edev, ecomp); 278 desc = ses_get_page2_descriptor(edev, ecomp);
257 if (desc) 279 if (desc)
258 ecomp->locate = (desc[2] & 0x02) ? 1 : 0; 280 ecomp->locate = (desc[2] & 0x02) ? 1 : 0;
@@ -265,6 +287,9 @@ static int ses_set_locate(struct enclosure_device *edev,
265 unsigned char desc[4]; 287 unsigned char desc[4];
266 unsigned char *desc_ptr; 288 unsigned char *desc_ptr;
267 289
290 if (!ses_page2_supported(edev))
291 return -EINVAL;
292
268 desc_ptr = ses_get_page2_descriptor(edev, ecomp); 293 desc_ptr = ses_get_page2_descriptor(edev, ecomp);
269 294
270 if (!desc_ptr) 295 if (!desc_ptr)
@@ -293,6 +318,9 @@ static int ses_set_active(struct enclosure_device *edev,
293 unsigned char desc[4]; 318 unsigned char desc[4];
294 unsigned char *desc_ptr; 319 unsigned char *desc_ptr;
295 320
321 if (!ses_page2_supported(edev))
322 return -EINVAL;
323
296 desc_ptr = ses_get_page2_descriptor(edev, ecomp); 324 desc_ptr = ses_get_page2_descriptor(edev, ecomp);
297 325
298 if (!desc_ptr) 326 if (!desc_ptr)
@@ -329,6 +357,11 @@ static void ses_get_power_status(struct enclosure_device *edev,
329{ 357{
330 unsigned char *desc; 358 unsigned char *desc;
331 359
360 if (!ses_page2_supported(edev)) {
361 ecomp->power_status = 0;
362 return;
363 }
364
332 desc = ses_get_page2_descriptor(edev, ecomp); 365 desc = ses_get_page2_descriptor(edev, ecomp);
333 if (desc) 366 if (desc)
334 ecomp->power_status = (desc[3] & 0x10) ? 0 : 1; 367 ecomp->power_status = (desc[3] & 0x10) ? 0 : 1;
@@ -341,6 +374,9 @@ static int ses_set_power_status(struct enclosure_device *edev,
341 unsigned char desc[4]; 374 unsigned char desc[4];
342 unsigned char *desc_ptr; 375 unsigned char *desc_ptr;
343 376
377 if (!ses_page2_supported(edev))
378 return -EINVAL;
379
344 desc_ptr = ses_get_page2_descriptor(edev, ecomp); 380 desc_ptr = ses_get_page2_descriptor(edev, ecomp);
345 381
346 if (!desc_ptr) 382 if (!desc_ptr)
@@ -674,7 +710,7 @@ static int ses_intf_add(struct device *cdev,
674 page = 2; 710 page = 2;
675 result = ses_recv_diag(sdev, page, hdr_buf, INIT_ALLOC_SIZE); 711 result = ses_recv_diag(sdev, page, hdr_buf, INIT_ALLOC_SIZE);
676 if (result) 712 if (result)
677 goto recv_failed; 713 goto page2_not_supported;
678 714
679 len = (hdr_buf[2] << 8) + hdr_buf[3] + 4; 715 len = (hdr_buf[2] << 8) + hdr_buf[3] + 4;
680 buf = kzalloc(len, GFP_KERNEL); 716 buf = kzalloc(len, GFP_KERNEL);
@@ -707,6 +743,7 @@ static int ses_intf_add(struct device *cdev,
707 ses_dev->page10_len = len; 743 ses_dev->page10_len = len;
708 buf = NULL; 744 buf = NULL;
709 } 745 }
746page2_not_supported:
710 scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL); 747 scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL);
711 if (!scomp) 748 if (!scomp)
712 goto err_free; 749 goto err_free;