diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-27 22:07:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-27 22:07:10 -0400 |
commit | 06d2e7812ecd1b585c5e9e7bda8ee90acebaef8c (patch) | |
tree | 2221916f69f4f485c8dd0353e5e83c9587dcc968 /drivers | |
parent | 7d8eb50290e4edf8de36973728862f73ff0b94bc (diff) | |
parent | 72a71f869c95dc11b73f09fe18c593d4a0618c3f (diff) |
Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull more i2c updates from Wolfram Sang:
"Here is the second pull request from I2C for this merge window:
- one new feature (which nearly fell through the cracks): i2c-dev
does now use the cdev API so it can handle >256 minors. Seems
people do need that.
- two fixes for the just added DMA feature for i2c-rcar
- some typo fixes"
* 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: dev: don't start function name with 'return'
i2c: dev: switch from register_chrdev to cdev API
i2c: xlr: rename ARCH_TANGOX to ARCH_TANGO
i2c: at91: change log when dma configuration fails
misc: at24: Fix typo in at24 header file
i2c: rcar: should depend on HAS_DMA
i2c: rcar: use dma_request_chan()
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/busses/Kconfig | 3 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-at91.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-rcar.c | 2 | ||||
-rw-r--r-- | drivers/i2c/i2c-dev.c | 25 |
4 files changed, 22 insertions, 10 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 2dd40ddf04de..f167021b8c21 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -965,7 +965,7 @@ config I2C_XILINX | |||
965 | 965 | ||
966 | config I2C_XLR | 966 | config I2C_XLR |
967 | tristate "Netlogic XLR and Sigma Designs I2C support" | 967 | tristate "Netlogic XLR and Sigma Designs I2C support" |
968 | depends on CPU_XLR || ARCH_TANGOX | 968 | depends on CPU_XLR || ARCH_TANGO |
969 | help | 969 | help |
970 | This driver enables support for the on-chip I2C interface of | 970 | This driver enables support for the on-chip I2C interface of |
971 | the Netlogic XLR/XLS MIPS processors and Sigma Designs SOCs. | 971 | the Netlogic XLR/XLS MIPS processors and Sigma Designs SOCs. |
@@ -985,6 +985,7 @@ config I2C_XLP9XX | |||
985 | 985 | ||
986 | config I2C_RCAR | 986 | config I2C_RCAR |
987 | tristate "Renesas R-Car I2C Controller" | 987 | tristate "Renesas R-Car I2C Controller" |
988 | depends on HAS_DMA | ||
988 | depends on ARCH_RENESAS || COMPILE_TEST | 989 | depends on ARCH_RENESAS || COMPILE_TEST |
989 | select I2C_SLAVE | 990 | select I2C_SLAVE |
990 | help | 991 | help |
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 921d32bfcda8..f23372669f77 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -1013,7 +1013,7 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) | |||
1013 | 1013 | ||
1014 | error: | 1014 | error: |
1015 | if (ret != -EPROBE_DEFER) | 1015 | if (ret != -EPROBE_DEFER) |
1016 | dev_info(dev->dev, "can't use DMA, error %d\n", ret); | 1016 | dev_info(dev->dev, "can't get DMA channel, continue without DMA support\n"); |
1017 | if (dma->chan_rx) | 1017 | if (dma->chan_rx) |
1018 | dma_release_channel(dma->chan_rx); | 1018 | dma_release_channel(dma->chan_rx); |
1019 | if (dma->chan_tx) | 1019 | if (dma->chan_tx) |
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 9aca1b4e2d8d..52407f3c9e1c 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c | |||
@@ -623,7 +623,7 @@ static struct dma_chan *rcar_i2c_request_dma_chan(struct device *dev, | |||
623 | char *chan_name = dir == DMA_MEM_TO_DEV ? "tx" : "rx"; | 623 | char *chan_name = dir == DMA_MEM_TO_DEV ? "tx" : "rx"; |
624 | int ret; | 624 | int ret; |
625 | 625 | ||
626 | chan = dma_request_slave_channel_reason(dev, chan_name); | 626 | chan = dma_request_chan(dev, chan_name); |
627 | if (IS_ERR(chan)) { | 627 | if (IS_ERR(chan)) { |
628 | ret = PTR_ERR(chan); | 628 | ret = PTR_ERR(chan); |
629 | dev_dbg(dev, "request_channel failed for %s (%d)\n", | 629 | dev_dbg(dev, "request_channel failed for %s (%d)\n", |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 0b1108d3c2f3..89593dcb79f0 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ | 23 | /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ |
24 | 24 | ||
25 | #include <linux/cdev.h> | ||
25 | #include <linux/device.h> | 26 | #include <linux/device.h> |
26 | #include <linux/fs.h> | 27 | #include <linux/fs.h> |
27 | #include <linux/i2c-dev.h> | 28 | #include <linux/i2c-dev.h> |
@@ -47,9 +48,10 @@ struct i2c_dev { | |||
47 | struct list_head list; | 48 | struct list_head list; |
48 | struct i2c_adapter *adap; | 49 | struct i2c_adapter *adap; |
49 | struct device *dev; | 50 | struct device *dev; |
51 | struct cdev cdev; | ||
50 | }; | 52 | }; |
51 | 53 | ||
52 | #define I2C_MINORS 256 | 54 | #define I2C_MINORS MINORMASK |
53 | static LIST_HEAD(i2c_dev_list); | 55 | static LIST_HEAD(i2c_dev_list); |
54 | static DEFINE_SPINLOCK(i2c_dev_list_lock); | 56 | static DEFINE_SPINLOCK(i2c_dev_list_lock); |
55 | 57 | ||
@@ -89,7 +91,7 @@ static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap) | |||
89 | return i2c_dev; | 91 | return i2c_dev; |
90 | } | 92 | } |
91 | 93 | ||
92 | static void return_i2c_dev(struct i2c_dev *i2c_dev) | 94 | static void put_i2c_dev(struct i2c_dev *i2c_dev) |
93 | { | 95 | { |
94 | spin_lock(&i2c_dev_list_lock); | 96 | spin_lock(&i2c_dev_list_lock); |
95 | list_del(&i2c_dev->list); | 97 | list_del(&i2c_dev->list); |
@@ -552,6 +554,12 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy) | |||
552 | if (IS_ERR(i2c_dev)) | 554 | if (IS_ERR(i2c_dev)) |
553 | return PTR_ERR(i2c_dev); | 555 | return PTR_ERR(i2c_dev); |
554 | 556 | ||
557 | cdev_init(&i2c_dev->cdev, &i2cdev_fops); | ||
558 | i2c_dev->cdev.owner = THIS_MODULE; | ||
559 | res = cdev_add(&i2c_dev->cdev, MKDEV(I2C_MAJOR, adap->nr), 1); | ||
560 | if (res) | ||
561 | goto error_cdev; | ||
562 | |||
555 | /* register this i2c device with the driver core */ | 563 | /* register this i2c device with the driver core */ |
556 | i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, | 564 | i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, |
557 | MKDEV(I2C_MAJOR, adap->nr), NULL, | 565 | MKDEV(I2C_MAJOR, adap->nr), NULL, |
@@ -565,7 +573,9 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy) | |||
565 | adap->name, adap->nr); | 573 | adap->name, adap->nr); |
566 | return 0; | 574 | return 0; |
567 | error: | 575 | error: |
568 | return_i2c_dev(i2c_dev); | 576 | cdev_del(&i2c_dev->cdev); |
577 | error_cdev: | ||
578 | put_i2c_dev(i2c_dev); | ||
569 | return res; | 579 | return res; |
570 | } | 580 | } |
571 | 581 | ||
@@ -582,8 +592,9 @@ static int i2cdev_detach_adapter(struct device *dev, void *dummy) | |||
582 | if (!i2c_dev) /* attach_adapter must have failed */ | 592 | if (!i2c_dev) /* attach_adapter must have failed */ |
583 | return 0; | 593 | return 0; |
584 | 594 | ||
585 | return_i2c_dev(i2c_dev); | 595 | put_i2c_dev(i2c_dev); |
586 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | 596 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); |
597 | cdev_del(&i2c_dev->cdev); | ||
587 | 598 | ||
588 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); | 599 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); |
589 | return 0; | 600 | return 0; |
@@ -620,7 +631,7 @@ static int __init i2c_dev_init(void) | |||
620 | 631 | ||
621 | printk(KERN_INFO "i2c /dev entries driver\n"); | 632 | printk(KERN_INFO "i2c /dev entries driver\n"); |
622 | 633 | ||
623 | res = register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops); | 634 | res = register_chrdev_region(MKDEV(I2C_MAJOR, 0), I2C_MINORS, "i2c"); |
624 | if (res) | 635 | if (res) |
625 | goto out; | 636 | goto out; |
626 | 637 | ||
@@ -644,7 +655,7 @@ static int __init i2c_dev_init(void) | |||
644 | out_unreg_class: | 655 | out_unreg_class: |
645 | class_destroy(i2c_dev_class); | 656 | class_destroy(i2c_dev_class); |
646 | out_unreg_chrdev: | 657 | out_unreg_chrdev: |
647 | unregister_chrdev(I2C_MAJOR, "i2c"); | 658 | unregister_chrdev_region(MKDEV(I2C_MAJOR, 0), I2C_MINORS); |
648 | out: | 659 | out: |
649 | printk(KERN_ERR "%s: Driver Initialisation failed\n", __FILE__); | 660 | printk(KERN_ERR "%s: Driver Initialisation failed\n", __FILE__); |
650 | return res; | 661 | return res; |
@@ -655,7 +666,7 @@ static void __exit i2c_dev_exit(void) | |||
655 | bus_unregister_notifier(&i2c_bus_type, &i2cdev_notifier); | 666 | bus_unregister_notifier(&i2c_bus_type, &i2cdev_notifier); |
656 | i2c_for_each_dev(NULL, i2cdev_detach_adapter); | 667 | i2c_for_each_dev(NULL, i2cdev_detach_adapter); |
657 | class_destroy(i2c_dev_class); | 668 | class_destroy(i2c_dev_class); |
658 | unregister_chrdev(I2C_MAJOR, "i2c"); | 669 | unregister_chrdev_region(MKDEV(I2C_MAJOR, 0), I2C_MINORS); |
659 | } | 670 | } |
660 | 671 | ||
661 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and " | 672 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and " |