CRIS v32: Change drivers/i2c.c locking.

- Change spin_lock + local_irq_save into spin_lock_irqsave
- Change spin_unlock + local_irq_restore into spin_unlock_irqrestore
- Return ENOTTY if ioctl is not recognized as a cris ioctl.
- Make init functions static.

+12 -49
+12 -49
arch/cris/arch-v32/drivers/i2c.c
··· 395 395 unsigned char value; 396 396 unsigned long flags; 397 397 398 - spin_lock(&i2c_lock); 398 + spin_lock_irqsave(&i2c_lock, flags); 399 399 400 400 do { 401 401 error = 0; 402 - /* 403 - * we don't like to be interrupted 404 - */ 405 - local_irq_save(flags); 406 402 407 403 i2c_start(); 408 404 /* ··· 426 430 * end byte stream 427 431 */ 428 432 i2c_stop(); 429 - /* 430 - * enable interrupt again 431 - */ 432 - local_irq_restore(flags); 433 433 434 434 } while (error && cntr--); 435 435 436 436 i2c_delay(CLOCK_LOW_TIME); 437 437 438 - spin_unlock(&i2c_lock); 438 + spin_unlock_irqrestore(&i2c_lock, flags); 439 439 440 440 return -error; 441 441 } ··· 451 459 int error, cntr = 3; 452 460 unsigned long flags; 453 461 454 - spin_lock(&i2c_lock); 462 + spin_lock_irqsave(&i2c_lock, flags); 455 463 456 464 do { 457 465 error = 0; 458 466 memset(data, 0, nbytes); 459 - /* 460 - * we don't like to be interrupted 461 - */ 462 - local_irq_save(flags); 463 467 /* 464 468 * generate start condition 465 469 */ ··· 488 500 * end sequence 489 501 */ 490 502 i2c_stop(); 491 - /* 492 - * enable interrupt again 493 - */ 494 - local_irq_restore(flags); 495 503 } while (error && cntr--); 496 504 497 - spin_unlock(&i2c_lock); 505 + spin_unlock_irqrestore(&i2c_lock, flags); 498 506 499 507 return -error; 500 508 } ··· 509 525 int error, cntr = 3; 510 526 unsigned long flags; 511 527 512 - spin_lock(&i2c_lock); 528 + spin_lock_irqsave(&i2c_lock, flags); 513 529 514 530 do { 515 531 error = 0; 516 - /* 517 - * we don't like to be interrupted 518 - */ 519 - local_irq_save(flags); 520 532 521 533 i2c_start(); 522 534 /* ··· 547 567 * end byte stream 548 568 */ 549 569 i2c_stop(); 550 - /* 551 - * enable interrupt again 552 - */ 553 - local_irq_restore(flags); 554 570 } while(error && cntr--); 555 571 556 572 i2c_delay(CLOCK_LOW_TIME); 557 573 558 - spin_unlock(&i2c_lock); 574 + spin_unlock_irqrestore(&i2c_lock, flags); 559 575 560 576 return -error; 561 577 } ··· 570 594 int error, cntr = 3; 571 595 unsigned long flags; 572 596 573 - spin_lock(&i2c_lock); 597 + spin_lock_irqsave(&i2c_lock, flags); 574 598 575 599 do { 576 600 error = 0; 577 - /* 578 - * we don't like to be interrupted 579 - */ 580 - local_irq_save(flags); 581 601 /* 582 602 * generate start condition 583 603 */ ··· 625 653 * end sequence 626 654 */ 627 655 i2c_stop(); 628 - /* 629 - * enable interrupt again 630 - */ 631 - local_irq_restore(flags); 632 656 633 657 } while(error && cntr--); 634 658 635 - spin_unlock(&i2c_lock); 659 + spin_unlock_irqrestore(&i2c_lock, flags); 636 660 637 661 return b; 638 662 } ··· 653 685 unsigned int cmd, unsigned long arg) 654 686 { 655 687 if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) { 656 - return -EINVAL; 688 + return -ENOTTY; 657 689 } 658 690 659 691 switch (_IOC_NR(cmd)) { ··· 693 725 .release = i2c_release, 694 726 }; 695 727 696 - int __init 697 - i2c_init(void) 728 + static int __init i2c_init(void) 698 729 { 699 730 static int res; 700 731 static int first = 1; ··· 717 750 } 718 751 719 752 720 - int __init 721 - i2c_register(void) 753 + static int __init i2c_register(void) 722 754 { 723 - 724 755 int res; 725 756 726 757 res = i2c_init(); ··· 728 763 /* register char device */ 729 764 730 765 res = register_chrdev(I2C_MAJOR, i2c_name, &i2c_fops); 731 - if(res < 0) { 766 + if (res < 0) { 732 767 printk(KERN_ERR "i2c: couldn't get a major number.\n"); 733 768 return res; 734 769 } ··· 738 773 739 774 return 0; 740 775 } 741 - 742 776 /* this makes sure that i2c_init is called during boot */ 743 - 744 777 module_init(i2c_register); 745 778 746 779 /****************** END OF FILE i2c.c ********************************/