aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/umem.c
diff options
context:
space:
mode:
authorRandy Dunlap <randy.dunlap@oracle.com>2007-12-17 14:24:20 -0500
committerJens Axboe <jens.axboe@oracle.com>2007-12-18 02:29:28 -0500
commit458cf5e9b666c251b04cb5242fb19fd5114645ba (patch)
tree8fd0de032105104467d15cd7cb991e5181ff3f03 /drivers/block/umem.c
parent2fdd82bd8852ec8ebad5c69c45138da25c6f9273 (diff)
Cleanup umem driver: fix most checkpatch warnings, conform to kernel
coding style. linux-2.6.24-rc5-git3> checkpatch.pl-next patches/block-umem-ckpatch.patch total: 0 errors, 5 warnings, 530 lines checked All of these are line-length warnings. Only change in generated object file is due to not initializing a static global variable to 0. Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block/umem.c')
-rw-r--r--drivers/block/umem.c237
1 files changed, 81 insertions, 156 deletions
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index 5f5095afb06b..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,12 +451,12 @@ 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;
@@ -489,8 +468,8 @@ static void process_page(unsigned long data)
489 } 468 }
490 469
491 pci_unmap_page(card->dev, desc->data_dma_handle, 470 pci_unmap_page(card->dev, desc->data_dma_handle,
492 bio_iovec_idx(bio,idx)->bv_len, 471 bio_iovec_idx(bio, idx)->bv_len,
493 (control& DMASCR_TRANSFER_READ) ? 472 (control & DMASCR_TRANSFER_READ) ?
494 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); 473 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
495 if (control & DMASCR_HARD_ERROR) { 474 if (control & DMASCR_HARD_ERROR) {
496 /* error */ 475 /* error */
@@ -501,9 +480,10 @@ static void process_page(unsigned long data)
501 le32_to_cpu(desc->transfer_size)); 480 le32_to_cpu(desc->transfer_size));
502 dump_dmastat(card, control); 481 dump_dmastat(card, control);
503 } else if (test_bit(BIO_RW, &bio->bi_rw) && 482 } else if (test_bit(BIO_RW, &bio->bi_rw) &&
504 le32_to_cpu(desc->local_addr)>>9 == card->init_size) { 483 le32_to_cpu(desc->local_addr) >> 9 ==
505 card->init_size += le32_to_cpu(desc->transfer_size)>>9; 484 card->init_size) {
506 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) {
507 dev_printk(KERN_INFO, &card->dev->dev, 487 dev_printk(KERN_INFO, &card->dev->dev,
508 "memory now initialised\n"); 488 "memory now initialised\n");
509 set_userbit(card, MEMORY_INITIALIZED, 1); 489 set_userbit(card, MEMORY_INITIALIZED, 1);
@@ -514,7 +494,8 @@ static void process_page(unsigned long data)
514 return_bio = bio; 494 return_bio = bio;
515 } 495 }
516 496
517 if (last) break; 497 if (last)
498 break;
518 } 499 }
519 500
520 if (debug & DEBUG_LED_ON_TRANSFER) 501 if (debug & DEBUG_LED_ON_TRANSFER)
@@ -536,7 +517,7 @@ static void process_page(unsigned long data)
536 out_unlock: 517 out_unlock:
537 spin_unlock_bh(&card->lock); 518 spin_unlock_bh(&card->lock);
538 519
539 while(return_bio) { 520 while (return_bio) {
540 struct bio *bio = return_bio; 521 struct bio *bio = return_bio;
541 522
542 return_bio = bio->bi_next; 523 return_bio = bio->bi_next;
@@ -545,11 +526,6 @@ static void process_page(unsigned long data)
545 } 526 }
546} 527}
547 528
548/*
549-----------------------------------------------------------------------------------
550-- mm_make_request
551-----------------------------------------------------------------------------------
552*/
553static int mm_make_request(struct request_queue *q, struct bio *bio) 529static int mm_make_request(struct request_queue *q, struct bio *bio)
554{ 530{
555 struct cardinfo *card = q->queuedata; 531 struct cardinfo *card = q->queuedata;
@@ -566,11 +542,6 @@ static int mm_make_request(struct request_queue *q, struct bio *bio)
566 return 0; 542 return 0;
567} 543}
568 544
569/*
570-----------------------------------------------------------------------------------
571-- mm_interrupt
572-----------------------------------------------------------------------------------
573*/
574static irqreturn_t mm_interrupt(int irq, void *__card) 545static irqreturn_t mm_interrupt(int irq, void *__card)
575{ 546{
576 struct cardinfo *card = (struct cardinfo *) __card; 547 struct cardinfo *card = (struct cardinfo *) __card;
@@ -584,15 +555,15 @@ HW_TRACE(0x30);
584 if (!(dma_status & (DMASCR_ERROR_MASK | DMASCR_CHAIN_COMPLETE))) { 555 if (!(dma_status & (DMASCR_ERROR_MASK | DMASCR_CHAIN_COMPLETE))) {
585 /* interrupt wasn't for me ... */ 556 /* interrupt wasn't for me ... */
586 return IRQ_NONE; 557 return IRQ_NONE;
587 } 558 }
588 559
589 /* clear COMPLETION interrupts */ 560 /* clear COMPLETION interrupts */
590 if (card->flags & UM_FLAG_NO_BYTE_STATUS) 561 if (card->flags & UM_FLAG_NO_BYTE_STATUS)
591 writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE), 562 writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE),
592 card->csr_remap+ DMA_STATUS_CTRL); 563 card->csr_remap + DMA_STATUS_CTRL);
593 else 564 else
594 writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16, 565 writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16,
595 card->csr_remap+ DMA_STATUS_CTRL + 2); 566 card->csr_remap + DMA_STATUS_CTRL + 2);
596 567
597 /* log errors and clear interrupt status */ 568 /* log errors and clear interrupt status */
598 if (dma_status & DMASCR_ANY_ERR) { 569 if (dma_status & DMASCR_ANY_ERR) {
@@ -602,9 +573,12 @@ HW_TRACE(0x30);
602 573
603 stat = readb(card->csr_remap + MEMCTRLCMD_ERRSTATUS); 574 stat = readb(card->csr_remap + MEMCTRLCMD_ERRSTATUS);
604 575
605 data_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG)); 576 data_log1 = le32_to_cpu(readl(card->csr_remap +
606 data_log2 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG + 4)); 577 ERROR_DATA_LOG));
607 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));
608 addr_log2 = readb(card->csr_remap + ERROR_ADDR_LOG + 4); 582 addr_log2 = readb(card->csr_remap + ERROR_ADDR_LOG + 4);
609 583
610 count = readb(card->csr_remap + ERROR_COUNT); 584 count = readb(card->csr_remap + ERROR_COUNT);
@@ -671,11 +645,7 @@ HW_TRACE(0x36);
671 645
672 return IRQ_HANDLED; 646 return IRQ_HANDLED;
673} 647}
674/* 648
675-----------------------------------------------------------------------------------
676-- set_fault_to_battery_status
677-----------------------------------------------------------------------------------
678*/
679/* 649/*
680 * If both batteries are good, no LED 650 * If both batteries are good, no LED
681 * If either battery has been warned, solid LED 651 * If either battery has been warned, solid LED
@@ -696,12 +666,6 @@ static void set_fault_to_battery_status(struct cardinfo *card)
696 666
697static void init_battery_timer(void); 667static void init_battery_timer(void);
698 668
699
700/*
701-----------------------------------------------------------------------------------
702-- check_battery
703-----------------------------------------------------------------------------------
704*/
705static int check_battery(struct cardinfo *card, int battery, int status) 669static int check_battery(struct cardinfo *card, int battery, int status)
706{ 670{
707 if (status != card->battery[battery].good) { 671 if (status != card->battery[battery].good) {
@@ -730,11 +694,7 @@ static int check_battery(struct cardinfo *card, int battery, int status)
730 694
731 return 0; 695 return 0;
732} 696}
733/* 697
734-----------------------------------------------------------------------------------
735-- check_batteries
736-----------------------------------------------------------------------------------
737*/
738static void check_batteries(struct cardinfo *card) 698static void check_batteries(struct cardinfo *card)
739{ 699{
740 /* NOTE: this must *never* be called while the card 700 /* NOTE: this must *never* be called while the card
@@ -775,11 +735,7 @@ static void check_all_batteries(unsigned long ptr)
775 735
776 init_battery_timer(); 736 init_battery_timer();
777} 737}
778/* 738
779-----------------------------------------------------------------------------------
780-- init_battery_timer
781-----------------------------------------------------------------------------------
782*/
783static void init_battery_timer(void) 739static void init_battery_timer(void)
784{ 740{
785 init_timer(&battery_timer); 741 init_timer(&battery_timer);
@@ -787,20 +743,12 @@ static void init_battery_timer(void)
787 battery_timer.expires = jiffies + (HZ * 60); 743 battery_timer.expires = jiffies + (HZ * 60);
788 add_timer(&battery_timer); 744 add_timer(&battery_timer);
789} 745}
790/* 746
791-----------------------------------------------------------------------------------
792-- del_battery_timer
793-----------------------------------------------------------------------------------
794*/
795static void del_battery_timer(void) 747static void del_battery_timer(void)
796{ 748{
797 del_timer(&battery_timer); 749 del_timer(&battery_timer);
798} 750}
799/* 751
800-----------------------------------------------------------------------------------
801-- mm_revalidate
802-----------------------------------------------------------------------------------
803*/
804/* 752/*
805 * 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
806 * 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
@@ -833,33 +781,23 @@ static int mm_getgeo(struct block_device *bdev, struct hd_geometry *geo)
833} 781}
834 782
835/* 783/*
836----------------------------------------------------------------------------------- 784 * Future support for removable devices
837-- mm_check_change 785 */
838-----------------------------------------------------------------------------------
839 Future support for removable devices
840*/
841static int mm_check_change(struct gendisk *disk) 786static int mm_check_change(struct gendisk *disk)
842{ 787{
843/* struct cardinfo *dev = disk->private_data; */ 788/* struct cardinfo *dev = disk->private_data; */
844 return 0; 789 return 0;
845} 790}
846/* 791
847-----------------------------------------------------------------------------------
848-- mm_fops
849-----------------------------------------------------------------------------------
850*/
851static struct block_device_operations mm_fops = { 792static struct block_device_operations mm_fops = {
852 .owner = THIS_MODULE, 793 .owner = THIS_MODULE,
853 .getgeo = mm_getgeo, 794 .getgeo = mm_getgeo,
854 .revalidate_disk= mm_revalidate, 795 .revalidate_disk = mm_revalidate,
855 .media_changed = mm_check_change, 796 .media_changed = mm_check_change,
856}; 797};
857/* 798
858----------------------------------------------------------------------------------- 799static int __devinit mm_pci_probe(struct pci_dev *dev,
859-- mm_pci_probe 800 const struct pci_device_id *id)
860-----------------------------------------------------------------------------------
861*/
862static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
863{ 801{
864 int ret = -ENODEV; 802 int ret = -ENODEV;
865 struct cardinfo *card = &cards[num_cards]; 803 struct cardinfo *card = &cards[num_cards];
@@ -889,7 +827,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
889 return -ENODEV; 827 return -ENODEV;
890 828
891 dev_printk(KERN_INFO, &dev->dev, 829 dev_printk(KERN_INFO, &dev->dev,
892 "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n"); 830 "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n");
893 831
894 if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && 832 if (pci_set_dma_mask(dev, DMA_64BIT_MASK) &&
895 pci_set_dma_mask(dev, DMA_32BIT_MASK)) { 833 pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
@@ -917,7 +855,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
917 "CSR 0x%08lx -> 0x%p (0x%lx)\n", 855 "CSR 0x%08lx -> 0x%p (0x%lx)\n",
918 csr_base, card->csr_remap, csr_len); 856 csr_base, card->csr_remap, csr_len);
919 857
920 switch(card->dev->device) { 858 switch (card->dev->device) {
921 case 0x5415: 859 case 0x5415:
922 card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG; 860 card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG;
923 magic_number = 0x59; 861 magic_number = 0x59;
@@ -929,7 +867,8 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
929 break; 867 break;
930 868
931 case 0x6155: 869 case 0x6155:
932 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;
933 magic_number = 0x99; 872 magic_number = 0x99;
934 break; 873 break;
935 874
@@ -945,11 +884,11 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
945 } 884 }
946 885
947 card->mm_pages[0].desc = pci_alloc_consistent(card->dev, 886 card->mm_pages[0].desc = pci_alloc_consistent(card->dev,
948 PAGE_SIZE*2, 887 PAGE_SIZE * 2,
949 &card->mm_pages[0].page_dma); 888 &card->mm_pages[0].page_dma);
950 card->mm_pages[1].desc = pci_alloc_consistent(card->dev, 889 card->mm_pages[1].desc = pci_alloc_consistent(card->dev,
951 PAGE_SIZE*2, 890 PAGE_SIZE * 2,
952 &card->mm_pages[1].page_dma); 891 &card->mm_pages[1].page_dma);
953 if (card->mm_pages[0].desc == NULL || 892 if (card->mm_pages[0].desc == NULL ||
954 card->mm_pages[1].desc == NULL) { 893 card->mm_pages[1].desc == NULL) {
955 dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n"); 894 dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n");
@@ -1013,9 +952,9 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
1013 dev_printk(KERN_INFO, &card->dev->dev, 952 dev_printk(KERN_INFO, &card->dev->dev,
1014 "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",
1015 card->mm_size, 954 card->mm_size,
1016 (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"), 955 batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled",
1017 card->battery[0].good ? "OK" : "FAILURE", 956 card->battery[0].good ? "OK" : "FAILURE",
1018 (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"), 957 batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled",
1019 card->battery[1].good ? "OK" : "FAILURE"); 958 card->battery[1].good ? "OK" : "FAILURE");
1020 959
1021 set_fault_to_battery_status(card); 960 set_fault_to_battery_status(card);
@@ -1030,18 +969,18 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
1030 data = ~data; 969 data = ~data;
1031 data += 1; 970 data += 1;
1032 971
1033 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)) {
1034 dev_printk(KERN_ERR, &card->dev->dev, 974 dev_printk(KERN_ERR, &card->dev->dev,
1035 "Unable to allocate IRQ\n"); 975 "Unable to allocate IRQ\n");
1036 ret = -ENODEV; 976 ret = -ENODEV;
1037
1038 goto failed_req_irq; 977 goto failed_req_irq;
1039 } 978 }
1040 979
1041 dev_printk(KERN_INFO, &card->dev->dev, 980 dev_printk(KERN_INFO, &card->dev->dev,
1042 "Window size %d bytes, IRQ %d\n", data, dev->irq); 981 "Window size %d bytes, IRQ %d\n", data, dev->irq);
1043 982
1044 spin_lock_init(&card->lock); 983 spin_lock_init(&card->lock);
1045 984
1046 pci_set_drvdata(dev, card); 985 pci_set_drvdata(dev, card);
1047 986
@@ -1060,7 +999,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
1060 999
1061 if (!get_userbit(card, MEMORY_INITIALIZED)) { 1000 if (!get_userbit(card, MEMORY_INITIALIZED)) {
1062 dev_printk(KERN_INFO, &card->dev->dev, 1001 dev_printk(KERN_INFO, &card->dev->dev,
1063 "memory NOT initialized. Consider over-writing whole device.\n"); 1002 "memory NOT initialized. Consider over-writing whole device.\n");
1064 card->init_size = 0; 1003 card->init_size = 0;
1065 } else { 1004 } else {
1066 dev_printk(KERN_INFO, &card->dev->dev, 1005 dev_printk(KERN_INFO, &card->dev->dev,
@@ -1091,11 +1030,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
1091 1030
1092 return ret; 1031 return ret;
1093} 1032}
1094/* 1033
1095-----------------------------------------------------------------------------------
1096-- mm_pci_remove
1097-----------------------------------------------------------------------------------
1098*/
1099static void mm_pci_remove(struct pci_dev *dev) 1034static void mm_pci_remove(struct pci_dev *dev)
1100{ 1035{
1101 struct cardinfo *card = pci_get_drvdata(dev); 1036 struct cardinfo *card = pci_get_drvdata(dev);
@@ -1119,16 +1054,16 @@ static void mm_pci_remove(struct pci_dev *dev)
1119} 1054}
1120 1055
1121static const struct pci_device_id mm_pci_ids[] = { 1056static const struct pci_device_id mm_pci_ids[] = {
1122 {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)},
1123 {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)},
1124 {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)},
1125 { 1060 {
1126 .vendor = 0x8086, 1061 .vendor = 0x8086,
1127 .device = 0xB555, 1062 .device = 0xB555,
1128 .subvendor= 0x1332, 1063 .subvendor = 0x1332,
1129 .subdevice= 0x5460, 1064 .subdevice = 0x5460,
1130 .class = 0x050000, 1065 .class = 0x050000,
1131 .class_mask= 0, 1066 .class_mask = 0,
1132 }, { /* end: all zeroes */ } 1067 }, { /* end: all zeroes */ }
1133}; 1068};
1134 1069
@@ -1141,12 +1076,6 @@ static struct pci_driver mm_pci_driver = {
1141 .remove = mm_pci_remove, 1076 .remove = mm_pci_remove,
1142}; 1077};
1143 1078
1144/*
1145-----------------------------------------------------------------------------------
1146-- mm_init
1147-----------------------------------------------------------------------------------
1148*/
1149
1150static int __init mm_init(void) 1079static int __init mm_init(void)
1151{ 1080{
1152 int retval, i; 1081 int retval, i;
@@ -1193,18 +1122,14 @@ out:
1193 put_disk(mm_gendisk[i]); 1122 put_disk(mm_gendisk[i]);
1194 return -ENOMEM; 1123 return -ENOMEM;
1195} 1124}
1196/* 1125
1197-----------------------------------------------------------------------------------
1198-- mm_cleanup
1199-----------------------------------------------------------------------------------
1200*/
1201static void __exit mm_cleanup(void) 1126static void __exit mm_cleanup(void)
1202{ 1127{
1203 int i; 1128 int i;
1204 1129
1205 del_battery_timer(); 1130 del_battery_timer();
1206 1131
1207 for (i=0; i < num_cards ; i++) { 1132 for (i = 0; i < num_cards ; i++) {
1208 del_gendisk(mm_gendisk[i]); 1133 del_gendisk(mm_gendisk[i]);
1209 put_disk(mm_gendisk[i]); 1134 put_disk(mm_gendisk[i]);
1210 } 1135 }