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