diff options
126 files changed, 3596 insertions, 1116 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-mei b/Documentation/ABI/testing/sysfs-bus-mei new file mode 100644 index 000000000000..2066f0bbd453 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-mei | |||
@@ -0,0 +1,7 @@ | |||
1 | What: /sys/bus/mei/devices/.../modalias | ||
2 | Date: March 2013 | ||
3 | KernelVersion: 3.10 | ||
4 | Contact: Samuel Ortiz <sameo@linux.intel.com> | ||
5 | linux-mei@linux.intel.com | ||
6 | Description: Stores the same MODALIAS value emitted by uevent | ||
7 | Format: mei:<mei device name> | ||
diff --git a/Documentation/devicetree/bindings/arm/msm/ssbi.txt b/Documentation/devicetree/bindings/arm/msm/ssbi.txt new file mode 100644 index 000000000000..54fd5ced3401 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/msm/ssbi.txt | |||
@@ -0,0 +1,18 @@ | |||
1 | * Qualcomm SSBI | ||
2 | |||
3 | Some Qualcomm MSM devices contain a point-to-point serial bus used to | ||
4 | communicate with a limited range of devices (mostly power management | ||
5 | chips). | ||
6 | |||
7 | These require the following properties: | ||
8 | |||
9 | - compatible: "qcom,ssbi" | ||
10 | |||
11 | - qcom,controller-type | ||
12 | indicates the SSBI bus variant the controller should use to talk | ||
13 | with the slave device. This should be one of "ssbi", "ssbi2", or | ||
14 | "pmic-arbiter". The type chosen is determined by the attached | ||
15 | slave. | ||
16 | |||
17 | The slave device should be the single child node of the ssbi device | ||
18 | with a compatible field. | ||
diff --git a/Documentation/misc-devices/mei/mei-client-bus.txt b/Documentation/misc-devices/mei/mei-client-bus.txt new file mode 100644 index 000000000000..9dc5ebf94eb1 --- /dev/null +++ b/Documentation/misc-devices/mei/mei-client-bus.txt | |||
@@ -0,0 +1,135 @@ | |||
1 | Intel(R) Management Engine (ME) Client bus API | ||
2 | =============================================== | ||
3 | |||
4 | |||
5 | Rationale | ||
6 | ========= | ||
7 | MEI misc character device is useful for dedicated applications to send and receive | ||
8 | data to the many FW appliance found in Intel's ME from the user space. | ||
9 | However for some of the ME functionalities it make sense to leverage existing software | ||
10 | stack and expose them through existing kernel subsystems. | ||
11 | |||
12 | In order to plug seamlessly into the kernel device driver model we add kernel virtual | ||
13 | bus abstraction on top of the MEI driver. This allows implementing linux kernel drivers | ||
14 | for the various MEI features as a stand alone entities found in their respective subsystem. | ||
15 | Existing device drivers can even potentially be re-used by adding an MEI CL bus layer to | ||
16 | the existing code. | ||
17 | |||
18 | |||
19 | MEI CL bus API | ||
20 | =========== | ||
21 | A driver implementation for an MEI Client is very similar to existing bus | ||
22 | based device drivers. The driver registers itself as an MEI CL bus driver through | ||
23 | the mei_cl_driver structure: | ||
24 | |||
25 | struct mei_cl_driver { | ||
26 | struct device_driver driver; | ||
27 | const char *name; | ||
28 | |||
29 | const struct mei_cl_device_id *id_table; | ||
30 | |||
31 | int (*probe)(struct mei_cl_device *dev, const struct mei_cl_id *id); | ||
32 | int (*remove)(struct mei_cl_device *dev); | ||
33 | }; | ||
34 | |||
35 | struct mei_cl_id { | ||
36 | char name[MEI_NAME_SIZE]; | ||
37 | kernel_ulong_t driver_info; | ||
38 | }; | ||
39 | |||
40 | The mei_cl_id structure allows the driver to bind itself against a device name. | ||
41 | |||
42 | To actually register a driver on the ME Client bus one must call the mei_cl_add_driver() | ||
43 | API. This is typically called at module init time. | ||
44 | |||
45 | Once registered on the ME Client bus, a driver will typically try to do some I/O on | ||
46 | this bus and this should be done through the mei_cl_send() and mei_cl_recv() | ||
47 | routines. The latter is synchronous (blocks and sleeps until data shows up). | ||
48 | In order for drivers to be notified of pending events waiting for them (e.g. | ||
49 | an Rx event) they can register an event handler through the | ||
50 | mei_cl_register_event_cb() routine. Currently only the MEI_EVENT_RX event | ||
51 | will trigger an event handler call and the driver implementation is supposed | ||
52 | to call mei_recv() from the event handler in order to fetch the pending | ||
53 | received buffers. | ||
54 | |||
55 | |||
56 | Example | ||
57 | ======= | ||
58 | As a theoretical example let's pretend the ME comes with a "contact" NFC IP. | ||
59 | The driver init and exit routines for this device would look like: | ||
60 | |||
61 | #define CONTACT_DRIVER_NAME "contact" | ||
62 | |||
63 | static struct mei_cl_device_id contact_mei_cl_tbl[] = { | ||
64 | { CONTACT_DRIVER_NAME, }, | ||
65 | |||
66 | /* required last entry */ | ||
67 | { } | ||
68 | }; | ||
69 | MODULE_DEVICE_TABLE(mei_cl, contact_mei_cl_tbl); | ||
70 | |||
71 | static struct mei_cl_driver contact_driver = { | ||
72 | .id_table = contact_mei_tbl, | ||
73 | .name = CONTACT_DRIVER_NAME, | ||
74 | |||
75 | .probe = contact_probe, | ||
76 | .remove = contact_remove, | ||
77 | }; | ||
78 | |||
79 | static int contact_init(void) | ||
80 | { | ||
81 | int r; | ||
82 | |||
83 | r = mei_cl_driver_register(&contact_driver); | ||
84 | if (r) { | ||
85 | pr_err(CONTACT_DRIVER_NAME ": driver registration failed\n"); | ||
86 | return r; | ||
87 | } | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static void __exit contact_exit(void) | ||
93 | { | ||
94 | mei_cl_driver_unregister(&contact_driver); | ||
95 | } | ||
96 | |||
97 | module_init(contact_init); | ||
98 | module_exit(contact_exit); | ||
99 | |||
100 | And the driver's simplified probe routine would look like that: | ||
101 | |||
102 | int contact_probe(struct mei_cl_device *dev, struct mei_cl_device_id *id) | ||
103 | { | ||
104 | struct contact_driver *contact; | ||
105 | |||
106 | [...] | ||
107 | mei_cl_register_event_cb(dev, contact_event_cb, contact); | ||
108 | |||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | In the probe routine the driver basically registers an ME bus event handler | ||
113 | which is as close as it can get to registering a threaded IRQ handler. | ||
114 | The handler implementation will typically call some I/O routine depending on | ||
115 | the pending events: | ||
116 | |||
117 | #define MAX_NFC_PAYLOAD 128 | ||
118 | |||
119 | static void contact_event_cb(struct mei_cl_device *dev, u32 events, | ||
120 | void *context) | ||
121 | { | ||
122 | struct contact_driver *contact = context; | ||
123 | |||
124 | if (events & BIT(MEI_EVENT_RX)) { | ||
125 | u8 payload[MAX_NFC_PAYLOAD]; | ||
126 | int payload_size; | ||
127 | |||
128 | payload_size = mei_recv(dev, payload, MAX_NFC_PAYLOAD); | ||
129 | if (payload_size <= 0) | ||
130 | return; | ||
131 | |||
132 | /* Hook to the NFC subsystem */ | ||
133 | nfc_hci_recv_frame(contact->hdev, payload, payload_size); | ||
134 | } | ||
135 | } | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 74e58a4d035b..d8e6e8cadead 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -1031,6 +1031,7 @@ F: drivers/mmc/host/msm_sdcc.h | |||
1031 | F: drivers/tty/serial/msm_serial.h | 1031 | F: drivers/tty/serial/msm_serial.h |
1032 | F: drivers/tty/serial/msm_serial.c | 1032 | F: drivers/tty/serial/msm_serial.c |
1033 | F: drivers/*/pm8???-* | 1033 | F: drivers/*/pm8???-* |
1034 | F: drivers/ssbi/ | ||
1034 | F: include/linux/mfd/pm8xxx/ | 1035 | F: include/linux/mfd/pm8xxx/ |
1035 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/davidb/linux-msm.git | 1036 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/davidb/linux-msm.git |
1036 | S: Maintained | 1037 | S: Maintained |
diff --git a/arch/arm/boot/dts/msm8660-surf.dts b/arch/arm/boot/dts/msm8660-surf.dts index 31f2157cd7d7..67f8670c4d6a 100644 --- a/arch/arm/boot/dts/msm8660-surf.dts +++ b/arch/arm/boot/dts/msm8660-surf.dts | |||
@@ -38,4 +38,10 @@ | |||
38 | <0x19c00000 0x1000>; | 38 | <0x19c00000 0x1000>; |
39 | interrupts = <0 195 0x0>; | 39 | interrupts = <0 195 0x0>; |
40 | }; | 40 | }; |
41 | |||
42 | qcom,ssbi@500000 { | ||
43 | compatible = "qcom,ssbi"; | ||
44 | reg = <0x500000 0x1000>; | ||
45 | qcom,controller-type = "pmic-arbiter"; | ||
46 | }; | ||
41 | }; | 47 | }; |
diff --git a/arch/arm/boot/dts/msm8960-cdp.dts b/arch/arm/boot/dts/msm8960-cdp.dts index 9e621b5ad3dd..c9b09a813a4b 100644 --- a/arch/arm/boot/dts/msm8960-cdp.dts +++ b/arch/arm/boot/dts/msm8960-cdp.dts | |||
@@ -38,4 +38,10 @@ | |||
38 | <0x16400000 0x1000>; | 38 | <0x16400000 0x1000>; |
39 | interrupts = <0 154 0x0>; | 39 | interrupts = <0 154 0x0>; |
40 | }; | 40 | }; |
41 | |||
42 | qcom,ssbi@500000 { | ||
43 | compatible = "qcom,ssbi"; | ||
44 | reg = <0x500000 0x1000>; | ||
45 | qcom,controller-type = "pmic-arbiter"; | ||
46 | }; | ||
41 | }; | 47 | }; |
diff --git a/drivers/Kconfig b/drivers/Kconfig index 202fa6d051b9..78a956e286e6 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig | |||
@@ -52,6 +52,8 @@ source "drivers/i2c/Kconfig" | |||
52 | 52 | ||
53 | source "drivers/spi/Kconfig" | 53 | source "drivers/spi/Kconfig" |
54 | 54 | ||
55 | source "drivers/ssbi/Kconfig" | ||
56 | |||
55 | source "drivers/hsi/Kconfig" | 57 | source "drivers/hsi/Kconfig" |
56 | 58 | ||
57 | source "drivers/pps/Kconfig" | 59 | source "drivers/pps/Kconfig" |
diff --git a/drivers/Makefile b/drivers/Makefile index dce39a95fa71..4865ed24708a 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -114,6 +114,7 @@ obj-y += firmware/ | |||
114 | obj-$(CONFIG_CRYPTO) += crypto/ | 114 | obj-$(CONFIG_CRYPTO) += crypto/ |
115 | obj-$(CONFIG_SUPERH) += sh/ | 115 | obj-$(CONFIG_SUPERH) += sh/ |
116 | obj-$(CONFIG_ARCH_SHMOBILE) += sh/ | 116 | obj-$(CONFIG_ARCH_SHMOBILE) += sh/ |
117 | obj-$(CONFIG_SSBI) += ssbi/ | ||
117 | ifndef CONFIG_ARCH_USES_GETTIMEOFFSET | 118 | ifndef CONFIG_ARCH_USES_GETTIMEOFFSET |
118 | obj-y += clocksource/ | 119 | obj-y += clocksource/ |
119 | endif | 120 | endif |
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 958238dda8fc..40254f4df584 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -387,21 +387,9 @@ static struct pcmcia_driver pcmcia_driver = { | |||
387 | .probe = pcmcia_init_one, | 387 | .probe = pcmcia_init_one, |
388 | .remove = pcmcia_remove_one, | 388 | .remove = pcmcia_remove_one, |
389 | }; | 389 | }; |
390 | 390 | module_pcmcia_driver(pcmcia_driver); | |
391 | static int __init pcmcia_init(void) | ||
392 | { | ||
393 | return pcmcia_register_driver(&pcmcia_driver); | ||
394 | } | ||
395 | |||
396 | static void __exit pcmcia_exit(void) | ||
397 | { | ||
398 | pcmcia_unregister_driver(&pcmcia_driver); | ||
399 | } | ||
400 | 391 | ||
401 | MODULE_AUTHOR("Alan Cox"); | 392 | MODULE_AUTHOR("Alan Cox"); |
402 | MODULE_DESCRIPTION("low-level driver for PCMCIA ATA"); | 393 | MODULE_DESCRIPTION("low-level driver for PCMCIA ATA"); |
403 | MODULE_LICENSE("GPL"); | 394 | MODULE_LICENSE("GPL"); |
404 | MODULE_VERSION(DRV_VERSION); | 395 | MODULE_VERSION(DRV_VERSION); |
405 | |||
406 | module_init(pcmcia_init); | ||
407 | module_exit(pcmcia_exit); | ||
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 0d26851d6e49..6c3e3d43c718 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c | |||
@@ -934,17 +934,4 @@ static struct pcmcia_driver bluecard_driver = { | |||
934 | .remove = bluecard_detach, | 934 | .remove = bluecard_detach, |
935 | .id_table = bluecard_ids, | 935 | .id_table = bluecard_ids, |
936 | }; | 936 | }; |
937 | 937 | module_pcmcia_driver(bluecard_driver); | |
938 | static int __init init_bluecard_cs(void) | ||
939 | { | ||
940 | return pcmcia_register_driver(&bluecard_driver); | ||
941 | } | ||
942 | |||
943 | |||
944 | static void __exit exit_bluecard_cs(void) | ||
945 | { | ||
946 | pcmcia_unregister_driver(&bluecard_driver); | ||
947 | } | ||
948 | |||
949 | module_init(init_bluecard_cs); | ||
950 | module_exit(exit_bluecard_cs); | ||
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 7ffd3f407144..a1aaa3ba2a4b 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -760,17 +760,4 @@ static struct pcmcia_driver bt3c_driver = { | |||
760 | .remove = bt3c_detach, | 760 | .remove = bt3c_detach, |
761 | .id_table = bt3c_ids, | 761 | .id_table = bt3c_ids, |
762 | }; | 762 | }; |
763 | 763 | module_pcmcia_driver(bt3c_driver); | |
764 | static int __init init_bt3c_cs(void) | ||
765 | { | ||
766 | return pcmcia_register_driver(&bt3c_driver); | ||
767 | } | ||
768 | |||
769 | |||
770 | static void __exit exit_bt3c_cs(void) | ||
771 | { | ||
772 | pcmcia_unregister_driver(&bt3c_driver); | ||
773 | } | ||
774 | |||
775 | module_init(init_bt3c_cs); | ||
776 | module_exit(exit_bt3c_cs); | ||
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 35a553a90616..beb262f2dc4d 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c | |||
@@ -688,17 +688,4 @@ static struct pcmcia_driver btuart_driver = { | |||
688 | .remove = btuart_detach, | 688 | .remove = btuart_detach, |
689 | .id_table = btuart_ids, | 689 | .id_table = btuart_ids, |
690 | }; | 690 | }; |
691 | 691 | module_pcmcia_driver(btuart_driver); | |
692 | static int __init init_btuart_cs(void) | ||
693 | { | ||
694 | return pcmcia_register_driver(&btuart_driver); | ||
695 | } | ||
696 | |||
697 | |||
698 | static void __exit exit_btuart_cs(void) | ||
699 | { | ||
700 | pcmcia_unregister_driver(&btuart_driver); | ||
701 | } | ||
702 | |||
703 | module_init(init_btuart_cs); | ||
704 | module_exit(exit_btuart_cs); | ||
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 036cb366fe6e..33f3a6950c0e 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c | |||
@@ -628,17 +628,4 @@ static struct pcmcia_driver dtl1_driver = { | |||
628 | .remove = dtl1_detach, | 628 | .remove = dtl1_detach, |
629 | .id_table = dtl1_ids, | 629 | .id_table = dtl1_ids, |
630 | }; | 630 | }; |
631 | 631 | module_pcmcia_driver(dtl1_driver); | |
632 | static int __init init_dtl1_cs(void) | ||
633 | { | ||
634 | return pcmcia_register_driver(&dtl1_driver); | ||
635 | } | ||
636 | |||
637 | |||
638 | static void __exit exit_dtl1_cs(void) | ||
639 | { | ||
640 | pcmcia_unregister_driver(&dtl1_driver); | ||
641 | } | ||
642 | |||
643 | module_init(init_dtl1_cs); | ||
644 | module_exit(exit_dtl1_cs); | ||
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c index 25373df1dcf8..974321a2508d 100644 --- a/drivers/char/applicom.c +++ b/drivers/char/applicom.c | |||
@@ -804,8 +804,8 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
804 | 804 | ||
805 | printk(KERN_INFO "Prom version board %d ....... V%d.%d %s", | 805 | printk(KERN_INFO "Prom version board %d ....... V%d.%d %s", |
806 | i+1, | 806 | i+1, |
807 | (int)(readb(apbs[IndexCard].RamIO + VERS) >> 4), | 807 | (int)(readb(apbs[i].RamIO + VERS) >> 4), |
808 | (int)(readb(apbs[IndexCard].RamIO + VERS) & 0xF), | 808 | (int)(readb(apbs[i].RamIO + VERS) & 0xF), |
809 | boardname); | 809 | boardname); |
810 | 810 | ||
811 | 811 | ||
diff --git a/drivers/char/hw_random/mxc-rnga.c b/drivers/char/hw_random/mxc-rnga.c index f05d85713fd3..895d0b8fb9ab 100644 --- a/drivers/char/hw_random/mxc-rnga.c +++ b/drivers/char/hw_random/mxc-rnga.c | |||
@@ -228,18 +228,7 @@ static struct platform_driver mxc_rnga_driver = { | |||
228 | .remove = __exit_p(mxc_rnga_remove), | 228 | .remove = __exit_p(mxc_rnga_remove), |
229 | }; | 229 | }; |
230 | 230 | ||
231 | static int __init mod_init(void) | 231 | module_platform_driver_probe(mxc_rnga_driver, mxc_rnga_probe); |
232 | { | ||
233 | return platform_driver_probe(&mxc_rnga_driver, mxc_rnga_probe); | ||
234 | } | ||
235 | |||
236 | static void __exit mod_exit(void) | ||
237 | { | ||
238 | platform_driver_unregister(&mxc_rnga_driver); | ||
239 | } | ||
240 | |||
241 | module_init(mod_init); | ||
242 | module_exit(mod_exit); | ||
243 | 232 | ||
244 | MODULE_AUTHOR("Freescale Semiconductor, Inc."); | 233 | MODULE_AUTHOR("Freescale Semiconductor, Inc."); |
245 | MODULE_DESCRIPTION("H/W RNGA driver for i.MX"); | 234 | MODULE_DESCRIPTION("H/W RNGA driver for i.MX"); |
diff --git a/drivers/char/hw_random/tx4939-rng.c b/drivers/char/hw_random/tx4939-rng.c index 30991989d65b..d34a24a0d484 100644 --- a/drivers/char/hw_random/tx4939-rng.c +++ b/drivers/char/hw_random/tx4939-rng.c | |||
@@ -166,18 +166,7 @@ static struct platform_driver tx4939_rng_driver = { | |||
166 | .remove = tx4939_rng_remove, | 166 | .remove = tx4939_rng_remove, |
167 | }; | 167 | }; |
168 | 168 | ||
169 | static int __init tx4939rng_init(void) | 169 | module_platform_driver_probe(tx4939_rng_driver, tx4939_rng_probe); |
170 | { | ||
171 | return platform_driver_probe(&tx4939_rng_driver, tx4939_rng_probe); | ||
172 | } | ||
173 | |||
174 | static void __exit tx4939rng_exit(void) | ||
175 | { | ||
176 | platform_driver_unregister(&tx4939_rng_driver); | ||
177 | } | ||
178 | |||
179 | module_init(tx4939rng_init); | ||
180 | module_exit(tx4939rng_exit); | ||
181 | 170 | ||
182 | MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for TX4939"); | 171 | MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for TX4939"); |
183 | MODULE_LICENSE("GPL"); | 172 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c index 3b22a606f79d..2e2036e940fc 100644 --- a/drivers/char/tile-srom.c +++ b/drivers/char/tile-srom.c | |||
@@ -371,7 +371,7 @@ static int srom_setup_minor(struct srom_dev *srom, int index) | |||
371 | 371 | ||
372 | dev = device_create(srom_class, &platform_bus, | 372 | dev = device_create(srom_class, &platform_bus, |
373 | MKDEV(srom_major, index), srom, "%d", index); | 373 | MKDEV(srom_major, index), srom, "%d", index); |
374 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; | 374 | return PTR_RET(dev); |
375 | } | 375 | } |
376 | 376 | ||
377 | /** srom_init() - Initialize the driver's module. */ | 377 | /** srom_init() - Initialize the driver's module. */ |
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index dc357a4051f6..7a1b4a7791ba 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c | |||
@@ -33,12 +33,17 @@ | |||
33 | #include <linux/mfd/arizona/pdata.h> | 33 | #include <linux/mfd/arizona/pdata.h> |
34 | #include <linux/mfd/arizona/registers.h> | 34 | #include <linux/mfd/arizona/registers.h> |
35 | 35 | ||
36 | #define ARIZONA_NUM_BUTTONS 6 | 36 | #define ARIZONA_MAX_MICD_RANGE 8 |
37 | 37 | ||
38 | #define ARIZONA_ACCDET_MODE_MIC 0 | 38 | #define ARIZONA_ACCDET_MODE_MIC 0 |
39 | #define ARIZONA_ACCDET_MODE_HPL 1 | 39 | #define ARIZONA_ACCDET_MODE_HPL 1 |
40 | #define ARIZONA_ACCDET_MODE_HPR 2 | 40 | #define ARIZONA_ACCDET_MODE_HPR 2 |
41 | 41 | ||
42 | #define ARIZONA_HPDET_MAX 10000 | ||
43 | |||
44 | #define HPDET_DEBOUNCE 500 | ||
45 | #define DEFAULT_MICD_TIMEOUT 2000 | ||
46 | |||
42 | struct arizona_extcon_info { | 47 | struct arizona_extcon_info { |
43 | struct device *dev; | 48 | struct device *dev; |
44 | struct arizona *arizona; | 49 | struct arizona *arizona; |
@@ -46,17 +51,27 @@ struct arizona_extcon_info { | |||
46 | struct regulator *micvdd; | 51 | struct regulator *micvdd; |
47 | struct input_dev *input; | 52 | struct input_dev *input; |
48 | 53 | ||
54 | u16 last_jackdet; | ||
55 | |||
49 | int micd_mode; | 56 | int micd_mode; |
50 | const struct arizona_micd_config *micd_modes; | 57 | const struct arizona_micd_config *micd_modes; |
51 | int micd_num_modes; | 58 | int micd_num_modes; |
52 | 59 | ||
60 | const struct arizona_micd_range *micd_ranges; | ||
61 | int num_micd_ranges; | ||
62 | |||
63 | int micd_timeout; | ||
64 | |||
53 | bool micd_reva; | 65 | bool micd_reva; |
54 | bool micd_clamp; | 66 | bool micd_clamp; |
55 | 67 | ||
56 | struct delayed_work hpdet_work; | 68 | struct delayed_work hpdet_work; |
69 | struct delayed_work micd_detect_work; | ||
70 | struct delayed_work micd_timeout_work; | ||
57 | 71 | ||
58 | bool hpdet_active; | 72 | bool hpdet_active; |
59 | bool hpdet_done; | 73 | bool hpdet_done; |
74 | bool hpdet_retried; | ||
60 | 75 | ||
61 | int num_hpdet_res; | 76 | int num_hpdet_res; |
62 | unsigned int hpdet_res[3]; | 77 | unsigned int hpdet_res[3]; |
@@ -71,20 +86,25 @@ struct arizona_extcon_info { | |||
71 | }; | 86 | }; |
72 | 87 | ||
73 | static const struct arizona_micd_config micd_default_modes[] = { | 88 | static const struct arizona_micd_config micd_default_modes[] = { |
74 | { 0, 2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 }, | ||
75 | { ARIZONA_ACCDET_SRC, 1 << ARIZONA_MICD_BIAS_SRC_SHIFT, 0 }, | 89 | { ARIZONA_ACCDET_SRC, 1 << ARIZONA_MICD_BIAS_SRC_SHIFT, 0 }, |
90 | { 0, 2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 }, | ||
76 | }; | 91 | }; |
77 | 92 | ||
78 | static struct { | 93 | static const struct arizona_micd_range micd_default_ranges[] = { |
79 | u16 status; | 94 | { .max = 11, .key = BTN_0 }, |
80 | int report; | 95 | { .max = 28, .key = BTN_1 }, |
81 | } arizona_lvl_to_key[ARIZONA_NUM_BUTTONS] = { | 96 | { .max = 54, .key = BTN_2 }, |
82 | { 0x1, BTN_0 }, | 97 | { .max = 100, .key = BTN_3 }, |
83 | { 0x2, BTN_1 }, | 98 | { .max = 186, .key = BTN_4 }, |
84 | { 0x4, BTN_2 }, | 99 | { .max = 430, .key = BTN_5 }, |
85 | { 0x8, BTN_3 }, | 100 | }; |
86 | { 0x10, BTN_4 }, | 101 | |
87 | { 0x20, BTN_5 }, | 102 | static const int arizona_micd_levels[] = { |
103 | 3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 34, 36, 39, 41, 44, 46, | ||
104 | 49, 52, 54, 57, 60, 62, 65, 67, 70, 73, 75, 78, 81, 83, 89, 94, 100, | ||
105 | 105, 111, 116, 122, 127, 139, 150, 161, 173, 186, 196, 209, 220, 245, | ||
106 | 270, 295, 321, 348, 375, 402, 430, 489, 550, 614, 681, 752, 903, 1071, | ||
107 | 1257, | ||
88 | }; | 108 | }; |
89 | 109 | ||
90 | #define ARIZONA_CABLE_MECHANICAL 0 | 110 | #define ARIZONA_CABLE_MECHANICAL 0 |
@@ -100,10 +120,63 @@ static const char *arizona_cable[] = { | |||
100 | NULL, | 120 | NULL, |
101 | }; | 121 | }; |
102 | 122 | ||
123 | static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info); | ||
124 | |||
125 | static void arizona_extcon_do_magic(struct arizona_extcon_info *info, | ||
126 | unsigned int magic) | ||
127 | { | ||
128 | struct arizona *arizona = info->arizona; | ||
129 | int ret; | ||
130 | |||
131 | mutex_lock(&arizona->dapm->card->dapm_mutex); | ||
132 | |||
133 | arizona->hpdet_magic = magic; | ||
134 | |||
135 | /* Keep the HP output stages disabled while doing the magic */ | ||
136 | if (magic) { | ||
137 | ret = regmap_update_bits(arizona->regmap, | ||
138 | ARIZONA_OUTPUT_ENABLES_1, | ||
139 | ARIZONA_OUT1L_ENA | | ||
140 | ARIZONA_OUT1R_ENA, 0); | ||
141 | if (ret != 0) | ||
142 | dev_warn(arizona->dev, | ||
143 | "Failed to disable headphone outputs: %d\n", | ||
144 | ret); | ||
145 | } | ||
146 | |||
147 | ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, | ||
148 | magic); | ||
149 | if (ret != 0) | ||
150 | dev_warn(arizona->dev, "Failed to do magic: %d\n", | ||
151 | ret); | ||
152 | |||
153 | ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, | ||
154 | magic); | ||
155 | if (ret != 0) | ||
156 | dev_warn(arizona->dev, "Failed to do magic: %d\n", | ||
157 | ret); | ||
158 | |||
159 | /* Restore the desired state while not doing the magic */ | ||
160 | if (!magic) { | ||
161 | ret = regmap_update_bits(arizona->regmap, | ||
162 | ARIZONA_OUTPUT_ENABLES_1, | ||
163 | ARIZONA_OUT1L_ENA | | ||
164 | ARIZONA_OUT1R_ENA, arizona->hp_ena); | ||
165 | if (ret != 0) | ||
166 | dev_warn(arizona->dev, | ||
167 | "Failed to restore headphone outputs: %d\n", | ||
168 | ret); | ||
169 | } | ||
170 | |||
171 | mutex_unlock(&arizona->dapm->card->dapm_mutex); | ||
172 | } | ||
173 | |||
103 | static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode) | 174 | static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode) |
104 | { | 175 | { |
105 | struct arizona *arizona = info->arizona; | 176 | struct arizona *arizona = info->arizona; |
106 | 177 | ||
178 | mode %= info->micd_num_modes; | ||
179 | |||
107 | if (arizona->pdata.micd_pol_gpio > 0) | 180 | if (arizona->pdata.micd_pol_gpio > 0) |
108 | gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio, | 181 | gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio, |
109 | info->micd_modes[mode].gpio); | 182 | info->micd_modes[mode].gpio); |
@@ -330,7 +403,7 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info) | |||
330 | /* If we go out of range report top of range */ | 403 | /* If we go out of range report top of range */ |
331 | if (val < 100 || val > 0x3fb) { | 404 | if (val < 100 || val > 0x3fb) { |
332 | dev_dbg(arizona->dev, "Measurement out of range\n"); | 405 | dev_dbg(arizona->dev, "Measurement out of range\n"); |
333 | return 10000; | 406 | return ARIZONA_HPDET_MAX; |
334 | } | 407 | } |
335 | 408 | ||
336 | dev_dbg(arizona->dev, "HPDET read %d in range %d\n", | 409 | dev_dbg(arizona->dev, "HPDET read %d in range %d\n", |
@@ -391,7 +464,8 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info) | |||
391 | return val; | 464 | return val; |
392 | } | 465 | } |
393 | 466 | ||
394 | static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading) | 467 | static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading, |
468 | bool *mic) | ||
395 | { | 469 | { |
396 | struct arizona *arizona = info->arizona; | 470 | struct arizona *arizona = info->arizona; |
397 | int id_gpio = arizona->pdata.hpdet_id_gpio; | 471 | int id_gpio = arizona->pdata.hpdet_id_gpio; |
@@ -403,32 +477,8 @@ static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading) | |||
403 | if (arizona->pdata.hpdet_acc_id) { | 477 | if (arizona->pdata.hpdet_acc_id) { |
404 | info->hpdet_res[info->num_hpdet_res++] = *reading; | 478 | info->hpdet_res[info->num_hpdet_res++] = *reading; |
405 | 479 | ||
406 | /* | ||
407 | * If the impedence is too high don't measure the | ||
408 | * second ground. | ||
409 | */ | ||
410 | if (info->num_hpdet_res == 1 && *reading >= 45) { | ||
411 | dev_dbg(arizona->dev, "Skipping ground flip\n"); | ||
412 | info->hpdet_res[info->num_hpdet_res++] = *reading; | ||
413 | } | ||
414 | |||
415 | if (info->num_hpdet_res == 1) { | ||
416 | dev_dbg(arizona->dev, "Flipping ground\n"); | ||
417 | |||
418 | regmap_update_bits(arizona->regmap, | ||
419 | ARIZONA_ACCESSORY_DETECT_MODE_1, | ||
420 | ARIZONA_ACCDET_SRC, | ||
421 | ~info->micd_modes[0].src); | ||
422 | |||
423 | regmap_update_bits(arizona->regmap, | ||
424 | ARIZONA_HEADPHONE_DETECT_1, | ||
425 | ARIZONA_HP_POLL, ARIZONA_HP_POLL); | ||
426 | return -EAGAIN; | ||
427 | } | ||
428 | |||
429 | /* Only check the mic directly if we didn't already ID it */ | 480 | /* Only check the mic directly if we didn't already ID it */ |
430 | if (id_gpio && info->num_hpdet_res == 2 && | 481 | if (id_gpio && info->num_hpdet_res == 1) { |
431 | !((info->hpdet_res[0] > info->hpdet_res[1] * 2))) { | ||
432 | dev_dbg(arizona->dev, "Measuring mic\n"); | 482 | dev_dbg(arizona->dev, "Measuring mic\n"); |
433 | 483 | ||
434 | regmap_update_bits(arizona->regmap, | 484 | regmap_update_bits(arizona->regmap, |
@@ -447,22 +497,28 @@ static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading) | |||
447 | } | 497 | } |
448 | 498 | ||
449 | /* OK, got both. Now, compare... */ | 499 | /* OK, got both. Now, compare... */ |
450 | dev_dbg(arizona->dev, "HPDET measured %d %d %d\n", | 500 | dev_dbg(arizona->dev, "HPDET measured %d %d\n", |
451 | info->hpdet_res[0], info->hpdet_res[1], | 501 | info->hpdet_res[0], info->hpdet_res[1]); |
452 | info->hpdet_res[2]); | ||
453 | |||
454 | 502 | ||
455 | /* Take the headphone impedance for the main report */ | 503 | /* Take the headphone impedance for the main report */ |
456 | *reading = info->hpdet_res[0]; | 504 | *reading = info->hpdet_res[0]; |
457 | 505 | ||
506 | /* Sometimes we get false readings due to slow insert */ | ||
507 | if (*reading >= ARIZONA_HPDET_MAX && !info->hpdet_retried) { | ||
508 | dev_dbg(arizona->dev, "Retrying high impedance\n"); | ||
509 | info->num_hpdet_res = 0; | ||
510 | info->hpdet_retried = true; | ||
511 | arizona_start_hpdet_acc_id(info); | ||
512 | pm_runtime_put(info->dev); | ||
513 | return -EAGAIN; | ||
514 | } | ||
515 | |||
458 | /* | 516 | /* |
459 | * Either the two grounds measure differently or we | 517 | * If we measure the mic as |
460 | * measure the mic as high impedance. | ||
461 | */ | 518 | */ |
462 | if ((info->hpdet_res[0] > info->hpdet_res[1] * 2) || | 519 | if (!id_gpio || info->hpdet_res[1] > 50) { |
463 | (id_gpio && info->hpdet_res[2] > 10)) { | ||
464 | dev_dbg(arizona->dev, "Detected mic\n"); | 520 | dev_dbg(arizona->dev, "Detected mic\n"); |
465 | info->mic = true; | 521 | *mic = true; |
466 | info->detecting = true; | 522 | info->detecting = true; |
467 | } else { | 523 | } else { |
468 | dev_dbg(arizona->dev, "Detected headphone\n"); | 524 | dev_dbg(arizona->dev, "Detected headphone\n"); |
@@ -484,8 +540,8 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data) | |||
484 | struct arizona *arizona = info->arizona; | 540 | struct arizona *arizona = info->arizona; |
485 | int id_gpio = arizona->pdata.hpdet_id_gpio; | 541 | int id_gpio = arizona->pdata.hpdet_id_gpio; |
486 | int report = ARIZONA_CABLE_HEADPHONE; | 542 | int report = ARIZONA_CABLE_HEADPHONE; |
487 | unsigned int val; | ||
488 | int ret, reading; | 543 | int ret, reading; |
544 | bool mic = false; | ||
489 | 545 | ||
490 | mutex_lock(&info->lock); | 546 | mutex_lock(&info->lock); |
491 | 547 | ||
@@ -521,7 +577,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data) | |||
521 | ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL, | 577 | ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL, |
522 | 0); | 578 | 0); |
523 | 579 | ||
524 | ret = arizona_hpdet_do_id(info, &reading); | 580 | ret = arizona_hpdet_do_id(info, &reading, &mic); |
525 | if (ret == -EAGAIN) { | 581 | if (ret == -EAGAIN) { |
526 | goto out; | 582 | goto out; |
527 | } else if (ret < 0) { | 583 | } else if (ret < 0) { |
@@ -539,28 +595,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data) | |||
539 | dev_err(arizona->dev, "Failed to report HP/line: %d\n", | 595 | dev_err(arizona->dev, "Failed to report HP/line: %d\n", |
540 | ret); | 596 | ret); |
541 | 597 | ||
542 | mutex_lock(&arizona->dapm->card->dapm_mutex); | 598 | arizona_extcon_do_magic(info, 0); |
543 | |||
544 | ret = regmap_read(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, &val); | ||
545 | if (ret != 0) { | ||
546 | dev_err(arizona->dev, "Failed to read output enables: %d\n", | ||
547 | ret); | ||
548 | val = 0; | ||
549 | } | ||
550 | |||
551 | if (!(val & (ARIZONA_OUT1L_ENA | ARIZONA_OUT1R_ENA))) { | ||
552 | ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0); | ||
553 | if (ret != 0) | ||
554 | dev_warn(arizona->dev, "Failed to undo magic: %d\n", | ||
555 | ret); | ||
556 | |||
557 | ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0); | ||
558 | if (ret != 0) | ||
559 | dev_warn(arizona->dev, "Failed to undo magic: %d\n", | ||
560 | ret); | ||
561 | } | ||
562 | |||
563 | mutex_unlock(&arizona->dapm->card->dapm_mutex); | ||
564 | 599 | ||
565 | done: | 600 | done: |
566 | if (id_gpio) | 601 | if (id_gpio) |
@@ -572,7 +607,7 @@ done: | |||
572 | ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC); | 607 | ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC); |
573 | 608 | ||
574 | /* If we have a mic then reenable MICDET */ | 609 | /* If we have a mic then reenable MICDET */ |
575 | if (info->mic) | 610 | if (mic || info->mic) |
576 | arizona_start_mic(info); | 611 | arizona_start_mic(info); |
577 | 612 | ||
578 | if (info->hpdet_active) { | 613 | if (info->hpdet_active) { |
@@ -606,13 +641,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info) | |||
606 | if (info->mic) | 641 | if (info->mic) |
607 | arizona_stop_mic(info); | 642 | arizona_stop_mic(info); |
608 | 643 | ||
609 | ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0x4000); | 644 | arizona_extcon_do_magic(info, 0x4000); |
610 | if (ret != 0) | ||
611 | dev_warn(arizona->dev, "Failed to do magic: %d\n", ret); | ||
612 | |||
613 | ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0x4000); | ||
614 | if (ret != 0) | ||
615 | dev_warn(arizona->dev, "Failed to do magic: %d\n", ret); | ||
616 | 645 | ||
617 | ret = regmap_update_bits(arizona->regmap, | 646 | ret = regmap_update_bits(arizona->regmap, |
618 | ARIZONA_ACCESSORY_DETECT_MODE_1, | 647 | ARIZONA_ACCESSORY_DETECT_MODE_1, |
@@ -653,7 +682,8 @@ err: | |||
653 | static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info) | 682 | static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info) |
654 | { | 683 | { |
655 | struct arizona *arizona = info->arizona; | 684 | struct arizona *arizona = info->arizona; |
656 | unsigned int val; | 685 | int hp_reading = 32; |
686 | bool mic; | ||
657 | int ret; | 687 | int ret; |
658 | 688 | ||
659 | dev_dbg(arizona->dev, "Starting identification via HPDET\n"); | 689 | dev_dbg(arizona->dev, "Starting identification via HPDET\n"); |
@@ -663,32 +693,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info) | |||
663 | 693 | ||
664 | info->hpdet_active = true; | 694 | info->hpdet_active = true; |
665 | 695 | ||
666 | arizona_extcon_pulse_micbias(info); | 696 | arizona_extcon_do_magic(info, 0x4000); |
667 | |||
668 | mutex_lock(&arizona->dapm->card->dapm_mutex); | ||
669 | |||
670 | ret = regmap_read(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, &val); | ||
671 | if (ret != 0) { | ||
672 | dev_err(arizona->dev, "Failed to read output enables: %d\n", | ||
673 | ret); | ||
674 | val = 0; | ||
675 | } | ||
676 | |||
677 | if (!(val & (ARIZONA_OUT1L_ENA | ARIZONA_OUT1R_ENA))) { | ||
678 | ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, | ||
679 | 0x4000); | ||
680 | if (ret != 0) | ||
681 | dev_warn(arizona->dev, "Failed to do magic: %d\n", | ||
682 | ret); | ||
683 | |||
684 | ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, | ||
685 | 0x4000); | ||
686 | if (ret != 0) | ||
687 | dev_warn(arizona->dev, "Failed to do magic: %d\n", | ||
688 | ret); | ||
689 | } | ||
690 | |||
691 | mutex_unlock(&arizona->dapm->card->dapm_mutex); | ||
692 | 697 | ||
693 | ret = regmap_update_bits(arizona->regmap, | 698 | ret = regmap_update_bits(arizona->regmap, |
694 | ARIZONA_ACCESSORY_DETECT_MODE_1, | 699 | ARIZONA_ACCESSORY_DETECT_MODE_1, |
@@ -700,12 +705,18 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info) | |||
700 | goto err; | 705 | goto err; |
701 | } | 706 | } |
702 | 707 | ||
703 | ret = regmap_update_bits(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1, | 708 | if (arizona->pdata.hpdet_acc_id_line) { |
704 | ARIZONA_HP_POLL, ARIZONA_HP_POLL); | 709 | ret = regmap_update_bits(arizona->regmap, |
705 | if (ret != 0) { | 710 | ARIZONA_HEADPHONE_DETECT_1, |
706 | dev_err(arizona->dev, "Can't start HPDETL measurement: %d\n", | 711 | ARIZONA_HP_POLL, ARIZONA_HP_POLL); |
707 | ret); | 712 | if (ret != 0) { |
708 | goto err; | 713 | dev_err(arizona->dev, |
714 | "Can't start HPDETL measurement: %d\n", | ||
715 | ret); | ||
716 | goto err; | ||
717 | } | ||
718 | } else { | ||
719 | arizona_hpdet_do_id(info, &hp_reading, &mic); | ||
709 | } | 720 | } |
710 | 721 | ||
711 | return; | 722 | return; |
@@ -724,28 +735,58 @@ err: | |||
724 | info->hpdet_active = false; | 735 | info->hpdet_active = false; |
725 | } | 736 | } |
726 | 737 | ||
727 | static irqreturn_t arizona_micdet(int irq, void *data) | 738 | static void arizona_micd_timeout_work(struct work_struct *work) |
728 | { | 739 | { |
729 | struct arizona_extcon_info *info = data; | 740 | struct arizona_extcon_info *info = container_of(work, |
741 | struct arizona_extcon_info, | ||
742 | micd_timeout_work.work); | ||
743 | |||
744 | mutex_lock(&info->lock); | ||
745 | |||
746 | dev_dbg(info->arizona->dev, "MICD timed out, reporting HP\n"); | ||
747 | arizona_identify_headphone(info); | ||
748 | |||
749 | info->detecting = false; | ||
750 | |||
751 | arizona_stop_mic(info); | ||
752 | |||
753 | mutex_unlock(&info->lock); | ||
754 | } | ||
755 | |||
756 | static void arizona_micd_detect(struct work_struct *work) | ||
757 | { | ||
758 | struct arizona_extcon_info *info = container_of(work, | ||
759 | struct arizona_extcon_info, | ||
760 | micd_detect_work.work); | ||
730 | struct arizona *arizona = info->arizona; | 761 | struct arizona *arizona = info->arizona; |
731 | unsigned int val, lvl; | 762 | unsigned int val = 0, lvl; |
732 | int ret, i; | 763 | int ret, i, key; |
764 | |||
765 | cancel_delayed_work_sync(&info->micd_timeout_work); | ||
733 | 766 | ||
734 | mutex_lock(&info->lock); | 767 | mutex_lock(&info->lock); |
735 | 768 | ||
736 | ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); | 769 | for (i = 0; i < 10 && !(val & 0x7fc); i++) { |
737 | if (ret != 0) { | 770 | ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); |
738 | dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret); | 771 | if (ret != 0) { |
739 | mutex_unlock(&info->lock); | 772 | dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret); |
740 | return IRQ_NONE; | 773 | mutex_unlock(&info->lock); |
741 | } | 774 | return; |
775 | } | ||
742 | 776 | ||
743 | dev_dbg(arizona->dev, "MICDET: %x\n", val); | 777 | dev_dbg(arizona->dev, "MICDET: %x\n", val); |
778 | |||
779 | if (!(val & ARIZONA_MICD_VALID)) { | ||
780 | dev_warn(arizona->dev, "Microphone detection state invalid\n"); | ||
781 | mutex_unlock(&info->lock); | ||
782 | return; | ||
783 | } | ||
784 | } | ||
744 | 785 | ||
745 | if (!(val & ARIZONA_MICD_VALID)) { | 786 | if (i == 10 && !(val & 0x7fc)) { |
746 | dev_warn(arizona->dev, "Microphone detection state invalid\n"); | 787 | dev_err(arizona->dev, "Failed to get valid MICDET value\n"); |
747 | mutex_unlock(&info->lock); | 788 | mutex_unlock(&info->lock); |
748 | return IRQ_NONE; | 789 | return; |
749 | } | 790 | } |
750 | 791 | ||
751 | /* Due to jack detect this should never happen */ | 792 | /* Due to jack detect this should never happen */ |
@@ -786,7 +827,7 @@ static irqreturn_t arizona_micdet(int irq, void *data) | |||
786 | * impedence then give up and report headphones. | 827 | * impedence then give up and report headphones. |
787 | */ | 828 | */ |
788 | if (info->detecting && (val & 0x3f8)) { | 829 | if (info->detecting && (val & 0x3f8)) { |
789 | if (info->jack_flips >= info->micd_num_modes) { | 830 | if (info->jack_flips >= info->micd_num_modes * 10) { |
790 | dev_dbg(arizona->dev, "Detected HP/line\n"); | 831 | dev_dbg(arizona->dev, "Detected HP/line\n"); |
791 | arizona_identify_headphone(info); | 832 | arizona_identify_headphone(info); |
792 | 833 | ||
@@ -816,12 +857,17 @@ static irqreturn_t arizona_micdet(int irq, void *data) | |||
816 | lvl = val & ARIZONA_MICD_LVL_MASK; | 857 | lvl = val & ARIZONA_MICD_LVL_MASK; |
817 | lvl >>= ARIZONA_MICD_LVL_SHIFT; | 858 | lvl >>= ARIZONA_MICD_LVL_SHIFT; |
818 | 859 | ||
819 | for (i = 0; i < ARIZONA_NUM_BUTTONS; i++) | 860 | for (i = 0; i < info->num_micd_ranges; i++) |
820 | if (lvl & arizona_lvl_to_key[i].status) | 861 | input_report_key(info->input, |
821 | input_report_key(info->input, | 862 | info->micd_ranges[i].key, 0); |
822 | arizona_lvl_to_key[i].report, | 863 | |
823 | 1); | 864 | WARN_ON(!lvl); |
824 | input_sync(info->input); | 865 | WARN_ON(ffs(lvl) - 1 >= info->num_micd_ranges); |
866 | if (lvl && ffs(lvl) - 1 < info->num_micd_ranges) { | ||
867 | key = info->micd_ranges[ffs(lvl) - 1].key; | ||
868 | input_report_key(info->input, key, 1); | ||
869 | input_sync(info->input); | ||
870 | } | ||
825 | 871 | ||
826 | } else if (info->detecting) { | 872 | } else if (info->detecting) { |
827 | dev_dbg(arizona->dev, "Headphone detected\n"); | 873 | dev_dbg(arizona->dev, "Headphone detected\n"); |
@@ -835,16 +881,41 @@ static irqreturn_t arizona_micdet(int irq, void *data) | |||
835 | } | 881 | } |
836 | } else { | 882 | } else { |
837 | dev_dbg(arizona->dev, "Mic button released\n"); | 883 | dev_dbg(arizona->dev, "Mic button released\n"); |
838 | for (i = 0; i < ARIZONA_NUM_BUTTONS; i++) | 884 | for (i = 0; i < info->num_micd_ranges; i++) |
839 | input_report_key(info->input, | 885 | input_report_key(info->input, |
840 | arizona_lvl_to_key[i].report, 0); | 886 | info->micd_ranges[i].key, 0); |
841 | input_sync(info->input); | 887 | input_sync(info->input); |
842 | arizona_extcon_pulse_micbias(info); | 888 | arizona_extcon_pulse_micbias(info); |
843 | } | 889 | } |
844 | 890 | ||
845 | handled: | 891 | handled: |
892 | if (info->detecting) | ||
893 | schedule_delayed_work(&info->micd_timeout_work, | ||
894 | msecs_to_jiffies(info->micd_timeout)); | ||
895 | |||
846 | pm_runtime_mark_last_busy(info->dev); | 896 | pm_runtime_mark_last_busy(info->dev); |
847 | mutex_unlock(&info->lock); | 897 | mutex_unlock(&info->lock); |
898 | } | ||
899 | |||
900 | static irqreturn_t arizona_micdet(int irq, void *data) | ||
901 | { | ||
902 | struct arizona_extcon_info *info = data; | ||
903 | struct arizona *arizona = info->arizona; | ||
904 | int debounce = arizona->pdata.micd_detect_debounce; | ||
905 | |||
906 | cancel_delayed_work_sync(&info->micd_detect_work); | ||
907 | cancel_delayed_work_sync(&info->micd_timeout_work); | ||
908 | |||
909 | mutex_lock(&info->lock); | ||
910 | if (!info->detecting) | ||
911 | debounce = 0; | ||
912 | mutex_unlock(&info->lock); | ||
913 | |||
914 | if (debounce) | ||
915 | schedule_delayed_work(&info->micd_detect_work, | ||
916 | msecs_to_jiffies(debounce)); | ||
917 | else | ||
918 | arizona_micd_detect(&info->micd_detect_work.work); | ||
848 | 919 | ||
849 | return IRQ_HANDLED; | 920 | return IRQ_HANDLED; |
850 | } | 921 | } |
@@ -865,11 +936,13 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
865 | struct arizona_extcon_info *info = data; | 936 | struct arizona_extcon_info *info = data; |
866 | struct arizona *arizona = info->arizona; | 937 | struct arizona *arizona = info->arizona; |
867 | unsigned int val, present, mask; | 938 | unsigned int val, present, mask; |
939 | bool cancelled_hp, cancelled_mic; | ||
868 | int ret, i; | 940 | int ret, i; |
869 | 941 | ||
870 | pm_runtime_get_sync(info->dev); | 942 | cancelled_hp = cancel_delayed_work_sync(&info->hpdet_work); |
943 | cancelled_mic = cancel_delayed_work_sync(&info->micd_timeout_work); | ||
871 | 944 | ||
872 | cancel_delayed_work_sync(&info->hpdet_work); | 945 | pm_runtime_get_sync(info->dev); |
873 | 946 | ||
874 | mutex_lock(&info->lock); | 947 | mutex_lock(&info->lock); |
875 | 948 | ||
@@ -890,7 +963,22 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
890 | return IRQ_NONE; | 963 | return IRQ_NONE; |
891 | } | 964 | } |
892 | 965 | ||
893 | if ((val & mask) == present) { | 966 | val &= mask; |
967 | if (val == info->last_jackdet) { | ||
968 | dev_dbg(arizona->dev, "Suppressing duplicate JACKDET\n"); | ||
969 | if (cancelled_hp) | ||
970 | schedule_delayed_work(&info->hpdet_work, | ||
971 | msecs_to_jiffies(HPDET_DEBOUNCE)); | ||
972 | |||
973 | if (cancelled_mic) | ||
974 | schedule_delayed_work(&info->micd_timeout_work, | ||
975 | msecs_to_jiffies(info->micd_timeout)); | ||
976 | |||
977 | goto out; | ||
978 | } | ||
979 | info->last_jackdet = val; | ||
980 | |||
981 | if (info->last_jackdet == present) { | ||
894 | dev_dbg(arizona->dev, "Detected jack\n"); | 982 | dev_dbg(arizona->dev, "Detected jack\n"); |
895 | ret = extcon_set_cable_state_(&info->edev, | 983 | ret = extcon_set_cable_state_(&info->edev, |
896 | ARIZONA_CABLE_MECHANICAL, true); | 984 | ARIZONA_CABLE_MECHANICAL, true); |
@@ -907,7 +995,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
907 | arizona_start_mic(info); | 995 | arizona_start_mic(info); |
908 | } else { | 996 | } else { |
909 | schedule_delayed_work(&info->hpdet_work, | 997 | schedule_delayed_work(&info->hpdet_work, |
910 | msecs_to_jiffies(250)); | 998 | msecs_to_jiffies(HPDET_DEBOUNCE)); |
911 | } | 999 | } |
912 | 1000 | ||
913 | regmap_update_bits(arizona->regmap, | 1001 | regmap_update_bits(arizona->regmap, |
@@ -923,10 +1011,11 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
923 | info->hpdet_res[i] = 0; | 1011 | info->hpdet_res[i] = 0; |
924 | info->mic = false; | 1012 | info->mic = false; |
925 | info->hpdet_done = false; | 1013 | info->hpdet_done = false; |
1014 | info->hpdet_retried = false; | ||
926 | 1015 | ||
927 | for (i = 0; i < ARIZONA_NUM_BUTTONS; i++) | 1016 | for (i = 0; i < info->num_micd_ranges; i++) |
928 | input_report_key(info->input, | 1017 | input_report_key(info->input, |
929 | arizona_lvl_to_key[i].report, 0); | 1018 | info->micd_ranges[i].key, 0); |
930 | input_sync(info->input); | 1019 | input_sync(info->input); |
931 | 1020 | ||
932 | ret = extcon_update_state(&info->edev, 0xffffffff, 0); | 1021 | ret = extcon_update_state(&info->edev, 0xffffffff, 0); |
@@ -940,6 +1029,11 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
940 | ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB); | 1029 | ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB); |
941 | } | 1030 | } |
942 | 1031 | ||
1032 | if (arizona->pdata.micd_timeout) | ||
1033 | info->micd_timeout = arizona->pdata.micd_timeout; | ||
1034 | else | ||
1035 | info->micd_timeout = DEFAULT_MICD_TIMEOUT; | ||
1036 | |||
943 | /* Clear trig_sts to make sure DCVDD is not forced up */ | 1037 | /* Clear trig_sts to make sure DCVDD is not forced up */ |
944 | regmap_write(arizona->regmap, ARIZONA_AOD_WKUP_AND_TRIG, | 1038 | regmap_write(arizona->regmap, ARIZONA_AOD_WKUP_AND_TRIG, |
945 | ARIZONA_MICD_CLAMP_FALL_TRIG_STS | | 1039 | ARIZONA_MICD_CLAMP_FALL_TRIG_STS | |
@@ -947,6 +1041,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
947 | ARIZONA_JD1_FALL_TRIG_STS | | 1041 | ARIZONA_JD1_FALL_TRIG_STS | |
948 | ARIZONA_JD1_RISE_TRIG_STS); | 1042 | ARIZONA_JD1_RISE_TRIG_STS); |
949 | 1043 | ||
1044 | out: | ||
950 | mutex_unlock(&info->lock); | 1045 | mutex_unlock(&info->lock); |
951 | 1046 | ||
952 | pm_runtime_mark_last_busy(info->dev); | 1047 | pm_runtime_mark_last_busy(info->dev); |
@@ -955,13 +1050,34 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
955 | return IRQ_HANDLED; | 1050 | return IRQ_HANDLED; |
956 | } | 1051 | } |
957 | 1052 | ||
1053 | /* Map a level onto a slot in the register bank */ | ||
1054 | static void arizona_micd_set_level(struct arizona *arizona, int index, | ||
1055 | unsigned int level) | ||
1056 | { | ||
1057 | int reg; | ||
1058 | unsigned int mask; | ||
1059 | |||
1060 | reg = ARIZONA_MIC_DETECT_LEVEL_4 - (index / 2); | ||
1061 | |||
1062 | if (!(index % 2)) { | ||
1063 | mask = 0x3f00; | ||
1064 | level <<= 8; | ||
1065 | } else { | ||
1066 | mask = 0x3f; | ||
1067 | } | ||
1068 | |||
1069 | /* Program the level itself */ | ||
1070 | regmap_update_bits(arizona->regmap, reg, mask, level); | ||
1071 | } | ||
1072 | |||
958 | static int arizona_extcon_probe(struct platform_device *pdev) | 1073 | static int arizona_extcon_probe(struct platform_device *pdev) |
959 | { | 1074 | { |
960 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); | 1075 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); |
961 | struct arizona_pdata *pdata; | 1076 | struct arizona_pdata *pdata; |
962 | struct arizona_extcon_info *info; | 1077 | struct arizona_extcon_info *info; |
1078 | unsigned int val; | ||
963 | int jack_irq_fall, jack_irq_rise; | 1079 | int jack_irq_fall, jack_irq_rise; |
964 | int ret, mode, i; | 1080 | int ret, mode, i, j; |
965 | 1081 | ||
966 | if (!arizona->dapm || !arizona->dapm->card) | 1082 | if (!arizona->dapm || !arizona->dapm->card) |
967 | return -EPROBE_DEFER; | 1083 | return -EPROBE_DEFER; |
@@ -985,7 +1101,10 @@ static int arizona_extcon_probe(struct platform_device *pdev) | |||
985 | mutex_init(&info->lock); | 1101 | mutex_init(&info->lock); |
986 | info->arizona = arizona; | 1102 | info->arizona = arizona; |
987 | info->dev = &pdev->dev; | 1103 | info->dev = &pdev->dev; |
1104 | info->last_jackdet = ~(ARIZONA_MICD_CLAMP_STS | ARIZONA_JD1_STS); | ||
988 | INIT_DELAYED_WORK(&info->hpdet_work, arizona_hpdet_work); | 1105 | INIT_DELAYED_WORK(&info->hpdet_work, arizona_hpdet_work); |
1106 | INIT_DELAYED_WORK(&info->micd_detect_work, arizona_micd_detect); | ||
1107 | INIT_DELAYED_WORK(&info->micd_timeout_work, arizona_micd_timeout_work); | ||
989 | platform_set_drvdata(pdev, info); | 1108 | platform_set_drvdata(pdev, info); |
990 | 1109 | ||
991 | switch (arizona->type) { | 1110 | switch (arizona->type) { |
@@ -1014,6 +1133,17 @@ static int arizona_extcon_probe(struct platform_device *pdev) | |||
1014 | goto err; | 1133 | goto err; |
1015 | } | 1134 | } |
1016 | 1135 | ||
1136 | info->input = devm_input_allocate_device(&pdev->dev); | ||
1137 | if (!info->input) { | ||
1138 | dev_err(arizona->dev, "Can't allocate input dev\n"); | ||
1139 | ret = -ENOMEM; | ||
1140 | goto err_register; | ||
1141 | } | ||
1142 | |||
1143 | info->input->name = "Headset"; | ||
1144 | info->input->phys = "arizona/extcon"; | ||
1145 | info->input->dev.parent = &pdev->dev; | ||
1146 | |||
1017 | if (pdata->num_micd_configs) { | 1147 | if (pdata->num_micd_configs) { |
1018 | info->micd_modes = pdata->micd_configs; | 1148 | info->micd_modes = pdata->micd_configs; |
1019 | info->micd_num_modes = pdata->num_micd_configs; | 1149 | info->micd_num_modes = pdata->num_micd_configs; |
@@ -1069,15 +1199,79 @@ static int arizona_extcon_probe(struct platform_device *pdev) | |||
1069 | arizona->pdata.micd_dbtime | 1199 | arizona->pdata.micd_dbtime |
1070 | << ARIZONA_MICD_DBTIME_SHIFT); | 1200 | << ARIZONA_MICD_DBTIME_SHIFT); |
1071 | 1201 | ||
1202 | BUILD_BUG_ON(ARRAY_SIZE(arizona_micd_levels) != 0x40); | ||
1203 | |||
1204 | if (arizona->pdata.num_micd_ranges) { | ||
1205 | info->micd_ranges = pdata->micd_ranges; | ||
1206 | info->num_micd_ranges = pdata->num_micd_ranges; | ||
1207 | } else { | ||
1208 | info->micd_ranges = micd_default_ranges; | ||
1209 | info->num_micd_ranges = ARRAY_SIZE(micd_default_ranges); | ||
1210 | } | ||
1211 | |||
1212 | if (arizona->pdata.num_micd_ranges > ARIZONA_MAX_MICD_RANGE) { | ||
1213 | dev_err(arizona->dev, "Too many MICD ranges: %d\n", | ||
1214 | arizona->pdata.num_micd_ranges); | ||
1215 | } | ||
1216 | |||
1217 | if (info->num_micd_ranges > 1) { | ||
1218 | for (i = 1; i < info->num_micd_ranges; i++) { | ||
1219 | if (info->micd_ranges[i - 1].max > | ||
1220 | info->micd_ranges[i].max) { | ||
1221 | dev_err(arizona->dev, | ||
1222 | "MICD ranges must be sorted\n"); | ||
1223 | ret = -EINVAL; | ||
1224 | goto err_input; | ||
1225 | } | ||
1226 | } | ||
1227 | } | ||
1228 | |||
1229 | /* Disable all buttons by default */ | ||
1230 | regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_2, | ||
1231 | ARIZONA_MICD_LVL_SEL_MASK, 0x81); | ||
1232 | |||
1233 | /* Set up all the buttons the user specified */ | ||
1234 | for (i = 0; i < info->num_micd_ranges; i++) { | ||
1235 | for (j = 0; j < ARRAY_SIZE(arizona_micd_levels); j++) | ||
1236 | if (arizona_micd_levels[j] >= info->micd_ranges[i].max) | ||
1237 | break; | ||
1238 | |||
1239 | if (j == ARRAY_SIZE(arizona_micd_levels)) { | ||
1240 | dev_err(arizona->dev, "Unsupported MICD level %d\n", | ||
1241 | info->micd_ranges[i].max); | ||
1242 | ret = -EINVAL; | ||
1243 | goto err_input; | ||
1244 | } | ||
1245 | |||
1246 | dev_dbg(arizona->dev, "%d ohms for MICD threshold %d\n", | ||
1247 | arizona_micd_levels[j], i); | ||
1248 | |||
1249 | arizona_micd_set_level(arizona, i, j); | ||
1250 | input_set_capability(info->input, EV_KEY, | ||
1251 | info->micd_ranges[i].key); | ||
1252 | |||
1253 | /* Enable reporting of that range */ | ||
1254 | regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_2, | ||
1255 | 1 << i, 1 << i); | ||
1256 | } | ||
1257 | |||
1258 | /* Set all the remaining keys to a maximum */ | ||
1259 | for (; i < ARIZONA_MAX_MICD_RANGE; i++) | ||
1260 | arizona_micd_set_level(arizona, i, 0x3f); | ||
1261 | |||
1072 | /* | 1262 | /* |
1073 | * If we have a clamp use it, activating in conjunction with | 1263 | * If we have a clamp use it, activating in conjunction with |
1074 | * GPIO5 if that is connected for jack detect operation. | 1264 | * GPIO5 if that is connected for jack detect operation. |
1075 | */ | 1265 | */ |
1076 | if (info->micd_clamp) { | 1266 | if (info->micd_clamp) { |
1077 | if (arizona->pdata.jd_gpio5) { | 1267 | if (arizona->pdata.jd_gpio5) { |
1078 | /* Put the GPIO into input mode */ | 1268 | /* Put the GPIO into input mode with optional pull */ |
1269 | val = 0xc101; | ||
1270 | if (arizona->pdata.jd_gpio5_nopull) | ||
1271 | val &= ~ARIZONA_GPN_PU; | ||
1272 | |||
1079 | regmap_write(arizona->regmap, ARIZONA_GPIO5_CTRL, | 1273 | regmap_write(arizona->regmap, ARIZONA_GPIO5_CTRL, |
1080 | 0xc101); | 1274 | val); |
1081 | 1275 | ||
1082 | regmap_update_bits(arizona->regmap, | 1276 | regmap_update_bits(arizona->regmap, |
1083 | ARIZONA_MICD_CLAMP_CONTROL, | 1277 | ARIZONA_MICD_CLAMP_CONTROL, |
@@ -1096,20 +1290,6 @@ static int arizona_extcon_probe(struct platform_device *pdev) | |||
1096 | 1290 | ||
1097 | arizona_extcon_set_mode(info, 0); | 1291 | arizona_extcon_set_mode(info, 0); |
1098 | 1292 | ||
1099 | info->input = devm_input_allocate_device(&pdev->dev); | ||
1100 | if (!info->input) { | ||
1101 | dev_err(arizona->dev, "Can't allocate input dev\n"); | ||
1102 | ret = -ENOMEM; | ||
1103 | goto err_register; | ||
1104 | } | ||
1105 | |||
1106 | for (i = 0; i < ARIZONA_NUM_BUTTONS; i++) | ||
1107 | input_set_capability(info->input, EV_KEY, | ||
1108 | arizona_lvl_to_key[i].report); | ||
1109 | info->input->name = "Headset"; | ||
1110 | info->input->phys = "arizona/extcon"; | ||
1111 | info->input->dev.parent = &pdev->dev; | ||
1112 | |||
1113 | pm_runtime_enable(&pdev->dev); | 1293 | pm_runtime_enable(&pdev->dev); |
1114 | pm_runtime_idle(&pdev->dev); | 1294 | pm_runtime_idle(&pdev->dev); |
1115 | pm_runtime_get_sync(&pdev->dev); | 1295 | pm_runtime_get_sync(&pdev->dev); |
diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile index e6abfa02d8b7..0a74b5661186 100644 --- a/drivers/hv/Makefile +++ b/drivers/hv/Makefile | |||
@@ -5,4 +5,4 @@ obj-$(CONFIG_HYPERV_BALLOON) += hv_balloon.o | |||
5 | hv_vmbus-y := vmbus_drv.o \ | 5 | hv_vmbus-y := vmbus_drv.o \ |
6 | hv.o connection.o channel.o \ | 6 | hv.o connection.o channel.o \ |
7 | channel_mgmt.o ring_buffer.o | 7 | channel_mgmt.o ring_buffer.o |
8 | hv_utils-y := hv_util.o hv_kvp.o | 8 | hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o |
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index ff1be167eb04..bad8128b283a 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c | |||
@@ -165,8 +165,19 @@ static void vmbus_process_rescind_offer(struct work_struct *work) | |||
165 | struct vmbus_channel *channel = container_of(work, | 165 | struct vmbus_channel *channel = container_of(work, |
166 | struct vmbus_channel, | 166 | struct vmbus_channel, |
167 | work); | 167 | work); |
168 | unsigned long flags; | ||
169 | struct vmbus_channel_relid_released msg; | ||
168 | 170 | ||
169 | vmbus_device_unregister(channel->device_obj); | 171 | vmbus_device_unregister(channel->device_obj); |
172 | memset(&msg, 0, sizeof(struct vmbus_channel_relid_released)); | ||
173 | msg.child_relid = channel->offermsg.child_relid; | ||
174 | msg.header.msgtype = CHANNELMSG_RELID_RELEASED; | ||
175 | vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released)); | ||
176 | |||
177 | spin_lock_irqsave(&vmbus_connection.channel_lock, flags); | ||
178 | list_del(&channel->listentry); | ||
179 | spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); | ||
180 | free_channel(channel); | ||
170 | } | 181 | } |
171 | 182 | ||
172 | void vmbus_free_channels(void) | 183 | void vmbus_free_channels(void) |
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 731158910c1e..ae4923756d98 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c | |||
@@ -289,9 +289,8 @@ void hv_synic_init(void *arg) | |||
289 | /* Check the version */ | 289 | /* Check the version */ |
290 | rdmsrl(HV_X64_MSR_SVERSION, version); | 290 | rdmsrl(HV_X64_MSR_SVERSION, version); |
291 | 291 | ||
292 | hv_context.event_dpc[cpu] = (struct tasklet_struct *) | 292 | hv_context.event_dpc[cpu] = kmalloc(sizeof(struct tasklet_struct), |
293 | kmalloc(sizeof(struct tasklet_struct), | 293 | GFP_ATOMIC); |
294 | GFP_ATOMIC); | ||
295 | if (hv_context.event_dpc[cpu] == NULL) { | 294 | if (hv_context.event_dpc[cpu] == NULL) { |
296 | pr_err("Unable to allocate event dpc\n"); | 295 | pr_err("Unable to allocate event dpc\n"); |
297 | goto cleanup; | 296 | goto cleanup; |
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 37873213e24f..4c605c70ebf9 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c | |||
@@ -117,7 +117,14 @@ union dm_caps { | |||
117 | struct { | 117 | struct { |
118 | __u64 balloon:1; | 118 | __u64 balloon:1; |
119 | __u64 hot_add:1; | 119 | __u64 hot_add:1; |
120 | __u64 reservedz:62; | 120 | /* |
121 | * To support guests that may have alignment | ||
122 | * limitations on hot-add, the guest can specify | ||
123 | * its alignment requirements; a value of n | ||
124 | * represents an alignment of 2^n in mega bytes. | ||
125 | */ | ||
126 | __u64 hot_add_alignment:4; | ||
127 | __u64 reservedz:58; | ||
121 | } cap_bits; | 128 | } cap_bits; |
122 | __u64 caps; | 129 | __u64 caps; |
123 | } __packed; | 130 | } __packed; |
@@ -412,13 +419,45 @@ struct dm_info_msg { | |||
412 | * End protocol definitions. | 419 | * End protocol definitions. |
413 | */ | 420 | */ |
414 | 421 | ||
415 | static bool hot_add; | 422 | /* |
423 | * State to manage hot adding memory into the guest. | ||
424 | * The range start_pfn : end_pfn specifies the range | ||
425 | * that the host has asked us to hot add. The range | ||
426 | * start_pfn : ha_end_pfn specifies the range that we have | ||
427 | * currently hot added. We hot add in multiples of 128M | ||
428 | * chunks; it is possible that we may not be able to bring | ||
429 | * online all the pages in the region. The range | ||
430 | * covered_start_pfn : covered_end_pfn defines the pages that can | ||
431 | * be brough online. | ||
432 | */ | ||
433 | |||
434 | struct hv_hotadd_state { | ||
435 | struct list_head list; | ||
436 | unsigned long start_pfn; | ||
437 | unsigned long covered_start_pfn; | ||
438 | unsigned long covered_end_pfn; | ||
439 | unsigned long ha_end_pfn; | ||
440 | unsigned long end_pfn; | ||
441 | }; | ||
442 | |||
443 | struct balloon_state { | ||
444 | __u32 num_pages; | ||
445 | struct work_struct wrk; | ||
446 | }; | ||
447 | |||
448 | struct hot_add_wrk { | ||
449 | union dm_mem_page_range ha_page_range; | ||
450 | union dm_mem_page_range ha_region_range; | ||
451 | struct work_struct wrk; | ||
452 | }; | ||
453 | |||
454 | static bool hot_add = true; | ||
416 | static bool do_hot_add; | 455 | static bool do_hot_add; |
417 | /* | 456 | /* |
418 | * Delay reporting memory pressure by | 457 | * Delay reporting memory pressure by |
419 | * the specified number of seconds. | 458 | * the specified number of seconds. |
420 | */ | 459 | */ |
421 | static uint pressure_report_delay = 30; | 460 | static uint pressure_report_delay = 45; |
422 | 461 | ||
423 | module_param(hot_add, bool, (S_IRUGO | S_IWUSR)); | 462 | module_param(hot_add, bool, (S_IRUGO | S_IWUSR)); |
424 | MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add"); | 463 | MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add"); |
@@ -446,6 +485,7 @@ enum hv_dm_state { | |||
446 | static __u8 recv_buffer[PAGE_SIZE]; | 485 | static __u8 recv_buffer[PAGE_SIZE]; |
447 | static __u8 *send_buffer; | 486 | static __u8 *send_buffer; |
448 | #define PAGES_IN_2M 512 | 487 | #define PAGES_IN_2M 512 |
488 | #define HA_CHUNK (32 * 1024) | ||
449 | 489 | ||
450 | struct hv_dynmem_device { | 490 | struct hv_dynmem_device { |
451 | struct hv_device *dev; | 491 | struct hv_device *dev; |
@@ -459,7 +499,28 @@ struct hv_dynmem_device { | |||
459 | unsigned int num_pages_ballooned; | 499 | unsigned int num_pages_ballooned; |
460 | 500 | ||
461 | /* | 501 | /* |
462 | * This thread handles both balloon/hot-add | 502 | * State to manage the ballooning (up) operation. |
503 | */ | ||
504 | struct balloon_state balloon_wrk; | ||
505 | |||
506 | /* | ||
507 | * State to execute the "hot-add" operation. | ||
508 | */ | ||
509 | struct hot_add_wrk ha_wrk; | ||
510 | |||
511 | /* | ||
512 | * This state tracks if the host has specified a hot-add | ||
513 | * region. | ||
514 | */ | ||
515 | bool host_specified_ha_region; | ||
516 | |||
517 | /* | ||
518 | * State to synchronize hot-add. | ||
519 | */ | ||
520 | struct completion ol_waitevent; | ||
521 | bool ha_waiting; | ||
522 | /* | ||
523 | * This thread handles hot-add | ||
463 | * requests from the host as well as notifying | 524 | * requests from the host as well as notifying |
464 | * the host with regards to memory pressure in | 525 | * the host with regards to memory pressure in |
465 | * the guest. | 526 | * the guest. |
@@ -467,6 +528,11 @@ struct hv_dynmem_device { | |||
467 | struct task_struct *thread; | 528 | struct task_struct *thread; |
468 | 529 | ||
469 | /* | 530 | /* |
531 | * A list of hot-add regions. | ||
532 | */ | ||
533 | struct list_head ha_region_list; | ||
534 | |||
535 | /* | ||
470 | * We start with the highest version we can support | 536 | * We start with the highest version we can support |
471 | * and downgrade based on the host; we save here the | 537 | * and downgrade based on the host; we save here the |
472 | * next version to try. | 538 | * next version to try. |
@@ -476,35 +542,358 @@ struct hv_dynmem_device { | |||
476 | 542 | ||
477 | static struct hv_dynmem_device dm_device; | 543 | static struct hv_dynmem_device dm_device; |
478 | 544 | ||
479 | static void hot_add_req(struct hv_dynmem_device *dm, struct dm_hot_add *msg) | 545 | #ifdef CONFIG_MEMORY_HOTPLUG |
546 | |||
547 | static void hv_bring_pgs_online(unsigned long start_pfn, unsigned long size) | ||
480 | { | 548 | { |
549 | int i; | ||
481 | 550 | ||
482 | struct dm_hot_add_response resp; | 551 | for (i = 0; i < size; i++) { |
552 | struct page *pg; | ||
553 | pg = pfn_to_page(start_pfn + i); | ||
554 | __online_page_set_limits(pg); | ||
555 | __online_page_increment_counters(pg); | ||
556 | __online_page_free(pg); | ||
557 | } | ||
558 | } | ||
483 | 559 | ||
484 | if (do_hot_add) { | 560 | static void hv_mem_hot_add(unsigned long start, unsigned long size, |
561 | unsigned long pfn_count, | ||
562 | struct hv_hotadd_state *has) | ||
563 | { | ||
564 | int ret = 0; | ||
565 | int i, nid, t; | ||
566 | unsigned long start_pfn; | ||
567 | unsigned long processed_pfn; | ||
568 | unsigned long total_pfn = pfn_count; | ||
569 | |||
570 | for (i = 0; i < (size/HA_CHUNK); i++) { | ||
571 | start_pfn = start + (i * HA_CHUNK); | ||
572 | has->ha_end_pfn += HA_CHUNK; | ||
573 | |||
574 | if (total_pfn > HA_CHUNK) { | ||
575 | processed_pfn = HA_CHUNK; | ||
576 | total_pfn -= HA_CHUNK; | ||
577 | } else { | ||
578 | processed_pfn = total_pfn; | ||
579 | total_pfn = 0; | ||
580 | } | ||
581 | |||
582 | has->covered_end_pfn += processed_pfn; | ||
583 | |||
584 | init_completion(&dm_device.ol_waitevent); | ||
585 | dm_device.ha_waiting = true; | ||
586 | |||
587 | nid = memory_add_physaddr_to_nid(PFN_PHYS(start_pfn)); | ||
588 | ret = add_memory(nid, PFN_PHYS((start_pfn)), | ||
589 | (HA_CHUNK << PAGE_SHIFT)); | ||
485 | 590 | ||
486 | pr_info("Memory hot add not supported\n"); | 591 | if (ret) { |
592 | pr_info("hot_add memory failed error is %d\n", ret); | ||
593 | if (ret == -EEXIST) { | ||
594 | /* | ||
595 | * This error indicates that the error | ||
596 | * is not a transient failure. This is the | ||
597 | * case where the guest's physical address map | ||
598 | * precludes hot adding memory. Stop all further | ||
599 | * memory hot-add. | ||
600 | */ | ||
601 | do_hot_add = false; | ||
602 | } | ||
603 | has->ha_end_pfn -= HA_CHUNK; | ||
604 | has->covered_end_pfn -= processed_pfn; | ||
605 | break; | ||
606 | } | ||
487 | 607 | ||
488 | /* | 608 | /* |
489 | * Currently we do not support hot add. | 609 | * Wait for the memory block to be onlined. |
490 | * Just fail the request. | ||
491 | */ | 610 | */ |
611 | t = wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ); | ||
612 | if (t == 0) { | ||
613 | pr_info("hot_add memory timedout\n"); | ||
614 | has->ha_end_pfn -= HA_CHUNK; | ||
615 | has->covered_end_pfn -= processed_pfn; | ||
616 | break; | ||
617 | } | ||
618 | |||
619 | } | ||
620 | |||
621 | return; | ||
622 | } | ||
623 | |||
624 | static void hv_online_page(struct page *pg) | ||
625 | { | ||
626 | struct list_head *cur; | ||
627 | struct hv_hotadd_state *has; | ||
628 | unsigned long cur_start_pgp; | ||
629 | unsigned long cur_end_pgp; | ||
630 | |||
631 | if (dm_device.ha_waiting) { | ||
632 | dm_device.ha_waiting = false; | ||
633 | complete(&dm_device.ol_waitevent); | ||
634 | } | ||
635 | |||
636 | list_for_each(cur, &dm_device.ha_region_list) { | ||
637 | has = list_entry(cur, struct hv_hotadd_state, list); | ||
638 | cur_start_pgp = (unsigned long) | ||
639 | pfn_to_page(has->covered_start_pfn); | ||
640 | cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); | ||
641 | |||
642 | if (((unsigned long)pg >= cur_start_pgp) && | ||
643 | ((unsigned long)pg < cur_end_pgp)) { | ||
644 | /* | ||
645 | * This frame is currently backed; online the | ||
646 | * page. | ||
647 | */ | ||
648 | __online_page_set_limits(pg); | ||
649 | __online_page_increment_counters(pg); | ||
650 | __online_page_free(pg); | ||
651 | has->covered_start_pfn++; | ||
652 | } | ||
653 | } | ||
654 | } | ||
655 | |||
656 | static bool pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) | ||
657 | { | ||
658 | struct list_head *cur; | ||
659 | struct hv_hotadd_state *has; | ||
660 | unsigned long residual, new_inc; | ||
661 | |||
662 | if (list_empty(&dm_device.ha_region_list)) | ||
663 | return false; | ||
664 | |||
665 | list_for_each(cur, &dm_device.ha_region_list) { | ||
666 | has = list_entry(cur, struct hv_hotadd_state, list); | ||
667 | |||
668 | /* | ||
669 | * If the pfn range we are dealing with is not in the current | ||
670 | * "hot add block", move on. | ||
671 | */ | ||
672 | if ((start_pfn >= has->end_pfn)) | ||
673 | continue; | ||
674 | /* | ||
675 | * If the current hot add-request extends beyond | ||
676 | * our current limit; extend it. | ||
677 | */ | ||
678 | if ((start_pfn + pfn_cnt) > has->end_pfn) { | ||
679 | residual = (start_pfn + pfn_cnt - has->end_pfn); | ||
680 | /* | ||
681 | * Extend the region by multiples of HA_CHUNK. | ||
682 | */ | ||
683 | new_inc = (residual / HA_CHUNK) * HA_CHUNK; | ||
684 | if (residual % HA_CHUNK) | ||
685 | new_inc += HA_CHUNK; | ||
686 | |||
687 | has->end_pfn += new_inc; | ||
688 | } | ||
689 | |||
690 | /* | ||
691 | * If the current start pfn is not where the covered_end | ||
692 | * is, update it. | ||
693 | */ | ||
694 | |||
695 | if (has->covered_end_pfn != start_pfn) { | ||
696 | has->covered_end_pfn = start_pfn; | ||
697 | has->covered_start_pfn = start_pfn; | ||
698 | } | ||
699 | return true; | ||
700 | |||
492 | } | 701 | } |
493 | 702 | ||
703 | return false; | ||
704 | } | ||
705 | |||
706 | static unsigned long handle_pg_range(unsigned long pg_start, | ||
707 | unsigned long pg_count) | ||
708 | { | ||
709 | unsigned long start_pfn = pg_start; | ||
710 | unsigned long pfn_cnt = pg_count; | ||
711 | unsigned long size; | ||
712 | struct list_head *cur; | ||
713 | struct hv_hotadd_state *has; | ||
714 | unsigned long pgs_ol = 0; | ||
715 | unsigned long old_covered_state; | ||
716 | |||
717 | if (list_empty(&dm_device.ha_region_list)) | ||
718 | return 0; | ||
719 | |||
720 | list_for_each(cur, &dm_device.ha_region_list) { | ||
721 | has = list_entry(cur, struct hv_hotadd_state, list); | ||
722 | |||
723 | /* | ||
724 | * If the pfn range we are dealing with is not in the current | ||
725 | * "hot add block", move on. | ||
726 | */ | ||
727 | if ((start_pfn >= has->end_pfn)) | ||
728 | continue; | ||
729 | |||
730 | old_covered_state = has->covered_end_pfn; | ||
731 | |||
732 | if (start_pfn < has->ha_end_pfn) { | ||
733 | /* | ||
734 | * This is the case where we are backing pages | ||
735 | * in an already hot added region. Bring | ||
736 | * these pages online first. | ||
737 | */ | ||
738 | pgs_ol = has->ha_end_pfn - start_pfn; | ||
739 | if (pgs_ol > pfn_cnt) | ||
740 | pgs_ol = pfn_cnt; | ||
741 | hv_bring_pgs_online(start_pfn, pgs_ol); | ||
742 | has->covered_end_pfn += pgs_ol; | ||
743 | has->covered_start_pfn += pgs_ol; | ||
744 | pfn_cnt -= pgs_ol; | ||
745 | } | ||
746 | |||
747 | if ((has->ha_end_pfn < has->end_pfn) && (pfn_cnt > 0)) { | ||
748 | /* | ||
749 | * We have some residual hot add range | ||
750 | * that needs to be hot added; hot add | ||
751 | * it now. Hot add a multiple of | ||
752 | * of HA_CHUNK that fully covers the pages | ||
753 | * we have. | ||
754 | */ | ||
755 | size = (has->end_pfn - has->ha_end_pfn); | ||
756 | if (pfn_cnt <= size) { | ||
757 | size = ((pfn_cnt / HA_CHUNK) * HA_CHUNK); | ||
758 | if (pfn_cnt % HA_CHUNK) | ||
759 | size += HA_CHUNK; | ||
760 | } else { | ||
761 | pfn_cnt = size; | ||
762 | } | ||
763 | hv_mem_hot_add(has->ha_end_pfn, size, pfn_cnt, has); | ||
764 | } | ||
765 | /* | ||
766 | * If we managed to online any pages that were given to us, | ||
767 | * we declare success. | ||
768 | */ | ||
769 | return has->covered_end_pfn - old_covered_state; | ||
770 | |||
771 | } | ||
772 | |||
773 | return 0; | ||
774 | } | ||
775 | |||
776 | static unsigned long process_hot_add(unsigned long pg_start, | ||
777 | unsigned long pfn_cnt, | ||
778 | unsigned long rg_start, | ||
779 | unsigned long rg_size) | ||
780 | { | ||
781 | struct hv_hotadd_state *ha_region = NULL; | ||
782 | |||
783 | if (pfn_cnt == 0) | ||
784 | return 0; | ||
785 | |||
786 | if (!dm_device.host_specified_ha_region) | ||
787 | if (pfn_covered(pg_start, pfn_cnt)) | ||
788 | goto do_pg_range; | ||
789 | |||
790 | /* | ||
791 | * If the host has specified a hot-add range; deal with it first. | ||
792 | */ | ||
793 | |||
794 | if (rg_size != 0) { | ||
795 | ha_region = kzalloc(sizeof(struct hv_hotadd_state), GFP_KERNEL); | ||
796 | if (!ha_region) | ||
797 | return 0; | ||
798 | |||
799 | INIT_LIST_HEAD(&ha_region->list); | ||
800 | |||
801 | list_add_tail(&ha_region->list, &dm_device.ha_region_list); | ||
802 | ha_region->start_pfn = rg_start; | ||
803 | ha_region->ha_end_pfn = rg_start; | ||
804 | ha_region->covered_start_pfn = pg_start; | ||
805 | ha_region->covered_end_pfn = pg_start; | ||
806 | ha_region->end_pfn = rg_start + rg_size; | ||
807 | } | ||
808 | |||
809 | do_pg_range: | ||
810 | /* | ||
811 | * Process the page range specified; bringing them | ||
812 | * online if possible. | ||
813 | */ | ||
814 | return handle_pg_range(pg_start, pfn_cnt); | ||
815 | } | ||
816 | |||
817 | #endif | ||
818 | |||
819 | static void hot_add_req(struct work_struct *dummy) | ||
820 | { | ||
821 | struct dm_hot_add_response resp; | ||
822 | #ifdef CONFIG_MEMORY_HOTPLUG | ||
823 | unsigned long pg_start, pfn_cnt; | ||
824 | unsigned long rg_start, rg_sz; | ||
825 | #endif | ||
826 | struct hv_dynmem_device *dm = &dm_device; | ||
827 | |||
494 | memset(&resp, 0, sizeof(struct dm_hot_add_response)); | 828 | memset(&resp, 0, sizeof(struct dm_hot_add_response)); |
495 | resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE; | 829 | resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE; |
496 | resp.hdr.size = sizeof(struct dm_hot_add_response); | 830 | resp.hdr.size = sizeof(struct dm_hot_add_response); |
497 | resp.hdr.trans_id = atomic_inc_return(&trans_id); | 831 | resp.hdr.trans_id = atomic_inc_return(&trans_id); |
498 | 832 | ||
499 | resp.page_count = 0; | 833 | #ifdef CONFIG_MEMORY_HOTPLUG |
500 | resp.result = 0; | 834 | pg_start = dm->ha_wrk.ha_page_range.finfo.start_page; |
835 | pfn_cnt = dm->ha_wrk.ha_page_range.finfo.page_cnt; | ||
836 | |||
837 | rg_start = dm->ha_wrk.ha_region_range.finfo.start_page; | ||
838 | rg_sz = dm->ha_wrk.ha_region_range.finfo.page_cnt; | ||
839 | |||
840 | if ((rg_start == 0) && (!dm->host_specified_ha_region)) { | ||
841 | unsigned long region_size; | ||
842 | unsigned long region_start; | ||
843 | |||
844 | /* | ||
845 | * The host has not specified the hot-add region. | ||
846 | * Based on the hot-add page range being specified, | ||
847 | * compute a hot-add region that can cover the pages | ||
848 | * that need to be hot-added while ensuring the alignment | ||
849 | * and size requirements of Linux as it relates to hot-add. | ||
850 | */ | ||
851 | region_start = pg_start; | ||
852 | region_size = (pfn_cnt / HA_CHUNK) * HA_CHUNK; | ||
853 | if (pfn_cnt % HA_CHUNK) | ||
854 | region_size += HA_CHUNK; | ||
855 | |||
856 | region_start = (pg_start / HA_CHUNK) * HA_CHUNK; | ||
857 | |||
858 | rg_start = region_start; | ||
859 | rg_sz = region_size; | ||
860 | } | ||
861 | |||
862 | if (do_hot_add) | ||
863 | resp.page_count = process_hot_add(pg_start, pfn_cnt, | ||
864 | rg_start, rg_sz); | ||
865 | #endif | ||
866 | /* | ||
867 | * The result field of the response structure has the | ||
868 | * following semantics: | ||
869 | * | ||
870 | * 1. If all or some pages hot-added: Guest should return success. | ||
871 | * | ||
872 | * 2. If no pages could be hot-added: | ||
873 | * | ||
874 | * If the guest returns success, then the host | ||
875 | * will not attempt any further hot-add operations. This | ||
876 | * signifies a permanent failure. | ||
877 | * | ||
878 | * If the guest returns failure, then this failure will be | ||
879 | * treated as a transient failure and the host may retry the | ||
880 | * hot-add operation after some delay. | ||
881 | */ | ||
882 | if (resp.page_count > 0) | ||
883 | resp.result = 1; | ||
884 | else if (!do_hot_add) | ||
885 | resp.result = 1; | ||
886 | else | ||
887 | resp.result = 0; | ||
888 | |||
889 | if (!do_hot_add || (resp.page_count == 0)) | ||
890 | pr_info("Memory hot add failed\n"); | ||
501 | 891 | ||
502 | dm->state = DM_INITIALIZED; | 892 | dm->state = DM_INITIALIZED; |
503 | vmbus_sendpacket(dm->dev->channel, &resp, | 893 | vmbus_sendpacket(dm->dev->channel, &resp, |
504 | sizeof(struct dm_hot_add_response), | 894 | sizeof(struct dm_hot_add_response), |
505 | (unsigned long)NULL, | 895 | (unsigned long)NULL, |
506 | VM_PKT_DATA_INBAND, 0); | 896 | VM_PKT_DATA_INBAND, 0); |
507 | |||
508 | } | 897 | } |
509 | 898 | ||
510 | static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg) | 899 | static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg) |
@@ -523,7 +912,7 @@ static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg) | |||
523 | } | 912 | } |
524 | } | 913 | } |
525 | 914 | ||
526 | unsigned long compute_balloon_floor(void) | 915 | static unsigned long compute_balloon_floor(void) |
527 | { | 916 | { |
528 | unsigned long min_pages; | 917 | unsigned long min_pages; |
529 | #define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT)) | 918 | #define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT)) |
@@ -644,6 +1033,14 @@ static int alloc_balloon_pages(struct hv_dynmem_device *dm, int num_pages, | |||
644 | 1033 | ||
645 | dm->num_pages_ballooned += alloc_unit; | 1034 | dm->num_pages_ballooned += alloc_unit; |
646 | 1035 | ||
1036 | /* | ||
1037 | * If we allocatted 2M pages; split them so we | ||
1038 | * can free them in any order we get. | ||
1039 | */ | ||
1040 | |||
1041 | if (alloc_unit != 1) | ||
1042 | split_page(pg, get_order(alloc_unit << PAGE_SHIFT)); | ||
1043 | |||
647 | bl_resp->range_count++; | 1044 | bl_resp->range_count++; |
648 | bl_resp->range_array[i].finfo.start_page = | 1045 | bl_resp->range_array[i].finfo.start_page = |
649 | page_to_pfn(pg); | 1046 | page_to_pfn(pg); |
@@ -657,9 +1054,9 @@ static int alloc_balloon_pages(struct hv_dynmem_device *dm, int num_pages, | |||
657 | 1054 | ||
658 | 1055 | ||
659 | 1056 | ||
660 | static void balloon_up(struct hv_dynmem_device *dm, struct dm_balloon *req) | 1057 | static void balloon_up(struct work_struct *dummy) |
661 | { | 1058 | { |
662 | int num_pages = req->num_pages; | 1059 | int num_pages = dm_device.balloon_wrk.num_pages; |
663 | int num_ballooned = 0; | 1060 | int num_ballooned = 0; |
664 | struct dm_balloon_response *bl_resp; | 1061 | struct dm_balloon_response *bl_resp; |
665 | int alloc_unit; | 1062 | int alloc_unit; |
@@ -670,9 +1067,10 @@ static void balloon_up(struct hv_dynmem_device *dm, struct dm_balloon *req) | |||
670 | 1067 | ||
671 | 1068 | ||
672 | /* | 1069 | /* |
673 | * Currently, we only support 4k allocations. | 1070 | * We will attempt 2M allocations. However, if we fail to |
1071 | * allocate 2M chunks, we will go back to 4k allocations. | ||
674 | */ | 1072 | */ |
675 | alloc_unit = 1; | 1073 | alloc_unit = 512; |
676 | 1074 | ||
677 | while (!done) { | 1075 | while (!done) { |
678 | bl_resp = (struct dm_balloon_response *)send_buffer; | 1076 | bl_resp = (struct dm_balloon_response *)send_buffer; |
@@ -684,14 +1082,19 @@ static void balloon_up(struct hv_dynmem_device *dm, struct dm_balloon *req) | |||
684 | 1082 | ||
685 | 1083 | ||
686 | num_pages -= num_ballooned; | 1084 | num_pages -= num_ballooned; |
687 | num_ballooned = alloc_balloon_pages(dm, num_pages, | 1085 | num_ballooned = alloc_balloon_pages(&dm_device, num_pages, |
688 | bl_resp, alloc_unit, | 1086 | bl_resp, alloc_unit, |
689 | &alloc_error); | 1087 | &alloc_error); |
690 | 1088 | ||
1089 | if ((alloc_error) && (alloc_unit != 1)) { | ||
1090 | alloc_unit = 1; | ||
1091 | continue; | ||
1092 | } | ||
1093 | |||
691 | if ((alloc_error) || (num_ballooned == num_pages)) { | 1094 | if ((alloc_error) || (num_ballooned == num_pages)) { |
692 | bl_resp->more_pages = 0; | 1095 | bl_resp->more_pages = 0; |
693 | done = true; | 1096 | done = true; |
694 | dm->state = DM_INITIALIZED; | 1097 | dm_device.state = DM_INITIALIZED; |
695 | } | 1098 | } |
696 | 1099 | ||
697 | /* | 1100 | /* |
@@ -719,7 +1122,7 @@ static void balloon_up(struct hv_dynmem_device *dm, struct dm_balloon *req) | |||
719 | pr_info("Balloon response failed\n"); | 1122 | pr_info("Balloon response failed\n"); |
720 | 1123 | ||
721 | for (i = 0; i < bl_resp->range_count; i++) | 1124 | for (i = 0; i < bl_resp->range_count; i++) |
722 | free_balloon_pages(dm, | 1125 | free_balloon_pages(&dm_device, |
723 | &bl_resp->range_array[i]); | 1126 | &bl_resp->range_array[i]); |
724 | 1127 | ||
725 | done = true; | 1128 | done = true; |
@@ -761,7 +1164,6 @@ static int dm_thread_func(void *dm_dev) | |||
761 | { | 1164 | { |
762 | struct hv_dynmem_device *dm = dm_dev; | 1165 | struct hv_dynmem_device *dm = dm_dev; |
763 | int t; | 1166 | int t; |
764 | unsigned long scan_start; | ||
765 | 1167 | ||
766 | while (!kthread_should_stop()) { | 1168 | while (!kthread_should_stop()) { |
767 | t = wait_for_completion_timeout(&dm_device.config_event, 1*HZ); | 1169 | t = wait_for_completion_timeout(&dm_device.config_event, 1*HZ); |
@@ -773,22 +1175,6 @@ static int dm_thread_func(void *dm_dev) | |||
773 | if (t == 0) | 1175 | if (t == 0) |
774 | post_status(dm); | 1176 | post_status(dm); |
775 | 1177 | ||
776 | scan_start = jiffies; | ||
777 | switch (dm->state) { | ||
778 | case DM_BALLOON_UP: | ||
779 | balloon_up(dm, (struct dm_balloon *)recv_buffer); | ||
780 | break; | ||
781 | |||
782 | case DM_HOT_ADD: | ||
783 | hot_add_req(dm, (struct dm_hot_add *)recv_buffer); | ||
784 | break; | ||
785 | default: | ||
786 | break; | ||
787 | } | ||
788 | |||
789 | if (!time_in_range(jiffies, scan_start, scan_start + HZ)) | ||
790 | post_status(dm); | ||
791 | |||
792 | } | 1178 | } |
793 | 1179 | ||
794 | return 0; | 1180 | return 0; |
@@ -861,6 +1247,10 @@ static void balloon_onchannelcallback(void *context) | |||
861 | struct dm_message *dm_msg; | 1247 | struct dm_message *dm_msg; |
862 | struct dm_header *dm_hdr; | 1248 | struct dm_header *dm_hdr; |
863 | struct hv_dynmem_device *dm = hv_get_drvdata(dev); | 1249 | struct hv_dynmem_device *dm = hv_get_drvdata(dev); |
1250 | struct dm_balloon *bal_msg; | ||
1251 | struct dm_hot_add *ha_msg; | ||
1252 | union dm_mem_page_range *ha_pg_range; | ||
1253 | union dm_mem_page_range *ha_region; | ||
864 | 1254 | ||
865 | memset(recv_buffer, 0, sizeof(recv_buffer)); | 1255 | memset(recv_buffer, 0, sizeof(recv_buffer)); |
866 | vmbus_recvpacket(dev->channel, recv_buffer, | 1256 | vmbus_recvpacket(dev->channel, recv_buffer, |
@@ -882,8 +1272,12 @@ static void balloon_onchannelcallback(void *context) | |||
882 | break; | 1272 | break; |
883 | 1273 | ||
884 | case DM_BALLOON_REQUEST: | 1274 | case DM_BALLOON_REQUEST: |
1275 | if (dm->state == DM_BALLOON_UP) | ||
1276 | pr_warn("Currently ballooning\n"); | ||
1277 | bal_msg = (struct dm_balloon *)recv_buffer; | ||
885 | dm->state = DM_BALLOON_UP; | 1278 | dm->state = DM_BALLOON_UP; |
886 | complete(&dm->config_event); | 1279 | dm_device.balloon_wrk.num_pages = bal_msg->num_pages; |
1280 | schedule_work(&dm_device.balloon_wrk.wrk); | ||
887 | break; | 1281 | break; |
888 | 1282 | ||
889 | case DM_UNBALLOON_REQUEST: | 1283 | case DM_UNBALLOON_REQUEST: |
@@ -893,8 +1287,31 @@ static void balloon_onchannelcallback(void *context) | |||
893 | break; | 1287 | break; |
894 | 1288 | ||
895 | case DM_MEM_HOT_ADD_REQUEST: | 1289 | case DM_MEM_HOT_ADD_REQUEST: |
1290 | if (dm->state == DM_HOT_ADD) | ||
1291 | pr_warn("Currently hot-adding\n"); | ||
896 | dm->state = DM_HOT_ADD; | 1292 | dm->state = DM_HOT_ADD; |
897 | complete(&dm->config_event); | 1293 | ha_msg = (struct dm_hot_add *)recv_buffer; |
1294 | if (ha_msg->hdr.size == sizeof(struct dm_hot_add)) { | ||
1295 | /* | ||
1296 | * This is a normal hot-add request specifying | ||
1297 | * hot-add memory. | ||
1298 | */ | ||
1299 | ha_pg_range = &ha_msg->range; | ||
1300 | dm->ha_wrk.ha_page_range = *ha_pg_range; | ||
1301 | dm->ha_wrk.ha_region_range.page_range = 0; | ||
1302 | } else { | ||
1303 | /* | ||
1304 | * Host is specifying that we first hot-add | ||
1305 | * a region and then partially populate this | ||
1306 | * region. | ||
1307 | */ | ||
1308 | dm->host_specified_ha_region = true; | ||
1309 | ha_pg_range = &ha_msg->range; | ||
1310 | ha_region = &ha_pg_range[1]; | ||
1311 | dm->ha_wrk.ha_page_range = *ha_pg_range; | ||
1312 | dm->ha_wrk.ha_region_range = *ha_region; | ||
1313 | } | ||
1314 | schedule_work(&dm_device.ha_wrk.wrk); | ||
898 | break; | 1315 | break; |
899 | 1316 | ||
900 | case DM_INFO_MESSAGE: | 1317 | case DM_INFO_MESSAGE: |
@@ -937,6 +1354,10 @@ static int balloon_probe(struct hv_device *dev, | |||
937 | dm_device.next_version = DYNMEM_PROTOCOL_VERSION_WIN7; | 1354 | dm_device.next_version = DYNMEM_PROTOCOL_VERSION_WIN7; |
938 | init_completion(&dm_device.host_event); | 1355 | init_completion(&dm_device.host_event); |
939 | init_completion(&dm_device.config_event); | 1356 | init_completion(&dm_device.config_event); |
1357 | INIT_LIST_HEAD(&dm_device.ha_region_list); | ||
1358 | INIT_WORK(&dm_device.balloon_wrk.wrk, balloon_up); | ||
1359 | INIT_WORK(&dm_device.ha_wrk.wrk, hot_add_req); | ||
1360 | dm_device.host_specified_ha_region = false; | ||
940 | 1361 | ||
941 | dm_device.thread = | 1362 | dm_device.thread = |
942 | kthread_run(dm_thread_func, &dm_device, "hv_balloon"); | 1363 | kthread_run(dm_thread_func, &dm_device, "hv_balloon"); |
@@ -945,6 +1366,10 @@ static int balloon_probe(struct hv_device *dev, | |||
945 | goto probe_error1; | 1366 | goto probe_error1; |
946 | } | 1367 | } |
947 | 1368 | ||
1369 | #ifdef CONFIG_MEMORY_HOTPLUG | ||
1370 | set_online_page_callback(&hv_online_page); | ||
1371 | #endif | ||
1372 | |||
948 | hv_set_drvdata(dev, &dm_device); | 1373 | hv_set_drvdata(dev, &dm_device); |
949 | /* | 1374 | /* |
950 | * Initiate the hand shake with the host and negotiate | 1375 | * Initiate the hand shake with the host and negotiate |
@@ -962,8 +1387,7 @@ static int balloon_probe(struct hv_device *dev, | |||
962 | ret = vmbus_sendpacket(dev->channel, &version_req, | 1387 | ret = vmbus_sendpacket(dev->channel, &version_req, |
963 | sizeof(struct dm_version_request), | 1388 | sizeof(struct dm_version_request), |
964 | (unsigned long)NULL, | 1389 | (unsigned long)NULL, |
965 | VM_PKT_DATA_INBAND, | 1390 | VM_PKT_DATA_INBAND, 0); |
966 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); | ||
967 | if (ret) | 1391 | if (ret) |
968 | goto probe_error2; | 1392 | goto probe_error2; |
969 | 1393 | ||
@@ -990,13 +1414,13 @@ static int balloon_probe(struct hv_device *dev, | |||
990 | cap_msg.hdr.trans_id = atomic_inc_return(&trans_id); | 1414 | cap_msg.hdr.trans_id = atomic_inc_return(&trans_id); |
991 | 1415 | ||
992 | cap_msg.caps.cap_bits.balloon = 1; | 1416 | cap_msg.caps.cap_bits.balloon = 1; |
1417 | cap_msg.caps.cap_bits.hot_add = 1; | ||
1418 | |||
993 | /* | 1419 | /* |
994 | * While we currently don't support hot-add, | 1420 | * Specify our alignment requirements as it relates |
995 | * we still advertise this capability since the | 1421 | * memory hot-add. Specify 128MB alignment. |
996 | * host requires that guests partcipating in the | ||
997 | * dynamic memory protocol support hot add. | ||
998 | */ | 1422 | */ |
999 | cap_msg.caps.cap_bits.hot_add = 1; | 1423 | cap_msg.caps.cap_bits.hot_add_alignment = 7; |
1000 | 1424 | ||
1001 | /* | 1425 | /* |
1002 | * Currently the host does not use these | 1426 | * Currently the host does not use these |
@@ -1009,8 +1433,7 @@ static int balloon_probe(struct hv_device *dev, | |||
1009 | ret = vmbus_sendpacket(dev->channel, &cap_msg, | 1433 | ret = vmbus_sendpacket(dev->channel, &cap_msg, |
1010 | sizeof(struct dm_capabilities), | 1434 | sizeof(struct dm_capabilities), |
1011 | (unsigned long)NULL, | 1435 | (unsigned long)NULL, |
1012 | VM_PKT_DATA_INBAND, | 1436 | VM_PKT_DATA_INBAND, 0); |
1013 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); | ||
1014 | if (ret) | 1437 | if (ret) |
1015 | goto probe_error2; | 1438 | goto probe_error2; |
1016 | 1439 | ||
@@ -1034,6 +1457,9 @@ static int balloon_probe(struct hv_device *dev, | |||
1034 | return 0; | 1457 | return 0; |
1035 | 1458 | ||
1036 | probe_error2: | 1459 | probe_error2: |
1460 | #ifdef CONFIG_MEMORY_HOTPLUG | ||
1461 | restore_online_page_callback(&hv_online_page); | ||
1462 | #endif | ||
1037 | kthread_stop(dm_device.thread); | 1463 | kthread_stop(dm_device.thread); |
1038 | 1464 | ||
1039 | probe_error1: | 1465 | probe_error1: |
@@ -1046,13 +1472,26 @@ probe_error0: | |||
1046 | static int balloon_remove(struct hv_device *dev) | 1472 | static int balloon_remove(struct hv_device *dev) |
1047 | { | 1473 | { |
1048 | struct hv_dynmem_device *dm = hv_get_drvdata(dev); | 1474 | struct hv_dynmem_device *dm = hv_get_drvdata(dev); |
1475 | struct list_head *cur, *tmp; | ||
1476 | struct hv_hotadd_state *has; | ||
1049 | 1477 | ||
1050 | if (dm->num_pages_ballooned != 0) | 1478 | if (dm->num_pages_ballooned != 0) |
1051 | pr_warn("Ballooned pages: %d\n", dm->num_pages_ballooned); | 1479 | pr_warn("Ballooned pages: %d\n", dm->num_pages_ballooned); |
1052 | 1480 | ||
1481 | cancel_work_sync(&dm->balloon_wrk.wrk); | ||
1482 | cancel_work_sync(&dm->ha_wrk.wrk); | ||
1483 | |||
1053 | vmbus_close(dev->channel); | 1484 | vmbus_close(dev->channel); |
1054 | kthread_stop(dm->thread); | 1485 | kthread_stop(dm->thread); |
1055 | kfree(send_buffer); | 1486 | kfree(send_buffer); |
1487 | #ifdef CONFIG_MEMORY_HOTPLUG | ||
1488 | restore_online_page_callback(&hv_online_page); | ||
1489 | #endif | ||
1490 | list_for_each_safe(cur, tmp, &dm->ha_region_list) { | ||
1491 | has = list_entry(cur, struct hv_hotadd_state, list); | ||
1492 | list_del(&has->list); | ||
1493 | kfree(has); | ||
1494 | } | ||
1056 | 1495 | ||
1057 | return 0; | 1496 | return 0; |
1058 | } | 1497 | } |
@@ -1079,14 +1518,7 @@ static int __init init_balloon_drv(void) | |||
1079 | return vmbus_driver_register(&balloon_drv); | 1518 | return vmbus_driver_register(&balloon_drv); |
1080 | } | 1519 | } |
1081 | 1520 | ||
1082 | static void exit_balloon_drv(void) | ||
1083 | { | ||
1084 | |||
1085 | vmbus_driver_unregister(&balloon_drv); | ||
1086 | } | ||
1087 | |||
1088 | module_init(init_balloon_drv); | 1521 | module_init(init_balloon_drv); |
1089 | module_exit(exit_balloon_drv); | ||
1090 | 1522 | ||
1091 | MODULE_DESCRIPTION("Hyper-V Balloon"); | 1523 | MODULE_DESCRIPTION("Hyper-V Balloon"); |
1092 | MODULE_VERSION(HV_DRV_VERSION); | 1524 | MODULE_VERSION(HV_DRV_VERSION); |
diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c new file mode 100644 index 000000000000..8ad5653ce447 --- /dev/null +++ b/drivers/hv/hv_snapshot.c | |||
@@ -0,0 +1,287 @@ | |||
1 | /* | ||
2 | * An implementation of host initiated guest snapshot. | ||
3 | * | ||
4 | * | ||
5 | * Copyright (C) 2013, Microsoft, Inc. | ||
6 | * Author : K. Y. Srinivasan <kys@microsoft.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License version 2 as published | ||
10 | * by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
15 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
16 | * details. | ||
17 | * | ||
18 | */ | ||
19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
20 | |||
21 | #include <linux/net.h> | ||
22 | #include <linux/nls.h> | ||
23 | #include <linux/connector.h> | ||
24 | #include <linux/workqueue.h> | ||
25 | #include <linux/hyperv.h> | ||
26 | |||
27 | |||
28 | |||
29 | /* | ||
30 | * Global state maintained for transaction that is being processed. | ||
31 | * Note that only one transaction can be active at any point in time. | ||
32 | * | ||
33 | * This state is set when we receive a request from the host; we | ||
34 | * cleanup this state when the transaction is completed - when we respond | ||
35 | * to the host with the key value. | ||
36 | */ | ||
37 | |||
38 | static struct { | ||
39 | bool active; /* transaction status - active or not */ | ||
40 | int recv_len; /* number of bytes received. */ | ||
41 | struct vmbus_channel *recv_channel; /* chn we got the request */ | ||
42 | u64 recv_req_id; /* request ID. */ | ||
43 | struct hv_vss_msg *msg; /* current message */ | ||
44 | } vss_transaction; | ||
45 | |||
46 | |||
47 | static void vss_respond_to_host(int error); | ||
48 | |||
49 | static struct cb_id vss_id = { CN_VSS_IDX, CN_VSS_VAL }; | ||
50 | static const char vss_name[] = "vss_kernel_module"; | ||
51 | static __u8 *recv_buffer; | ||
52 | |||
53 | static void vss_send_op(struct work_struct *dummy); | ||
54 | static DECLARE_WORK(vss_send_op_work, vss_send_op); | ||
55 | |||
56 | /* | ||
57 | * Callback when data is received from user mode. | ||
58 | */ | ||
59 | |||
60 | static void | ||
61 | vss_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) | ||
62 | { | ||
63 | struct hv_vss_msg *vss_msg; | ||
64 | |||
65 | vss_msg = (struct hv_vss_msg *)msg->data; | ||
66 | |||
67 | if (vss_msg->vss_hdr.operation == VSS_OP_REGISTER) { | ||
68 | pr_info("VSS daemon registered\n"); | ||
69 | vss_transaction.active = false; | ||
70 | if (vss_transaction.recv_channel != NULL) | ||
71 | hv_vss_onchannelcallback(vss_transaction.recv_channel); | ||
72 | return; | ||
73 | |||
74 | } | ||
75 | vss_respond_to_host(vss_msg->error); | ||
76 | } | ||
77 | |||
78 | |||
79 | static void vss_send_op(struct work_struct *dummy) | ||
80 | { | ||
81 | int op = vss_transaction.msg->vss_hdr.operation; | ||
82 | struct cn_msg *msg; | ||
83 | struct hv_vss_msg *vss_msg; | ||
84 | |||
85 | msg = kzalloc(sizeof(*msg) + sizeof(*vss_msg), GFP_ATOMIC); | ||
86 | if (!msg) | ||
87 | return; | ||
88 | |||
89 | vss_msg = (struct hv_vss_msg *)msg->data; | ||
90 | |||
91 | msg->id.idx = CN_VSS_IDX; | ||
92 | msg->id.val = CN_VSS_VAL; | ||
93 | |||
94 | vss_msg->vss_hdr.operation = op; | ||
95 | msg->len = sizeof(struct hv_vss_msg); | ||
96 | |||
97 | cn_netlink_send(msg, 0, GFP_ATOMIC); | ||
98 | kfree(msg); | ||
99 | |||
100 | return; | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * Send a response back to the host. | ||
105 | */ | ||
106 | |||
107 | static void | ||
108 | vss_respond_to_host(int error) | ||
109 | { | ||
110 | struct icmsg_hdr *icmsghdrp; | ||
111 | u32 buf_len; | ||
112 | struct vmbus_channel *channel; | ||
113 | u64 req_id; | ||
114 | |||
115 | /* | ||
116 | * If a transaction is not active; log and return. | ||
117 | */ | ||
118 | |||
119 | if (!vss_transaction.active) { | ||
120 | /* | ||
121 | * This is a spurious call! | ||
122 | */ | ||
123 | pr_warn("VSS: Transaction not active\n"); | ||
124 | return; | ||
125 | } | ||
126 | /* | ||
127 | * Copy the global state for completing the transaction. Note that | ||
128 | * only one transaction can be active at a time. | ||
129 | */ | ||
130 | |||
131 | buf_len = vss_transaction.recv_len; | ||
132 | channel = vss_transaction.recv_channel; | ||
133 | req_id = vss_transaction.recv_req_id; | ||
134 | vss_transaction.active = false; | ||
135 | |||
136 | icmsghdrp = (struct icmsg_hdr *) | ||
137 | &recv_buffer[sizeof(struct vmbuspipe_hdr)]; | ||
138 | |||
139 | if (channel->onchannel_callback == NULL) | ||
140 | /* | ||
141 | * We have raced with util driver being unloaded; | ||
142 | * silently return. | ||
143 | */ | ||
144 | return; | ||
145 | |||
146 | icmsghdrp->status = error; | ||
147 | |||
148 | icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; | ||
149 | |||
150 | vmbus_sendpacket(channel, recv_buffer, buf_len, req_id, | ||
151 | VM_PKT_DATA_INBAND, 0); | ||
152 | |||
153 | } | ||
154 | |||
155 | /* | ||
156 | * This callback is invoked when we get a VSS message from the host. | ||
157 | * The host ensures that only one VSS transaction can be active at a time. | ||
158 | */ | ||
159 | |||
160 | void hv_vss_onchannelcallback(void *context) | ||
161 | { | ||
162 | struct vmbus_channel *channel = context; | ||
163 | u32 recvlen; | ||
164 | u64 requestid; | ||
165 | struct hv_vss_msg *vss_msg; | ||
166 | |||
167 | |||
168 | struct icmsg_hdr *icmsghdrp; | ||
169 | struct icmsg_negotiate *negop = NULL; | ||
170 | |||
171 | if (vss_transaction.active) { | ||
172 | /* | ||
173 | * We will defer processing this callback once | ||
174 | * the current transaction is complete. | ||
175 | */ | ||
176 | vss_transaction.recv_channel = channel; | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen, | ||
181 | &requestid); | ||
182 | |||
183 | if (recvlen > 0) { | ||
184 | icmsghdrp = (struct icmsg_hdr *)&recv_buffer[ | ||
185 | sizeof(struct vmbuspipe_hdr)]; | ||
186 | |||
187 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { | ||
188 | vmbus_prep_negotiate_resp(icmsghdrp, negop, | ||
189 | recv_buffer, MAX_SRV_VER, MAX_SRV_VER); | ||
190 | /* | ||
191 | * We currently negotiate the highest number the | ||
192 | * host has presented. If this version is not | ||
193 | * atleast 5.0, reject. | ||
194 | */ | ||
195 | negop = (struct icmsg_negotiate *)&recv_buffer[ | ||
196 | sizeof(struct vmbuspipe_hdr) + | ||
197 | sizeof(struct icmsg_hdr)]; | ||
198 | |||
199 | if (negop->icversion_data[1].major < 5) | ||
200 | negop->icframe_vercnt = 0; | ||
201 | } else { | ||
202 | vss_msg = (struct hv_vss_msg *)&recv_buffer[ | ||
203 | sizeof(struct vmbuspipe_hdr) + | ||
204 | sizeof(struct icmsg_hdr)]; | ||
205 | |||
206 | /* | ||
207 | * Stash away this global state for completing the | ||
208 | * transaction; note transactions are serialized. | ||
209 | */ | ||
210 | |||
211 | vss_transaction.recv_len = recvlen; | ||
212 | vss_transaction.recv_channel = channel; | ||
213 | vss_transaction.recv_req_id = requestid; | ||
214 | vss_transaction.active = true; | ||
215 | vss_transaction.msg = (struct hv_vss_msg *)vss_msg; | ||
216 | |||
217 | switch (vss_msg->vss_hdr.operation) { | ||
218 | /* | ||
219 | * Initiate a "freeze/thaw" | ||
220 | * operation in the guest. | ||
221 | * We respond to the host once | ||
222 | * the operation is complete. | ||
223 | * | ||
224 | * We send the message to the | ||
225 | * user space daemon and the | ||
226 | * operation is performed in | ||
227 | * the daemon. | ||
228 | */ | ||
229 | case VSS_OP_FREEZE: | ||
230 | case VSS_OP_THAW: | ||
231 | schedule_work(&vss_send_op_work); | ||
232 | return; | ||
233 | |||
234 | case VSS_OP_HOT_BACKUP: | ||
235 | vss_msg->vss_cf.flags = | ||
236 | VSS_HBU_NO_AUTO_RECOVERY; | ||
237 | vss_respond_to_host(0); | ||
238 | return; | ||
239 | |||
240 | case VSS_OP_GET_DM_INFO: | ||
241 | vss_msg->dm_info.flags = 0; | ||
242 | vss_respond_to_host(0); | ||
243 | return; | ||
244 | |||
245 | default: | ||
246 | vss_respond_to_host(0); | ||
247 | return; | ||
248 | |||
249 | } | ||
250 | |||
251 | } | ||
252 | |||
253 | icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ||
254 | | ICMSGHDRFLAG_RESPONSE; | ||
255 | |||
256 | vmbus_sendpacket(channel, recv_buffer, | ||
257 | recvlen, requestid, | ||
258 | VM_PKT_DATA_INBAND, 0); | ||
259 | } | ||
260 | |||
261 | } | ||
262 | |||
263 | int | ||
264 | hv_vss_init(struct hv_util_service *srv) | ||
265 | { | ||
266 | int err; | ||
267 | |||
268 | err = cn_add_callback(&vss_id, vss_name, vss_cn_callback); | ||
269 | if (err) | ||
270 | return err; | ||
271 | recv_buffer = srv->recv_buffer; | ||
272 | |||
273 | /* | ||
274 | * When this driver loads, the user level daemon that | ||
275 | * processes the host requests may not yet be running. | ||
276 | * Defer processing channel callbacks until the daemon | ||
277 | * has registered. | ||
278 | */ | ||
279 | vss_transaction.active = true; | ||
280 | return 0; | ||
281 | } | ||
282 | |||
283 | void hv_vss_deinit(void) | ||
284 | { | ||
285 | cn_del_callback(&vss_id); | ||
286 | cancel_work_sync(&vss_send_op_work); | ||
287 | } | ||
diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index 1d4cbd8e8261..2f561c5dfe24 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c | |||
@@ -49,6 +49,12 @@ static struct hv_util_service util_kvp = { | |||
49 | .util_deinit = hv_kvp_deinit, | 49 | .util_deinit = hv_kvp_deinit, |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static struct hv_util_service util_vss = { | ||
53 | .util_cb = hv_vss_onchannelcallback, | ||
54 | .util_init = hv_vss_init, | ||
55 | .util_deinit = hv_vss_deinit, | ||
56 | }; | ||
57 | |||
52 | static void perform_shutdown(struct work_struct *dummy) | 58 | static void perform_shutdown(struct work_struct *dummy) |
53 | { | 59 | { |
54 | orderly_poweroff(true); | 60 | orderly_poweroff(true); |
@@ -339,6 +345,10 @@ static const struct hv_vmbus_device_id id_table[] = { | |||
339 | { HV_KVP_GUID, | 345 | { HV_KVP_GUID, |
340 | .driver_data = (unsigned long)&util_kvp | 346 | .driver_data = (unsigned long)&util_kvp |
341 | }, | 347 | }, |
348 | /* VSS GUID */ | ||
349 | { HV_VSS_GUID, | ||
350 | .driver_data = (unsigned long)&util_vss | ||
351 | }, | ||
342 | { }, | 352 | { }, |
343 | }; | 353 | }; |
344 | 354 | ||
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index cafa72ffdc30..d6fbb5772b8d 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c | |||
@@ -71,6 +71,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi) | |||
71 | 71 | ||
72 | static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) | 72 | static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) |
73 | { | 73 | { |
74 | smp_mb(); | ||
74 | if (rbi->ring_buffer->interrupt_mask) | 75 | if (rbi->ring_buffer->interrupt_mask) |
75 | return false; | 76 | return false; |
76 | 77 | ||
diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c index 0246b1fddffe..c276fde318e5 100644 --- a/drivers/ipack/carriers/tpci200.c +++ b/drivers/ipack/carriers/tpci200.c | |||
@@ -480,6 +480,7 @@ static void tpci200_release_device(struct ipack_device *dev) | |||
480 | 480 | ||
481 | static int tpci200_create_device(struct tpci200_board *tpci200, int i) | 481 | static int tpci200_create_device(struct tpci200_board *tpci200, int i) |
482 | { | 482 | { |
483 | int ret; | ||
483 | enum ipack_space space; | 484 | enum ipack_space space; |
484 | struct ipack_device *dev = | 485 | struct ipack_device *dev = |
485 | kzalloc(sizeof(struct ipack_device), GFP_KERNEL); | 486 | kzalloc(sizeof(struct ipack_device), GFP_KERNEL); |
@@ -495,7 +496,18 @@ static int tpci200_create_device(struct tpci200_board *tpci200, int i) | |||
495 | + tpci200_space_interval[space] * i; | 496 | + tpci200_space_interval[space] * i; |
496 | dev->region[space].size = tpci200_space_size[space]; | 497 | dev->region[space].size = tpci200_space_size[space]; |
497 | } | 498 | } |
498 | return ipack_device_register(dev); | 499 | |
500 | ret = ipack_device_init(dev); | ||
501 | if (ret < 0) { | ||
502 | ipack_put_device(dev); | ||
503 | return ret; | ||
504 | } | ||
505 | |||
506 | ret = ipack_device_add(dev); | ||
507 | if (ret < 0) | ||
508 | ipack_put_device(dev); | ||
509 | |||
510 | return ret; | ||
499 | } | 511 | } |
500 | 512 | ||
501 | static int tpci200_pci_probe(struct pci_dev *pdev, | 513 | static int tpci200_pci_probe(struct pci_dev *pdev, |
diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c index 7ec6b208b1cb..6e066c53acce 100644 --- a/drivers/ipack/ipack.c +++ b/drivers/ipack/ipack.c | |||
@@ -227,7 +227,7 @@ static int ipack_unregister_bus_member(struct device *dev, void *data) | |||
227 | struct ipack_bus_device *bus = data; | 227 | struct ipack_bus_device *bus = data; |
228 | 228 | ||
229 | if (idev->bus == bus) | 229 | if (idev->bus == bus) |
230 | ipack_device_unregister(idev); | 230 | ipack_device_del(idev); |
231 | 231 | ||
232 | return 1; | 232 | return 1; |
233 | } | 233 | } |
@@ -419,7 +419,7 @@ out: | |||
419 | return ret; | 419 | return ret; |
420 | } | 420 | } |
421 | 421 | ||
422 | int ipack_device_register(struct ipack_device *dev) | 422 | int ipack_device_init(struct ipack_device *dev) |
423 | { | 423 | { |
424 | int ret; | 424 | int ret; |
425 | 425 | ||
@@ -428,6 +428,7 @@ int ipack_device_register(struct ipack_device *dev) | |||
428 | dev->dev.parent = dev->bus->parent; | 428 | dev->dev.parent = dev->bus->parent; |
429 | dev_set_name(&dev->dev, | 429 | dev_set_name(&dev->dev, |
430 | "ipack-dev.%u.%u", dev->bus->bus_nr, dev->slot); | 430 | "ipack-dev.%u.%u", dev->bus->bus_nr, dev->slot); |
431 | device_initialize(&dev->dev); | ||
431 | 432 | ||
432 | if (dev->bus->ops->set_clockrate(dev, 8)) | 433 | if (dev->bus->ops->set_clockrate(dev, 8)) |
433 | dev_warn(&dev->dev, "failed to switch to 8 MHz operation for reading of device ID.\n"); | 434 | dev_warn(&dev->dev, "failed to switch to 8 MHz operation for reading of device ID.\n"); |
@@ -447,19 +448,34 @@ int ipack_device_register(struct ipack_device *dev) | |||
447 | dev_err(&dev->dev, "failed to switch to 32 MHz operation.\n"); | 448 | dev_err(&dev->dev, "failed to switch to 32 MHz operation.\n"); |
448 | } | 449 | } |
449 | 450 | ||
450 | ret = device_register(&dev->dev); | 451 | return 0; |
451 | if (ret < 0) | 452 | } |
452 | kfree(dev->id); | 453 | EXPORT_SYMBOL_GPL(ipack_device_init); |
453 | 454 | ||
454 | return ret; | 455 | int ipack_device_add(struct ipack_device *dev) |
456 | { | ||
457 | return device_add(&dev->dev); | ||
458 | } | ||
459 | EXPORT_SYMBOL_GPL(ipack_device_add); | ||
460 | |||
461 | void ipack_device_del(struct ipack_device *dev) | ||
462 | { | ||
463 | device_del(&dev->dev); | ||
464 | ipack_put_device(dev); | ||
465 | } | ||
466 | EXPORT_SYMBOL_GPL(ipack_device_del); | ||
467 | |||
468 | void ipack_get_device(struct ipack_device *dev) | ||
469 | { | ||
470 | get_device(&dev->dev); | ||
455 | } | 471 | } |
456 | EXPORT_SYMBOL_GPL(ipack_device_register); | 472 | EXPORT_SYMBOL_GPL(ipack_get_device); |
457 | 473 | ||
458 | void ipack_device_unregister(struct ipack_device *dev) | 474 | void ipack_put_device(struct ipack_device *dev) |
459 | { | 475 | { |
460 | device_unregister(&dev->dev); | 476 | put_device(&dev->dev); |
461 | } | 477 | } |
462 | EXPORT_SYMBOL_GPL(ipack_device_unregister); | 478 | EXPORT_SYMBOL_GPL(ipack_put_device); |
463 | 479 | ||
464 | static int __init ipack_init(void) | 480 | static int __init ipack_init(void) |
465 | { | 481 | { |
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index c21353d8e915..62b8030ee331 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c | |||
@@ -163,16 +163,4 @@ static struct pcmcia_driver avmcs_driver = { | |||
163 | .remove = avmcs_detach, | 163 | .remove = avmcs_detach, |
164 | .id_table = avmcs_ids, | 164 | .id_table = avmcs_ids, |
165 | }; | 165 | }; |
166 | 166 | module_pcmcia_driver(avmcs_driver); | |
167 | static int __init avmcs_init(void) | ||
168 | { | ||
169 | return pcmcia_register_driver(&avmcs_driver); | ||
170 | } | ||
171 | |||
172 | static void __exit avmcs_exit(void) | ||
173 | { | ||
174 | pcmcia_unregister_driver(&avmcs_driver); | ||
175 | } | ||
176 | |||
177 | module_init(avmcs_init); | ||
178 | module_exit(avmcs_exit); | ||
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 4e676bcf8506..baad94ec1f4a 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c | |||
@@ -159,16 +159,4 @@ static struct pcmcia_driver avma1cs_driver = { | |||
159 | .remove = avma1cs_detach, | 159 | .remove = avma1cs_detach, |
160 | .id_table = avma1cs_ids, | 160 | .id_table = avma1cs_ids, |
161 | }; | 161 | }; |
162 | 162 | module_pcmcia_driver(avma1cs_driver); | |
163 | static int __init init_avma1_cs(void) | ||
164 | { | ||
165 | return pcmcia_register_driver(&avma1cs_driver); | ||
166 | } | ||
167 | |||
168 | static void __exit exit_avma1_cs(void) | ||
169 | { | ||
170 | pcmcia_unregister_driver(&avma1cs_driver); | ||
171 | } | ||
172 | |||
173 | module_init(init_avma1_cs); | ||
174 | module_exit(exit_avma1_cs); | ||
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index ebe56918f6fc..40f6fad79de3 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c | |||
@@ -215,16 +215,4 @@ static struct pcmcia_driver elsa_cs_driver = { | |||
215 | .suspend = elsa_suspend, | 215 | .suspend = elsa_suspend, |
216 | .resume = elsa_resume, | 216 | .resume = elsa_resume, |
217 | }; | 217 | }; |
218 | 218 | module_pcmcia_driver(elsa_cs_driver); | |
219 | static int __init init_elsa_cs(void) | ||
220 | { | ||
221 | return pcmcia_register_driver(&elsa_cs_driver); | ||
222 | } | ||
223 | |||
224 | static void __exit exit_elsa_cs(void) | ||
225 | { | ||
226 | pcmcia_unregister_driver(&elsa_cs_driver); | ||
227 | } | ||
228 | |||
229 | module_init(init_elsa_cs); | ||
230 | module_exit(exit_elsa_cs); | ||
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 90f81291641b..92ef62d4caf4 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c | |||
@@ -206,16 +206,4 @@ static struct pcmcia_driver sedlbauer_driver = { | |||
206 | .suspend = sedlbauer_suspend, | 206 | .suspend = sedlbauer_suspend, |
207 | .resume = sedlbauer_resume, | 207 | .resume = sedlbauer_resume, |
208 | }; | 208 | }; |
209 | 209 | module_pcmcia_driver(sedlbauer_driver); | |
210 | static int __init init_sedlbauer_cs(void) | ||
211 | { | ||
212 | return pcmcia_register_driver(&sedlbauer_driver); | ||
213 | } | ||
214 | |||
215 | static void __exit exit_sedlbauer_cs(void) | ||
216 | { | ||
217 | pcmcia_unregister_driver(&sedlbauer_driver); | ||
218 | } | ||
219 | |||
220 | module_init(init_sedlbauer_cs); | ||
221 | module_exit(exit_sedlbauer_cs); | ||
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index f2476ffb04fd..b8dd14958757 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c | |||
@@ -197,16 +197,4 @@ static struct pcmcia_driver teles_cs_driver = { | |||
197 | .suspend = teles_suspend, | 197 | .suspend = teles_suspend, |
198 | .resume = teles_resume, | 198 | .resume = teles_resume, |
199 | }; | 199 | }; |
200 | 200 | module_pcmcia_driver(teles_cs_driver); | |
201 | static int __init init_teles_cs(void) | ||
202 | { | ||
203 | return pcmcia_register_driver(&teles_cs_driver); | ||
204 | } | ||
205 | |||
206 | static void __exit exit_teles_cs(void) | ||
207 | { | ||
208 | pcmcia_unregister_driver(&teles_cs_driver); | ||
209 | } | ||
210 | |||
211 | module_init(init_teles_cs); | ||
212 | module_exit(exit_teles_cs); | ||
diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c index df0873694858..cadf1cc19aaf 100644 --- a/drivers/memory/emif.c +++ b/drivers/memory/emif.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/list.h> | 26 | #include <linux/list.h> |
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | #include <linux/pm.h> | ||
28 | #include <memory/jedec_ddr.h> | 29 | #include <memory/jedec_ddr.h> |
29 | #include "emif.h" | 30 | #include "emif.h" |
30 | #include "of_memory.h" | 31 | #include "of_memory.h" |
@@ -256,6 +257,41 @@ static void set_lpmode(struct emif_data *emif, u8 lpmode) | |||
256 | u32 temp; | 257 | u32 temp; |
257 | void __iomem *base = emif->base; | 258 | void __iomem *base = emif->base; |
258 | 259 | ||
260 | /* | ||
261 | * Workaround for errata i743 - LPDDR2 Power-Down State is Not | ||
262 | * Efficient | ||
263 | * | ||
264 | * i743 DESCRIPTION: | ||
265 | * The EMIF supports power-down state for low power. The EMIF | ||
266 | * automatically puts the SDRAM into power-down after the memory is | ||
267 | * not accessed for a defined number of cycles and the | ||
268 | * EMIF_PWR_MGMT_CTRL[10:8] REG_LP_MODE bit field is set to 0x4. | ||
269 | * As the EMIF supports automatic output impedance calibration, a ZQ | ||
270 | * calibration long command is issued every time it exits active | ||
271 | * power-down and precharge power-down modes. The EMIF waits and | ||
272 | * blocks any other command during this calibration. | ||
273 | * The EMIF does not allow selective disabling of ZQ calibration upon | ||
274 | * exit of power-down mode. Due to very short periods of power-down | ||
275 | * cycles, ZQ calibration overhead creates bandwidth issues and | ||
276 | * increases overall system power consumption. On the other hand, | ||
277 | * issuing ZQ calibration long commands when exiting self-refresh is | ||
278 | * still required. | ||
279 | * | ||
280 | * WORKAROUND | ||
281 | * Because there is no power consumption benefit of the power-down due | ||
282 | * to the calibration and there is a performance risk, the guideline | ||
283 | * is to not allow power-down state and, therefore, to not have set | ||
284 | * the EMIF_PWR_MGMT_CTRL[10:8] REG_LP_MODE bit field to 0x4. | ||
285 | */ | ||
286 | if ((emif->plat_data->ip_rev == EMIF_4D) && | ||
287 | (EMIF_LP_MODE_PWR_DN == lpmode)) { | ||
288 | WARN_ONCE(1, | ||
289 | "REG_LP_MODE = LP_MODE_PWR_DN(4) is prohibited by" | ||
290 | "erratum i743 switch to LP_MODE_SELF_REFRESH(2)\n"); | ||
291 | /* rollback LP_MODE to Self-refresh mode */ | ||
292 | lpmode = EMIF_LP_MODE_SELF_REFRESH; | ||
293 | } | ||
294 | |||
259 | temp = readl(base + EMIF_POWER_MANAGEMENT_CONTROL); | 295 | temp = readl(base + EMIF_POWER_MANAGEMENT_CONTROL); |
260 | temp &= ~LP_MODE_MASK; | 296 | temp &= ~LP_MODE_MASK; |
261 | temp |= (lpmode << LP_MODE_SHIFT); | 297 | temp |= (lpmode << LP_MODE_SHIFT); |
@@ -715,6 +751,8 @@ static u32 get_pwr_mgmt_ctrl(u32 freq, struct emif_data *emif, u32 ip_rev) | |||
715 | u32 timeout_perf = EMIF_LP_MODE_TIMEOUT_PERFORMANCE; | 751 | u32 timeout_perf = EMIF_LP_MODE_TIMEOUT_PERFORMANCE; |
716 | u32 timeout_pwr = EMIF_LP_MODE_TIMEOUT_POWER; | 752 | u32 timeout_pwr = EMIF_LP_MODE_TIMEOUT_POWER; |
717 | u32 freq_threshold = EMIF_LP_MODE_FREQ_THRESHOLD; | 753 | u32 freq_threshold = EMIF_LP_MODE_FREQ_THRESHOLD; |
754 | u32 mask; | ||
755 | u8 shift; | ||
718 | 756 | ||
719 | struct emif_custom_configs *cust_cfgs = emif->plat_data->custom_configs; | 757 | struct emif_custom_configs *cust_cfgs = emif->plat_data->custom_configs; |
720 | 758 | ||
@@ -728,37 +766,59 @@ static u32 get_pwr_mgmt_ctrl(u32 freq, struct emif_data *emif, u32 ip_rev) | |||
728 | /* Timeout based on DDR frequency */ | 766 | /* Timeout based on DDR frequency */ |
729 | timeout = freq >= freq_threshold ? timeout_perf : timeout_pwr; | 767 | timeout = freq >= freq_threshold ? timeout_perf : timeout_pwr; |
730 | 768 | ||
731 | /* The value to be set in register is "log2(timeout) - 3" */ | 769 | /* |
770 | * The value to be set in register is "log2(timeout) - 3" | ||
771 | * if timeout < 16 load 0 in register | ||
772 | * if timeout is not a power of 2, round to next highest power of 2 | ||
773 | */ | ||
732 | if (timeout < 16) { | 774 | if (timeout < 16) { |
733 | timeout = 0; | 775 | timeout = 0; |
734 | } else { | 776 | } else { |
735 | timeout = __fls(timeout) - 3; | ||
736 | if (timeout & (timeout - 1)) | 777 | if (timeout & (timeout - 1)) |
737 | timeout++; | 778 | timeout <<= 1; |
779 | timeout = __fls(timeout) - 3; | ||
738 | } | 780 | } |
739 | 781 | ||
740 | switch (lpmode) { | 782 | switch (lpmode) { |
741 | case EMIF_LP_MODE_CLOCK_STOP: | 783 | case EMIF_LP_MODE_CLOCK_STOP: |
742 | pwr_mgmt_ctrl = (timeout << CS_TIM_SHIFT) | | 784 | shift = CS_TIM_SHIFT; |
743 | SR_TIM_MASK | PD_TIM_MASK; | 785 | mask = CS_TIM_MASK; |
744 | break; | 786 | break; |
745 | case EMIF_LP_MODE_SELF_REFRESH: | 787 | case EMIF_LP_MODE_SELF_REFRESH: |
746 | /* Workaround for errata i735 */ | 788 | /* Workaround for errata i735 */ |
747 | if (timeout < 6) | 789 | if (timeout < 6) |
748 | timeout = 6; | 790 | timeout = 6; |
749 | 791 | ||
750 | pwr_mgmt_ctrl = (timeout << SR_TIM_SHIFT) | | 792 | shift = SR_TIM_SHIFT; |
751 | CS_TIM_MASK | PD_TIM_MASK; | 793 | mask = SR_TIM_MASK; |
752 | break; | 794 | break; |
753 | case EMIF_LP_MODE_PWR_DN: | 795 | case EMIF_LP_MODE_PWR_DN: |
754 | pwr_mgmt_ctrl = (timeout << PD_TIM_SHIFT) | | 796 | shift = PD_TIM_SHIFT; |
755 | CS_TIM_MASK | SR_TIM_MASK; | 797 | mask = PD_TIM_MASK; |
756 | break; | 798 | break; |
757 | case EMIF_LP_MODE_DISABLE: | 799 | case EMIF_LP_MODE_DISABLE: |
758 | default: | 800 | default: |
759 | pwr_mgmt_ctrl = CS_TIM_MASK | | 801 | mask = 0; |
760 | PD_TIM_MASK | SR_TIM_MASK; | 802 | shift = 0; |
803 | break; | ||
761 | } | 804 | } |
805 | /* Round to maximum in case of overflow, BUT warn! */ | ||
806 | if (lpmode != EMIF_LP_MODE_DISABLE && timeout > mask >> shift) { | ||
807 | pr_err("TIMEOUT Overflow - lpmode=%d perf=%d pwr=%d freq=%d\n", | ||
808 | lpmode, | ||
809 | timeout_perf, | ||
810 | timeout_pwr, | ||
811 | freq_threshold); | ||
812 | WARN(1, "timeout=0x%02x greater than 0x%02x. Using max\n", | ||
813 | timeout, mask >> shift); | ||
814 | timeout = mask >> shift; | ||
815 | } | ||
816 | |||
817 | /* Setup required timing */ | ||
818 | pwr_mgmt_ctrl = (timeout << shift) & mask; | ||
819 | /* setup a default mask for rest of the modes */ | ||
820 | pwr_mgmt_ctrl |= (SR_TIM_MASK | CS_TIM_MASK | PD_TIM_MASK) & | ||
821 | ~mask; | ||
762 | 822 | ||
763 | /* No CS_TIM in EMIF_4D5 */ | 823 | /* No CS_TIM in EMIF_4D5 */ |
764 | if (ip_rev == EMIF_4D5) | 824 | if (ip_rev == EMIF_4D5) |
@@ -815,6 +875,8 @@ static void setup_registers(struct emif_data *emif, struct emif_regs *regs) | |||
815 | 875 | ||
816 | writel(regs->sdram_tim2_shdw, base + EMIF_SDRAM_TIMING_2_SHDW); | 876 | writel(regs->sdram_tim2_shdw, base + EMIF_SDRAM_TIMING_2_SHDW); |
817 | writel(regs->phy_ctrl_1_shdw, base + EMIF_DDR_PHY_CTRL_1_SHDW); | 877 | writel(regs->phy_ctrl_1_shdw, base + EMIF_DDR_PHY_CTRL_1_SHDW); |
878 | writel(regs->pwr_mgmt_ctrl_shdw, | ||
879 | base + EMIF_POWER_MANAGEMENT_CTRL_SHDW); | ||
818 | 880 | ||
819 | /* Settings specific for EMIF4D5 */ | 881 | /* Settings specific for EMIF4D5 */ |
820 | if (emif->plat_data->ip_rev != EMIF_4D5) | 882 | if (emif->plat_data->ip_rev != EMIF_4D5) |
@@ -892,6 +954,7 @@ static irqreturn_t handle_temp_alert(void __iomem *base, struct emif_data *emif) | |||
892 | { | 954 | { |
893 | u32 old_temp_level; | 955 | u32 old_temp_level; |
894 | irqreturn_t ret = IRQ_HANDLED; | 956 | irqreturn_t ret = IRQ_HANDLED; |
957 | struct emif_custom_configs *custom_configs; | ||
895 | 958 | ||
896 | spin_lock_irqsave(&emif_lock, irq_state); | 959 | spin_lock_irqsave(&emif_lock, irq_state); |
897 | old_temp_level = emif->temperature_level; | 960 | old_temp_level = emif->temperature_level; |
@@ -904,6 +967,29 @@ static irqreturn_t handle_temp_alert(void __iomem *base, struct emif_data *emif) | |||
904 | goto out; | 967 | goto out; |
905 | } | 968 | } |
906 | 969 | ||
970 | custom_configs = emif->plat_data->custom_configs; | ||
971 | |||
972 | /* | ||
973 | * IF we detect higher than "nominal rating" from DDR sensor | ||
974 | * on an unsupported DDR part, shutdown system | ||
975 | */ | ||
976 | if (custom_configs && !(custom_configs->mask & | ||
977 | EMIF_CUSTOM_CONFIG_EXTENDED_TEMP_PART)) { | ||
978 | if (emif->temperature_level >= SDRAM_TEMP_HIGH_DERATE_REFRESH) { | ||
979 | dev_err(emif->dev, | ||
980 | "%s:NOT Extended temperature capable memory." | ||
981 | "Converting MR4=0x%02x as shutdown event\n", | ||
982 | __func__, emif->temperature_level); | ||
983 | /* | ||
984 | * Temperature far too high - do kernel_power_off() | ||
985 | * from thread context | ||
986 | */ | ||
987 | emif->temperature_level = SDRAM_TEMP_VERY_HIGH_SHUTDOWN; | ||
988 | ret = IRQ_WAKE_THREAD; | ||
989 | goto out; | ||
990 | } | ||
991 | } | ||
992 | |||
907 | if (emif->temperature_level < old_temp_level || | 993 | if (emif->temperature_level < old_temp_level || |
908 | emif->temperature_level == SDRAM_TEMP_VERY_HIGH_SHUTDOWN) { | 994 | emif->temperature_level == SDRAM_TEMP_VERY_HIGH_SHUTDOWN) { |
909 | /* | 995 | /* |
@@ -965,7 +1051,14 @@ static irqreturn_t emif_threaded_isr(int irq, void *dev_id) | |||
965 | 1051 | ||
966 | if (emif->temperature_level == SDRAM_TEMP_VERY_HIGH_SHUTDOWN) { | 1052 | if (emif->temperature_level == SDRAM_TEMP_VERY_HIGH_SHUTDOWN) { |
967 | dev_emerg(emif->dev, "SDRAM temperature exceeds operating limit.. Needs shut down!!!\n"); | 1053 | dev_emerg(emif->dev, "SDRAM temperature exceeds operating limit.. Needs shut down!!!\n"); |
968 | kernel_power_off(); | 1054 | |
1055 | /* If we have Power OFF ability, use it, else try restarting */ | ||
1056 | if (pm_power_off) { | ||
1057 | kernel_power_off(); | ||
1058 | } else { | ||
1059 | WARN(1, "FIXME: NO pm_power_off!!! trying restart\n"); | ||
1060 | kernel_restart("SDRAM Over-temp Emergency restart"); | ||
1061 | } | ||
969 | return IRQ_HANDLED; | 1062 | return IRQ_HANDLED; |
970 | } | 1063 | } |
971 | 1064 | ||
@@ -1170,7 +1263,7 @@ static void __init_or_module of_get_custom_configs(struct device_node *np_emif, | |||
1170 | { | 1263 | { |
1171 | struct emif_custom_configs *cust_cfgs = NULL; | 1264 | struct emif_custom_configs *cust_cfgs = NULL; |
1172 | int len; | 1265 | int len; |
1173 | const int *lpmode, *poll_intvl; | 1266 | const __be32 *lpmode, *poll_intvl; |
1174 | 1267 | ||
1175 | lpmode = of_get_property(np_emif, "low-power-mode", &len); | 1268 | lpmode = of_get_property(np_emif, "low-power-mode", &len); |
1176 | poll_intvl = of_get_property(np_emif, "temp-alert-poll-interval", &len); | 1269 | poll_intvl = of_get_property(np_emif, "temp-alert-poll-interval", &len); |
@@ -1184,7 +1277,7 @@ static void __init_or_module of_get_custom_configs(struct device_node *np_emif, | |||
1184 | 1277 | ||
1185 | if (lpmode) { | 1278 | if (lpmode) { |
1186 | cust_cfgs->mask |= EMIF_CUSTOM_CONFIG_LPMODE; | 1279 | cust_cfgs->mask |= EMIF_CUSTOM_CONFIG_LPMODE; |
1187 | cust_cfgs->lpmode = *lpmode; | 1280 | cust_cfgs->lpmode = be32_to_cpup(lpmode); |
1188 | of_property_read_u32(np_emif, | 1281 | of_property_read_u32(np_emif, |
1189 | "low-power-mode-timeout-performance", | 1282 | "low-power-mode-timeout-performance", |
1190 | &cust_cfgs->lpmode_timeout_performance); | 1283 | &cust_cfgs->lpmode_timeout_performance); |
@@ -1199,9 +1292,13 @@ static void __init_or_module of_get_custom_configs(struct device_node *np_emif, | |||
1199 | if (poll_intvl) { | 1292 | if (poll_intvl) { |
1200 | cust_cfgs->mask |= | 1293 | cust_cfgs->mask |= |
1201 | EMIF_CUSTOM_CONFIG_TEMP_ALERT_POLL_INTERVAL; | 1294 | EMIF_CUSTOM_CONFIG_TEMP_ALERT_POLL_INTERVAL; |
1202 | cust_cfgs->temp_alert_poll_interval_ms = *poll_intvl; | 1295 | cust_cfgs->temp_alert_poll_interval_ms = |
1296 | be32_to_cpup(poll_intvl); | ||
1203 | } | 1297 | } |
1204 | 1298 | ||
1299 | if (of_find_property(np_emif, "extended-temp-part", &len)) | ||
1300 | cust_cfgs->mask |= EMIF_CUSTOM_CONFIG_EXTENDED_TEMP_PART; | ||
1301 | |||
1205 | if (!is_custom_config_valid(cust_cfgs, emif->dev)) { | 1302 | if (!is_custom_config_valid(cust_cfgs, emif->dev)) { |
1206 | devm_kfree(emif->dev, cust_cfgs); | 1303 | devm_kfree(emif->dev, cust_cfgs); |
1207 | return; | 1304 | return; |
@@ -1407,7 +1504,7 @@ static struct emif_data *__init_or_module get_device_details( | |||
1407 | if (pd->timings) { | 1504 | if (pd->timings) { |
1408 | temp = devm_kzalloc(dev, size, GFP_KERNEL); | 1505 | temp = devm_kzalloc(dev, size, GFP_KERNEL); |
1409 | if (temp) { | 1506 | if (temp) { |
1410 | memcpy(temp, pd->timings, sizeof(*pd->timings)); | 1507 | memcpy(temp, pd->timings, size); |
1411 | pd->timings = temp; | 1508 | pd->timings = temp; |
1412 | } else { | 1509 | } else { |
1413 | dev_warn(dev, "%s:%d: allocation error\n", __func__, | 1510 | dev_warn(dev, "%s:%d: allocation error\n", __func__, |
@@ -1841,18 +1938,8 @@ static struct platform_driver emif_driver = { | |||
1841 | }, | 1938 | }, |
1842 | }; | 1939 | }; |
1843 | 1940 | ||
1844 | static int __init_or_module emif_register(void) | 1941 | module_platform_driver_probe(emif_driver, emif_probe); |
1845 | { | ||
1846 | return platform_driver_probe(&emif_driver, emif_probe); | ||
1847 | } | ||
1848 | |||
1849 | static void __exit emif_unregister(void) | ||
1850 | { | ||
1851 | platform_driver_unregister(&emif_driver); | ||
1852 | } | ||
1853 | 1942 | ||
1854 | module_init(emif_register); | ||
1855 | module_exit(emif_unregister); | ||
1856 | MODULE_DESCRIPTION("TI EMIF SDRAM Controller Driver"); | 1943 | MODULE_DESCRIPTION("TI EMIF SDRAM Controller Driver"); |
1857 | MODULE_LICENSE("GPL"); | 1944 | MODULE_LICENSE("GPL"); |
1858 | MODULE_ALIAS("platform:emif"); | 1945 | MODULE_ALIAS("platform:emif"); |
diff --git a/drivers/memory/tegra30-mc.c b/drivers/memory/tegra30-mc.c index 0b975986777d..f4ae074badc3 100644 --- a/drivers/memory/tegra30-mc.c +++ b/drivers/memory/tegra30-mc.c | |||
@@ -268,6 +268,7 @@ static const u32 tegra30_mc_ctx[] = { | |||
268 | MC_INTMASK, | 268 | MC_INTMASK, |
269 | }; | 269 | }; |
270 | 270 | ||
271 | #ifdef CONFIG_PM | ||
271 | static int tegra30_mc_suspend(struct device *dev) | 272 | static int tegra30_mc_suspend(struct device *dev) |
272 | { | 273 | { |
273 | int i; | 274 | int i; |
@@ -291,6 +292,7 @@ static int tegra30_mc_resume(struct device *dev) | |||
291 | mc_readl(mc, MC_TIMING_CONTROL); | 292 | mc_readl(mc, MC_TIMING_CONTROL); |
292 | return 0; | 293 | return 0; |
293 | } | 294 | } |
295 | #endif | ||
294 | 296 | ||
295 | static UNIVERSAL_DEV_PM_OPS(tegra30_mc_pm, | 297 | static UNIVERSAL_DEV_PM_OPS(tegra30_mc_pm, |
296 | tegra30_mc_suspend, | 298 | tegra30_mc_suspend, |
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index c346941a2515..ca86581d02ce 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -991,7 +991,7 @@ config MFD_PM8XXX | |||
991 | 991 | ||
992 | config MFD_PM8921_CORE | 992 | config MFD_PM8921_CORE |
993 | tristate "Qualcomm PM8921 PMIC chip" | 993 | tristate "Qualcomm PM8921 PMIC chip" |
994 | depends on MSM_SSBI | 994 | depends on SSBI && BROKEN |
995 | select MFD_CORE | 995 | select MFD_CORE |
996 | select MFD_PM8XXX | 996 | select MFD_PM8XXX |
997 | help | 997 | help |
diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c index d4b297cbd801..ecc137ffa8c3 100644 --- a/drivers/mfd/pm8921-core.c +++ b/drivers/mfd/pm8921-core.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/err.h> | 19 | #include <linux/err.h> |
20 | #include <linux/msm_ssbi.h> | 20 | #include <linux/ssbi.h> |
21 | #include <linux/mfd/core.h> | 21 | #include <linux/mfd/core.h> |
22 | #include <linux/mfd/pm8xxx/pm8921.h> | 22 | #include <linux/mfd/pm8xxx/pm8921.h> |
23 | #include <linux/mfd/pm8xxx/core.h> | 23 | #include <linux/mfd/pm8xxx/core.h> |
@@ -35,7 +35,7 @@ static int pm8921_readb(const struct device *dev, u16 addr, u8 *val) | |||
35 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | 35 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); |
36 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | 36 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; |
37 | 37 | ||
38 | return msm_ssbi_read(pmic->dev->parent, addr, val, 1); | 38 | return ssbi_read(pmic->dev->parent, addr, val, 1); |
39 | } | 39 | } |
40 | 40 | ||
41 | static int pm8921_writeb(const struct device *dev, u16 addr, u8 val) | 41 | static int pm8921_writeb(const struct device *dev, u16 addr, u8 val) |
@@ -43,7 +43,7 @@ static int pm8921_writeb(const struct device *dev, u16 addr, u8 val) | |||
43 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | 43 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); |
44 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | 44 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; |
45 | 45 | ||
46 | return msm_ssbi_write(pmic->dev->parent, addr, &val, 1); | 46 | return ssbi_write(pmic->dev->parent, addr, &val, 1); |
47 | } | 47 | } |
48 | 48 | ||
49 | static int pm8921_read_buf(const struct device *dev, u16 addr, u8 *buf, | 49 | static int pm8921_read_buf(const struct device *dev, u16 addr, u8 *buf, |
@@ -52,7 +52,7 @@ static int pm8921_read_buf(const struct device *dev, u16 addr, u8 *buf, | |||
52 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | 52 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); |
53 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | 53 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; |
54 | 54 | ||
55 | return msm_ssbi_read(pmic->dev->parent, addr, buf, cnt); | 55 | return ssbi_read(pmic->dev->parent, addr, buf, cnt); |
56 | } | 56 | } |
57 | 57 | ||
58 | static int pm8921_write_buf(const struct device *dev, u16 addr, u8 *buf, | 58 | static int pm8921_write_buf(const struct device *dev, u16 addr, u8 *buf, |
@@ -61,7 +61,7 @@ static int pm8921_write_buf(const struct device *dev, u16 addr, u8 *buf, | |||
61 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | 61 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); |
62 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | 62 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; |
63 | 63 | ||
64 | return msm_ssbi_write(pmic->dev->parent, addr, buf, cnt); | 64 | return ssbi_write(pmic->dev->parent, addr, buf, cnt); |
65 | } | 65 | } |
66 | 66 | ||
67 | static int pm8921_read_irq_stat(const struct device *dev, int irq) | 67 | static int pm8921_read_irq_stat(const struct device *dev, int irq) |
@@ -124,7 +124,7 @@ static int pm8921_probe(struct platform_device *pdev) | |||
124 | } | 124 | } |
125 | 125 | ||
126 | /* Read PMIC chip revision */ | 126 | /* Read PMIC chip revision */ |
127 | rc = msm_ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); | 127 | rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); |
128 | if (rc) { | 128 | if (rc) { |
129 | pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); | 129 | pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); |
130 | goto err_read_rev; | 130 | goto err_read_rev; |
@@ -133,7 +133,7 @@ static int pm8921_probe(struct platform_device *pdev) | |||
133 | rev = val; | 133 | rev = val; |
134 | 134 | ||
135 | /* Read PMIC chip revision 2 */ | 135 | /* Read PMIC chip revision 2 */ |
136 | rc = msm_ssbi_read(pdev->dev.parent, REG_HWREV_2, &val, sizeof(val)); | 136 | rc = ssbi_read(pdev->dev.parent, REG_HWREV_2, &val, sizeof(val)); |
137 | if (rc) { | 137 | if (rc) { |
138 | pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", | 138 | pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", |
139 | REG_HWREV_2, rc); | 139 | REG_HWREV_2, rc); |
diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c index a433f580aa4c..ca2aed6bc830 100644 --- a/drivers/mfd/wm5102-tables.c +++ b/drivers/mfd/wm5102-tables.c | |||
@@ -331,6 +331,10 @@ static const struct reg_default wm5102_reg_default[] = { | |||
331 | { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */ | 331 | { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */ |
332 | { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */ | 332 | { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */ |
333 | { 0x000002A5, 0x0000 }, /* R677 - Mic Detect 3 */ | 333 | { 0x000002A5, 0x0000 }, /* R677 - Mic Detect 3 */ |
334 | { 0x000002A6, 0x3737 }, /* R678 - Mic Detect Level 1 */ | ||
335 | { 0x000002A7, 0x372C }, /* R679 - Mic Detect Level 2 */ | ||
336 | { 0x000002A8, 0x1422 }, /* R680 - Mic Detect Level 3 */ | ||
337 | { 0x000002A9, 0x030A }, /* R681 - Mic Detect Level 4 */ | ||
334 | { 0x000002C3, 0x0000 }, /* R707 - Mic noise mix control 1 */ | 338 | { 0x000002C3, 0x0000 }, /* R707 - Mic noise mix control 1 */ |
335 | { 0x000002CB, 0x0000 }, /* R715 - Isolation control */ | 339 | { 0x000002CB, 0x0000 }, /* R715 - Isolation control */ |
336 | { 0x000002D3, 0x0000 }, /* R723 - Jack detect analogue */ | 340 | { 0x000002D3, 0x0000 }, /* R723 - Jack detect analogue */ |
@@ -1090,6 +1094,10 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg) | |||
1090 | case ARIZONA_MIC_DETECT_1: | 1094 | case ARIZONA_MIC_DETECT_1: |
1091 | case ARIZONA_MIC_DETECT_2: | 1095 | case ARIZONA_MIC_DETECT_2: |
1092 | case ARIZONA_MIC_DETECT_3: | 1096 | case ARIZONA_MIC_DETECT_3: |
1097 | case ARIZONA_MIC_DETECT_LEVEL_1: | ||
1098 | case ARIZONA_MIC_DETECT_LEVEL_2: | ||
1099 | case ARIZONA_MIC_DETECT_LEVEL_3: | ||
1100 | case ARIZONA_MIC_DETECT_LEVEL_4: | ||
1093 | case ARIZONA_MIC_NOISE_MIX_CONTROL_1: | 1101 | case ARIZONA_MIC_NOISE_MIX_CONTROL_1: |
1094 | case ARIZONA_ISOLATION_CONTROL: | 1102 | case ARIZONA_ISOLATION_CONTROL: |
1095 | case ARIZONA_JACK_DETECT_ANALOGUE: | 1103 | case ARIZONA_JACK_DETECT_ANALOGUE: |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index e83fdfe0c8ca..69bb79d6dd54 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -93,6 +93,14 @@ config ATMEL_TCB_CLKSRC_BLOCK | |||
93 | TC can be used for other purposes, such as PWM generation and | 93 | TC can be used for other purposes, such as PWM generation and |
94 | interval timing. | 94 | interval timing. |
95 | 95 | ||
96 | config DUMMY_IRQ | ||
97 | tristate "Dummy IRQ handler" | ||
98 | default n | ||
99 | ---help--- | ||
100 | This module accepts a single 'irq' parameter, which it should register for. | ||
101 | The sole purpose of this module is to help with debugging of systems on | ||
102 | which spurious IRQs would happen on disabled IRQ vector. | ||
103 | |||
96 | config IBM_ASM | 104 | config IBM_ASM |
97 | tristate "Device driver for IBM RSA service processor" | 105 | tristate "Device driver for IBM RSA service processor" |
98 | depends on X86 && PCI && INPUT | 106 | depends on X86 && PCI && INPUT |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 35a1463c72d9..865cbc6a7ae1 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -13,6 +13,7 @@ obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o | |||
13 | obj-$(CONFIG_BMP085) += bmp085.o | 13 | obj-$(CONFIG_BMP085) += bmp085.o |
14 | obj-$(CONFIG_BMP085_I2C) += bmp085-i2c.o | 14 | obj-$(CONFIG_BMP085_I2C) += bmp085-i2c.o |
15 | obj-$(CONFIG_BMP085_SPI) += bmp085-spi.o | 15 | obj-$(CONFIG_BMP085_SPI) += bmp085-spi.o |
16 | obj-$(CONFIG_DUMMY_IRQ) += dummy-irq.o | ||
16 | obj-$(CONFIG_ICS932S401) += ics932s401.o | 17 | obj-$(CONFIG_ICS932S401) += ics932s401.o |
17 | obj-$(CONFIG_LKDTM) += lkdtm.o | 18 | obj-$(CONFIG_LKDTM) += lkdtm.o |
18 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o | 19 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o |
@@ -49,6 +50,5 @@ obj-y += carma/ | |||
49 | obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o | 50 | obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o |
50 | obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/ | 51 | obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/ |
51 | obj-$(CONFIG_INTEL_MEI) += mei/ | 52 | obj-$(CONFIG_INTEL_MEI) += mei/ |
52 | obj-$(CONFIG_MAX8997_MUIC) += max8997-muic.o | ||
53 | obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ | 53 | obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ |
54 | obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o | 54 | obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o |
diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c index 0e67f8263cd8..98f9bb26492a 100644 --- a/drivers/misc/apds990x.c +++ b/drivers/misc/apds990x.c | |||
@@ -700,9 +700,6 @@ static ssize_t apds990x_lux_calib_store(struct device *dev, | |||
700 | if (strict_strtoul(buf, 0, &value)) | 700 | if (strict_strtoul(buf, 0, &value)) |
701 | return -EINVAL; | 701 | return -EINVAL; |
702 | 702 | ||
703 | if (chip->lux_calib > APDS_RANGE) | ||
704 | return -EINVAL; | ||
705 | |||
706 | chip->lux_calib = value; | 703 | chip->lux_calib = value; |
707 | 704 | ||
708 | return len; | 705 | return len; |
@@ -1204,7 +1201,7 @@ static int apds990x_remove(struct i2c_client *client) | |||
1204 | return 0; | 1201 | return 0; |
1205 | } | 1202 | } |
1206 | 1203 | ||
1207 | #ifdef CONFIG_PM | 1204 | #ifdef CONFIG_PM_SLEEP |
1208 | static int apds990x_suspend(struct device *dev) | 1205 | static int apds990x_suspend(struct device *dev) |
1209 | { | 1206 | { |
1210 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); | 1207 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); |
@@ -1227,10 +1224,6 @@ static int apds990x_resume(struct device *dev) | |||
1227 | 1224 | ||
1228 | return 0; | 1225 | return 0; |
1229 | } | 1226 | } |
1230 | #else | ||
1231 | #define apds990x_suspend NULL | ||
1232 | #define apds990x_resume NULL | ||
1233 | #define apds990x_shutdown NULL | ||
1234 | #endif | 1227 | #endif |
1235 | 1228 | ||
1236 | #ifdef CONFIG_PM_RUNTIME | 1229 | #ifdef CONFIG_PM_RUNTIME |
diff --git a/drivers/misc/arm-charlcd.c b/drivers/misc/arm-charlcd.c index fe8616a8d287..48651ef0028c 100644 --- a/drivers/misc/arm-charlcd.c +++ b/drivers/misc/arm-charlcd.c | |||
@@ -378,18 +378,7 @@ static struct platform_driver charlcd_driver = { | |||
378 | .remove = __exit_p(charlcd_remove), | 378 | .remove = __exit_p(charlcd_remove), |
379 | }; | 379 | }; |
380 | 380 | ||
381 | static int __init charlcd_init(void) | 381 | module_platform_driver_probe(charlcd_driver, charlcd_probe); |
382 | { | ||
383 | return platform_driver_probe(&charlcd_driver, charlcd_probe); | ||
384 | } | ||
385 | |||
386 | static void __exit charlcd_exit(void) | ||
387 | { | ||
388 | platform_driver_unregister(&charlcd_driver); | ||
389 | } | ||
390 | |||
391 | module_init(charlcd_init); | ||
392 | module_exit(charlcd_exit); | ||
393 | 382 | ||
394 | MODULE_AUTHOR("Linus Walleij <triad@df.lth.se>"); | 383 | MODULE_AUTHOR("Linus Walleij <triad@df.lth.se>"); |
395 | MODULE_DESCRIPTION("ARM Character LCD Driver"); | 384 | MODULE_DESCRIPTION("ARM Character LCD Driver"); |
diff --git a/drivers/misc/atmel_pwm.c b/drivers/misc/atmel_pwm.c index 28f5aaa19d4a..494d0500bda6 100644 --- a/drivers/misc/atmel_pwm.c +++ b/drivers/misc/atmel_pwm.c | |||
@@ -393,17 +393,7 @@ static struct platform_driver atmel_pwm_driver = { | |||
393 | */ | 393 | */ |
394 | }; | 394 | }; |
395 | 395 | ||
396 | static int __init pwm_init(void) | 396 | module_platform_driver_probe(atmel_pwm_driver, pwm_probe); |
397 | { | ||
398 | return platform_driver_probe(&atmel_pwm_driver, pwm_probe); | ||
399 | } | ||
400 | module_init(pwm_init); | ||
401 | |||
402 | static void __exit pwm_exit(void) | ||
403 | { | ||
404 | platform_driver_unregister(&atmel_pwm_driver); | ||
405 | } | ||
406 | module_exit(pwm_exit); | ||
407 | 397 | ||
408 | MODULE_DESCRIPTION("Driver for AT32/AT91 PWM module"); | 398 | MODULE_DESCRIPTION("Driver for AT32/AT91 PWM module"); |
409 | MODULE_LICENSE("GPL"); | 399 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c index 2ed8fc3be7e6..f4975f7d0d5b 100644 --- a/drivers/misc/bh1770glc.c +++ b/drivers/misc/bh1770glc.c | |||
@@ -1310,7 +1310,7 @@ static int bh1770_remove(struct i2c_client *client) | |||
1310 | return 0; | 1310 | return 0; |
1311 | } | 1311 | } |
1312 | 1312 | ||
1313 | #ifdef CONFIG_PM | 1313 | #ifdef CONFIG_PM_SLEEP |
1314 | static int bh1770_suspend(struct device *dev) | 1314 | static int bh1770_suspend(struct device *dev) |
1315 | { | 1315 | { |
1316 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); | 1316 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); |
@@ -1346,11 +1346,6 @@ static int bh1770_resume(struct device *dev) | |||
1346 | } | 1346 | } |
1347 | return ret; | 1347 | return ret; |
1348 | } | 1348 | } |
1349 | |||
1350 | #else | ||
1351 | #define bh1770_suspend NULL | ||
1352 | #define bh1770_shutdown NULL | ||
1353 | #define bh1770_resume NULL | ||
1354 | #endif | 1349 | #endif |
1355 | 1350 | ||
1356 | #ifdef CONFIG_PM_RUNTIME | 1351 | #ifdef CONFIG_PM_RUNTIME |
diff --git a/drivers/misc/bh1780gli.c b/drivers/misc/bh1780gli.c index cf03d0abf33e..818f3a0e62bf 100644 --- a/drivers/misc/bh1780gli.c +++ b/drivers/misc/bh1780gli.c | |||
@@ -196,7 +196,7 @@ static int bh1780_remove(struct i2c_client *client) | |||
196 | return 0; | 196 | return 0; |
197 | } | 197 | } |
198 | 198 | ||
199 | #ifdef CONFIG_PM | 199 | #ifdef CONFIG_PM_SLEEP |
200 | static int bh1780_suspend(struct device *dev) | 200 | static int bh1780_suspend(struct device *dev) |
201 | { | 201 | { |
202 | struct bh1780_data *ddata; | 202 | struct bh1780_data *ddata; |
@@ -235,11 +235,9 @@ static int bh1780_resume(struct device *dev) | |||
235 | 235 | ||
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | #endif /* CONFIG_PM_SLEEP */ | ||
239 | |||
238 | static SIMPLE_DEV_PM_OPS(bh1780_pm, bh1780_suspend, bh1780_resume); | 240 | static SIMPLE_DEV_PM_OPS(bh1780_pm, bh1780_suspend, bh1780_resume); |
239 | #define BH1780_PMOPS (&bh1780_pm) | ||
240 | #else | ||
241 | #define BH1780_PMOPS NULL | ||
242 | #endif /* CONFIG_PM */ | ||
243 | 241 | ||
244 | static const struct i2c_device_id bh1780_id[] = { | 242 | static const struct i2c_device_id bh1780_id[] = { |
245 | { "bh1780", 0 }, | 243 | { "bh1780", 0 }, |
@@ -252,7 +250,7 @@ static struct i2c_driver bh1780_driver = { | |||
252 | .id_table = bh1780_id, | 250 | .id_table = bh1780_id, |
253 | .driver = { | 251 | .driver = { |
254 | .name = "bh1780", | 252 | .name = "bh1780", |
255 | .pm = BH1780_PMOPS, | 253 | .pm = &bh1780_pm, |
256 | }, | 254 | }, |
257 | }; | 255 | }; |
258 | 256 | ||
diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c index 9858f36dad8b..effd8c6b2b94 100644 --- a/drivers/misc/cs5535-mfgpt.c +++ b/drivers/misc/cs5535-mfgpt.c | |||
@@ -24,8 +24,11 @@ | |||
24 | 24 | ||
25 | static int mfgpt_reset_timers; | 25 | static int mfgpt_reset_timers; |
26 | module_param_named(mfgptfix, mfgpt_reset_timers, int, 0644); | 26 | module_param_named(mfgptfix, mfgpt_reset_timers, int, 0644); |
27 | MODULE_PARM_DESC(mfgptfix, "Reset the MFGPT timers during init; " | 27 | MODULE_PARM_DESC(mfgptfix, "Try to reset the MFGPT timers during init; " |
28 | "required by some broken BIOSes (ie, TinyBIOS < 0.99)."); | 28 | "required by some broken BIOSes (ie, TinyBIOS < 0.99) or kexec " |
29 | "(1 = reset the MFGPT using an undocumented bit, " | ||
30 | "2 = perform a soft reset by unconfiguring all timers); " | ||
31 | "use what works best for you."); | ||
29 | 32 | ||
30 | struct cs5535_mfgpt_timer { | 33 | struct cs5535_mfgpt_timer { |
31 | struct cs5535_mfgpt_chip *chip; | 34 | struct cs5535_mfgpt_chip *chip; |
@@ -256,6 +259,28 @@ static void reset_all_timers(void) | |||
256 | } | 259 | } |
257 | 260 | ||
258 | /* | 261 | /* |
262 | * This is another sledgehammer to reset all MFGPT timers. | ||
263 | * Instead of using the undocumented bit method it clears | ||
264 | * IRQ, NMI and RESET settings. | ||
265 | */ | ||
266 | static void soft_reset(void) | ||
267 | { | ||
268 | int i; | ||
269 | struct cs5535_mfgpt_timer t; | ||
270 | |||
271 | for (i = 0; i < MFGPT_MAX_TIMERS; i++) { | ||
272 | t.nr = i; | ||
273 | |||
274 | cs5535_mfgpt_toggle_event(&t, MFGPT_CMP1, MFGPT_EVENT_RESET, 0); | ||
275 | cs5535_mfgpt_toggle_event(&t, MFGPT_CMP2, MFGPT_EVENT_RESET, 0); | ||
276 | cs5535_mfgpt_toggle_event(&t, MFGPT_CMP1, MFGPT_EVENT_NMI, 0); | ||
277 | cs5535_mfgpt_toggle_event(&t, MFGPT_CMP2, MFGPT_EVENT_NMI, 0); | ||
278 | cs5535_mfgpt_toggle_event(&t, MFGPT_CMP1, MFGPT_EVENT_IRQ, 0); | ||
279 | cs5535_mfgpt_toggle_event(&t, MFGPT_CMP2, MFGPT_EVENT_IRQ, 0); | ||
280 | } | ||
281 | } | ||
282 | |||
283 | /* | ||
259 | * Check whether any MFGPTs are available for the kernel to use. In most | 284 | * Check whether any MFGPTs are available for the kernel to use. In most |
260 | * cases, firmware that uses AMD's VSA code will claim all timers during | 285 | * cases, firmware that uses AMD's VSA code will claim all timers during |
261 | * bootup; we certainly don't want to take them if they're already in use. | 286 | * bootup; we certainly don't want to take them if they're already in use. |
@@ -271,15 +296,17 @@ static int scan_timers(struct cs5535_mfgpt_chip *mfgpt) | |||
271 | int i; | 296 | int i; |
272 | 297 | ||
273 | /* bios workaround */ | 298 | /* bios workaround */ |
274 | if (mfgpt_reset_timers) | 299 | if (mfgpt_reset_timers == 1) |
275 | reset_all_timers(); | 300 | reset_all_timers(); |
301 | else if (mfgpt_reset_timers == 2) | ||
302 | soft_reset(); | ||
276 | 303 | ||
277 | /* just to be safe, protect this section w/ lock */ | 304 | /* just to be safe, protect this section w/ lock */ |
278 | spin_lock_irqsave(&mfgpt->lock, flags); | 305 | spin_lock_irqsave(&mfgpt->lock, flags); |
279 | for (i = 0; i < MFGPT_MAX_TIMERS; i++) { | 306 | for (i = 0; i < MFGPT_MAX_TIMERS; i++) { |
280 | timer.nr = i; | 307 | timer.nr = i; |
281 | val = cs5535_mfgpt_read(&timer, MFGPT_REG_SETUP); | 308 | val = cs5535_mfgpt_read(&timer, MFGPT_REG_SETUP); |
282 | if (!(val & MFGPT_SETUP_SETUP)) { | 309 | if (!(val & MFGPT_SETUP_SETUP) || mfgpt_reset_timers == 2) { |
283 | __set_bit(i, mfgpt->avail); | 310 | __set_bit(i, mfgpt->avail); |
284 | timers++; | 311 | timers++; |
285 | } | 312 | } |
@@ -294,6 +321,12 @@ static int cs5535_mfgpt_probe(struct platform_device *pdev) | |||
294 | struct resource *res; | 321 | struct resource *res; |
295 | int err = -EIO, t; | 322 | int err = -EIO, t; |
296 | 323 | ||
324 | if (mfgpt_reset_timers < 0 || mfgpt_reset_timers > 2) { | ||
325 | dev_err(&pdev->dev, "Bad mfgpt_reset_timers value: %i\n", | ||
326 | mfgpt_reset_timers); | ||
327 | goto done; | ||
328 | } | ||
329 | |||
297 | /* There are two ways to get the MFGPT base address; one is by | 330 | /* There are two ways to get the MFGPT base address; one is by |
298 | * fetching it from MSR_LBAR_MFGPT, the other is by reading the | 331 | * fetching it from MSR_LBAR_MFGPT, the other is by reading the |
299 | * PCI BAR info. The latter method is easier (especially across | 332 | * PCI BAR info. The latter method is easier (especially across |
diff --git a/drivers/misc/dummy-irq.c b/drivers/misc/dummy-irq.c new file mode 100644 index 000000000000..7014167e2c61 --- /dev/null +++ b/drivers/misc/dummy-irq.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * Dummy IRQ handler driver. | ||
3 | * | ||
4 | * This module only registers itself as a handler that is specified to it | ||
5 | * by the 'irq' parameter. | ||
6 | * | ||
7 | * The sole purpose of this module is to help with debugging of systems on | ||
8 | * which spurious IRQs would happen on disabled IRQ vector. | ||
9 | * | ||
10 | * Copyright (C) 2013 Jiri Kosina | ||
11 | */ | ||
12 | |||
13 | /* | ||
14 | * This program is free software; you can redistribute it and/or modify it | ||
15 | * under the terms of the GNU General Public License version 2 as published by | ||
16 | * the Free Software Foundation. | ||
17 | */ | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/irq.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | |||
22 | static int irq; | ||
23 | |||
24 | static irqreturn_t dummy_interrupt(int irq, void *dev_id) | ||
25 | { | ||
26 | static int count = 0; | ||
27 | |||
28 | if (count == 0) { | ||
29 | printk(KERN_INFO "dummy-irq: interrupt occured on IRQ %d\n", | ||
30 | irq); | ||
31 | count++; | ||
32 | } | ||
33 | |||
34 | return IRQ_NONE; | ||
35 | } | ||
36 | |||
37 | static int __init dummy_irq_init(void) | ||
38 | { | ||
39 | if (request_irq(irq, &dummy_interrupt, IRQF_SHARED, "dummy_irq", &irq)) { | ||
40 | printk(KERN_ERR "dummy-irq: cannot register IRQ %d\n", irq); | ||
41 | return -EIO; | ||
42 | } | ||
43 | printk(KERN_INFO "dummy-irq: registered for IRQ %d\n", irq); | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | static void __exit dummy_irq_exit(void) | ||
48 | { | ||
49 | printk(KERN_INFO "dummy-irq unloaded\n"); | ||
50 | free_irq(irq, &irq); | ||
51 | } | ||
52 | |||
53 | module_init(dummy_irq_init); | ||
54 | module_exit(dummy_irq_exit); | ||
55 | |||
56 | MODULE_LICENSE("GPL"); | ||
57 | MODULE_AUTHOR("Jiri Kosina"); | ||
58 | module_param(irq, uint, 0444); | ||
59 | MODULE_PARM_DESC(irq, "The IRQ to register for"); | ||
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c index b08cf8a08789..ad8fd8e64937 100644 --- a/drivers/misc/eeprom/at25.c +++ b/drivers/misc/eeprom/at25.c | |||
@@ -412,7 +412,7 @@ static int at25_probe(struct spi_device *spi) | |||
412 | mutex_init(&at25->lock); | 412 | mutex_init(&at25->lock); |
413 | at25->chip = chip; | 413 | at25->chip = chip; |
414 | at25->spi = spi_dev_get(spi); | 414 | at25->spi = spi_dev_get(spi); |
415 | dev_set_drvdata(&spi->dev, at25); | 415 | spi_set_drvdata(spi, at25); |
416 | at25->addrlen = addrlen; | 416 | at25->addrlen = addrlen; |
417 | 417 | ||
418 | /* Export the EEPROM bytes through sysfs, since that's convenient. | 418 | /* Export the EEPROM bytes through sysfs, since that's convenient. |
@@ -463,7 +463,7 @@ static int at25_remove(struct spi_device *spi) | |||
463 | { | 463 | { |
464 | struct at25_data *at25; | 464 | struct at25_data *at25; |
465 | 465 | ||
466 | at25 = dev_get_drvdata(&spi->dev); | 466 | at25 = spi_get_drvdata(spi); |
467 | sysfs_remove_bin_file(&spi->dev.kobj, &at25->bin); | 467 | sysfs_remove_bin_file(&spi->dev.kobj, &at25->bin); |
468 | kfree(at25); | 468 | kfree(at25); |
469 | return 0; | 469 | return 0; |
diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c index a6b5d5e73485..94cfc1212577 100644 --- a/drivers/misc/eeprom/eeprom_93xx46.c +++ b/drivers/misc/eeprom/eeprom_93xx46.c | |||
@@ -363,7 +363,7 @@ static int eeprom_93xx46_probe(struct spi_device *spi) | |||
363 | dev_err(&spi->dev, "can't create erase interface\n"); | 363 | dev_err(&spi->dev, "can't create erase interface\n"); |
364 | } | 364 | } |
365 | 365 | ||
366 | dev_set_drvdata(&spi->dev, edev); | 366 | spi_set_drvdata(spi, edev); |
367 | return 0; | 367 | return 0; |
368 | fail: | 368 | fail: |
369 | kfree(edev); | 369 | kfree(edev); |
@@ -372,13 +372,13 @@ fail: | |||
372 | 372 | ||
373 | static int eeprom_93xx46_remove(struct spi_device *spi) | 373 | static int eeprom_93xx46_remove(struct spi_device *spi) |
374 | { | 374 | { |
375 | struct eeprom_93xx46_dev *edev = dev_get_drvdata(&spi->dev); | 375 | struct eeprom_93xx46_dev *edev = spi_get_drvdata(spi); |
376 | 376 | ||
377 | if (!(edev->pdata->flags & EE_READONLY)) | 377 | if (!(edev->pdata->flags & EE_READONLY)) |
378 | device_remove_file(&spi->dev, &dev_attr_erase); | 378 | device_remove_file(&spi->dev, &dev_attr_erase); |
379 | 379 | ||
380 | sysfs_remove_bin_file(&spi->dev.kobj, &edev->bin); | 380 | sysfs_remove_bin_file(&spi->dev.kobj, &edev->bin); |
381 | dev_set_drvdata(&spi->dev, NULL); | 381 | spi_set_drvdata(spi, NULL); |
382 | kfree(edev); | 382 | kfree(edev); |
383 | return 0; | 383 | return 0; |
384 | } | 384 | } |
diff --git a/drivers/misc/ep93xx_pwm.c b/drivers/misc/ep93xx_pwm.c index 16d7179e2f9b..96787ec15cad 100644 --- a/drivers/misc/ep93xx_pwm.c +++ b/drivers/misc/ep93xx_pwm.c | |||
@@ -365,18 +365,7 @@ static struct platform_driver ep93xx_pwm_driver = { | |||
365 | .remove = __exit_p(ep93xx_pwm_remove), | 365 | .remove = __exit_p(ep93xx_pwm_remove), |
366 | }; | 366 | }; |
367 | 367 | ||
368 | static int __init ep93xx_pwm_init(void) | 368 | module_platform_driver_probe(ep93xx_pwm_driver, ep93xx_pwm_probe); |
369 | { | ||
370 | return platform_driver_probe(&ep93xx_pwm_driver, ep93xx_pwm_probe); | ||
371 | } | ||
372 | |||
373 | static void __exit ep93xx_pwm_exit(void) | ||
374 | { | ||
375 | platform_driver_unregister(&ep93xx_pwm_driver); | ||
376 | } | ||
377 | |||
378 | module_init(ep93xx_pwm_init); | ||
379 | module_exit(ep93xx_pwm_exit); | ||
380 | 369 | ||
381 | MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>, " | 370 | MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>, " |
382 | "H Hartley Sweeten <hsweeten@visionengravers.com>"); | 371 | "H Hartley Sweeten <hsweeten@visionengravers.com>"); |
diff --git a/drivers/misc/lattice-ecp3-config.c b/drivers/misc/lattice-ecp3-config.c index 155700bfd2b6..bb26f086bd8b 100644 --- a/drivers/misc/lattice-ecp3-config.c +++ b/drivers/misc/lattice-ecp3-config.c | |||
@@ -69,7 +69,7 @@ static const struct ecp3_dev ecp3_dev[] = { | |||
69 | static void firmware_load(const struct firmware *fw, void *context) | 69 | static void firmware_load(const struct firmware *fw, void *context) |
70 | { | 70 | { |
71 | struct spi_device *spi = (struct spi_device *)context; | 71 | struct spi_device *spi = (struct spi_device *)context; |
72 | struct fpga_data *data = dev_get_drvdata(&spi->dev); | 72 | struct fpga_data *data = spi_get_drvdata(spi); |
73 | u8 *buffer; | 73 | u8 *buffer; |
74 | int ret; | 74 | int ret; |
75 | u8 txbuf[8]; | 75 | u8 txbuf[8]; |
diff --git a/drivers/misc/mei/Kconfig b/drivers/misc/mei/Kconfig index d21b4d006a55..c76fa31e9bf6 100644 --- a/drivers/misc/mei/Kconfig +++ b/drivers/misc/mei/Kconfig | |||
@@ -10,10 +10,9 @@ config INTEL_MEI | |||
10 | <http://software.intel.com/en-us/manageability/> | 10 | <http://software.intel.com/en-us/manageability/> |
11 | 11 | ||
12 | config INTEL_MEI_ME | 12 | config INTEL_MEI_ME |
13 | bool "ME Enabled Intel Chipsets" | 13 | tristate "ME Enabled Intel Chipsets" |
14 | depends on INTEL_MEI | 14 | select INTEL_MEI |
15 | depends on X86 && PCI && WATCHDOG_CORE | 15 | depends on X86 && PCI && WATCHDOG_CORE |
16 | default y | ||
17 | help | 16 | help |
18 | MEI support for ME Enabled Intel chipsets. | 17 | MEI support for ME Enabled Intel chipsets. |
19 | 18 | ||
diff --git a/drivers/misc/mei/Makefile b/drivers/misc/mei/Makefile index 040af6c7b147..3612d576a677 100644 --- a/drivers/misc/mei/Makefile +++ b/drivers/misc/mei/Makefile | |||
@@ -10,5 +10,9 @@ mei-objs += client.o | |||
10 | mei-objs += main.o | 10 | mei-objs += main.o |
11 | mei-objs += amthif.o | 11 | mei-objs += amthif.o |
12 | mei-objs += wd.o | 12 | mei-objs += wd.o |
13 | mei-$(CONFIG_INTEL_MEI_ME) += pci-me.o | 13 | mei-objs += bus.o |
14 | mei-$(CONFIG_INTEL_MEI_ME) += hw-me.o | 14 | mei-$(CONFIG_DEBUG_FS) += debugfs.o |
15 | |||
16 | obj-$(CONFIG_INTEL_MEI_ME) += mei-me.o | ||
17 | mei-me-objs := pci-me.o | ||
18 | mei-me-objs += hw-me.o | ||
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c index c86d7e3839a4..9a5e8c72628b 100644 --- a/drivers/misc/mei/amthif.c +++ b/drivers/misc/mei/amthif.c | |||
@@ -449,7 +449,7 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, | |||
449 | struct mei_msg_hdr mei_hdr; | 449 | struct mei_msg_hdr mei_hdr; |
450 | struct mei_cl *cl = cb->cl; | 450 | struct mei_cl *cl = cb->cl; |
451 | size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index; | 451 | size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index; |
452 | size_t msg_slots = mei_data2slots(len); | 452 | u32 msg_slots = mei_data2slots(len); |
453 | 453 | ||
454 | mei_hdr.host_addr = cl->host_client_id; | 454 | mei_hdr.host_addr = cl->host_client_id; |
455 | mei_hdr.me_addr = cl->me_client_id; | 455 | mei_hdr.me_addr = cl->me_client_id; |
@@ -566,12 +566,13 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list, | |||
566 | */ | 566 | */ |
567 | int mei_amthif_irq_read(struct mei_device *dev, s32 *slots) | 567 | int mei_amthif_irq_read(struct mei_device *dev, s32 *slots) |
568 | { | 568 | { |
569 | u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control)); | ||
569 | 570 | ||
570 | if (((*slots) * sizeof(u32)) < (sizeof(struct mei_msg_hdr) | 571 | if (*slots < msg_slots) |
571 | + sizeof(struct hbm_flow_control))) { | ||
572 | return -EMSGSIZE; | 572 | return -EMSGSIZE; |
573 | } | 573 | |
574 | *slots -= mei_data2slots(sizeof(struct hbm_flow_control)); | 574 | *slots -= msg_slots; |
575 | |||
575 | if (mei_hbm_cl_flow_control_req(dev, &dev->iamthif_cl)) { | 576 | if (mei_hbm_cl_flow_control_req(dev, &dev->iamthif_cl)) { |
576 | dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n"); | 577 | dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n"); |
577 | return -EIO; | 578 | return -EIO; |
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c new file mode 100644 index 000000000000..8dbcb1516dc6 --- /dev/null +++ b/drivers/misc/mei/bus.c | |||
@@ -0,0 +1,496 @@ | |||
1 | /* | ||
2 | * Intel Management Engine Interface (Intel MEI) Linux driver | ||
3 | * Copyright (c) 2012-2013, Intel Corporation. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/sched.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/errno.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/mutex.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/pci.h> | ||
26 | #include <linux/mei_cl_bus.h> | ||
27 | |||
28 | #include "mei_dev.h" | ||
29 | #include "hw-me.h" | ||
30 | #include "client.h" | ||
31 | |||
32 | #define to_mei_cl_driver(d) container_of(d, struct mei_cl_driver, driver) | ||
33 | #define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev) | ||
34 | |||
35 | static int mei_cl_device_match(struct device *dev, struct device_driver *drv) | ||
36 | { | ||
37 | struct mei_cl_device *device = to_mei_cl_device(dev); | ||
38 | struct mei_cl_driver *driver = to_mei_cl_driver(drv); | ||
39 | const struct mei_cl_device_id *id; | ||
40 | |||
41 | if (!device) | ||
42 | return 0; | ||
43 | |||
44 | if (!driver || !driver->id_table) | ||
45 | return 0; | ||
46 | |||
47 | id = driver->id_table; | ||
48 | |||
49 | while (id->name[0]) { | ||
50 | if (!strcmp(dev_name(dev), id->name)) | ||
51 | return 1; | ||
52 | |||
53 | id++; | ||
54 | } | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int mei_cl_device_probe(struct device *dev) | ||
60 | { | ||
61 | struct mei_cl_device *device = to_mei_cl_device(dev); | ||
62 | struct mei_cl_driver *driver; | ||
63 | struct mei_cl_device_id id; | ||
64 | |||
65 | if (!device) | ||
66 | return 0; | ||
67 | |||
68 | driver = to_mei_cl_driver(dev->driver); | ||
69 | if (!driver || !driver->probe) | ||
70 | return -ENODEV; | ||
71 | |||
72 | dev_dbg(dev, "Device probe\n"); | ||
73 | |||
74 | strncpy(id.name, dev_name(dev), MEI_CL_NAME_SIZE); | ||
75 | |||
76 | return driver->probe(device, &id); | ||
77 | } | ||
78 | |||
79 | static int mei_cl_device_remove(struct device *dev) | ||
80 | { | ||
81 | struct mei_cl_device *device = to_mei_cl_device(dev); | ||
82 | struct mei_cl_driver *driver; | ||
83 | |||
84 | if (!device || !dev->driver) | ||
85 | return 0; | ||
86 | |||
87 | if (device->event_cb) { | ||
88 | device->event_cb = NULL; | ||
89 | cancel_work_sync(&device->event_work); | ||
90 | } | ||
91 | |||
92 | driver = to_mei_cl_driver(dev->driver); | ||
93 | if (!driver->remove) { | ||
94 | dev->driver = NULL; | ||
95 | |||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | return driver->remove(device); | ||
100 | } | ||
101 | |||
102 | static ssize_t modalias_show(struct device *dev, struct device_attribute *a, | ||
103 | char *buf) | ||
104 | { | ||
105 | int len; | ||
106 | |||
107 | len = snprintf(buf, PAGE_SIZE, "mei:%s\n", dev_name(dev)); | ||
108 | |||
109 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; | ||
110 | } | ||
111 | |||
112 | static struct device_attribute mei_cl_dev_attrs[] = { | ||
113 | __ATTR_RO(modalias), | ||
114 | __ATTR_NULL, | ||
115 | }; | ||
116 | |||
117 | static int mei_cl_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
118 | { | ||
119 | if (add_uevent_var(env, "MODALIAS=mei:%s", dev_name(dev))) | ||
120 | return -ENOMEM; | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | static struct bus_type mei_cl_bus_type = { | ||
126 | .name = "mei", | ||
127 | .dev_attrs = mei_cl_dev_attrs, | ||
128 | .match = mei_cl_device_match, | ||
129 | .probe = mei_cl_device_probe, | ||
130 | .remove = mei_cl_device_remove, | ||
131 | .uevent = mei_cl_uevent, | ||
132 | }; | ||
133 | |||
134 | static void mei_cl_dev_release(struct device *dev) | ||
135 | { | ||
136 | kfree(to_mei_cl_device(dev)); | ||
137 | } | ||
138 | |||
139 | static struct device_type mei_cl_device_type = { | ||
140 | .release = mei_cl_dev_release, | ||
141 | }; | ||
142 | |||
143 | static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev, | ||
144 | uuid_le uuid) | ||
145 | { | ||
146 | struct mei_cl *cl, *next; | ||
147 | |||
148 | list_for_each_entry_safe(cl, next, &dev->device_list, device_link) { | ||
149 | if (!uuid_le_cmp(uuid, cl->device_uuid)) | ||
150 | return cl; | ||
151 | } | ||
152 | |||
153 | return NULL; | ||
154 | } | ||
155 | struct mei_cl_device *mei_cl_add_device(struct mei_device *dev, | ||
156 | uuid_le uuid, char *name) | ||
157 | { | ||
158 | struct mei_cl_device *device; | ||
159 | struct mei_cl *cl; | ||
160 | int status; | ||
161 | |||
162 | cl = mei_bus_find_mei_cl_by_uuid(dev, uuid); | ||
163 | if (cl == NULL) | ||
164 | return NULL; | ||
165 | |||
166 | device = kzalloc(sizeof(struct mei_cl_device), GFP_KERNEL); | ||
167 | if (!device) | ||
168 | return NULL; | ||
169 | |||
170 | device->cl = cl; | ||
171 | |||
172 | device->dev.parent = &dev->pdev->dev; | ||
173 | device->dev.bus = &mei_cl_bus_type; | ||
174 | device->dev.type = &mei_cl_device_type; | ||
175 | |||
176 | dev_set_name(&device->dev, "%s", name); | ||
177 | |||
178 | status = device_register(&device->dev); | ||
179 | if (status) { | ||
180 | dev_err(&dev->pdev->dev, "Failed to register MEI device\n"); | ||
181 | kfree(device); | ||
182 | return NULL; | ||
183 | } | ||
184 | |||
185 | cl->device = device; | ||
186 | |||
187 | dev_dbg(&device->dev, "client %s registered\n", name); | ||
188 | |||
189 | return device; | ||
190 | } | ||
191 | EXPORT_SYMBOL_GPL(mei_cl_add_device); | ||
192 | |||
193 | void mei_cl_remove_device(struct mei_cl_device *device) | ||
194 | { | ||
195 | device_unregister(&device->dev); | ||
196 | } | ||
197 | EXPORT_SYMBOL_GPL(mei_cl_remove_device); | ||
198 | |||
199 | int __mei_cl_driver_register(struct mei_cl_driver *driver, struct module *owner) | ||
200 | { | ||
201 | int err; | ||
202 | |||
203 | driver->driver.name = driver->name; | ||
204 | driver->driver.owner = owner; | ||
205 | driver->driver.bus = &mei_cl_bus_type; | ||
206 | |||
207 | err = driver_register(&driver->driver); | ||
208 | if (err) | ||
209 | return err; | ||
210 | |||
211 | pr_debug("mei: driver [%s] registered\n", driver->driver.name); | ||
212 | |||
213 | return 0; | ||
214 | } | ||
215 | EXPORT_SYMBOL_GPL(__mei_cl_driver_register); | ||
216 | |||
217 | void mei_cl_driver_unregister(struct mei_cl_driver *driver) | ||
218 | { | ||
219 | driver_unregister(&driver->driver); | ||
220 | |||
221 | pr_debug("mei: driver [%s] unregistered\n", driver->driver.name); | ||
222 | } | ||
223 | EXPORT_SYMBOL_GPL(mei_cl_driver_unregister); | ||
224 | |||
225 | static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, | ||
226 | bool blocking) | ||
227 | { | ||
228 | struct mei_device *dev; | ||
229 | struct mei_msg_hdr mei_hdr; | ||
230 | struct mei_cl_cb *cb; | ||
231 | int me_cl_id, err; | ||
232 | |||
233 | if (WARN_ON(!cl || !cl->dev)) | ||
234 | return -ENODEV; | ||
235 | |||
236 | if (cl->state != MEI_FILE_CONNECTED) | ||
237 | return -ENODEV; | ||
238 | |||
239 | cb = mei_io_cb_init(cl, NULL); | ||
240 | if (!cb) | ||
241 | return -ENOMEM; | ||
242 | |||
243 | err = mei_io_cb_alloc_req_buf(cb, length); | ||
244 | if (err < 0) { | ||
245 | mei_io_cb_free(cb); | ||
246 | return err; | ||
247 | } | ||
248 | |||
249 | memcpy(cb->request_buffer.data, buf, length); | ||
250 | cb->fop_type = MEI_FOP_WRITE; | ||
251 | |||
252 | dev = cl->dev; | ||
253 | |||
254 | mutex_lock(&dev->device_lock); | ||
255 | |||
256 | /* Check if we have an ME client device */ | ||
257 | me_cl_id = mei_me_cl_by_id(dev, cl->me_client_id); | ||
258 | if (me_cl_id == dev->me_clients_num) { | ||
259 | err = -ENODEV; | ||
260 | goto out_err; | ||
261 | } | ||
262 | |||
263 | if (length > dev->me_clients[me_cl_id].props.max_msg_length) { | ||
264 | err = -EINVAL; | ||
265 | goto out_err; | ||
266 | } | ||
267 | |||
268 | err = mei_cl_flow_ctrl_creds(cl); | ||
269 | if (err < 0) | ||
270 | goto out_err; | ||
271 | |||
272 | /* Host buffer is not ready, we queue the request */ | ||
273 | if (err == 0 || !dev->hbuf_is_ready) { | ||
274 | cb->buf_idx = 0; | ||
275 | mei_hdr.msg_complete = 0; | ||
276 | cl->writing_state = MEI_WRITING; | ||
277 | |||
278 | goto out; | ||
279 | } | ||
280 | |||
281 | dev->hbuf_is_ready = false; | ||
282 | |||
283 | /* Check for a maximum length */ | ||
284 | if (length > mei_hbuf_max_len(dev)) { | ||
285 | mei_hdr.length = mei_hbuf_max_len(dev); | ||
286 | mei_hdr.msg_complete = 0; | ||
287 | } else { | ||
288 | mei_hdr.length = length; | ||
289 | mei_hdr.msg_complete = 1; | ||
290 | } | ||
291 | |||
292 | mei_hdr.host_addr = cl->host_client_id; | ||
293 | mei_hdr.me_addr = cl->me_client_id; | ||
294 | mei_hdr.reserved = 0; | ||
295 | |||
296 | if (mei_write_message(dev, &mei_hdr, buf)) { | ||
297 | err = -EIO; | ||
298 | goto out_err; | ||
299 | } | ||
300 | |||
301 | cl->writing_state = MEI_WRITING; | ||
302 | cb->buf_idx = mei_hdr.length; | ||
303 | |||
304 | out: | ||
305 | if (mei_hdr.msg_complete) { | ||
306 | if (mei_cl_flow_ctrl_reduce(cl)) { | ||
307 | err = -ENODEV; | ||
308 | goto out_err; | ||
309 | } | ||
310 | list_add_tail(&cb->list, &dev->write_waiting_list.list); | ||
311 | } else { | ||
312 | list_add_tail(&cb->list, &dev->write_list.list); | ||
313 | } | ||
314 | |||
315 | mutex_unlock(&dev->device_lock); | ||
316 | |||
317 | if (blocking && cl->writing_state != MEI_WRITE_COMPLETE) { | ||
318 | if (wait_event_interruptible(cl->tx_wait, | ||
319 | cl->writing_state == MEI_WRITE_COMPLETE)) { | ||
320 | if (signal_pending(current)) | ||
321 | err = -EINTR; | ||
322 | err = -ERESTARTSYS; | ||
323 | mutex_lock(&dev->device_lock); | ||
324 | goto out_err; | ||
325 | } | ||
326 | } | ||
327 | |||
328 | return mei_hdr.length; | ||
329 | |||
330 | out_err: | ||
331 | mutex_unlock(&dev->device_lock); | ||
332 | mei_io_cb_free(cb); | ||
333 | |||
334 | return err; | ||
335 | } | ||
336 | |||
337 | int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) | ||
338 | { | ||
339 | struct mei_device *dev; | ||
340 | struct mei_cl_cb *cb; | ||
341 | size_t r_length; | ||
342 | int err; | ||
343 | |||
344 | if (WARN_ON(!cl || !cl->dev)) | ||
345 | return -ENODEV; | ||
346 | |||
347 | dev = cl->dev; | ||
348 | |||
349 | mutex_lock(&dev->device_lock); | ||
350 | |||
351 | if (!cl->read_cb) { | ||
352 | err = mei_cl_read_start(cl); | ||
353 | if (err < 0) { | ||
354 | mutex_unlock(&dev->device_lock); | ||
355 | return err; | ||
356 | } | ||
357 | } | ||
358 | |||
359 | if (cl->reading_state != MEI_READ_COMPLETE && | ||
360 | !waitqueue_active(&cl->rx_wait)) { | ||
361 | mutex_unlock(&dev->device_lock); | ||
362 | |||
363 | if (wait_event_interruptible(cl->rx_wait, | ||
364 | (MEI_READ_COMPLETE == cl->reading_state))) { | ||
365 | if (signal_pending(current)) | ||
366 | return -EINTR; | ||
367 | return -ERESTARTSYS; | ||
368 | } | ||
369 | |||
370 | mutex_lock(&dev->device_lock); | ||
371 | } | ||
372 | |||
373 | cb = cl->read_cb; | ||
374 | |||
375 | if (cl->reading_state != MEI_READ_COMPLETE) { | ||
376 | r_length = 0; | ||
377 | goto out; | ||
378 | } | ||
379 | |||
380 | r_length = min_t(size_t, length, cb->buf_idx); | ||
381 | |||
382 | memcpy(buf, cb->response_buffer.data, r_length); | ||
383 | |||
384 | mei_io_cb_free(cb); | ||
385 | cl->reading_state = MEI_IDLE; | ||
386 | cl->read_cb = NULL; | ||
387 | |||
388 | out: | ||
389 | mutex_unlock(&dev->device_lock); | ||
390 | |||
391 | return r_length; | ||
392 | } | ||
393 | |||
394 | inline int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length) | ||
395 | { | ||
396 | return ___mei_cl_send(cl, buf, length, 0); | ||
397 | } | ||
398 | |||
399 | inline int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length) | ||
400 | { | ||
401 | return ___mei_cl_send(cl, buf, length, 1); | ||
402 | } | ||
403 | |||
404 | int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) | ||
405 | { | ||
406 | struct mei_cl *cl = device->cl; | ||
407 | |||
408 | if (cl == NULL) | ||
409 | return -ENODEV; | ||
410 | |||
411 | if (device->ops && device->ops->send) | ||
412 | return device->ops->send(device, buf, length); | ||
413 | |||
414 | return __mei_cl_send(cl, buf, length); | ||
415 | } | ||
416 | EXPORT_SYMBOL_GPL(mei_cl_send); | ||
417 | |||
418 | int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length) | ||
419 | { | ||
420 | struct mei_cl *cl = device->cl; | ||
421 | |||
422 | if (cl == NULL) | ||
423 | return -ENODEV; | ||
424 | |||
425 | if (device->ops && device->ops->recv) | ||
426 | return device->ops->recv(device, buf, length); | ||
427 | |||
428 | return __mei_cl_recv(cl, buf, length); | ||
429 | } | ||
430 | EXPORT_SYMBOL_GPL(mei_cl_recv); | ||
431 | |||
432 | static void mei_bus_event_work(struct work_struct *work) | ||
433 | { | ||
434 | struct mei_cl_device *device; | ||
435 | |||
436 | device = container_of(work, struct mei_cl_device, event_work); | ||
437 | |||
438 | if (device->event_cb) | ||
439 | device->event_cb(device, device->events, device->event_context); | ||
440 | |||
441 | device->events = 0; | ||
442 | |||
443 | /* Prepare for the next read */ | ||
444 | mei_cl_read_start(device->cl); | ||
445 | } | ||
446 | |||
447 | int mei_cl_register_event_cb(struct mei_cl_device *device, | ||
448 | mei_cl_event_cb_t event_cb, void *context) | ||
449 | { | ||
450 | if (device->event_cb) | ||
451 | return -EALREADY; | ||
452 | |||
453 | device->events = 0; | ||
454 | device->event_cb = event_cb; | ||
455 | device->event_context = context; | ||
456 | INIT_WORK(&device->event_work, mei_bus_event_work); | ||
457 | |||
458 | mei_cl_read_start(device->cl); | ||
459 | |||
460 | return 0; | ||
461 | } | ||
462 | EXPORT_SYMBOL_GPL(mei_cl_register_event_cb); | ||
463 | |||
464 | void *mei_cl_get_drvdata(const struct mei_cl_device *device) | ||
465 | { | ||
466 | return dev_get_drvdata(&device->dev); | ||
467 | } | ||
468 | EXPORT_SYMBOL_GPL(mei_cl_get_drvdata); | ||
469 | |||
470 | void mei_cl_set_drvdata(struct mei_cl_device *device, void *data) | ||
471 | { | ||
472 | dev_set_drvdata(&device->dev, data); | ||
473 | } | ||
474 | EXPORT_SYMBOL_GPL(mei_cl_set_drvdata); | ||
475 | |||
476 | void mei_cl_bus_rx_event(struct mei_cl *cl) | ||
477 | { | ||
478 | struct mei_cl_device *device = cl->device; | ||
479 | |||
480 | if (!device || !device->event_cb) | ||
481 | return; | ||
482 | |||
483 | set_bit(MEI_CL_EVENT_RX, &device->events); | ||
484 | |||
485 | schedule_work(&device->event_work); | ||
486 | } | ||
487 | |||
488 | int __init mei_cl_bus_init(void) | ||
489 | { | ||
490 | return bus_register(&mei_cl_bus_type); | ||
491 | } | ||
492 | |||
493 | void __exit mei_cl_bus_exit(void) | ||
494 | { | ||
495 | bus_unregister(&mei_cl_bus_type); | ||
496 | } | ||
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index 1569afe935de..e14397b09187 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
@@ -216,6 +216,7 @@ void mei_cl_init(struct mei_cl *cl, struct mei_device *dev) | |||
216 | init_waitqueue_head(&cl->rx_wait); | 216 | init_waitqueue_head(&cl->rx_wait); |
217 | init_waitqueue_head(&cl->tx_wait); | 217 | init_waitqueue_head(&cl->tx_wait); |
218 | INIT_LIST_HEAD(&cl->link); | 218 | INIT_LIST_HEAD(&cl->link); |
219 | INIT_LIST_HEAD(&cl->device_link); | ||
219 | cl->reading_state = MEI_IDLE; | 220 | cl->reading_state = MEI_IDLE; |
220 | cl->writing_state = MEI_IDLE; | 221 | cl->writing_state = MEI_IDLE; |
221 | cl->dev = dev; | 222 | cl->dev = dev; |
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c new file mode 100644 index 000000000000..7135a7186940 --- /dev/null +++ b/drivers/misc/mei/debugfs.c | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Intel Management Engine Interface (Intel MEI) Linux driver | ||
4 | * Copyright (c) 2012-2013, Intel Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | */ | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/device.h> | ||
19 | #include <linux/debugfs.h> | ||
20 | #include <linux/pci.h> | ||
21 | |||
22 | #include <linux/mei.h> | ||
23 | |||
24 | #include "mei_dev.h" | ||
25 | #include "hw.h" | ||
26 | |||
27 | static int mei_dbgfs_open(struct inode *inode, struct file *file) | ||
28 | { | ||
29 | file->private_data = inode->i_private; | ||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf, | ||
34 | size_t cnt, loff_t *ppos) | ||
35 | { | ||
36 | struct mei_device *dev = fp->private_data; | ||
37 | struct mei_me_client *cl; | ||
38 | const size_t bufsz = 1024; | ||
39 | char *buf = kzalloc(bufsz, GFP_KERNEL); | ||
40 | int i; | ||
41 | int pos = 0; | ||
42 | int ret; | ||
43 | |||
44 | if (!buf) | ||
45 | return -ENOMEM; | ||
46 | |||
47 | pos += scnprintf(buf + pos, bufsz - pos, | ||
48 | " |id|addr| UUID |con|msg len|\n"); | ||
49 | |||
50 | mutex_lock(&dev->device_lock); | ||
51 | |||
52 | /* if the driver is not enabled the list won't b consitent */ | ||
53 | if (dev->dev_state != MEI_DEV_ENABLED) | ||
54 | goto out; | ||
55 | |||
56 | for (i = 0; i < dev->me_clients_num; i++) { | ||
57 | cl = &dev->me_clients[i]; | ||
58 | |||
59 | /* skip me clients that cannot be connected */ | ||
60 | if (cl->props.max_number_of_connections == 0) | ||
61 | continue; | ||
62 | |||
63 | pos += scnprintf(buf + pos, bufsz - pos, | ||
64 | "%2d|%2d|%4d|%pUl|%3d|%7d|\n", | ||
65 | i, cl->client_id, | ||
66 | cl->props.fixed_address, | ||
67 | &cl->props.protocol_name, | ||
68 | cl->props.max_number_of_connections, | ||
69 | cl->props.max_msg_length); | ||
70 | } | ||
71 | out: | ||
72 | mutex_unlock(&dev->device_lock); | ||
73 | ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, pos); | ||
74 | kfree(buf); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | static const struct file_operations mei_dbgfs_fops_meclients = { | ||
79 | .open = mei_dbgfs_open, | ||
80 | .read = mei_dbgfs_read_meclients, | ||
81 | .llseek = generic_file_llseek, | ||
82 | }; | ||
83 | |||
84 | static ssize_t mei_dbgfs_read_devstate(struct file *fp, char __user *ubuf, | ||
85 | size_t cnt, loff_t *ppos) | ||
86 | { | ||
87 | struct mei_device *dev = fp->private_data; | ||
88 | const size_t bufsz = 1024; | ||
89 | char *buf = kzalloc(bufsz, GFP_KERNEL); | ||
90 | int pos = 0; | ||
91 | int ret; | ||
92 | |||
93 | if (!buf) | ||
94 | return -ENOMEM; | ||
95 | |||
96 | pos += scnprintf(buf + pos, bufsz - pos, "%s\n", | ||
97 | mei_dev_state_str(dev->dev_state)); | ||
98 | ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, pos); | ||
99 | kfree(buf); | ||
100 | return ret; | ||
101 | } | ||
102 | static const struct file_operations mei_dbgfs_fops_devstate = { | ||
103 | .open = mei_dbgfs_open, | ||
104 | .read = mei_dbgfs_read_devstate, | ||
105 | .llseek = generic_file_llseek, | ||
106 | }; | ||
107 | |||
108 | /** | ||
109 | * mei_dbgfs_deregister - Remove the debugfs files and directories | ||
110 | * @mei - pointer to mei device private dat | ||
111 | */ | ||
112 | void mei_dbgfs_deregister(struct mei_device *dev) | ||
113 | { | ||
114 | if (!dev->dbgfs_dir) | ||
115 | return; | ||
116 | debugfs_remove_recursive(dev->dbgfs_dir); | ||
117 | dev->dbgfs_dir = NULL; | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * Add the debugfs files | ||
122 | * | ||
123 | */ | ||
124 | int mei_dbgfs_register(struct mei_device *dev, const char *name) | ||
125 | { | ||
126 | struct dentry *dir, *f; | ||
127 | dir = debugfs_create_dir(name, NULL); | ||
128 | if (!dir) | ||
129 | return -ENOMEM; | ||
130 | |||
131 | f = debugfs_create_file("meclients", S_IRUSR, dir, | ||
132 | dev, &mei_dbgfs_fops_meclients); | ||
133 | if (!f) { | ||
134 | dev_err(&dev->pdev->dev, "meclients: registration failed\n"); | ||
135 | goto err; | ||
136 | } | ||
137 | f = debugfs_create_file("devstate", S_IRUSR, dir, | ||
138 | dev, &mei_dbgfs_fops_devstate); | ||
139 | if (!f) { | ||
140 | dev_err(&dev->pdev->dev, "devstate: registration failed\n"); | ||
141 | goto err; | ||
142 | } | ||
143 | dev->dbgfs_dir = dir; | ||
144 | return 0; | ||
145 | err: | ||
146 | mei_dbgfs_deregister(dev); | ||
147 | return -ENODEV; | ||
148 | } | ||
149 | |||
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index 642c6223fa6c..5ad53ebf57b9 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c | |||
@@ -26,14 +26,14 @@ | |||
26 | 26 | ||
27 | 27 | ||
28 | /** | 28 | /** |
29 | * mei_reg_read - Reads 32bit data from the mei device | 29 | * mei_me_reg_read - Reads 32bit data from the mei device |
30 | * | 30 | * |
31 | * @dev: the device structure | 31 | * @dev: the device structure |
32 | * @offset: offset from which to read the data | 32 | * @offset: offset from which to read the data |
33 | * | 33 | * |
34 | * returns register value (u32) | 34 | * returns register value (u32) |
35 | */ | 35 | */ |
36 | static inline u32 mei_reg_read(const struct mei_me_hw *hw, | 36 | static inline u32 mei_me_reg_read(const struct mei_me_hw *hw, |
37 | unsigned long offset) | 37 | unsigned long offset) |
38 | { | 38 | { |
39 | return ioread32(hw->mem_addr + offset); | 39 | return ioread32(hw->mem_addr + offset); |
@@ -41,20 +41,20 @@ static inline u32 mei_reg_read(const struct mei_me_hw *hw, | |||
41 | 41 | ||
42 | 42 | ||
43 | /** | 43 | /** |
44 | * mei_reg_write - Writes 32bit data to the mei device | 44 | * mei_me_reg_write - Writes 32bit data to the mei device |
45 | * | 45 | * |
46 | * @dev: the device structure | 46 | * @dev: the device structure |
47 | * @offset: offset from which to write the data | 47 | * @offset: offset from which to write the data |
48 | * @value: register value to write (u32) | 48 | * @value: register value to write (u32) |
49 | */ | 49 | */ |
50 | static inline void mei_reg_write(const struct mei_me_hw *hw, | 50 | static inline void mei_me_reg_write(const struct mei_me_hw *hw, |
51 | unsigned long offset, u32 value) | 51 | unsigned long offset, u32 value) |
52 | { | 52 | { |
53 | iowrite32(value, hw->mem_addr + offset); | 53 | iowrite32(value, hw->mem_addr + offset); |
54 | } | 54 | } |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * mei_mecbrw_read - Reads 32bit data from ME circular buffer | 57 | * mei_me_mecbrw_read - Reads 32bit data from ME circular buffer |
58 | * read window register | 58 | * read window register |
59 | * | 59 | * |
60 | * @dev: the device structure | 60 | * @dev: the device structure |
@@ -63,18 +63,18 @@ static inline void mei_reg_write(const struct mei_me_hw *hw, | |||
63 | */ | 63 | */ |
64 | static u32 mei_me_mecbrw_read(const struct mei_device *dev) | 64 | static u32 mei_me_mecbrw_read(const struct mei_device *dev) |
65 | { | 65 | { |
66 | return mei_reg_read(to_me_hw(dev), ME_CB_RW); | 66 | return mei_me_reg_read(to_me_hw(dev), ME_CB_RW); |
67 | } | 67 | } |
68 | /** | 68 | /** |
69 | * mei_mecsr_read - Reads 32bit data from the ME CSR | 69 | * mei_me_mecsr_read - Reads 32bit data from the ME CSR |
70 | * | 70 | * |
71 | * @dev: the device structure | 71 | * @dev: the device structure |
72 | * | 72 | * |
73 | * returns ME_CSR_HA register value (u32) | 73 | * returns ME_CSR_HA register value (u32) |
74 | */ | 74 | */ |
75 | static inline u32 mei_mecsr_read(const struct mei_me_hw *hw) | 75 | static inline u32 mei_me_mecsr_read(const struct mei_me_hw *hw) |
76 | { | 76 | { |
77 | return mei_reg_read(hw, ME_CSR_HA); | 77 | return mei_me_reg_read(hw, ME_CSR_HA); |
78 | } | 78 | } |
79 | 79 | ||
80 | /** | 80 | /** |
@@ -86,7 +86,7 @@ static inline u32 mei_mecsr_read(const struct mei_me_hw *hw) | |||
86 | */ | 86 | */ |
87 | static inline u32 mei_hcsr_read(const struct mei_me_hw *hw) | 87 | static inline u32 mei_hcsr_read(const struct mei_me_hw *hw) |
88 | { | 88 | { |
89 | return mei_reg_read(hw, H_CSR); | 89 | return mei_me_reg_read(hw, H_CSR); |
90 | } | 90 | } |
91 | 91 | ||
92 | /** | 92 | /** |
@@ -98,7 +98,7 @@ static inline u32 mei_hcsr_read(const struct mei_me_hw *hw) | |||
98 | static inline void mei_hcsr_set(struct mei_me_hw *hw, u32 hcsr) | 98 | static inline void mei_hcsr_set(struct mei_me_hw *hw, u32 hcsr) |
99 | { | 99 | { |
100 | hcsr &= ~H_IS; | 100 | hcsr &= ~H_IS; |
101 | mei_reg_write(hw, H_CSR, hcsr); | 101 | mei_me_reg_write(hw, H_CSR, hcsr); |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
@@ -123,7 +123,7 @@ static void mei_me_intr_clear(struct mei_device *dev) | |||
123 | struct mei_me_hw *hw = to_me_hw(dev); | 123 | struct mei_me_hw *hw = to_me_hw(dev); |
124 | u32 hcsr = mei_hcsr_read(hw); | 124 | u32 hcsr = mei_hcsr_read(hw); |
125 | if ((hcsr & H_IS) == H_IS) | 125 | if ((hcsr & H_IS) == H_IS) |
126 | mei_reg_write(hw, H_CSR, hcsr); | 126 | mei_me_reg_write(hw, H_CSR, hcsr); |
127 | } | 127 | } |
128 | /** | 128 | /** |
129 | * mei_me_intr_enable - enables mei device interrupts | 129 | * mei_me_intr_enable - enables mei device interrupts |
@@ -228,10 +228,42 @@ static bool mei_me_host_is_ready(struct mei_device *dev) | |||
228 | static bool mei_me_hw_is_ready(struct mei_device *dev) | 228 | static bool mei_me_hw_is_ready(struct mei_device *dev) |
229 | { | 229 | { |
230 | struct mei_me_hw *hw = to_me_hw(dev); | 230 | struct mei_me_hw *hw = to_me_hw(dev); |
231 | hw->me_hw_state = mei_mecsr_read(hw); | 231 | hw->me_hw_state = mei_me_mecsr_read(hw); |
232 | return (hw->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA; | 232 | return (hw->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA; |
233 | } | 233 | } |
234 | 234 | ||
235 | static int mei_me_hw_ready_wait(struct mei_device *dev) | ||
236 | { | ||
237 | int err; | ||
238 | if (mei_me_hw_is_ready(dev)) | ||
239 | return 0; | ||
240 | |||
241 | mutex_unlock(&dev->device_lock); | ||
242 | err = wait_event_interruptible_timeout(dev->wait_hw_ready, | ||
243 | dev->recvd_hw_ready, MEI_INTEROP_TIMEOUT); | ||
244 | mutex_lock(&dev->device_lock); | ||
245 | if (!err && !dev->recvd_hw_ready) { | ||
246 | dev_err(&dev->pdev->dev, | ||
247 | "wait hw ready failed. status = 0x%x\n", err); | ||
248 | return -ETIMEDOUT; | ||
249 | } | ||
250 | |||
251 | dev->recvd_hw_ready = false; | ||
252 | return 0; | ||
253 | } | ||
254 | |||
255 | static int mei_me_hw_start(struct mei_device *dev) | ||
256 | { | ||
257 | int ret = mei_me_hw_ready_wait(dev); | ||
258 | if (ret) | ||
259 | return ret; | ||
260 | dev_dbg(&dev->pdev->dev, "hw is ready\n"); | ||
261 | |||
262 | mei_me_host_set_ready(dev); | ||
263 | return ret; | ||
264 | } | ||
265 | |||
266 | |||
235 | /** | 267 | /** |
236 | * mei_hbuf_filled_slots - gets number of device filled buffer slots | 268 | * mei_hbuf_filled_slots - gets number of device filled buffer slots |
237 | * | 269 | * |
@@ -305,10 +337,11 @@ static int mei_me_write_message(struct mei_device *dev, | |||
305 | unsigned char *buf) | 337 | unsigned char *buf) |
306 | { | 338 | { |
307 | struct mei_me_hw *hw = to_me_hw(dev); | 339 | struct mei_me_hw *hw = to_me_hw(dev); |
308 | unsigned long rem, dw_cnt; | 340 | unsigned long rem; |
309 | unsigned long length = header->length; | 341 | unsigned long length = header->length; |
310 | u32 *reg_buf = (u32 *)buf; | 342 | u32 *reg_buf = (u32 *)buf; |
311 | u32 hcsr; | 343 | u32 hcsr; |
344 | u32 dw_cnt; | ||
312 | int i; | 345 | int i; |
313 | int empty_slots; | 346 | int empty_slots; |
314 | 347 | ||
@@ -321,16 +354,16 @@ static int mei_me_write_message(struct mei_device *dev, | |||
321 | if (empty_slots < 0 || dw_cnt > empty_slots) | 354 | if (empty_slots < 0 || dw_cnt > empty_slots) |
322 | return -EIO; | 355 | return -EIO; |
323 | 356 | ||
324 | mei_reg_write(hw, H_CB_WW, *((u32 *) header)); | 357 | mei_me_reg_write(hw, H_CB_WW, *((u32 *) header)); |
325 | 358 | ||
326 | for (i = 0; i < length / 4; i++) | 359 | for (i = 0; i < length / 4; i++) |
327 | mei_reg_write(hw, H_CB_WW, reg_buf[i]); | 360 | mei_me_reg_write(hw, H_CB_WW, reg_buf[i]); |
328 | 361 | ||
329 | rem = length & 0x3; | 362 | rem = length & 0x3; |
330 | if (rem > 0) { | 363 | if (rem > 0) { |
331 | u32 reg = 0; | 364 | u32 reg = 0; |
332 | memcpy(®, &buf[length - rem], rem); | 365 | memcpy(®, &buf[length - rem], rem); |
333 | mei_reg_write(hw, H_CB_WW, reg); | 366 | mei_me_reg_write(hw, H_CB_WW, reg); |
334 | } | 367 | } |
335 | 368 | ||
336 | hcsr = mei_hcsr_read(hw) | H_IG; | 369 | hcsr = mei_hcsr_read(hw) | H_IG; |
@@ -354,7 +387,7 @@ static int mei_me_count_full_read_slots(struct mei_device *dev) | |||
354 | char read_ptr, write_ptr; | 387 | char read_ptr, write_ptr; |
355 | unsigned char buffer_depth, filled_slots; | 388 | unsigned char buffer_depth, filled_slots; |
356 | 389 | ||
357 | hw->me_hw_state = mei_mecsr_read(hw); | 390 | hw->me_hw_state = mei_me_mecsr_read(hw); |
358 | buffer_depth = (unsigned char)((hw->me_hw_state & ME_CBD_HRA) >> 24); | 391 | buffer_depth = (unsigned char)((hw->me_hw_state & ME_CBD_HRA) >> 24); |
359 | read_ptr = (char) ((hw->me_hw_state & ME_CBRP_HRA) >> 8); | 392 | read_ptr = (char) ((hw->me_hw_state & ME_CBRP_HRA) >> 8); |
360 | write_ptr = (char) ((hw->me_hw_state & ME_CBWP_HRA) >> 16); | 393 | write_ptr = (char) ((hw->me_hw_state & ME_CBWP_HRA) >> 16); |
@@ -414,7 +447,7 @@ irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id) | |||
414 | return IRQ_NONE; | 447 | return IRQ_NONE; |
415 | 448 | ||
416 | /* clear H_IS bit in H_CSR */ | 449 | /* clear H_IS bit in H_CSR */ |
417 | mei_reg_write(hw, H_CSR, csr_reg); | 450 | mei_me_reg_write(hw, H_CSR, csr_reg); |
418 | 451 | ||
419 | return IRQ_WAKE_THREAD; | 452 | return IRQ_WAKE_THREAD; |
420 | } | 453 | } |
@@ -433,8 +466,6 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id) | |||
433 | { | 466 | { |
434 | struct mei_device *dev = (struct mei_device *) dev_id; | 467 | struct mei_device *dev = (struct mei_device *) dev_id; |
435 | struct mei_cl_cb complete_list; | 468 | struct mei_cl_cb complete_list; |
436 | struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL; | ||
437 | struct mei_cl *cl; | ||
438 | s32 slots; | 469 | s32 slots; |
439 | int rets; | 470 | int rets; |
440 | bool bus_message_received; | 471 | bool bus_message_received; |
@@ -465,14 +496,9 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id) | |||
465 | if (mei_hw_is_ready(dev)) { | 496 | if (mei_hw_is_ready(dev)) { |
466 | dev_dbg(&dev->pdev->dev, "we need to start the dev.\n"); | 497 | dev_dbg(&dev->pdev->dev, "we need to start the dev.\n"); |
467 | 498 | ||
468 | mei_host_set_ready(dev); | 499 | dev->recvd_hw_ready = true; |
469 | 500 | wake_up_interruptible(&dev->wait_hw_ready); | |
470 | dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n"); | ||
471 | /* link is established * start sending messages. */ | ||
472 | |||
473 | dev->dev_state = MEI_DEV_INIT_CLIENTS; | ||
474 | 501 | ||
475 | mei_hbm_start_req(dev); | ||
476 | mutex_unlock(&dev->device_lock); | 502 | mutex_unlock(&dev->device_lock); |
477 | return IRQ_HANDLED; | 503 | return IRQ_HANDLED; |
478 | } else { | 504 | } else { |
@@ -510,33 +536,19 @@ end: | |||
510 | wake_up_interruptible(&dev->wait_recvd_msg); | 536 | wake_up_interruptible(&dev->wait_recvd_msg); |
511 | bus_message_received = false; | 537 | bus_message_received = false; |
512 | } | 538 | } |
513 | if (list_empty(&complete_list.list)) | ||
514 | return IRQ_HANDLED; | ||
515 | 539 | ||
540 | mei_irq_compl_handler(dev, &complete_list); | ||
516 | 541 | ||
517 | list_for_each_entry_safe(cb_pos, cb_next, &complete_list.list, list) { | ||
518 | cl = cb_pos->cl; | ||
519 | list_del(&cb_pos->list); | ||
520 | if (cl) { | ||
521 | if (cl != &dev->iamthif_cl) { | ||
522 | dev_dbg(&dev->pdev->dev, "completing call back.\n"); | ||
523 | mei_irq_complete_handler(cl, cb_pos); | ||
524 | cb_pos = NULL; | ||
525 | } else if (cl == &dev->iamthif_cl) { | ||
526 | mei_amthif_complete(dev, cb_pos); | ||
527 | } | ||
528 | } | ||
529 | } | ||
530 | return IRQ_HANDLED; | 542 | return IRQ_HANDLED; |
531 | } | 543 | } |
532 | static const struct mei_hw_ops mei_me_hw_ops = { | 544 | static const struct mei_hw_ops mei_me_hw_ops = { |
533 | 545 | ||
534 | .host_set_ready = mei_me_host_set_ready, | ||
535 | .host_is_ready = mei_me_host_is_ready, | 546 | .host_is_ready = mei_me_host_is_ready, |
536 | 547 | ||
537 | .hw_is_ready = mei_me_hw_is_ready, | 548 | .hw_is_ready = mei_me_hw_is_ready, |
538 | .hw_reset = mei_me_hw_reset, | 549 | .hw_reset = mei_me_hw_reset, |
539 | .hw_config = mei_me_hw_config, | 550 | .hw_config = mei_me_hw_config, |
551 | .hw_start = mei_me_hw_start, | ||
540 | 552 | ||
541 | .intr_clear = mei_me_intr_clear, | 553 | .intr_clear = mei_me_intr_clear, |
542 | .intr_enable = mei_me_intr_enable, | 554 | .intr_enable = mei_me_intr_enable, |
@@ -571,14 +583,6 @@ struct mei_device *mei_me_dev_init(struct pci_dev *pdev) | |||
571 | 583 | ||
572 | mei_device_init(dev); | 584 | mei_device_init(dev); |
573 | 585 | ||
574 | INIT_LIST_HEAD(&dev->wd_cl.link); | ||
575 | INIT_LIST_HEAD(&dev->iamthif_cl.link); | ||
576 | mei_io_list_init(&dev->amthif_cmd_list); | ||
577 | mei_io_list_init(&dev->amthif_rd_complete_list); | ||
578 | |||
579 | INIT_DELAYED_WORK(&dev->timer_work, mei_timer); | ||
580 | INIT_WORK(&dev->init_work, mei_host_client_init); | ||
581 | |||
582 | dev->ops = &mei_me_hw_ops; | 586 | dev->ops = &mei_me_hw_ops; |
583 | 587 | ||
584 | dev->pdev = pdev; | 588 | dev->pdev = pdev; |
diff --git a/drivers/misc/mei/hw-me.h b/drivers/misc/mei/hw-me.h index 8518d3eeb838..80bd829fbd9a 100644 --- a/drivers/misc/mei/hw-me.h +++ b/drivers/misc/mei/hw-me.h | |||
@@ -36,12 +36,6 @@ struct mei_me_hw { | |||
36 | 36 | ||
37 | struct mei_device *mei_me_dev_init(struct pci_dev *pdev); | 37 | struct mei_device *mei_me_dev_init(struct pci_dev *pdev); |
38 | 38 | ||
39 | /* get slots (dwords) from a message length + header (bytes) */ | ||
40 | static inline unsigned char mei_data2slots(size_t length) | ||
41 | { | ||
42 | return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, 4); | ||
43 | } | ||
44 | |||
45 | irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id); | 39 | irqreturn_t mei_me_irq_quick_handler(int irq, void *dev_id); |
46 | irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id); | 40 | irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id); |
47 | 41 | ||
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 356179991a2e..54b51c05fa41 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c | |||
@@ -14,6 +14,7 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/export.h> | ||
17 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
18 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
19 | #include <linux/wait.h> | 20 | #include <linux/wait.h> |
@@ -22,6 +23,7 @@ | |||
22 | #include <linux/mei.h> | 23 | #include <linux/mei.h> |
23 | 24 | ||
24 | #include "mei_dev.h" | 25 | #include "mei_dev.h" |
26 | #include "hbm.h" | ||
25 | #include "client.h" | 27 | #include "client.h" |
26 | 28 | ||
27 | const char *mei_dev_state_str(int state) | 29 | const char *mei_dev_state_str(int state) |
@@ -33,7 +35,6 @@ const char *mei_dev_state_str(int state) | |||
33 | MEI_DEV_STATE(ENABLED); | 35 | MEI_DEV_STATE(ENABLED); |
34 | MEI_DEV_STATE(RESETING); | 36 | MEI_DEV_STATE(RESETING); |
35 | MEI_DEV_STATE(DISABLED); | 37 | MEI_DEV_STATE(DISABLED); |
36 | MEI_DEV_STATE(RECOVERING_FROM_RESET); | ||
37 | MEI_DEV_STATE(POWER_DOWN); | 38 | MEI_DEV_STATE(POWER_DOWN); |
38 | MEI_DEV_STATE(POWER_UP); | 39 | MEI_DEV_STATE(POWER_UP); |
39 | default: | 40 | default: |
@@ -46,7 +47,9 @@ void mei_device_init(struct mei_device *dev) | |||
46 | { | 47 | { |
47 | /* setup our list array */ | 48 | /* setup our list array */ |
48 | INIT_LIST_HEAD(&dev->file_list); | 49 | INIT_LIST_HEAD(&dev->file_list); |
50 | INIT_LIST_HEAD(&dev->device_list); | ||
49 | mutex_init(&dev->device_lock); | 51 | mutex_init(&dev->device_lock); |
52 | init_waitqueue_head(&dev->wait_hw_ready); | ||
50 | init_waitqueue_head(&dev->wait_recvd_msg); | 53 | init_waitqueue_head(&dev->wait_recvd_msg); |
51 | init_waitqueue_head(&dev->wait_stop_wd); | 54 | init_waitqueue_head(&dev->wait_stop_wd); |
52 | dev->dev_state = MEI_DEV_INITIALIZING; | 55 | dev->dev_state = MEI_DEV_INITIALIZING; |
@@ -56,16 +59,26 @@ void mei_device_init(struct mei_device *dev) | |||
56 | mei_io_list_init(&dev->write_waiting_list); | 59 | mei_io_list_init(&dev->write_waiting_list); |
57 | mei_io_list_init(&dev->ctrl_wr_list); | 60 | mei_io_list_init(&dev->ctrl_wr_list); |
58 | mei_io_list_init(&dev->ctrl_rd_list); | 61 | mei_io_list_init(&dev->ctrl_rd_list); |
62 | |||
63 | INIT_DELAYED_WORK(&dev->timer_work, mei_timer); | ||
64 | INIT_WORK(&dev->init_work, mei_host_client_init); | ||
65 | |||
66 | INIT_LIST_HEAD(&dev->wd_cl.link); | ||
67 | INIT_LIST_HEAD(&dev->iamthif_cl.link); | ||
68 | mei_io_list_init(&dev->amthif_cmd_list); | ||
69 | mei_io_list_init(&dev->amthif_rd_complete_list); | ||
70 | |||
59 | } | 71 | } |
72 | EXPORT_SYMBOL_GPL(mei_device_init); | ||
60 | 73 | ||
61 | /** | 74 | /** |
62 | * mei_hw_init - initializes host and fw to start work. | 75 | * mei_start - initializes host and fw to start work. |
63 | * | 76 | * |
64 | * @dev: the device structure | 77 | * @dev: the device structure |
65 | * | 78 | * |
66 | * returns 0 on success, <0 on failure. | 79 | * returns 0 on success, <0 on failure. |
67 | */ | 80 | */ |
68 | int mei_hw_init(struct mei_device *dev) | 81 | int mei_start(struct mei_device *dev) |
69 | { | 82 | { |
70 | int ret = 0; | 83 | int ret = 0; |
71 | 84 | ||
@@ -126,6 +139,7 @@ err: | |||
126 | mutex_unlock(&dev->device_lock); | 139 | mutex_unlock(&dev->device_lock); |
127 | return -ENODEV; | 140 | return -ENODEV; |
128 | } | 141 | } |
142 | EXPORT_SYMBOL_GPL(mei_start); | ||
129 | 143 | ||
130 | /** | 144 | /** |
131 | * mei_reset - resets host and fw. | 145 | * mei_reset - resets host and fw. |
@@ -137,9 +151,6 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) | |||
137 | { | 151 | { |
138 | bool unexpected; | 152 | bool unexpected; |
139 | 153 | ||
140 | if (dev->dev_state == MEI_DEV_RECOVERING_FROM_RESET) | ||
141 | return; | ||
142 | |||
143 | unexpected = (dev->dev_state != MEI_DEV_INITIALIZING && | 154 | unexpected = (dev->dev_state != MEI_DEV_INITIALIZING && |
144 | dev->dev_state != MEI_DEV_DISABLED && | 155 | dev->dev_state != MEI_DEV_DISABLED && |
145 | dev->dev_state != MEI_DEV_POWER_DOWN && | 156 | dev->dev_state != MEI_DEV_POWER_DOWN && |
@@ -176,12 +187,27 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) | |||
176 | dev_warn(&dev->pdev->dev, "unexpected reset: dev_state = %s\n", | 187 | dev_warn(&dev->pdev->dev, "unexpected reset: dev_state = %s\n", |
177 | mei_dev_state_str(dev->dev_state)); | 188 | mei_dev_state_str(dev->dev_state)); |
178 | 189 | ||
190 | if (!interrupts_enabled) { | ||
191 | dev_dbg(&dev->pdev->dev, "intr not enabled end of reset\n"); | ||
192 | return; | ||
193 | } | ||
194 | |||
195 | mei_hw_start(dev); | ||
196 | |||
197 | dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n"); | ||
198 | /* link is established * start sending messages. */ | ||
199 | |||
200 | dev->dev_state = MEI_DEV_INIT_CLIENTS; | ||
201 | |||
202 | mei_hbm_start_req(dev); | ||
203 | |||
179 | /* wake up all readings so they can be interrupted */ | 204 | /* wake up all readings so they can be interrupted */ |
180 | mei_cl_all_read_wakeup(dev); | 205 | mei_cl_all_read_wakeup(dev); |
181 | 206 | ||
182 | /* remove all waiting requests */ | 207 | /* remove all waiting requests */ |
183 | mei_cl_all_write_clear(dev); | 208 | mei_cl_all_write_clear(dev); |
184 | } | 209 | } |
210 | EXPORT_SYMBOL_GPL(mei_reset); | ||
185 | 211 | ||
186 | void mei_stop(struct mei_device *dev) | 212 | void mei_stop(struct mei_device *dev) |
187 | { | 213 | { |
@@ -199,8 +225,10 @@ void mei_stop(struct mei_device *dev) | |||
199 | mutex_unlock(&dev->device_lock); | 225 | mutex_unlock(&dev->device_lock); |
200 | 226 | ||
201 | flush_scheduled_work(); | 227 | flush_scheduled_work(); |
202 | } | ||
203 | 228 | ||
229 | mei_watchdog_unregister(dev); | ||
230 | } | ||
231 | EXPORT_SYMBOL_GPL(mei_stop); | ||
204 | 232 | ||
205 | 233 | ||
206 | 234 | ||
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index 3535b2676c97..255e0853479c 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
@@ -15,6 +15,7 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | 17 | ||
18 | #include <linux/export.h> | ||
18 | #include <linux/pci.h> | 19 | #include <linux/pci.h> |
19 | #include <linux/kthread.h> | 20 | #include <linux/kthread.h> |
20 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
@@ -30,30 +31,58 @@ | |||
30 | 31 | ||
31 | 32 | ||
32 | /** | 33 | /** |
33 | * mei_complete_handler - processes completed operation. | 34 | * mei_cl_complete_handler - processes completed operation for a client |
34 | * | 35 | * |
35 | * @cl: private data of the file object. | 36 | * @cl: private data of the file object. |
36 | * @cb_pos: callback block. | 37 | * @cb: callback block. |
37 | */ | 38 | */ |
38 | void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb_pos) | 39 | static void mei_cl_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb) |
39 | { | 40 | { |
40 | if (cb_pos->fop_type == MEI_FOP_WRITE) { | 41 | if (cb->fop_type == MEI_FOP_WRITE) { |
41 | mei_io_cb_free(cb_pos); | 42 | mei_io_cb_free(cb); |
42 | cb_pos = NULL; | 43 | cb = NULL; |
43 | cl->writing_state = MEI_WRITE_COMPLETE; | 44 | cl->writing_state = MEI_WRITE_COMPLETE; |
44 | if (waitqueue_active(&cl->tx_wait)) | 45 | if (waitqueue_active(&cl->tx_wait)) |
45 | wake_up_interruptible(&cl->tx_wait); | 46 | wake_up_interruptible(&cl->tx_wait); |
46 | 47 | ||
47 | } else if (cb_pos->fop_type == MEI_FOP_READ && | 48 | } else if (cb->fop_type == MEI_FOP_READ && |
48 | MEI_READING == cl->reading_state) { | 49 | MEI_READING == cl->reading_state) { |
49 | cl->reading_state = MEI_READ_COMPLETE; | 50 | cl->reading_state = MEI_READ_COMPLETE; |
50 | if (waitqueue_active(&cl->rx_wait)) | 51 | if (waitqueue_active(&cl->rx_wait)) |
51 | wake_up_interruptible(&cl->rx_wait); | 52 | wake_up_interruptible(&cl->rx_wait); |
53 | else | ||
54 | mei_cl_bus_rx_event(cl); | ||
52 | 55 | ||
53 | } | 56 | } |
54 | } | 57 | } |
55 | 58 | ||
56 | /** | 59 | /** |
60 | * mei_irq_compl_handler - dispatch complete handelers | ||
61 | * for the completed callbacks | ||
62 | * | ||
63 | * @dev - mei device | ||
64 | * @compl_list - list of completed cbs | ||
65 | */ | ||
66 | void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *compl_list) | ||
67 | { | ||
68 | struct mei_cl_cb *cb, *next; | ||
69 | struct mei_cl *cl; | ||
70 | |||
71 | list_for_each_entry_safe(cb, next, &compl_list->list, list) { | ||
72 | cl = cb->cl; | ||
73 | list_del(&cb->list); | ||
74 | if (!cl) | ||
75 | continue; | ||
76 | |||
77 | dev_dbg(&dev->pdev->dev, "completing call back.\n"); | ||
78 | if (cl == &dev->iamthif_cl) | ||
79 | mei_amthif_complete(dev, cb); | ||
80 | else | ||
81 | mei_cl_complete_handler(cl, cb); | ||
82 | } | ||
83 | } | ||
84 | EXPORT_SYMBOL_GPL(mei_irq_compl_handler); | ||
85 | /** | ||
57 | * _mei_irq_thread_state_ok - checks if mei header matches file private data | 86 | * _mei_irq_thread_state_ok - checks if mei header matches file private data |
58 | * | 87 | * |
59 | * @cl: private data of the file object | 88 | * @cl: private data of the file object |
@@ -153,25 +182,27 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots, | |||
153 | struct mei_cl *cl, | 182 | struct mei_cl *cl, |
154 | struct mei_cl_cb *cmpl_list) | 183 | struct mei_cl_cb *cmpl_list) |
155 | { | 184 | { |
156 | if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) + | 185 | u32 msg_slots = |
157 | sizeof(struct hbm_client_connect_request))) | 186 | mei_data2slots(sizeof(struct hbm_client_connect_request)); |
158 | return -EBADMSG; | 187 | |
188 | if (*slots < msg_slots) | ||
189 | return -EMSGSIZE; | ||
159 | 190 | ||
160 | *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request)); | 191 | *slots -= msg_slots; |
161 | 192 | ||
162 | if (mei_hbm_cl_disconnect_req(dev, cl)) { | 193 | if (mei_hbm_cl_disconnect_req(dev, cl)) { |
163 | cl->status = 0; | 194 | cl->status = 0; |
164 | cb_pos->buf_idx = 0; | 195 | cb_pos->buf_idx = 0; |
165 | list_move_tail(&cb_pos->list, &cmpl_list->list); | 196 | list_move_tail(&cb_pos->list, &cmpl_list->list); |
166 | return -EMSGSIZE; | 197 | return -EIO; |
167 | } else { | ||
168 | cl->state = MEI_FILE_DISCONNECTING; | ||
169 | cl->status = 0; | ||
170 | cb_pos->buf_idx = 0; | ||
171 | list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list); | ||
172 | cl->timer_count = MEI_CONNECT_TIMEOUT; | ||
173 | } | 198 | } |
174 | 199 | ||
200 | cl->state = MEI_FILE_DISCONNECTING; | ||
201 | cl->status = 0; | ||
202 | cb_pos->buf_idx = 0; | ||
203 | list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list); | ||
204 | cl->timer_count = MEI_CONNECT_TIMEOUT; | ||
205 | |||
175 | return 0; | 206 | return 0; |
176 | } | 207 | } |
177 | 208 | ||
@@ -192,14 +223,15 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots, | |||
192 | struct mei_cl *cl, | 223 | struct mei_cl *cl, |
193 | struct mei_cl_cb *cmpl_list) | 224 | struct mei_cl_cb *cmpl_list) |
194 | { | 225 | { |
195 | if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) + | 226 | u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control)); |
196 | sizeof(struct hbm_flow_control))) { | 227 | |
228 | if (*slots < msg_slots) { | ||
197 | /* return the cancel routine */ | 229 | /* return the cancel routine */ |
198 | list_del(&cb_pos->list); | 230 | list_del(&cb_pos->list); |
199 | return -EBADMSG; | 231 | return -EMSGSIZE; |
200 | } | 232 | } |
201 | 233 | ||
202 | *slots -= mei_data2slots(sizeof(struct hbm_flow_control)); | 234 | *slots -= msg_slots; |
203 | 235 | ||
204 | if (mei_hbm_cl_flow_control_req(dev, cl)) { | 236 | if (mei_hbm_cl_flow_control_req(dev, cl)) { |
205 | cl->status = -ENODEV; | 237 | cl->status = -ENODEV; |
@@ -229,15 +261,19 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots, | |||
229 | struct mei_cl *cl, | 261 | struct mei_cl *cl, |
230 | struct mei_cl_cb *cmpl_list) | 262 | struct mei_cl_cb *cmpl_list) |
231 | { | 263 | { |
232 | if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) + | 264 | u32 msg_slots = |
233 | sizeof(struct hbm_client_connect_request))) { | 265 | mei_data2slots(sizeof(struct hbm_client_connect_request)); |
266 | |||
267 | if (*slots < msg_slots) { | ||
234 | /* return the cancel routine */ | 268 | /* return the cancel routine */ |
235 | list_del(&cb_pos->list); | 269 | list_del(&cb_pos->list); |
236 | return -EBADMSG; | 270 | return -EMSGSIZE; |
237 | } | 271 | } |
238 | 272 | ||
273 | *slots -= msg_slots; | ||
274 | |||
239 | cl->state = MEI_FILE_CONNECTING; | 275 | cl->state = MEI_FILE_CONNECTING; |
240 | *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request)); | 276 | |
241 | if (mei_hbm_cl_connect_req(dev, cl)) { | 277 | if (mei_hbm_cl_connect_req(dev, cl)) { |
242 | cl->status = -ENODEV; | 278 | cl->status = -ENODEV; |
243 | cb_pos->buf_idx = 0; | 279 | cb_pos->buf_idx = 0; |
@@ -266,7 +302,7 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots, | |||
266 | struct mei_msg_hdr mei_hdr; | 302 | struct mei_msg_hdr mei_hdr; |
267 | struct mei_cl *cl = cb->cl; | 303 | struct mei_cl *cl = cb->cl; |
268 | size_t len = cb->request_buffer.size - cb->buf_idx; | 304 | size_t len = cb->request_buffer.size - cb->buf_idx; |
269 | size_t msg_slots = mei_data2slots(len); | 305 | u32 msg_slots = mei_data2slots(len); |
270 | 306 | ||
271 | mei_hdr.host_addr = cl->host_client_id; | 307 | mei_hdr.host_addr = cl->host_client_id; |
272 | mei_hdr.me_addr = cl->me_client_id; | 308 | mei_hdr.me_addr = cl->me_client_id; |
@@ -408,6 +444,7 @@ int mei_irq_read_handler(struct mei_device *dev, | |||
408 | end: | 444 | end: |
409 | return ret; | 445 | return ret; |
410 | } | 446 | } |
447 | EXPORT_SYMBOL_GPL(mei_irq_read_handler); | ||
411 | 448 | ||
412 | 449 | ||
413 | /** | 450 | /** |
@@ -419,8 +456,7 @@ end: | |||
419 | * | 456 | * |
420 | * returns 0 on success, <0 on failure. | 457 | * returns 0 on success, <0 on failure. |
421 | */ | 458 | */ |
422 | int mei_irq_write_handler(struct mei_device *dev, | 459 | int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list) |
423 | struct mei_cl_cb *cmpl_list) | ||
424 | { | 460 | { |
425 | 461 | ||
426 | struct mei_cl *cl; | 462 | struct mei_cl *cl; |
@@ -559,6 +595,7 @@ int mei_irq_write_handler(struct mei_device *dev, | |||
559 | } | 595 | } |
560 | return 0; | 596 | return 0; |
561 | } | 597 | } |
598 | EXPORT_SYMBOL_GPL(mei_irq_write_handler); | ||
562 | 599 | ||
563 | 600 | ||
564 | 601 | ||
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 903f809b21f7..329fb865cfd0 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c | |||
@@ -753,17 +753,44 @@ static struct miscdevice mei_misc_device = { | |||
753 | .minor = MISC_DYNAMIC_MINOR, | 753 | .minor = MISC_DYNAMIC_MINOR, |
754 | }; | 754 | }; |
755 | 755 | ||
756 | int mei_register(struct device *dev) | 756 | |
757 | int mei_register(struct mei_device *dev) | ||
757 | { | 758 | { |
758 | mei_misc_device.parent = dev; | 759 | int ret; |
759 | return misc_register(&mei_misc_device); | 760 | mei_misc_device.parent = &dev->pdev->dev; |
761 | ret = misc_register(&mei_misc_device); | ||
762 | if (ret) | ||
763 | return ret; | ||
764 | |||
765 | if (mei_dbgfs_register(dev, mei_misc_device.name)) | ||
766 | dev_err(&dev->pdev->dev, "cannot register debugfs\n"); | ||
767 | |||
768 | return 0; | ||
760 | } | 769 | } |
770 | EXPORT_SYMBOL_GPL(mei_register); | ||
761 | 771 | ||
762 | void mei_deregister(void) | 772 | void mei_deregister(struct mei_device *dev) |
763 | { | 773 | { |
774 | mei_dbgfs_deregister(dev); | ||
764 | misc_deregister(&mei_misc_device); | 775 | misc_deregister(&mei_misc_device); |
765 | mei_misc_device.parent = NULL; | 776 | mei_misc_device.parent = NULL; |
766 | } | 777 | } |
778 | EXPORT_SYMBOL_GPL(mei_deregister); | ||
779 | |||
780 | static int __init mei_init(void) | ||
781 | { | ||
782 | return mei_cl_bus_init(); | ||
783 | } | ||
784 | |||
785 | static void __exit mei_exit(void) | ||
786 | { | ||
787 | mei_cl_bus_exit(); | ||
788 | } | ||
789 | |||
790 | module_init(mei_init); | ||
791 | module_exit(mei_exit); | ||
767 | 792 | ||
793 | MODULE_AUTHOR("Intel Corporation"); | ||
794 | MODULE_DESCRIPTION("Intel(R) Management Engine Interface"); | ||
768 | MODULE_LICENSE("GPL v2"); | 795 | MODULE_LICENSE("GPL v2"); |
769 | 796 | ||
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 97873812e33b..8806be420f6b 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/watchdog.h> | 21 | #include <linux/watchdog.h> |
22 | #include <linux/poll.h> | 22 | #include <linux/poll.h> |
23 | #include <linux/mei.h> | 23 | #include <linux/mei.h> |
24 | #include <linux/mei_cl_bus.h> | ||
24 | 25 | ||
25 | #include "hw.h" | 26 | #include "hw.h" |
26 | #include "hw-me-regs.h" | 27 | #include "hw-me-regs.h" |
@@ -97,7 +98,6 @@ enum mei_dev_state { | |||
97 | MEI_DEV_ENABLED, | 98 | MEI_DEV_ENABLED, |
98 | MEI_DEV_RESETING, | 99 | MEI_DEV_RESETING, |
99 | MEI_DEV_DISABLED, | 100 | MEI_DEV_DISABLED, |
100 | MEI_DEV_RECOVERING_FROM_RESET, | ||
101 | MEI_DEV_POWER_DOWN, | 101 | MEI_DEV_POWER_DOWN, |
102 | MEI_DEV_POWER_UP | 102 | MEI_DEV_POWER_UP |
103 | }; | 103 | }; |
@@ -209,15 +209,20 @@ struct mei_cl { | |||
209 | enum mei_file_transaction_states writing_state; | 209 | enum mei_file_transaction_states writing_state; |
210 | int sm_state; | 210 | int sm_state; |
211 | struct mei_cl_cb *read_cb; | 211 | struct mei_cl_cb *read_cb; |
212 | |||
213 | /* MEI CL bus data */ | ||
214 | struct mei_cl_device *device; | ||
215 | struct list_head device_link; | ||
216 | uuid_le device_uuid; | ||
212 | }; | 217 | }; |
213 | 218 | ||
214 | /** struct mei_hw_ops | 219 | /** struct mei_hw_ops |
215 | * | 220 | * |
216 | * @host_set_ready - notify FW that host side is ready | ||
217 | * @host_is_ready - query for host readiness | 221 | * @host_is_ready - query for host readiness |
218 | 222 | ||
219 | * @hw_is_ready - query if hw is ready | 223 | * @hw_is_ready - query if hw is ready |
220 | * @hw_reset - reset hw | 224 | * @hw_reset - reset hw |
225 | * @hw_start - start hw after reset | ||
221 | * @hw_config - configure hw | 226 | * @hw_config - configure hw |
222 | 227 | ||
223 | * @intr_clear - clear pending interrupts | 228 | * @intr_clear - clear pending interrupts |
@@ -237,11 +242,11 @@ struct mei_cl { | |||
237 | */ | 242 | */ |
238 | struct mei_hw_ops { | 243 | struct mei_hw_ops { |
239 | 244 | ||
240 | void (*host_set_ready) (struct mei_device *dev); | ||
241 | bool (*host_is_ready) (struct mei_device *dev); | 245 | bool (*host_is_ready) (struct mei_device *dev); |
242 | 246 | ||
243 | bool (*hw_is_ready) (struct mei_device *dev); | 247 | bool (*hw_is_ready) (struct mei_device *dev); |
244 | void (*hw_reset) (struct mei_device *dev, bool enable); | 248 | void (*hw_reset) (struct mei_device *dev, bool enable); |
249 | int (*hw_start) (struct mei_device *dev); | ||
245 | void (*hw_config) (struct mei_device *dev); | 250 | void (*hw_config) (struct mei_device *dev); |
246 | 251 | ||
247 | void (*intr_clear) (struct mei_device *dev); | 252 | void (*intr_clear) (struct mei_device *dev); |
@@ -263,6 +268,67 @@ struct mei_hw_ops { | |||
263 | unsigned char *buf, unsigned long len); | 268 | unsigned char *buf, unsigned long len); |
264 | }; | 269 | }; |
265 | 270 | ||
271 | /* MEI bus API*/ | ||
272 | struct mei_cl_device *mei_cl_add_device(struct mei_device *dev, | ||
273 | uuid_le uuid, char *name); | ||
274 | void mei_cl_remove_device(struct mei_cl_device *device); | ||
275 | |||
276 | int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length); | ||
277 | int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length); | ||
278 | int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length); | ||
279 | |||
280 | /** | ||
281 | * struct mei_cl_transport_ops - MEI CL device transport ops | ||
282 | * This structure allows ME host clients to implement technology | ||
283 | * specific transport layers. | ||
284 | * | ||
285 | * @send: Tx hook for the device. This allows ME host clients to trap | ||
286 | * the device driver buffers before actually physically | ||
287 | * pushing it to the ME. | ||
288 | * @recv: Rx hook for the device. This allows ME host clients to trap the | ||
289 | * ME buffers before forwarding them to the device driver. | ||
290 | */ | ||
291 | struct mei_cl_transport_ops { | ||
292 | int (*send)(struct mei_cl_device *device, u8 *buf, size_t length); | ||
293 | int (*recv)(struct mei_cl_device *device, u8 *buf, size_t length); | ||
294 | }; | ||
295 | |||
296 | void mei_cl_bus_rx_event(struct mei_cl *cl); | ||
297 | int mei_cl_bus_init(void); | ||
298 | void mei_cl_bus_exit(void); | ||
299 | |||
300 | |||
301 | /** | ||
302 | * struct mei_cl_device - MEI device handle | ||
303 | * An mei_cl_device pointer is returned from mei_add_device() | ||
304 | * and links MEI bus clients to their actual ME host client pointer. | ||
305 | * Drivers for MEI devices will get an mei_cl_device pointer | ||
306 | * when being probed and shall use it for doing ME bus I/O. | ||
307 | * | ||
308 | * @dev: linux driver model device pointer | ||
309 | * @uuid: me client uuid | ||
310 | * @cl: mei client | ||
311 | * @ops: ME transport ops | ||
312 | * @event_cb: Drivers register this callback to get asynchronous ME | ||
313 | * events (e.g. Rx buffer pending) notifications. | ||
314 | * @events: Events bitmask sent to the driver. | ||
315 | * @priv_data: client private data | ||
316 | */ | ||
317 | struct mei_cl_device { | ||
318 | struct device dev; | ||
319 | |||
320 | struct mei_cl *cl; | ||
321 | |||
322 | const struct mei_cl_transport_ops *ops; | ||
323 | |||
324 | struct work_struct event_work; | ||
325 | mei_cl_event_cb_t event_cb; | ||
326 | void *event_context; | ||
327 | unsigned long events; | ||
328 | |||
329 | void *priv_data; | ||
330 | }; | ||
331 | |||
266 | /** | 332 | /** |
267 | * struct mei_device - MEI private device struct | 333 | * struct mei_device - MEI private device struct |
268 | 334 | ||
@@ -296,11 +362,14 @@ struct mei_device { | |||
296 | */ | 362 | */ |
297 | struct mutex device_lock; /* device lock */ | 363 | struct mutex device_lock; /* device lock */ |
298 | struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ | 364 | struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ |
365 | |||
366 | bool recvd_hw_ready; | ||
299 | bool recvd_msg; | 367 | bool recvd_msg; |
300 | 368 | ||
301 | /* | 369 | /* |
302 | * waiting queue for receive message from FW | 370 | * waiting queue for receive message from FW |
303 | */ | 371 | */ |
372 | wait_queue_head_t wait_hw_ready; | ||
304 | wait_queue_head_t wait_recvd_msg; | 373 | wait_queue_head_t wait_recvd_msg; |
305 | wait_queue_head_t wait_stop_wd; | 374 | wait_queue_head_t wait_stop_wd; |
306 | 375 | ||
@@ -365,6 +434,14 @@ struct mei_device { | |||
365 | 434 | ||
366 | struct work_struct init_work; | 435 | struct work_struct init_work; |
367 | 436 | ||
437 | /* List of bus devices */ | ||
438 | struct list_head device_list; | ||
439 | |||
440 | #if IS_ENABLED(CONFIG_DEBUG_FS) | ||
441 | struct dentry *dbgfs_dir; | ||
442 | #endif /* CONFIG_DEBUG_FS */ | ||
443 | |||
444 | |||
368 | const struct mei_hw_ops *ops; | 445 | const struct mei_hw_ops *ops; |
369 | char hw[0] __aligned(sizeof(void *)); | 446 | char hw[0] __aligned(sizeof(void *)); |
370 | }; | 447 | }; |
@@ -374,13 +451,23 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec) | |||
374 | return msecs_to_jiffies(sec * MSEC_PER_SEC); | 451 | return msecs_to_jiffies(sec * MSEC_PER_SEC); |
375 | } | 452 | } |
376 | 453 | ||
454 | /** | ||
455 | * mei_data2slots - get slots - number of (dwords) from a message length | ||
456 | * + size of the mei header | ||
457 | * @length - size of the messages in bytes | ||
458 | * returns - number of slots | ||
459 | */ | ||
460 | static inline u32 mei_data2slots(size_t length) | ||
461 | { | ||
462 | return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, 4); | ||
463 | } | ||
377 | 464 | ||
378 | /* | 465 | /* |
379 | * mei init function prototypes | 466 | * mei init function prototypes |
380 | */ | 467 | */ |
381 | void mei_device_init(struct mei_device *dev); | 468 | void mei_device_init(struct mei_device *dev); |
382 | void mei_reset(struct mei_device *dev, int interrupts); | 469 | void mei_reset(struct mei_device *dev, int interrupts); |
383 | int mei_hw_init(struct mei_device *dev); | 470 | int mei_start(struct mei_device *dev); |
384 | void mei_stop(struct mei_device *dev); | 471 | void mei_stop(struct mei_device *dev); |
385 | 472 | ||
386 | /* | 473 | /* |
@@ -392,8 +479,7 @@ int mei_irq_read_handler(struct mei_device *dev, | |||
392 | struct mei_cl_cb *cmpl_list, s32 *slots); | 479 | struct mei_cl_cb *cmpl_list, s32 *slots); |
393 | 480 | ||
394 | int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list); | 481 | int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list); |
395 | 482 | void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list); | |
396 | void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb_pos); | ||
397 | 483 | ||
398 | /* | 484 | /* |
399 | * AMTHIF - AMT Host Interface Functions | 485 | * AMTHIF - AMT Host Interface Functions |
@@ -455,6 +541,11 @@ static inline void mei_hw_reset(struct mei_device *dev, bool enable) | |||
455 | dev->ops->hw_reset(dev, enable); | 541 | dev->ops->hw_reset(dev, enable); |
456 | } | 542 | } |
457 | 543 | ||
544 | static inline void mei_hw_start(struct mei_device *dev) | ||
545 | { | ||
546 | dev->ops->hw_start(dev); | ||
547 | } | ||
548 | |||
458 | static inline void mei_clear_interrupts(struct mei_device *dev) | 549 | static inline void mei_clear_interrupts(struct mei_device *dev) |
459 | { | 550 | { |
460 | dev->ops->intr_clear(dev); | 551 | dev->ops->intr_clear(dev); |
@@ -470,10 +561,6 @@ static inline void mei_disable_interrupts(struct mei_device *dev) | |||
470 | dev->ops->intr_disable(dev); | 561 | dev->ops->intr_disable(dev); |
471 | } | 562 | } |
472 | 563 | ||
473 | static inline void mei_host_set_ready(struct mei_device *dev) | ||
474 | { | ||
475 | dev->ops->host_set_ready(dev); | ||
476 | } | ||
477 | static inline bool mei_host_is_ready(struct mei_device *dev) | 564 | static inline bool mei_host_is_ready(struct mei_device *dev) |
478 | { | 565 | { |
479 | return dev->ops->host_is_ready(dev); | 566 | return dev->ops->host_is_ready(dev); |
@@ -521,8 +608,19 @@ static inline int mei_count_full_read_slots(struct mei_device *dev) | |||
521 | return dev->ops->rdbuf_full_slots(dev); | 608 | return dev->ops->rdbuf_full_slots(dev); |
522 | } | 609 | } |
523 | 610 | ||
524 | int mei_register(struct device *dev); | 611 | #if IS_ENABLED(CONFIG_DEBUG_FS) |
525 | void mei_deregister(void); | 612 | int mei_dbgfs_register(struct mei_device *dev, const char *name); |
613 | void mei_dbgfs_deregister(struct mei_device *dev); | ||
614 | #else | ||
615 | static inline int mei_dbgfs_register(struct mei_device *dev, const char *name) | ||
616 | { | ||
617 | return 0; | ||
618 | } | ||
619 | static inline void mei_dbgfs_deregister(struct mei_device *dev) {} | ||
620 | #endif /* CONFIG_DEBUG_FS */ | ||
621 | |||
622 | int mei_register(struct mei_device *dev); | ||
623 | void mei_deregister(struct mei_device *dev); | ||
526 | 624 | ||
527 | #define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d" | 625 | #define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d" |
528 | #define MEI_HDR_PRM(hdr) \ | 626 | #define MEI_HDR_PRM(hdr) \ |
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index b8b5c9c3ad03..88aec6a90ff4 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c | |||
@@ -47,7 +47,7 @@ | |||
47 | static struct pci_dev *mei_pdev; | 47 | static struct pci_dev *mei_pdev; |
48 | 48 | ||
49 | /* mei_pci_tbl - PCI Device ID Table */ | 49 | /* mei_pci_tbl - PCI Device ID Table */ |
50 | static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = { | 50 | static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = { |
51 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)}, | 51 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)}, |
52 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G35)}, | 52 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G35)}, |
53 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82Q965)}, | 53 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82Q965)}, |
@@ -86,7 +86,7 @@ static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = { | |||
86 | {0, } | 86 | {0, } |
87 | }; | 87 | }; |
88 | 88 | ||
89 | MODULE_DEVICE_TABLE(pci, mei_pci_tbl); | 89 | MODULE_DEVICE_TABLE(pci, mei_me_pci_tbl); |
90 | 90 | ||
91 | static DEFINE_MUTEX(mei_mutex); | 91 | static DEFINE_MUTEX(mei_mutex); |
92 | 92 | ||
@@ -97,7 +97,7 @@ static DEFINE_MUTEX(mei_mutex); | |||
97 | * | 97 | * |
98 | * returns true if ME Interface is valid, false otherwise | 98 | * returns true if ME Interface is valid, false otherwise |
99 | */ | 99 | */ |
100 | static bool mei_quirk_probe(struct pci_dev *pdev, | 100 | static bool mei_me_quirk_probe(struct pci_dev *pdev, |
101 | const struct pci_device_id *ent) | 101 | const struct pci_device_id *ent) |
102 | { | 102 | { |
103 | u32 reg; | 103 | u32 reg; |
@@ -119,7 +119,7 @@ static bool mei_quirk_probe(struct pci_dev *pdev, | |||
119 | * | 119 | * |
120 | * returns 0 on success, <0 on failure. | 120 | * returns 0 on success, <0 on failure. |
121 | */ | 121 | */ |
122 | static int mei_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 122 | static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
123 | { | 123 | { |
124 | struct mei_device *dev; | 124 | struct mei_device *dev; |
125 | struct mei_me_hw *hw; | 125 | struct mei_me_hw *hw; |
@@ -127,7 +127,7 @@ static int mei_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
127 | 127 | ||
128 | mutex_lock(&mei_mutex); | 128 | mutex_lock(&mei_mutex); |
129 | 129 | ||
130 | if (!mei_quirk_probe(pdev, ent)) { | 130 | if (!mei_me_quirk_probe(pdev, ent)) { |
131 | err = -ENODEV; | 131 | err = -ENODEV; |
132 | goto end; | 132 | goto end; |
133 | } | 133 | } |
@@ -184,20 +184,19 @@ static int mei_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
184 | goto disable_msi; | 184 | goto disable_msi; |
185 | } | 185 | } |
186 | 186 | ||
187 | if (mei_hw_init(dev)) { | 187 | if (mei_start(dev)) { |
188 | dev_err(&pdev->dev, "init hw failure.\n"); | 188 | dev_err(&pdev->dev, "init hw failure.\n"); |
189 | err = -ENODEV; | 189 | err = -ENODEV; |
190 | goto release_irq; | 190 | goto release_irq; |
191 | } | 191 | } |
192 | 192 | ||
193 | err = mei_register(&pdev->dev); | 193 | err = mei_register(dev); |
194 | if (err) | 194 | if (err) |
195 | goto release_irq; | 195 | goto release_irq; |
196 | 196 | ||
197 | mei_pdev = pdev; | 197 | mei_pdev = pdev; |
198 | pci_set_drvdata(pdev, dev); | 198 | pci_set_drvdata(pdev, dev); |
199 | 199 | ||
200 | |||
201 | schedule_delayed_work(&dev->timer_work, HZ); | 200 | schedule_delayed_work(&dev->timer_work, HZ); |
202 | 201 | ||
203 | mutex_unlock(&mei_mutex); | 202 | mutex_unlock(&mei_mutex); |
@@ -233,7 +232,7 @@ end: | |||
233 | * mei_remove is called by the PCI subsystem to alert the driver | 232 | * mei_remove is called by the PCI subsystem to alert the driver |
234 | * that it should release a PCI device. | 233 | * that it should release a PCI device. |
235 | */ | 234 | */ |
236 | static void mei_remove(struct pci_dev *pdev) | 235 | static void mei_me_remove(struct pci_dev *pdev) |
237 | { | 236 | { |
238 | struct mei_device *dev; | 237 | struct mei_device *dev; |
239 | struct mei_me_hw *hw; | 238 | struct mei_me_hw *hw; |
@@ -253,8 +252,6 @@ static void mei_remove(struct pci_dev *pdev) | |||
253 | 252 | ||
254 | mei_pdev = NULL; | 253 | mei_pdev = NULL; |
255 | 254 | ||
256 | mei_watchdog_unregister(dev); | ||
257 | |||
258 | /* disable interrupts */ | 255 | /* disable interrupts */ |
259 | mei_disable_interrupts(dev); | 256 | mei_disable_interrupts(dev); |
260 | 257 | ||
@@ -265,16 +262,17 @@ static void mei_remove(struct pci_dev *pdev) | |||
265 | if (hw->mem_addr) | 262 | if (hw->mem_addr) |
266 | pci_iounmap(pdev, hw->mem_addr); | 263 | pci_iounmap(pdev, hw->mem_addr); |
267 | 264 | ||
265 | mei_deregister(dev); | ||
266 | |||
268 | kfree(dev); | 267 | kfree(dev); |
269 | 268 | ||
270 | pci_release_regions(pdev); | 269 | pci_release_regions(pdev); |
271 | pci_disable_device(pdev); | 270 | pci_disable_device(pdev); |
272 | 271 | ||
273 | mei_deregister(); | ||
274 | 272 | ||
275 | } | 273 | } |
276 | #ifdef CONFIG_PM | 274 | #ifdef CONFIG_PM |
277 | static int mei_pci_suspend(struct device *device) | 275 | static int mei_me_pci_suspend(struct device *device) |
278 | { | 276 | { |
279 | struct pci_dev *pdev = to_pci_dev(device); | 277 | struct pci_dev *pdev = to_pci_dev(device); |
280 | struct mei_device *dev = pci_get_drvdata(pdev); | 278 | struct mei_device *dev = pci_get_drvdata(pdev); |
@@ -294,7 +292,7 @@ static int mei_pci_suspend(struct device *device) | |||
294 | return 0; | 292 | return 0; |
295 | } | 293 | } |
296 | 294 | ||
297 | static int mei_pci_resume(struct device *device) | 295 | static int mei_me_pci_resume(struct device *device) |
298 | { | 296 | { |
299 | struct pci_dev *pdev = to_pci_dev(device); | 297 | struct pci_dev *pdev = to_pci_dev(device); |
300 | struct mei_device *dev; | 298 | struct mei_device *dev; |
@@ -334,24 +332,24 @@ static int mei_pci_resume(struct device *device) | |||
334 | 332 | ||
335 | return err; | 333 | return err; |
336 | } | 334 | } |
337 | static SIMPLE_DEV_PM_OPS(mei_pm_ops, mei_pci_suspend, mei_pci_resume); | 335 | static SIMPLE_DEV_PM_OPS(mei_me_pm_ops, mei_me_pci_suspend, mei_me_pci_resume); |
338 | #define MEI_PM_OPS (&mei_pm_ops) | 336 | #define MEI_ME_PM_OPS (&mei_me_pm_ops) |
339 | #else | 337 | #else |
340 | #define MEI_PM_OPS NULL | 338 | #define MEI_ME_PM_OPS NULL |
341 | #endif /* CONFIG_PM */ | 339 | #endif /* CONFIG_PM */ |
342 | /* | 340 | /* |
343 | * PCI driver structure | 341 | * PCI driver structure |
344 | */ | 342 | */ |
345 | static struct pci_driver mei_driver = { | 343 | static struct pci_driver mei_me_driver = { |
346 | .name = KBUILD_MODNAME, | 344 | .name = KBUILD_MODNAME, |
347 | .id_table = mei_pci_tbl, | 345 | .id_table = mei_me_pci_tbl, |
348 | .probe = mei_probe, | 346 | .probe = mei_me_probe, |
349 | .remove = mei_remove, | 347 | .remove = mei_me_remove, |
350 | .shutdown = mei_remove, | 348 | .shutdown = mei_me_remove, |
351 | .driver.pm = MEI_PM_OPS, | 349 | .driver.pm = MEI_ME_PM_OPS, |
352 | }; | 350 | }; |
353 | 351 | ||
354 | module_pci_driver(mei_driver); | 352 | module_pci_driver(mei_me_driver); |
355 | 353 | ||
356 | MODULE_AUTHOR("Intel Corporation"); | 354 | MODULE_AUTHOR("Intel Corporation"); |
357 | MODULE_DESCRIPTION("Intel(R) Management Engine Interface"); | 355 | MODULE_DESCRIPTION("Intel(R) Management Engine Interface"); |
diff --git a/drivers/misc/vmw_vmci/Kconfig b/drivers/misc/vmw_vmci/Kconfig index 39c2ecadb273..ea98f7e9ccd1 100644 --- a/drivers/misc/vmw_vmci/Kconfig +++ b/drivers/misc/vmw_vmci/Kconfig | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | config VMWARE_VMCI | 5 | config VMWARE_VMCI |
6 | tristate "VMware VMCI Driver" | 6 | tristate "VMware VMCI Driver" |
7 | depends on X86 && PCI | 7 | depends on X86 && PCI && NET |
8 | help | 8 | help |
9 | This is VMware's Virtual Machine Communication Interface. It enables | 9 | This is VMware's Virtual Machine Communication Interface. It enables |
10 | high-speed communication between host and guest in a virtual | 10 | high-speed communication between host and guest in a virtual |
diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c index 7009f17ad6cd..50adbd155f35 100644 --- a/drivers/mmc/host/sdricoh_cs.c +++ b/drivers/mmc/host/sdricoh_cs.c | |||
@@ -543,25 +543,7 @@ static struct pcmcia_driver sdricoh_driver = { | |||
543 | .suspend = sdricoh_pcmcia_suspend, | 543 | .suspend = sdricoh_pcmcia_suspend, |
544 | .resume = sdricoh_pcmcia_resume, | 544 | .resume = sdricoh_pcmcia_resume, |
545 | }; | 545 | }; |
546 | 546 | module_pcmcia_driver(sdricoh_driver); | |
547 | /*****************************************************************************\ | ||
548 | * * | ||
549 | * Driver init/exit * | ||
550 | * * | ||
551 | \*****************************************************************************/ | ||
552 | |||
553 | static int __init sdricoh_drv_init(void) | ||
554 | { | ||
555 | return pcmcia_register_driver(&sdricoh_driver); | ||
556 | } | ||
557 | |||
558 | static void __exit sdricoh_drv_exit(void) | ||
559 | { | ||
560 | pcmcia_unregister_driver(&sdricoh_driver); | ||
561 | } | ||
562 | |||
563 | module_init(sdricoh_drv_init); | ||
564 | module_exit(sdricoh_drv_exit); | ||
565 | 547 | ||
566 | module_param(switchlocked, uint, 0444); | 548 | module_param(switchlocked, uint, 0444); |
567 | 549 | ||
diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c index 5bed4c4e2508..74dc1875f9cd 100644 --- a/drivers/net/arcnet/com20020_cs.c +++ b/drivers/net/arcnet/com20020_cs.c | |||
@@ -333,16 +333,4 @@ static struct pcmcia_driver com20020_cs_driver = { | |||
333 | .suspend = com20020_suspend, | 333 | .suspend = com20020_suspend, |
334 | .resume = com20020_resume, | 334 | .resume = com20020_resume, |
335 | }; | 335 | }; |
336 | 336 | module_pcmcia_driver(com20020_cs_driver); | |
337 | static int __init init_com20020_cs(void) | ||
338 | { | ||
339 | return pcmcia_register_driver(&com20020_cs_driver); | ||
340 | } | ||
341 | |||
342 | static void __exit exit_com20020_cs(void) | ||
343 | { | ||
344 | pcmcia_unregister_driver(&com20020_cs_driver); | ||
345 | } | ||
346 | |||
347 | module_init(init_com20020_cs); | ||
348 | module_exit(exit_com20020_cs); | ||
diff --git a/drivers/net/can/sja1000/ems_pcmcia.c b/drivers/net/can/sja1000/ems_pcmcia.c index 5c2f3fbbf5ae..321c27e1c7fc 100644 --- a/drivers/net/can/sja1000/ems_pcmcia.c +++ b/drivers/net/can/sja1000/ems_pcmcia.c | |||
@@ -316,15 +316,4 @@ static struct pcmcia_driver ems_pcmcia_driver = { | |||
316 | .remove = ems_pcmcia_remove, | 316 | .remove = ems_pcmcia_remove, |
317 | .id_table = ems_pcmcia_tbl, | 317 | .id_table = ems_pcmcia_tbl, |
318 | }; | 318 | }; |
319 | 319 | module_pcmcia_driver(ems_pcmcia_driver); | |
320 | static int __init ems_pcmcia_init(void) | ||
321 | { | ||
322 | return pcmcia_register_driver(&ems_pcmcia_driver); | ||
323 | } | ||
324 | module_init(ems_pcmcia_init); | ||
325 | |||
326 | static void __exit ems_pcmcia_exit(void) | ||
327 | { | ||
328 | pcmcia_unregister_driver(&ems_pcmcia_driver); | ||
329 | } | ||
330 | module_exit(ems_pcmcia_exit); | ||
diff --git a/drivers/net/can/sja1000/peak_pcmcia.c b/drivers/net/can/sja1000/peak_pcmcia.c index 1a7020ba37f5..0a707f70661c 100644 --- a/drivers/net/can/sja1000/peak_pcmcia.c +++ b/drivers/net/can/sja1000/peak_pcmcia.c | |||
@@ -740,15 +740,4 @@ static struct pcmcia_driver pcan_driver = { | |||
740 | .remove = pcan_remove, | 740 | .remove = pcan_remove, |
741 | .id_table = pcan_table, | 741 | .id_table = pcan_table, |
742 | }; | 742 | }; |
743 | 743 | module_pcmcia_driver(pcan_driver); | |
744 | static int __init pcan_init(void) | ||
745 | { | ||
746 | return pcmcia_register_driver(&pcan_driver); | ||
747 | } | ||
748 | module_init(pcan_init); | ||
749 | |||
750 | static void __exit pcan_exit(void) | ||
751 | { | ||
752 | pcmcia_unregister_driver(&pcan_driver); | ||
753 | } | ||
754 | module_exit(pcan_exit); | ||
diff --git a/drivers/net/can/softing/softing_cs.c b/drivers/net/can/softing/softing_cs.c index c2c0a5bb0b21..498605f833dd 100644 --- a/drivers/net/can/softing/softing_cs.c +++ b/drivers/net/can/softing/softing_cs.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "softing_platform.h" | 27 | #include "softing_platform.h" |
28 | 28 | ||
29 | static int softingcs_index; | 29 | static int softingcs_index; |
30 | static spinlock_t softingcs_index_lock; | 30 | static DEFINE_SPINLOCK(softingcs_index_lock); |
31 | 31 | ||
32 | static int softingcs_reset(struct platform_device *pdev, int v); | 32 | static int softingcs_reset(struct platform_device *pdev, int v); |
33 | static int softingcs_enable_irq(struct platform_device *pdev, int v); | 33 | static int softingcs_enable_irq(struct platform_device *pdev, int v); |
@@ -340,19 +340,7 @@ static struct pcmcia_driver softingcs_driver = { | |||
340 | .remove = softingcs_remove, | 340 | .remove = softingcs_remove, |
341 | }; | 341 | }; |
342 | 342 | ||
343 | static int __init softingcs_start(void) | 343 | module_pcmcia_driver(softingcs_driver); |
344 | { | ||
345 | spin_lock_init(&softingcs_index_lock); | ||
346 | return pcmcia_register_driver(&softingcs_driver); | ||
347 | } | ||
348 | |||
349 | static void __exit softingcs_stop(void) | ||
350 | { | ||
351 | pcmcia_unregister_driver(&softingcs_driver); | ||
352 | } | ||
353 | |||
354 | module_init(softingcs_start); | ||
355 | module_exit(softingcs_stop); | ||
356 | 344 | ||
357 | MODULE_DESCRIPTION("softing CANcard driver" | 345 | MODULE_DESCRIPTION("softing CANcard driver" |
358 | ", links PCMCIA card to softing driver"); | 346 | ", links PCMCIA card to softing driver"); |
diff --git a/drivers/net/ethernet/3com/3c574_cs.c b/drivers/net/ethernet/3com/3c574_cs.c index ffd8de28a76a..6fc994fa4abe 100644 --- a/drivers/net/ethernet/3com/3c574_cs.c +++ b/drivers/net/ethernet/3com/3c574_cs.c | |||
@@ -1165,16 +1165,4 @@ static struct pcmcia_driver tc574_driver = { | |||
1165 | .suspend = tc574_suspend, | 1165 | .suspend = tc574_suspend, |
1166 | .resume = tc574_resume, | 1166 | .resume = tc574_resume, |
1167 | }; | 1167 | }; |
1168 | 1168 | module_pcmcia_driver(tc574_driver); | |
1169 | static int __init init_tc574(void) | ||
1170 | { | ||
1171 | return pcmcia_register_driver(&tc574_driver); | ||
1172 | } | ||
1173 | |||
1174 | static void __exit exit_tc574(void) | ||
1175 | { | ||
1176 | pcmcia_unregister_driver(&tc574_driver); | ||
1177 | } | ||
1178 | |||
1179 | module_init(init_tc574); | ||
1180 | module_exit(exit_tc574); | ||
diff --git a/drivers/net/ethernet/3com/3c589_cs.c b/drivers/net/ethernet/3com/3c589_cs.c index a556c01e011b..078480aaa168 100644 --- a/drivers/net/ethernet/3com/3c589_cs.c +++ b/drivers/net/ethernet/3com/3c589_cs.c | |||
@@ -928,16 +928,4 @@ static struct pcmcia_driver tc589_driver = { | |||
928 | .suspend = tc589_suspend, | 928 | .suspend = tc589_suspend, |
929 | .resume = tc589_resume, | 929 | .resume = tc589_resume, |
930 | }; | 930 | }; |
931 | 931 | module_pcmcia_driver(tc589_driver); | |
932 | static int __init init_tc589(void) | ||
933 | { | ||
934 | return pcmcia_register_driver(&tc589_driver); | ||
935 | } | ||
936 | |||
937 | static void __exit exit_tc589(void) | ||
938 | { | ||
939 | pcmcia_unregister_driver(&tc589_driver); | ||
940 | } | ||
941 | |||
942 | module_init(init_tc589); | ||
943 | module_exit(exit_tc589); | ||
diff --git a/drivers/net/ethernet/8390/axnet_cs.c b/drivers/net/ethernet/8390/axnet_cs.c index e1b3941bd149..d801c1410fb0 100644 --- a/drivers/net/ethernet/8390/axnet_cs.c +++ b/drivers/net/ethernet/8390/axnet_cs.c | |||
@@ -728,19 +728,7 @@ static struct pcmcia_driver axnet_cs_driver = { | |||
728 | .suspend = axnet_suspend, | 728 | .suspend = axnet_suspend, |
729 | .resume = axnet_resume, | 729 | .resume = axnet_resume, |
730 | }; | 730 | }; |
731 | 731 | module_pcmcia_driver(axnet_cs_driver); | |
732 | static int __init init_axnet_cs(void) | ||
733 | { | ||
734 | return pcmcia_register_driver(&axnet_cs_driver); | ||
735 | } | ||
736 | |||
737 | static void __exit exit_axnet_cs(void) | ||
738 | { | ||
739 | pcmcia_unregister_driver(&axnet_cs_driver); | ||
740 | } | ||
741 | |||
742 | module_init(init_axnet_cs); | ||
743 | module_exit(exit_axnet_cs); | ||
744 | 732 | ||
745 | /*====================================================================*/ | 733 | /*====================================================================*/ |
746 | 734 | ||
diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c index de1af0bfed4c..46c5aadaca8e 100644 --- a/drivers/net/ethernet/8390/pcnet_cs.c +++ b/drivers/net/ethernet/8390/pcnet_cs.c | |||
@@ -1694,16 +1694,4 @@ static struct pcmcia_driver pcnet_driver = { | |||
1694 | .suspend = pcnet_suspend, | 1694 | .suspend = pcnet_suspend, |
1695 | .resume = pcnet_resume, | 1695 | .resume = pcnet_resume, |
1696 | }; | 1696 | }; |
1697 | 1697 | module_pcmcia_driver(pcnet_driver); | |
1698 | static int __init init_pcnet_cs(void) | ||
1699 | { | ||
1700 | return pcmcia_register_driver(&pcnet_driver); | ||
1701 | } | ||
1702 | |||
1703 | static void __exit exit_pcnet_cs(void) | ||
1704 | { | ||
1705 | pcmcia_unregister_driver(&pcnet_driver); | ||
1706 | } | ||
1707 | |||
1708 | module_init(init_pcnet_cs); | ||
1709 | module_exit(exit_pcnet_cs); | ||
diff --git a/drivers/net/ethernet/amd/nmclan_cs.c b/drivers/net/ethernet/amd/nmclan_cs.c index 9f59bf63514b..d4ed89130c52 100644 --- a/drivers/net/ethernet/amd/nmclan_cs.c +++ b/drivers/net/ethernet/amd/nmclan_cs.c | |||
@@ -1508,16 +1508,4 @@ static struct pcmcia_driver nmclan_cs_driver = { | |||
1508 | .suspend = nmclan_suspend, | 1508 | .suspend = nmclan_suspend, |
1509 | .resume = nmclan_resume, | 1509 | .resume = nmclan_resume, |
1510 | }; | 1510 | }; |
1511 | 1511 | module_pcmcia_driver(nmclan_cs_driver); | |
1512 | static int __init init_nmclan_cs(void) | ||
1513 | { | ||
1514 | return pcmcia_register_driver(&nmclan_cs_driver); | ||
1515 | } | ||
1516 | |||
1517 | static void __exit exit_nmclan_cs(void) | ||
1518 | { | ||
1519 | pcmcia_unregister_driver(&nmclan_cs_driver); | ||
1520 | } | ||
1521 | |||
1522 | module_init(init_nmclan_cs); | ||
1523 | module_exit(exit_nmclan_cs); | ||
diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c index 2418faf2251a..ab98b77df309 100644 --- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c +++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c | |||
@@ -705,19 +705,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = { | |||
705 | .suspend = fmvj18x_suspend, | 705 | .suspend = fmvj18x_suspend, |
706 | .resume = fmvj18x_resume, | 706 | .resume = fmvj18x_resume, |
707 | }; | 707 | }; |
708 | 708 | module_pcmcia_driver(fmvj18x_cs_driver); | |
709 | static int __init init_fmvj18x_cs(void) | ||
710 | { | ||
711 | return pcmcia_register_driver(&fmvj18x_cs_driver); | ||
712 | } | ||
713 | |||
714 | static void __exit exit_fmvj18x_cs(void) | ||
715 | { | ||
716 | pcmcia_unregister_driver(&fmvj18x_cs_driver); | ||
717 | } | ||
718 | |||
719 | module_init(init_fmvj18x_cs); | ||
720 | module_exit(exit_fmvj18x_cs); | ||
721 | 709 | ||
722 | /*====================================================================*/ | 710 | /*====================================================================*/ |
723 | 711 | ||
diff --git a/drivers/net/ethernet/smsc/smc91c92_cs.c b/drivers/net/ethernet/smsc/smc91c92_cs.c index 04393b5fef71..656d2e2ebfc9 100644 --- a/drivers/net/ethernet/smsc/smc91c92_cs.c +++ b/drivers/net/ethernet/smsc/smc91c92_cs.c | |||
@@ -2054,16 +2054,4 @@ static struct pcmcia_driver smc91c92_cs_driver = { | |||
2054 | .suspend = smc91c92_suspend, | 2054 | .suspend = smc91c92_suspend, |
2055 | .resume = smc91c92_resume, | 2055 | .resume = smc91c92_resume, |
2056 | }; | 2056 | }; |
2057 | 2057 | module_pcmcia_driver(smc91c92_cs_driver); | |
2058 | static int __init init_smc91c92_cs(void) | ||
2059 | { | ||
2060 | return pcmcia_register_driver(&smc91c92_cs_driver); | ||
2061 | } | ||
2062 | |||
2063 | static void __exit exit_smc91c92_cs(void) | ||
2064 | { | ||
2065 | pcmcia_unregister_driver(&smc91c92_cs_driver); | ||
2066 | } | ||
2067 | |||
2068 | module_init(init_smc91c92_cs); | ||
2069 | module_exit(exit_smc91c92_cs); | ||
diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c index 98e09d0d3ce2..1025b4e937d2 100644 --- a/drivers/net/ethernet/xircom/xirc2ps_cs.c +++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c | |||
@@ -1775,21 +1775,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = { | |||
1775 | .suspend = xirc2ps_suspend, | 1775 | .suspend = xirc2ps_suspend, |
1776 | .resume = xirc2ps_resume, | 1776 | .resume = xirc2ps_resume, |
1777 | }; | 1777 | }; |
1778 | 1778 | module_pcmcia_driver(xirc2ps_cs_driver); | |
1779 | static int __init | ||
1780 | init_xirc2ps_cs(void) | ||
1781 | { | ||
1782 | return pcmcia_register_driver(&xirc2ps_cs_driver); | ||
1783 | } | ||
1784 | |||
1785 | static void __exit | ||
1786 | exit_xirc2ps_cs(void) | ||
1787 | { | ||
1788 | pcmcia_unregister_driver(&xirc2ps_cs_driver); | ||
1789 | } | ||
1790 | |||
1791 | module_init(init_xirc2ps_cs); | ||
1792 | module_exit(exit_xirc2ps_cs); | ||
1793 | 1779 | ||
1794 | #ifndef MODULE | 1780 | #ifndef MODULE |
1795 | static int __init setup_xirc2ps_cs(char *str) | 1781 | static int __init setup_xirc2ps_cs(char *str) |
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index 956024a636e6..14128fd265ac 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c | |||
@@ -180,16 +180,7 @@ static struct pcmcia_driver airo_driver = { | |||
180 | .suspend = airo_suspend, | 180 | .suspend = airo_suspend, |
181 | .resume = airo_resume, | 181 | .resume = airo_resume, |
182 | }; | 182 | }; |
183 | 183 | module_pcmcia_driver(airo_driver); | |
184 | static int __init airo_cs_init(void) | ||
185 | { | ||
186 | return pcmcia_register_driver(&airo_driver); | ||
187 | } | ||
188 | |||
189 | static void __exit airo_cs_cleanup(void) | ||
190 | { | ||
191 | pcmcia_unregister_driver(&airo_driver); | ||
192 | } | ||
193 | 184 | ||
194 | /* | 185 | /* |
195 | This program is free software; you can redistribute it and/or | 186 | This program is free software; you can redistribute it and/or |
@@ -229,6 +220,3 @@ static void __exit airo_cs_cleanup(void) | |||
229 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 220 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
230 | POSSIBILITY OF SUCH DAMAGE. | 221 | POSSIBILITY OF SUCH DAMAGE. |
231 | */ | 222 | */ |
232 | |||
233 | module_init(airo_cs_init); | ||
234 | module_exit(airo_cs_cleanup); | ||
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index b42930f457c2..522572219217 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c | |||
@@ -245,16 +245,7 @@ static struct pcmcia_driver atmel_driver = { | |||
245 | .suspend = atmel_suspend, | 245 | .suspend = atmel_suspend, |
246 | .resume = atmel_resume, | 246 | .resume = atmel_resume, |
247 | }; | 247 | }; |
248 | 248 | module_pcmcia_driver(atmel_driver); | |
249 | static int __init atmel_cs_init(void) | ||
250 | { | ||
251 | return pcmcia_register_driver(&atmel_driver); | ||
252 | } | ||
253 | |||
254 | static void __exit atmel_cs_cleanup(void) | ||
255 | { | ||
256 | pcmcia_unregister_driver(&atmel_driver); | ||
257 | } | ||
258 | 249 | ||
259 | /* | 250 | /* |
260 | This program is free software; you can redistribute it and/or | 251 | This program is free software; you can redistribute it and/or |
@@ -294,6 +285,3 @@ static void __exit atmel_cs_cleanup(void) | |||
294 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 285 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
295 | POSSIBILITY OF SUCH DAMAGE. | 286 | POSSIBILITY OF SUCH DAMAGE. |
296 | */ | 287 | */ |
297 | |||
298 | module_init(atmel_cs_init); | ||
299 | module_exit(atmel_cs_cleanup); | ||
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c index f2ea2ceec8a9..55f2bd7f8f74 100644 --- a/drivers/net/wireless/b43/pcmcia.c +++ b/drivers/net/wireless/b43/pcmcia.c | |||
@@ -130,6 +130,10 @@ static struct pcmcia_driver b43_pcmcia_driver = { | |||
130 | .resume = b43_pcmcia_resume, | 130 | .resume = b43_pcmcia_resume, |
131 | }; | 131 | }; |
132 | 132 | ||
133 | /* | ||
134 | * These are not module init/exit functions! | ||
135 | * The module_pcmcia_driver() helper cannot be used here. | ||
136 | */ | ||
133 | int b43_pcmcia_init(void) | 137 | int b43_pcmcia_init(void) |
134 | { | 138 | { |
135 | return pcmcia_register_driver(&b43_pcmcia_driver); | 139 | return pcmcia_register_driver(&b43_pcmcia_driver); |
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 89e9d3a78c3c..56cd01ca8ad0 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -709,17 +709,4 @@ static struct pcmcia_driver hostap_driver = { | |||
709 | .suspend = hostap_cs_suspend, | 709 | .suspend = hostap_cs_suspend, |
710 | .resume = hostap_cs_resume, | 710 | .resume = hostap_cs_resume, |
711 | }; | 711 | }; |
712 | 712 | module_pcmcia_driver(hostap_driver); | |
713 | static int __init init_prism2_pccard(void) | ||
714 | { | ||
715 | return pcmcia_register_driver(&hostap_driver); | ||
716 | } | ||
717 | |||
718 | static void __exit exit_prism2_pccard(void) | ||
719 | { | ||
720 | pcmcia_unregister_driver(&hostap_driver); | ||
721 | } | ||
722 | |||
723 | |||
724 | module_init(init_prism2_pccard); | ||
725 | module_exit(exit_prism2_pccard); | ||
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c index 16beaf39dc53..c94dd6802672 100644 --- a/drivers/net/wireless/libertas/if_cs.c +++ b/drivers/net/wireless/libertas/if_cs.c | |||
@@ -999,7 +999,6 @@ static const struct pcmcia_device_id if_cs_ids[] = { | |||
999 | }; | 999 | }; |
1000 | MODULE_DEVICE_TABLE(pcmcia, if_cs_ids); | 1000 | MODULE_DEVICE_TABLE(pcmcia, if_cs_ids); |
1001 | 1001 | ||
1002 | |||
1003 | static struct pcmcia_driver lbs_driver = { | 1002 | static struct pcmcia_driver lbs_driver = { |
1004 | .owner = THIS_MODULE, | 1003 | .owner = THIS_MODULE, |
1005 | .name = DRV_NAME, | 1004 | .name = DRV_NAME, |
@@ -1007,26 +1006,4 @@ static struct pcmcia_driver lbs_driver = { | |||
1007 | .remove = if_cs_detach, | 1006 | .remove = if_cs_detach, |
1008 | .id_table = if_cs_ids, | 1007 | .id_table = if_cs_ids, |
1009 | }; | 1008 | }; |
1010 | 1009 | module_pcmcia_driver(lbs_driver); | |
1011 | |||
1012 | static int __init if_cs_init(void) | ||
1013 | { | ||
1014 | int ret; | ||
1015 | |||
1016 | lbs_deb_enter(LBS_DEB_CS); | ||
1017 | ret = pcmcia_register_driver(&lbs_driver); | ||
1018 | lbs_deb_leave(LBS_DEB_CS); | ||
1019 | return ret; | ||
1020 | } | ||
1021 | |||
1022 | |||
1023 | static void __exit if_cs_exit(void) | ||
1024 | { | ||
1025 | lbs_deb_enter(LBS_DEB_CS); | ||
1026 | pcmcia_unregister_driver(&lbs_driver); | ||
1027 | lbs_deb_leave(LBS_DEB_CS); | ||
1028 | } | ||
1029 | |||
1030 | |||
1031 | module_init(if_cs_init); | ||
1032 | module_exit(if_cs_exit); | ||
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c index d7dbc00bcfbe..d21d95939316 100644 --- a/drivers/net/wireless/orinoco/orinoco_cs.c +++ b/drivers/net/wireless/orinoco/orinoco_cs.c | |||
@@ -338,18 +338,4 @@ static struct pcmcia_driver orinoco_driver = { | |||
338 | .suspend = orinoco_cs_suspend, | 338 | .suspend = orinoco_cs_suspend, |
339 | .resume = orinoco_cs_resume, | 339 | .resume = orinoco_cs_resume, |
340 | }; | 340 | }; |
341 | 341 | module_pcmcia_driver(orinoco_driver); | |
342 | static int __init | ||
343 | init_orinoco_cs(void) | ||
344 | { | ||
345 | return pcmcia_register_driver(&orinoco_driver); | ||
346 | } | ||
347 | |||
348 | static void __exit | ||
349 | exit_orinoco_cs(void) | ||
350 | { | ||
351 | pcmcia_unregister_driver(&orinoco_driver); | ||
352 | } | ||
353 | |||
354 | module_init(init_orinoco_cs); | ||
355 | module_exit(exit_orinoco_cs); | ||
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c index 6e28ee4e9c52..e2264bc12ebf 100644 --- a/drivers/net/wireless/orinoco/spectrum_cs.c +++ b/drivers/net/wireless/orinoco/spectrum_cs.c | |||
@@ -318,18 +318,4 @@ static struct pcmcia_driver orinoco_driver = { | |||
318 | .resume = spectrum_cs_resume, | 318 | .resume = spectrum_cs_resume, |
319 | .id_table = spectrum_cs_ids, | 319 | .id_table = spectrum_cs_ids, |
320 | }; | 320 | }; |
321 | 321 | module_pcmcia_driver(orinoco_driver); | |
322 | static int __init | ||
323 | init_spectrum_cs(void) | ||
324 | { | ||
325 | return pcmcia_register_driver(&orinoco_driver); | ||
326 | } | ||
327 | |||
328 | static void __exit | ||
329 | exit_spectrum_cs(void) | ||
330 | { | ||
331 | pcmcia_unregister_driver(&orinoco_driver); | ||
332 | } | ||
333 | |||
334 | module_init(init_spectrum_cs); | ||
335 | module_exit(exit_spectrum_cs); | ||
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 730186d0449b..38d2089f338a 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c | |||
@@ -2013,19 +2013,7 @@ static struct pcmcia_driver wl3501_driver = { | |||
2013 | .suspend = wl3501_suspend, | 2013 | .suspend = wl3501_suspend, |
2014 | .resume = wl3501_resume, | 2014 | .resume = wl3501_resume, |
2015 | }; | 2015 | }; |
2016 | 2016 | module_pcmcia_driver(wl3501_driver); | |
2017 | static int __init wl3501_init_module(void) | ||
2018 | { | ||
2019 | return pcmcia_register_driver(&wl3501_driver); | ||
2020 | } | ||
2021 | |||
2022 | static void __exit wl3501_exit_module(void) | ||
2023 | { | ||
2024 | pcmcia_unregister_driver(&wl3501_driver); | ||
2025 | } | ||
2026 | |||
2027 | module_init(wl3501_init_module); | ||
2028 | module_exit(wl3501_exit_module); | ||
2029 | 2017 | ||
2030 | MODULE_AUTHOR("Fox Chen <mhchen@golf.ccl.itri.org.tw>, " | 2018 | MODULE_AUTHOR("Fox Chen <mhchen@golf.ccl.itri.org.tw>, " |
2031 | "Arnaldo Carvalho de Melo <acme@conectiva.com.br>," | 2019 | "Arnaldo Carvalho de Melo <acme@conectiva.com.br>," |
diff --git a/drivers/parport/parport_amiga.c b/drivers/parport/parport_amiga.c index ee78e0ee6e05..09503b8d12e6 100644 --- a/drivers/parport/parport_amiga.c +++ b/drivers/parport/parport_amiga.c | |||
@@ -244,20 +244,7 @@ static struct platform_driver amiga_parallel_driver = { | |||
244 | }, | 244 | }, |
245 | }; | 245 | }; |
246 | 246 | ||
247 | static int __init amiga_parallel_init(void) | 247 | module_platform_driver_probe(amiga_parallel_driver, amiga_parallel_probe); |
248 | { | ||
249 | return platform_driver_probe(&amiga_parallel_driver, | ||
250 | amiga_parallel_probe); | ||
251 | } | ||
252 | |||
253 | module_init(amiga_parallel_init); | ||
254 | |||
255 | static void __exit amiga_parallel_exit(void) | ||
256 | { | ||
257 | platform_driver_unregister(&amiga_parallel_driver); | ||
258 | } | ||
259 | |||
260 | module_exit(amiga_parallel_exit); | ||
261 | 248 | ||
262 | MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>"); | 249 | MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>"); |
263 | MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port"); | 250 | MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port"); |
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 067ad517c1f5..e9b52e4a4648 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c | |||
@@ -193,16 +193,4 @@ static struct pcmcia_driver parport_cs_driver = { | |||
193 | .remove = parport_detach, | 193 | .remove = parport_detach, |
194 | .id_table = parport_ids, | 194 | .id_table = parport_ids, |
195 | }; | 195 | }; |
196 | 196 | module_pcmcia_driver(parport_cs_driver); | |
197 | static int __init init_parport_cs(void) | ||
198 | { | ||
199 | return pcmcia_register_driver(&parport_cs_driver); | ||
200 | } | ||
201 | |||
202 | static void __exit exit_parport_cs(void) | ||
203 | { | ||
204 | pcmcia_unregister_driver(&parport_cs_driver); | ||
205 | } | ||
206 | |||
207 | module_init(init_parport_cs); | ||
208 | module_exit(exit_parport_cs); | ||
diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c index 050773c36823..a5251cb5fb0c 100644 --- a/drivers/parport/parport_gsc.c +++ b/drivers/parport/parport_gsc.c | |||
@@ -246,14 +246,14 @@ struct parport *parport_gsc_probe_port(unsigned long base, | |||
246 | printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base); | 246 | printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base); |
247 | return NULL; | 247 | return NULL; |
248 | } | 248 | } |
249 | ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL); | 249 | ops = kmemdup(&parport_gsc_ops, sizeof(struct parport_operations), |
250 | GFP_KERNEL); | ||
250 | if (!ops) { | 251 | if (!ops) { |
251 | printk (KERN_DEBUG "parport (0x%lx): no memory for ops!\n", | 252 | printk (KERN_DEBUG "parport (0x%lx): no memory for ops!\n", |
252 | base); | 253 | base); |
253 | kfree (priv); | 254 | kfree (priv); |
254 | return NULL; | 255 | return NULL; |
255 | } | 256 | } |
256 | memcpy (ops, &parport_gsc_ops, sizeof (struct parport_operations)); | ||
257 | priv->ctr = 0xc; | 257 | priv->ctr = 0xc; |
258 | priv->ctr_writable = 0xff; | 258 | priv->ctr_writable = 0xff; |
259 | priv->dma_buf = 0; | 259 | priv->dma_buf = 0; |
diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c index 5c4b6a1db6ca..dffd6d0bd15b 100644 --- a/drivers/parport/parport_sunbpp.c +++ b/drivers/parport/parport_sunbpp.c | |||
@@ -284,12 +284,11 @@ static int bpp_probe(struct platform_device *op) | |||
284 | size = resource_size(&op->resource[0]); | 284 | size = resource_size(&op->resource[0]); |
285 | dma = PARPORT_DMA_NONE; | 285 | dma = PARPORT_DMA_NONE; |
286 | 286 | ||
287 | ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL); | 287 | ops = kmemdup(&parport_sunbpp_ops, sizeof(struct parport_operations), |
288 | GFP_KERNEL); | ||
288 | if (!ops) | 289 | if (!ops) |
289 | goto out_unmap; | 290 | goto out_unmap; |
290 | 291 | ||
291 | memcpy (ops, &parport_sunbpp_ops, sizeof(struct parport_operations)); | ||
292 | |||
293 | dprintk(("register_port\n")); | 292 | dprintk(("register_port\n")); |
294 | if (!(p = parport_register_port((unsigned long)base, irq, dma, ops))) | 293 | if (!(p = parport_register_port((unsigned long)base, irq, dma, ops))) |
295 | goto out_free_ops; | 294 | goto out_free_ops; |
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 3f56bc086cb5..92ed045a5f93 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c | |||
@@ -476,10 +476,9 @@ int parport_proc_register(struct parport *port) | |||
476 | struct parport_sysctl_table *t; | 476 | struct parport_sysctl_table *t; |
477 | int i; | 477 | int i; |
478 | 478 | ||
479 | t = kmalloc(sizeof(*t), GFP_KERNEL); | 479 | t = kmemdup(&parport_sysctl_template, sizeof(*t), GFP_KERNEL); |
480 | if (t == NULL) | 480 | if (t == NULL) |
481 | return -ENOMEM; | 481 | return -ENOMEM; |
482 | memcpy(t, &parport_sysctl_template, sizeof(*t)); | ||
483 | 482 | ||
484 | t->device_dir[0].extra1 = port; | 483 | t->device_dir[0].extra1 = port; |
485 | 484 | ||
@@ -523,10 +522,9 @@ int parport_device_proc_register(struct pardevice *device) | |||
523 | struct parport_device_sysctl_table *t; | 522 | struct parport_device_sysctl_table *t; |
524 | struct parport * port = device->port; | 523 | struct parport * port = device->port; |
525 | 524 | ||
526 | t = kmalloc(sizeof(*t), GFP_KERNEL); | 525 | t = kmemdup(&parport_device_sysctl_template, sizeof(*t), GFP_KERNEL); |
527 | if (t == NULL) | 526 | if (t == NULL) |
528 | return -ENOMEM; | 527 | return -ENOMEM; |
529 | memcpy(t, &parport_device_sysctl_template, sizeof(*t)); | ||
530 | 528 | ||
531 | t->dev_dir[0].child = t->parport_dir; | 529 | t->dev_dir[0].child = t->parport_dir; |
532 | t->parport_dir[0].child = t->port_dir; | 530 | t->parport_dir[0].child = t->port_dir; |
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 7d1609fa233c..df82a349e969 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c | |||
@@ -220,16 +220,4 @@ static struct pcmcia_driver aha152x_cs_driver = { | |||
220 | .id_table = aha152x_ids, | 220 | .id_table = aha152x_ids, |
221 | .resume = aha152x_resume, | 221 | .resume = aha152x_resume, |
222 | }; | 222 | }; |
223 | 223 | module_pcmcia_driver(aha152x_cs_driver); | |
224 | static int __init init_aha152x_cs(void) | ||
225 | { | ||
226 | return pcmcia_register_driver(&aha152x_cs_driver); | ||
227 | } | ||
228 | |||
229 | static void __exit exit_aha152x_cs(void) | ||
230 | { | ||
231 | pcmcia_unregister_driver(&aha152x_cs_driver); | ||
232 | } | ||
233 | |||
234 | module_init(init_aha152x_cs); | ||
235 | module_exit(exit_aha152x_cs); | ||
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index 714b248f5d5e..ba84769e849f 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c | |||
@@ -194,16 +194,4 @@ static struct pcmcia_driver fdomain_cs_driver = { | |||
194 | .id_table = fdomain_ids, | 194 | .id_table = fdomain_ids, |
195 | .resume = fdomain_resume, | 195 | .resume = fdomain_resume, |
196 | }; | 196 | }; |
197 | 197 | module_pcmcia_driver(fdomain_cs_driver); | |
198 | static int __init init_fdomain_cs(void) | ||
199 | { | ||
200 | return pcmcia_register_driver(&fdomain_cs_driver); | ||
201 | } | ||
202 | |||
203 | static void __exit exit_fdomain_cs(void) | ||
204 | { | ||
205 | pcmcia_unregister_driver(&fdomain_cs_driver); | ||
206 | } | ||
207 | |||
208 | module_init(init_fdomain_cs); | ||
209 | module_exit(exit_fdomain_cs); | ||
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index b61a753eb896..76ca00cbc11e 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c | |||
@@ -1773,19 +1773,4 @@ static struct pcmcia_driver nsp_driver = { | |||
1773 | .suspend = nsp_cs_suspend, | 1773 | .suspend = nsp_cs_suspend, |
1774 | .resume = nsp_cs_resume, | 1774 | .resume = nsp_cs_resume, |
1775 | }; | 1775 | }; |
1776 | 1776 | module_pcmcia_driver(nsp_driver); | |
1777 | static int __init nsp_cs_init(void) | ||
1778 | { | ||
1779 | return pcmcia_register_driver(&nsp_driver); | ||
1780 | } | ||
1781 | |||
1782 | static void __exit nsp_cs_exit(void) | ||
1783 | { | ||
1784 | pcmcia_unregister_driver(&nsp_driver); | ||
1785 | } | ||
1786 | |||
1787 | |||
1788 | module_init(nsp_cs_init) | ||
1789 | module_exit(nsp_cs_exit) | ||
1790 | |||
1791 | /* end */ | ||
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index bcaf89fe0c9e..8d4fdc292242 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c | |||
@@ -300,19 +300,8 @@ static struct pcmcia_driver qlogic_cs_driver = { | |||
300 | .id_table = qlogic_ids, | 300 | .id_table = qlogic_ids, |
301 | .resume = qlogic_resume, | 301 | .resume = qlogic_resume, |
302 | }; | 302 | }; |
303 | 303 | module_pcmcia_driver(qlogic_cs_driver); | |
304 | static int __init init_qlogic_cs(void) | ||
305 | { | ||
306 | return pcmcia_register_driver(&qlogic_cs_driver); | ||
307 | } | ||
308 | |||
309 | static void __exit exit_qlogic_cs(void) | ||
310 | { | ||
311 | pcmcia_unregister_driver(&qlogic_cs_driver); | ||
312 | } | ||
313 | 304 | ||
314 | MODULE_AUTHOR("Tom Zerucha, Michael Griffith"); | 305 | MODULE_AUTHOR("Tom Zerucha, Michael Griffith"); |
315 | MODULE_DESCRIPTION("Driver for the PCMCIA Qlogic FAS SCSI controllers"); | 306 | MODULE_DESCRIPTION("Driver for the PCMCIA Qlogic FAS SCSI controllers"); |
316 | MODULE_LICENSE("GPL"); | 307 | MODULE_LICENSE("GPL"); |
317 | module_init(init_qlogic_cs); | ||
318 | module_exit(exit_qlogic_cs); | ||
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index f5b52731abd9..55b0b2b38a65 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c | |||
@@ -881,18 +881,4 @@ static struct pcmcia_driver sym53c500_cs_driver = { | |||
881 | .id_table = sym53c500_ids, | 881 | .id_table = sym53c500_ids, |
882 | .resume = sym53c500_resume, | 882 | .resume = sym53c500_resume, |
883 | }; | 883 | }; |
884 | 884 | module_pcmcia_driver(sym53c500_cs_driver); | |
885 | static int __init | ||
886 | init_sym53c500_cs(void) | ||
887 | { | ||
888 | return pcmcia_register_driver(&sym53c500_cs_driver); | ||
889 | } | ||
890 | |||
891 | static void __exit | ||
892 | exit_sym53c500_cs(void) | ||
893 | { | ||
894 | pcmcia_unregister_driver(&sym53c500_cs_driver); | ||
895 | } | ||
896 | |||
897 | module_init(init_sym53c500_cs); | ||
898 | module_exit(exit_sym53c500_cs); | ||
diff --git a/drivers/ssbi/Kconfig b/drivers/ssbi/Kconfig new file mode 100644 index 000000000000..1ae4040afedd --- /dev/null +++ b/drivers/ssbi/Kconfig | |||
@@ -0,0 +1,16 @@ | |||
1 | # | ||
2 | # SSBI bus support | ||
3 | # | ||
4 | |||
5 | menu "Qualcomm MSM SSBI bus support" | ||
6 | |||
7 | config SSBI | ||
8 | tristate "Qualcomm Single-wire Serial Bus Interface (SSBI)" | ||
9 | help | ||
10 | If you say yes to this option, support will be included for the | ||
11 | built-in SSBI interface on Qualcomm MSM family processors. | ||
12 | |||
13 | This is required for communicating with Qualcomm PMICs and | ||
14 | other devices that have the SSBI interface. | ||
15 | |||
16 | endmenu | ||
diff --git a/drivers/ssbi/Makefile b/drivers/ssbi/Makefile new file mode 100644 index 000000000000..38fb70c31caf --- /dev/null +++ b/drivers/ssbi/Makefile | |||
@@ -0,0 +1 @@ | |||
obj-$(CONFIG_SSBI) += ssbi.o | |||
diff --git a/drivers/ssbi/ssbi.c b/drivers/ssbi/ssbi.c new file mode 100644 index 000000000000..f32da0258a8e --- /dev/null +++ b/drivers/ssbi/ssbi.c | |||
@@ -0,0 +1,379 @@ | |||
1 | /* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. | ||
2 | * Copyright (c) 2010, Google Inc. | ||
3 | * | ||
4 | * Original authors: Code Aurora Forum | ||
5 | * | ||
6 | * Author: Dima Zavin <dima@android.com> | ||
7 | * - Largely rewritten from original to not be an i2c driver. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 and | ||
11 | * only version 2 as published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | */ | ||
18 | |||
19 | #define pr_fmt(fmt) "%s: " fmt, __func__ | ||
20 | |||
21 | #include <linux/delay.h> | ||
22 | #include <linux/err.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/platform_device.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/ssbi.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/of.h> | ||
30 | #include <linux/of_device.h> | ||
31 | |||
32 | /* SSBI 2.0 controller registers */ | ||
33 | #define SSBI2_CMD 0x0008 | ||
34 | #define SSBI2_RD 0x0010 | ||
35 | #define SSBI2_STATUS 0x0014 | ||
36 | #define SSBI2_MODE2 0x001C | ||
37 | |||
38 | /* SSBI_CMD fields */ | ||
39 | #define SSBI_CMD_RDWRN (1 << 24) | ||
40 | |||
41 | /* SSBI_STATUS fields */ | ||
42 | #define SSBI_STATUS_RD_READY (1 << 2) | ||
43 | #define SSBI_STATUS_READY (1 << 1) | ||
44 | #define SSBI_STATUS_MCHN_BUSY (1 << 0) | ||
45 | |||
46 | /* SSBI_MODE2 fields */ | ||
47 | #define SSBI_MODE2_REG_ADDR_15_8_SHFT 0x04 | ||
48 | #define SSBI_MODE2_REG_ADDR_15_8_MASK (0x7f << SSBI_MODE2_REG_ADDR_15_8_SHFT) | ||
49 | |||
50 | #define SET_SSBI_MODE2_REG_ADDR_15_8(MD, AD) \ | ||
51 | (((MD) & 0x0F) | ((((AD) >> 8) << SSBI_MODE2_REG_ADDR_15_8_SHFT) & \ | ||
52 | SSBI_MODE2_REG_ADDR_15_8_MASK)) | ||
53 | |||
54 | /* SSBI PMIC Arbiter command registers */ | ||
55 | #define SSBI_PA_CMD 0x0000 | ||
56 | #define SSBI_PA_RD_STATUS 0x0004 | ||
57 | |||
58 | /* SSBI_PA_CMD fields */ | ||
59 | #define SSBI_PA_CMD_RDWRN (1 << 24) | ||
60 | #define SSBI_PA_CMD_ADDR_MASK 0x7fff /* REG_ADDR_7_0, REG_ADDR_8_14*/ | ||
61 | |||
62 | /* SSBI_PA_RD_STATUS fields */ | ||
63 | #define SSBI_PA_RD_STATUS_TRANS_DONE (1 << 27) | ||
64 | #define SSBI_PA_RD_STATUS_TRANS_DENIED (1 << 26) | ||
65 | |||
66 | #define SSBI_TIMEOUT_US 100 | ||
67 | |||
68 | struct ssbi { | ||
69 | struct device *slave; | ||
70 | void __iomem *base; | ||
71 | spinlock_t lock; | ||
72 | enum ssbi_controller_type controller_type; | ||
73 | int (*read)(struct ssbi *, u16 addr, u8 *buf, int len); | ||
74 | int (*write)(struct ssbi *, u16 addr, u8 *buf, int len); | ||
75 | }; | ||
76 | |||
77 | #define to_ssbi(dev) platform_get_drvdata(to_platform_device(dev)) | ||
78 | |||
79 | static inline u32 ssbi_readl(struct ssbi *ssbi, u32 reg) | ||
80 | { | ||
81 | return readl(ssbi->base + reg); | ||
82 | } | ||
83 | |||
84 | static inline void ssbi_writel(struct ssbi *ssbi, u32 val, u32 reg) | ||
85 | { | ||
86 | writel(val, ssbi->base + reg); | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * Via private exchange with one of the original authors, the hardware | ||
91 | * should generally finish a transaction in about 5us. The worst | ||
92 | * case, is when using the arbiter and both other CPUs have just | ||
93 | * started trying to use the SSBI bus will result in a time of about | ||
94 | * 20us. It should never take longer than this. | ||
95 | * | ||
96 | * As such, this wait merely spins, with a udelay. | ||
97 | */ | ||
98 | static int ssbi_wait_mask(struct ssbi *ssbi, u32 set_mask, u32 clr_mask) | ||
99 | { | ||
100 | u32 timeout = SSBI_TIMEOUT_US; | ||
101 | u32 val; | ||
102 | |||
103 | while (timeout--) { | ||
104 | val = ssbi_readl(ssbi, SSBI2_STATUS); | ||
105 | if (((val & set_mask) == set_mask) && ((val & clr_mask) == 0)) | ||
106 | return 0; | ||
107 | udelay(1); | ||
108 | } | ||
109 | |||
110 | return -ETIMEDOUT; | ||
111 | } | ||
112 | |||
113 | static int | ||
114 | ssbi_read_bytes(struct ssbi *ssbi, u16 addr, u8 *buf, int len) | ||
115 | { | ||
116 | u32 cmd = SSBI_CMD_RDWRN | ((addr & 0xff) << 16); | ||
117 | int ret = 0; | ||
118 | |||
119 | if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { | ||
120 | u32 mode2 = ssbi_readl(ssbi, SSBI2_MODE2); | ||
121 | mode2 = SET_SSBI_MODE2_REG_ADDR_15_8(mode2, addr); | ||
122 | ssbi_writel(ssbi, mode2, SSBI2_MODE2); | ||
123 | } | ||
124 | |||
125 | while (len) { | ||
126 | ret = ssbi_wait_mask(ssbi, SSBI_STATUS_READY, 0); | ||
127 | if (ret) | ||
128 | goto err; | ||
129 | |||
130 | ssbi_writel(ssbi, cmd, SSBI2_CMD); | ||
131 | ret = ssbi_wait_mask(ssbi, SSBI_STATUS_RD_READY, 0); | ||
132 | if (ret) | ||
133 | goto err; | ||
134 | *buf++ = ssbi_readl(ssbi, SSBI2_RD) & 0xff; | ||
135 | len--; | ||
136 | } | ||
137 | |||
138 | err: | ||
139 | return ret; | ||
140 | } | ||
141 | |||
142 | static int | ||
143 | ssbi_write_bytes(struct ssbi *ssbi, u16 addr, u8 *buf, int len) | ||
144 | { | ||
145 | int ret = 0; | ||
146 | |||
147 | if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { | ||
148 | u32 mode2 = ssbi_readl(ssbi, SSBI2_MODE2); | ||
149 | mode2 = SET_SSBI_MODE2_REG_ADDR_15_8(mode2, addr); | ||
150 | ssbi_writel(ssbi, mode2, SSBI2_MODE2); | ||
151 | } | ||
152 | |||
153 | while (len) { | ||
154 | ret = ssbi_wait_mask(ssbi, SSBI_STATUS_READY, 0); | ||
155 | if (ret) | ||
156 | goto err; | ||
157 | |||
158 | ssbi_writel(ssbi, ((addr & 0xff) << 16) | *buf, SSBI2_CMD); | ||
159 | ret = ssbi_wait_mask(ssbi, 0, SSBI_STATUS_MCHN_BUSY); | ||
160 | if (ret) | ||
161 | goto err; | ||
162 | buf++; | ||
163 | len--; | ||
164 | } | ||
165 | |||
166 | err: | ||
167 | return ret; | ||
168 | } | ||
169 | |||
170 | /* | ||
171 | * See ssbi_wait_mask for an explanation of the time and the | ||
172 | * busywait. | ||
173 | */ | ||
174 | static inline int | ||
175 | ssbi_pa_transfer(struct ssbi *ssbi, u32 cmd, u8 *data) | ||
176 | { | ||
177 | u32 timeout = SSBI_TIMEOUT_US; | ||
178 | u32 rd_status = 0; | ||
179 | |||
180 | ssbi_writel(ssbi, cmd, SSBI_PA_CMD); | ||
181 | |||
182 | while (timeout--) { | ||
183 | rd_status = ssbi_readl(ssbi, SSBI_PA_RD_STATUS); | ||
184 | |||
185 | if (rd_status & SSBI_PA_RD_STATUS_TRANS_DENIED) | ||
186 | return -EPERM; | ||
187 | |||
188 | if (rd_status & SSBI_PA_RD_STATUS_TRANS_DONE) { | ||
189 | if (data) | ||
190 | *data = rd_status & 0xff; | ||
191 | return 0; | ||
192 | } | ||
193 | udelay(1); | ||
194 | } | ||
195 | |||
196 | return -ETIMEDOUT; | ||
197 | } | ||
198 | |||
199 | static int | ||
200 | ssbi_pa_read_bytes(struct ssbi *ssbi, u16 addr, u8 *buf, int len) | ||
201 | { | ||
202 | u32 cmd; | ||
203 | int ret = 0; | ||
204 | |||
205 | cmd = SSBI_PA_CMD_RDWRN | (addr & SSBI_PA_CMD_ADDR_MASK) << 8; | ||
206 | |||
207 | while (len) { | ||
208 | ret = ssbi_pa_transfer(ssbi, cmd, buf); | ||
209 | if (ret) | ||
210 | goto err; | ||
211 | buf++; | ||
212 | len--; | ||
213 | } | ||
214 | |||
215 | err: | ||
216 | return ret; | ||
217 | } | ||
218 | |||
219 | static int | ||
220 | ssbi_pa_write_bytes(struct ssbi *ssbi, u16 addr, u8 *buf, int len) | ||
221 | { | ||
222 | u32 cmd; | ||
223 | int ret = 0; | ||
224 | |||
225 | while (len) { | ||
226 | cmd = (addr & SSBI_PA_CMD_ADDR_MASK) << 8 | *buf; | ||
227 | ret = ssbi_pa_transfer(ssbi, cmd, NULL); | ||
228 | if (ret) | ||
229 | goto err; | ||
230 | buf++; | ||
231 | len--; | ||
232 | } | ||
233 | |||
234 | err: | ||
235 | return ret; | ||
236 | } | ||
237 | |||
238 | int ssbi_read(struct device *dev, u16 addr, u8 *buf, int len) | ||
239 | { | ||
240 | struct ssbi *ssbi = to_ssbi(dev); | ||
241 | unsigned long flags; | ||
242 | int ret; | ||
243 | |||
244 | spin_lock_irqsave(&ssbi->lock, flags); | ||
245 | ret = ssbi->read(ssbi, addr, buf, len); | ||
246 | spin_unlock_irqrestore(&ssbi->lock, flags); | ||
247 | |||
248 | return ret; | ||
249 | } | ||
250 | EXPORT_SYMBOL_GPL(ssbi_read); | ||
251 | |||
252 | int ssbi_write(struct device *dev, u16 addr, u8 *buf, int len) | ||
253 | { | ||
254 | struct ssbi *ssbi = to_ssbi(dev); | ||
255 | unsigned long flags; | ||
256 | int ret; | ||
257 | |||
258 | spin_lock_irqsave(&ssbi->lock, flags); | ||
259 | ret = ssbi->write(ssbi, addr, buf, len); | ||
260 | spin_unlock_irqrestore(&ssbi->lock, flags); | ||
261 | |||
262 | return ret; | ||
263 | } | ||
264 | EXPORT_SYMBOL_GPL(ssbi_write); | ||
265 | |||
266 | static int ssbi_probe(struct platform_device *pdev) | ||
267 | { | ||
268 | struct device_node *np = pdev->dev.of_node; | ||
269 | struct resource *mem_res; | ||
270 | struct ssbi *ssbi; | ||
271 | int ret = 0; | ||
272 | const char *type; | ||
273 | |||
274 | ssbi = kzalloc(sizeof(struct ssbi), GFP_KERNEL); | ||
275 | if (!ssbi) { | ||
276 | pr_err("can not allocate ssbi_data\n"); | ||
277 | return -ENOMEM; | ||
278 | } | ||
279 | |||
280 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
281 | if (!mem_res) { | ||
282 | pr_err("missing mem resource\n"); | ||
283 | ret = -EINVAL; | ||
284 | goto err_get_mem_res; | ||
285 | } | ||
286 | |||
287 | ssbi->base = ioremap(mem_res->start, resource_size(mem_res)); | ||
288 | if (!ssbi->base) { | ||
289 | pr_err("ioremap of 0x%p failed\n", (void *)mem_res->start); | ||
290 | ret = -EINVAL; | ||
291 | goto err_ioremap; | ||
292 | } | ||
293 | platform_set_drvdata(pdev, ssbi); | ||
294 | |||
295 | type = of_get_property(np, "qcom,controller-type", NULL); | ||
296 | if (type == NULL) { | ||
297 | pr_err("Missing qcom,controller-type property\n"); | ||
298 | ret = -EINVAL; | ||
299 | goto err_ssbi_controller; | ||
300 | } | ||
301 | dev_info(&pdev->dev, "SSBI controller type: '%s'\n", type); | ||
302 | if (strcmp(type, "ssbi") == 0) | ||
303 | ssbi->controller_type = MSM_SBI_CTRL_SSBI; | ||
304 | else if (strcmp(type, "ssbi2") == 0) | ||
305 | ssbi->controller_type = MSM_SBI_CTRL_SSBI2; | ||
306 | else if (strcmp(type, "pmic-arbiter") == 0) | ||
307 | ssbi->controller_type = MSM_SBI_CTRL_PMIC_ARBITER; | ||
308 | else { | ||
309 | pr_err("Unknown qcom,controller-type\n"); | ||
310 | ret = -EINVAL; | ||
311 | goto err_ssbi_controller; | ||
312 | } | ||
313 | |||
314 | if (ssbi->controller_type == MSM_SBI_CTRL_PMIC_ARBITER) { | ||
315 | ssbi->read = ssbi_pa_read_bytes; | ||
316 | ssbi->write = ssbi_pa_write_bytes; | ||
317 | } else { | ||
318 | ssbi->read = ssbi_read_bytes; | ||
319 | ssbi->write = ssbi_write_bytes; | ||
320 | } | ||
321 | |||
322 | spin_lock_init(&ssbi->lock); | ||
323 | |||
324 | ret = of_platform_populate(np, NULL, NULL, &pdev->dev); | ||
325 | if (ret) | ||
326 | goto err_ssbi_controller; | ||
327 | |||
328 | return 0; | ||
329 | |||
330 | err_ssbi_controller: | ||
331 | platform_set_drvdata(pdev, NULL); | ||
332 | iounmap(ssbi->base); | ||
333 | err_ioremap: | ||
334 | err_get_mem_res: | ||
335 | kfree(ssbi); | ||
336 | return ret; | ||
337 | } | ||
338 | |||
339 | static int ssbi_remove(struct platform_device *pdev) | ||
340 | { | ||
341 | struct ssbi *ssbi = platform_get_drvdata(pdev); | ||
342 | |||
343 | platform_set_drvdata(pdev, NULL); | ||
344 | iounmap(ssbi->base); | ||
345 | kfree(ssbi); | ||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | static struct of_device_id ssbi_match_table[] = { | ||
350 | { .compatible = "qcom,ssbi" }, | ||
351 | {} | ||
352 | }; | ||
353 | |||
354 | static struct platform_driver ssbi_driver = { | ||
355 | .probe = ssbi_probe, | ||
356 | .remove = ssbi_remove, | ||
357 | .driver = { | ||
358 | .name = "ssbi", | ||
359 | .owner = THIS_MODULE, | ||
360 | .of_match_table = ssbi_match_table, | ||
361 | }, | ||
362 | }; | ||
363 | |||
364 | static int __init ssbi_init(void) | ||
365 | { | ||
366 | return platform_driver_register(&ssbi_driver); | ||
367 | } | ||
368 | module_init(ssbi_init); | ||
369 | |||
370 | static void __exit ssbi_exit(void) | ||
371 | { | ||
372 | platform_driver_unregister(&ssbi_driver); | ||
373 | } | ||
374 | module_exit(ssbi_exit) | ||
375 | |||
376 | MODULE_LICENSE("GPL v2"); | ||
377 | MODULE_VERSION("1.0"); | ||
378 | MODULE_ALIAS("platform:ssbi"); | ||
379 | MODULE_AUTHOR("Dima Zavin <dima@android.com>"); | ||
diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c index b7d48b346393..1b74b88e1e1e 100644 --- a/drivers/tty/serial/8250/serial_cs.c +++ b/drivers/tty/serial/8250/serial_cs.c | |||
@@ -852,18 +852,6 @@ static struct pcmcia_driver serial_cs_driver = { | |||
852 | .suspend = serial_suspend, | 852 | .suspend = serial_suspend, |
853 | .resume = serial_resume, | 853 | .resume = serial_resume, |
854 | }; | 854 | }; |
855 | 855 | module_pcmcia_driver(serial_cs_driver); | |
856 | static int __init init_serial_cs(void) | ||
857 | { | ||
858 | return pcmcia_register_driver(&serial_cs_driver); | ||
859 | } | ||
860 | |||
861 | static void __exit exit_serial_cs(void) | ||
862 | { | ||
863 | pcmcia_unregister_driver(&serial_cs_driver); | ||
864 | } | ||
865 | |||
866 | module_init(init_serial_cs); | ||
867 | module_exit(exit_serial_cs); | ||
868 | 856 | ||
869 | MODULE_LICENSE("GPL"); | 857 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index c8b926291e28..b645c47501b4 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -374,6 +374,7 @@ static int uio_get_minor(struct uio_device *idev) | |||
374 | retval = idr_alloc(&uio_idr, idev, 0, UIO_MAX_DEVICES, GFP_KERNEL); | 374 | retval = idr_alloc(&uio_idr, idev, 0, UIO_MAX_DEVICES, GFP_KERNEL); |
375 | if (retval >= 0) { | 375 | if (retval >= 0) { |
376 | idev->minor = retval; | 376 | idev->minor = retval; |
377 | retval = 0; | ||
377 | } else if (retval == -ENOSPC) { | 378 | } else if (retval == -ENOSPC) { |
378 | dev_err(idev->dev, "too many uio devices\n"); | 379 | dev_err(idev->dev, "too many uio devices\n"); |
379 | retval = -EINVAL; | 380 | retval = -EINVAL; |
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 3b6f50eaec91..469564e57a52 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c | |||
@@ -200,17 +200,4 @@ static struct pcmcia_driver sl811_cs_driver = { | |||
200 | .remove = sl811_cs_detach, | 200 | .remove = sl811_cs_detach, |
201 | .id_table = sl811_ids, | 201 | .id_table = sl811_ids, |
202 | }; | 202 | }; |
203 | 203 | module_pcmcia_driver(sl811_cs_driver); | |
204 | /*====================================================================*/ | ||
205 | |||
206 | static int __init init_sl811_cs(void) | ||
207 | { | ||
208 | return pcmcia_register_driver(&sl811_cs_driver); | ||
209 | } | ||
210 | module_init(init_sl811_cs); | ||
211 | |||
212 | static void __exit exit_sl811_cs(void) | ||
213 | { | ||
214 | pcmcia_unregister_driver(&sl811_cs_driver); | ||
215 | } | ||
216 | module_exit(exit_sl811_cs); | ||
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c index 950d354d50e2..47e12cfc2a57 100644 --- a/drivers/w1/masters/mxc_w1.c +++ b/drivers/w1/masters/mxc_w1.c | |||
@@ -121,9 +121,9 @@ static int mxc_w1_probe(struct platform_device *pdev) | |||
121 | mdev->clkdiv = (clk_get_rate(mdev->clk) / 1000000) - 1; | 121 | mdev->clkdiv = (clk_get_rate(mdev->clk) / 1000000) - 1; |
122 | 122 | ||
123 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 123 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
124 | mdev->regs = devm_request_and_ioremap(&pdev->dev, res); | 124 | mdev->regs = devm_ioremap_resource(&pdev->dev, res); |
125 | if (!mdev->regs) | 125 | if (IS_ERR(mdev->regs)) |
126 | return -EBUSY; | 126 | return PTR_ERR(mdev->regs); |
127 | 127 | ||
128 | clk_prepare_enable(mdev->clk); | 128 | clk_prepare_enable(mdev->clk); |
129 | __raw_writeb(mdev->clkdiv, mdev->regs + MXC_W1_TIME_DIVIDER); | 129 | __raw_writeb(mdev->clkdiv, mdev->regs + MXC_W1_TIME_DIVIDER); |
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig index 762561fbabbf..5e6a3c9e510b 100644 --- a/drivers/w1/slaves/Kconfig +++ b/drivers/w1/slaves/Kconfig | |||
@@ -22,6 +22,16 @@ config W1_SLAVE_DS2408 | |||
22 | Say Y here if you want to use a 1-wire | 22 | Say Y here if you want to use a 1-wire |
23 | DS2408 8-Channel Addressable Switch device support | 23 | DS2408 8-Channel Addressable Switch device support |
24 | 24 | ||
25 | config W1_SLAVE_DS2408_READBACK | ||
26 | bool "Read-back values written to DS2408's output register" | ||
27 | depends on W1_SLAVE_DS2408 | ||
28 | default y | ||
29 | help | ||
30 | Enabling this will cause the driver to read back the values written | ||
31 | to the chip's output register in order to detect errors. | ||
32 | |||
33 | This is slower but useful when debugging chips and/or busses. | ||
34 | |||
25 | config W1_SLAVE_DS2413 | 35 | config W1_SLAVE_DS2413 |
26 | tristate "Dual Channel Addressable Switch 0x3a family support (DS2413)" | 36 | tristate "Dual Channel Addressable Switch 0x3a family support (DS2413)" |
27 | help | 37 | help |
diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c index 441ad3a3b586..e45eca1044bd 100644 --- a/drivers/w1/slaves/w1_ds2408.c +++ b/drivers/w1/slaves/w1_ds2408.c | |||
@@ -178,6 +178,15 @@ static ssize_t w1_f29_write_output( | |||
178 | w1_write_block(sl->master, w1_buf, 3); | 178 | w1_write_block(sl->master, w1_buf, 3); |
179 | 179 | ||
180 | readBack = w1_read_8(sl->master); | 180 | readBack = w1_read_8(sl->master); |
181 | |||
182 | if (readBack != W1_F29_SUCCESS_CONFIRM_BYTE) { | ||
183 | if (w1_reset_resume_command(sl->master)) | ||
184 | goto error; | ||
185 | /* try again, the slave is ready for a command */ | ||
186 | continue; | ||
187 | } | ||
188 | |||
189 | #ifdef CONFIG_W1_SLAVE_DS2408_READBACK | ||
181 | /* here the master could read another byte which | 190 | /* here the master could read another byte which |
182 | would be the PIO reg (the actual pin logic state) | 191 | would be the PIO reg (the actual pin logic state) |
183 | since in this driver we don't know which pins are | 192 | since in this driver we don't know which pins are |
@@ -186,11 +195,6 @@ static ssize_t w1_f29_write_output( | |||
186 | if (w1_reset_resume_command(sl->master)) | 195 | if (w1_reset_resume_command(sl->master)) |
187 | goto error; | 196 | goto error; |
188 | 197 | ||
189 | if (readBack != 0xAA) { | ||
190 | /* try again, the slave is ready for a command */ | ||
191 | continue; | ||
192 | } | ||
193 | |||
194 | /* go read back the output latches */ | 198 | /* go read back the output latches */ |
195 | /* (the direct effect of the write above) */ | 199 | /* (the direct effect of the write above) */ |
196 | w1_buf[0] = W1_F29_FUNC_READ_PIO_REGS; | 200 | w1_buf[0] = W1_F29_FUNC_READ_PIO_REGS; |
@@ -198,7 +202,9 @@ static ssize_t w1_f29_write_output( | |||
198 | w1_buf[2] = 0; | 202 | w1_buf[2] = 0; |
199 | w1_write_block(sl->master, w1_buf, 3); | 203 | w1_write_block(sl->master, w1_buf, 3); |
200 | /* read the result of the READ_PIO_REGS command */ | 204 | /* read the result of the READ_PIO_REGS command */ |
201 | if (w1_read_8(sl->master) == *buf) { | 205 | if (w1_read_8(sl->master) == *buf) |
206 | #endif | ||
207 | { | ||
202 | /* success! */ | 208 | /* success! */ |
203 | mutex_unlock(&sl->master->bus_mutex); | 209 | mutex_unlock(&sl->master->bus_mutex); |
204 | dev_dbg(&sl->dev, | 210 | dev_dbg(&sl->dev, |
@@ -297,8 +303,7 @@ error: | |||
297 | 303 | ||
298 | 304 | ||
299 | 305 | ||
300 | #define NB_SYSFS_BIN_FILES 6 | 306 | static struct bin_attribute w1_f29_sysfs_bin_files[] = { |
301 | static struct bin_attribute w1_f29_sysfs_bin_files[NB_SYSFS_BIN_FILES] = { | ||
302 | { | 307 | { |
303 | .attr = { | 308 | .attr = { |
304 | .name = "state", | 309 | .name = "state", |
@@ -357,7 +362,7 @@ static int w1_f29_add_slave(struct w1_slave *sl) | |||
357 | int err = 0; | 362 | int err = 0; |
358 | int i; | 363 | int i; |
359 | 364 | ||
360 | for (i = 0; i < NB_SYSFS_BIN_FILES && !err; ++i) | 365 | for (i = 0; i < ARRAY_SIZE(w1_f29_sysfs_bin_files) && !err; ++i) |
361 | err = sysfs_create_bin_file( | 366 | err = sysfs_create_bin_file( |
362 | &sl->dev.kobj, | 367 | &sl->dev.kobj, |
363 | &(w1_f29_sysfs_bin_files[i])); | 368 | &(w1_f29_sysfs_bin_files[i])); |
@@ -371,7 +376,7 @@ static int w1_f29_add_slave(struct w1_slave *sl) | |||
371 | static void w1_f29_remove_slave(struct w1_slave *sl) | 376 | static void w1_f29_remove_slave(struct w1_slave *sl) |
372 | { | 377 | { |
373 | int i; | 378 | int i; |
374 | for (i = NB_SYSFS_BIN_FILES - 1; i >= 0; --i) | 379 | for (i = ARRAY_SIZE(w1_f29_sysfs_bin_files) - 1; i >= 0; --i) |
375 | sysfs_remove_bin_file(&sl->dev.kobj, | 380 | sysfs_remove_bin_file(&sl->dev.kobj, |
376 | &(w1_f29_sysfs_bin_files[i])); | 381 | &(w1_f29_sysfs_bin_files[i])); |
377 | } | 382 | } |
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index df77ba9a8166..95d0850584da 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h | |||
@@ -27,6 +27,63 @@ | |||
27 | 27 | ||
28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
29 | 29 | ||
30 | |||
31 | /* | ||
32 | * Implementation of host controlled snapshot of the guest. | ||
33 | */ | ||
34 | |||
35 | #define VSS_OP_REGISTER 128 | ||
36 | |||
37 | enum hv_vss_op { | ||
38 | VSS_OP_CREATE = 0, | ||
39 | VSS_OP_DELETE, | ||
40 | VSS_OP_HOT_BACKUP, | ||
41 | VSS_OP_GET_DM_INFO, | ||
42 | VSS_OP_BU_COMPLETE, | ||
43 | /* | ||
44 | * Following operations are only supported with IC version >= 5.0 | ||
45 | */ | ||
46 | VSS_OP_FREEZE, /* Freeze the file systems in the VM */ | ||
47 | VSS_OP_THAW, /* Unfreeze the file systems */ | ||
48 | VSS_OP_AUTO_RECOVER, | ||
49 | VSS_OP_COUNT /* Number of operations, must be last */ | ||
50 | }; | ||
51 | |||
52 | |||
53 | /* | ||
54 | * Header for all VSS messages. | ||
55 | */ | ||
56 | struct hv_vss_hdr { | ||
57 | __u8 operation; | ||
58 | __u8 reserved[7]; | ||
59 | } __attribute__((packed)); | ||
60 | |||
61 | |||
62 | /* | ||
63 | * Flag values for the hv_vss_check_feature. Linux supports only | ||
64 | * one value. | ||
65 | */ | ||
66 | #define VSS_HBU_NO_AUTO_RECOVERY 0x00000005 | ||
67 | |||
68 | struct hv_vss_check_feature { | ||
69 | __u32 flags; | ||
70 | } __attribute__((packed)); | ||
71 | |||
72 | struct hv_vss_check_dm_info { | ||
73 | __u32 flags; | ||
74 | } __attribute__((packed)); | ||
75 | |||
76 | struct hv_vss_msg { | ||
77 | union { | ||
78 | struct hv_vss_hdr vss_hdr; | ||
79 | int error; | ||
80 | }; | ||
81 | union { | ||
82 | struct hv_vss_check_feature vss_cf; | ||
83 | struct hv_vss_check_dm_info dm_info; | ||
84 | }; | ||
85 | } __attribute__((packed)); | ||
86 | |||
30 | /* | 87 | /* |
31 | * An implementation of HyperV key value pair (KVP) functionality for Linux. | 88 | * An implementation of HyperV key value pair (KVP) functionality for Linux. |
32 | * | 89 | * |
@@ -1253,6 +1310,14 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver); | |||
1253 | } | 1310 | } |
1254 | 1311 | ||
1255 | /* | 1312 | /* |
1313 | * VSS (Backup/Restore) GUID | ||
1314 | */ | ||
1315 | #define HV_VSS_GUID \ | ||
1316 | .guid = { \ | ||
1317 | 0x29, 0x2e, 0xfa, 0x35, 0x23, 0xea, 0x36, 0x42, \ | ||
1318 | 0x96, 0xae, 0x3a, 0x6e, 0xba, 0xcb, 0xa4, 0x40 \ | ||
1319 | } | ||
1320 | /* | ||
1256 | * Common header for Hyper-V ICs | 1321 | * Common header for Hyper-V ICs |
1257 | */ | 1322 | */ |
1258 | 1323 | ||
@@ -1356,6 +1421,10 @@ int hv_kvp_init(struct hv_util_service *); | |||
1356 | void hv_kvp_deinit(void); | 1421 | void hv_kvp_deinit(void); |
1357 | void hv_kvp_onchannelcallback(void *); | 1422 | void hv_kvp_onchannelcallback(void *); |
1358 | 1423 | ||
1424 | int hv_vss_init(struct hv_util_service *); | ||
1425 | void hv_vss_deinit(void); | ||
1426 | void hv_vss_onchannelcallback(void *); | ||
1427 | |||
1359 | /* | 1428 | /* |
1360 | * Negotiated version with the Host. | 1429 | * Negotiated version with the Host. |
1361 | */ | 1430 | */ |
diff --git a/include/linux/ipack.h b/include/linux/ipack.h index fea12cbb2aeb..1888e06ddf64 100644 --- a/include/linux/ipack.h +++ b/include/linux/ipack.h | |||
@@ -207,19 +207,41 @@ int ipack_driver_register(struct ipack_driver *edrv, struct module *owner, | |||
207 | void ipack_driver_unregister(struct ipack_driver *edrv); | 207 | void ipack_driver_unregister(struct ipack_driver *edrv); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * ipack_device_register -- register an IPack device with the kernel | 210 | * ipack_device_init -- initialize an IPack device |
211 | * @dev: the new device to register. | 211 | * @dev: the new device to initialize. |
212 | * | 212 | * |
213 | * Register a new IPack device ("module" in IndustryPack jargon). The call | 213 | * Initialize a new IPack device ("module" in IndustryPack jargon). The call |
214 | * is done by the carrier driver. The carrier should populate the fields | 214 | * is done by the carrier driver. The carrier should populate the fields |
215 | * bus and slot as well as the region array of @dev prior to calling this | 215 | * bus and slot as well as the region array of @dev prior to calling this |
216 | * function. The rest of the fields will be allocated and populated | 216 | * function. The rest of the fields will be allocated and populated |
217 | * during registration. | 217 | * during initalization. |
218 | * | 218 | * |
219 | * Return zero on success or error code on failure. | 219 | * Return zero on success or error code on failure. |
220 | * | ||
221 | * NOTE: _Never_ directly free @dev after calling this function, even | ||
222 | * if it returned an error! Always use ipack_put_device() to give up the | ||
223 | * reference initialized in this function instead. | ||
224 | */ | ||
225 | int ipack_device_init(struct ipack_device *dev); | ||
226 | |||
227 | /** | ||
228 | * ipack_device_add -- Add an IPack device | ||
229 | * @dev: the new device to add. | ||
230 | * | ||
231 | * Add a new IPack device. The call is done by the carrier driver | ||
232 | * after calling ipack_device_init(). | ||
233 | * | ||
234 | * Return zero on success or error code on failure. | ||
235 | * | ||
236 | * NOTE: _Never_ directly free @dev after calling this function, even | ||
237 | * if it returned an error! Always use ipack_put_device() to give up the | ||
238 | * reference initialized in this function instead. | ||
220 | */ | 239 | */ |
221 | int ipack_device_register(struct ipack_device *dev); | 240 | int ipack_device_add(struct ipack_device *dev); |
222 | void ipack_device_unregister(struct ipack_device *dev); | 241 | void ipack_device_del(struct ipack_device *dev); |
242 | |||
243 | void ipack_get_device(struct ipack_device *dev); | ||
244 | void ipack_put_device(struct ipack_device *dev); | ||
223 | 245 | ||
224 | /** | 246 | /** |
225 | * DEFINE_IPACK_DEVICE_TABLE - macro used to describe a IndustryPack table | 247 | * DEFINE_IPACK_DEVICE_TABLE - macro used to describe a IndustryPack table |
diff --git a/include/linux/mei_cl_bus.h b/include/linux/mei_cl_bus.h new file mode 100644 index 000000000000..1bece18825ba --- /dev/null +++ b/include/linux/mei_cl_bus.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef _LINUX_MEI_CL_BUS_H | ||
2 | #define _LINUX_MEI_CL_BUS_H | ||
3 | |||
4 | #include <linux/device.h> | ||
5 | #include <linux/uuid.h> | ||
6 | |||
7 | struct mei_cl_device; | ||
8 | |||
9 | struct mei_cl_driver { | ||
10 | struct device_driver driver; | ||
11 | const char *name; | ||
12 | |||
13 | const struct mei_cl_device_id *id_table; | ||
14 | |||
15 | int (*probe)(struct mei_cl_device *dev, | ||
16 | const struct mei_cl_device_id *id); | ||
17 | int (*remove)(struct mei_cl_device *dev); | ||
18 | }; | ||
19 | |||
20 | int __mei_cl_driver_register(struct mei_cl_driver *driver, | ||
21 | struct module *owner); | ||
22 | #define mei_cl_driver_register(driver) \ | ||
23 | __mei_cl_driver_register(driver, THIS_MODULE) | ||
24 | |||
25 | void mei_cl_driver_unregister(struct mei_cl_driver *driver); | ||
26 | |||
27 | int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length); | ||
28 | int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length); | ||
29 | |||
30 | typedef void (*mei_cl_event_cb_t)(struct mei_cl_device *device, | ||
31 | u32 events, void *context); | ||
32 | int mei_cl_register_event_cb(struct mei_cl_device *device, | ||
33 | mei_cl_event_cb_t read_cb, void *context); | ||
34 | |||
35 | #define MEI_CL_EVENT_RX 0 | ||
36 | #define MEI_CL_EVENT_TX 1 | ||
37 | |||
38 | void *mei_cl_get_drvdata(const struct mei_cl_device *device); | ||
39 | void mei_cl_set_drvdata(struct mei_cl_device *device, void *data); | ||
40 | |||
41 | #endif /* _LINUX_MEI_CL_BUS_H */ | ||
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h index a710255528d7..cc281368dc55 100644 --- a/include/linux/mfd/arizona/core.h +++ b/include/linux/mfd/arizona/core.h | |||
@@ -100,6 +100,9 @@ struct arizona { | |||
100 | struct regmap_irq_chip_data *aod_irq_chip; | 100 | struct regmap_irq_chip_data *aod_irq_chip; |
101 | struct regmap_irq_chip_data *irq_chip; | 101 | struct regmap_irq_chip_data *irq_chip; |
102 | 102 | ||
103 | bool hpdet_magic; | ||
104 | unsigned int hp_ena; | ||
105 | |||
103 | struct mutex clk_lock; | 106 | struct mutex clk_lock; |
104 | int clk32k_ref; | 107 | int clk32k_ref; |
105 | 108 | ||
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h index 455c51d22d6b..a0f940987a3e 100644 --- a/include/linux/mfd/arizona/pdata.h +++ b/include/linux/mfd/arizona/pdata.h | |||
@@ -86,6 +86,11 @@ struct arizona_micd_config { | |||
86 | bool gpio; | 86 | bool gpio; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | struct arizona_micd_range { | ||
90 | int max; /** Ohms */ | ||
91 | int key; /** Key to report to input layer */ | ||
92 | }; | ||
93 | |||
89 | struct arizona_pdata { | 94 | struct arizona_pdata { |
90 | int reset; /** GPIO controlling /RESET, if any */ | 95 | int reset; /** GPIO controlling /RESET, if any */ |
91 | int ldoena; /** GPIO controlling LODENA, if any */ | 96 | int ldoena; /** GPIO controlling LODENA, if any */ |
@@ -117,12 +122,21 @@ struct arizona_pdata { | |||
117 | /** GPIO5 is used for jack detection */ | 122 | /** GPIO5 is used for jack detection */ |
118 | bool jd_gpio5; | 123 | bool jd_gpio5; |
119 | 124 | ||
125 | /** Internal pull on GPIO5 is disabled when used for jack detection */ | ||
126 | bool jd_gpio5_nopull; | ||
127 | |||
120 | /** Use the headphone detect circuit to identify the accessory */ | 128 | /** Use the headphone detect circuit to identify the accessory */ |
121 | bool hpdet_acc_id; | 129 | bool hpdet_acc_id; |
122 | 130 | ||
131 | /** Check for line output with HPDET method */ | ||
132 | bool hpdet_acc_id_line; | ||
133 | |||
123 | /** GPIO used for mic isolation with HPDET */ | 134 | /** GPIO used for mic isolation with HPDET */ |
124 | int hpdet_id_gpio; | 135 | int hpdet_id_gpio; |
125 | 136 | ||
137 | /** Extra debounce timeout used during initial mic detection (ms) */ | ||
138 | int micd_detect_debounce; | ||
139 | |||
126 | /** GPIO for mic detection polarity */ | 140 | /** GPIO for mic detection polarity */ |
127 | int micd_pol_gpio; | 141 | int micd_pol_gpio; |
128 | 142 | ||
@@ -135,9 +149,16 @@ struct arizona_pdata { | |||
135 | /** Mic detect debounce level */ | 149 | /** Mic detect debounce level */ |
136 | int micd_dbtime; | 150 | int micd_dbtime; |
137 | 151 | ||
152 | /** Mic detect timeout (ms) */ | ||
153 | int micd_timeout; | ||
154 | |||
138 | /** Force MICBIAS on for mic detect */ | 155 | /** Force MICBIAS on for mic detect */ |
139 | bool micd_force_micbias; | 156 | bool micd_force_micbias; |
140 | 157 | ||
158 | /** Mic detect level parameters */ | ||
159 | const struct arizona_micd_range *micd_ranges; | ||
160 | int num_micd_ranges; | ||
161 | |||
141 | /** Headset polarity configurations */ | 162 | /** Headset polarity configurations */ |
142 | struct arizona_micd_config *micd_configs; | 163 | struct arizona_micd_config *micd_configs; |
143 | int num_micd_configs; | 164 | int num_micd_configs; |
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h index 340355136069..f43aa7c8d040 100644 --- a/include/linux/mfd/arizona/registers.h +++ b/include/linux/mfd/arizona/registers.h | |||
@@ -124,6 +124,10 @@ | |||
124 | #define ARIZONA_MIC_DETECT_1 0x2A3 | 124 | #define ARIZONA_MIC_DETECT_1 0x2A3 |
125 | #define ARIZONA_MIC_DETECT_2 0x2A4 | 125 | #define ARIZONA_MIC_DETECT_2 0x2A4 |
126 | #define ARIZONA_MIC_DETECT_3 0x2A5 | 126 | #define ARIZONA_MIC_DETECT_3 0x2A5 |
127 | #define ARIZONA_MIC_DETECT_LEVEL_1 0x2A6 | ||
128 | #define ARIZONA_MIC_DETECT_LEVEL_2 0x2A7 | ||
129 | #define ARIZONA_MIC_DETECT_LEVEL_3 0x2A8 | ||
130 | #define ARIZONA_MIC_DETECT_LEVEL_4 0x2A9 | ||
127 | #define ARIZONA_MIC_NOISE_MIX_CONTROL_1 0x2C3 | 131 | #define ARIZONA_MIC_NOISE_MIX_CONTROL_1 0x2C3 |
128 | #define ARIZONA_ISOLATION_CONTROL 0x2CB | 132 | #define ARIZONA_ISOLATION_CONTROL 0x2CB |
129 | #define ARIZONA_JACK_DETECT_ANALOGUE 0x2D3 | 133 | #define ARIZONA_JACK_DETECT_ANALOGUE 0x2D3 |
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 779cf7c4a3d1..b508016fb76d 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #ifdef __KERNEL__ | 10 | #ifdef __KERNEL__ |
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <linux/uuid.h> | ||
12 | typedef unsigned long kernel_ulong_t; | 13 | typedef unsigned long kernel_ulong_t; |
13 | #endif | 14 | #endif |
14 | 15 | ||
@@ -568,4 +569,12 @@ struct ipack_device_id { | |||
568 | __u32 device; /* Device ID or IPACK_ANY_ID */ | 569 | __u32 device; /* Device ID or IPACK_ANY_ID */ |
569 | }; | 570 | }; |
570 | 571 | ||
572 | #define MEI_CL_MODULE_PREFIX "mei:" | ||
573 | #define MEI_CL_NAME_SIZE 32 | ||
574 | |||
575 | struct mei_cl_device_id { | ||
576 | char name[MEI_CL_NAME_SIZE]; | ||
577 | kernel_ulong_t driver_info; | ||
578 | }; | ||
579 | |||
571 | #endif /* LINUX_MOD_DEVICETABLE_H */ | 580 | #endif /* LINUX_MOD_DEVICETABLE_H */ |
diff --git a/include/linux/platform_data/emif_plat.h b/include/linux/platform_data/emif_plat.h index 03378ca84061..5c19a2a647c4 100644 --- a/include/linux/platform_data/emif_plat.h +++ b/include/linux/platform_data/emif_plat.h | |||
@@ -40,6 +40,7 @@ | |||
40 | /* Custom config requests */ | 40 | /* Custom config requests */ |
41 | #define EMIF_CUSTOM_CONFIG_LPMODE 0x00000001 | 41 | #define EMIF_CUSTOM_CONFIG_LPMODE 0x00000001 |
42 | #define EMIF_CUSTOM_CONFIG_TEMP_ALERT_POLL_INTERVAL 0x00000002 | 42 | #define EMIF_CUSTOM_CONFIG_TEMP_ALERT_POLL_INTERVAL 0x00000002 |
43 | #define EMIF_CUSTOM_CONFIG_EXTENDED_TEMP_PART 0x00000004 | ||
43 | 44 | ||
44 | #ifndef __ASSEMBLY__ | 45 | #ifndef __ASSEMBLY__ |
45 | /** | 46 | /** |
diff --git a/include/linux/ssbi.h b/include/linux/ssbi.h new file mode 100644 index 000000000000..44ef5da21470 --- /dev/null +++ b/include/linux/ssbi.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* Copyright (C) 2010 Google, Inc. | ||
2 | * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | ||
3 | * Author: Dima Zavin <dima@android.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 and | ||
7 | * only version 2 as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #ifndef _LINUX_SSBI_H | ||
16 | #define _LINUX_SSBI_H | ||
17 | |||
18 | #include <linux/types.h> | ||
19 | |||
20 | struct ssbi_slave_info { | ||
21 | const char *name; | ||
22 | void *platform_data; | ||
23 | }; | ||
24 | |||
25 | enum ssbi_controller_type { | ||
26 | MSM_SBI_CTRL_SSBI = 0, | ||
27 | MSM_SBI_CTRL_SSBI2, | ||
28 | MSM_SBI_CTRL_PMIC_ARBITER, | ||
29 | }; | ||
30 | |||
31 | struct ssbi_platform_data { | ||
32 | struct ssbi_slave_info slave; | ||
33 | enum ssbi_controller_type controller_type; | ||
34 | }; | ||
35 | |||
36 | int ssbi_write(struct device *dev, u16 addr, u8 *buf, int len); | ||
37 | int ssbi_read(struct device *dev, u16 addr, u8 *buf, int len); | ||
38 | #endif | ||
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 3bbbd78e1439..2d56e428506c 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h | |||
@@ -65,6 +65,18 @@ struct pcmcia_driver { | |||
65 | int pcmcia_register_driver(struct pcmcia_driver *driver); | 65 | int pcmcia_register_driver(struct pcmcia_driver *driver); |
66 | void pcmcia_unregister_driver(struct pcmcia_driver *driver); | 66 | void pcmcia_unregister_driver(struct pcmcia_driver *driver); |
67 | 67 | ||
68 | /** | ||
69 | * module_pcmcia_driver() - Helper macro for registering a pcmcia driver | ||
70 | * @__pcmcia_driver: pcmcia_driver struct | ||
71 | * | ||
72 | * Helper macro for pcmcia drivers which do not do anything special in module | ||
73 | * init/exit. This eliminates a lot of boilerplate. Each module may only use | ||
74 | * this macro once, and calling it replaces module_init() and module_exit(). | ||
75 | */ | ||
76 | #define module_pcmcia_driver(__pcmcia_driver) \ | ||
77 | module_driver(__pcmcia_driver, pcmcia_register_driver, \ | ||
78 | pcmcia_unregister_driver) | ||
79 | |||
68 | /* for struct resource * array embedded in struct pcmcia_device */ | 80 | /* for struct resource * array embedded in struct pcmcia_device */ |
69 | enum { | 81 | enum { |
70 | PCMCIA_IOPORT_0, | 82 | PCMCIA_IOPORT_0, |
diff --git a/include/uapi/linux/connector.h b/include/uapi/linux/connector.h index 8761a0349c74..4cb283505e45 100644 --- a/include/uapi/linux/connector.h +++ b/include/uapi/linux/connector.h | |||
@@ -44,8 +44,11 @@ | |||
44 | #define CN_VAL_DRBD 0x1 | 44 | #define CN_VAL_DRBD 0x1 |
45 | #define CN_KVP_IDX 0x9 /* HyperV KVP */ | 45 | #define CN_KVP_IDX 0x9 /* HyperV KVP */ |
46 | #define CN_KVP_VAL 0x1 /* queries from the kernel */ | 46 | #define CN_KVP_VAL 0x1 /* queries from the kernel */ |
47 | #define CN_VSS_IDX 0xA /* HyperV VSS */ | ||
48 | #define CN_VSS_VAL 0x1 /* queries from the kernel */ | ||
47 | 49 | ||
48 | #define CN_NETLINK_USERS 10 /* Highest index + 1 */ | 50 | |
51 | #define CN_NETLINK_USERS 11 /* Highest index + 1 */ | ||
49 | 52 | ||
50 | /* | 53 | /* |
51 | * Maximum connector's message size. | 54 | * Maximum connector's message size. |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8fcced7823fa..7ff1536f01b8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1397,6 +1397,7 @@ void split_page(struct page *page, unsigned int order) | |||
1397 | for (i = 1; i < (1 << order); i++) | 1397 | for (i = 1; i < (1 << order); i++) |
1398 | set_page_refcounted(page + i); | 1398 | set_page_refcounted(page + i); |
1399 | } | 1399 | } |
1400 | EXPORT_SYMBOL_GPL(split_page); | ||
1400 | 1401 | ||
1401 | static int __isolate_free_page(struct page *page, unsigned int order) | 1402 | static int __isolate_free_page(struct page *page, unsigned int order) |
1402 | { | 1403 | { |
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index b45260bfeaa0..e66d4d258e1a 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c | |||
@@ -174,5 +174,8 @@ int main(void) | |||
174 | DEVID_FIELD(x86_cpu_id, model); | 174 | DEVID_FIELD(x86_cpu_id, model); |
175 | DEVID_FIELD(x86_cpu_id, vendor); | 175 | DEVID_FIELD(x86_cpu_id, vendor); |
176 | 176 | ||
177 | DEVID(mei_cl_device_id); | ||
178 | DEVID_FIELD(mei_cl_device_id, name); | ||
179 | |||
177 | return 0; | 180 | return 0; |
178 | } | 181 | } |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 771ac17f635d..45f9a3377dcd 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -1133,6 +1133,18 @@ static int do_x86cpu_entry(const char *filename, void *symval, | |||
1133 | } | 1133 | } |
1134 | ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); | 1134 | ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); |
1135 | 1135 | ||
1136 | /* Looks like: mei:S */ | ||
1137 | static int do_mei_entry(const char *filename, void *symval, | ||
1138 | char *alias) | ||
1139 | { | ||
1140 | DEF_FIELD_ADDR(symval, mei_cl_device_id, name); | ||
1141 | |||
1142 | sprintf(alias, MEI_CL_MODULE_PREFIX "%s", *name); | ||
1143 | |||
1144 | return 1; | ||
1145 | } | ||
1146 | ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); | ||
1147 | |||
1136 | /* Does namelen bytes of name exactly match the symbol? */ | 1148 | /* Does namelen bytes of name exactly match the symbol? */ |
1137 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) | 1149 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) |
1138 | { | 1150 | { |
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index f9b5229b2723..8f489de5c4c6 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c | |||
@@ -295,18 +295,5 @@ static struct pcmcia_driver pdacf_cs_driver = { | |||
295 | .suspend = pdacf_suspend, | 295 | .suspend = pdacf_suspend, |
296 | .resume = pdacf_resume, | 296 | .resume = pdacf_resume, |
297 | #endif | 297 | #endif |
298 | |||
299 | }; | 298 | }; |
300 | 299 | module_pcmcia_driver(pdacf_cs_driver); | |
301 | static int __init init_pdacf(void) | ||
302 | { | ||
303 | return pcmcia_register_driver(&pdacf_cs_driver); | ||
304 | } | ||
305 | |||
306 | static void __exit exit_pdacf(void) | ||
307 | { | ||
308 | pcmcia_unregister_driver(&pdacf_cs_driver); | ||
309 | } | ||
310 | |||
311 | module_init(init_pdacf); | ||
312 | module_exit(exit_pdacf); | ||
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 8f9350475c7b..d4db7ecaa6bf 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c | |||
@@ -367,16 +367,4 @@ static struct pcmcia_driver vxp_cs_driver = { | |||
367 | .resume = vxp_resume, | 367 | .resume = vxp_resume, |
368 | #endif | 368 | #endif |
369 | }; | 369 | }; |
370 | 370 | module_pcmcia_driver(vxp_cs_driver); | |
371 | static int __init init_vxpocket(void) | ||
372 | { | ||
373 | return pcmcia_register_driver(&vxp_cs_driver); | ||
374 | } | ||
375 | |||
376 | static void __exit exit_vxpocket(void) | ||
377 | { | ||
378 | pcmcia_unregister_driver(&vxp_cs_driver); | ||
379 | } | ||
380 | |||
381 | module_init(init_vxpocket); | ||
382 | module_exit(exit_vxpocket); | ||
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index ac948a671ea6..e7d34711412c 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c | |||
@@ -364,6 +364,39 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, | |||
364 | } | 364 | } |
365 | EXPORT_SYMBOL_GPL(arizona_out_ev); | 365 | EXPORT_SYMBOL_GPL(arizona_out_ev); |
366 | 366 | ||
367 | int arizona_hp_ev(struct snd_soc_dapm_widget *w, | ||
368 | struct snd_kcontrol *kcontrol, | ||
369 | int event) | ||
370 | { | ||
371 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); | ||
372 | unsigned int mask = 1 << w->shift; | ||
373 | unsigned int val; | ||
374 | |||
375 | switch (event) { | ||
376 | case SND_SOC_DAPM_POST_PMU: | ||
377 | val = mask; | ||
378 | break; | ||
379 | case SND_SOC_DAPM_PRE_PMD: | ||
380 | val = 0; | ||
381 | break; | ||
382 | default: | ||
383 | return -EINVAL; | ||
384 | } | ||
385 | |||
386 | /* Store the desired state for the HP outputs */ | ||
387 | priv->arizona->hp_ena &= ~mask; | ||
388 | priv->arizona->hp_ena |= val; | ||
389 | |||
390 | /* Force off if HPDET magic is active */ | ||
391 | if (priv->arizona->hpdet_magic) | ||
392 | val = 0; | ||
393 | |||
394 | snd_soc_update_bits(w->codec, ARIZONA_OUTPUT_ENABLES_1, mask, val); | ||
395 | |||
396 | return arizona_out_ev(w, kcontrol, event); | ||
397 | } | ||
398 | EXPORT_SYMBOL_GPL(arizona_hp_ev); | ||
399 | |||
367 | static unsigned int arizona_sysclk_48k_rates[] = { | 400 | static unsigned int arizona_sysclk_48k_rates[] = { |
368 | 6144000, | 401 | 6144000, |
369 | 12288000, | 402 | 12288000, |
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 116372c91f5d..13dd2916b721 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h | |||
@@ -184,6 +184,9 @@ extern int arizona_in_ev(struct snd_soc_dapm_widget *w, | |||
184 | extern int arizona_out_ev(struct snd_soc_dapm_widget *w, | 184 | extern int arizona_out_ev(struct snd_soc_dapm_widget *w, |
185 | struct snd_kcontrol *kcontrol, | 185 | struct snd_kcontrol *kcontrol, |
186 | int event); | 186 | int event); |
187 | extern int arizona_hp_ev(struct snd_soc_dapm_widget *w, | ||
188 | struct snd_kcontrol *kcontrol, | ||
189 | int event); | ||
187 | 190 | ||
188 | extern int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, | 191 | extern int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, |
189 | int source, unsigned int freq, int dir); | 192 | int source, unsigned int freq, int dir); |
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index b82bbf584146..2657aad3f8b1 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c | |||
@@ -1131,11 +1131,11 @@ ARIZONA_DSP_WIDGETS(DSP1, "DSP1"), | |||
1131 | SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, | 1131 | SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, |
1132 | ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux), | 1132 | ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux), |
1133 | 1133 | ||
1134 | SND_SOC_DAPM_PGA_E("OUT1L", ARIZONA_OUTPUT_ENABLES_1, | 1134 | SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, |
1135 | ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | 1135 | ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, |
1136 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | 1136 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
1137 | SND_SOC_DAPM_PGA_E("OUT1R", ARIZONA_OUTPUT_ENABLES_1, | 1137 | SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, |
1138 | ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | 1138 | ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, |
1139 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | 1139 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
1140 | SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, | 1140 | SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, |
1141 | ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | 1141 | ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index cdeb301da1f6..7841b42a819c 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c | |||
@@ -551,11 +551,11 @@ SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0, | |||
551 | SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, | 551 | SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, |
552 | ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0), | 552 | ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0), |
553 | 553 | ||
554 | SND_SOC_DAPM_PGA_E("OUT1L", ARIZONA_OUTPUT_ENABLES_1, | 554 | SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, |
555 | ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | 555 | ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, |
556 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | 556 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
557 | SND_SOC_DAPM_PGA_E("OUT1R", ARIZONA_OUTPUT_ENABLES_1, | 557 | SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, |
558 | ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | 558 | ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, |
559 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | 559 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), |
560 | SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, | 560 | SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, |
561 | ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | 561 | ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, |
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index c800ea4c8bf9..5a1f6489d185 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
@@ -102,6 +102,10 @@ static struct utsname uts_buf; | |||
102 | #define MAX_FILE_NAME 100 | 102 | #define MAX_FILE_NAME 100 |
103 | #define ENTRIES_PER_BLOCK 50 | 103 | #define ENTRIES_PER_BLOCK 50 |
104 | 104 | ||
105 | #ifndef SOL_NETLINK | ||
106 | #define SOL_NETLINK 270 | ||
107 | #endif | ||
108 | |||
105 | struct kvp_record { | 109 | struct kvp_record { |
106 | char key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | 110 | char key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; |
107 | char value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; | 111 | char value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; |
@@ -1407,7 +1411,7 @@ netlink_send(int fd, struct cn_msg *msg) | |||
1407 | 1411 | ||
1408 | int main(void) | 1412 | int main(void) |
1409 | { | 1413 | { |
1410 | int fd, len, sock_opt; | 1414 | int fd, len, nl_group; |
1411 | int error; | 1415 | int error; |
1412 | struct cn_msg *message; | 1416 | struct cn_msg *message; |
1413 | struct pollfd pfd; | 1417 | struct pollfd pfd; |
@@ -1443,7 +1447,7 @@ int main(void) | |||
1443 | addr.nl_family = AF_NETLINK; | 1447 | addr.nl_family = AF_NETLINK; |
1444 | addr.nl_pad = 0; | 1448 | addr.nl_pad = 0; |
1445 | addr.nl_pid = 0; | 1449 | addr.nl_pid = 0; |
1446 | addr.nl_groups = CN_KVP_IDX; | 1450 | addr.nl_groups = 0; |
1447 | 1451 | ||
1448 | 1452 | ||
1449 | error = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); | 1453 | error = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); |
@@ -1452,8 +1456,8 @@ int main(void) | |||
1452 | close(fd); | 1456 | close(fd); |
1453 | exit(EXIT_FAILURE); | 1457 | exit(EXIT_FAILURE); |
1454 | } | 1458 | } |
1455 | sock_opt = addr.nl_groups; | 1459 | nl_group = CN_KVP_IDX; |
1456 | setsockopt(fd, 270, 1, &sock_opt, sizeof(sock_opt)); | 1460 | setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group)); |
1457 | /* | 1461 | /* |
1458 | * Register ourselves with the kernel. | 1462 | * Register ourselves with the kernel. |
1459 | */ | 1463 | */ |
@@ -1499,6 +1503,10 @@ int main(void) | |||
1499 | } | 1503 | } |
1500 | 1504 | ||
1501 | incoming_msg = (struct nlmsghdr *)kvp_recv_buffer; | 1505 | incoming_msg = (struct nlmsghdr *)kvp_recv_buffer; |
1506 | |||
1507 | if (incoming_msg->nlmsg_type != NLMSG_DONE) | ||
1508 | continue; | ||
1509 | |||
1502 | incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); | 1510 | incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); |
1503 | hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data; | 1511 | hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data; |
1504 | 1512 | ||
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c new file mode 100644 index 000000000000..95269952aa92 --- /dev/null +++ b/tools/hv/hv_vss_daemon.c | |||
@@ -0,0 +1,220 @@ | |||
1 | /* | ||
2 | * An implementation of the host initiated guest snapshot for Hyper-V. | ||
3 | * | ||
4 | * | ||
5 | * Copyright (C) 2013, Microsoft, Inc. | ||
6 | * Author : K. Y. Srinivasan <kys@microsoft.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License version 2 as published | ||
10 | * by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
15 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
16 | * details. | ||
17 | * | ||
18 | */ | ||
19 | |||
20 | |||
21 | #include <sys/types.h> | ||
22 | #include <sys/socket.h> | ||
23 | #include <sys/poll.h> | ||
24 | #include <linux/types.h> | ||
25 | #include <stdio.h> | ||
26 | #include <stdlib.h> | ||
27 | #include <unistd.h> | ||
28 | #include <string.h> | ||
29 | #include <ctype.h> | ||
30 | #include <errno.h> | ||
31 | #include <arpa/inet.h> | ||
32 | #include <linux/connector.h> | ||
33 | #include <linux/hyperv.h> | ||
34 | #include <linux/netlink.h> | ||
35 | #include <syslog.h> | ||
36 | |||
37 | static char vss_recv_buffer[4096]; | ||
38 | static char vss_send_buffer[4096]; | ||
39 | static struct sockaddr_nl addr; | ||
40 | |||
41 | #ifndef SOL_NETLINK | ||
42 | #define SOL_NETLINK 270 | ||
43 | #endif | ||
44 | |||
45 | |||
46 | static int vss_operate(int operation) | ||
47 | { | ||
48 | char *fs_op; | ||
49 | char cmd[512]; | ||
50 | char buf[512]; | ||
51 | FILE *file; | ||
52 | char *p; | ||
53 | char *x; | ||
54 | int error; | ||
55 | |||
56 | switch (operation) { | ||
57 | case VSS_OP_FREEZE: | ||
58 | fs_op = "-f "; | ||
59 | break; | ||
60 | case VSS_OP_THAW: | ||
61 | fs_op = "-u "; | ||
62 | break; | ||
63 | } | ||
64 | |||
65 | file = popen("mount | awk '/^\/dev\// { print $3}'", "r"); | ||
66 | if (file == NULL) | ||
67 | return; | ||
68 | |||
69 | while ((p = fgets(buf, sizeof(buf), file)) != NULL) { | ||
70 | x = strchr(p, '\n'); | ||
71 | *x = '\0'; | ||
72 | if (!strncmp(p, "/", sizeof("/"))) | ||
73 | continue; | ||
74 | |||
75 | sprintf(cmd, "%s %s %s", "fsfreeze ", fs_op, p); | ||
76 | syslog(LOG_INFO, "VSS cmd is %s\n", cmd); | ||
77 | error = system(cmd); | ||
78 | } | ||
79 | pclose(file); | ||
80 | |||
81 | sprintf(cmd, "%s %s %s", "fsfreeze ", fs_op, "/"); | ||
82 | syslog(LOG_INFO, "VSS cmd is %s\n", cmd); | ||
83 | error = system(cmd); | ||
84 | |||
85 | return error; | ||
86 | } | ||
87 | |||
88 | static int netlink_send(int fd, struct cn_msg *msg) | ||
89 | { | ||
90 | struct nlmsghdr *nlh; | ||
91 | unsigned int size; | ||
92 | struct msghdr message; | ||
93 | char buffer[64]; | ||
94 | struct iovec iov[2]; | ||
95 | |||
96 | size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len); | ||
97 | |||
98 | nlh = (struct nlmsghdr *)buffer; | ||
99 | nlh->nlmsg_seq = 0; | ||
100 | nlh->nlmsg_pid = getpid(); | ||
101 | nlh->nlmsg_type = NLMSG_DONE; | ||
102 | nlh->nlmsg_len = NLMSG_LENGTH(size - sizeof(*nlh)); | ||
103 | nlh->nlmsg_flags = 0; | ||
104 | |||
105 | iov[0].iov_base = nlh; | ||
106 | iov[0].iov_len = sizeof(*nlh); | ||
107 | |||
108 | iov[1].iov_base = msg; | ||
109 | iov[1].iov_len = size; | ||
110 | |||
111 | memset(&message, 0, sizeof(message)); | ||
112 | message.msg_name = &addr; | ||
113 | message.msg_namelen = sizeof(addr); | ||
114 | message.msg_iov = iov; | ||
115 | message.msg_iovlen = 2; | ||
116 | |||
117 | return sendmsg(fd, &message, 0); | ||
118 | } | ||
119 | |||
120 | int main(void) | ||
121 | { | ||
122 | int fd, len, nl_group; | ||
123 | int error; | ||
124 | struct cn_msg *message; | ||
125 | struct pollfd pfd; | ||
126 | struct nlmsghdr *incoming_msg; | ||
127 | struct cn_msg *incoming_cn_msg; | ||
128 | int op; | ||
129 | struct hv_vss_msg *vss_msg; | ||
130 | |||
131 | daemon(1, 0); | ||
132 | openlog("Hyper-V VSS", 0, LOG_USER); | ||
133 | syslog(LOG_INFO, "VSS starting; pid is:%d", getpid()); | ||
134 | |||
135 | fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); | ||
136 | if (fd < 0) { | ||
137 | syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd); | ||
138 | exit(EXIT_FAILURE); | ||
139 | } | ||
140 | addr.nl_family = AF_NETLINK; | ||
141 | addr.nl_pad = 0; | ||
142 | addr.nl_pid = 0; | ||
143 | addr.nl_groups = 0; | ||
144 | |||
145 | |||
146 | error = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); | ||
147 | if (error < 0) { | ||
148 | syslog(LOG_ERR, "bind failed; error:%d", error); | ||
149 | close(fd); | ||
150 | exit(EXIT_FAILURE); | ||
151 | } | ||
152 | nl_group = CN_VSS_IDX; | ||
153 | setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group)); | ||
154 | /* | ||
155 | * Register ourselves with the kernel. | ||
156 | */ | ||
157 | message = (struct cn_msg *)vss_send_buffer; | ||
158 | message->id.idx = CN_VSS_IDX; | ||
159 | message->id.val = CN_VSS_VAL; | ||
160 | message->ack = 0; | ||
161 | vss_msg = (struct hv_vss_msg *)message->data; | ||
162 | vss_msg->vss_hdr.operation = VSS_OP_REGISTER; | ||
163 | |||
164 | message->len = sizeof(struct hv_vss_msg); | ||
165 | |||
166 | len = netlink_send(fd, message); | ||
167 | if (len < 0) { | ||
168 | syslog(LOG_ERR, "netlink_send failed; error:%d", len); | ||
169 | close(fd); | ||
170 | exit(EXIT_FAILURE); | ||
171 | } | ||
172 | |||
173 | pfd.fd = fd; | ||
174 | |||
175 | while (1) { | ||
176 | struct sockaddr *addr_p = (struct sockaddr *) &addr; | ||
177 | socklen_t addr_l = sizeof(addr); | ||
178 | pfd.events = POLLIN; | ||
179 | pfd.revents = 0; | ||
180 | poll(&pfd, 1, -1); | ||
181 | |||
182 | len = recvfrom(fd, vss_recv_buffer, sizeof(vss_recv_buffer), 0, | ||
183 | addr_p, &addr_l); | ||
184 | |||
185 | if (len < 0 || addr.nl_pid) { | ||
186 | syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s", | ||
187 | addr.nl_pid, errno, strerror(errno)); | ||
188 | close(fd); | ||
189 | return -1; | ||
190 | } | ||
191 | |||
192 | incoming_msg = (struct nlmsghdr *)vss_recv_buffer; | ||
193 | |||
194 | if (incoming_msg->nlmsg_type != NLMSG_DONE) | ||
195 | continue; | ||
196 | |||
197 | incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); | ||
198 | vss_msg = (struct hv_vss_msg *)incoming_cn_msg->data; | ||
199 | op = vss_msg->vss_hdr.operation; | ||
200 | error = HV_S_OK; | ||
201 | |||
202 | switch (op) { | ||
203 | case VSS_OP_FREEZE: | ||
204 | case VSS_OP_THAW: | ||
205 | error = vss_operate(op); | ||
206 | if (error) | ||
207 | error = HV_E_FAIL; | ||
208 | break; | ||
209 | default: | ||
210 | syslog(LOG_ERR, "Illegal op:%d\n", op); | ||
211 | } | ||
212 | vss_msg->error = error; | ||
213 | len = netlink_send(fd, incoming_cn_msg); | ||
214 | if (len < 0) { | ||
215 | syslog(LOG_ERR, "net_link send failed; error:%d", len); | ||
216 | exit(EXIT_FAILURE); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | } | ||