aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hpsa.c
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2011-03-09 18:00:01 -0500
committerJames Bottomley <James.Bottomley@suse.de>2011-03-14 19:40:20 -0400
commit3f5eac3a040a2ea61a575f713aabedecdd23c3f8 (patch)
treeac421baa47d2bf8c569fb054c39e0cf70586785b /drivers/scsi/hpsa.c
parent5b94e23292dec213e5bb0240894b597d93744e2a (diff)
[SCSI] hpsa: move device attributes to avoid forward declarations
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/hpsa.c')
-rw-r--r--drivers/scsi/hpsa.c253
1 files changed, 120 insertions, 133 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 09a529e34452..dcabef4bb149 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -155,21 +155,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd);
155static int hpsa_slave_alloc(struct scsi_device *sdev); 155static int hpsa_slave_alloc(struct scsi_device *sdev);
156static void hpsa_slave_destroy(struct scsi_device *sdev); 156static void hpsa_slave_destroy(struct scsi_device *sdev);
157 157
158static ssize_t raid_level_show(struct device *dev,
159 struct device_attribute *attr, char *buf);
160static ssize_t lunid_show(struct device *dev,
161 struct device_attribute *attr, char *buf);
162static ssize_t unique_id_show(struct device *dev,
163 struct device_attribute *attr, char *buf);
164static ssize_t host_show_firmware_revision(struct device *dev,
165 struct device_attribute *attr, char *buf);
166static ssize_t host_show_commands_outstanding(struct device *dev,
167 struct device_attribute *attr, char *buf);
168static ssize_t host_show_transport_mode(struct device *dev,
169 struct device_attribute *attr, char *buf);
170static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno); 158static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno);
171static ssize_t host_store_rescan(struct device *dev,
172 struct device_attribute *attr, const char *buf, size_t count);
173static int check_for_unit_attention(struct ctlr_info *h, 159static int check_for_unit_attention(struct ctlr_info *h,
174 struct CommandList *c); 160 struct CommandList *c);
175static void check_ioctl_unit_attention(struct ctlr_info *h, 161static void check_ioctl_unit_attention(struct ctlr_info *h,
@@ -190,53 +176,6 @@ static int __devinit hpsa_wait_for_board_state(struct pci_dev *pdev,
190#define BOARD_NOT_READY 0 176#define BOARD_NOT_READY 0
191#define BOARD_READY 1 177#define BOARD_READY 1
192 178
193static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
194static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL);
195static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL);
196static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
197static DEVICE_ATTR(firmware_revision, S_IRUGO,
198 host_show_firmware_revision, NULL);
199static DEVICE_ATTR(commands_outstanding, S_IRUGO,
200 host_show_commands_outstanding, NULL);
201static DEVICE_ATTR(transport_mode, S_IRUGO,
202 host_show_transport_mode, NULL);
203
204static struct device_attribute *hpsa_sdev_attrs[] = {
205 &dev_attr_raid_level,
206 &dev_attr_lunid,
207 &dev_attr_unique_id,
208 NULL,
209};
210
211static struct device_attribute *hpsa_shost_attrs[] = {
212 &dev_attr_rescan,
213 &dev_attr_firmware_revision,
214 &dev_attr_commands_outstanding,
215 &dev_attr_transport_mode,
216 NULL,
217};
218
219static struct scsi_host_template hpsa_driver_template = {
220 .module = THIS_MODULE,
221 .name = "hpsa",
222 .proc_name = "hpsa",
223 .queuecommand = hpsa_scsi_queue_command,
224 .scan_start = hpsa_scan_start,
225 .scan_finished = hpsa_scan_finished,
226 .change_queue_depth = hpsa_change_queue_depth,
227 .this_id = -1,
228 .use_clustering = ENABLE_CLUSTERING,
229 .eh_device_reset_handler = hpsa_eh_device_reset_handler,
230 .ioctl = hpsa_ioctl,
231 .slave_alloc = hpsa_slave_alloc,
232 .slave_destroy = hpsa_slave_destroy,
233#ifdef CONFIG_COMPAT
234 .compat_ioctl = hpsa_compat_ioctl,
235#endif
236 .sdev_attrs = hpsa_sdev_attrs,
237 .shost_attrs = hpsa_shost_attrs,
238};
239
240static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev) 179static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
241{ 180{
242 unsigned long *priv = shost_priv(sdev->host); 181 unsigned long *priv = shost_priv(sdev->host);
@@ -334,83 +273,11 @@ static ssize_t host_show_transport_mode(struct device *dev,
334 "performant" : "simple"); 273 "performant" : "simple");
335} 274}
336 275
337/* Enqueuing and dequeuing functions for cmdlists. */
338static inline void addQ(struct list_head *list, struct CommandList *c)
339{
340 list_add_tail(&c->list, list);
341}
342
343static inline u32 next_command(struct ctlr_info *h)
344{
345 u32 a;
346
347 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
348 return h->access.command_completed(h);
349
350 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
351 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
352 (h->reply_pool_head)++;
353 h->commands_outstanding--;
354 } else {
355 a = FIFO_EMPTY;
356 }
357 /* Check for wraparound */
358 if (h->reply_pool_head == (h->reply_pool + h->max_commands)) {
359 h->reply_pool_head = h->reply_pool;
360 h->reply_pool_wraparound ^= 1;
361 }
362 return a;
363}
364
365/* set_performant_mode: Modify the tag for cciss performant
366 * set bit 0 for pull model, bits 3-1 for block fetch
367 * register number
368 */
369static void set_performant_mode(struct ctlr_info *h, struct CommandList *c)
370{
371 if (likely(h->transMethod & CFGTBL_Trans_Performant))
372 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1);
373}
374
375static void enqueue_cmd_and_start_io(struct ctlr_info *h,
376 struct CommandList *c)
377{
378 unsigned long flags;
379
380 set_performant_mode(h, c);
381 spin_lock_irqsave(&h->lock, flags);
382 addQ(&h->reqQ, c);
383 h->Qdepth++;
384 start_io(h);
385 spin_unlock_irqrestore(&h->lock, flags);
386}
387
388static inline void removeQ(struct CommandList *c)
389{
390 if (WARN_ON(list_empty(&c->list)))
391 return;
392 list_del_init(&c->list);
393}
394
395static inline int is_hba_lunid(unsigned char scsi3addr[])
396{
397 return memcmp(scsi3addr, RAID_CTLR_LUNID, 8) == 0;
398}
399
400static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[]) 276static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
401{ 277{
402 return (scsi3addr[3] & 0xC0) == 0x40; 278 return (scsi3addr[3] & 0xC0) == 0x40;
403} 279}
404 280
405static inline int is_scsi_rev_5(struct ctlr_info *h)
406{
407 if (!h->hba_inquiry_data)
408 return 0;
409 if ((h->hba_inquiry_data[2] & 0x07) == 5)
410 return 1;
411 return 0;
412}
413
414static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", 281static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG",
415 "UNKNOWN" 282 "UNKNOWN"
416}; 283};
@@ -502,6 +369,126 @@ static ssize_t unique_id_show(struct device *dev,
502 sn[12], sn[13], sn[14], sn[15]); 369 sn[12], sn[13], sn[14], sn[15]);
503} 370}
504 371
372static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
373static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL);
374static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL);
375static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
376static DEVICE_ATTR(firmware_revision, S_IRUGO,
377 host_show_firmware_revision, NULL);
378static DEVICE_ATTR(commands_outstanding, S_IRUGO,
379 host_show_commands_outstanding, NULL);
380static DEVICE_ATTR(transport_mode, S_IRUGO,
381 host_show_transport_mode, NULL);
382
383static struct device_attribute *hpsa_sdev_attrs[] = {
384 &dev_attr_raid_level,
385 &dev_attr_lunid,
386 &dev_attr_unique_id,
387 NULL,
388};
389
390static struct device_attribute *hpsa_shost_attrs[] = {
391 &dev_attr_rescan,
392 &dev_attr_firmware_revision,
393 &dev_attr_commands_outstanding,
394 &dev_attr_transport_mode,
395 NULL,
396};
397
398static struct scsi_host_template hpsa_driver_template = {
399 .module = THIS_MODULE,
400 .name = "hpsa",
401 .proc_name = "hpsa",
402 .queuecommand = hpsa_scsi_queue_command,
403 .scan_start = hpsa_scan_start,
404 .scan_finished = hpsa_scan_finished,
405 .change_queue_depth = hpsa_change_queue_depth,
406 .this_id = -1,
407 .use_clustering = ENABLE_CLUSTERING,
408 .eh_device_reset_handler = hpsa_eh_device_reset_handler,
409 .ioctl = hpsa_ioctl,
410 .slave_alloc = hpsa_slave_alloc,
411 .slave_destroy = hpsa_slave_destroy,
412#ifdef CONFIG_COMPAT
413 .compat_ioctl = hpsa_compat_ioctl,
414#endif
415 .sdev_attrs = hpsa_sdev_attrs,
416 .shost_attrs = hpsa_shost_attrs,
417};
418
419
420/* Enqueuing and dequeuing functions for cmdlists. */
421static inline void addQ(struct list_head *list, struct CommandList *c)
422{
423 list_add_tail(&c->list, list);
424}
425
426static inline u32 next_command(struct ctlr_info *h)
427{
428 u32 a;
429
430 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
431 return h->access.command_completed(h);
432
433 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
434 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
435 (h->reply_pool_head)++;
436 h->commands_outstanding--;
437 } else {
438 a = FIFO_EMPTY;
439 }
440 /* Check for wraparound */
441 if (h->reply_pool_head == (h->reply_pool + h->max_commands)) {
442 h->reply_pool_head = h->reply_pool;
443 h->reply_pool_wraparound ^= 1;
444 }
445 return a;
446}
447
448/* set_performant_mode: Modify the tag for cciss performant
449 * set bit 0 for pull model, bits 3-1 for block fetch
450 * register number
451 */
452static void set_performant_mode(struct ctlr_info *h, struct CommandList *c)
453{
454 if (likely(h->transMethod & CFGTBL_Trans_Performant))
455 c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1);
456}
457
458static void enqueue_cmd_and_start_io(struct ctlr_info *h,
459 struct CommandList *c)
460{
461 unsigned long flags;
462
463 set_performant_mode(h, c);
464 spin_lock_irqsave(&h->lock, flags);
465 addQ(&h->reqQ, c);
466 h->Qdepth++;
467 start_io(h);
468 spin_unlock_irqrestore(&h->lock, flags);
469}
470
471static inline void removeQ(struct CommandList *c)
472{
473 if (WARN_ON(list_empty(&c->list)))
474 return;
475 list_del_init(&c->list);
476}
477
478static inline int is_hba_lunid(unsigned char scsi3addr[])
479{
480 return memcmp(scsi3addr, RAID_CTLR_LUNID, 8) == 0;
481}
482
483static inline int is_scsi_rev_5(struct ctlr_info *h)
484{
485 if (!h->hba_inquiry_data)
486 return 0;
487 if ((h->hba_inquiry_data[2] & 0x07) == 5)
488 return 1;
489 return 0;
490}
491
505static int hpsa_find_target_lun(struct ctlr_info *h, 492static int hpsa_find_target_lun(struct ctlr_info *h,
506 unsigned char scsi3addr[], int bus, int *target, int *lun) 493 unsigned char scsi3addr[], int bus, int *target, int *lun)
507{ 494{