aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aic7xxx/aic79xx_osm.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2008-03-22 23:41:22 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-04-24 10:09:18 -0400
commitbe0d67680d524981dd65c661efe3c9cbd52a684f (patch)
treec9f48421ee7396bcc593c0a0ef8415dd18e1eaba /drivers/scsi/aic7xxx/aic79xx_osm.c
parent93c20a59af4624aedf53f8320606b355aa951bc1 (diff)
[SCSI] aic7xxx, aic79xx: deinline functions
Deinlines and moves big functions from .h to .c files. Adds prototypes for ahc_lookup_scb and ahd_lookup_scb to .h files. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/aic7xxx/aic79xx_osm.c')
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c162
1 files changed, 159 insertions, 3 deletions
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 0081aa357c8b..6c5287722465 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -369,10 +369,166 @@ static void ahd_release_simq(struct ahd_softc *ahd);
369static int ahd_linux_unit; 369static int ahd_linux_unit;
370 370
371 371
372/************************** OS Utility Wrappers *******************************/
373void ahd_delay(long);
374void
375ahd_delay(long usec)
376{
377 /*
378 * udelay on Linux can have problems for
379 * multi-millisecond waits. Wait at most
380 * 1024us per call.
381 */
382 while (usec > 0) {
383 udelay(usec % 1024);
384 usec -= 1024;
385 }
386}
387
388
389/***************************** Low Level I/O **********************************/
390uint8_t ahd_inb(struct ahd_softc * ahd, long port);
391uint16_t ahd_inw_atomic(struct ahd_softc * ahd, long port);
392void ahd_outb(struct ahd_softc * ahd, long port, uint8_t val);
393void ahd_outw_atomic(struct ahd_softc * ahd,
394 long port, uint16_t val);
395void ahd_outsb(struct ahd_softc * ahd, long port,
396 uint8_t *, int count);
397void ahd_insb(struct ahd_softc * ahd, long port,
398 uint8_t *, int count);
399
400uint8_t
401ahd_inb(struct ahd_softc * ahd, long port)
402{
403 uint8_t x;
404
405 if (ahd->tags[0] == BUS_SPACE_MEMIO) {
406 x = readb(ahd->bshs[0].maddr + port);
407 } else {
408 x = inb(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
409 }
410 mb();
411 return (x);
412}
413
414uint16_t
415ahd_inw_atomic(struct ahd_softc * ahd, long port)
416{
417 uint8_t x;
418
419 if (ahd->tags[0] == BUS_SPACE_MEMIO) {
420 x = readw(ahd->bshs[0].maddr + port);
421 } else {
422 x = inw(ahd->bshs[(port) >> 8].ioport + ((port) & 0xFF));
423 }
424 mb();
425 return (x);
426}
427
428void
429ahd_outb(struct ahd_softc * ahd, long port, uint8_t val)
430{
431 if (ahd->tags[0] == BUS_SPACE_MEMIO) {
432 writeb(val, ahd->bshs[0].maddr + port);
433 } else {
434 outb(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
435 }
436 mb();
437}
438
439void
440ahd_outw_atomic(struct ahd_softc * ahd, long port, uint16_t val)
441{
442 if (ahd->tags[0] == BUS_SPACE_MEMIO) {
443 writew(val, ahd->bshs[0].maddr + port);
444 } else {
445 outw(val, ahd->bshs[(port) >> 8].ioport + (port & 0xFF));
446 }
447 mb();
448}
449
450void
451ahd_outsb(struct ahd_softc * ahd, long port, uint8_t *array, int count)
452{
453 int i;
454
455 /*
456 * There is probably a more efficient way to do this on Linux
457 * but we don't use this for anything speed critical and this
458 * should work.
459 */
460 for (i = 0; i < count; i++)
461 ahd_outb(ahd, port, *array++);
462}
463
464void
465ahd_insb(struct ahd_softc * ahd, long port, uint8_t *array, int count)
466{
467 int i;
468
469 /*
470 * There is probably a more efficient way to do this on Linux
471 * but we don't use this for anything speed critical and this
472 * should work.
473 */
474 for (i = 0; i < count; i++)
475 *array++ = ahd_inb(ahd, port);
476}
477
478/******************************* PCI Routines *********************************/
479uint32_t
480ahd_pci_read_config(ahd_dev_softc_t pci, int reg, int width)
481{
482 switch (width) {
483 case 1:
484 {
485 uint8_t retval;
486
487 pci_read_config_byte(pci, reg, &retval);
488 return (retval);
489 }
490 case 2:
491 {
492 uint16_t retval;
493 pci_read_config_word(pci, reg, &retval);
494 return (retval);
495 }
496 case 4:
497 {
498 uint32_t retval;
499 pci_read_config_dword(pci, reg, &retval);
500 return (retval);
501 }
502 default:
503 panic("ahd_pci_read_config: Read size too big");
504 /* NOTREACHED */
505 return (0);
506 }
507}
508
509void
510ahd_pci_write_config(ahd_dev_softc_t pci, int reg, uint32_t value, int width)
511{
512 switch (width) {
513 case 1:
514 pci_write_config_byte(pci, reg, value);
515 break;
516 case 2:
517 pci_write_config_word(pci, reg, value);
518 break;
519 case 4:
520 pci_write_config_dword(pci, reg, value);
521 break;
522 default:
523 panic("ahd_pci_write_config: Write size too big");
524 /* NOTREACHED */
525 }
526}
527
372/****************************** Inlines ***************************************/ 528/****************************** Inlines ***************************************/
373static __inline void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*); 529static void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*);
374 530
375static __inline void 531static void
376ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) 532ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb)
377{ 533{
378 struct scsi_cmnd *cmd; 534 struct scsi_cmnd *cmd;
@@ -432,7 +588,7 @@ ahd_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
432 return rtn; 588 return rtn;
433} 589}
434 590
435static inline struct scsi_target ** 591static struct scsi_target **
436ahd_linux_target_in_softc(struct scsi_target *starget) 592ahd_linux_target_in_softc(struct scsi_target *starget)
437{ 593{
438 struct ahd_softc *ahd = 594 struct ahd_softc *ahd =