aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/ata/atmel-at91_cf.txt19
-rw-r--r--Documentation/devicetree/bindings/memory-controllers/mvebu-devbus.txt156
-rw-r--r--Documentation/w1/w1.generic4
-rw-r--r--drivers/char/mem.c2
-rw-r--r--drivers/char/mspec.c2
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.h10
-rw-r--r--drivers/hv/channel.c50
-rw-r--r--drivers/hv/channel_mgmt.c119
-rw-r--r--drivers/hv/connection.c14
-rw-r--r--drivers/memory/Kconfig10
-rw-r--r--drivers/memory/Makefile1
-rw-r--r--drivers/memory/mvebu-devbus.c340
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/misc/ad525x_dpot.c2
-rw-r--r--drivers/misc/apds9802als.c5
-rw-r--r--drivers/misc/apds990x.c37
-rw-r--r--drivers/misc/arm-charlcd.c5
-rw-r--r--drivers/misc/bh1770glc.c59
-rw-r--r--drivers/misc/bh1780gli.c2
-rw-r--r--drivers/misc/carma/carma-fpga-program.c14
-rw-r--r--drivers/misc/carma/carma-fpga.c8
-rw-r--r--drivers/misc/eeprom/at24.c44
-rw-r--r--drivers/misc/eeprom/at25.c25
-rw-r--r--drivers/misc/ep93xx_pwm.c188
-rw-r--r--drivers/misc/hmc6352.c5
-rw-r--r--drivers/misc/isl29003.c24
-rw-r--r--drivers/misc/isl29020.c6
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d.c6
-rw-r--r--drivers/misc/mei/amthif.c6
-rw-r--r--drivers/misc/mei/client.c26
-rw-r--r--drivers/misc/mei/client.h1
-rw-r--r--drivers/misc/mei/interrupt.c158
-rw-r--r--drivers/misc/mei/main.c49
-rw-r--r--drivers/misc/mei/mei_dev.h19
-rw-r--r--drivers/misc/mei/pci-me.c19
-rw-r--r--drivers/misc/mei/wd.c6
-rw-r--r--drivers/misc/pch_phub.c44
-rw-r--r--drivers/misc/sgi-gru/gruprocfs.c14
-rw-r--r--drivers/misc/spear13xx_pcie_gadget.c69
-rw-r--r--drivers/misc/sram.c7
-rw-r--r--drivers/misc/ti-st/st_kim.c6
-rw-r--r--drivers/misc/ti_dac7512.c6
-rw-r--r--drivers/misc/tsl2550.c4
-rw-r--r--drivers/net/netconsole.c1
-rw-r--r--drivers/pcmcia/Kconfig2
-rw-r--r--drivers/pcmcia/at91_cf.c176
-rw-r--r--drivers/uio/uio_aec.c14
-rw-r--r--drivers/uio/uio_cif.c14
-rw-r--r--drivers/uio/uio_netx.c14
-rw-r--r--drivers/uio/uio_pci_generic.c17
-rw-r--r--drivers/uio/uio_pruss.c2
-rw-r--r--drivers/uio/uio_sercos3.c14
-rw-r--r--drivers/vme/vme.c2
-rw-r--r--drivers/w1/masters/w1-gpio.c6
-rw-r--r--drivers/w1/slaves/w1_ds2408.c1
-rw-r--r--drivers/w1/slaves/w1_ds2413.c1
-rw-r--r--drivers/w1/slaves/w1_ds2423.c1
-rw-r--r--drivers/w1/slaves/w1_ds2431.c1
-rw-r--r--drivers/w1/slaves/w1_ds2433.c1
-rw-r--r--drivers/w1/slaves/w1_ds2760.c1
-rw-r--r--drivers/w1/slaves/w1_ds2780.c1
-rw-r--r--drivers/w1/slaves/w1_ds2781.c1
-rw-r--r--drivers/w1/slaves/w1_ds28e04.c1
-rw-r--r--drivers/w1/slaves/w1_smem.c2
-rw-r--r--drivers/w1/slaves/w1_therm.c5
-rw-r--r--drivers/w1/w1.c2
-rw-r--r--include/linux/hyperv.h70
-rw-r--r--include/linux/if_ether.h1
-rw-r--r--include/linux/kernel.h2
-rw-r--r--lib/Kconfig3
-rw-r--r--lib/Makefile2
-rw-r--r--lib/net_utils.c26
-rw-r--r--net/Kconfig1
-rw-r--r--net/core/netpoll.c1
-rw-r--r--net/core/utils.c22
-rw-r--r--tools/hv/hv_kvp_daemon.c29
76 files changed, 1338 insertions, 691 deletions
diff --git a/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt b/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt
new file mode 100644
index 000000000000..c1d22b3ae134
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/atmel-at91_cf.txt
@@ -0,0 +1,19 @@
1Atmel AT91RM9200 CompactFlash
2
3Required properties:
4- compatible : "atmel,at91rm9200-cf".
5- reg : should specify localbus address and size used.
6- gpios : specifies the gpio pins to control the CF device. Detect
7 and reset gpio's are mandatory while irq and vcc gpio's are
8 optional and may be set to 0 if not present.
9
10Example:
11compact-flash@50000000 {
12 compatible = "atmel,at91rm9200-cf";
13 reg = <0x50000000 0x30000000>;
14 gpios = <&pioC 13 0 /* irq */
15 &pioC 15 0 /* detect */
16 0 /* vcc */
17 &pioC 5 0 /* reset */
18 >;
19};
diff --git a/Documentation/devicetree/bindings/memory-controllers/mvebu-devbus.txt b/Documentation/devicetree/bindings/memory-controllers/mvebu-devbus.txt
new file mode 100644
index 000000000000..653c90c34a71
--- /dev/null
+++ b/Documentation/devicetree/bindings/memory-controllers/mvebu-devbus.txt
@@ -0,0 +1,156 @@
1Device tree bindings for MVEBU Device Bus controllers
2
3The Device Bus controller available in some Marvell's SoC allows to control
4different types of standard memory and I/O devices such as NOR, NAND, and FPGA.
5The actual devices are instantiated from the child nodes of a Device Bus node.
6
7Required properties:
8
9 - compatible: Currently only Armada 370/XP SoC are supported,
10 with this compatible string:
11
12 marvell,mvebu-devbus
13
14 - reg: A resource specifier for the register space.
15 This is the base address of a chip select within
16 the controller's register space.
17 (see the example below)
18
19 - #address-cells: Must be set to 1
20 - #size-cells: Must be set to 1
21 - ranges: Must be set up to reflect the memory layout with four
22 integer values for each chip-select line in use:
23 0 <physical address of mapping> <size>
24
25Mandatory timing properties for child nodes:
26
27Read parameters:
28
29 - devbus,turn-off-ps: Defines the time during which the controller does not
30 drive the AD bus after the completion of a device read.
31 This prevents contentions on the Device Bus after a read
32 cycle from a slow device.
33
34 - devbus,bus-width: Defines the bus width (e.g. <16>)
35
36 - devbus,badr-skew-ps: Defines the time delay from from A[2:0] toggle,
37 to read data sample. This parameter is useful for
38 synchronous pipelined devices, where the address
39 precedes the read data by one or two cycles.
40
41 - devbus,acc-first-ps: Defines the time delay from the negation of
42 ALE[0] to the cycle that the first read data is sampled
43 by the controller.
44
45 - devbus,acc-next-ps: Defines the time delay between the cycle that
46 samples data N and the cycle that samples data N+1
47 (in burst accesses).
48
49 - devbus,rd-setup-ps: Defines the time delay between DEV_CSn assertion to
50 DEV_OEn assertion. If set to 0 (default),
51 DEV_OEn and DEV_CSn are asserted at the same cycle.
52 This parameter has no affect on <acc-first-ps> parameter
53 (no affect on first data sample). Set <rd-setup-ps>
54 to a value smaller than <acc-first-ps>.
55
56 - devbus,rd-hold-ps: Defines the time between the last data sample to the
57 de-assertion of DEV_CSn. If set to 0 (default),
58 DEV_OEn and DEV_CSn are de-asserted at the same cycle
59 (the cycle of the last data sample).
60 This parameter has no affect on DEV_OEn de-assertion.
61 DEV_OEn is always de-asserted the next cycle after
62 last data sampled. Also this parameter has no
63 affect on <turn-off-ps> parameter.
64 Set <rd-hold-ps> to a value smaller than <turn-off-ps>.
65
66Write parameters:
67
68 - devbus,ale-wr-ps: Defines the time delay from the ALE[0] negation cycle
69 to the DEV_WEn assertion.
70
71 - devbus,wr-low-ps: Defines the time during which DEV_WEn is active.
72 A[2:0] and Data are kept valid as long as DEV_WEn
73 is active. This parameter defines the setup time of
74 address and data to DEV_WEn rise.
75
76 - devbus,wr-high-ps: Defines the time during which DEV_WEn is kept
77 inactive (high) between data beats of a burst write.
78 DEV_A[2:0] and Data are kept valid (do not toggle) for
79 <wr-high-ps> - <tick> ps.
80 This parameter defines the hold time of address and
81 data after DEV_WEn rise.
82
83 - devbus,sync-enable: Synchronous device enable.
84 1: True
85 0: False
86
87An example for an Armada XP GP board, with a 16 MiB NOR device as child
88is showed below. Note that the Device Bus driver is in charge of allocating
89the mbus address decoding window for each of its child devices.
90The window is created using the chip select specified in the child
91device node together with the base address and size specified in the ranges
92property. For instance, in the example below the allocated decoding window
93will start at base address 0xf0000000, with a size 0x1000000 (16 MiB)
94for chip select 0 (a.k.a DEV_BOOTCS).
95
96This address window handling is done in this mvebu-devbus only as a temporary
97solution. It will be removed when the support for mbus device tree binding is
98added.
99
100The reg property implicitly specifies the chip select as this:
101
102 0x10400: DEV_BOOTCS
103 0x10408: DEV_CS0
104 0x10410: DEV_CS1
105 0x10418: DEV_CS2
106 0x10420: DEV_CS3
107
108Example:
109
110 devbus-bootcs@d0010400 {
111 status = "okay";
112 ranges = <0 0xf0000000 0x1000000>; /* @addr 0xf0000000, size 0x1000000 */
113 #address-cells = <1>;
114 #size-cells = <1>;
115
116 /* Device Bus parameters are required */
117
118 /* Read parameters */
119 devbus,bus-width = <8>;
120 devbus,turn-off-ps = <60000>;
121 devbus,badr-skew-ps = <0>;
122 devbus,acc-first-ps = <124000>;
123 devbus,acc-next-ps = <248000>;
124 devbus,rd-setup-ps = <0>;
125 devbus,rd-hold-ps = <0>;
126
127 /* Write parameters */
128 devbus,sync-enable = <0>;
129 devbus,wr-high-ps = <60000>;
130 devbus,wr-low-ps = <60000>;
131 devbus,ale-wr-ps = <60000>;
132
133 flash@0 {
134 compatible = "cfi-flash";
135
136 /* 16 MiB */
137 reg = <0 0x1000000>;
138 bank-width = <2>;
139 #address-cells = <1>;
140 #size-cells = <1>;
141
142 /*
143 * We split the 16 MiB in two partitions,
144 * just as an example.
145 */
146 partition@0 {
147 label = "First";
148 reg = <0 0x800000>;
149 };
150
151 partition@800000 {
152 label = "Second";
153 reg = <0x800000 0x800000>;
154 };
155 };
156 };
diff --git a/Documentation/w1/w1.generic b/Documentation/w1/w1.generic
index 212f4ac31c01..a31c5a242973 100644
--- a/Documentation/w1/w1.generic
+++ b/Documentation/w1/w1.generic
@@ -25,8 +25,8 @@ When a w1 master driver registers with the w1 subsystem, the following occurs:
25 - sysfs entries for that w1 master are created 25 - sysfs entries for that w1 master are created
26 - the w1 bus is periodically searched for new slave devices 26 - the w1 bus is periodically searched for new slave devices
27 27
28When a device is found on the bus, w1 core checks if driver for its family is 28When a device is found on the bus, w1 core tries to load the driver for its family
29loaded. If so, the family driver is attached to the slave. 29and check if it is loaded. If so, the family driver is attached to the slave.
30If there is no driver for the family, default one is assigned, which allows to perform 30If there is no driver for the family, default one is assigned, which allows to perform
31almost any kind of operations. Each logical operation is a transaction 31almost any kind of operations. Each logical operation is a transaction
32in nature, which can contain several (two or one) low-level operations. 32in nature, which can contain several (two or one) low-level operations.
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 1ccbe9482faa..2ca6d7844ad9 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -745,7 +745,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
745 offset += file->f_pos; 745 offset += file->f_pos;
746 case SEEK_SET: 746 case SEEK_SET:
747 /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */ 747 /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */
748 if ((unsigned long long)offset >= ~0xFFFULL) { 748 if (IS_ERR_VALUE((unsigned long long)offset)) {
749 ret = -EOVERFLOW; 749 ret = -EOVERFLOW;
750 break; 750 break;
751 } 751 }
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index e1f60f968fdd..f1d7fa45c275 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -267,7 +267,7 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,
267 if ((vma->vm_flags & VM_WRITE) == 0) 267 if ((vma->vm_flags & VM_WRITE) == 0)
268 return -EPERM; 268 return -EPERM;
269 269
270 pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; 270 pages = vma_pages(vma);
271 vdata_size = sizeof(struct vma_data) + pages * sizeof(long); 271 vdata_size = sizeof(struct vma_data) + pages * sizeof(long);
272 if (vdata_size <= PAGE_SIZE) 272 if (vdata_size <= PAGE_SIZE)
273 vdata = kzalloc(vdata_size, GFP_KERNEL); 273 vdata = kzalloc(vdata_size, GFP_KERNEL);
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
index d31ee23c9f13..38b145eaf24d 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
@@ -37,7 +37,7 @@
37#include <linux/cdev.h> 37#include <linux/cdev.h>
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39 39
40#include <asm/io.h> 40#include <linux/io.h>
41 41
42struct hwicap_drvdata { 42struct hwicap_drvdata {
43 u32 write_buffer_in_use; /* Always in [0,3] */ 43 u32 write_buffer_in_use; /* Always in [0,3] */
@@ -85,7 +85,13 @@ struct hwicap_driver_config {
85 void (*reset)(struct hwicap_drvdata *drvdata); 85 void (*reset)(struct hwicap_drvdata *drvdata);
86}; 86};
87 87
88/* Number of times to poll the done regsiter */ 88/* Number of times to poll the done register. This has to be large
89 * enough to allow an entire configuration to complete. If an entire
90 * page (4kb) is configured at once, that could take up to 4k cycles
91 * with a byte-wide icap interface. In most cases, this driver is
92 * used with a much smaller fifo, but this should be sufficient in the
93 * worst case.
94 */
89#define XHI_MAX_RETRIES 5000 95#define XHI_MAX_RETRIES 5000
90 96
91/************ Constant Definitions *************/ 97/************ Constant Definitions *************/
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 0b122f8c7005..6de6c98ce6eb 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -116,6 +116,15 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
116 unsigned long flags; 116 unsigned long flags;
117 int ret, t, err = 0; 117 int ret, t, err = 0;
118 118
119 spin_lock_irqsave(&newchannel->sc_lock, flags);
120 if (newchannel->state == CHANNEL_OPEN_STATE) {
121 newchannel->state = CHANNEL_OPENING_STATE;
122 } else {
123 spin_unlock_irqrestore(&newchannel->sc_lock, flags);
124 return -EINVAL;
125 }
126 spin_unlock_irqrestore(&newchannel->sc_lock, flags);
127
119 newchannel->onchannel_callback = onchannelcallback; 128 newchannel->onchannel_callback = onchannelcallback;
120 newchannel->channel_callback_context = context; 129 newchannel->channel_callback_context = context;
121 130
@@ -216,6 +225,9 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
216 list_del(&open_info->msglistentry); 225 list_del(&open_info->msglistentry);
217 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); 226 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
218 227
228 if (err == 0)
229 newchannel->state = CHANNEL_OPENED_STATE;
230
219 kfree(open_info); 231 kfree(open_info);
220 return err; 232 return err;
221 233
@@ -500,15 +512,14 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
500} 512}
501EXPORT_SYMBOL_GPL(vmbus_teardown_gpadl); 513EXPORT_SYMBOL_GPL(vmbus_teardown_gpadl);
502 514
503/* 515static void vmbus_close_internal(struct vmbus_channel *channel)
504 * vmbus_close - Close the specified channel
505 */
506void vmbus_close(struct vmbus_channel *channel)
507{ 516{
508 struct vmbus_channel_close_channel *msg; 517 struct vmbus_channel_close_channel *msg;
509 int ret; 518 int ret;
510 unsigned long flags; 519 unsigned long flags;
511 520
521 channel->state = CHANNEL_OPEN_STATE;
522 channel->sc_creation_callback = NULL;
512 /* Stop callback and cancel the timer asap */ 523 /* Stop callback and cancel the timer asap */
513 spin_lock_irqsave(&channel->inbound_lock, flags); 524 spin_lock_irqsave(&channel->inbound_lock, flags);
514 channel->onchannel_callback = NULL; 525 channel->onchannel_callback = NULL;
@@ -538,6 +549,37 @@ void vmbus_close(struct vmbus_channel *channel)
538 549
539 550
540} 551}
552
553/*
554 * vmbus_close - Close the specified channel
555 */
556void vmbus_close(struct vmbus_channel *channel)
557{
558 struct list_head *cur, *tmp;
559 struct vmbus_channel *cur_channel;
560
561 if (channel->primary_channel != NULL) {
562 /*
563 * We will only close sub-channels when
564 * the primary is closed.
565 */
566 return;
567 }
568 /*
569 * Close all the sub-channels first and then close the
570 * primary channel.
571 */
572 list_for_each_safe(cur, tmp, &channel->sc_list) {
573 cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
574 if (cur_channel->state != CHANNEL_OPENED_STATE)
575 continue;
576 vmbus_close_internal(cur_channel);
577 }
578 /*
579 * Now close the primary.
580 */
581 vmbus_close_internal(channel);
582}
541EXPORT_SYMBOL_GPL(vmbus_close); 583EXPORT_SYMBOL_GPL(vmbus_close);
542 584
543/** 585/**
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 21ef68934a20..0df75908200e 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -115,6 +115,9 @@ static struct vmbus_channel *alloc_channel(void)
115 return NULL; 115 return NULL;
116 116
117 spin_lock_init(&channel->inbound_lock); 117 spin_lock_init(&channel->inbound_lock);
118 spin_lock_init(&channel->sc_lock);
119
120 INIT_LIST_HEAD(&channel->sc_list);
118 121
119 channel->controlwq = create_workqueue("hv_vmbus_ctl"); 122 channel->controlwq = create_workqueue("hv_vmbus_ctl");
120 if (!channel->controlwq) { 123 if (!channel->controlwq) {
@@ -166,6 +169,7 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
166 struct vmbus_channel, 169 struct vmbus_channel,
167 work); 170 work);
168 unsigned long flags; 171 unsigned long flags;
172 struct vmbus_channel *primary_channel;
169 struct vmbus_channel_relid_released msg; 173 struct vmbus_channel_relid_released msg;
170 174
171 vmbus_device_unregister(channel->device_obj); 175 vmbus_device_unregister(channel->device_obj);
@@ -174,9 +178,16 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
174 msg.header.msgtype = CHANNELMSG_RELID_RELEASED; 178 msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
175 vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released)); 179 vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released));
176 180
177 spin_lock_irqsave(&vmbus_connection.channel_lock, flags); 181 if (channel->primary_channel == NULL) {
178 list_del(&channel->listentry); 182 spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
179 spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); 183 list_del(&channel->listentry);
184 spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
185 } else {
186 primary_channel = channel->primary_channel;
187 spin_lock_irqsave(&primary_channel->sc_lock, flags);
188 list_del(&channel->listentry);
189 spin_unlock_irqrestore(&primary_channel->sc_lock, flags);
190 }
180 free_channel(channel); 191 free_channel(channel);
181} 192}
182 193
@@ -228,6 +239,24 @@ static void vmbus_process_offer(struct work_struct *work)
228 spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); 239 spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
229 240
230 if (!fnew) { 241 if (!fnew) {
242 /*
243 * Check to see if this is a sub-channel.
244 */
245 if (newchannel->offermsg.offer.sub_channel_index != 0) {
246 /*
247 * Process the sub-channel.
248 */
249 newchannel->primary_channel = channel;
250 spin_lock_irqsave(&channel->sc_lock, flags);
251 list_add_tail(&newchannel->sc_list, &channel->sc_list);
252 spin_unlock_irqrestore(&channel->sc_lock, flags);
253 newchannel->state = CHANNEL_OPEN_STATE;
254 if (channel->sc_creation_callback != NULL)
255 channel->sc_creation_callback(newchannel);
256
257 return;
258 }
259
231 free_channel(newchannel); 260 free_channel(newchannel);
232 return; 261 return;
233 } 262 }
@@ -685,4 +714,86 @@ cleanup:
685 return ret; 714 return ret;
686} 715}
687 716
688/* eof */ 717/*
718 * Retrieve the (sub) channel on which to send an outgoing request.
719 * When a primary channel has multiple sub-channels, we choose a
720 * channel whose VCPU binding is closest to the VCPU on which
721 * this call is being made.
722 */
723struct vmbus_channel *vmbus_get_outgoing_channel(struct vmbus_channel *primary)
724{
725 struct list_head *cur, *tmp;
726 int cur_cpu = hv_context.vp_index[smp_processor_id()];
727 struct vmbus_channel *cur_channel;
728 struct vmbus_channel *outgoing_channel = primary;
729 int cpu_distance, new_cpu_distance;
730
731 if (list_empty(&primary->sc_list))
732 return outgoing_channel;
733
734 list_for_each_safe(cur, tmp, &primary->sc_list) {
735 cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
736 if (cur_channel->state != CHANNEL_OPENED_STATE)
737 continue;
738
739 if (cur_channel->target_vp == cur_cpu)
740 return cur_channel;
741
742 cpu_distance = ((outgoing_channel->target_vp > cur_cpu) ?
743 (outgoing_channel->target_vp - cur_cpu) :
744 (cur_cpu - outgoing_channel->target_vp));
745
746 new_cpu_distance = ((cur_channel->target_vp > cur_cpu) ?
747 (cur_channel->target_vp - cur_cpu) :
748 (cur_cpu - cur_channel->target_vp));
749
750 if (cpu_distance < new_cpu_distance)
751 continue;
752
753 outgoing_channel = cur_channel;
754 }
755
756 return outgoing_channel;
757}
758EXPORT_SYMBOL_GPL(vmbus_get_outgoing_channel);
759
760static void invoke_sc_cb(struct vmbus_channel *primary_channel)
761{
762 struct list_head *cur, *tmp;
763 struct vmbus_channel *cur_channel;
764
765 if (primary_channel->sc_creation_callback == NULL)
766 return;
767
768 list_for_each_safe(cur, tmp, &primary_channel->sc_list) {
769 cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
770
771 primary_channel->sc_creation_callback(cur_channel);
772 }
773}
774
775void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel,
776 void (*sc_cr_cb)(struct vmbus_channel *new_sc))
777{
778 primary_channel->sc_creation_callback = sc_cr_cb;
779}
780EXPORT_SYMBOL_GPL(vmbus_set_sc_create_callback);
781
782bool vmbus_are_subchannels_present(struct vmbus_channel *primary)
783{
784 bool ret;
785
786 ret = !list_empty(&primary->sc_list);
787
788 if (ret) {
789 /*
790 * Invoke the callback on sub-channel creation.
791 * This will present a uniform interface to the
792 * clients.
793 */
794 invoke_sc_cb(primary);
795 }
796
797 return ret;
798}
799EXPORT_SYMBOL_GPL(vmbus_are_subchannels_present);
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 253a74ba245c..ec3b8cdf1e04 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -246,12 +246,26 @@ struct vmbus_channel *relid2channel(u32 relid)
246 struct vmbus_channel *channel; 246 struct vmbus_channel *channel;
247 struct vmbus_channel *found_channel = NULL; 247 struct vmbus_channel *found_channel = NULL;
248 unsigned long flags; 248 unsigned long flags;
249 struct list_head *cur, *tmp;
250 struct vmbus_channel *cur_sc;
249 251
250 spin_lock_irqsave(&vmbus_connection.channel_lock, flags); 252 spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
251 list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) { 253 list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
252 if (channel->offermsg.child_relid == relid) { 254 if (channel->offermsg.child_relid == relid) {
253 found_channel = channel; 255 found_channel = channel;
254 break; 256 break;
257 } else if (!list_empty(&channel->sc_list)) {
258 /*
259 * Deal with sub-channels.
260 */
261 list_for_each_safe(cur, tmp, &channel->sc_list) {
262 cur_sc = list_entry(cur, struct vmbus_channel,
263 sc_list);
264 if (cur_sc->offermsg.child_relid == relid) {
265 found_channel = cur_sc;
266 break;
267 }
268 }
255 } 269 }
256 } 270 }
257 spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); 271 spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig
index 067f31174a0e..29a11db365bc 100644
--- a/drivers/memory/Kconfig
+++ b/drivers/memory/Kconfig
@@ -20,6 +20,16 @@ config TI_EMIF
20 parameters and other settings during frequency, voltage and 20 parameters and other settings during frequency, voltage and
21 temperature changes 21 temperature changes
22 22
23config MVEBU_DEVBUS
24 bool "Marvell EBU Device Bus Controller"
25 default y
26 depends on PLAT_ORION && OF
27 help
28 This driver is for the Device Bus controller available in some
29 Marvell EBU SoCs such as Discovery (mv78xx0), Orion (88f5xxx) and
30 Armada 370 and Armada XP. This controller allows to handle flash
31 devices such as NOR, NAND, SRAM, and FPGA.
32
23config TEGRA20_MC 33config TEGRA20_MC
24 bool "Tegra20 Memory Controller(MC) driver" 34 bool "Tegra20 Memory Controller(MC) driver"
25 default y 35 default y
diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile
index 9cce5d70ed52..969d923dad93 100644
--- a/drivers/memory/Makefile
+++ b/drivers/memory/Makefile
@@ -6,5 +6,6 @@ ifeq ($(CONFIG_DDR),y)
6obj-$(CONFIG_OF) += of_memory.o 6obj-$(CONFIG_OF) += of_memory.o
7endif 7endif
8obj-$(CONFIG_TI_EMIF) += emif.o 8obj-$(CONFIG_TI_EMIF) += emif.o
9obj-$(CONFIG_MVEBU_DEVBUS) += mvebu-devbus.o
9obj-$(CONFIG_TEGRA20_MC) += tegra20-mc.o 10obj-$(CONFIG_TEGRA20_MC) += tegra20-mc.o
10obj-$(CONFIG_TEGRA30_MC) += tegra30-mc.o 11obj-$(CONFIG_TEGRA30_MC) += tegra30-mc.o
diff --git a/drivers/memory/mvebu-devbus.c b/drivers/memory/mvebu-devbus.c
new file mode 100644
index 000000000000..978e8e3abc5c
--- /dev/null
+++ b/drivers/memory/mvebu-devbus.c
@@ -0,0 +1,340 @@
1/*
2 * Marvell EBU SoC Device Bus Controller
3 * (memory controller for NOR/NAND/SRAM/FPGA devices)
4 *
5 * Copyright (C) 2013 Marvell
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/err.h>
25#include <linux/io.h>
26#include <linux/clk.h>
27#include <linux/mbus.h>
28#include <linux/of_platform.h>
29#include <linux/of_address.h>
30#include <linux/platform_device.h>
31
32/* Register definitions */
33#define DEV_WIDTH_BIT 30
34#define BADR_SKEW_BIT 28
35#define RD_HOLD_BIT 23
36#define ACC_NEXT_BIT 17
37#define RD_SETUP_BIT 12
38#define ACC_FIRST_BIT 6
39
40#define SYNC_ENABLE_BIT 24
41#define WR_HIGH_BIT 16
42#define WR_LOW_BIT 8
43
44#define READ_PARAM_OFFSET 0x0
45#define WRITE_PARAM_OFFSET 0x4
46
47static const char * const devbus_wins[] = {
48 "devbus-boot",
49 "devbus-cs0",
50 "devbus-cs1",
51 "devbus-cs2",
52 "devbus-cs3",
53};
54
55struct devbus_read_params {
56 u32 bus_width;
57 u32 badr_skew;
58 u32 turn_off;
59 u32 acc_first;
60 u32 acc_next;
61 u32 rd_setup;
62 u32 rd_hold;
63};
64
65struct devbus_write_params {
66 u32 sync_enable;
67 u32 wr_high;
68 u32 wr_low;
69 u32 ale_wr;
70};
71
72struct devbus {
73 struct device *dev;
74 void __iomem *base;
75 unsigned long tick_ps;
76};
77
78static int get_timing_param_ps(struct devbus *devbus,
79 struct device_node *node,
80 const char *name,
81 u32 *ticks)
82{
83 u32 time_ps;
84 int err;
85
86 err = of_property_read_u32(node, name, &time_ps);
87 if (err < 0) {
88 dev_err(devbus->dev, "%s has no '%s' property\n",
89 name, node->full_name);
90 return err;
91 }
92
93 *ticks = (time_ps + devbus->tick_ps - 1) / devbus->tick_ps;
94
95 dev_dbg(devbus->dev, "%s: %u ps -> 0x%x\n",
96 name, time_ps, *ticks);
97 return 0;
98}
99
100static int devbus_set_timing_params(struct devbus *devbus,
101 struct device_node *node)
102{
103 struct devbus_read_params r;
104 struct devbus_write_params w;
105 u32 value;
106 int err;
107
108 dev_dbg(devbus->dev, "Setting timing parameter, tick is %lu ps\n",
109 devbus->tick_ps);
110
111 /* Get read timings */
112 err = of_property_read_u32(node, "devbus,bus-width", &r.bus_width);
113 if (err < 0) {
114 dev_err(devbus->dev,
115 "%s has no 'devbus,bus-width' property\n",
116 node->full_name);
117 return err;
118 }
119 /* Convert bit width to byte width */
120 r.bus_width /= 8;
121
122 err = get_timing_param_ps(devbus, node, "devbus,badr-skew-ps",
123 &r.badr_skew);
124 if (err < 0)
125 return err;
126
127 err = get_timing_param_ps(devbus, node, "devbus,turn-off-ps",
128 &r.turn_off);
129 if (err < 0)
130 return err;
131
132 err = get_timing_param_ps(devbus, node, "devbus,acc-first-ps",
133 &r.acc_first);
134 if (err < 0)
135 return err;
136
137 err = get_timing_param_ps(devbus, node, "devbus,acc-next-ps",
138 &r.acc_next);
139 if (err < 0)
140 return err;
141
142 err = get_timing_param_ps(devbus, node, "devbus,rd-setup-ps",
143 &r.rd_setup);
144 if (err < 0)
145 return err;
146
147 err = get_timing_param_ps(devbus, node, "devbus,rd-hold-ps",
148 &r.rd_hold);
149 if (err < 0)
150 return err;
151
152 /* Get write timings */
153 err = of_property_read_u32(node, "devbus,sync-enable",
154 &w.sync_enable);
155 if (err < 0) {
156 dev_err(devbus->dev,
157 "%s has no 'devbus,sync-enable' property\n",
158 node->full_name);
159 return err;
160 }
161
162 err = get_timing_param_ps(devbus, node, "devbus,ale-wr-ps",
163 &w.ale_wr);
164 if (err < 0)
165 return err;
166
167 err = get_timing_param_ps(devbus, node, "devbus,wr-low-ps",
168 &w.wr_low);
169 if (err < 0)
170 return err;
171
172 err = get_timing_param_ps(devbus, node, "devbus,wr-high-ps",
173 &w.wr_high);
174 if (err < 0)
175 return err;
176
177 /* Set read timings */
178 value = r.bus_width << DEV_WIDTH_BIT |
179 r.badr_skew << BADR_SKEW_BIT |
180 r.rd_hold << RD_HOLD_BIT |
181 r.acc_next << ACC_NEXT_BIT |
182 r.rd_setup << RD_SETUP_BIT |
183 r.acc_first << ACC_FIRST_BIT |
184 r.turn_off;
185
186 dev_dbg(devbus->dev, "read parameters register 0x%p = 0x%x\n",
187 devbus->base + READ_PARAM_OFFSET,
188 value);
189
190 writel(value, devbus->base + READ_PARAM_OFFSET);
191
192 /* Set write timings */
193 value = w.sync_enable << SYNC_ENABLE_BIT |
194 w.wr_low << WR_LOW_BIT |
195 w.wr_high << WR_HIGH_BIT |
196 w.ale_wr;
197
198 dev_dbg(devbus->dev, "write parameters register: 0x%p = 0x%x\n",
199 devbus->base + WRITE_PARAM_OFFSET,
200 value);
201
202 writel(value, devbus->base + WRITE_PARAM_OFFSET);
203
204 return 0;
205}
206
207static int mvebu_devbus_probe(struct platform_device *pdev)
208{
209 struct device *dev = &pdev->dev;
210 struct device_node *node = pdev->dev.of_node;
211 struct device_node *parent;
212 struct devbus *devbus;
213 struct resource *res;
214 struct clk *clk;
215 unsigned long rate;
216 const __be32 *ranges;
217 int err, cs;
218 int addr_cells, p_addr_cells, size_cells;
219 int ranges_len, tuple_len;
220 u32 base, size;
221
222 devbus = devm_kzalloc(&pdev->dev, sizeof(struct devbus), GFP_KERNEL);
223 if (!devbus)
224 return -ENOMEM;
225
226 devbus->dev = dev;
227 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
228 devbus->base = devm_ioremap_resource(&pdev->dev, res);
229 if (IS_ERR(devbus->base))
230 return PTR_ERR(devbus->base);
231
232 clk = devm_clk_get(&pdev->dev, NULL);
233 if (IS_ERR(clk))
234 return PTR_ERR(clk);
235 clk_prepare_enable(clk);
236
237 /*
238 * Obtain clock period in picoseconds,
239 * we need this in order to convert timing
240 * parameters from cycles to picoseconds.
241 */
242 rate = clk_get_rate(clk) / 1000;
243 devbus->tick_ps = 1000000000 / rate;
244
245 /* Read the device tree node and set the new timing parameters */
246 err = devbus_set_timing_params(devbus, node);
247 if (err < 0)
248 return err;
249
250 /*
251 * Allocate an address window for this device.
252 * If the device probing fails, then we won't be able to
253 * remove the allocated address decoding window.
254 *
255 * FIXME: This is only a temporary hack! We need to do this here
256 * because we still don't have device tree bindings for mbus.
257 * Once that support is added, we will declare these address windows
258 * statically in the device tree, and remove the window configuration
259 * from here.
260 */
261
262 /*
263 * Get the CS to choose the window string.
264 * This is a bit hacky, but it will be removed once the
265 * address windows are declared in the device tree.
266 */
267 cs = (((unsigned long)devbus->base) % 0x400) / 8;
268
269 /*
270 * Parse 'ranges' property to obtain a (base,size) window tuple.
271 * This will be removed once the address windows
272 * are declared in the device tree.
273 */
274 parent = of_get_parent(node);
275 if (!parent)
276 return -EINVAL;
277
278 p_addr_cells = of_n_addr_cells(parent);
279 of_node_put(parent);
280
281 addr_cells = of_n_addr_cells(node);
282 size_cells = of_n_size_cells(node);
283 tuple_len = (p_addr_cells + addr_cells + size_cells) * sizeof(__be32);
284
285 ranges = of_get_property(node, "ranges", &ranges_len);
286 if (ranges == NULL || ranges_len != tuple_len)
287 return -EINVAL;
288
289 base = of_translate_address(node, ranges + addr_cells);
290 if (base == OF_BAD_ADDR)
291 return -EINVAL;
292 size = of_read_number(ranges + addr_cells + p_addr_cells, size_cells);
293
294 /*
295 * Create an mbus address windows.
296 * FIXME: Remove this, together with the above code, once the
297 * address windows are declared in the device tree.
298 */
299 err = mvebu_mbus_add_window(devbus_wins[cs], base, size);
300 if (err < 0)
301 return err;
302
303 /*
304 * We need to create a child device explicitly from here to
305 * guarantee that the child will be probed after the timing
306 * parameters for the bus are written.
307 */
308 err = of_platform_populate(node, NULL, NULL, dev);
309 if (err < 0) {
310 mvebu_mbus_del_window(base, size);
311 return err;
312 }
313
314 return 0;
315}
316
317static const struct of_device_id mvebu_devbus_of_match[] = {
318 { .compatible = "marvell,mvebu-devbus" },
319 {},
320};
321MODULE_DEVICE_TABLE(of, mvebu_devbus_of_match);
322
323static struct platform_driver mvebu_devbus_driver = {
324 .probe = mvebu_devbus_probe,
325 .driver = {
326 .name = "mvebu-devbus",
327 .owner = THIS_MODULE,
328 .of_match_table = mvebu_devbus_of_match,
329 },
330};
331
332static int __init mvebu_devbus_init(void)
333{
334 return platform_driver_register(&mvebu_devbus_driver);
335}
336module_init(mvebu_devbus_init);
337
338MODULE_LICENSE("GPL v2");
339MODULE_AUTHOR("Ezequiel Garcia <ezequiel.garcia@free-electrons.com>");
340MODULE_DESCRIPTION("Marvell EBU SoC Device Bus controller");
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index c002d8660e30..80889d5f95f5 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -480,6 +480,7 @@ config BMP085_SPI
480 480
481config PCH_PHUB 481config PCH_PHUB
482 tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB" 482 tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB"
483 select GENERIC_NET_UTILS
483 depends on PCI 484 depends on PCI
484 help 485 help
485 This driver is for PCH(Platform controller Hub) PHUB(Packet Hub) of 486 This driver is for PCH(Platform controller Hub) PHUB(Packet Hub) of
diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 8f99e8e3f0ac..0daadcf1ed7a 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -470,7 +470,7 @@ static ssize_t sysfs_set_reg(struct device *dev,
470 !test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask)) 470 !test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask))
471 return -EPERM; 471 return -EPERM;
472 472
473 err = strict_strtoul(buf, 10, &value); 473 err = kstrtoul(buf, 10, &value);
474 if (err) 474 if (err)
475 return err; 475 return err;
476 476
diff --git a/drivers/misc/apds9802als.c b/drivers/misc/apds9802als.c
index 5b5fd8416b3e..0c6e037153d2 100644
--- a/drivers/misc/apds9802als.c
+++ b/drivers/misc/apds9802als.c
@@ -126,8 +126,9 @@ static ssize_t als_sensing_range_store(struct device *dev,
126 int ret_val; 126 int ret_val;
127 unsigned long val; 127 unsigned long val;
128 128
129 if (strict_strtoul(buf, 10, &val)) 129 ret_val = kstrtoul(buf, 10, &val);
130 return -EINVAL; 130 if (ret_val)
131 return ret_val;
131 132
132 if (val < 4096) 133 if (val < 4096)
133 val = 1; 134 val = 1;
diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c
index 98f9bb26492a..868a30a1b417 100644
--- a/drivers/misc/apds990x.c
+++ b/drivers/misc/apds990x.c
@@ -696,9 +696,11 @@ static ssize_t apds990x_lux_calib_store(struct device *dev,
696{ 696{
697 struct apds990x_chip *chip = dev_get_drvdata(dev); 697 struct apds990x_chip *chip = dev_get_drvdata(dev);
698 unsigned long value; 698 unsigned long value;
699 int ret;
699 700
700 if (strict_strtoul(buf, 0, &value)) 701 ret = kstrtoul(buf, 0, &value);
701 return -EINVAL; 702 if (ret)
703 return ret;
702 704
703 chip->lux_calib = value; 705 chip->lux_calib = value;
704 706
@@ -759,8 +761,9 @@ static ssize_t apds990x_rate_store(struct device *dev,
759 unsigned long value; 761 unsigned long value;
760 int ret; 762 int ret;
761 763
762 if (strict_strtoul(buf, 0, &value)) 764 ret = kstrtoul(buf, 0, &value);
763 return -EINVAL; 765 if (ret)
766 return ret;
764 767
765 mutex_lock(&chip->mutex); 768 mutex_lock(&chip->mutex);
766 ret = apds990x_set_arate(chip, value); 769 ret = apds990x_set_arate(chip, value);
@@ -813,9 +816,11 @@ static ssize_t apds990x_prox_enable_store(struct device *dev,
813{ 816{
814 struct apds990x_chip *chip = dev_get_drvdata(dev); 817 struct apds990x_chip *chip = dev_get_drvdata(dev);
815 unsigned long value; 818 unsigned long value;
819 int ret;
816 820
817 if (strict_strtoul(buf, 0, &value)) 821 ret = kstrtoul(buf, 0, &value);
818 return -EINVAL; 822 if (ret)
823 return ret;
819 824
820 mutex_lock(&chip->mutex); 825 mutex_lock(&chip->mutex);
821 826
@@ -892,11 +897,12 @@ static ssize_t apds990x_lux_thresh_below_show(struct device *dev,
892static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, 897static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target,
893 const char *buf) 898 const char *buf)
894{ 899{
895 int ret = 0;
896 unsigned long thresh; 900 unsigned long thresh;
901 int ret;
897 902
898 if (strict_strtoul(buf, 0, &thresh)) 903 ret = kstrtoul(buf, 0, &thresh);
899 return -EINVAL; 904 if (ret)
905 return ret;
900 906
901 if (thresh > APDS_RANGE) 907 if (thresh > APDS_RANGE)
902 return -EINVAL; 908 return -EINVAL;
@@ -957,9 +963,11 @@ static ssize_t apds990x_prox_threshold_store(struct device *dev,
957{ 963{
958 struct apds990x_chip *chip = dev_get_drvdata(dev); 964 struct apds990x_chip *chip = dev_get_drvdata(dev);
959 unsigned long value; 965 unsigned long value;
966 int ret;
960 967
961 if (strict_strtoul(buf, 0, &value)) 968 ret = kstrtoul(buf, 0, &value);
962 return -EINVAL; 969 if (ret)
970 return ret;
963 971
964 if ((value > APDS_RANGE) || (value == 0) || 972 if ((value > APDS_RANGE) || (value == 0) ||
965 (value < APDS_PROX_HYSTERESIS)) 973 (value < APDS_PROX_HYSTERESIS))
@@ -990,9 +998,12 @@ static ssize_t apds990x_power_state_store(struct device *dev,
990{ 998{
991 struct apds990x_chip *chip = dev_get_drvdata(dev); 999 struct apds990x_chip *chip = dev_get_drvdata(dev);
992 unsigned long value; 1000 unsigned long value;
1001 int ret;
1002
1003 ret = kstrtoul(buf, 0, &value);
1004 if (ret)
1005 return ret;
993 1006
994 if (strict_strtoul(buf, 0, &value))
995 return -EINVAL;
996 if (value) { 1007 if (value) {
997 pm_runtime_get_sync(dev); 1008 pm_runtime_get_sync(dev);
998 mutex_lock(&chip->mutex); 1009 mutex_lock(&chip->mutex);
diff --git a/drivers/misc/arm-charlcd.c b/drivers/misc/arm-charlcd.c
index 48651ef0028c..1256a4bf1c04 100644
--- a/drivers/misc/arm-charlcd.c
+++ b/drivers/misc/arm-charlcd.c
@@ -291,7 +291,7 @@ static int __init charlcd_probe(struct platform_device *pdev)
291 lcd->virtbase = ioremap(lcd->phybase, lcd->physize); 291 lcd->virtbase = ioremap(lcd->phybase, lcd->physize);
292 if (!lcd->virtbase) { 292 if (!lcd->virtbase) {
293 ret = -ENOMEM; 293 ret = -ENOMEM;
294 goto out_no_remap; 294 goto out_no_memregion;
295 } 295 }
296 296
297 lcd->irq = platform_get_irq(pdev, 0); 297 lcd->irq = platform_get_irq(pdev, 0);
@@ -320,8 +320,6 @@ static int __init charlcd_probe(struct platform_device *pdev)
320 320
321out_no_irq: 321out_no_irq:
322 iounmap(lcd->virtbase); 322 iounmap(lcd->virtbase);
323out_no_remap:
324 platform_set_drvdata(pdev, NULL);
325out_no_memregion: 323out_no_memregion:
326 release_mem_region(lcd->phybase, SZ_4K); 324 release_mem_region(lcd->phybase, SZ_4K);
327out_no_resource: 325out_no_resource:
@@ -337,7 +335,6 @@ static int __exit charlcd_remove(struct platform_device *pdev)
337 free_irq(lcd->irq, lcd); 335 free_irq(lcd->irq, lcd);
338 iounmap(lcd->virtbase); 336 iounmap(lcd->virtbase);
339 release_mem_region(lcd->phybase, lcd->physize); 337 release_mem_region(lcd->phybase, lcd->physize);
340 platform_set_drvdata(pdev, NULL);
341 kfree(lcd); 338 kfree(lcd);
342 } 339 }
343 340
diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index f4975f7d0d5b..99a04686e45f 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -651,8 +651,9 @@ static ssize_t bh1770_power_state_store(struct device *dev,
651 unsigned long value; 651 unsigned long value;
652 ssize_t ret; 652 ssize_t ret;
653 653
654 if (strict_strtoul(buf, 0, &value)) 654 ret = kstrtoul(buf, 0, &value);
655 return -EINVAL; 655 if (ret)
656 return ret;
656 657
657 mutex_lock(&chip->mutex); 658 mutex_lock(&chip->mutex);
658 if (value) { 659 if (value) {
@@ -726,9 +727,11 @@ static ssize_t bh1770_prox_enable_store(struct device *dev,
726{ 727{
727 struct bh1770_chip *chip = dev_get_drvdata(dev); 728 struct bh1770_chip *chip = dev_get_drvdata(dev);
728 unsigned long value; 729 unsigned long value;
730 int ret;
729 731
730 if (strict_strtoul(buf, 0, &value)) 732 ret = kstrtoul(buf, 0, &value);
731 return -EINVAL; 733 if (ret)
734 return ret;
732 735
733 mutex_lock(&chip->mutex); 736 mutex_lock(&chip->mutex);
734 /* Assume no proximity. Sensor will tell real state soon */ 737 /* Assume no proximity. Sensor will tell real state soon */
@@ -824,9 +827,11 @@ static ssize_t bh1770_set_prox_rate_above(struct device *dev,
824{ 827{
825 struct bh1770_chip *chip = dev_get_drvdata(dev); 828 struct bh1770_chip *chip = dev_get_drvdata(dev);
826 unsigned long value; 829 unsigned long value;
830 int ret;
827 831
828 if (strict_strtoul(buf, 0, &value)) 832 ret = kstrtoul(buf, 0, &value);
829 return -EINVAL; 833 if (ret)
834 return ret;
830 835
831 mutex_lock(&chip->mutex); 836 mutex_lock(&chip->mutex);
832 chip->prox_rate_threshold = bh1770_prox_rate_validate(value); 837 chip->prox_rate_threshold = bh1770_prox_rate_validate(value);
@@ -840,9 +845,11 @@ static ssize_t bh1770_set_prox_rate_below(struct device *dev,
840{ 845{
841 struct bh1770_chip *chip = dev_get_drvdata(dev); 846 struct bh1770_chip *chip = dev_get_drvdata(dev);
842 unsigned long value; 847 unsigned long value;
848 int ret;
843 849
844 if (strict_strtoul(buf, 0, &value)) 850 ret = kstrtoul(buf, 0, &value);
845 return -EINVAL; 851 if (ret)
852 return ret;
846 853
847 mutex_lock(&chip->mutex); 854 mutex_lock(&chip->mutex);
848 chip->prox_rate = bh1770_prox_rate_validate(value); 855 chip->prox_rate = bh1770_prox_rate_validate(value);
@@ -865,8 +872,10 @@ static ssize_t bh1770_set_prox_thres(struct device *dev,
865 unsigned long value; 872 unsigned long value;
866 int ret; 873 int ret;
867 874
868 if (strict_strtoul(buf, 0, &value)) 875 ret = kstrtoul(buf, 0, &value);
869 return -EINVAL; 876 if (ret)
877 return ret;
878
870 if (value > BH1770_PROX_RANGE) 879 if (value > BH1770_PROX_RANGE)
871 return -EINVAL; 880 return -EINVAL;
872 881
@@ -893,9 +902,11 @@ static ssize_t bh1770_prox_persistence_store(struct device *dev,
893{ 902{
894 struct bh1770_chip *chip = dev_get_drvdata(dev); 903 struct bh1770_chip *chip = dev_get_drvdata(dev);
895 unsigned long value; 904 unsigned long value;
905 int ret;
896 906
897 if (strict_strtoul(buf, 0, &value)) 907 ret = kstrtoul(buf, 0, &value);
898 return -EINVAL; 908 if (ret)
909 return ret;
899 910
900 if (value > BH1770_PROX_MAX_PERSISTENCE) 911 if (value > BH1770_PROX_MAX_PERSISTENCE)
901 return -EINVAL; 912 return -EINVAL;
@@ -918,9 +929,11 @@ static ssize_t bh1770_prox_abs_thres_store(struct device *dev,
918{ 929{
919 struct bh1770_chip *chip = dev_get_drvdata(dev); 930 struct bh1770_chip *chip = dev_get_drvdata(dev);
920 unsigned long value; 931 unsigned long value;
932 int ret;
921 933
922 if (strict_strtoul(buf, 0, &value)) 934 ret = kstrtoul(buf, 0, &value);
923 return -EINVAL; 935 if (ret)
936 return ret;
924 937
925 if (value > BH1770_PROX_RANGE) 938 if (value > BH1770_PROX_RANGE)
926 return -EINVAL; 939 return -EINVAL;
@@ -963,9 +976,11 @@ static ssize_t bh1770_lux_calib_store(struct device *dev,
963 unsigned long value; 976 unsigned long value;
964 u32 old_calib; 977 u32 old_calib;
965 u32 new_corr; 978 u32 new_corr;
979 int ret;
966 980
967 if (strict_strtoul(buf, 0, &value)) 981 ret = kstrtoul(buf, 0, &value);
968 return -EINVAL; 982 if (ret)
983 return ret;
969 984
970 mutex_lock(&chip->mutex); 985 mutex_lock(&chip->mutex);
971 old_calib = chip->lux_calib; 986 old_calib = chip->lux_calib;
@@ -1012,8 +1027,9 @@ static ssize_t bh1770_set_lux_rate(struct device *dev,
1012 unsigned long rate_hz; 1027 unsigned long rate_hz;
1013 int ret, i; 1028 int ret, i;
1014 1029
1015 if (strict_strtoul(buf, 0, &rate_hz)) 1030 ret = kstrtoul(buf, 0, &rate_hz);
1016 return -EINVAL; 1031 if (ret)
1032 return ret;
1017 1033
1018 for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++) 1034 for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++)
1019 if (rate_hz >= lux_rates_hz[i]) 1035 if (rate_hz >= lux_rates_hz[i])
@@ -1047,11 +1063,12 @@ static ssize_t bh1770_get_lux_thresh_below(struct device *dev,
1047static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target, 1063static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target,
1048 const char *buf) 1064 const char *buf)
1049{ 1065{
1050 int ret = 0;
1051 unsigned long thresh; 1066 unsigned long thresh;
1067 int ret;
1052 1068
1053 if (strict_strtoul(buf, 0, &thresh)) 1069 ret = kstrtoul(buf, 0, &thresh);
1054 return -EINVAL; 1070 if (ret)
1071 return ret;
1055 1072
1056 if (thresh > BH1770_LUX_RANGE) 1073 if (thresh > BH1770_LUX_RANGE)
1057 return -EINVAL; 1074 return -EINVAL;
diff --git a/drivers/misc/bh1780gli.c b/drivers/misc/bh1780gli.c
index 818f3a0e62bf..057580e026c0 100644
--- a/drivers/misc/bh1780gli.c
+++ b/drivers/misc/bh1780gli.c
@@ -107,7 +107,7 @@ static ssize_t bh1780_store_power_state(struct device *dev,
107 unsigned long val; 107 unsigned long val;
108 int error; 108 int error;
109 109
110 error = strict_strtoul(buf, 0, &val); 110 error = kstrtoul(buf, 0, &val);
111 if (error) 111 if (error)
112 return error; 112 return error;
113 113
diff --git a/drivers/misc/carma/carma-fpga-program.c b/drivers/misc/carma/carma-fpga-program.c
index 736c7714f565..c6bd7e84de24 100644
--- a/drivers/misc/carma/carma-fpga-program.c
+++ b/drivers/misc/carma/carma-fpga-program.c
@@ -830,8 +830,9 @@ static ssize_t penable_store(struct device *dev, struct device_attribute *attr,
830 unsigned long val; 830 unsigned long val;
831 int ret; 831 int ret;
832 832
833 if (strict_strtoul(buf, 0, &val)) 833 ret = kstrtoul(buf, 0, &val);
834 return -EINVAL; 834 if (ret)
835 return ret;
835 836
836 if (val) { 837 if (val) {
837 ret = fpga_enable_power_supplies(priv); 838 ret = fpga_enable_power_supplies(priv);
@@ -859,8 +860,9 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr,
859 unsigned long val; 860 unsigned long val;
860 int ret; 861 int ret;
861 862
862 if (strict_strtoul(buf, 0, &val)) 863 ret = kstrtoul(buf, 0, &val);
863 return -EINVAL; 864 if (ret)
865 return ret;
864 866
865 /* We can't have an image writer and be programming simultaneously */ 867 /* We can't have an image writer and be programming simultaneously */
866 if (mutex_lock_interruptible(&priv->lock)) 868 if (mutex_lock_interruptible(&priv->lock))
@@ -919,7 +921,7 @@ static bool dma_filter(struct dma_chan *chan, void *data)
919 921
920static int fpga_of_remove(struct platform_device *op) 922static int fpga_of_remove(struct platform_device *op)
921{ 923{
922 struct fpga_dev *priv = dev_get_drvdata(&op->dev); 924 struct fpga_dev *priv = platform_get_drvdata(op);
923 struct device *this_device = priv->miscdev.this_device; 925 struct device *this_device = priv->miscdev.this_device;
924 926
925 sysfs_remove_group(&this_device->kobj, &fpga_attr_group); 927 sysfs_remove_group(&this_device->kobj, &fpga_attr_group);
@@ -969,7 +971,7 @@ static int fpga_of_probe(struct platform_device *op)
969 971
970 kref_init(&priv->ref); 972 kref_init(&priv->ref);
971 973
972 dev_set_drvdata(&op->dev, priv); 974 platform_set_drvdata(op, priv);
973 priv->dev = &op->dev; 975 priv->dev = &op->dev;
974 mutex_init(&priv->lock); 976 mutex_init(&priv->lock);
975 init_completion(&priv->completion); 977 init_completion(&priv->completion);
diff --git a/drivers/misc/carma/carma-fpga.c b/drivers/misc/carma/carma-fpga.c
index 7508cafff103..7b56563f8b74 100644
--- a/drivers/misc/carma/carma-fpga.c
+++ b/drivers/misc/carma/carma-fpga.c
@@ -1002,10 +1002,10 @@ static ssize_t data_en_set(struct device *dev, struct device_attribute *attr,
1002 unsigned long enable; 1002 unsigned long enable;
1003 int ret; 1003 int ret;
1004 1004
1005 ret = strict_strtoul(buf, 0, &enable); 1005 ret = kstrtoul(buf, 0, &enable);
1006 if (ret) { 1006 if (ret) {
1007 dev_err(priv->dev, "unable to parse enable input\n"); 1007 dev_err(priv->dev, "unable to parse enable input\n");
1008 return -EINVAL; 1008 return ret;
1009 } 1009 }
1010 1010
1011 /* protect against concurrent enable/disable */ 1011 /* protect against concurrent enable/disable */
@@ -1296,7 +1296,7 @@ static int data_of_probe(struct platform_device *op)
1296 goto out_return; 1296 goto out_return;
1297 } 1297 }
1298 1298
1299 dev_set_drvdata(&op->dev, priv); 1299 platform_set_drvdata(op, priv);
1300 priv->dev = &op->dev; 1300 priv->dev = &op->dev;
1301 kref_init(&priv->ref); 1301 kref_init(&priv->ref);
1302 mutex_init(&priv->mutex); 1302 mutex_init(&priv->mutex);
@@ -1400,7 +1400,7 @@ out_return:
1400 1400
1401static int data_of_remove(struct platform_device *op) 1401static int data_of_remove(struct platform_device *op)
1402{ 1402{
1403 struct fpga_device *priv = dev_get_drvdata(&op->dev); 1403 struct fpga_device *priv = platform_get_drvdata(op);
1404 struct device *this_device = priv->miscdev.this_device; 1404 struct device *this_device = priv->miscdev.this_device;
1405 1405
1406 /* remove all sysfs files, now the device cannot be re-enabled */ 1406 /* remove all sysfs files, now the device cannot be re-enabled */
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 2baeec56edfe..5d4fd69d04ca 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -492,10 +492,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
492 if (client->dev.platform_data) { 492 if (client->dev.platform_data) {
493 chip = *(struct at24_platform_data *)client->dev.platform_data; 493 chip = *(struct at24_platform_data *)client->dev.platform_data;
494 } else { 494 } else {
495 if (!id->driver_data) { 495 if (!id->driver_data)
496 err = -ENODEV; 496 return -ENODEV;
497 goto err_out; 497
498 }
499 magic = id->driver_data; 498 magic = id->driver_data;
500 chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN)); 499 chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
501 magic >>= AT24_SIZE_BYTELEN; 500 magic >>= AT24_SIZE_BYTELEN;
@@ -519,8 +518,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
519 "byte_len looks suspicious (no power of 2)!\n"); 518 "byte_len looks suspicious (no power of 2)!\n");
520 if (!chip.page_size) { 519 if (!chip.page_size) {
521 dev_err(&client->dev, "page_size must not be 0!\n"); 520 dev_err(&client->dev, "page_size must not be 0!\n");
522 err = -EINVAL; 521 return -EINVAL;
523 goto err_out;
524 } 522 }
525 if (!is_power_of_2(chip.page_size)) 523 if (!is_power_of_2(chip.page_size))
526 dev_warn(&client->dev, 524 dev_warn(&client->dev,
@@ -528,10 +526,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
528 526
529 /* Use I2C operations unless we're stuck with SMBus extensions. */ 527 /* Use I2C operations unless we're stuck with SMBus extensions. */
530 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 528 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
531 if (chip.flags & AT24_FLAG_ADDR16) { 529 if (chip.flags & AT24_FLAG_ADDR16)
532 err = -EPFNOSUPPORT; 530 return -EPFNOSUPPORT;
533 goto err_out; 531
534 }
535 if (i2c_check_functionality(client->adapter, 532 if (i2c_check_functionality(client->adapter,
536 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { 533 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
537 use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; 534 use_smbus = I2C_SMBUS_I2C_BLOCK_DATA;
@@ -542,8 +539,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
542 I2C_FUNC_SMBUS_READ_BYTE_DATA)) { 539 I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
543 use_smbus = I2C_SMBUS_BYTE_DATA; 540 use_smbus = I2C_SMBUS_BYTE_DATA;
544 } else { 541 } else {
545 err = -EPFNOSUPPORT; 542 return -EPFNOSUPPORT;
546 goto err_out;
547 } 543 }
548 } 544 }
549 545
@@ -553,12 +549,10 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
553 num_addresses = DIV_ROUND_UP(chip.byte_len, 549 num_addresses = DIV_ROUND_UP(chip.byte_len,
554 (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256); 550 (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
555 551
556 at24 = kzalloc(sizeof(struct at24_data) + 552 at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
557 num_addresses * sizeof(struct i2c_client *), GFP_KERNEL); 553 num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
558 if (!at24) { 554 if (!at24)
559 err = -ENOMEM; 555 return -ENOMEM;
560 goto err_out;
561 }
562 556
563 mutex_init(&at24->lock); 557 mutex_init(&at24->lock);
564 at24->use_smbus = use_smbus; 558 at24->use_smbus = use_smbus;
@@ -596,11 +590,10 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
596 at24->write_max = write_max; 590 at24->write_max = write_max;
597 591
598 /* buffer (data + address at the beginning) */ 592 /* buffer (data + address at the beginning) */
599 at24->writebuf = kmalloc(write_max + 2, GFP_KERNEL); 593 at24->writebuf = devm_kzalloc(&client->dev,
600 if (!at24->writebuf) { 594 write_max + 2, GFP_KERNEL);
601 err = -ENOMEM; 595 if (!at24->writebuf)
602 goto err_struct; 596 return -ENOMEM;
603 }
604 } else { 597 } else {
605 dev_warn(&client->dev, 598 dev_warn(&client->dev,
606 "cannot write due to controller restrictions."); 599 "cannot write due to controller restrictions.");
@@ -648,11 +641,6 @@ err_clients:
648 if (at24->client[i]) 641 if (at24->client[i])
649 i2c_unregister_device(at24->client[i]); 642 i2c_unregister_device(at24->client[i]);
650 643
651 kfree(at24->writebuf);
652err_struct:
653 kfree(at24);
654err_out:
655 dev_dbg(&client->dev, "probe error %d\n", err);
656 return err; 644 return err;
657} 645}
658 646
@@ -667,8 +655,6 @@ static int at24_remove(struct i2c_client *client)
667 for (i = 1; i < at24->num_addresses; i++) 655 for (i = 1; i < at24->num_addresses; i++)
668 i2c_unregister_device(at24->client[i]); 656 i2c_unregister_device(at24->client[i]);
669 657
670 kfree(at24->writebuf);
671 kfree(at24);
672 return 0; 658 return 0;
673} 659}
674 660
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index ad8fd8e64937..840b3594a5ae 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -371,11 +371,10 @@ static int at25_probe(struct spi_device *spi)
371 if (np) { 371 if (np) {
372 err = at25_np_to_chip(&spi->dev, np, &chip); 372 err = at25_np_to_chip(&spi->dev, np, &chip);
373 if (err) 373 if (err)
374 goto fail; 374 return err;
375 } else { 375 } else {
376 dev_err(&spi->dev, "Error: no chip description\n"); 376 dev_err(&spi->dev, "Error: no chip description\n");
377 err = -ENODEV; 377 return -ENODEV;
378 goto fail;
379 } 378 }
380 } else 379 } else
381 chip = *(struct spi_eeprom *)spi->dev.platform_data; 380 chip = *(struct spi_eeprom *)spi->dev.platform_data;
@@ -389,8 +388,7 @@ static int at25_probe(struct spi_device *spi)
389 addrlen = 3; 388 addrlen = 3;
390 else { 389 else {
391 dev_dbg(&spi->dev, "unsupported address type\n"); 390 dev_dbg(&spi->dev, "unsupported address type\n");
392 err = -EINVAL; 391 return -EINVAL;
393 goto fail;
394 } 392 }
395 393
396 /* Ping the chip ... the status register is pretty portable, 394 /* Ping the chip ... the status register is pretty portable,
@@ -400,14 +398,12 @@ static int at25_probe(struct spi_device *spi)
400 sr = spi_w8r8(spi, AT25_RDSR); 398 sr = spi_w8r8(spi, AT25_RDSR);
401 if (sr < 0 || sr & AT25_SR_nRDY) { 399 if (sr < 0 || sr & AT25_SR_nRDY) {
402 dev_dbg(&spi->dev, "rdsr --> %d (%02x)\n", sr, sr); 400 dev_dbg(&spi->dev, "rdsr --> %d (%02x)\n", sr, sr);
403 err = -ENXIO; 401 return -ENXIO;
404 goto fail;
405 } 402 }
406 403
407 if (!(at25 = kzalloc(sizeof *at25, GFP_KERNEL))) { 404 at25 = devm_kzalloc(&spi->dev, sizeof(struct at25_data), GFP_KERNEL);
408 err = -ENOMEM; 405 if (!at25)
409 goto fail; 406 return -ENOMEM;
410 }
411 407
412 mutex_init(&at25->lock); 408 mutex_init(&at25->lock);
413 at25->chip = chip; 409 at25->chip = chip;
@@ -439,7 +435,7 @@ static int at25_probe(struct spi_device *spi)
439 435
440 err = sysfs_create_bin_file(&spi->dev.kobj, &at25->bin); 436 err = sysfs_create_bin_file(&spi->dev.kobj, &at25->bin);
441 if (err) 437 if (err)
442 goto fail; 438 return err;
443 439
444 if (chip.setup) 440 if (chip.setup)
445 chip.setup(&at25->mem, chip.context); 441 chip.setup(&at25->mem, chip.context);
@@ -453,10 +449,6 @@ static int at25_probe(struct spi_device *spi)
453 (chip.flags & EE_READONLY) ? " (readonly)" : "", 449 (chip.flags & EE_READONLY) ? " (readonly)" : "",
454 at25->chip.page_size); 450 at25->chip.page_size);
455 return 0; 451 return 0;
456fail:
457 dev_dbg(&spi->dev, "probe err %d\n", err);
458 kfree(at25);
459 return err;
460} 452}
461 453
462static int at25_remove(struct spi_device *spi) 454static int at25_remove(struct spi_device *spi)
@@ -465,7 +457,6 @@ static int at25_remove(struct spi_device *spi)
465 457
466 at25 = spi_get_drvdata(spi); 458 at25 = spi_get_drvdata(spi);
467 sysfs_remove_bin_file(&spi->dev.kobj, &at25->bin); 459 sysfs_remove_bin_file(&spi->dev.kobj, &at25->bin);
468 kfree(at25);
469 return 0; 460 return 0;
470} 461}
471 462
diff --git a/drivers/misc/ep93xx_pwm.c b/drivers/misc/ep93xx_pwm.c
index 96787ec15cad..cdb67a9c1959 100644
--- a/drivers/misc/ep93xx_pwm.c
+++ b/drivers/misc/ep93xx_pwm.c
@@ -39,63 +39,6 @@ struct ep93xx_pwm {
39 u32 duty_percent; 39 u32 duty_percent;
40}; 40};
41 41
42static inline void ep93xx_pwm_writel(struct ep93xx_pwm *pwm,
43 unsigned int val, unsigned int off)
44{
45 __raw_writel(val, pwm->mmio_base + off);
46}
47
48static inline unsigned int ep93xx_pwm_readl(struct ep93xx_pwm *pwm,
49 unsigned int off)
50{
51 return __raw_readl(pwm->mmio_base + off);
52}
53
54static inline void ep93xx_pwm_write_tc(struct ep93xx_pwm *pwm, u16 value)
55{
56 ep93xx_pwm_writel(pwm, value, EP93XX_PWMx_TERM_COUNT);
57}
58
59static inline u16 ep93xx_pwm_read_tc(struct ep93xx_pwm *pwm)
60{
61 return ep93xx_pwm_readl(pwm, EP93XX_PWMx_TERM_COUNT);
62}
63
64static inline void ep93xx_pwm_write_dc(struct ep93xx_pwm *pwm, u16 value)
65{
66 ep93xx_pwm_writel(pwm, value, EP93XX_PWMx_DUTY_CYCLE);
67}
68
69static inline void ep93xx_pwm_enable(struct ep93xx_pwm *pwm)
70{
71 ep93xx_pwm_writel(pwm, 0x1, EP93XX_PWMx_ENABLE);
72}
73
74static inline void ep93xx_pwm_disable(struct ep93xx_pwm *pwm)
75{
76 ep93xx_pwm_writel(pwm, 0x0, EP93XX_PWMx_ENABLE);
77}
78
79static inline int ep93xx_pwm_is_enabled(struct ep93xx_pwm *pwm)
80{
81 return ep93xx_pwm_readl(pwm, EP93XX_PWMx_ENABLE) & 0x1;
82}
83
84static inline void ep93xx_pwm_invert(struct ep93xx_pwm *pwm)
85{
86 ep93xx_pwm_writel(pwm, 0x1, EP93XX_PWMx_INVERT);
87}
88
89static inline void ep93xx_pwm_normal(struct ep93xx_pwm *pwm)
90{
91 ep93xx_pwm_writel(pwm, 0x0, EP93XX_PWMx_INVERT);
92}
93
94static inline int ep93xx_pwm_is_inverted(struct ep93xx_pwm *pwm)
95{
96 return ep93xx_pwm_readl(pwm, EP93XX_PWMx_INVERT) & 0x1;
97}
98
99/* 42/*
100 * /sys/devices/platform/ep93xx-pwm.N 43 * /sys/devices/platform/ep93xx-pwm.N
101 * /min_freq read-only minimum pwm output frequency 44 * /min_freq read-only minimum pwm output frequency
@@ -131,9 +74,9 @@ static ssize_t ep93xx_pwm_get_freq(struct device *dev,
131 struct platform_device *pdev = to_platform_device(dev); 74 struct platform_device *pdev = to_platform_device(dev);
132 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev); 75 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
133 76
134 if (ep93xx_pwm_is_enabled(pwm)) { 77 if (readl(pwm->mmio_base + EP93XX_PWMx_ENABLE) & 0x1) {
135 unsigned long rate = clk_get_rate(pwm->clk); 78 unsigned long rate = clk_get_rate(pwm->clk);
136 u16 term = ep93xx_pwm_read_tc(pwm); 79 u16 term = readl(pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
137 80
138 return sprintf(buf, "%ld\n", rate / (term + 1)); 81 return sprintf(buf, "%ld\n", rate / (term + 1));
139 } else { 82 } else {
@@ -149,12 +92,12 @@ static ssize_t ep93xx_pwm_set_freq(struct device *dev,
149 long val; 92 long val;
150 int err; 93 int err;
151 94
152 err = strict_strtol(buf, 10, &val); 95 err = kstrtol(buf, 10, &val);
153 if (err) 96 if (err)
154 return -EINVAL; 97 return -EINVAL;
155 98
156 if (val == 0) { 99 if (val == 0) {
157 ep93xx_pwm_disable(pwm); 100 writel(0x0, pwm->mmio_base + EP93XX_PWMx_ENABLE);
158 } else if (val <= (clk_get_rate(pwm->clk) / 2)) { 101 } else if (val <= (clk_get_rate(pwm->clk) / 2)) {
159 u32 term, duty; 102 u32 term, duty;
160 103
@@ -164,20 +107,20 @@ static ssize_t ep93xx_pwm_set_freq(struct device *dev,
164 if (val < 1) 107 if (val < 1)
165 val = 1; 108 val = 1;
166 109
167 term = ep93xx_pwm_read_tc(pwm); 110 term = readl(pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
168 duty = ((val + 1) * pwm->duty_percent / 100) - 1; 111 duty = ((val + 1) * pwm->duty_percent / 100) - 1;
169 112
170 /* If pwm is running, order is important */ 113 /* If pwm is running, order is important */
171 if (val > term) { 114 if (val > term) {
172 ep93xx_pwm_write_tc(pwm, val); 115 writel(val, pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
173 ep93xx_pwm_write_dc(pwm, duty); 116 writel(duty, pwm->mmio_base + EP93XX_PWMx_DUTY_CYCLE);
174 } else { 117 } else {
175 ep93xx_pwm_write_dc(pwm, duty); 118 writel(duty, pwm->mmio_base + EP93XX_PWMx_DUTY_CYCLE);
176 ep93xx_pwm_write_tc(pwm, val); 119 writel(val, pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
177 } 120 }
178 121
179 if (!ep93xx_pwm_is_enabled(pwm)) 122 if (!readl(pwm->mmio_base + EP93XX_PWMx_ENABLE) & 0x1)
180 ep93xx_pwm_enable(pwm); 123 writel(0x1, pwm->mmio_base + EP93XX_PWMx_ENABLE);
181 } else { 124 } else {
182 return -EINVAL; 125 return -EINVAL;
183 } 126 }
@@ -202,13 +145,15 @@ static ssize_t ep93xx_pwm_set_duty_percent(struct device *dev,
202 long val; 145 long val;
203 int err; 146 int err;
204 147
205 err = strict_strtol(buf, 10, &val); 148 err = kstrtol(buf, 10, &val);
206 if (err) 149 if (err)
207 return -EINVAL; 150 return -EINVAL;
208 151
209 if (val > 0 && val < 100) { 152 if (val > 0 && val < 100) {
210 u32 term = ep93xx_pwm_read_tc(pwm); 153 u32 term = readl(pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
211 ep93xx_pwm_write_dc(pwm, ((term + 1) * val / 100) - 1); 154 u32 duty = ((term + 1) * val / 100) - 1;
155
156 writel(duty, pwm->mmio_base + EP93XX_PWMx_DUTY_CYCLE);
212 pwm->duty_percent = val; 157 pwm->duty_percent = val;
213 return count; 158 return count;
214 } 159 }
@@ -221,8 +166,9 @@ static ssize_t ep93xx_pwm_get_invert(struct device *dev,
221{ 166{
222 struct platform_device *pdev = to_platform_device(dev); 167 struct platform_device *pdev = to_platform_device(dev);
223 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev); 168 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
169 int inverted = readl(pwm->mmio_base + EP93XX_PWMx_INVERT) & 0x1;
224 170
225 return sprintf(buf, "%d\n", ep93xx_pwm_is_inverted(pwm)); 171 return sprintf(buf, "%d\n", inverted);
226} 172}
227 173
228static ssize_t ep93xx_pwm_set_invert(struct device *dev, 174static ssize_t ep93xx_pwm_set_invert(struct device *dev,
@@ -233,14 +179,14 @@ static ssize_t ep93xx_pwm_set_invert(struct device *dev,
233 long val; 179 long val;
234 int err; 180 int err;
235 181
236 err = strict_strtol(buf, 10, &val); 182 err = kstrtol(buf, 10, &val);
237 if (err) 183 if (err)
238 return -EINVAL; 184 return -EINVAL;
239 185
240 if (val == 0) 186 if (val == 0)
241 ep93xx_pwm_normal(pwm); 187 writel(0x0, pwm->mmio_base + EP93XX_PWMx_INVERT);
242 else if (val == 1) 188 else if (val == 1)
243 ep93xx_pwm_invert(pwm); 189 writel(0x1, pwm->mmio_base + EP93XX_PWMx_INVERT);
244 else 190 else
245 return -EINVAL; 191 return -EINVAL;
246 192
@@ -269,89 +215,55 @@ static const struct attribute_group ep93xx_pwm_sysfs_files = {
269 .attrs = ep93xx_pwm_attrs, 215 .attrs = ep93xx_pwm_attrs,
270}; 216};
271 217
272static int __init ep93xx_pwm_probe(struct platform_device *pdev) 218static int ep93xx_pwm_probe(struct platform_device *pdev)
273{ 219{
274 struct ep93xx_pwm *pwm; 220 struct ep93xx_pwm *pwm;
275 struct resource *res; 221 struct resource *res;
276 int err; 222 int ret;
277 223
278 err = ep93xx_pwm_acquire_gpio(pdev); 224 pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
279 if (err) 225 if (!pwm)
280 return err; 226 return -ENOMEM;
281 227
282 pwm = kzalloc(sizeof(struct ep93xx_pwm), GFP_KERNEL); 228 pwm->clk = devm_clk_get(&pdev->dev, "pwm_clk");
283 if (!pwm) { 229 if (IS_ERR(pwm->clk))
284 err = -ENOMEM; 230 return PTR_ERR(pwm->clk);
285 goto fail_no_mem;
286 }
287 231
288 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 232 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
289 if (res == NULL) { 233 pwm->mmio_base = devm_ioremap_resource(&pdev->dev, res);
290 err = -ENXIO; 234 if (IS_ERR(pwm->mmio_base))
291 goto fail_no_mem_resource; 235 return PTR_ERR(pwm->mmio_base);
292 } 236
293 237 ret = ep93xx_pwm_acquire_gpio(pdev);
294 res = request_mem_region(res->start, resource_size(res), pdev->name); 238 if (ret)
295 if (res == NULL) { 239 return ret;
296 err = -EBUSY; 240
297 goto fail_no_mem_resource; 241 ret = sysfs_create_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files);
298 } 242 if (ret) {
299 243 ep93xx_pwm_release_gpio(pdev);
300 pwm->mmio_base = ioremap(res->start, resource_size(res)); 244 return ret;
301 if (pwm->mmio_base == NULL) {
302 err = -ENXIO;
303 goto fail_no_ioremap;
304 }
305
306 err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files);
307 if (err)
308 goto fail_no_sysfs;
309
310 pwm->clk = clk_get(&pdev->dev, "pwm_clk");
311 if (IS_ERR(pwm->clk)) {
312 err = PTR_ERR(pwm->clk);
313 goto fail_no_clk;
314 } 245 }
315 246
316 pwm->duty_percent = 50; 247 pwm->duty_percent = 50;
317 248
318 platform_set_drvdata(pdev, pwm);
319
320 /* disable pwm at startup. Avoids zero value. */ 249 /* disable pwm at startup. Avoids zero value. */
321 ep93xx_pwm_disable(pwm); 250 writel(0x0, pwm->mmio_base + EP93XX_PWMx_ENABLE);
322 ep93xx_pwm_write_tc(pwm, EP93XX_PWM_MAX_COUNT); 251 writel(EP93XX_PWM_MAX_COUNT, pwm->mmio_base + EP93XX_PWMx_TERM_COUNT);
323 ep93xx_pwm_write_dc(pwm, EP93XX_PWM_MAX_COUNT / 2); 252 writel(EP93XX_PWM_MAX_COUNT/2, pwm->mmio_base + EP93XX_PWMx_DUTY_CYCLE);
324 253
325 clk_enable(pwm->clk); 254 clk_enable(pwm->clk);
326 255
256 platform_set_drvdata(pdev, pwm);
327 return 0; 257 return 0;
328
329fail_no_clk:
330 sysfs_remove_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files);
331fail_no_sysfs:
332 iounmap(pwm->mmio_base);
333fail_no_ioremap:
334 release_mem_region(res->start, resource_size(res));
335fail_no_mem_resource:
336 kfree(pwm);
337fail_no_mem:
338 ep93xx_pwm_release_gpio(pdev);
339 return err;
340} 258}
341 259
342static int __exit ep93xx_pwm_remove(struct platform_device *pdev) 260static int ep93xx_pwm_remove(struct platform_device *pdev)
343{ 261{
344 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev); 262 struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
345 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
346 263
347 ep93xx_pwm_disable(pwm); 264 writel(0x0, pwm->mmio_base + EP93XX_PWMx_ENABLE);
348 clk_disable(pwm->clk); 265 clk_disable(pwm->clk);
349 clk_put(pwm->clk);
350 platform_set_drvdata(pdev, NULL);
351 sysfs_remove_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files); 266 sysfs_remove_group(&pdev->dev.kobj, &ep93xx_pwm_sysfs_files);
352 iounmap(pwm->mmio_base);
353 release_mem_region(res->start, resource_size(res));
354 kfree(pwm);
355 ep93xx_pwm_release_gpio(pdev); 267 ep93xx_pwm_release_gpio(pdev);
356 268
357 return 0; 269 return 0;
@@ -362,10 +274,10 @@ static struct platform_driver ep93xx_pwm_driver = {
362 .name = "ep93xx-pwm", 274 .name = "ep93xx-pwm",
363 .owner = THIS_MODULE, 275 .owner = THIS_MODULE,
364 }, 276 },
365 .remove = __exit_p(ep93xx_pwm_remove), 277 .probe = ep93xx_pwm_probe,
278 .remove = ep93xx_pwm_remove,
366}; 279};
367 280module_platform_driver(ep93xx_pwm_driver);
368module_platform_driver_probe(ep93xx_pwm_driver, ep93xx_pwm_probe);
369 281
370MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>, " 282MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>, "
371 "H Hartley Sweeten <hsweeten@visionengravers.com>"); 283 "H Hartley Sweeten <hsweeten@visionengravers.com>");
diff --git a/drivers/misc/hmc6352.c b/drivers/misc/hmc6352.c
index 423cd40f1c0f..170bd3daf336 100644
--- a/drivers/misc/hmc6352.c
+++ b/drivers/misc/hmc6352.c
@@ -46,8 +46,9 @@ static int compass_store(struct device *dev, const char *buf, size_t count,
46 int ret; 46 int ret;
47 unsigned long val; 47 unsigned long val;
48 48
49 if (strict_strtoul(buf, 10, &val)) 49 ret = kstrtoul(buf, 10, &val);
50 return -EINVAL; 50 if (ret)
51 return ret;
51 if (val >= strlen(map)) 52 if (val >= strlen(map))
52 return -EINVAL; 53 return -EINVAL;
53 mutex_lock(&compass_mutex); 54 mutex_lock(&compass_mutex);
diff --git a/drivers/misc/isl29003.c b/drivers/misc/isl29003.c
index c5145b3fcce8..e3183f26216b 100644
--- a/drivers/misc/isl29003.c
+++ b/drivers/misc/isl29003.c
@@ -208,7 +208,11 @@ static ssize_t isl29003_store_range(struct device *dev,
208 unsigned long val; 208 unsigned long val;
209 int ret; 209 int ret;
210 210
211 if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3)) 211 ret = kstrtoul(buf, 10, &val);
212 if (ret)
213 return ret;
214
215 if (val > 3)
212 return -EINVAL; 216 return -EINVAL;
213 217
214 ret = isl29003_set_range(client, val); 218 ret = isl29003_set_range(client, val);
@@ -239,7 +243,11 @@ static ssize_t isl29003_store_resolution(struct device *dev,
239 unsigned long val; 243 unsigned long val;
240 int ret; 244 int ret;
241 245
242 if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3)) 246 ret = kstrtoul(buf, 10, &val);
247 if (ret)
248 return ret;
249
250 if (val > 3)
243 return -EINVAL; 251 return -EINVAL;
244 252
245 ret = isl29003_set_resolution(client, val); 253 ret = isl29003_set_resolution(client, val);
@@ -267,7 +275,11 @@ static ssize_t isl29003_store_mode(struct device *dev,
267 unsigned long val; 275 unsigned long val;
268 int ret; 276 int ret;
269 277
270 if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2)) 278 ret = kstrtoul(buf, 10, &val);
279 if (ret)
280 return ret;
281
282 if (val > 2)
271 return -EINVAL; 283 return -EINVAL;
272 284
273 ret = isl29003_set_mode(client, val); 285 ret = isl29003_set_mode(client, val);
@@ -298,7 +310,11 @@ static ssize_t isl29003_store_power_state(struct device *dev,
298 unsigned long val; 310 unsigned long val;
299 int ret; 311 int ret;
300 312
301 if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1)) 313 ret = kstrtoul(buf, 10, &val);
314 if (ret)
315 return ret;
316
317 if (val > 1)
302 return -EINVAL; 318 return -EINVAL;
303 319
304 ret = isl29003_set_power_state(client, val); 320 ret = isl29003_set_power_state(client, val);
diff --git a/drivers/misc/isl29020.c b/drivers/misc/isl29020.c
index 0aa08c746463..b7f84dacf822 100644
--- a/drivers/misc/isl29020.c
+++ b/drivers/misc/isl29020.c
@@ -90,8 +90,10 @@ static ssize_t als_sensing_range_store(struct device *dev,
90 int ret_val; 90 int ret_val;
91 unsigned long val; 91 unsigned long val;
92 92
93 if (strict_strtoul(buf, 10, &val)) 93 ret_val = kstrtoul(buf, 10, &val);
94 return -EINVAL; 94 if (ret_val)
95 return ret_val;
96
95 if (val < 1 || val > 64000) 97 if (val < 1 || val > 64000)
96 return -EINVAL; 98 return -EINVAL;
97 99
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index 4cd4a3d2a76a..036effe9a795 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -831,9 +831,11 @@ static ssize_t lis3lv02d_rate_set(struct device *dev,
831{ 831{
832 struct lis3lv02d *lis3 = dev_get_drvdata(dev); 832 struct lis3lv02d *lis3 = dev_get_drvdata(dev);
833 unsigned long rate; 833 unsigned long rate;
834 int ret;
834 835
835 if (strict_strtoul(buf, 0, &rate)) 836 ret = kstrtoul(buf, 0, &rate);
836 return -EINVAL; 837 if (ret)
838 return ret;
837 839
838 lis3lv02d_sysfs_poweron(lis3); 840 lis3lv02d_sysfs_poweron(lis3);
839 if (lis3lv02d_set_odr(lis3, rate)) 841 if (lis3lv02d_set_odr(lis3, rate))
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index b3e50984d2c8..749452f8e2f6 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -443,11 +443,11 @@ unsigned int mei_amthif_poll(struct mei_device *dev,
443 * 443 *
444 * returns 0, OK; otherwise, error. 444 * returns 0, OK; otherwise, error.
445 */ 445 */
446int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, 446int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
447 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list) 447 s32 *slots, struct mei_cl_cb *cmpl_list)
448{ 448{
449 struct mei_device *dev = cl->dev;
449 struct mei_msg_hdr mei_hdr; 450 struct mei_msg_hdr mei_hdr;
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 u32 msg_slots = mei_data2slots(len); 452 u32 msg_slots = mei_data2slots(len);
453 453
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index e310ca6ed1a3..c2534ca5c6f1 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -785,6 +785,32 @@ err:
785} 785}
786 786
787 787
788/**
789 * mei_cl_complete - processes completed operation for a client
790 *
791 * @cl: private data of the file object.
792 * @cb: callback block.
793 */
794void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
795{
796 if (cb->fop_type == MEI_FOP_WRITE) {
797 mei_io_cb_free(cb);
798 cb = NULL;
799 cl->writing_state = MEI_WRITE_COMPLETE;
800 if (waitqueue_active(&cl->tx_wait))
801 wake_up_interruptible(&cl->tx_wait);
802
803 } else if (cb->fop_type == MEI_FOP_READ &&
804 MEI_READING == cl->reading_state) {
805 cl->reading_state = MEI_READ_COMPLETE;
806 if (waitqueue_active(&cl->rx_wait))
807 wake_up_interruptible(&cl->rx_wait);
808 else
809 mei_cl_bus_rx_event(cl);
810
811 }
812}
813
788 814
789/** 815/**
790 * mei_cl_all_disconnect - disconnect forcefully all connected clients 816 * mei_cl_all_disconnect - disconnect forcefully all connected clients
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index cfdb144526aa..7dc2af7b6fba 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -89,6 +89,7 @@ int mei_cl_disconnect(struct mei_cl *cl);
89int mei_cl_connect(struct mei_cl *cl, struct file *file); 89int mei_cl_connect(struct mei_cl *cl, struct file *file);
90int mei_cl_read_start(struct mei_cl *cl, size_t length); 90int mei_cl_read_start(struct mei_cl *cl, size_t length);
91int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking); 91int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking);
92void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb);
92 93
93void mei_host_client_init(struct work_struct *work); 94void mei_host_client_init(struct work_struct *work);
94 95
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 2ad736989410..7d9509a094e9 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -31,32 +31,6 @@
31 31
32 32
33/** 33/**
34 * mei_cl_complete_handler - processes completed operation for a client
35 *
36 * @cl: private data of the file object.
37 * @cb: callback block.
38 */
39static void mei_cl_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb)
40{
41 if (cb->fop_type == MEI_FOP_WRITE) {
42 mei_io_cb_free(cb);
43 cb = NULL;
44 cl->writing_state = MEI_WRITE_COMPLETE;
45 if (waitqueue_active(&cl->tx_wait))
46 wake_up_interruptible(&cl->tx_wait);
47
48 } else if (cb->fop_type == MEI_FOP_READ &&
49 MEI_READING == cl->reading_state) {
50 cl->reading_state = MEI_READ_COMPLETE;
51 if (waitqueue_active(&cl->rx_wait))
52 wake_up_interruptible(&cl->rx_wait);
53 else
54 mei_cl_bus_rx_event(cl);
55
56 }
57}
58
59/**
60 * mei_irq_compl_handler - dispatch complete handelers 34 * mei_irq_compl_handler - dispatch complete handelers
61 * for the completed callbacks 35 * for the completed callbacks
62 * 36 *
@@ -78,7 +52,7 @@ void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *compl_list)
78 if (cl == &dev->iamthif_cl) 52 if (cl == &dev->iamthif_cl)
79 mei_amthif_complete(dev, cb); 53 mei_amthif_complete(dev, cb);
80 else 54 else
81 mei_cl_complete_handler(cl, cb); 55 mei_cl_complete(cl, cb);
82 } 56 }
83} 57}
84EXPORT_SYMBOL_GPL(mei_irq_compl_handler); 58EXPORT_SYMBOL_GPL(mei_irq_compl_handler);
@@ -189,21 +163,21 @@ static int mei_cl_irq_read_msg(struct mei_device *dev,
189} 163}
190 164
191/** 165/**
192 * _mei_irq_thread_close - processes close related operation. 166 * mei_cl_irq_close - processes close related operation from
167 * interrupt thread context - send disconnect request
193 * 168 *
194 * @dev: the device structure. 169 * @cl: client
170 * @cb: callback block.
195 * @slots: free slots. 171 * @slots: free slots.
196 * @cb_pos: callback block.
197 * @cl: private data of the file object.
198 * @cmpl_list: complete list. 172 * @cmpl_list: complete list.
199 * 173 *
200 * returns 0, OK; otherwise, error. 174 * returns 0, OK; otherwise, error.
201 */ 175 */
202static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots, 176static int mei_cl_irq_close(struct mei_cl *cl, struct mei_cl_cb *cb,
203 struct mei_cl_cb *cb_pos, 177 s32 *slots, struct mei_cl_cb *cmpl_list)
204 struct mei_cl *cl,
205 struct mei_cl_cb *cmpl_list)
206{ 178{
179 struct mei_device *dev = cl->dev;
180
207 u32 msg_slots = 181 u32 msg_slots =
208 mei_data2slots(sizeof(struct hbm_client_connect_request)); 182 mei_data2slots(sizeof(struct hbm_client_connect_request));
209 183
@@ -214,15 +188,15 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
214 188
215 if (mei_hbm_cl_disconnect_req(dev, cl)) { 189 if (mei_hbm_cl_disconnect_req(dev, cl)) {
216 cl->status = 0; 190 cl->status = 0;
217 cb_pos->buf_idx = 0; 191 cb->buf_idx = 0;
218 list_move_tail(&cb_pos->list, &cmpl_list->list); 192 list_move_tail(&cb->list, &cmpl_list->list);
219 return -EIO; 193 return -EIO;
220 } 194 }
221 195
222 cl->state = MEI_FILE_DISCONNECTING; 196 cl->state = MEI_FILE_DISCONNECTING;
223 cl->status = 0; 197 cl->status = 0;
224 cb_pos->buf_idx = 0; 198 cb->buf_idx = 0;
225 list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list); 199 list_move_tail(&cb->list, &dev->ctrl_rd_list.list);
226 cl->timer_count = MEI_CONNECT_TIMEOUT; 200 cl->timer_count = MEI_CONNECT_TIMEOUT;
227 201
228 return 0; 202 return 0;
@@ -230,26 +204,26 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
230 204
231 205
232/** 206/**
233 * _mei_irq_thread_read - processes read related operation. 207 * mei_cl_irq_close - processes client read related operation from the
208 * interrupt thread context - request for flow control credits
234 * 209 *
235 * @dev: the device structure. 210 * @cl: client
211 * @cb: callback block.
236 * @slots: free slots. 212 * @slots: free slots.
237 * @cb_pos: callback block.
238 * @cl: private data of the file object.
239 * @cmpl_list: complete list. 213 * @cmpl_list: complete list.
240 * 214 *
241 * returns 0, OK; otherwise, error. 215 * returns 0, OK; otherwise, error.
242 */ 216 */
243static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots, 217static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
244 struct mei_cl_cb *cb_pos, 218 s32 *slots, struct mei_cl_cb *cmpl_list)
245 struct mei_cl *cl,
246 struct mei_cl_cb *cmpl_list)
247{ 219{
220 struct mei_device *dev = cl->dev;
221
248 u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control)); 222 u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));
249 223
250 if (*slots < msg_slots) { 224 if (*slots < msg_slots) {
251 /* return the cancel routine */ 225 /* return the cancel routine */
252 list_del(&cb_pos->list); 226 list_del(&cb->list);
253 return -EMSGSIZE; 227 return -EMSGSIZE;
254 } 228 }
255 229
@@ -257,38 +231,38 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
257 231
258 if (mei_hbm_cl_flow_control_req(dev, cl)) { 232 if (mei_hbm_cl_flow_control_req(dev, cl)) {
259 cl->status = -ENODEV; 233 cl->status = -ENODEV;
260 cb_pos->buf_idx = 0; 234 cb->buf_idx = 0;
261 list_move_tail(&cb_pos->list, &cmpl_list->list); 235 list_move_tail(&cb->list, &cmpl_list->list);
262 return -ENODEV; 236 return -ENODEV;
263 } 237 }
264 list_move_tail(&cb_pos->list, &dev->read_list.list); 238 list_move_tail(&cb->list, &dev->read_list.list);
265 239
266 return 0; 240 return 0;
267} 241}
268 242
269 243
270/** 244/**
271 * _mei_irq_thread_ioctl - processes ioctl related operation. 245 * mei_cl_irq_ioctl - processes client ioctl related operation from the
246 * interrupt thread context - send connection request
272 * 247 *
273 * @dev: the device structure. 248 * @cl: client
249 * @cb: callback block.
274 * @slots: free slots. 250 * @slots: free slots.
275 * @cb_pos: callback block.
276 * @cl: private data of the file object.
277 * @cmpl_list: complete list. 251 * @cmpl_list: complete list.
278 * 252 *
279 * returns 0, OK; otherwise, error. 253 * returns 0, OK; otherwise, error.
280 */ 254 */
281static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots, 255static int mei_cl_irq_ioctl(struct mei_cl *cl, struct mei_cl_cb *cb,
282 struct mei_cl_cb *cb_pos, 256 s32 *slots, struct mei_cl_cb *cmpl_list)
283 struct mei_cl *cl,
284 struct mei_cl_cb *cmpl_list)
285{ 257{
258 struct mei_device *dev = cl->dev;
259
286 u32 msg_slots = 260 u32 msg_slots =
287 mei_data2slots(sizeof(struct hbm_client_connect_request)); 261 mei_data2slots(sizeof(struct hbm_client_connect_request));
288 262
289 if (*slots < msg_slots) { 263 if (*slots < msg_slots) {
290 /* return the cancel routine */ 264 /* return the cancel routine */
291 list_del(&cb_pos->list); 265 list_del(&cb->list);
292 return -EMSGSIZE; 266 return -EMSGSIZE;
293 } 267 }
294 268
@@ -298,31 +272,31 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
298 272
299 if (mei_hbm_cl_connect_req(dev, cl)) { 273 if (mei_hbm_cl_connect_req(dev, cl)) {
300 cl->status = -ENODEV; 274 cl->status = -ENODEV;
301 cb_pos->buf_idx = 0; 275 cb->buf_idx = 0;
302 list_del(&cb_pos->list); 276 list_del(&cb->list);
303 return -ENODEV; 277 return -ENODEV;
304 } else {
305 list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
306 cl->timer_count = MEI_CONNECT_TIMEOUT;
307 } 278 }
279
280 list_move_tail(&cb->list, &dev->ctrl_rd_list.list);
281 cl->timer_count = MEI_CONNECT_TIMEOUT;
308 return 0; 282 return 0;
309} 283}
310 284
311/** 285/**
312 * mei_irq_thread_write_complete - write messages to device. 286 * mei_cl_irq_write_complete - write messages to device.
313 * 287 *
314 * @dev: the device structure. 288 * @cl: client
315 * @slots: free slots.
316 * @cb: callback block. 289 * @cb: callback block.
290 * @slots: free slots.
317 * @cmpl_list: complete list. 291 * @cmpl_list: complete list.
318 * 292 *
319 * returns 0, OK; otherwise, error. 293 * returns 0, OK; otherwise, error.
320 */ 294 */
321static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots, 295static int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
322 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list) 296 s32 *slots, struct mei_cl_cb *cmpl_list)
323{ 297{
298 struct mei_device *dev = cl->dev;
324 struct mei_msg_hdr mei_hdr; 299 struct mei_msg_hdr mei_hdr;
325 struct mei_cl *cl = cb->cl;
326 size_t len = cb->request_buffer.size - cb->buf_idx; 300 size_t len = cb->request_buffer.size - cb->buf_idx;
327 u32 msg_slots = mei_data2slots(len); 301 u32 msg_slots = mei_data2slots(len);
328 302
@@ -481,7 +455,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
481{ 455{
482 456
483 struct mei_cl *cl; 457 struct mei_cl *cl;
484 struct mei_cl_cb *pos = NULL, *next = NULL; 458 struct mei_cl_cb *cb, *next;
485 struct mei_cl_cb *list; 459 struct mei_cl_cb *list;
486 s32 slots; 460 s32 slots;
487 int ret; 461 int ret;
@@ -498,19 +472,19 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
498 dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n"); 472 dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
499 473
500 list = &dev->write_waiting_list; 474 list = &dev->write_waiting_list;
501 list_for_each_entry_safe(pos, next, &list->list, list) { 475 list_for_each_entry_safe(cb, next, &list->list, list) {
502 cl = pos->cl; 476 cl = cb->cl;
503 if (cl == NULL) 477 if (cl == NULL)
504 continue; 478 continue;
505 479
506 cl->status = 0; 480 cl->status = 0;
507 list_del(&pos->list); 481 list_del(&cb->list);
508 if (MEI_WRITING == cl->writing_state && 482 if (MEI_WRITING == cl->writing_state &&
509 pos->fop_type == MEI_FOP_WRITE && 483 cb->fop_type == MEI_FOP_WRITE &&
510 cl != &dev->iamthif_cl) { 484 cl != &dev->iamthif_cl) {
511 dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n"); 485 dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n");
512 cl->writing_state = MEI_WRITE_COMPLETE; 486 cl->writing_state = MEI_WRITE_COMPLETE;
513 list_add_tail(&pos->list, &cmpl_list->list); 487 list_add_tail(&cb->list, &cmpl_list->list);
514 } 488 }
515 if (cl == &dev->iamthif_cl) { 489 if (cl == &dev->iamthif_cl) {
516 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n"); 490 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
@@ -552,25 +526,23 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
552 526
553 /* complete control write list CB */ 527 /* complete control write list CB */
554 dev_dbg(&dev->pdev->dev, "complete control write list cb.\n"); 528 dev_dbg(&dev->pdev->dev, "complete control write list cb.\n");
555 list_for_each_entry_safe(pos, next, &dev->ctrl_wr_list.list, list) { 529 list_for_each_entry_safe(cb, next, &dev->ctrl_wr_list.list, list) {
556 cl = pos->cl; 530 cl = cb->cl;
557 if (!cl) { 531 if (!cl) {
558 list_del(&pos->list); 532 list_del(&cb->list);
559 return -ENODEV; 533 return -ENODEV;
560 } 534 }
561 switch (pos->fop_type) { 535 switch (cb->fop_type) {
562 case MEI_FOP_CLOSE: 536 case MEI_FOP_CLOSE:
563 /* send disconnect message */ 537 /* send disconnect message */
564 ret = _mei_irq_thread_close(dev, &slots, pos, 538 ret = mei_cl_irq_close(cl, cb, &slots, cmpl_list);
565 cl, cmpl_list);
566 if (ret) 539 if (ret)
567 return ret; 540 return ret;
568 541
569 break; 542 break;
570 case MEI_FOP_READ: 543 case MEI_FOP_READ:
571 /* send flow control message */ 544 /* send flow control message */
572 ret = _mei_irq_thread_read(dev, &slots, pos, 545 ret = mei_cl_irq_read(cl, cb, &slots, cmpl_list);
573 cl, cmpl_list);
574 if (ret) 546 if (ret)
575 return ret; 547 return ret;
576 548
@@ -579,8 +551,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
579 /* connect message */ 551 /* connect message */
580 if (mei_cl_is_other_connecting(cl)) 552 if (mei_cl_is_other_connecting(cl))
581 continue; 553 continue;
582 ret = _mei_irq_thread_ioctl(dev, &slots, pos, 554 ret = mei_cl_irq_ioctl(cl, cb, &slots, cmpl_list);
583 cl, cmpl_list);
584 if (ret) 555 if (ret)
585 return ret; 556 return ret;
586 557
@@ -593,8 +564,8 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
593 } 564 }
594 /* complete write list CB */ 565 /* complete write list CB */
595 dev_dbg(&dev->pdev->dev, "complete write list cb.\n"); 566 dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
596 list_for_each_entry_safe(pos, next, &dev->write_list.list, list) { 567 list_for_each_entry_safe(cb, next, &dev->write_list.list, list) {
597 cl = pos->cl; 568 cl = cb->cl;
598 if (cl == NULL) 569 if (cl == NULL)
599 continue; 570 continue;
600 if (mei_cl_flow_ctrl_creds(cl) <= 0) { 571 if (mei_cl_flow_ctrl_creds(cl) <= 0) {
@@ -605,14 +576,13 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
605 } 576 }
606 577
607 if (cl == &dev->iamthif_cl) 578 if (cl == &dev->iamthif_cl)
608 ret = mei_amthif_irq_write_complete(dev, &slots, 579 ret = mei_amthif_irq_write_complete(cl, cb,
609 pos, cmpl_list); 580 &slots, cmpl_list);
610 else 581 else
611 ret = mei_irq_thread_write_complete(dev, &slots, pos, 582 ret = mei_cl_irq_write_complete(cl, cb,
612 cmpl_list); 583 &slots, cmpl_list);
613 if (ret) 584 if (ret)
614 return ret; 585 return ret;
615
616 } 586 }
617 return 0; 587 return 0;
618} 588}
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 053139f61086..5e11b5b9b65d 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -194,7 +194,6 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
194 struct mei_cl_cb *cb_pos = NULL; 194 struct mei_cl_cb *cb_pos = NULL;
195 struct mei_cl_cb *cb = NULL; 195 struct mei_cl_cb *cb = NULL;
196 struct mei_device *dev; 196 struct mei_device *dev;
197 int i;
198 int rets; 197 int rets;
199 int err; 198 int err;
200 199
@@ -210,38 +209,26 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
210 goto out; 209 goto out;
211 } 210 }
212 211
213 if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) {
214 /* Do not allow to read watchdog client */
215 i = mei_me_cl_by_uuid(dev, &mei_wd_guid);
216 if (i >= 0) {
217 struct mei_me_client *me_client = &dev->me_clients[i];
218 if (cl->me_client_id == me_client->client_id) {
219 rets = -EBADF;
220 goto out;
221 }
222 }
223 } else {
224 cl->sm_state &= ~MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
225 }
226
227 if (cl == &dev->iamthif_cl) { 212 if (cl == &dev->iamthif_cl) {
228 rets = mei_amthif_read(dev, file, ubuf, length, offset); 213 rets = mei_amthif_read(dev, file, ubuf, length, offset);
229 goto out; 214 goto out;
230 } 215 }
231 216
232 if (cl->read_cb && cl->read_cb->buf_idx > *offset) { 217 if (cl->read_cb) {
233 cb = cl->read_cb;
234 goto copy_buffer;
235 } else if (cl->read_cb && cl->read_cb->buf_idx > 0 &&
236 cl->read_cb->buf_idx <= *offset) {
237 cb = cl->read_cb; 218 cb = cl->read_cb;
238 rets = 0; 219 /* read what left */
239 goto free; 220 if (cb->buf_idx > *offset)
240 } else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) { 221 goto copy_buffer;
241 /*Offset needs to be cleaned for contiguous reads*/ 222 /* offset is beyond buf_idx we have no more data return 0 */
223 if (cb->buf_idx > 0 && cb->buf_idx <= *offset) {
224 rets = 0;
225 goto free;
226 }
227 /* Offset needs to be cleaned for contiguous reads*/
228 if (cb->buf_idx == 0 && *offset > 0)
229 *offset = 0;
230 } else if (*offset > 0) {
242 *offset = 0; 231 *offset = 0;
243 rets = 0;
244 goto out;
245 } 232 }
246 233
247 err = mei_cl_read_start(cl, length); 234 err = mei_cl_read_start(cl, length);
@@ -420,16 +407,6 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
420 if (rets) 407 if (rets)
421 goto out; 408 goto out;
422 409
423 cl->sm_state = 0;
424 if (length == 4 &&
425 ((memcmp(mei_wd_state_independence_msg[0],
426 write_cb->request_buffer.data, 4) == 0) ||
427 (memcmp(mei_wd_state_independence_msg[1],
428 write_cb->request_buffer.data, 4) == 0) ||
429 (memcmp(mei_wd_state_independence_msg[2],
430 write_cb->request_buffer.data, 4) == 0)))
431 cl->sm_state |= MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
432
433 if (cl == &dev->iamthif_cl) { 410 if (cl == &dev->iamthif_cl) {
434 rets = mei_amthif_write(dev, write_cb); 411 rets = mei_amthif_write(dev, write_cb);
435 412
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 4de5140e7379..80a90319fc29 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -56,11 +56,6 @@ extern const uuid_le mei_amthif_guid;
56extern const uuid_le mei_wd_guid; 56extern const uuid_le mei_wd_guid;
57 57
58/* 58/*
59 * Watchdog independence state message
60 */
61extern const u8 mei_wd_state_independence_msg[3][4];
62
63/*
64 * Number of Maximum MEI Clients 59 * Number of Maximum MEI Clients
65 */ 60 */
66#define MEI_CLIENTS_MAX 256 61#define MEI_CLIENTS_MAX 256
@@ -201,7 +196,6 @@ struct mei_cl {
201 u8 timer_count; 196 u8 timer_count;
202 enum mei_file_transaction_states reading_state; 197 enum mei_file_transaction_states reading_state;
203 enum mei_file_transaction_states writing_state; 198 enum mei_file_transaction_states writing_state;
204 int sm_state;
205 struct mei_cl_cb *read_cb; 199 struct mei_cl_cb *read_cb;
206 200
207 /* MEI CL bus data */ 201 /* MEI CL bus data */
@@ -502,8 +496,8 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
502 496
503void mei_amthif_run_next_cmd(struct mei_device *dev); 497void mei_amthif_run_next_cmd(struct mei_device *dev);
504 498
505int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, 499int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
506 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list); 500 s32 *slots, struct mei_cl_cb *cmpl_list);
507 501
508void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb); 502void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
509int mei_amthif_irq_read_msg(struct mei_device *dev, 503int mei_amthif_irq_read_msg(struct mei_device *dev,
@@ -522,15 +516,6 @@ void mei_nfc_host_exit(void);
522 */ 516 */
523extern const uuid_le mei_nfc_guid; 517extern const uuid_le mei_nfc_guid;
524 518
525int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
526 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list);
527
528void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
529int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
530 struct mei_device *dev, struct mei_msg_hdr *mei_hdr);
531int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
532
533
534int mei_wd_send(struct mei_device *dev); 519int mei_wd_send(struct mei_device *dev);
535int mei_wd_stop(struct mei_device *dev); 520int mei_wd_stop(struct mei_device *dev);
536int mei_wd_host_init(struct mei_device *dev); 521int mei_wd_host_init(struct mei_device *dev);
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index a727464e9c3f..a2f5520f4060 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -43,9 +43,6 @@
43#include "hw-me.h" 43#include "hw-me.h"
44#include "client.h" 44#include "client.h"
45 45
46/* AMT device is a singleton on the platform */
47static struct pci_dev *mei_pdev;
48
49/* mei_pci_tbl - PCI Device ID Table */ 46/* mei_pci_tbl - PCI Device ID Table */
50static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = { 47static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = {
51 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)}, 48 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)},
@@ -88,8 +85,6 @@ static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = {
88 85
89MODULE_DEVICE_TABLE(pci, mei_me_pci_tbl); 86MODULE_DEVICE_TABLE(pci, mei_me_pci_tbl);
90 87
91static DEFINE_MUTEX(mei_mutex);
92
93/** 88/**
94 * mei_quirk_probe - probe for devices that doesn't valid ME interface 89 * mei_quirk_probe - probe for devices that doesn't valid ME interface
95 * 90 *
@@ -126,17 +121,12 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
126 struct mei_me_hw *hw; 121 struct mei_me_hw *hw;
127 int err; 122 int err;
128 123
129 mutex_lock(&mei_mutex);
130 124
131 if (!mei_me_quirk_probe(pdev, ent)) { 125 if (!mei_me_quirk_probe(pdev, ent)) {
132 err = -ENODEV; 126 err = -ENODEV;
133 goto end; 127 goto end;
134 } 128 }
135 129
136 if (mei_pdev) {
137 err = -EEXIST;
138 goto end;
139 }
140 /* enable pci dev */ 130 /* enable pci dev */
141 err = pci_enable_device(pdev); 131 err = pci_enable_device(pdev);
142 if (err) { 132 if (err) {
@@ -195,13 +185,10 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
195 if (err) 185 if (err)
196 goto release_irq; 186 goto release_irq;
197 187
198 mei_pdev = pdev;
199 pci_set_drvdata(pdev, dev); 188 pci_set_drvdata(pdev, dev);
200 189
201 schedule_delayed_work(&dev->timer_work, HZ); 190 schedule_delayed_work(&dev->timer_work, HZ);
202 191
203 mutex_unlock(&mei_mutex);
204
205 pr_debug("initialization successful.\n"); 192 pr_debug("initialization successful.\n");
206 193
207 return 0; 194 return 0;
@@ -220,7 +207,6 @@ release_regions:
220disable_device: 207disable_device:
221 pci_disable_device(pdev); 208 pci_disable_device(pdev);
222end: 209end:
223 mutex_unlock(&mei_mutex);
224 dev_err(&pdev->dev, "initialization failed.\n"); 210 dev_err(&pdev->dev, "initialization failed.\n");
225 return err; 211 return err;
226} 212}
@@ -238,9 +224,6 @@ static void mei_me_remove(struct pci_dev *pdev)
238 struct mei_device *dev; 224 struct mei_device *dev;
239 struct mei_me_hw *hw; 225 struct mei_me_hw *hw;
240 226
241 if (mei_pdev != pdev)
242 return;
243
244 dev = pci_get_drvdata(pdev); 227 dev = pci_get_drvdata(pdev);
245 if (!dev) 228 if (!dev)
246 return; 229 return;
@@ -251,8 +234,6 @@ static void mei_me_remove(struct pci_dev *pdev)
251 dev_err(&pdev->dev, "stop\n"); 234 dev_err(&pdev->dev, "stop\n");
252 mei_stop(dev); 235 mei_stop(dev);
253 236
254 mei_pdev = NULL;
255
256 /* disable interrupts */ 237 /* disable interrupts */
257 mei_disable_interrupts(dev); 238 mei_disable_interrupts(dev);
258 239
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 6251a4ee7067..b8921432e89d 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -31,12 +31,6 @@
31static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 }; 31static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 };
32static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 }; 32static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 };
33 33
34const u8 mei_wd_state_independence_msg[3][4] = {
35 {0x05, 0x02, 0x51, 0x10},
36 {0x05, 0x02, 0x52, 0x10},
37 {0x07, 0x02, 0x01, 0x10}
38};
39
40/* 34/*
41 * AMT Watchdog Device 35 * AMT Watchdog Device
42 */ 36 */
diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c
index 931e635aa491..a5925f7f17f6 100644
--- a/drivers/misc/pch_phub.c
+++ b/drivers/misc/pch_phub.c
@@ -633,17 +633,13 @@ static ssize_t show_pch_mac(struct device *dev, struct device_attribute *attr,
633static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr, 633static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr,
634 const char *buf, size_t count) 634 const char *buf, size_t count)
635{ 635{
636 u8 mac[6]; 636 u8 mac[ETH_ALEN];
637 ssize_t rom_size; 637 ssize_t rom_size;
638 struct pch_phub_reg *chip = dev_get_drvdata(dev); 638 struct pch_phub_reg *chip = dev_get_drvdata(dev);
639 639
640 if (count != 18) 640 if (!mac_pton(buf, mac))
641 return -EINVAL; 641 return -EINVAL;
642 642
643 sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
644 (u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2], (u32 *)&mac[3],
645 (u32 *)&mac[4], (u32 *)&mac[5]);
646
647 chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size); 643 chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
648 if (!chip->pch_phub_extrom_base_address) 644 if (!chip->pch_phub_extrom_base_address)
649 return -ENOMEM; 645 return -ENOMEM;
@@ -669,8 +665,6 @@ static struct bin_attribute pch_bin_attr = {
669static int pch_phub_probe(struct pci_dev *pdev, 665static int pch_phub_probe(struct pci_dev *pdev,
670 const struct pci_device_id *id) 666 const struct pci_device_id *id)
671{ 667{
672 int retval;
673
674 int ret; 668 int ret;
675 struct pch_phub_reg *chip; 669 struct pch_phub_reg *chip;
676 670
@@ -713,13 +707,13 @@ static int pch_phub_probe(struct pci_dev *pdev,
713 if (id->driver_data == 1) { /* EG20T PCH */ 707 if (id->driver_data == 1) { /* EG20T PCH */
714 const char *board_name; 708 const char *board_name;
715 709
716 retval = sysfs_create_file(&pdev->dev.kobj, 710 ret = sysfs_create_file(&pdev->dev.kobj,
717 &dev_attr_pch_mac.attr); 711 &dev_attr_pch_mac.attr);
718 if (retval) 712 if (ret)
719 goto err_sysfs_create; 713 goto err_sysfs_create;
720 714
721 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); 715 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
722 if (retval) 716 if (ret)
723 goto exit_bin_attr; 717 goto exit_bin_attr;
724 718
725 pch_phub_read_modify_write_reg(chip, 719 pch_phub_read_modify_write_reg(chip,
@@ -743,8 +737,8 @@ static int pch_phub_probe(struct pci_dev *pdev,
743 chip->pch_opt_rom_start_address = PCH_PHUB_ROM_START_ADDR_EG20T; 737 chip->pch_opt_rom_start_address = PCH_PHUB_ROM_START_ADDR_EG20T;
744 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_EG20T; 738 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_EG20T;
745 } else if (id->driver_data == 2) { /* ML7213 IOH */ 739 } else if (id->driver_data == 2) { /* ML7213 IOH */
746 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); 740 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
747 if (retval) 741 if (ret)
748 goto err_sysfs_create; 742 goto err_sysfs_create;
749 /* set the prefech value 743 /* set the prefech value
750 * Device2(USB OHCI #1/ USB EHCI #1/ USB Device):a 744 * Device2(USB OHCI #1/ USB EHCI #1/ USB Device):a
@@ -766,12 +760,12 @@ static int pch_phub_probe(struct pci_dev *pdev,
766 PCH_PHUB_ROM_START_ADDR_ML7223; 760 PCH_PHUB_ROM_START_ADDR_ML7223;
767 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223; 761 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223;
768 } else if (id->driver_data == 4) { /* ML7223 IOH Bus-n*/ 762 } else if (id->driver_data == 4) { /* ML7223 IOH Bus-n*/
769 retval = sysfs_create_file(&pdev->dev.kobj, 763 ret = sysfs_create_file(&pdev->dev.kobj,
770 &dev_attr_pch_mac.attr); 764 &dev_attr_pch_mac.attr);
771 if (retval) 765 if (ret)
772 goto err_sysfs_create; 766 goto err_sysfs_create;
773 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); 767 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
774 if (retval) 768 if (ret)
775 goto exit_bin_attr; 769 goto exit_bin_attr;
776 /* set the prefech value 770 /* set the prefech value
777 * Device2(USB OHCI #0,1,2,3/ USB EHCI #0):a 771 * Device2(USB OHCI #0,1,2,3/ USB EHCI #0):a
@@ -783,13 +777,13 @@ static int pch_phub_probe(struct pci_dev *pdev,
783 PCH_PHUB_ROM_START_ADDR_ML7223; 777 PCH_PHUB_ROM_START_ADDR_ML7223;
784 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223; 778 chip->pch_mac_start_address = PCH_PHUB_MAC_START_ADDR_ML7223;
785 } else if (id->driver_data == 5) { /* ML7831 */ 779 } else if (id->driver_data == 5) { /* ML7831 */
786 retval = sysfs_create_file(&pdev->dev.kobj, 780 ret = sysfs_create_file(&pdev->dev.kobj,
787 &dev_attr_pch_mac.attr); 781 &dev_attr_pch_mac.attr);
788 if (retval) 782 if (ret)
789 goto err_sysfs_create; 783 goto err_sysfs_create;
790 784
791 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); 785 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr);
792 if (retval) 786 if (ret)
793 goto exit_bin_attr; 787 goto exit_bin_attr;
794 788
795 /* set the prefech value */ 789 /* set the prefech value */
diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
index 797d7962cc88..4f7635922394 100644
--- a/drivers/misc/sgi-gru/gruprocfs.c
+++ b/drivers/misc/sgi-gru/gruprocfs.c
@@ -160,15 +160,11 @@ static int options_show(struct seq_file *s, void *p)
160static ssize_t options_write(struct file *file, const char __user *userbuf, 160static ssize_t options_write(struct file *file, const char __user *userbuf,
161 size_t count, loff_t *data) 161 size_t count, loff_t *data)
162{ 162{
163 char buf[20]; 163 int ret;
164 164
165 if (count >= sizeof(buf)) 165 ret = kstrtoul_from_user(userbuf, count, 0, &gru_options);
166 return -EINVAL; 166 if (ret)
167 if (copy_from_user(buf, userbuf, count)) 167 return ret;
168 return -EFAULT;
169 buf[count] = '\0';
170 if (strict_strtoul(buf, 0, &gru_options))
171 return -EINVAL;
172 168
173 return count; 169 return count;
174} 170}
diff --git a/drivers/misc/spear13xx_pcie_gadget.c b/drivers/misc/spear13xx_pcie_gadget.c
index 7deb25dc86a7..2e13614d41e8 100644
--- a/drivers/misc/spear13xx_pcie_gadget.c
+++ b/drivers/misc/spear13xx_pcie_gadget.c
@@ -316,8 +316,12 @@ static ssize_t pcie_gadget_store_no_of_msi(
316 struct spear_pcie_gadget_config *config, 316 struct spear_pcie_gadget_config *config,
317 const char *buf, size_t count) 317 const char *buf, size_t count)
318{ 318{
319 if (strict_strtoul(buf, 0, &config->requested_msi)) 319 int ret;
320 return -EINVAL; 320
321 ret = kstrtoul(buf, 0, &config->requested_msi);
322 if (ret)
323 return ret;
324
321 if (config->requested_msi > 32) 325 if (config->requested_msi > 32)
322 config->requested_msi = 32; 326 config->requested_msi = 32;
323 327
@@ -330,9 +334,11 @@ static ssize_t pcie_gadget_store_inta(
330{ 334{
331 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 335 struct pcie_app_reg __iomem *app_reg = config->va_app_base;
332 ulong en; 336 ulong en;
337 int ret;
333 338
334 if (strict_strtoul(buf, 0, &en)) 339 ret = kstrtoul(buf, 0, &en);
335 return -EINVAL; 340 if (ret)
341 return ret;
336 342
337 if (en) 343 if (en)
338 writel(readl(&app_reg->app_ctrl_0) | (1 << SYS_INT_ID), 344 writel(readl(&app_reg->app_ctrl_0) | (1 << SYS_INT_ID),
@@ -351,9 +357,11 @@ static ssize_t pcie_gadget_store_send_msi(
351 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 357 struct pcie_app_reg __iomem *app_reg = config->va_app_base;
352 ulong vector; 358 ulong vector;
353 u32 ven_msi; 359 u32 ven_msi;
360 int ret;
354 361
355 if (strict_strtoul(buf, 0, &vector)) 362 ret = kstrtoul(buf, 0, &vector);
356 return -EINVAL; 363 if (ret)
364 return ret;
357 365
358 if (!config->configured_msi) 366 if (!config->configured_msi)
359 return -EINVAL; 367 return -EINVAL;
@@ -395,9 +403,11 @@ static ssize_t pcie_gadget_store_vendor_id(
395 const char *buf, size_t count) 403 const char *buf, size_t count)
396{ 404{
397 ulong id; 405 ulong id;
406 int ret;
398 407
399 if (strict_strtoul(buf, 0, &id)) 408 ret = kstrtoul(buf, 0, &id);
400 return -EINVAL; 409 if (ret)
410 return ret;
401 411
402 spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id); 412 spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id);
403 413
@@ -420,9 +430,11 @@ static ssize_t pcie_gadget_store_device_id(
420 const char *buf, size_t count) 430 const char *buf, size_t count)
421{ 431{
422 ulong id; 432 ulong id;
433 int ret;
423 434
424 if (strict_strtoul(buf, 0, &id)) 435 ret = kstrtoul(buf, 0, &id);
425 return -EINVAL; 436 if (ret)
437 return ret;
426 438
427 spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id); 439 spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id);
428 440
@@ -443,9 +455,12 @@ static ssize_t pcie_gadget_store_bar0_size(
443 ulong size; 455 ulong size;
444 u32 pos, pos1; 456 u32 pos, pos1;
445 u32 no_of_bit = 0; 457 u32 no_of_bit = 0;
458 int ret;
459
460 ret = kstrtoul(buf, 0, &size);
461 if (ret)
462 return ret;
446 463
447 if (strict_strtoul(buf, 0, &size))
448 return -EINVAL;
449 /* min bar size is 256 */ 464 /* min bar size is 256 */
450 if (size <= 0x100) 465 if (size <= 0x100)
451 size = 0x100; 466 size = 0x100;
@@ -490,9 +505,11 @@ static ssize_t pcie_gadget_store_bar0_address(
490{ 505{
491 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 506 struct pcie_app_reg __iomem *app_reg = config->va_app_base;
492 ulong address; 507 ulong address;
508 int ret;
493 509
494 if (strict_strtoul(buf, 0, &address)) 510 ret = kstrtoul(buf, 0, &address);
495 return -EINVAL; 511 if (ret)
512 return ret;
496 513
497 address &= ~(config->bar0_size - 1); 514 address &= ~(config->bar0_size - 1);
498 if (config->va_bar0_address) 515 if (config->va_bar0_address)
@@ -518,9 +535,11 @@ static ssize_t pcie_gadget_store_bar0_rw_offset(
518 const char *buf, size_t count) 535 const char *buf, size_t count)
519{ 536{
520 ulong offset; 537 ulong offset;
538 int ret;
521 539
522 if (strict_strtoul(buf, 0, &offset)) 540 ret = kstrtoul(buf, 0, &offset);
523 return -EINVAL; 541 if (ret)
542 return ret;
524 543
525 if (offset % 4) 544 if (offset % 4)
526 return -EINVAL; 545 return -EINVAL;
@@ -549,9 +568,11 @@ static ssize_t pcie_gadget_store_bar0_data(
549 const char *buf, size_t count) 568 const char *buf, size_t count)
550{ 569{
551 ulong data; 570 ulong data;
571 int ret;
552 572
553 if (strict_strtoul(buf, 0, &data)) 573 ret = kstrtoul(buf, 0, &data);
554 return -EINVAL; 574 if (ret)
575 return ret;
555 576
556 if (!config->va_bar0_address) 577 if (!config->va_bar0_address)
557 return -ENOMEM; 578 return -ENOMEM;
@@ -776,7 +797,7 @@ static int spear_pcie_gadget_probe(struct platform_device *pdev)
776 goto err_iounmap_app; 797 goto err_iounmap_app;
777 } 798 }
778 799
779 dev_set_drvdata(&pdev->dev, target); 800 platform_set_drvdata(pdev, target);
780 801
781 irq = platform_get_irq(pdev, 0); 802 irq = platform_get_irq(pdev, 0);
782 if (irq < 0) { 803 if (irq < 0) {
@@ -814,9 +835,11 @@ static int spear_pcie_gadget_probe(struct platform_device *pdev)
814 clk = clk_get_sys("pcie1", NULL); 835 clk = clk_get_sys("pcie1", NULL);
815 if (IS_ERR(clk)) { 836 if (IS_ERR(clk)) {
816 pr_err("%s:couldn't get clk for pcie1\n", __func__); 837 pr_err("%s:couldn't get clk for pcie1\n", __func__);
838 status = PTR_ERR(clk);
817 goto err_irq; 839 goto err_irq;
818 } 840 }
819 if (clk_enable(clk)) { 841 status = clk_enable(clk);
842 if (status) {
820 pr_err("%s:couldn't enable clk for pcie1\n", __func__); 843 pr_err("%s:couldn't enable clk for pcie1\n", __func__);
821 goto err_irq; 844 goto err_irq;
822 } 845 }
@@ -828,9 +851,11 @@ static int spear_pcie_gadget_probe(struct platform_device *pdev)
828 clk = clk_get_sys("pcie2", NULL); 851 clk = clk_get_sys("pcie2", NULL);
829 if (IS_ERR(clk)) { 852 if (IS_ERR(clk)) {
830 pr_err("%s:couldn't get clk for pcie2\n", __func__); 853 pr_err("%s:couldn't get clk for pcie2\n", __func__);
854 status = PTR_ERR(clk);
831 goto err_irq; 855 goto err_irq;
832 } 856 }
833 if (clk_enable(clk)) { 857 status = clk_enable(clk);
858 if (status) {
834 pr_err("%s:couldn't enable clk for pcie2\n", __func__); 859 pr_err("%s:couldn't enable clk for pcie2\n", __func__);
835 goto err_irq; 860 goto err_irq;
836 } 861 }
@@ -863,7 +888,7 @@ static int spear_pcie_gadget_remove(struct platform_device *pdev)
863 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 888 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
864 res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 889 res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
865 irq = platform_get_irq(pdev, 0); 890 irq = platform_get_irq(pdev, 0);
866 target = dev_get_drvdata(&pdev->dev); 891 target = platform_get_drvdata(pdev);
867 config = &target->config; 892 config = &target->config;
868 893
869 free_irq(irq, NULL); 894 free_irq(irq, NULL);
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index 437192e43006..4a938860fec0 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -50,9 +50,10 @@ static int sram_probe(struct platform_device *pdev)
50 50
51 size = resource_size(res); 51 size = resource_size(res);
52 52
53 virt_base = devm_request_and_ioremap(&pdev->dev, res); 53 virt_base = devm_ioremap_resource(&pdev->dev, res);
54 if (!virt_base) 54 if (IS_ERR(virt_base))
55 return -EADDRNOTAVAIL; 55 return PTR_ERR(virt_base);
56
56 57
57 sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL); 58 sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL);
58 if (!sram) 59 if (!sram)
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 83269f1d16e3..83907c720594 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -680,7 +680,7 @@ void st_kim_ref(struct st_data_s **core_data, int id)
680 *core_data = NULL; 680 *core_data = NULL;
681 return; 681 return;
682 } 682 }
683 kim_gdata = dev_get_drvdata(&pdev->dev); 683 kim_gdata = platform_get_drvdata(pdev);
684 *core_data = kim_gdata->core_data; 684 *core_data = kim_gdata->core_data;
685} 685}
686 686
@@ -735,7 +735,7 @@ static int kim_probe(struct platform_device *pdev)
735 pr_err("no mem to allocate"); 735 pr_err("no mem to allocate");
736 return -ENOMEM; 736 return -ENOMEM;
737 } 737 }
738 dev_set_drvdata(&pdev->dev, kim_gdata); 738 platform_set_drvdata(pdev, kim_gdata);
739 739
740 err = st_core_init(&kim_gdata->core_data); 740 err = st_core_init(&kim_gdata->core_data);
741 if (err != 0) { 741 if (err != 0) {
@@ -810,7 +810,7 @@ static int kim_remove(struct platform_device *pdev)
810 struct ti_st_plat_data *pdata = pdev->dev.platform_data; 810 struct ti_st_plat_data *pdata = pdev->dev.platform_data;
811 struct kim_data_s *kim_gdata; 811 struct kim_data_s *kim_gdata;
812 812
813 kim_gdata = dev_get_drvdata(&pdev->dev); 813 kim_gdata = platform_get_drvdata(pdev);
814 814
815 /* Free the Bluetooth/FM/GPIO 815 /* Free the Bluetooth/FM/GPIO
816 * nShutdown gpio from the system 816 * nShutdown gpio from the system
diff --git a/drivers/misc/ti_dac7512.c b/drivers/misc/ti_dac7512.c
index 1d86407189eb..9b237221bc4e 100644
--- a/drivers/misc/ti_dac7512.c
+++ b/drivers/misc/ti_dac7512.c
@@ -33,9 +33,11 @@ static ssize_t dac7512_store_val(struct device *dev,
33 struct spi_device *spi = to_spi_device(dev); 33 struct spi_device *spi = to_spi_device(dev);
34 unsigned char tmp[2]; 34 unsigned char tmp[2];
35 unsigned long val; 35 unsigned long val;
36 int ret;
36 37
37 if (strict_strtoul(buf, 10, &val) < 0) 38 ret = kstrtoul(buf, 10, &val);
38 return -EINVAL; 39 if (ret)
40 return ret;
39 41
40 tmp[0] = val >> 8; 42 tmp[0] = val >> 8;
41 tmp[1] = val & 0xff; 43 tmp[1] = val & 0xff;
diff --git a/drivers/misc/tsl2550.c b/drivers/misc/tsl2550.c
index 1dfde4d543db..5bc10fa193de 100644
--- a/drivers/misc/tsl2550.c
+++ b/drivers/misc/tsl2550.c
@@ -204,7 +204,7 @@ static ssize_t tsl2550_store_power_state(struct device *dev,
204 unsigned long val = simple_strtoul(buf, NULL, 10); 204 unsigned long val = simple_strtoul(buf, NULL, 10);
205 int ret; 205 int ret;
206 206
207 if (val < 0 || val > 1) 207 if (val > 1)
208 return -EINVAL; 208 return -EINVAL;
209 209
210 mutex_lock(&data->update_lock); 210 mutex_lock(&data->update_lock);
@@ -236,7 +236,7 @@ static ssize_t tsl2550_store_operating_mode(struct device *dev,
236 unsigned long val = simple_strtoul(buf, NULL, 10); 236 unsigned long val = simple_strtoul(buf, NULL, 10);
237 int ret; 237 int ret;
238 238
239 if (val < 0 || val > 1) 239 if (val > 1)
240 return -EINVAL; 240 return -EINVAL;
241 241
242 if (data->power_state == 0) 242 if (data->power_state == 0)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 59ac143dec25..4f777ed9b089 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -40,6 +40,7 @@
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/console.h> 41#include <linux/console.h>
42#include <linux/moduleparam.h> 42#include <linux/moduleparam.h>
43#include <linux/kernel.h>
43#include <linux/string.h> 44#include <linux/string.h>
44#include <linux/netpoll.h> 45#include <linux/netpoll.h>
45#include <linux/inet.h> 46#include <linux/inet.h>
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index b90f85bf5f81..80faa56c684d 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -288,7 +288,7 @@ config BFIN_CFPCMCIA
288 288
289config AT91_CF 289config AT91_CF
290 tristate "AT91 CompactFlash Controller" 290 tristate "AT91 CompactFlash Controller"
291 depends on PCMCIA && ARCH_AT91RM9200 291 depends on PCMCIA && ARCH_AT91
292 help 292 help
293 Say Y here to support the CompactFlash controller on AT91 chips. 293 Say Y here to support the CompactFlash controller on AT91 chips.
294 Or choose M to compile the driver as a module named "at91_cf". 294 Or choose M to compile the driver as a module named "at91_cf".
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 01463c781847..b8f5acf02261 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -18,13 +18,14 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/gpio.h> 19#include <linux/gpio.h>
20#include <linux/platform_data/atmel.h> 20#include <linux/platform_data/atmel.h>
21#include <linux/io.h>
22#include <linux/sizes.h>
23#include <linux/of.h>
24#include <linux/of_device.h>
25#include <linux/of_gpio.h>
21 26
22#include <pcmcia/ss.h> 27#include <pcmcia/ss.h>
23 28
24#include <mach/hardware.h>
25#include <asm/io.h>
26#include <asm/sizes.h>
27
28#include <mach/at91rm9200_mc.h> 29#include <mach/at91rm9200_mc.h>
29#include <mach/at91_ramc.h> 30#include <mach/at91_ramc.h>
30 31
@@ -41,8 +42,6 @@
41 42
42/*--------------------------------------------------------------------------*/ 43/*--------------------------------------------------------------------------*/
43 44
44static const char driver_name[] = "at91_cf";
45
46struct at91_cf_socket { 45struct at91_cf_socket {
47 struct pcmcia_socket socket; 46 struct pcmcia_socket socket;
48 47
@@ -76,7 +75,7 @@ static irqreturn_t at91_cf_irq(int irq, void *_cf)
76 /* kick pccard as needed */ 75 /* kick pccard as needed */
77 if (present != cf->present) { 76 if (present != cf->present) {
78 cf->present = present; 77 cf->present = present;
79 pr_debug("%s: card %s\n", driver_name, 78 dev_dbg(&cf->pdev->dev, "card %s\n",
80 present ? "present" : "gone"); 79 present ? "present" : "gone");
81 pcmcia_parse_events(&cf->socket, SS_DETECT); 80 pcmcia_parse_events(&cf->socket, SS_DETECT);
82 } 81 }
@@ -100,9 +99,9 @@ static int at91_cf_get_status(struct pcmcia_socket *s, u_int *sp)
100 int vcc = gpio_is_valid(cf->board->vcc_pin); 99 int vcc = gpio_is_valid(cf->board->vcc_pin);
101 100
102 *sp = SS_DETECT | SS_3VCARD; 101 *sp = SS_DETECT | SS_3VCARD;
103 if (!rdy || gpio_get_value(rdy)) 102 if (!rdy || gpio_get_value(cf->board->irq_pin))
104 *sp |= SS_READY; 103 *sp |= SS_READY;
105 if (!vcc || gpio_get_value(vcc)) 104 if (!vcc || gpio_get_value(cf->board->vcc_pin))
106 *sp |= SS_POWERON; 105 *sp |= SS_POWERON;
107 } else 106 } else
108 *sp = 0; 107 *sp = 0;
@@ -120,22 +119,22 @@ at91_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
120 /* switch Vcc if needed and possible */ 119 /* switch Vcc if needed and possible */
121 if (gpio_is_valid(cf->board->vcc_pin)) { 120 if (gpio_is_valid(cf->board->vcc_pin)) {
122 switch (s->Vcc) { 121 switch (s->Vcc) {
123 case 0: 122 case 0:
124 gpio_set_value(cf->board->vcc_pin, 0); 123 gpio_set_value(cf->board->vcc_pin, 0);
125 break; 124 break;
126 case 33: 125 case 33:
127 gpio_set_value(cf->board->vcc_pin, 1); 126 gpio_set_value(cf->board->vcc_pin, 1);
128 break; 127 break;
129 default: 128 default:
130 return -EINVAL; 129 return -EINVAL;
131 } 130 }
132 } 131 }
133 132
134 /* toggle reset if needed */ 133 /* toggle reset if needed */
135 gpio_set_value(cf->board->rst_pin, s->flags & SS_RESET); 134 gpio_set_value(cf->board->rst_pin, s->flags & SS_RESET);
136 135
137 pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n", 136 dev_dbg(&cf->pdev->dev, "Vcc %d, io_irq %d, flags %04x csc %04x\n",
138 driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask); 137 s->Vcc, s->io_irq, s->flags, s->csc_mask);
139 138
140 return 0; 139 return 0;
141} 140}
@@ -171,10 +170,10 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
171 */ 170 */
172 if (!(io->flags & (MAP_16BIT | MAP_AUTOSZ))) { 171 if (!(io->flags & (MAP_16BIT | MAP_AUTOSZ))) {
173 csr |= AT91_SMC_DBW_8; 172 csr |= AT91_SMC_DBW_8;
174 pr_debug("%s: 8bit i/o bus\n", driver_name); 173 dev_dbg(&cf->pdev->dev, "8bit i/o bus\n");
175 } else { 174 } else {
176 csr |= AT91_SMC_DBW_16; 175 csr |= AT91_SMC_DBW_16;
177 pr_debug("%s: 16bit i/o bus\n", driver_name); 176 dev_dbg(&cf->pdev->dev, "16bit i/o bus\n");
178 } 177 }
179 at91_ramc_write(0, AT91_SMC_CSR(cf->board->chipselect), csr); 178 at91_ramc_write(0, AT91_SMC_CSR(cf->board->chipselect), csr);
180 179
@@ -215,6 +214,37 @@ static struct pccard_operations at91_cf_ops = {
215 214
216/*--------------------------------------------------------------------------*/ 215/*--------------------------------------------------------------------------*/
217 216
217#if defined(CONFIG_OF)
218static const struct of_device_id at91_cf_dt_ids[] = {
219 { .compatible = "atmel,at91rm9200-cf" },
220 { /* sentinel */ }
221};
222MODULE_DEVICE_TABLE(of, at91_cf_dt_ids);
223
224static int at91_cf_dt_init(struct platform_device *pdev)
225{
226 struct at91_cf_data *board;
227
228 board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL);
229 if (!board)
230 return -ENOMEM;
231
232 board->irq_pin = of_get_gpio(pdev->dev.of_node, 0);
233 board->det_pin = of_get_gpio(pdev->dev.of_node, 1);
234 board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2);
235 board->rst_pin = of_get_gpio(pdev->dev.of_node, 3);
236
237 pdev->dev.platform_data = board;
238
239 return 0;
240}
241#else
242static int at91_cf_dt_init(struct platform_device *pdev)
243{
244 return -ENODEV;
245}
246#endif
247
218static int __init at91_cf_probe(struct platform_device *pdev) 248static int __init at91_cf_probe(struct platform_device *pdev)
219{ 249{
220 struct at91_cf_socket *cf; 250 struct at91_cf_socket *cf;
@@ -222,14 +252,22 @@ static int __init at91_cf_probe(struct platform_device *pdev)
222 struct resource *io; 252 struct resource *io;
223 int status; 253 int status;
224 254
225 if (!board || !gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin)) 255 if (!board) {
256 status = at91_cf_dt_init(pdev);
257 if (status)
258 return status;
259
260 board = pdev->dev.platform_data;
261 }
262
263 if (!gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
226 return -ENODEV; 264 return -ENODEV;
227 265
228 io = platform_get_resource(pdev, IORESOURCE_MEM, 0); 266 io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
229 if (!io) 267 if (!io)
230 return -ENODEV; 268 return -ENODEV;
231 269
232 cf = kzalloc(sizeof *cf, GFP_KERNEL); 270 cf = devm_kzalloc(&pdev->dev, sizeof(*cf), GFP_KERNEL);
233 if (!cf) 271 if (!cf)
234 return -ENOMEM; 272 return -ENOMEM;
235 273
@@ -239,22 +277,25 @@ static int __init at91_cf_probe(struct platform_device *pdev)
239 platform_set_drvdata(pdev, cf); 277 platform_set_drvdata(pdev, cf);
240 278
241 /* must be a GPIO; ergo must trigger on both edges */ 279 /* must be a GPIO; ergo must trigger on both edges */
242 status = gpio_request(board->det_pin, "cf_det"); 280 status = devm_gpio_request(&pdev->dev, board->det_pin, "cf_det");
243 if (status < 0) 281 if (status < 0)
244 goto fail0; 282 return status;
245 status = request_irq(gpio_to_irq(board->det_pin), at91_cf_irq, 0, driver_name, cf); 283
284 status = devm_request_irq(&pdev->dev, gpio_to_irq(board->det_pin),
285 at91_cf_irq, 0, "at91_cf detect", cf);
246 if (status < 0) 286 if (status < 0)
247 goto fail00; 287 return status;
288
248 device_init_wakeup(&pdev->dev, 1); 289 device_init_wakeup(&pdev->dev, 1);
249 290
250 status = gpio_request(board->rst_pin, "cf_rst"); 291 status = devm_gpio_request(&pdev->dev, board->rst_pin, "cf_rst");
251 if (status < 0) 292 if (status < 0)
252 goto fail0a; 293 goto fail0a;
253 294
254 if (gpio_is_valid(board->vcc_pin)) { 295 if (gpio_is_valid(board->vcc_pin)) {
255 status = gpio_request(board->vcc_pin, "cf_vcc"); 296 status = devm_gpio_request(&pdev->dev, board->vcc_pin, "cf_vcc");
256 if (status < 0) 297 if (status < 0)
257 goto fail0b; 298 goto fail0a;
258 } 299 }
259 300
260 /* 301 /*
@@ -264,32 +305,33 @@ static int __init at91_cf_probe(struct platform_device *pdev)
264 * (Note: DK board doesn't wire the IRQ pin...) 305 * (Note: DK board doesn't wire the IRQ pin...)
265 */ 306 */
266 if (gpio_is_valid(board->irq_pin)) { 307 if (gpio_is_valid(board->irq_pin)) {
267 status = gpio_request(board->irq_pin, "cf_irq"); 308 status = devm_gpio_request(&pdev->dev, board->irq_pin, "cf_irq");
268 if (status < 0) 309 if (status < 0)
269 goto fail0c; 310 goto fail0a;
270 status = request_irq(gpio_to_irq(board->irq_pin), at91_cf_irq, 311
271 IRQF_SHARED, driver_name, cf); 312 status = devm_request_irq(&pdev->dev, gpio_to_irq(board->irq_pin),
313 at91_cf_irq, IRQF_SHARED, "at91_cf", cf);
272 if (status < 0) 314 if (status < 0)
273 goto fail0d; 315 goto fail0a;
274 cf->socket.pci_irq = gpio_to_irq(board->irq_pin); 316 cf->socket.pci_irq = gpio_to_irq(board->irq_pin);
275 } else 317 } else
276 cf->socket.pci_irq = nr_irqs + 1; 318 cf->socket.pci_irq = nr_irqs + 1;
277 319
278 /* pcmcia layer only remaps "real" memory not iospace */ 320 /* pcmcia layer only remaps "real" memory not iospace */
279 cf->socket.io_offset = (unsigned long) 321 cf->socket.io_offset = (unsigned long) devm_ioremap(&pdev->dev,
280 ioremap(cf->phys_baseaddr + CF_IO_PHYS, SZ_2K); 322 cf->phys_baseaddr + CF_IO_PHYS, SZ_2K);
281 if (!cf->socket.io_offset) { 323 if (!cf->socket.io_offset) {
282 status = -ENXIO; 324 status = -ENXIO;
283 goto fail1; 325 goto fail0a;
284 } 326 }
285 327
286 /* reserve chip-select regions */ 328 /* reserve chip-select regions */
287 if (!request_mem_region(io->start, resource_size(io), driver_name)) { 329 if (!devm_request_mem_region(&pdev->dev, io->start, resource_size(io), "at91_cf")) {
288 status = -ENXIO; 330 status = -ENXIO;
289 goto fail1; 331 goto fail0a;
290 } 332 }
291 333
292 pr_info("%s: irqs det #%d, io #%d\n", driver_name, 334 dev_info(&pdev->dev, "irqs det #%d, io #%d\n",
293 gpio_to_irq(board->det_pin), gpio_to_irq(board->irq_pin)); 335 gpio_to_irq(board->det_pin), gpio_to_irq(board->irq_pin));
294 336
295 cf->socket.owner = THIS_MODULE; 337 cf->socket.owner = THIS_MODULE;
@@ -303,55 +345,22 @@ static int __init at91_cf_probe(struct platform_device *pdev)
303 345
304 status = pcmcia_register_socket(&cf->socket); 346 status = pcmcia_register_socket(&cf->socket);
305 if (status < 0) 347 if (status < 0)
306 goto fail2; 348 goto fail0a;
307 349
308 return 0; 350 return 0;
309 351
310fail2:
311 release_mem_region(io->start, resource_size(io));
312fail1:
313 if (cf->socket.io_offset)
314 iounmap((void __iomem *) cf->socket.io_offset);
315 if (gpio_is_valid(board->irq_pin)) {
316 free_irq(gpio_to_irq(board->irq_pin), cf);
317fail0d:
318 gpio_free(board->irq_pin);
319 }
320fail0c:
321 if (gpio_is_valid(board->vcc_pin))
322 gpio_free(board->vcc_pin);
323fail0b:
324 gpio_free(board->rst_pin);
325fail0a: 352fail0a:
326 device_init_wakeup(&pdev->dev, 0); 353 device_init_wakeup(&pdev->dev, 0);
327 free_irq(gpio_to_irq(board->det_pin), cf);
328fail00:
329 gpio_free(board->det_pin);
330fail0:
331 kfree(cf);
332 return status; 354 return status;
333} 355}
334 356
335static int __exit at91_cf_remove(struct platform_device *pdev) 357static int __exit at91_cf_remove(struct platform_device *pdev)
336{ 358{
337 struct at91_cf_socket *cf = platform_get_drvdata(pdev); 359 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
338 struct at91_cf_data *board = cf->board;
339 struct resource *io = cf->socket.io[0].res;
340 360
341 pcmcia_unregister_socket(&cf->socket); 361 pcmcia_unregister_socket(&cf->socket);
342 release_mem_region(io->start, resource_size(io));
343 iounmap((void __iomem *) cf->socket.io_offset);
344 if (gpio_is_valid(board->irq_pin)) {
345 free_irq(gpio_to_irq(board->irq_pin), cf);
346 gpio_free(board->irq_pin);
347 }
348 if (gpio_is_valid(board->vcc_pin))
349 gpio_free(board->vcc_pin);
350 gpio_free(board->rst_pin);
351 device_init_wakeup(&pdev->dev, 0); 362 device_init_wakeup(&pdev->dev, 0);
352 free_irq(gpio_to_irq(board->det_pin), cf); 363
353 gpio_free(board->det_pin);
354 kfree(cf);
355 return 0; 364 return 0;
356} 365}
357 366
@@ -391,8 +400,9 @@ static int at91_cf_resume(struct platform_device *pdev)
391 400
392static struct platform_driver at91_cf_driver = { 401static struct platform_driver at91_cf_driver = {
393 .driver = { 402 .driver = {
394 .name = (char *) driver_name, 403 .name = "at91_cf",
395 .owner = THIS_MODULE, 404 .owner = THIS_MODULE,
405 .of_match_table = of_match_ptr(at91_cf_dt_ids),
396 }, 406 },
397 .remove = __exit_p(at91_cf_remove), 407 .remove = __exit_p(at91_cf_remove),
398 .suspend = at91_cf_suspend, 408 .suspend = at91_cf_suspend,
@@ -401,17 +411,7 @@ static struct platform_driver at91_cf_driver = {
401 411
402/*--------------------------------------------------------------------------*/ 412/*--------------------------------------------------------------------------*/
403 413
404static int __init at91_cf_init(void) 414module_platform_driver_probe(at91_cf_driver, at91_cf_probe);
405{
406 return platform_driver_probe(&at91_cf_driver, at91_cf_probe);
407}
408module_init(at91_cf_init);
409
410static void __exit at91_cf_exit(void)
411{
412 platform_driver_unregister(&at91_cf_driver);
413}
414module_exit(at91_cf_exit);
415 415
416MODULE_DESCRIPTION("AT91 Compact Flash Driver"); 416MODULE_DESCRIPTION("AT91 Compact Flash Driver");
417MODULE_AUTHOR("David Brownell"); 417MODULE_AUTHOR("David Brownell");
diff --git a/drivers/uio/uio_aec.c b/drivers/uio/uio_aec.c
index 1548982db58b..f3611c2d83b6 100644
--- a/drivers/uio/uio_aec.c
+++ b/drivers/uio/uio_aec.c
@@ -160,17 +160,5 @@ static struct pci_driver pci_driver = {
160 .remove = remove, 160 .remove = remove,
161}; 161};
162 162
163static int __init aectc_init(void) 163module_pci_driver(pci_driver);
164{
165 return pci_register_driver(&pci_driver);
166}
167
168static void __exit aectc_exit(void)
169{
170 pci_unregister_driver(&pci_driver);
171}
172
173MODULE_LICENSE("GPL"); 164MODULE_LICENSE("GPL");
174
175module_init(aectc_init);
176module_exit(aectc_exit);
diff --git a/drivers/uio/uio_cif.c b/drivers/uio/uio_cif.c
index 7dd6fc60539d..22cdf385ab33 100644
--- a/drivers/uio/uio_cif.c
+++ b/drivers/uio/uio_cif.c
@@ -135,19 +135,7 @@ static struct pci_driver hilscher_pci_driver = {
135 .remove = hilscher_pci_remove, 135 .remove = hilscher_pci_remove,
136}; 136};
137 137
138static int __init hilscher_init_module(void) 138module_pci_driver(hilscher_pci_driver);
139{
140 return pci_register_driver(&hilscher_pci_driver);
141}
142
143static void __exit hilscher_exit_module(void)
144{
145 pci_unregister_driver(&hilscher_pci_driver);
146}
147
148module_init(hilscher_init_module);
149module_exit(hilscher_exit_module);
150
151MODULE_DEVICE_TABLE(pci, hilscher_pci_ids); 139MODULE_DEVICE_TABLE(pci, hilscher_pci_ids);
152MODULE_LICENSE("GPL v2"); 140MODULE_LICENSE("GPL v2");
153MODULE_AUTHOR("Hans J. Koch, Benedikt Spranger"); 141MODULE_AUTHOR("Hans J. Koch, Benedikt Spranger");
diff --git a/drivers/uio/uio_netx.c b/drivers/uio/uio_netx.c
index 6a4ba5e83e37..28a766b9e198 100644
--- a/drivers/uio/uio_netx.c
+++ b/drivers/uio/uio_netx.c
@@ -174,19 +174,7 @@ static struct pci_driver netx_pci_driver = {
174 .remove = netx_pci_remove, 174 .remove = netx_pci_remove,
175}; 175};
176 176
177static int __init netx_init_module(void) 177module_pci_driver(netx_pci_driver);
178{
179 return pci_register_driver(&netx_pci_driver);
180}
181
182static void __exit netx_exit_module(void)
183{
184 pci_unregister_driver(&netx_pci_driver);
185}
186
187module_init(netx_init_module);
188module_exit(netx_exit_module);
189
190MODULE_DEVICE_TABLE(pci, netx_pci_ids); 178MODULE_DEVICE_TABLE(pci, netx_pci_ids);
191MODULE_LICENSE("GPL v2"); 179MODULE_LICENSE("GPL v2");
192MODULE_AUTHOR("Hans J. Koch, Manuel Traut"); 180MODULE_AUTHOR("Hans J. Koch, Manuel Traut");
diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
index 14aa10c1f6de..077ae12269ce 100644
--- a/drivers/uio/uio_pci_generic.c
+++ b/drivers/uio/uio_pci_generic.c
@@ -113,27 +113,14 @@ static void remove(struct pci_dev *pdev)
113 kfree(gdev); 113 kfree(gdev);
114} 114}
115 115
116static struct pci_driver driver = { 116static struct pci_driver uio_pci_driver = {
117 .name = "uio_pci_generic", 117 .name = "uio_pci_generic",
118 .id_table = NULL, /* only dynamic id's */ 118 .id_table = NULL, /* only dynamic id's */
119 .probe = probe, 119 .probe = probe,
120 .remove = remove, 120 .remove = remove,
121}; 121};
122 122
123static int __init init(void) 123module_pci_driver(uio_pci_driver);
124{
125 pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
126 return pci_register_driver(&driver);
127}
128
129static void __exit cleanup(void)
130{
131 pci_unregister_driver(&driver);
132}
133
134module_init(init);
135module_exit(cleanup);
136
137MODULE_VERSION(DRIVER_VERSION); 124MODULE_VERSION(DRIVER_VERSION);
138MODULE_LICENSE("GPL v2"); 125MODULE_LICENSE("GPL v2");
139MODULE_AUTHOR(DRIVER_AUTHOR); 126MODULE_AUTHOR(DRIVER_AUTHOR);
diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index 6e2ab007fe9c..21f7a72301e4 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -136,9 +136,9 @@ static int pruss_probe(struct platform_device *dev)
136 gdev->pruss_clk = clk_get(&dev->dev, "pruss"); 136 gdev->pruss_clk = clk_get(&dev->dev, "pruss");
137 if (IS_ERR(gdev->pruss_clk)) { 137 if (IS_ERR(gdev->pruss_clk)) {
138 dev_err(&dev->dev, "Failed to get clock\n"); 138 dev_err(&dev->dev, "Failed to get clock\n");
139 ret = PTR_ERR(gdev->pruss_clk);
139 kfree(gdev->info); 140 kfree(gdev->info);
140 kfree(gdev); 141 kfree(gdev);
141 ret = PTR_ERR(gdev->pruss_clk);
142 return ret; 142 return ret;
143 } else { 143 } else {
144 clk_enable(gdev->pruss_clk); 144 clk_enable(gdev->pruss_clk);
diff --git a/drivers/uio/uio_sercos3.c b/drivers/uio/uio_sercos3.c
index 81a10a563120..541983217085 100644
--- a/drivers/uio/uio_sercos3.c
+++ b/drivers/uio/uio_sercos3.c
@@ -226,19 +226,7 @@ static struct pci_driver sercos3_pci_driver = {
226 .remove = sercos3_pci_remove, 226 .remove = sercos3_pci_remove,
227}; 227};
228 228
229static int __init sercos3_init_module(void) 229module_pci_driver(sercos3_pci_driver);
230{
231 return pci_register_driver(&sercos3_pci_driver);
232}
233
234static void __exit sercos3_exit_module(void)
235{
236 pci_unregister_driver(&sercos3_pci_driver);
237}
238
239module_init(sercos3_init_module);
240module_exit(sercos3_exit_module);
241
242MODULE_DESCRIPTION("UIO driver for the Automata Sercos III PCI card"); 230MODULE_DESCRIPTION("UIO driver for the Automata Sercos III PCI card");
243MODULE_AUTHOR("John Ogness <john.ogness@linutronix.de>"); 231MODULE_AUTHOR("John Ogness <john.ogness@linutronix.de>");
244MODULE_LICENSE("GPL v2"); 232MODULE_LICENSE("GPL v2");
diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 5e6c7d74e19f..f6856b427496 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -959,6 +959,8 @@ int vme_dma_free(struct vme_resource *resource)
959 959
960 mutex_unlock(&ctrlr->mtx); 960 mutex_unlock(&ctrlr->mtx);
961 961
962 kfree(resource);
963
962 return 0; 964 return 0;
963} 965}
964EXPORT_SYMBOL(vme_dma_free); 966EXPORT_SYMBOL(vme_dma_free);
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index 46d97014342e..f54ece268c98 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -16,7 +16,6 @@
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/of_platform.h> 17#include <linux/of_platform.h>
18#include <linux/of_gpio.h> 18#include <linux/of_gpio.h>
19#include <linux/pinctrl/consumer.h>
20#include <linux/err.h> 19#include <linux/err.h>
21#include <linux/of.h> 20#include <linux/of.h>
22 21
@@ -78,13 +77,8 @@ static int w1_gpio_probe(struct platform_device *pdev)
78{ 77{
79 struct w1_bus_master *master; 78 struct w1_bus_master *master;
80 struct w1_gpio_platform_data *pdata; 79 struct w1_gpio_platform_data *pdata;
81 struct pinctrl *pinctrl;
82 int err; 80 int err;
83 81
84 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
85 if (IS_ERR(pinctrl))
86 dev_warn(&pdev->dev, "unable to select pin group\n");
87
88 if (of_have_populated_dt()) { 82 if (of_have_populated_dt()) {
89 err = w1_gpio_probe_dt(pdev); 83 err = w1_gpio_probe_dt(pdev);
90 if (err < 0) { 84 if (err < 0) {
diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c
index e45eca1044bd..91cc2cdf02c0 100644
--- a/drivers/w1/slaves/w1_ds2408.c
+++ b/drivers/w1/slaves/w1_ds2408.c
@@ -22,6 +22,7 @@
22MODULE_LICENSE("GPL"); 22MODULE_LICENSE("GPL");
23MODULE_AUTHOR("Jean-Francois Dagenais <dagenaisj@sonatest.com>"); 23MODULE_AUTHOR("Jean-Francois Dagenais <dagenaisj@sonatest.com>");
24MODULE_DESCRIPTION("w1 family 29 driver for DS2408 8 Pin IO"); 24MODULE_DESCRIPTION("w1 family 29 driver for DS2408 8 Pin IO");
25MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_DS2408));
25 26
26 27
27#define W1_F29_RETRIES 3 28#define W1_F29_RETRIES 3
diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c
index 829786252c6b..85937773a96a 100644
--- a/drivers/w1/slaves/w1_ds2413.c
+++ b/drivers/w1/slaves/w1_ds2413.c
@@ -23,6 +23,7 @@
23MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
24MODULE_AUTHOR("Mariusz Bialonczyk <manio@skyboo.net>"); 24MODULE_AUTHOR("Mariusz Bialonczyk <manio@skyboo.net>");
25MODULE_DESCRIPTION("w1 family 3a driver for DS2413 2 Pin IO"); 25MODULE_DESCRIPTION("w1 family 3a driver for DS2413 2 Pin IO");
26MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_DS2413));
26 27
27#define W1_F3A_RETRIES 3 28#define W1_F3A_RETRIES 3
28#define W1_F3A_FUNC_PIO_ACCESS_READ 0xF5 29#define W1_F3A_FUNC_PIO_ACCESS_READ 0xF5
diff --git a/drivers/w1/slaves/w1_ds2423.c b/drivers/w1/slaves/w1_ds2423.c
index 40a10b5ed120..7f86aec74088 100644
--- a/drivers/w1/slaves/w1_ds2423.c
+++ b/drivers/w1/slaves/w1_ds2423.c
@@ -164,3 +164,4 @@ module_exit(w1_f1d_exit);
164MODULE_LICENSE("GPL"); 164MODULE_LICENSE("GPL");
165MODULE_AUTHOR("Mika Laitio <lamikr@pilppa.org>"); 165MODULE_AUTHOR("Mika Laitio <lamikr@pilppa.org>");
166MODULE_DESCRIPTION("w1 family 1d driver for DS2423, 4 counters and 4kb ram"); 166MODULE_DESCRIPTION("w1 family 1d driver for DS2423, 4 counters and 4kb ram");
167MODULE_ALIAS("w1-family-" __stringify(W1_COUNTER_DS2423));
diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c
index 984b30331a45..cef8605e43ec 100644
--- a/drivers/w1/slaves/w1_ds2431.c
+++ b/drivers/w1/slaves/w1_ds2431.c
@@ -310,3 +310,4 @@ module_exit(w1_f2d_fini);
310MODULE_LICENSE("GPL"); 310MODULE_LICENSE("GPL");
311MODULE_AUTHOR("Bernhard Weirich <bernhard.weirich@riedel.net>"); 311MODULE_AUTHOR("Bernhard Weirich <bernhard.weirich@riedel.net>");
312MODULE_DESCRIPTION("w1 family 2d driver for DS2431, 1kb EEPROM"); 312MODULE_DESCRIPTION("w1 family 2d driver for DS2431, 1kb EEPROM");
313MODULE_ALIAS("w1-family-" __stringify(W1_EEPROM_DS2431));
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 85f2cdb27fa2..10cc1b6176e6 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -29,6 +29,7 @@
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); 30MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
31MODULE_DESCRIPTION("w1 family 23 driver for DS2433, 4kb EEPROM"); 31MODULE_DESCRIPTION("w1 family 23 driver for DS2433, 4kb EEPROM");
32MODULE_ALIAS("w1-family-" __stringify(W1_EEPROM_DS2433));
32 33
33#define W1_EEPROM_SIZE 512 34#define W1_EEPROM_SIZE 512
34#define W1_PAGE_COUNT 16 35#define W1_PAGE_COUNT 16
diff --git a/drivers/w1/slaves/w1_ds2760.c b/drivers/w1/slaves/w1_ds2760.c
index e86a69dc411e..93719d25d849 100644
--- a/drivers/w1/slaves/w1_ds2760.c
+++ b/drivers/w1/slaves/w1_ds2760.c
@@ -203,3 +203,4 @@ module_exit(w1_ds2760_exit);
203MODULE_LICENSE("GPL"); 203MODULE_LICENSE("GPL");
204MODULE_AUTHOR("Szabolcs Gyurko <szabolcs.gyurko@tlt.hu>"); 204MODULE_AUTHOR("Szabolcs Gyurko <szabolcs.gyurko@tlt.hu>");
205MODULE_DESCRIPTION("1-wire Driver Dallas 2760 battery monitor chip"); 205MODULE_DESCRIPTION("1-wire Driver Dallas 2760 battery monitor chip");
206MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_DS2760));
diff --git a/drivers/w1/slaves/w1_ds2780.c b/drivers/w1/slaves/w1_ds2780.c
index 98ed9c49cf50..0cd7a27b5d6b 100644
--- a/drivers/w1/slaves/w1_ds2780.c
+++ b/drivers/w1/slaves/w1_ds2780.c
@@ -188,3 +188,4 @@ module_exit(w1_ds2780_exit);
188MODULE_LICENSE("GPL"); 188MODULE_LICENSE("GPL");
189MODULE_AUTHOR("Clifton Barnes <cabarnes@indesign-llc.com>"); 189MODULE_AUTHOR("Clifton Barnes <cabarnes@indesign-llc.com>");
190MODULE_DESCRIPTION("1-wire Driver for Maxim/Dallas DS2780 Stand-Alone Fuel Gauge IC"); 190MODULE_DESCRIPTION("1-wire Driver for Maxim/Dallas DS2780 Stand-Alone Fuel Gauge IC");
191MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_DS2780));
diff --git a/drivers/w1/slaves/w1_ds2781.c b/drivers/w1/slaves/w1_ds2781.c
index 5140d7be67ab..1aba8e41ad46 100644
--- a/drivers/w1/slaves/w1_ds2781.c
+++ b/drivers/w1/slaves/w1_ds2781.c
@@ -186,3 +186,4 @@ module_exit(w1_ds2781_exit);
186MODULE_LICENSE("GPL"); 186MODULE_LICENSE("GPL");
187MODULE_AUTHOR("Renata Sayakhova <renata@oktetlabs.ru>"); 187MODULE_AUTHOR("Renata Sayakhova <renata@oktetlabs.ru>");
188MODULE_DESCRIPTION("1-wire Driver for Maxim/Dallas DS2781 Stand-Alone Fuel Gauge IC"); 188MODULE_DESCRIPTION("1-wire Driver for Maxim/Dallas DS2781 Stand-Alone Fuel Gauge IC");
189MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_DS2781));
diff --git a/drivers/w1/slaves/w1_ds28e04.c b/drivers/w1/slaves/w1_ds28e04.c
index 98117db595bb..cd30a6d95ea5 100644
--- a/drivers/w1/slaves/w1_ds28e04.c
+++ b/drivers/w1/slaves/w1_ds28e04.c
@@ -27,6 +27,7 @@
27MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
28MODULE_AUTHOR("Markus Franke <franke.m@sebakmt.com>, <franm@hrz.tu-chemnitz.de>"); 28MODULE_AUTHOR("Markus Franke <franke.m@sebakmt.com>, <franm@hrz.tu-chemnitz.de>");
29MODULE_DESCRIPTION("w1 family 1C driver for DS28E04, 4kb EEPROM and PIO"); 29MODULE_DESCRIPTION("w1 family 1C driver for DS28E04, 4kb EEPROM and PIO");
30MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_DS28E04));
30 31
31/* Allow the strong pullup to be disabled, but default to enabled. 32/* Allow the strong pullup to be disabled, but default to enabled.
32 * If it was disabled a parasite powered device might not get the required 33 * If it was disabled a parasite powered device might not get the required
diff --git a/drivers/w1/slaves/w1_smem.c b/drivers/w1/slaves/w1_smem.c
index 84655625c870..ed4c87506def 100644
--- a/drivers/w1/slaves/w1_smem.c
+++ b/drivers/w1/slaves/w1_smem.c
@@ -34,6 +34,8 @@
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>"); 35MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
36MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family."); 36MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family.");
37MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_SMEM_01));
38MODULE_ALIAS("w1-family-" __stringify(W1_FAMILY_SMEM_81));
37 39
38static struct w1_family w1_smem_family_01 = { 40static struct w1_family w1_smem_family_01 = {
39 .fid = W1_FAMILY_SMEM_01, 41 .fid = W1_FAMILY_SMEM_01,
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index c1a702f8c803..8978360bd387 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -36,6 +36,11 @@
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>"); 37MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
38MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family."); 38MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family.");
39MODULE_ALIAS("w1-family-" __stringify(W1_THERM_DS18S20));
40MODULE_ALIAS("w1-family-" __stringify(W1_THERM_DS1822));
41MODULE_ALIAS("w1-family-" __stringify(W1_THERM_DS18B20));
42MODULE_ALIAS("w1-family-" __stringify(W1_THERM_DS1825));
43MODULE_ALIAS("w1-family-" __stringify(W1_THERM_DS28EA00));
39 44
40/* Allow the strong pullup to be disabled, but default to enabled. 45/* Allow the strong pullup to be disabled, but default to enabled.
41 * If it was disabled a parasite powered device might not get the require 46 * If it was disabled a parasite powered device might not get the require
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 7ce277d2bb67..0459df843c58 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -680,6 +680,8 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
680 atomic_set(&sl->refcnt, 0); 680 atomic_set(&sl->refcnt, 0);
681 init_completion(&sl->released); 681 init_completion(&sl->released);
682 682
683 request_module("w1-family-0x%0x", rn->family);
684
683 spin_lock(&w1_flock); 685 spin_lock(&w1_flock);
684 f = w1_family_registered(rn->family); 686 f = w1_family_registered(rn->family);
685 if (!f) { 687 if (!f) {
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index c2559847d7ee..fae8bac907ef 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -909,6 +909,7 @@ enum vmbus_channel_state {
909 CHANNEL_OFFER_STATE, 909 CHANNEL_OFFER_STATE,
910 CHANNEL_OPENING_STATE, 910 CHANNEL_OPENING_STATE,
911 CHANNEL_OPEN_STATE, 911 CHANNEL_OPEN_STATE,
912 CHANNEL_OPENED_STATE,
912}; 913};
913 914
914struct vmbus_channel_debug_info { 915struct vmbus_channel_debug_info {
@@ -1046,6 +1047,38 @@ struct vmbus_channel {
1046 * preserve the earlier behavior. 1047 * preserve the earlier behavior.
1047 */ 1048 */
1048 u32 target_vp; 1049 u32 target_vp;
1050 /*
1051 * Support for sub-channels. For high performance devices,
1052 * it will be useful to have multiple sub-channels to support
1053 * a scalable communication infrastructure with the host.
1054 * The support for sub-channels is implemented as an extention
1055 * to the current infrastructure.
1056 * The initial offer is considered the primary channel and this
1057 * offer message will indicate if the host supports sub-channels.
1058 * The guest is free to ask for sub-channels to be offerred and can
1059 * open these sub-channels as a normal "primary" channel. However,
1060 * all sub-channels will have the same type and instance guids as the
1061 * primary channel. Requests sent on a given channel will result in a
1062 * response on the same channel.
1063 */
1064
1065 /*
1066 * Sub-channel creation callback. This callback will be called in
1067 * process context when a sub-channel offer is received from the host.
1068 * The guest can open the sub-channel in the context of this callback.
1069 */
1070 void (*sc_creation_callback)(struct vmbus_channel *new_sc);
1071
1072 spinlock_t sc_lock;
1073 /*
1074 * All Sub-channels of a primary channel are linked here.
1075 */
1076 struct list_head sc_list;
1077 /*
1078 * The primary channel this sub-channel belongs to.
1079 * This will be NULL for the primary channel.
1080 */
1081 struct vmbus_channel *primary_channel;
1049}; 1082};
1050 1083
1051static inline void set_channel_read_state(struct vmbus_channel *c, bool state) 1084static inline void set_channel_read_state(struct vmbus_channel *c, bool state)
@@ -1057,6 +1090,34 @@ void vmbus_onmessage(void *context);
1057 1090
1058int vmbus_request_offers(void); 1091int vmbus_request_offers(void);
1059 1092
1093/*
1094 * APIs for managing sub-channels.
1095 */
1096
1097void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel,
1098 void (*sc_cr_cb)(struct vmbus_channel *new_sc));
1099
1100/*
1101 * Retrieve the (sub) channel on which to send an outgoing request.
1102 * When a primary channel has multiple sub-channels, we choose a
1103 * channel whose VCPU binding is closest to the VCPU on which
1104 * this call is being made.
1105 */
1106struct vmbus_channel *vmbus_get_outgoing_channel(struct vmbus_channel *primary);
1107
1108/*
1109 * Check if sub-channels have already been offerred. This API will be useful
1110 * when the driver is unloaded after establishing sub-channels. In this case,
1111 * when the driver is re-loaded, the driver would have to check if the
1112 * subchannels have already been established before attempting to request
1113 * the creation of sub-channels.
1114 * This function returns TRUE to indicate that subchannels have already been
1115 * created.
1116 * This function should be invoked after setting the callback function for
1117 * sub-channel creation.
1118 */
1119bool vmbus_are_subchannels_present(struct vmbus_channel *primary);
1120
1060/* The format must be the same as struct vmdata_gpa_direct */ 1121/* The format must be the same as struct vmdata_gpa_direct */
1061struct vmbus_channel_packet_page_buffer { 1122struct vmbus_channel_packet_page_buffer {
1062 u16 type; 1123 u16 type;
@@ -1327,6 +1388,15 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver);
1327 0x8e, 0x77, 0x05, 0x58, 0xeb, 0x10, 0x73, 0xf8 \ 1388 0x8e, 0x77, 0x05, 0x58, 0xeb, 0x10, 0x73, 0xf8 \
1328 } 1389 }
1329 1390
1391/*
1392 * Synthetic FC GUID
1393 * {2f9bcc4a-0069-4af3-b76b-6fd0be528cda}
1394 */
1395#define HV_SYNTHFC_GUID \
1396 .guid = { \
1397 0x4A, 0xCC, 0x9B, 0x2F, 0x69, 0x00, 0xF3, 0x4A, \
1398 0xB7, 0x6B, 0x6F, 0xD0, 0xBE, 0x52, 0x8C, 0xDA \
1399 }
1330 1400
1331/* 1401/*
1332 * Common header for Hyper-V ICs 1402 * Common header for Hyper-V ICs
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 12b4d55a02af..d5569734f672 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -30,7 +30,6 @@ static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
30 30
31int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr); 31int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
32 32
33int mac_pton(const char *s, u8 *mac);
34extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len); 33extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
35 34
36#endif /* _LINUX_IF_ETHER_H */ 35#endif /* _LINUX_IF_ETHER_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e9ef6d6b51d5..3afb969441d1 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -450,6 +450,8 @@ static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)
450extern int hex_to_bin(char ch); 450extern int hex_to_bin(char ch);
451extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); 451extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
452 452
453int mac_pton(const char *s, u8 *mac);
454
453/* 455/*
454 * General tracing related utility functions - trace_printk(), 456 * General tracing related utility functions - trace_printk(),
455 * tracing_on/tracing_off and tracing_start()/tracing_stop 457 * tracing_on/tracing_off and tracing_start()/tracing_stop
diff --git a/lib/Kconfig b/lib/Kconfig
index fe01d418b09a..d246a3bbd6ef 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -22,6 +22,9 @@ config GENERIC_STRNCPY_FROM_USER
22config GENERIC_STRNLEN_USER 22config GENERIC_STRNLEN_USER
23 bool 23 bool
24 24
25config GENERIC_NET_UTILS
26 bool
27
25config GENERIC_FIND_FIRST_BIT 28config GENERIC_FIND_FIRST_BIT
26 bool 29 bool
27 30
diff --git a/lib/Makefile b/lib/Makefile
index c55a037a354e..22f0f4e8a9e1 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -137,6 +137,8 @@ obj-$(CONFIG_DDR) += jedec_ddr_data.o
137obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o 137obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o
138obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o 138obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o
139 139
140obj-$(CONFIG_GENERIC_NET_UTILS) += net_utils.o
141
140obj-$(CONFIG_STMP_DEVICE) += stmp_device.o 142obj-$(CONFIG_STMP_DEVICE) += stmp_device.o
141 143
142libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o 144libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o
diff --git a/lib/net_utils.c b/lib/net_utils.c
new file mode 100644
index 000000000000..2e3c52c8d050
--- /dev/null
+++ b/lib/net_utils.c
@@ -0,0 +1,26 @@
1#include <linux/string.h>
2#include <linux/if_ether.h>
3#include <linux/ctype.h>
4#include <linux/kernel.h>
5
6int mac_pton(const char *s, u8 *mac)
7{
8 int i;
9
10 /* XX:XX:XX:XX:XX:XX */
11 if (strlen(s) < 3 * ETH_ALEN - 1)
12 return 0;
13
14 /* Don't dirty result unless string is valid MAC. */
15 for (i = 0; i < ETH_ALEN; i++) {
16 if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1]))
17 return 0;
18 if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
19 return 0;
20 }
21 for (i = 0; i < ETH_ALEN; i++) {
22 mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]);
23 }
24 return 1;
25}
26EXPORT_SYMBOL(mac_pton);
diff --git a/net/Kconfig b/net/Kconfig
index 2ddc9046868e..6dfe1c636a80 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -5,6 +5,7 @@
5menuconfig NET 5menuconfig NET
6 bool "Networking support" 6 bool "Networking support"
7 select NLATTR 7 select NLATTR
8 select GENERIC_NET_UTILS
8 ---help--- 9 ---help---
9 Unless you really know what you are doing, you should say Y here. 10 Unless you really know what you are doing, you should say Y here.
10 The reason is that some programs need kernel networking support even 11 The reason is that some programs need kernel networking support even
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index cec074be8c43..35a9f0804b6f 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -12,6 +12,7 @@
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 13
14#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
15#include <linux/kernel.h>
15#include <linux/netdevice.h> 16#include <linux/netdevice.h>
16#include <linux/etherdevice.h> 17#include <linux/etherdevice.h>
17#include <linux/string.h> 18#include <linux/string.h>
diff --git a/net/core/utils.c b/net/core/utils.c
index 3c7f5b51b979..aa88e23fc87a 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -338,25 +338,3 @@ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
338 csum_unfold(*sum))); 338 csum_unfold(*sum)));
339} 339}
340EXPORT_SYMBOL(inet_proto_csum_replace16); 340EXPORT_SYMBOL(inet_proto_csum_replace16);
341
342int mac_pton(const char *s, u8 *mac)
343{
344 int i;
345
346 /* XX:XX:XX:XX:XX:XX */
347 if (strlen(s) < 3 * ETH_ALEN - 1)
348 return 0;
349
350 /* Don't dirty result unless string is valid MAC. */
351 for (i = 0; i < ETH_ALEN; i++) {
352 if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1]))
353 return 0;
354 if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
355 return 0;
356 }
357 for (i = 0; i < ETH_ALEN; i++) {
358 mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]);
359 }
360 return 1;
361}
362EXPORT_SYMBOL(mac_pton);
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 5a1f6489d185..d55ce4040b74 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -257,12 +257,15 @@ static int kvp_file_init(void)
257 257
258 258
259 filep = fopen(fname, "re"); 259 filep = fopen(fname, "re");
260 if (!filep) 260 if (!filep) {
261 close(fd);
261 return 1; 262 return 1;
263 }
262 264
263 record = malloc(alloc_unit * num_blocks); 265 record = malloc(alloc_unit * num_blocks);
264 if (record == NULL) { 266 if (record == NULL) {
265 fclose(filep); 267 fclose(filep);
268 close(fd);
266 return 1; 269 return 1;
267 } 270 }
268 for (;;) { 271 for (;;) {
@@ -286,6 +289,7 @@ static int kvp_file_init(void)
286 num_blocks); 289 num_blocks);
287 if (record == NULL) { 290 if (record == NULL) {
288 fclose(filep); 291 fclose(filep);
292 close(fd);
289 return 1; 293 return 1;
290 } 294 }
291 continue; 295 continue;
@@ -765,7 +769,9 @@ static void kvp_process_ipconfig_file(char *cmd,
765 break; 769 break;
766 770
767 x = strchr(p, '\n'); 771 x = strchr(p, '\n');
768 *x = '\0'; 772 if (x)
773 *x = '\0';
774
769 strcat(config_buf, p); 775 strcat(config_buf, p);
770 strcat(config_buf, ";"); 776 strcat(config_buf, ";");
771 } 777 }
@@ -1457,7 +1463,13 @@ int main(void)
1457 exit(EXIT_FAILURE); 1463 exit(EXIT_FAILURE);
1458 } 1464 }
1459 nl_group = CN_KVP_IDX; 1465 nl_group = CN_KVP_IDX;
1460 setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group)); 1466
1467 if (setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group)) < 0) {
1468 syslog(LOG_ERR, "setsockopt failed; error: %d %s", errno, strerror(errno));
1469 close(fd);
1470 exit(EXIT_FAILURE);
1471 }
1472
1461 /* 1473 /*
1462 * Register ourselves with the kernel. 1474 * Register ourselves with the kernel.
1463 */ 1475 */
@@ -1484,7 +1496,16 @@ int main(void)
1484 socklen_t addr_l = sizeof(addr); 1496 socklen_t addr_l = sizeof(addr);
1485 pfd.events = POLLIN; 1497 pfd.events = POLLIN;
1486 pfd.revents = 0; 1498 pfd.revents = 0;
1487 poll(&pfd, 1, -1); 1499
1500 if (poll(&pfd, 1, -1) < 0) {
1501 syslog(LOG_ERR, "poll failed; error: %d %s", errno, strerror(errno));
1502 if (errno == EINVAL) {
1503 close(fd);
1504 exit(EXIT_FAILURE);
1505 }
1506 else
1507 continue;
1508 }
1488 1509
1489 len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0, 1510 len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0,
1490 addr_p, &addr_l); 1511 addr_p, &addr_l);