aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/umem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/umem.c')
-rw-r--r--drivers/block/umem.c240
1 files changed, 83 insertions, 157 deletions
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index 99806f9ee4ce..c24e1bdbad43 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -34,7 +34,7 @@
34 * - set initialised bit then. 34 * - set initialised bit then.
35 */ 35 */
36 36
37//#define DEBUG /* uncomment if you want debugging info (pr_debug) */ 37#undef DEBUG /* #define DEBUG if you want debugging info (pr_debug) */
38#include <linux/fs.h> 38#include <linux/fs.h>
39#include <linux/bio.h> 39#include <linux/bio.h>
40#include <linux/kernel.h> 40#include <linux/kernel.h>
@@ -143,17 +143,12 @@ static struct cardinfo cards[MM_MAXCARDS];
143static struct block_device_operations mm_fops; 143static struct block_device_operations mm_fops;
144static struct timer_list battery_timer; 144static struct timer_list battery_timer;
145 145
146static int num_cards = 0; 146static int num_cards;
147 147
148static struct gendisk *mm_gendisk[MM_MAXCARDS]; 148static struct gendisk *mm_gendisk[MM_MAXCARDS];
149 149
150static void check_batteries(struct cardinfo *card); 150static void check_batteries(struct cardinfo *card);
151 151
152/*
153-----------------------------------------------------------------------------------
154-- get_userbit
155-----------------------------------------------------------------------------------
156*/
157static int get_userbit(struct cardinfo *card, int bit) 152static int get_userbit(struct cardinfo *card, int bit)
158{ 153{
159 unsigned char led; 154 unsigned char led;
@@ -161,11 +156,7 @@ static int get_userbit(struct cardinfo *card, int bit)
161 led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); 156 led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL);
162 return led & bit; 157 return led & bit;
163} 158}
164/* 159
165-----------------------------------------------------------------------------------
166-- set_userbit
167-----------------------------------------------------------------------------------
168*/
169static int set_userbit(struct cardinfo *card, int bit, unsigned char state) 160static int set_userbit(struct cardinfo *card, int bit, unsigned char state)
170{ 161{
171 unsigned char led; 162 unsigned char led;
@@ -179,11 +170,7 @@ static int set_userbit(struct cardinfo *card, int bit, unsigned char state)
179 170
180 return 0; 171 return 0;
181} 172}
182/* 173
183-----------------------------------------------------------------------------------
184-- set_led
185-----------------------------------------------------------------------------------
186*/
187/* 174/*
188 * NOTE: For the power LED, use the LED_POWER_* macros since they differ 175 * NOTE: For the power LED, use the LED_POWER_* macros since they differ
189 */ 176 */
@@ -203,11 +190,6 @@ static void set_led(struct cardinfo *card, int shift, unsigned char state)
203} 190}
204 191
205#ifdef MM_DIAG 192#ifdef MM_DIAG
206/*
207-----------------------------------------------------------------------------------
208-- dump_regs
209-----------------------------------------------------------------------------------
210*/
211static void dump_regs(struct cardinfo *card) 193static void dump_regs(struct cardinfo *card)
212{ 194{
213 unsigned char *p; 195 unsigned char *p;
@@ -224,32 +206,28 @@ static void dump_regs(struct cardinfo *card)
224 } 206 }
225} 207}
226#endif 208#endif
227/* 209
228-----------------------------------------------------------------------------------
229-- dump_dmastat
230-----------------------------------------------------------------------------------
231*/
232static void dump_dmastat(struct cardinfo *card, unsigned int dmastat) 210static void dump_dmastat(struct cardinfo *card, unsigned int dmastat)
233{ 211{
234 dev_printk(KERN_DEBUG, &card->dev->dev, "DMAstat - "); 212 dev_printk(KERN_DEBUG, &card->dev->dev, "DMAstat - ");
235 if (dmastat & DMASCR_ANY_ERR) 213 if (dmastat & DMASCR_ANY_ERR)
236 printk("ANY_ERR "); 214 printk(KERN_CONT "ANY_ERR ");
237 if (dmastat & DMASCR_MBE_ERR) 215 if (dmastat & DMASCR_MBE_ERR)
238 printk("MBE_ERR "); 216 printk(KERN_CONT "MBE_ERR ");
239 if (dmastat & DMASCR_PARITY_ERR_REP) 217 if (dmastat & DMASCR_PARITY_ERR_REP)
240 printk("PARITY_ERR_REP "); 218 printk(KERN_CONT "PARITY_ERR_REP ");
241 if (dmastat & DMASCR_PARITY_ERR_DET) 219 if (dmastat & DMASCR_PARITY_ERR_DET)
242 printk("PARITY_ERR_DET "); 220 printk(KERN_CONT "PARITY_ERR_DET ");
243 if (dmastat & DMASCR_SYSTEM_ERR_SIG) 221 if (dmastat & DMASCR_SYSTEM_ERR_SIG)
244 printk("SYSTEM_ERR_SIG "); 222 printk(KERN_CONT "SYSTEM_ERR_SIG ");
245 if (dmastat & DMASCR_TARGET_ABT) 223 if (dmastat & DMASCR_TARGET_ABT)
246 printk("TARGET_ABT "); 224 printk(KERN_CONT "TARGET_ABT ");
247 if (dmastat & DMASCR_MASTER_ABT) 225 if (dmastat & DMASCR_MASTER_ABT)
248 printk("MASTER_ABT "); 226 printk(KERN_CONT "MASTER_ABT ");
249 if (dmastat & DMASCR_CHAIN_COMPLETE) 227 if (dmastat & DMASCR_CHAIN_COMPLETE)
250 printk("CHAIN_COMPLETE "); 228 printk(KERN_CONT "CHAIN_COMPLETE ");
251 if (dmastat & DMASCR_DMA_COMPLETE) 229 if (dmastat & DMASCR_DMA_COMPLETE)
252 printk("DMA_COMPLETE "); 230 printk(KERN_CONT "DMA_COMPLETE ");
253 printk("\n"); 231 printk("\n");
254} 232}
255 233
@@ -286,7 +264,8 @@ static void mm_start_io(struct cardinfo *card)
286 264
287 /* make the last descriptor end the chain */ 265 /* make the last descriptor end the chain */
288 page = &card->mm_pages[card->Active]; 266 page = &card->mm_pages[card->Active];
289 pr_debug("start_io: %d %d->%d\n", card->Active, page->headcnt, page->cnt-1); 267 pr_debug("start_io: %d %d->%d\n",
268 card->Active, page->headcnt, page->cnt - 1);
290 desc = &page->desc[page->cnt-1]; 269 desc = &page->desc[page->cnt-1];
291 270
292 desc->control_bits |= cpu_to_le32(DMASCR_CHAIN_COMP_EN); 271 desc->control_bits |= cpu_to_le32(DMASCR_CHAIN_COMP_EN);
@@ -310,8 +289,8 @@ static void mm_start_io(struct cardinfo *card)
310 writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR); 289 writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR);
311 writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR + 4); 290 writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR + 4);
312 291
313 offset = ((char*)desc) - ((char*)page->desc); 292 offset = ((char *)desc) - ((char *)page->desc);
314 writel(cpu_to_le32((page->page_dma+offset)&0xffffffff), 293 writel(cpu_to_le32((page->page_dma+offset) & 0xffffffff),
315 card->csr_remap + DMA_DESCRIPTOR_ADDR); 294 card->csr_remap + DMA_DESCRIPTOR_ADDR);
316 /* Force the value to u64 before shifting otherwise >> 32 is undefined C 295 /* Force the value to u64 before shifting otherwise >> 32 is undefined C
317 * and on some ports will do nothing ! */ 296 * and on some ports will do nothing ! */
@@ -352,7 +331,7 @@ static inline void reset_page(struct mm_page *page)
352 page->cnt = 0; 331 page->cnt = 0;
353 page->headcnt = 0; 332 page->headcnt = 0;
354 page->bio = NULL; 333 page->bio = NULL;
355 page->biotail = & page->bio; 334 page->biotail = &page->bio;
356} 335}
357 336
358static void mm_unplug_device(struct request_queue *q) 337static void mm_unplug_device(struct request_queue *q)
@@ -408,7 +387,7 @@ static int add_bio(struct cardinfo *card)
408 vec->bv_page, 387 vec->bv_page,
409 vec->bv_offset, 388 vec->bv_offset,
410 len, 389 len,
411 (rw==READ) ? 390 (rw == READ) ?
412 PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); 391 PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE);
413 392
414 p = &card->mm_pages[card->Ready]; 393 p = &card->mm_pages[card->Ready];
@@ -427,10 +406,10 @@ static int add_bio(struct cardinfo *card)
427 desc->pci_addr = cpu_to_le64((u64)desc->data_dma_handle); 406 desc->pci_addr = cpu_to_le64((u64)desc->data_dma_handle);
428 desc->local_addr = cpu_to_le64(card->current_sector << 9); 407 desc->local_addr = cpu_to_le64(card->current_sector << 9);
429 desc->transfer_size = cpu_to_le32(len); 408 desc->transfer_size = cpu_to_le32(len);
430 offset = ( ((char*)&desc->sem_control_bits) - ((char*)p->desc)); 409 offset = (((char *)&desc->sem_control_bits) - ((char *)p->desc));
431 desc->sem_addr = cpu_to_le64((u64)(p->page_dma+offset)); 410 desc->sem_addr = cpu_to_le64((u64)(p->page_dma+offset));
432 desc->zero1 = desc->zero2 = 0; 411 desc->zero1 = desc->zero2 = 0;
433 offset = ( ((char*)(desc+1)) - ((char*)p->desc)); 412 offset = (((char *)(desc+1)) - ((char *)p->desc));
434 desc->next_desc_addr = cpu_to_le64(p->page_dma+offset); 413 desc->next_desc_addr = cpu_to_le64(p->page_dma+offset);
435 desc->control_bits = cpu_to_le32(DMASCR_GO|DMASCR_ERR_INT_EN| 414 desc->control_bits = cpu_to_le32(DMASCR_GO|DMASCR_ERR_INT_EN|
436 DMASCR_PARITY_INT_EN| 415 DMASCR_PARITY_INT_EN|
@@ -455,11 +434,11 @@ static void process_page(unsigned long data)
455 /* check if any of the requests in the page are DMA_COMPLETE, 434 /* check if any of the requests in the page are DMA_COMPLETE,
456 * and deal with them appropriately. 435 * and deal with them appropriately.
457 * If we find a descriptor without DMA_COMPLETE in the semaphore, then 436 * If we find a descriptor without DMA_COMPLETE in the semaphore, then
458 * dma must have hit an error on that descriptor, so use dma_status instead 437 * dma must have hit an error on that descriptor, so use dma_status
459 * and assume that all following descriptors must be re-tried. 438 * instead and assume that all following descriptors must be re-tried.
460 */ 439 */
461 struct mm_page *page; 440 struct mm_page *page;
462 struct bio *return_bio=NULL; 441 struct bio *return_bio = NULL;
463 struct cardinfo *card = (struct cardinfo *)data; 442 struct cardinfo *card = (struct cardinfo *)data;
464 unsigned int dma_status = card->dma_status; 443 unsigned int dma_status = card->dma_status;
465 444
@@ -472,24 +451,25 @@ static void process_page(unsigned long data)
472 struct bio *bio = page->bio; 451 struct bio *bio = page->bio;
473 struct mm_dma_desc *desc = &page->desc[page->headcnt]; 452 struct mm_dma_desc *desc = &page->desc[page->headcnt];
474 int control = le32_to_cpu(desc->sem_control_bits); 453 int control = le32_to_cpu(desc->sem_control_bits);
475 int last=0; 454 int last = 0;
476 int idx; 455 int idx;
477 456
478 if (!(control & DMASCR_DMA_COMPLETE)) { 457 if (!(control & DMASCR_DMA_COMPLETE)) {
479 control = dma_status; 458 control = dma_status;
480 last=1; 459 last = 1;
481 } 460 }
482 page->headcnt++; 461 page->headcnt++;
483 idx = page->idx; 462 idx = page->idx;
484 page->idx++; 463 page->idx++;
485 if (page->idx >= bio->bi_vcnt) { 464 if (page->idx >= bio->bi_vcnt) {
486 page->bio = bio->bi_next; 465 page->bio = bio->bi_next;
487 page->idx = page->bio->bi_idx; 466 if (page->bio)
467 page->idx = page->bio->bi_idx;
488 } 468 }
489 469
490 pci_unmap_page(card->dev, desc->data_dma_handle, 470 pci_unmap_page(card->dev, desc->data_dma_handle,
491 bio_iovec_idx(bio,idx)->bv_len, 471 bio_iovec_idx(bio, idx)->bv_len,
492 (control& DMASCR_TRANSFER_READ) ? 472 (control & DMASCR_TRANSFER_READ) ?
493 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); 473 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
494 if (control & DMASCR_HARD_ERROR) { 474 if (control & DMASCR_HARD_ERROR) {
495 /* error */ 475 /* error */
@@ -500,9 +480,10 @@ static void process_page(unsigned long data)
500 le32_to_cpu(desc->transfer_size)); 480 le32_to_cpu(desc->transfer_size));
501 dump_dmastat(card, control); 481 dump_dmastat(card, control);
502 } else if (test_bit(BIO_RW, &bio->bi_rw) && 482 } else if (test_bit(BIO_RW, &bio->bi_rw) &&
503 le32_to_cpu(desc->local_addr)>>9 == card->init_size) { 483 le32_to_cpu(desc->local_addr) >> 9 ==
504 card->init_size += le32_to_cpu(desc->transfer_size)>>9; 484 card->init_size) {
505 if (card->init_size>>1 >= card->mm_size) { 485 card->init_size += le32_to_cpu(desc->transfer_size) >> 9;
486 if (card->init_size >> 1 >= card->mm_size) {
506 dev_printk(KERN_INFO, &card->dev->dev, 487 dev_printk(KERN_INFO, &card->dev->dev,
507 "memory now initialised\n"); 488 "memory now initialised\n");
508 set_userbit(card, MEMORY_INITIALIZED, 1); 489 set_userbit(card, MEMORY_INITIALIZED, 1);
@@ -513,7 +494,8 @@ static void process_page(unsigned long data)
513 return_bio = bio; 494 return_bio = bio;
514 } 495 }
515 496
516 if (last) break; 497 if (last)
498 break;
517 } 499 }
518 500
519 if (debug & DEBUG_LED_ON_TRANSFER) 501 if (debug & DEBUG_LED_ON_TRANSFER)
@@ -535,7 +517,7 @@ static void process_page(unsigned long data)
535 out_unlock: 517 out_unlock:
536 spin_unlock_bh(&card->lock); 518 spin_unlock_bh(&card->lock);
537 519
538 while(return_bio) { 520 while (return_bio) {
539 struct bio *bio = return_bio; 521 struct bio *bio = return_bio;
540 522
541 return_bio = bio->bi_next; 523 return_bio = bio->bi_next;
@@ -544,11 +526,6 @@ static void process_page(unsigned long data)
544 } 526 }
545} 527}
546 528
547/*
548-----------------------------------------------------------------------------------
549-- mm_make_request
550-----------------------------------------------------------------------------------
551*/
552static int mm_make_request(struct request_queue *q, struct bio *bio) 529static int mm_make_request(struct request_queue *q, struct bio *bio)
553{ 530{
554 struct cardinfo *card = q->queuedata; 531 struct cardinfo *card = q->queuedata;
@@ -565,11 +542,6 @@ static int mm_make_request(struct request_queue *q, struct bio *bio)
565 return 0; 542 return 0;
566} 543}
567 544
568/*
569-----------------------------------------------------------------------------------
570-- mm_interrupt
571-----------------------------------------------------------------------------------
572*/
573static irqreturn_t mm_interrupt(int irq, void *__card) 545static irqreturn_t mm_interrupt(int irq, void *__card)
574{ 546{
575 struct cardinfo *card = (struct cardinfo *) __card; 547 struct cardinfo *card = (struct cardinfo *) __card;
@@ -583,15 +555,15 @@ HW_TRACE(0x30);
583 if (!(dma_status & (DMASCR_ERROR_MASK | DMASCR_CHAIN_COMPLETE))) { 555 if (!(dma_status & (DMASCR_ERROR_MASK | DMASCR_CHAIN_COMPLETE))) {
584 /* interrupt wasn't for me ... */ 556 /* interrupt wasn't for me ... */
585 return IRQ_NONE; 557 return IRQ_NONE;
586 } 558 }
587 559
588 /* clear COMPLETION interrupts */ 560 /* clear COMPLETION interrupts */
589 if (card->flags & UM_FLAG_NO_BYTE_STATUS) 561 if (card->flags & UM_FLAG_NO_BYTE_STATUS)
590 writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE), 562 writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE),
591 card->csr_remap+ DMA_STATUS_CTRL); 563 card->csr_remap + DMA_STATUS_CTRL);
592 else 564 else
593 writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16, 565 writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16,
594 card->csr_remap+ DMA_STATUS_CTRL + 2); 566 card->csr_remap + DMA_STATUS_CTRL + 2);
595 567
596 /* log errors and clear interrupt status */ 568 /* log errors and clear interrupt status */
597 if (dma_status & DMASCR_ANY_ERR) { 569 if (dma_status & DMASCR_ANY_ERR) {
@@ -601,9 +573,12 @@ HW_TRACE(0x30);
601 573
602 stat = readb(card->csr_remap + MEMCTRLCMD_ERRSTATUS); 574 stat = readb(card->csr_remap + MEMCTRLCMD_ERRSTATUS);
603 575
604 data_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG)); 576 data_log1 = le32_to_cpu(readl(card->csr_remap +
605 data_log2 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG + 4)); 577 ERROR_DATA_LOG));
606 addr_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_ADDR_LOG)); 578 data_log2 = le32_to_cpu(readl(card->csr_remap +
579 ERROR_DATA_LOG + 4));
580 addr_log1 = le32_to_cpu(readl(card->csr_remap +
581 ERROR_ADDR_LOG));
607 addr_log2 = readb(card->csr_remap + ERROR_ADDR_LOG + 4); 582 addr_log2 = readb(card->csr_remap + ERROR_ADDR_LOG + 4);
608 583
609 count = readb(card->csr_remap + ERROR_COUNT); 584 count = readb(card->csr_remap + ERROR_COUNT);
@@ -670,11 +645,7 @@ HW_TRACE(0x36);
670 645
671 return IRQ_HANDLED; 646 return IRQ_HANDLED;
672} 647}
673/* 648
674-----------------------------------------------------------------------------------
675-- set_fault_to_battery_status
676-----------------------------------------------------------------------------------
677*/
678/* 649/*
679 * If both batteries are good, no LED 650 * If both batteries are good, no LED
680 * If either battery has been warned, solid LED 651 * If either battery has been warned, solid LED
@@ -695,12 +666,6 @@ static void set_fault_to_battery_status(struct cardinfo *card)
695 666
696static void init_battery_timer(void); 667static void init_battery_timer(void);
697 668
698
699/*
700-----------------------------------------------------------------------------------
701-- check_battery
702-----------------------------------------------------------------------------------
703*/
704static int check_battery(struct cardinfo *card, int battery, int status) 669static int check_battery(struct cardinfo *card, int battery, int status)
705{ 670{
706 if (status != card->battery[battery].good) { 671 if (status != card->battery[battery].good) {
@@ -729,11 +694,7 @@ static int check_battery(struct cardinfo *card, int battery, int status)
729 694
730 return 0; 695 return 0;
731} 696}
732/* 697
733-----------------------------------------------------------------------------------
734-- check_batteries
735-----------------------------------------------------------------------------------
736*/
737static void check_batteries(struct cardinfo *card) 698static void check_batteries(struct cardinfo *card)
738{ 699{
739 /* NOTE: this must *never* be called while the card 700 /* NOTE: this must *never* be called while the card
@@ -774,11 +735,7 @@ static void check_all_batteries(unsigned long ptr)
774 735
775 init_battery_timer(); 736 init_battery_timer();
776} 737}
777/* 738
778-----------------------------------------------------------------------------------
779-- init_battery_timer
780-----------------------------------------------------------------------------------
781*/
782static void init_battery_timer(void) 739static void init_battery_timer(void)
783{ 740{
784 init_timer(&battery_timer); 741 init_timer(&battery_timer);
@@ -786,20 +743,12 @@ static void init_battery_timer(void)
786 battery_timer.expires = jiffies + (HZ * 60); 743 battery_timer.expires = jiffies + (HZ * 60);
787 add_timer(&battery_timer); 744 add_timer(&battery_timer);
788} 745}
789/* 746
790-----------------------------------------------------------------------------------
791-- del_battery_timer
792-----------------------------------------------------------------------------------
793*/
794static void del_battery_timer(void) 747static void del_battery_timer(void)
795{ 748{
796 del_timer(&battery_timer); 749 del_timer(&battery_timer);
797} 750}
798/* 751
799-----------------------------------------------------------------------------------
800-- mm_revalidate
801-----------------------------------------------------------------------------------
802*/
803/* 752/*
804 * Note no locks taken out here. In a worst case scenario, we could drop 753 * Note no locks taken out here. In a worst case scenario, we could drop
805 * a chunk of system memory. But that should never happen, since validation 754 * a chunk of system memory. But that should never happen, since validation
@@ -832,33 +781,23 @@ static int mm_getgeo(struct block_device *bdev, struct hd_geometry *geo)
832} 781}
833 782
834/* 783/*
835----------------------------------------------------------------------------------- 784 * Future support for removable devices
836-- mm_check_change 785 */
837-----------------------------------------------------------------------------------
838 Future support for removable devices
839*/
840static int mm_check_change(struct gendisk *disk) 786static int mm_check_change(struct gendisk *disk)
841{ 787{
842/* struct cardinfo *dev = disk->private_data; */ 788/* struct cardinfo *dev = disk->private_data; */
843 return 0; 789 return 0;
844} 790}
845/* 791
846-----------------------------------------------------------------------------------
847-- mm_fops
848-----------------------------------------------------------------------------------
849*/
850static struct block_device_operations mm_fops = { 792static struct block_device_operations mm_fops = {
851 .owner = THIS_MODULE, 793 .owner = THIS_MODULE,
852 .getgeo = mm_getgeo, 794 .getgeo = mm_getgeo,
853 .revalidate_disk= mm_revalidate, 795 .revalidate_disk = mm_revalidate,
854 .media_changed = mm_check_change, 796 .media_changed = mm_check_change,
855}; 797};
856/* 798
857----------------------------------------------------------------------------------- 799static int __devinit mm_pci_probe(struct pci_dev *dev,
858-- mm_pci_probe 800 const struct pci_device_id *id)
859-----------------------------------------------------------------------------------
860*/
861static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
862{ 801{
863 int ret = -ENODEV; 802 int ret = -ENODEV;
864 struct cardinfo *card = &cards[num_cards]; 803 struct cardinfo *card = &cards[num_cards];
@@ -888,7 +827,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
888 return -ENODEV; 827 return -ENODEV;
889 828
890 dev_printk(KERN_INFO, &dev->dev, 829 dev_printk(KERN_INFO, &dev->dev,
891 "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n"); 830 "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n");
892 831
893 if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && 832 if (pci_set_dma_mask(dev, DMA_64BIT_MASK) &&
894 pci_set_dma_mask(dev, DMA_32BIT_MASK)) { 833 pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
@@ -916,7 +855,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
916 "CSR 0x%08lx -> 0x%p (0x%lx)\n", 855 "CSR 0x%08lx -> 0x%p (0x%lx)\n",
917 csr_base, card->csr_remap, csr_len); 856 csr_base, card->csr_remap, csr_len);
918 857
919 switch(card->dev->device) { 858 switch (card->dev->device) {
920 case 0x5415: 859 case 0x5415:
921 card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG; 860 card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG;
922 magic_number = 0x59; 861 magic_number = 0x59;
@@ -928,7 +867,8 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
928 break; 867 break;
929 868
930 case 0x6155: 869 case 0x6155:
931 card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT; 870 card->flags |= UM_FLAG_NO_BYTE_STATUS |
871 UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT;
932 magic_number = 0x99; 872 magic_number = 0x99;
933 break; 873 break;
934 874
@@ -944,11 +884,11 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
944 } 884 }
945 885
946 card->mm_pages[0].desc = pci_alloc_consistent(card->dev, 886 card->mm_pages[0].desc = pci_alloc_consistent(card->dev,
947 PAGE_SIZE*2, 887 PAGE_SIZE * 2,
948 &card->mm_pages[0].page_dma); 888 &card->mm_pages[0].page_dma);
949 card->mm_pages[1].desc = pci_alloc_consistent(card->dev, 889 card->mm_pages[1].desc = pci_alloc_consistent(card->dev,
950 PAGE_SIZE*2, 890 PAGE_SIZE * 2,
951 &card->mm_pages[1].page_dma); 891 &card->mm_pages[1].page_dma);
952 if (card->mm_pages[0].desc == NULL || 892 if (card->mm_pages[0].desc == NULL ||
953 card->mm_pages[1].desc == NULL) { 893 card->mm_pages[1].desc == NULL) {
954 dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n"); 894 dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n");
@@ -1012,9 +952,9 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
1012 dev_printk(KERN_INFO, &card->dev->dev, 952 dev_printk(KERN_INFO, &card->dev->dev,
1013 "Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n", 953 "Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n",
1014 card->mm_size, 954 card->mm_size,
1015 (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"), 955 batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled",
1016 card->battery[0].good ? "OK" : "FAILURE", 956 card->battery[0].good ? "OK" : "FAILURE",
1017 (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"), 957 batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled",
1018 card->battery[1].good ? "OK" : "FAILURE"); 958 card->battery[1].good ? "OK" : "FAILURE");
1019 959
1020 set_fault_to_battery_status(card); 960 set_fault_to_battery_status(card);
@@ -1029,18 +969,18 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
1029 data = ~data; 969 data = ~data;
1030 data += 1; 970 data += 1;
1031 971
1032 if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, DRIVER_NAME, card)) { 972 if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, DRIVER_NAME,
973 card)) {
1033 dev_printk(KERN_ERR, &card->dev->dev, 974 dev_printk(KERN_ERR, &card->dev->dev,
1034 "Unable to allocate IRQ\n"); 975 "Unable to allocate IRQ\n");
1035 ret = -ENODEV; 976 ret = -ENODEV;
1036
1037 goto failed_req_irq; 977 goto failed_req_irq;
1038 } 978 }
1039 979
1040 dev_printk(KERN_INFO, &card->dev->dev, 980 dev_printk(KERN_INFO, &card->dev->dev,
1041 "Window size %d bytes, IRQ %d\n", data, dev->irq); 981 "Window size %d bytes, IRQ %d\n", data, dev->irq);
1042 982
1043 spin_lock_init(&card->lock); 983 spin_lock_init(&card->lock);
1044 984
1045 pci_set_drvdata(dev, card); 985 pci_set_drvdata(dev, card);
1046 986
@@ -1059,7 +999,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
1059 999
1060 if (!get_userbit(card, MEMORY_INITIALIZED)) { 1000 if (!get_userbit(card, MEMORY_INITIALIZED)) {
1061 dev_printk(KERN_INFO, &card->dev->dev, 1001 dev_printk(KERN_INFO, &card->dev->dev,
1062 "memory NOT initialized. Consider over-writing whole device.\n"); 1002 "memory NOT initialized. Consider over-writing whole device.\n");
1063 card->init_size = 0; 1003 card->init_size = 0;
1064 } else { 1004 } else {
1065 dev_printk(KERN_INFO, &card->dev->dev, 1005 dev_printk(KERN_INFO, &card->dev->dev,
@@ -1090,11 +1030,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
1090 1030
1091 return ret; 1031 return ret;
1092} 1032}
1093/* 1033
1094-----------------------------------------------------------------------------------
1095-- mm_pci_remove
1096-----------------------------------------------------------------------------------
1097*/
1098static void mm_pci_remove(struct pci_dev *dev) 1034static void mm_pci_remove(struct pci_dev *dev)
1099{ 1035{
1100 struct cardinfo *card = pci_get_drvdata(dev); 1036 struct cardinfo *card = pci_get_drvdata(dev);
@@ -1118,16 +1054,16 @@ static void mm_pci_remove(struct pci_dev *dev)
1118} 1054}
1119 1055
1120static const struct pci_device_id mm_pci_ids[] = { 1056static const struct pci_device_id mm_pci_ids[] = {
1121 {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_5415CN)}, 1057 {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY, PCI_DEVICE_ID_MICRO_MEMORY_5415CN)},
1122 {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_5425CN)}, 1058 {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY, PCI_DEVICE_ID_MICRO_MEMORY_5425CN)},
1123 {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_6155)}, 1059 {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY, PCI_DEVICE_ID_MICRO_MEMORY_6155)},
1124 { 1060 {
1125 .vendor = 0x8086, 1061 .vendor = 0x8086,
1126 .device = 0xB555, 1062 .device = 0xB555,
1127 .subvendor= 0x1332, 1063 .subvendor = 0x1332,
1128 .subdevice= 0x5460, 1064 .subdevice = 0x5460,
1129 .class = 0x050000, 1065 .class = 0x050000,
1130 .class_mask= 0, 1066 .class_mask = 0,
1131 }, { /* end: all zeroes */ } 1067 }, { /* end: all zeroes */ }
1132}; 1068};
1133 1069
@@ -1140,12 +1076,6 @@ static struct pci_driver mm_pci_driver = {
1140 .remove = mm_pci_remove, 1076 .remove = mm_pci_remove,
1141}; 1077};
1142 1078
1143/*
1144-----------------------------------------------------------------------------------
1145-- mm_init
1146-----------------------------------------------------------------------------------
1147*/
1148
1149static int __init mm_init(void) 1079static int __init mm_init(void)
1150{ 1080{
1151 int retval, i; 1081 int retval, i;
@@ -1192,18 +1122,14 @@ out:
1192 put_disk(mm_gendisk[i]); 1122 put_disk(mm_gendisk[i]);
1193 return -ENOMEM; 1123 return -ENOMEM;
1194} 1124}
1195/* 1125
1196-----------------------------------------------------------------------------------
1197-- mm_cleanup
1198-----------------------------------------------------------------------------------
1199*/
1200static void __exit mm_cleanup(void) 1126static void __exit mm_cleanup(void)
1201{ 1127{
1202 int i; 1128 int i;
1203 1129
1204 del_battery_timer(); 1130 del_battery_timer();
1205 1131
1206 for (i=0; i < num_cards ; i++) { 1132 for (i = 0; i < num_cards ; i++) {
1207 del_gendisk(mm_gendisk[i]); 1133 del_gendisk(mm_gendisk[i]);
1208 put_disk(mm_gendisk[i]); 1134 put_disk(mm_gendisk[i]);
1209 } 1135 }