Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r1402 - genpatches-2.6/trunk/2.6.27
Date: Fri, 21 Nov 2008 00:58:26
Message-Id: E1L3KLk-0006wl-BW@stork.gentoo.org
1 Author: mpagano
2 Date: 2008-11-21 00:58:20 +0000 (Fri, 21 Nov 2008)
3 New Revision: 1402
4
5 Added:
6 genpatches-2.6/trunk/2.6.27/1006_linux-2.6.27.7.patch
7 Modified:
8 genpatches-2.6/trunk/2.6.27/0000_README
9 Log:
10 Adding linux patch version 2.6.27.7
11
12 Modified: genpatches-2.6/trunk/2.6.27/0000_README
13 ===================================================================
14 --- genpatches-2.6/trunk/2.6.27/0000_README 2008-11-20 04:22:21 UTC (rev 1401)
15 +++ genpatches-2.6/trunk/2.6.27/0000_README 2008-11-21 00:58:20 UTC (rev 1402)
16 @@ -63,6 +63,10 @@
17 From: http://www.kernel.org
18 Desc: Linux 2.6.27.6
19
20 +Patch: 1006_linux-2.6.27.7.patch
21 +From: http://www.kernel.org
22 +Desc: Linux 2.6.27.7
23 +
24 Patch: 1700_HP-laptop-dmi-quirk-fix.patch
25 From: http://bugs.gentoo.org/show_bug.cgi?id=245158
26 Desc: dmi quirk call fix for HP laptops
27
28 Added: genpatches-2.6/trunk/2.6.27/1006_linux-2.6.27.7.patch
29 ===================================================================
30 --- genpatches-2.6/trunk/2.6.27/1006_linux-2.6.27.7.patch (rev 0)
31 +++ genpatches-2.6/trunk/2.6.27/1006_linux-2.6.27.7.patch 2008-11-21 00:58:20 UTC (rev 1402)
32 @@ -0,0 +1,1991 @@
33 +diff --git a/arch/arm/mm/cache-feroceon-l2.c b/arch/arm/mm/cache-feroceon-l2.c
34 +index 7b5a25d..4f6cf46 100644
35 +--- a/arch/arm/mm/cache-feroceon-l2.c
36 ++++ b/arch/arm/mm/cache-feroceon-l2.c
37 +@@ -148,7 +148,7 @@ static void feroceon_l2_inv_range(unsigned long start, unsigned long end)
38 + /*
39 + * Clean and invalidate partial last cache line.
40 + */
41 +- if (end & (CACHE_LINE_SIZE - 1)) {
42 ++ if (start < end && end & (CACHE_LINE_SIZE - 1)) {
43 + l2_clean_inv_pa(end & ~(CACHE_LINE_SIZE - 1));
44 + end &= ~(CACHE_LINE_SIZE - 1);
45 + }
46 +@@ -156,7 +156,7 @@ static void feroceon_l2_inv_range(unsigned long start, unsigned long end)
47 + /*
48 + * Invalidate all full cache lines between 'start' and 'end'.
49 + */
50 +- while (start != end) {
51 ++ while (start < end) {
52 + unsigned long range_end = calc_range_end(start, end);
53 + l2_inv_pa_range(start, range_end - CACHE_LINE_SIZE);
54 + start = range_end;
55 +diff --git a/arch/m68k/kernel/ints.c b/arch/m68k/kernel/ints.c
56 +index ded7dd2..c4460bf 100644
57 +--- a/arch/m68k/kernel/ints.c
58 ++++ b/arch/m68k/kernel/ints.c
59 +@@ -133,7 +133,7 @@ void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt,
60 + {
61 + int i;
62 +
63 +- BUG_ON(IRQ_USER + cnt >= NR_IRQS);
64 ++ BUG_ON(IRQ_USER + cnt > NR_IRQS);
65 + m68k_first_user_vec = vec;
66 + for (i = 0; i < cnt; i++)
67 + irq_controller[IRQ_USER + i] = &user_irq_controller;
68 +diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
69 +index fe566a3..eb685ed 100644
70 +--- a/arch/powerpc/include/asm/mpic.h
71 ++++ b/arch/powerpc/include/asm/mpic.h
72 +@@ -355,6 +355,8 @@ struct mpic
73 + #define MPIC_NO_BIAS 0x00000400
74 + /* Ignore NIRQS as reported by FRR */
75 + #define MPIC_BROKEN_FRR_NIRQS 0x00000800
76 ++/* Destination only supports a single CPU at a time */
77 ++#define MPIC_SINGLE_DEST_CPU 0x00001000
78 +
79 + /* MPIC HW modification ID */
80 + #define MPIC_REGSET_MASK 0xf0000000
81 +diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
82 +index 483b65c..613bf8c 100644
83 +--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
84 ++++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
85 +@@ -78,7 +78,8 @@ void __init mpc85xx_ds_pic_init(void)
86 +
87 + mpic = mpic_alloc(np, r.start,
88 + MPIC_PRIMARY | MPIC_WANTS_RESET |
89 +- MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
90 ++ MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
91 ++ MPIC_SINGLE_DEST_CPU,
92 + 0, 256, " OpenPIC ");
93 + BUG_ON(mpic == NULL);
94 + of_node_put(np);
95 +diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
96 +index 8881c5d..668275d 100644
97 +--- a/arch/powerpc/platforms/86xx/pic.c
98 ++++ b/arch/powerpc/platforms/86xx/pic.c
99 +@@ -44,7 +44,8 @@ void __init mpc86xx_init_irq(void)
100 +
101 + mpic = mpic_alloc(np, res.start,
102 + MPIC_PRIMARY | MPIC_WANTS_RESET |
103 +- MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
104 ++ MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
105 ++ MPIC_SINGLE_DEST_CPU,
106 + 0, 256, " MPIC ");
107 + of_node_put(np);
108 + BUG_ON(mpic == NULL);
109 +diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
110 +index 8e3478c..f6299cc 100644
111 +--- a/arch/powerpc/sysdev/mpic.c
112 ++++ b/arch/powerpc/sysdev/mpic.c
113 +@@ -563,6 +563,51 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
114 +
115 + #endif /* CONFIG_MPIC_U3_HT_IRQS */
116 +
117 ++#ifdef CONFIG_SMP
118 ++static int irq_choose_cpu(unsigned int virt_irq)
119 ++{
120 ++ cpumask_t mask = irq_desc[virt_irq].affinity;
121 ++ int cpuid;
122 ++
123 ++ if (cpus_equal(mask, CPU_MASK_ALL)) {
124 ++ static int irq_rover;
125 ++ static DEFINE_SPINLOCK(irq_rover_lock);
126 ++ unsigned long flags;
127 ++
128 ++ /* Round-robin distribution... */
129 ++ do_round_robin:
130 ++ spin_lock_irqsave(&irq_rover_lock, flags);
131 ++
132 ++ while (!cpu_online(irq_rover)) {
133 ++ if (++irq_rover >= NR_CPUS)
134 ++ irq_rover = 0;
135 ++ }
136 ++ cpuid = irq_rover;
137 ++ do {
138 ++ if (++irq_rover >= NR_CPUS)
139 ++ irq_rover = 0;
140 ++ } while (!cpu_online(irq_rover));
141 ++
142 ++ spin_unlock_irqrestore(&irq_rover_lock, flags);
143 ++ } else {
144 ++ cpumask_t tmp;
145 ++
146 ++ cpus_and(tmp, cpu_online_map, mask);
147 ++
148 ++ if (cpus_empty(tmp))
149 ++ goto do_round_robin;
150 ++
151 ++ cpuid = first_cpu(tmp);
152 ++ }
153 ++
154 ++ return cpuid;
155 ++}
156 ++#else
157 ++static int irq_choose_cpu(unsigned int virt_irq)
158 ++{
159 ++ return hard_smp_processor_id();
160 ++}
161 ++#endif
162 +
163 + #define mpic_irq_to_hw(virq) ((unsigned int)irq_map[virq].hwirq)
164 +
165 +@@ -777,12 +822,18 @@ void mpic_set_affinity(unsigned int irq, cpumask_t cpumask)
166 + struct mpic *mpic = mpic_from_irq(irq);
167 + unsigned int src = mpic_irq_to_hw(irq);
168 +
169 +- cpumask_t tmp;
170 ++ if (mpic->flags & MPIC_SINGLE_DEST_CPU) {
171 ++ int cpuid = irq_choose_cpu(irq);
172 +
173 +- cpus_and(tmp, cpumask, cpu_online_map);
174 ++ mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid);
175 ++ } else {
176 ++ cpumask_t tmp;
177 +
178 +- mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION),
179 +- mpic_physmask(cpus_addr(tmp)[0]));
180 ++ cpus_and(tmp, cpumask, cpu_online_map);
181 ++
182 ++ mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION),
183 ++ mpic_physmask(cpus_addr(tmp)[0]));
184 ++ }
185 + }
186 +
187 + static unsigned int mpic_type_to_vecpri(struct mpic *mpic, unsigned int type)
188 +diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
189 +index 632b13e..a947899 100644
190 +--- a/arch/s390/kernel/topology.c
191 ++++ b/arch/s390/kernel/topology.c
192 +@@ -65,18 +65,21 @@ static int machine_has_topology_irq;
193 + static struct timer_list topology_timer;
194 + static void set_topology_timer(void);
195 + static DECLARE_WORK(topology_work, topology_work_fn);
196 ++/* topology_lock protects the core linked list */
197 ++static DEFINE_SPINLOCK(topology_lock);
198 +
199 + cpumask_t cpu_core_map[NR_CPUS];
200 +
201 + cpumask_t cpu_coregroup_map(unsigned int cpu)
202 + {
203 + struct core_info *core = &core_info;
204 ++ unsigned long flags;
205 + cpumask_t mask;
206 +
207 + cpus_clear(mask);
208 + if (!machine_has_topology)
209 + return cpu_present_map;
210 +- mutex_lock(&smp_cpu_state_mutex);
211 ++ spin_lock_irqsave(&topology_lock, flags);
212 + while (core) {
213 + if (cpu_isset(cpu, core->mask)) {
214 + mask = core->mask;
215 +@@ -84,7 +87,7 @@ cpumask_t cpu_coregroup_map(unsigned int cpu)
216 + }
217 + core = core->next;
218 + }
219 +- mutex_unlock(&smp_cpu_state_mutex);
220 ++ spin_unlock_irqrestore(&topology_lock, flags);
221 + if (cpus_empty(mask))
222 + mask = cpumask_of_cpu(cpu);
223 + return mask;
224 +@@ -133,7 +136,7 @@ static void tl_to_cores(struct tl_info *info)
225 + union tl_entry *tle, *end;
226 + struct core_info *core = &core_info;
227 +
228 +- mutex_lock(&smp_cpu_state_mutex);
229 ++ spin_lock_irq(&topology_lock);
230 + clear_cores();
231 + tle = info->tle;
232 + end = (union tl_entry *)((unsigned long)info + info->length);
233 +@@ -157,7 +160,7 @@ static void tl_to_cores(struct tl_info *info)
234 + }
235 + tle = next_tle(tle);
236 + }
237 +- mutex_unlock(&smp_cpu_state_mutex);
238 ++ spin_unlock_irq(&topology_lock);
239 + }
240 +
241 + static void topology_update_polarization_simple(void)
242 +diff --git a/block/blk-merge.c b/block/blk-merge.c
243 +index 5efc9e7..857dce7 100644
244 +--- a/block/blk-merge.c
245 ++++ b/block/blk-merge.c
246 +@@ -95,6 +95,9 @@ new_hw_segment:
247 + nr_hw_segs++;
248 + }
249 +
250 ++ if (nr_phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size)
251 ++ rq->bio->bi_seg_front_size = seg_size;
252 ++
253 + nr_phys_segs++;
254 + bvprv = bv;
255 + seg_size = bv->bv_len;
256 +@@ -106,6 +109,10 @@ new_hw_segment:
257 + rq->bio->bi_hw_front_size = hw_seg_size;
258 + if (hw_seg_size > rq->biotail->bi_hw_back_size)
259 + rq->biotail->bi_hw_back_size = hw_seg_size;
260 ++ if (nr_phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size)
261 ++ rq->bio->bi_seg_front_size = seg_size;
262 ++ if (seg_size > rq->biotail->bi_seg_back_size)
263 ++ rq->biotail->bi_seg_back_size = seg_size;
264 + rq->nr_phys_segments = nr_phys_segs;
265 + rq->nr_hw_segments = nr_hw_segs;
266 + }
267 +@@ -133,7 +140,8 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
268 +
269 + if (!BIOVEC_PHYS_MERGEABLE(__BVEC_END(bio), __BVEC_START(nxt)))
270 + return 0;
271 +- if (bio->bi_size + nxt->bi_size > q->max_segment_size)
272 ++ if (bio->bi_seg_back_size + nxt->bi_seg_front_size >
273 ++ q->max_segment_size)
274 + return 0;
275 +
276 + /*
277 +@@ -377,6 +385,8 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
278 + {
279 + int total_phys_segments;
280 + int total_hw_segments;
281 ++ unsigned int seg_size =
282 ++ req->biotail->bi_seg_back_size + next->bio->bi_seg_front_size;
283 +
284 + /*
285 + * First check if the either of the requests are re-queued
286 +@@ -392,8 +402,13 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
287 + return 0;
288 +
289 + total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
290 +- if (blk_phys_contig_segment(q, req->biotail, next->bio))
291 ++ if (blk_phys_contig_segment(q, req->biotail, next->bio)) {
292 ++ if (req->nr_phys_segments == 1)
293 ++ req->bio->bi_seg_front_size = seg_size;
294 ++ if (next->nr_phys_segments == 1)
295 ++ next->biotail->bi_seg_back_size = seg_size;
296 + total_phys_segments--;
297 ++ }
298 +
299 + if (total_phys_segments > q->max_phys_segments)
300 + return 0;
301 +diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
302 +index ccae305..c54f38e 100644
303 +--- a/drivers/acpi/bus.c
304 ++++ b/drivers/acpi/bus.c
305 +@@ -95,21 +95,21 @@ int acpi_bus_get_status(struct acpi_device *device)
306 + }
307 +
308 + /*
309 +- * Otherwise we assume the status of our parent (unless we don't
310 +- * have one, in which case status is implied).
311 ++ * According to ACPI spec some device can be present and functional
312 ++ * even if the parent is not present but functional.
313 ++ * In such conditions the child device should not inherit the status
314 ++ * from the parent.
315 + */
316 +- else if (device->parent)
317 +- device->status = device->parent->status;
318 + else
319 + STRUCT_TO_INT(device->status) =
320 + ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED |
321 + ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING;
322 +
323 + if (device->status.functional && !device->status.present) {
324 +- printk(KERN_WARNING PREFIX "Device [%s] status [%08x]: "
325 +- "functional but not present; setting present\n",
326 +- device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status));
327 +- device->status.present = 1;
328 ++ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
329 ++ "functional but not present;\n",
330 ++ device->pnp.bus_id,
331 ++ (u32) STRUCT_TO_INT(device->status)));
332 + }
333 +
334 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
335 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
336 +index 444cd9e..41b8e7c 100644
337 +--- a/drivers/acpi/ec.c
338 ++++ b/drivers/acpi/ec.c
339 +@@ -70,7 +70,7 @@ enum ec_command {
340 + #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
341 + #define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */
342 +
343 +-#define ACPI_EC_STORM_THRESHOLD 20 /* number of false interrupts
344 ++#define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts
345 + per one transaction */
346 +
347 + enum {
348 +@@ -100,8 +100,11 @@ struct transaction {
349 + u8 *rdata;
350 + unsigned short irq_count;
351 + u8 command;
352 ++ u8 wi;
353 ++ u8 ri;
354 + u8 wlen;
355 + u8 rlen;
356 ++ bool done;
357 + };
358 +
359 + static struct acpi_ec {
360 +@@ -178,34 +181,45 @@ static int ec_transaction_done(struct acpi_ec *ec)
361 + unsigned long flags;
362 + int ret = 0;
363 + spin_lock_irqsave(&ec->curr_lock, flags);
364 +- if (!ec->curr || (!ec->curr->wlen && !ec->curr->rlen))
365 ++ if (!ec->curr || ec->curr->done)
366 + ret = 1;
367 + spin_unlock_irqrestore(&ec->curr_lock, flags);
368 + return ret;
369 + }
370 +
371 ++static void start_transaction(struct acpi_ec *ec)
372 ++{
373 ++ ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0;
374 ++ ec->curr->done = false;
375 ++ acpi_ec_write_cmd(ec, ec->curr->command);
376 ++}
377 ++
378 + static void gpe_transaction(struct acpi_ec *ec, u8 status)
379 + {
380 + unsigned long flags;
381 + spin_lock_irqsave(&ec->curr_lock, flags);
382 + if (!ec->curr)
383 + goto unlock;
384 +- if (ec->curr->wlen > 0) {
385 +- if ((status & ACPI_EC_FLAG_IBF) == 0) {
386 +- acpi_ec_write_data(ec, *(ec->curr->wdata++));
387 +- --ec->curr->wlen;
388 +- } else
389 +- /* false interrupt, state didn't change */
390 +- ++ec->curr->irq_count;
391 +-
392 +- } else if (ec->curr->rlen > 0) {
393 ++ if (ec->curr->wlen > ec->curr->wi) {
394 ++ if ((status & ACPI_EC_FLAG_IBF) == 0)
395 ++ acpi_ec_write_data(ec,
396 ++ ec->curr->wdata[ec->curr->wi++]);
397 ++ else
398 ++ goto err;
399 ++ } else if (ec->curr->rlen > ec->curr->ri) {
400 + if ((status & ACPI_EC_FLAG_OBF) == 1) {
401 +- *(ec->curr->rdata++) = acpi_ec_read_data(ec);
402 +- --ec->curr->rlen;
403 ++ ec->curr->rdata[ec->curr->ri++] = acpi_ec_read_data(ec);
404 ++ if (ec->curr->rlen == ec->curr->ri)
405 ++ ec->curr->done = true;
406 + } else
407 +- /* false interrupt, state didn't change */
408 +- ++ec->curr->irq_count;
409 +- }
410 ++ goto err;
411 ++ } else if (ec->curr->wlen == ec->curr->wi &&
412 ++ (status & ACPI_EC_FLAG_IBF) == 0)
413 ++ ec->curr->done = true;
414 ++ goto unlock;
415 ++err:
416 ++ /* false interrupt, state didn't change */
417 ++ ++ec->curr->irq_count;
418 + unlock:
419 + spin_unlock_irqrestore(&ec->curr_lock, flags);
420 + }
421 +@@ -215,6 +229,15 @@ static int acpi_ec_wait(struct acpi_ec *ec)
422 + if (wait_event_timeout(ec->wait, ec_transaction_done(ec),
423 + msecs_to_jiffies(ACPI_EC_DELAY)))
424 + return 0;
425 ++ /* try restart command if we get any false interrupts */
426 ++ if (ec->curr->irq_count &&
427 ++ (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) {
428 ++ pr_debug(PREFIX "controller reset, restart transaction\n");
429 ++ start_transaction(ec);
430 ++ if (wait_event_timeout(ec->wait, ec_transaction_done(ec),
431 ++ msecs_to_jiffies(ACPI_EC_DELAY)))
432 ++ return 0;
433 ++ }
434 + /* missing GPEs, switch back to poll mode */
435 + if (printk_ratelimit())
436 + pr_info(PREFIX "missing confirmations, "
437 +@@ -239,10 +262,10 @@ static int ec_check_sci(struct acpi_ec *ec, u8 state)
438 + static int ec_poll(struct acpi_ec *ec)
439 + {
440 + unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
441 +- msleep(1);
442 ++ udelay(ACPI_EC_UDELAY);
443 + while (time_before(jiffies, delay)) {
444 + gpe_transaction(ec, acpi_ec_read_status(ec));
445 +- msleep(1);
446 ++ udelay(ACPI_EC_UDELAY);
447 + if (ec_transaction_done(ec))
448 + return 0;
449 + }
450 +@@ -264,9 +287,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
451 + /* start transaction */
452 + spin_lock_irqsave(&ec->curr_lock, tmp);
453 + /* following two actions should be kept atomic */
454 +- t->irq_count = 0;
455 + ec->curr = t;
456 +- acpi_ec_write_cmd(ec, ec->curr->command);
457 ++ start_transaction(ec);
458 + if (ec->curr->command == ACPI_EC_COMMAND_QUERY)
459 + clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
460 + spin_unlock_irqrestore(&ec->curr_lock, tmp);
461 +@@ -286,7 +308,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
462 + acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
463 + } else if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
464 + t->irq_count > ACPI_EC_STORM_THRESHOLD) {
465 +- pr_debug(PREFIX "GPE storm detected\n");
466 ++ pr_info(PREFIX "GPE storm detected, "
467 ++ "transactions will use polling mode\n");
468 + set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
469 + }
470 + return ret;
471 +@@ -558,17 +581,26 @@ static u32 acpi_ec_gpe_handler(void *data)
472 + pr_debug(PREFIX "~~~> interrupt\n");
473 + status = acpi_ec_read_status(ec);
474 +
475 +- gpe_transaction(ec, status);
476 +- if (ec_transaction_done(ec) && (status & ACPI_EC_FLAG_IBF) == 0)
477 +- wake_up(&ec->wait);
478 ++ if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) {
479 ++ gpe_transaction(ec, status);
480 ++ if (ec_transaction_done(ec) &&
481 ++ (status & ACPI_EC_FLAG_IBF) == 0)
482 ++ wake_up(&ec->wait);
483 ++ }
484 +
485 + ec_check_sci(ec, status);
486 + if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
487 + !test_bit(EC_FLAGS_NO_GPE, &ec->flags)) {
488 + /* this is non-query, must be confirmation */
489 +- if (printk_ratelimit())
490 +- pr_info(PREFIX "non-query interrupt received,"
491 ++ if (!test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
492 ++ if (printk_ratelimit())
493 ++ pr_info(PREFIX "non-query interrupt received,"
494 ++ " switching to interrupt mode\n");
495 ++ } else {
496 ++ /* hush, STORM switches the mode every transaction */
497 ++ pr_debug(PREFIX "non-query interrupt received,"
498 + " switching to interrupt mode\n");
499 ++ }
500 + set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
501 + }
502 + return ACPI_INTERRUPT_HANDLED;
503 +diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
504 +index f6f52c1..0450761 100644
505 +--- a/drivers/acpi/scan.c
506 ++++ b/drivers/acpi/scan.c
507 +@@ -276,6 +276,13 @@ int acpi_match_device_ids(struct acpi_device *device,
508 + {
509 + const struct acpi_device_id *id;
510 +
511 ++ /*
512 ++ * If the device is not present, it is unnecessary to load device
513 ++ * driver for it.
514 ++ */
515 ++ if (!device->status.present)
516 ++ return -ENODEV;
517 ++
518 + if (device->flags.hardware_id) {
519 + for (id = ids; id->id[0]; id++) {
520 + if (!strcmp((char*)id->id, device->pnp.hardware_id))
521 +@@ -1221,15 +1228,18 @@ acpi_add_single_object(struct acpi_device **child,
522 + result = -ENODEV;
523 + goto end;
524 + }
525 +- if (!device->status.present) {
526 +- /* Bay and dock should be handled even if absent */
527 +- if (!ACPI_SUCCESS(
528 +- acpi_is_child_device(device, acpi_bay_match)) &&
529 +- !ACPI_SUCCESS(
530 +- acpi_is_child_device(device, acpi_dock_match))) {
531 +- result = -ENODEV;
532 +- goto end;
533 +- }
534 ++ /*
535 ++ * When the device is neither present nor functional, the
536 ++ * device should not be added to Linux ACPI device tree.
537 ++ * When the status of the device is not present but functinal,
538 ++ * it should be added to Linux ACPI tree. For example : bay
539 ++ * device , dock device.
540 ++ * In such conditions it is unncessary to check whether it is
541 ++ * bay device or dock device.
542 ++ */
543 ++ if (!device->status.present && !device->status.functional) {
544 ++ result = -ENODEV;
545 ++ goto end;
546 + }
547 + break;
548 + default:
549 +@@ -1402,7 +1412,12 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
550 + * TBD: Need notifications and other detection mechanisms
551 + * in place before we can fully implement this.
552 + */
553 +- if (child->status.present) {
554 ++ /*
555 ++ * When the device is not present but functional, it is also
556 ++ * necessary to scan the children of this device.
557 ++ */
558 ++ if (child->status.present || (!child->status.present &&
559 ++ child->status.functional)) {
560 + status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
561 + NULL, NULL);
562 + if (ACPI_SUCCESS(status)) {
563 +diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
564 +index 91dec44..4745792 100644
565 +--- a/drivers/acpi/system.c
566 ++++ b/drivers/acpi/system.c
567 +@@ -78,9 +78,15 @@ static ssize_t acpi_table_show(struct kobject *kobj,
568 + container_of(bin_attr, struct acpi_table_attr, attr);
569 + struct acpi_table_header *table_header = NULL;
570 + acpi_status status;
571 ++ char name[ACPI_NAME_SIZE];
572 ++
573 ++ if (strncmp(table_attr->name, "NULL", 4))
574 ++ memcpy(name, table_attr->name, ACPI_NAME_SIZE);
575 ++ else
576 ++ memcpy(name, "\0\0\0\0", 4);
577 +
578 + status =
579 +- acpi_get_table(table_attr->name, table_attr->instance,
580 ++ acpi_get_table(name, table_attr->instance,
581 + &table_header);
582 + if (ACPI_FAILURE(status))
583 + return -ENODEV;
584 +@@ -95,21 +101,24 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
585 + struct acpi_table_header *header = NULL;
586 + struct acpi_table_attr *attr = NULL;
587 +
588 +- memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE);
589 ++ if (table_header->signature[0] != '\0')
590 ++ memcpy(table_attr->name, table_header->signature,
591 ++ ACPI_NAME_SIZE);
592 ++ else
593 ++ memcpy(table_attr->name, "NULL", 4);
594 +
595 + list_for_each_entry(attr, &acpi_table_attr_list, node) {
596 +- if (!memcmp(table_header->signature, attr->name,
597 +- ACPI_NAME_SIZE))
598 ++ if (!memcmp(table_attr->name, attr->name, ACPI_NAME_SIZE))
599 + if (table_attr->instance < attr->instance)
600 + table_attr->instance = attr->instance;
601 + }
602 + table_attr->instance++;
603 +
604 + if (table_attr->instance > 1 || (table_attr->instance == 1 &&
605 +- !acpi_get_table(table_header->
606 +- signature, 2,
607 +- &header)))
608 +- sprintf(table_attr->name + 4, "%d", table_attr->instance);
609 ++ !acpi_get_table
610 ++ (table_header->signature, 2, &header)))
611 ++ sprintf(table_attr->name + ACPI_NAME_SIZE, "%d",
612 ++ table_attr->instance);
613 +
614 + table_attr->attr.size = 0;
615 + table_attr->attr.read = acpi_table_show;
616 +diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
617 +index 8a59aaa..7a88dfd 100644
618 +--- a/drivers/char/ipmi/ipmi_msghandler.c
619 ++++ b/drivers/char/ipmi/ipmi_msghandler.c
620 +@@ -422,9 +422,11 @@ struct ipmi_smi {
621 + /**
622 + * The driver model view of the IPMI messaging driver.
623 + */
624 +-static struct device_driver ipmidriver = {
625 +- .name = "ipmi",
626 +- .bus = &platform_bus_type
627 ++static struct platform_driver ipmidriver = {
628 ++ .driver = {
629 ++ .name = "ipmi",
630 ++ .bus = &platform_bus_type
631 ++ }
632 + };
633 + static DEFINE_MUTEX(ipmidriver_mutex);
634 +
635 +@@ -2384,9 +2386,9 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
636 + * representing the interfaced BMC already
637 + */
638 + if (bmc->guid_set)
639 +- old_bmc = ipmi_find_bmc_guid(&ipmidriver, bmc->guid);
640 ++ old_bmc = ipmi_find_bmc_guid(&ipmidriver.driver, bmc->guid);
641 + else
642 +- old_bmc = ipmi_find_bmc_prod_dev_id(&ipmidriver,
643 ++ old_bmc = ipmi_find_bmc_prod_dev_id(&ipmidriver.driver,
644 + bmc->id.product_id,
645 + bmc->id.device_id);
646 +
647 +@@ -2416,7 +2418,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
648 + snprintf(name, sizeof(name),
649 + "ipmi_bmc.%4.4x", bmc->id.product_id);
650 +
651 +- while (ipmi_find_bmc_prod_dev_id(&ipmidriver,
652 ++ while (ipmi_find_bmc_prod_dev_id(&ipmidriver.driver,
653 + bmc->id.product_id,
654 + bmc->id.device_id)) {
655 + if (!warn_printed) {
656 +@@ -2446,7 +2448,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
657 + " Unable to allocate platform device\n");
658 + return -ENOMEM;
659 + }
660 +- bmc->dev->dev.driver = &ipmidriver;
661 ++ bmc->dev->dev.driver = &ipmidriver.driver;
662 + dev_set_drvdata(&bmc->dev->dev, bmc);
663 + kref_init(&bmc->refcount);
664 +
665 +@@ -4247,7 +4249,7 @@ static int ipmi_init_msghandler(void)
666 + if (initialized)
667 + return 0;
668 +
669 +- rv = driver_register(&ipmidriver);
670 ++ rv = driver_register(&ipmidriver.driver);
671 + if (rv) {
672 + printk(KERN_ERR PFX "Could not register IPMI driver\n");
673 + return rv;
674 +@@ -4308,7 +4310,7 @@ static __exit void cleanup_ipmi(void)
675 + remove_proc_entry(proc_ipmi_root->name, NULL);
676 + #endif /* CONFIG_PROC_FS */
677 +
678 +- driver_unregister(&ipmidriver);
679 ++ driver_unregister(&ipmidriver.driver);
680 +
681 + initialized = 0;
682 +
683 +diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
684 +index 8e8afb6..7e860da 100644
685 +--- a/drivers/char/ipmi/ipmi_si_intf.c
686 ++++ b/drivers/char/ipmi/ipmi_si_intf.c
687 +@@ -114,9 +114,11 @@ static char *si_to_str[] = { "kcs", "smic", "bt" };
688 +
689 + #define DEVICE_NAME "ipmi_si"
690 +
691 +-static struct device_driver ipmi_driver = {
692 +- .name = DEVICE_NAME,
693 +- .bus = &platform_bus_type
694 ++static struct platform_driver ipmi_driver = {
695 ++ .driver = {
696 ++ .name = DEVICE_NAME,
697 ++ .bus = &platform_bus_type
698 ++ }
699 + };
700 +
701 +
702 +@@ -2868,7 +2870,7 @@ static int try_smi_init(struct smi_info *new_smi)
703 + goto out_err;
704 + }
705 + new_smi->dev = &new_smi->pdev->dev;
706 +- new_smi->dev->driver = &ipmi_driver;
707 ++ new_smi->dev->driver = &ipmi_driver.driver;
708 +
709 + rv = platform_device_add(new_smi->pdev);
710 + if (rv) {
711 +@@ -2983,7 +2985,7 @@ static __devinit int init_ipmi_si(void)
712 + initialized = 1;
713 +
714 + /* Register the device drivers. */
715 +- rv = driver_register(&ipmi_driver);
716 ++ rv = driver_register(&ipmi_driver.driver);
717 + if (rv) {
718 + printk(KERN_ERR
719 + "init_ipmi_si: Unable to register driver: %d\n",
720 +@@ -3052,7 +3054,7 @@ static __devinit int init_ipmi_si(void)
721 + #ifdef CONFIG_PPC_OF
722 + of_unregister_platform_driver(&ipmi_of_platform_driver);
723 + #endif
724 +- driver_unregister(&ipmi_driver);
725 ++ driver_unregister(&ipmi_driver.driver);
726 + printk(KERN_WARNING
727 + "ipmi_si: Unable to find any System Interface(s)\n");
728 + return -ENODEV;
729 +@@ -3151,7 +3153,7 @@ static __exit void cleanup_ipmi_si(void)
730 + cleanup_one_si(e);
731 + mutex_unlock(&smi_infos_lock);
732 +
733 +- driver_unregister(&ipmi_driver);
734 ++ driver_unregister(&ipmi_driver.driver);
735 + }
736 + module_exit(cleanup_ipmi_si);
737 +
738 +diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
739 +index 0f70dc2..7e909e8 100644
740 +--- a/drivers/hwmon/ibmaem.c
741 ++++ b/drivers/hwmon/ibmaem.c
742 +@@ -88,9 +88,11 @@
743 + static DEFINE_IDR(aem_idr);
744 + static DEFINE_SPINLOCK(aem_idr_lock);
745 +
746 +-static struct device_driver aem_driver = {
747 +- .name = DRVNAME,
748 +- .bus = &platform_bus_type,
749 ++static struct platform_driver aem_driver = {
750 ++ .driver = {
751 ++ .name = DRVNAME,
752 ++ .bus = &platform_bus_type,
753 ++ }
754 + };
755 +
756 + struct aem_ipmi_data {
757 +@@ -583,7 +585,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
758 + data->pdev = platform_device_alloc(DRVNAME, data->id);
759 + if (!data->pdev)
760 + goto dev_err;
761 +- data->pdev->dev.driver = &aem_driver;
762 ++ data->pdev->dev.driver = &aem_driver.driver;
763 +
764 + res = platform_device_add(data->pdev);
765 + if (res)
766 +@@ -716,7 +718,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
767 + data->pdev = platform_device_alloc(DRVNAME, data->id);
768 + if (!data->pdev)
769 + goto dev_err;
770 +- data->pdev->dev.driver = &aem_driver;
771 ++ data->pdev->dev.driver = &aem_driver.driver;
772 +
773 + res = platform_device_add(data->pdev);
774 + if (res)
775 +@@ -1085,7 +1087,7 @@ static int __init aem_init(void)
776 + {
777 + int res;
778 +
779 +- res = driver_register(&aem_driver);
780 ++ res = driver_register(&aem_driver.driver);
781 + if (res) {
782 + printk(KERN_ERR "Can't register aem driver\n");
783 + return res;
784 +@@ -1097,7 +1099,7 @@ static int __init aem_init(void)
785 + return 0;
786 +
787 + ipmi_reg_err:
788 +- driver_unregister(&aem_driver);
789 ++ driver_unregister(&aem_driver.driver);
790 + return res;
791 +
792 + }
793 +@@ -1107,7 +1109,7 @@ static void __exit aem_exit(void)
794 + struct aem_data *p1, *next1;
795 +
796 + ipmi_smi_watcher_unregister(&driver_data.bmc_events);
797 +- driver_unregister(&aem_driver);
798 ++ driver_unregister(&aem_driver.driver);
799 + list_for_each_entry_safe(p1, next1, &driver_data.aem_devices, list)
800 + aem_delete(p1);
801 + }
802 +diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
803 +index 385e32b..cbedf95 100644
804 +--- a/drivers/input/mouse/alps.c
805 ++++ b/drivers/input/mouse/alps.c
806 +@@ -54,6 +54,7 @@ static const struct alps_model_info alps_model_data[] = {
807 + { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */
808 + { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT },
809 + { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */
810 ++ { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude E6500 */
811 + { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */
812 + };
813 +
814 +diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
815 +index ff05fe8..97ef945 100644
816 +--- a/drivers/md/dm-raid1.c
817 ++++ b/drivers/md/dm-raid1.c
818 +@@ -1598,6 +1598,7 @@ static void mirror_dtr(struct dm_target *ti)
819 +
820 + del_timer_sync(&ms->timer);
821 + flush_workqueue(ms->kmirrord_wq);
822 ++ flush_scheduled_work();
823 + dm_kcopyd_client_destroy(ms->kcopyd_client);
824 + destroy_workqueue(ms->kmirrord_wq);
825 + free_context(ms, ti, ms->nr_mirrors);
826 +diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
827 +index b59e472..d74df58 100644
828 +--- a/drivers/media/video/tvaudio.c
829 ++++ b/drivers/media/video/tvaudio.c
830 +@@ -1576,13 +1576,13 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
831 + return 0;
832 + }
833 + case V4L2_CID_AUDIO_BASS:
834 +- if (desc->flags & CHIP_HAS_BASSTREBLE)
835 ++ if (!(desc->flags & CHIP_HAS_BASSTREBLE))
836 + break;
837 + ctrl->value = chip->bass;
838 + return 0;
839 + case V4L2_CID_AUDIO_TREBLE:
840 +- if (desc->flags & CHIP_HAS_BASSTREBLE)
841 +- return -EINVAL;
842 ++ if (!(desc->flags & CHIP_HAS_BASSTREBLE))
843 ++ break;
844 + ctrl->value = chip->treble;
845 + return 0;
846 + }
847 +@@ -1642,16 +1642,15 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip,
848 + return 0;
849 + }
850 + case V4L2_CID_AUDIO_BASS:
851 +- if (desc->flags & CHIP_HAS_BASSTREBLE)
852 ++ if (!(desc->flags & CHIP_HAS_BASSTREBLE))
853 + break;
854 + chip->bass = ctrl->value;
855 + chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass));
856 +
857 + return 0;
858 + case V4L2_CID_AUDIO_TREBLE:
859 +- if (desc->flags & CHIP_HAS_BASSTREBLE)
860 +- return -EINVAL;
861 +-
862 ++ if (!(desc->flags & CHIP_HAS_BASSTREBLE))
863 ++ break;
864 + chip->treble = ctrl->value;
865 + chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble));
866 +
867 +@@ -1695,7 +1694,7 @@ static int chip_command(struct i2c_client *client,
868 + break;
869 + case V4L2_CID_AUDIO_BASS:
870 + case V4L2_CID_AUDIO_TREBLE:
871 +- if (desc->flags & CHIP_HAS_BASSTREBLE)
872 ++ if (!(desc->flags & CHIP_HAS_BASSTREBLE))
873 + return -EINVAL;
874 + break;
875 + default:
876 +diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
877 +index 60775be..b35eb92 100644
878 +--- a/drivers/misc/sony-laptop.c
879 ++++ b/drivers/misc/sony-laptop.c
880 +@@ -2315,8 +2315,10 @@ end:
881 + */
882 + static int sony_pic_disable(struct acpi_device *device)
883 + {
884 +- if (ACPI_FAILURE(acpi_evaluate_object(device->handle,
885 +- "_DIS", NULL, NULL)))
886 ++ acpi_status ret = acpi_evaluate_object(device->handle, "_DIS", NULL,
887 ++ NULL);
888 ++
889 ++ if (ACPI_FAILURE(ret) && ret != AE_NOT_FOUND)
890 + return -ENXIO;
891 +
892 + dprintk("Device disabled\n");
893 +diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
894 +index 4a11296..60a0453 100644
895 +--- a/drivers/net/Kconfig
896 ++++ b/drivers/net/Kconfig
897 +@@ -2046,6 +2046,7 @@ config R8169
898 + tristate "Realtek 8169 gigabit ethernet support"
899 + depends on PCI
900 + select CRC32
901 ++ select MII
902 + ---help---
903 + Say Y here if you have a Realtek 8169 PCI Gigabit Ethernet adapter.
904 +
905 +diff --git a/drivers/net/bnx2x_init.h b/drivers/net/bnx2x_init.h
906 +index 130927c..a6c0b3a 100644
907 +--- a/drivers/net/bnx2x_init.h
908 ++++ b/drivers/net/bnx2x_init.h
909 +@@ -564,14 +564,15 @@ static const struct arb_line write_arb_addr[NUM_WR_Q-1] = {
910 +
911 + static void bnx2x_init_pxp(struct bnx2x *bp)
912 + {
913 ++ u16 devctl;
914 + int r_order, w_order;
915 + u32 val, i;
916 +
917 + pci_read_config_word(bp->pdev,
918 +- bp->pcie_cap + PCI_EXP_DEVCTL, (u16 *)&val);
919 +- DP(NETIF_MSG_HW, "read 0x%x from devctl\n", (u16)val);
920 +- w_order = ((val & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
921 +- r_order = ((val & PCI_EXP_DEVCTL_READRQ) >> 12);
922 ++ bp->pcie_cap + PCI_EXP_DEVCTL, &devctl);
923 ++ DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl);
924 ++ w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
925 ++ r_order = ((devctl & PCI_EXP_DEVCTL_READRQ) >> 12);
926 +
927 + if (r_order > MAX_RD_ORD) {
928 + DP(NETIF_MSG_HW, "read order of %d order adjusted to %d\n",
929 +diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
930 +index a8eb3c4..53459db 100644
931 +--- a/drivers/net/bnx2x_main.c
932 ++++ b/drivers/net/bnx2x_main.c
933 +@@ -6480,6 +6480,7 @@ load_int_disable:
934 + bnx2x_free_irq(bp);
935 + load_error:
936 + bnx2x_free_mem(bp);
937 ++ bp->port.pmf = 0;
938 +
939 + /* TBD we really need to reset the chip
940 + if we want to recover from this */
941 +@@ -6790,6 +6791,7 @@ unload_error:
942 + /* Report UNLOAD_DONE to MCP */
943 + if (!BP_NOMCP(bp))
944 + bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE);
945 ++ bp->port.pmf = 0;
946 +
947 + /* Free SKBs, SGEs, TPA pool and driver internals */
948 + bnx2x_free_skbs(bp);
949 +@@ -10203,8 +10205,6 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
950 + return -ENOMEM;
951 + }
952 +
953 +- netif_carrier_off(dev);
954 +-
955 + bp = netdev_priv(dev);
956 + bp->msglevel = debug;
957 +
958 +@@ -10228,6 +10228,8 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
959 + goto init_one_exit;
960 + }
961 +
962 ++ netif_carrier_off(dev);
963 ++
964 + bp->common.name = board_info[ent->driver_data].name;
965 + printk(KERN_INFO "%s: %s (%c%d) PCI-E x%d %s found at mem %lx,"
966 + " IRQ %d, ", dev->name, bp->common.name,
967 +diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
968 +index 0676c6d..a225827 100644
969 +--- a/drivers/net/wireless/ath5k/base.c
970 ++++ b/drivers/net/wireless/ath5k/base.c
971 +@@ -294,9 +294,9 @@ static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp)
972 + }
973 +
974 + /* Interrupt handling */
975 +-static int ath5k_init(struct ath5k_softc *sc);
976 ++static int ath5k_init(struct ath5k_softc *sc, bool is_resume);
977 + static int ath5k_stop_locked(struct ath5k_softc *sc);
978 +-static int ath5k_stop_hw(struct ath5k_softc *sc);
979 ++static int ath5k_stop_hw(struct ath5k_softc *sc, bool is_suspend);
980 + static irqreturn_t ath5k_intr(int irq, void *dev_id);
981 + static void ath5k_tasklet_reset(unsigned long data);
982 +
983 +@@ -584,7 +584,7 @@ ath5k_pci_suspend(struct pci_dev *pdev, pm_message_t state)
984 +
985 + ath5k_led_off(sc);
986 +
987 +- ath5k_stop_hw(sc);
988 ++ ath5k_stop_hw(sc, true);
989 +
990 + free_irq(pdev->irq, sc);
991 + pci_save_state(pdev);
992 +@@ -599,8 +599,7 @@ ath5k_pci_resume(struct pci_dev *pdev)
993 + {
994 + struct ieee80211_hw *hw = pci_get_drvdata(pdev);
995 + struct ath5k_softc *sc = hw->priv;
996 +- struct ath5k_hw *ah = sc->ah;
997 +- int i, err;
998 ++ int err;
999 +
1000 + pci_restore_state(pdev);
1001 +
1002 +@@ -621,21 +620,11 @@ ath5k_pci_resume(struct pci_dev *pdev)
1003 + goto err_no_irq;
1004 + }
1005 +
1006 +- err = ath5k_init(sc);
1007 ++ err = ath5k_init(sc, true);
1008 + if (err)
1009 + goto err_irq;
1010 + ath5k_led_enable(sc);
1011 +
1012 +- /*
1013 +- * Reset the key cache since some parts do not
1014 +- * reset the contents on initial power up or resume.
1015 +- *
1016 +- * FIXME: This may need to be revisited when mac80211 becomes
1017 +- * aware of suspend/resume.
1018 +- */
1019 +- for (i = 0; i < AR5K_KEYTABLE_SIZE; i++)
1020 +- ath5k_hw_reset_key(ah, i);
1021 +-
1022 + return 0;
1023 + err_irq:
1024 + free_irq(pdev->irq, sc);
1025 +@@ -657,7 +646,6 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
1026 + struct ath5k_softc *sc = hw->priv;
1027 + struct ath5k_hw *ah = sc->ah;
1028 + u8 mac[ETH_ALEN];
1029 +- unsigned int i;
1030 + int ret;
1031 +
1032 + ATH5K_DBG(sc, ATH5K_DEBUG_ANY, "devid 0x%x\n", pdev->device);
1033 +@@ -676,13 +664,6 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
1034 + __set_bit(ATH_STAT_MRRETRY, sc->status);
1035 +
1036 + /*
1037 +- * Reset the key cache since some parts do not
1038 +- * reset the contents on initial power up.
1039 +- */
1040 +- for (i = 0; i < AR5K_KEYTABLE_SIZE; i++)
1041 +- ath5k_hw_reset_key(ah, i);
1042 +-
1043 +- /*
1044 + * Collect the channel list. The 802.11 layer
1045 + * is resposible for filtering this list based
1046 + * on settings like the phy mode and regulatory
1047 +@@ -2197,12 +2178,18 @@ ath5k_beacon_config(struct ath5k_softc *sc)
1048 + \********************/
1049 +
1050 + static int
1051 +-ath5k_init(struct ath5k_softc *sc)
1052 ++ath5k_init(struct ath5k_softc *sc, bool is_resume)
1053 + {
1054 +- int ret;
1055 ++ struct ath5k_hw *ah = sc->ah;
1056 ++ int ret, i;
1057 +
1058 + mutex_lock(&sc->lock);
1059 +
1060 ++ if (is_resume && !test_bit(ATH_STAT_STARTED, sc->status))
1061 ++ goto out_ok;
1062 ++
1063 ++ __clear_bit(ATH_STAT_STARTED, sc->status);
1064 ++
1065 + ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "mode %d\n", sc->opmode);
1066 +
1067 + /*
1068 +@@ -2220,7 +2207,7 @@ ath5k_init(struct ath5k_softc *sc)
1069 + */
1070 + sc->curchan = sc->hw->conf.channel;
1071 + sc->curband = &sc->sbands[sc->curchan->band];
1072 +- ret = ath5k_hw_reset(sc->ah, sc->opmode, sc->curchan, false);
1073 ++ ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, false);
1074 + if (ret) {
1075 + ATH5K_ERR(sc, "unable to reset hardware: %d\n", ret);
1076 + goto done;
1077 +@@ -2229,7 +2216,14 @@ ath5k_init(struct ath5k_softc *sc)
1078 + * This is needed only to setup initial state
1079 + * but it's best done after a reset.
1080 + */
1081 +- ath5k_hw_set_txpower_limit(sc->ah, 0);
1082 ++ ath5k_hw_set_txpower_limit(ah, 0);
1083 ++
1084 ++ /*
1085 ++ * Reset the key cache since some parts do not reset the
1086 ++ * contents on initial power up or resume from suspend.
1087 ++ */
1088 ++ for (i = 0; i < AR5K_KEYTABLE_SIZE; i++)
1089 ++ ath5k_hw_reset_key(ah, i);
1090 +
1091 + /*
1092 + * Setup the hardware after reset: the key cache
1093 +@@ -2249,13 +2243,17 @@ ath5k_init(struct ath5k_softc *sc)
1094 + AR5K_INT_RXORN | AR5K_INT_FATAL | AR5K_INT_GLOBAL |
1095 + AR5K_INT_MIB;
1096 +
1097 +- ath5k_hw_set_intr(sc->ah, sc->imask);
1098 ++ ath5k_hw_set_intr(ah, sc->imask);
1099 ++
1100 ++ __set_bit(ATH_STAT_STARTED, sc->status);
1101 ++
1102 + /* Set ack to be sent at low bit-rates */
1103 +- ath5k_hw_set_ack_bitrate_high(sc->ah, false);
1104 ++ ath5k_hw_set_ack_bitrate_high(ah, false);
1105 +
1106 + mod_timer(&sc->calib_tim, round_jiffies(jiffies +
1107 + msecs_to_jiffies(ath5k_calinterval * 1000)));
1108 +
1109 ++out_ok:
1110 + ret = 0;
1111 + done:
1112 + mmiowb();
1113 +@@ -2310,7 +2308,7 @@ ath5k_stop_locked(struct ath5k_softc *sc)
1114 + * stop is preempted).
1115 + */
1116 + static int
1117 +-ath5k_stop_hw(struct ath5k_softc *sc)
1118 ++ath5k_stop_hw(struct ath5k_softc *sc, bool is_suspend)
1119 + {
1120 + int ret;
1121 +
1122 +@@ -2341,6 +2339,9 @@ ath5k_stop_hw(struct ath5k_softc *sc)
1123 + }
1124 + }
1125 + ath5k_txbuf_free(sc, sc->bbuf);
1126 ++ if (!is_suspend)
1127 ++ __clear_bit(ATH_STAT_STARTED, sc->status);
1128 ++
1129 + mmiowb();
1130 + mutex_unlock(&sc->lock);
1131 +
1132 +@@ -2719,12 +2720,12 @@ err:
1133 +
1134 + static int ath5k_start(struct ieee80211_hw *hw)
1135 + {
1136 +- return ath5k_init(hw->priv);
1137 ++ return ath5k_init(hw->priv, false);
1138 + }
1139 +
1140 + static void ath5k_stop(struct ieee80211_hw *hw)
1141 + {
1142 +- ath5k_stop_hw(hw->priv);
1143 ++ ath5k_stop_hw(hw->priv, false);
1144 + }
1145 +
1146 + static int ath5k_add_interface(struct ieee80211_hw *hw,
1147 +diff --git a/drivers/net/wireless/ath5k/base.h b/drivers/net/wireless/ath5k/base.h
1148 +index 7ec2f37..214a565 100644
1149 +--- a/drivers/net/wireless/ath5k/base.h
1150 ++++ b/drivers/net/wireless/ath5k/base.h
1151 +@@ -132,11 +132,12 @@ struct ath5k_softc {
1152 + size_t desc_len; /* size of TX/RX descriptors */
1153 + u16 cachelsz; /* cache line size */
1154 +
1155 +- DECLARE_BITMAP(status, 4);
1156 ++ DECLARE_BITMAP(status, 5);
1157 + #define ATH_STAT_INVALID 0 /* disable hardware accesses */
1158 + #define ATH_STAT_MRRETRY 1 /* multi-rate retry support */
1159 + #define ATH_STAT_PROMISC 2
1160 + #define ATH_STAT_LEDSOFT 3 /* enable LED gpio status */
1161 ++#define ATH_STAT_STARTED 4 /* opened & irqs enabled */
1162 +
1163 + unsigned int filter_flags; /* HW flags, AR5K_RX_FILTER_* */
1164 + unsigned int curmode; /* current phy mode */
1165 +diff --git a/drivers/net/wireless/ath5k/hw.c b/drivers/net/wireless/ath5k/hw.c
1166 +index ad1a5b4..9b40cbe 100644
1167 +--- a/drivers/net/wireless/ath5k/hw.c
1168 ++++ b/drivers/net/wireless/ath5k/hw.c
1169 +@@ -826,9 +826,10 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum ieee80211_if_types op_mode,
1170 + mdelay(1);
1171 +
1172 + /*
1173 +- * Write some more initial register settings
1174 ++ * Write some more initial register settings for revised chips
1175 + */
1176 +- if (ah->ah_version == AR5K_AR5212) {
1177 ++ if (ah->ah_version == AR5K_AR5212 &&
1178 ++ ah->ah_phy_revision > 0x41) {
1179 + ath5k_hw_reg_write(ah, 0x0002a002, 0x982c);
1180 +
1181 + if (channel->hw_value == CHANNEL_G)
1182 +@@ -847,19 +848,10 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum ieee80211_if_types op_mode,
1183 + else
1184 + ath5k_hw_reg_write(ah, 0x00000000, 0x994c);
1185 +
1186 +- /* Some bits are disabled here, we know nothing about
1187 +- * register 0xa228 yet, most of the times this ends up
1188 +- * with a value 0x9b5 -haven't seen any dump with
1189 +- * a different value- */
1190 +- /* Got this from decompiling binary HAL */
1191 +- data = ath5k_hw_reg_read(ah, 0xa228);
1192 +- data &= 0xfffffdff;
1193 +- ath5k_hw_reg_write(ah, data, 0xa228);
1194 +-
1195 +- data = ath5k_hw_reg_read(ah, 0xa228);
1196 +- data &= 0xfffe03ff;
1197 +- ath5k_hw_reg_write(ah, data, 0xa228);
1198 +- data = 0;
1199 ++ /* Got this from legacy-hal */
1200 ++ AR5K_REG_DISABLE_BITS(ah, 0xa228, 0x200);
1201 ++
1202 ++ AR5K_REG_MASKED_BITS(ah, 0xa228, 2 << 10, ~0x1fc00);
1203 +
1204 + /* Just write 0x9b5 ? */
1205 + /* ath5k_hw_reg_write(ah, 0x000009b5, 0xa228); */
1206 +diff --git a/drivers/net/wireless/ath5k/initvals.c b/drivers/net/wireless/ath5k/initvals.c
1207 +index 2806b21..cf7ebd1 100644
1208 +--- a/drivers/net/wireless/ath5k/initvals.c
1209 ++++ b/drivers/net/wireless/ath5k/initvals.c
1210 +@@ -810,6 +810,8 @@ static const struct ath5k_ini_mode ar5212_rf5111_ini_mode_end[] = {
1211 + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
1212 + { AR5K_PHY(642),
1213 + { 0xd03e6788, 0xd03e6788, 0xd03e6788, 0xd03e6788, 0xd03e6788 } },
1214 ++ { 0xa228,
1215 ++ { 0x000001b5, 0x000001b5, 0x000001b5, 0x000001b5, 0x000001b5 } },
1216 + { 0xa23c,
1217 + { 0x13c889af, 0x13c889af, 0x13c889af, 0x13c889af, 0x13c889af } },
1218 + };
1219 +diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h
1220 +index ffdf487..a68f97c 100644
1221 +--- a/drivers/net/wireless/hostap/hostap_wlan.h
1222 ++++ b/drivers/net/wireless/hostap/hostap_wlan.h
1223 +@@ -918,9 +918,12 @@ struct hostap_interface {
1224 +
1225 + /*
1226 + * TX meta data - stored in skb->cb buffer, so this must not be increased over
1227 +- * the 40-byte limit
1228 ++ * the 48-byte limit.
1229 ++ * THE PADDING THIS STARTS WITH IS A HORRIBLE HACK THAT SHOULD NOT LIVE
1230 ++ * TO SEE THE DAY.
1231 + */
1232 + struct hostap_skb_tx_data {
1233 ++ unsigned int __padding_for_default_qdiscs;
1234 + u32 magic; /* HOSTAP_SKB_TX_DATA_MAGIC */
1235 + u8 rate; /* transmit rate */
1236 + #define HOSTAP_TX_FLAGS_WDS BIT(0)
1237 +diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
1238 +index 72a6743..cf7056e 100644
1239 +--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
1240 ++++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
1241 +@@ -3275,7 +3275,11 @@ static void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw,
1242 + return;
1243 + }
1244 +
1245 +- iwl_scan_cancel_timeout(priv, 100);
1246 ++ if (iwl_scan_cancel(priv)) {
1247 ++ /* cancel scan failed, just live w/ bad key and rely
1248 ++ briefly on SW decryption */
1249 ++ return;
1250 ++ }
1251 +
1252 + key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
1253 + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
1254 +diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
1255 +index ca5deb6..0cebbc4 100644
1256 +--- a/drivers/net/wireless/rtl8187_dev.c
1257 ++++ b/drivers/net/wireless/rtl8187_dev.c
1258 +@@ -45,6 +45,9 @@ static struct usb_device_id rtl8187_table[] __devinitdata = {
1259 + {USB_DEVICE(0x03f0, 0xca02), .driver_info = DEVICE_RTL8187},
1260 + /* Sitecom */
1261 + {USB_DEVICE(0x0df6, 0x000d), .driver_info = DEVICE_RTL8187},
1262 ++ {USB_DEVICE(0x0df6, 0x0028), .driver_info = DEVICE_RTL8187B},
1263 ++ /* Abocom */
1264 ++ {USB_DEVICE(0x13d1, 0xabe6), .driver_info = DEVICE_RTL8187},
1265 + {}
1266 + };
1267 +
1268 +diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
1269 +index c1b9ea3..98b9df7 100644
1270 +--- a/drivers/pnp/pnpacpi/core.c
1271 ++++ b/drivers/pnp/pnpacpi/core.c
1272 +@@ -148,9 +148,13 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
1273 + acpi_status status;
1274 + struct pnp_dev *dev;
1275 +
1276 ++ /*
1277 ++ * If a PnPacpi device is not present , the device
1278 ++ * driver should not be loaded.
1279 ++ */
1280 + status = acpi_get_handle(device->handle, "_CRS", &temp);
1281 + if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
1282 +- is_exclusive_device(device))
1283 ++ is_exclusive_device(device) || (!device->status.present))
1284 + return 0;
1285 +
1286 + dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device));
1287 +diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
1288 +index 1fe0901..7716145 100644
1289 +--- a/drivers/scsi/dpt_i2o.c
1290 ++++ b/drivers/scsi/dpt_i2o.c
1291 +@@ -2445,7 +2445,7 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
1292 + hba_status = detailed_status >> 8;
1293 +
1294 + // calculate resid for sg
1295 +- scsi_set_resid(cmd, scsi_bufflen(cmd) - readl(reply+5));
1296 ++ scsi_set_resid(cmd, scsi_bufflen(cmd) - readl(reply+20));
1297 +
1298 + pHba = (adpt_hba*) cmd->device->host->hostdata[0];
1299 +
1300 +@@ -2456,7 +2456,7 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
1301 + case I2O_SCSI_DSC_SUCCESS:
1302 + cmd->result = (DID_OK << 16);
1303 + // handle underflow
1304 +- if(readl(reply+5) < cmd->underflow ) {
1305 ++ if (readl(reply+20) < cmd->underflow) {
1306 + cmd->result = (DID_ERROR <<16);
1307 + printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name);
1308 + }
1309 +diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
1310 +index 94a720e..00f6780 100644
1311 +--- a/drivers/scsi/qla2xxx/qla_def.h
1312 ++++ b/drivers/scsi/qla2xxx/qla_def.h
1313 +@@ -2546,7 +2546,6 @@ typedef struct scsi_qla_host {
1314 + uint8_t fcode_revision[16];
1315 + uint32_t fw_revision[4];
1316 +
1317 +- uint16_t fdt_odd_index;
1318 + uint32_t fdt_wrt_disable;
1319 + uint32_t fdt_erase_cmd;
1320 + uint32_t fdt_block_size;
1321 +diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
1322 +index ee89ddd..3a0a178 100644
1323 +--- a/drivers/scsi/qla2xxx/qla_init.c
1324 ++++ b/drivers/scsi/qla2xxx/qla_init.c
1325 +@@ -974,7 +974,6 @@ qla2x00_setup_chip(scsi_qla_host_t *ha)
1326 + &ha->fw_minor_version,
1327 + &ha->fw_subminor_version,
1328 + &ha->fw_attributes, &ha->fw_memory_size);
1329 +- qla2x00_resize_request_q(ha);
1330 + ha->flags.npiv_supported = 0;
1331 + if ((IS_QLA24XX(ha) || IS_QLA25XX(ha) ||
1332 + IS_QLA84XX(ha)) &&
1333 +@@ -986,6 +985,7 @@ qla2x00_setup_chip(scsi_qla_host_t *ha)
1334 + ha->max_npiv_vports =
1335 + MIN_MULTI_ID_FABRIC - 1;
1336 + }
1337 ++ qla2x00_resize_request_q(ha);
1338 +
1339 + if (ql2xallocfwdump)
1340 + qla2x00_alloc_fw_dump(ha);
1341 +diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
1342 +index 813bc77..c07e879 100644
1343 +--- a/drivers/scsi/qla2xxx/qla_mbx.c
1344 ++++ b/drivers/scsi/qla2xxx/qla_mbx.c
1345 +@@ -1964,7 +1964,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1346 + *cur_iocb_cnt = mcp->mb[7];
1347 + if (orig_iocb_cnt)
1348 + *orig_iocb_cnt = mcp->mb[10];
1349 +- if (max_npiv_vports)
1350 ++ if (ha->flags.npiv_supported && max_npiv_vports)
1351 + *max_npiv_vports = mcp->mb[11];
1352 + }
1353 +
1354 +diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
1355 +index 6d0f0e5..86e143c 100644
1356 +--- a/drivers/scsi/qla2xxx/qla_os.c
1357 ++++ b/drivers/scsi/qla2xxx/qla_os.c
1358 +@@ -730,6 +730,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
1359 + if (ha->isp_ops->abort_command(ha, sp)) {
1360 + DEBUG2(printk("%s(%ld): abort_command "
1361 + "mbx failed.\n", __func__, ha->host_no));
1362 ++ ret = FAILED;
1363 + } else {
1364 + DEBUG3(printk("%s(%ld): abort_command "
1365 + "mbx success.\n", __func__, ha->host_no));
1366 +diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
1367 +index 1bca744..910c3b3 100644
1368 +--- a/drivers/scsi/qla2xxx/qla_sup.c
1369 ++++ b/drivers/scsi/qla2xxx/qla_sup.c
1370 +@@ -546,6 +546,7 @@ qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id,
1371 + void
1372 + qla2xxx_get_flash_info(scsi_qla_host_t *ha)
1373 + {
1374 ++#define FLASH_BLK_SIZE_4K 0x1000
1375 + #define FLASH_BLK_SIZE_32K 0x8000
1376 + #define FLASH_BLK_SIZE_64K 0x10000
1377 + uint16_t cnt, chksum;
1378 +@@ -577,7 +578,6 @@ qla2xxx_get_flash_info(scsi_qla_host_t *ha)
1379 + goto no_flash_data;
1380 + }
1381 +
1382 +- ha->fdt_odd_index = le16_to_cpu(fdt->man_id) == 0x1f;
1383 + ha->fdt_wrt_disable = fdt->wrt_disable_bits;
1384 + ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0300 | fdt->erase_cmd);
1385 + ha->fdt_block_size = le32_to_cpu(fdt->block_size);
1386 +@@ -590,10 +590,10 @@ qla2xxx_get_flash_info(scsi_qla_host_t *ha)
1387 + }
1388 +
1389 + DEBUG2(qla_printk(KERN_DEBUG, ha, "Flash[FDT]: (0x%x/0x%x) erase=0x%x "
1390 +- "pro=%x upro=%x idx=%d wrtd=0x%x blk=0x%x.\n",
1391 ++ "pro=%x upro=%x wrtd=0x%x blk=0x%x.\n",
1392 + le16_to_cpu(fdt->man_id), le16_to_cpu(fdt->id), ha->fdt_erase_cmd,
1393 + ha->fdt_protect_sec_cmd, ha->fdt_unprotect_sec_cmd,
1394 +- ha->fdt_odd_index, ha->fdt_wrt_disable, ha->fdt_block_size));
1395 ++ ha->fdt_wrt_disable, ha->fdt_block_size));
1396 + return;
1397 +
1398 + no_flash_data:
1399 +@@ -614,8 +614,7 @@ no_flash_data:
1400 + ha->fdt_block_size = FLASH_BLK_SIZE_64K;
1401 + break;
1402 + case 0x1f: /* Atmel 26DF081A. */
1403 +- ha->fdt_odd_index = 1;
1404 +- ha->fdt_block_size = FLASH_BLK_SIZE_64K;
1405 ++ ha->fdt_block_size = FLASH_BLK_SIZE_4K;
1406 + ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0320);
1407 + ha->fdt_unprotect_sec_cmd = flash_conf_to_access_addr(0x0339);
1408 + ha->fdt_protect_sec_cmd = flash_conf_to_access_addr(0x0336);
1409 +@@ -627,9 +626,9 @@ no_flash_data:
1410 + }
1411 +
1412 + DEBUG2(qla_printk(KERN_DEBUG, ha, "Flash[MID]: (0x%x/0x%x) erase=0x%x "
1413 +- "pro=%x upro=%x idx=%d wrtd=0x%x blk=0x%x.\n", man_id, flash_id,
1414 ++ "pro=%x upro=%x wrtd=0x%x blk=0x%x.\n", man_id, flash_id,
1415 + ha->fdt_erase_cmd, ha->fdt_protect_sec_cmd,
1416 +- ha->fdt_unprotect_sec_cmd, ha->fdt_odd_index, ha->fdt_wrt_disable,
1417 ++ ha->fdt_unprotect_sec_cmd, ha->fdt_wrt_disable,
1418 + ha->fdt_block_size));
1419 + }
1420 +
1421 +@@ -710,13 +709,9 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
1422 + qla24xx_unprotect_flash(ha);
1423 +
1424 + for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) {
1425 +- if (ha->fdt_odd_index) {
1426 +- findex = faddr << 2;
1427 +- fdata = findex & sec_mask;
1428 +- } else {
1429 +- findex = faddr;
1430 +- fdata = (findex & sec_mask) << 2;
1431 +- }
1432 ++
1433 ++ findex = faddr;
1434 ++ fdata = (findex & sec_mask) << 2;
1435 +
1436 + /* Are we at the beginning of a sector? */
1437 + if ((findex & rest_addr) == 0) {
1438 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1439 +index d996a61..61524fc 100644
1440 +--- a/drivers/usb/class/cdc-acm.c
1441 ++++ b/drivers/usb/class/cdc-acm.c
1442 +@@ -158,16 +158,12 @@ static int acm_wb_is_avail(struct acm *acm)
1443 + }
1444 +
1445 + /*
1446 +- * Finish write.
1447 ++ * Finish write. Caller must hold acm->write_lock
1448 + */
1449 + static void acm_write_done(struct acm *acm, struct acm_wb *wb)
1450 + {
1451 +- unsigned long flags;
1452 +-
1453 +- spin_lock_irqsave(&acm->write_lock, flags);
1454 + wb->use = 0;
1455 + acm->transmitting--;
1456 +- spin_unlock_irqrestore(&acm->write_lock, flags);
1457 + }
1458 +
1459 + /*
1460 +@@ -482,6 +478,7 @@ static void acm_write_bulk(struct urb *urb)
1461 + {
1462 + struct acm_wb *wb = urb->context;
1463 + struct acm *acm = wb->instance;
1464 ++ unsigned long flags;
1465 +
1466 + if (verbose || urb->status
1467 + || (urb->actual_length != urb->transfer_buffer_length))
1468 +@@ -490,7 +487,9 @@ static void acm_write_bulk(struct urb *urb)
1469 + urb->transfer_buffer_length,
1470 + urb->status);
1471 +
1472 ++ spin_lock_irqsave(&acm->write_lock, flags);
1473 + acm_write_done(acm, wb);
1474 ++ spin_unlock_irqrestore(&acm->write_lock, flags);
1475 + if (ACM_READY(acm))
1476 + schedule_work(&acm->work);
1477 + else
1478 +diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
1479 +index 286b443..9cfa366 100644
1480 +--- a/drivers/usb/core/message.c
1481 ++++ b/drivers/usb/core/message.c
1482 +@@ -1091,6 +1091,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1483 + continue;
1484 + dev_dbg(&dev->dev, "unregistering interface %s\n",
1485 + dev_name(&interface->dev));
1486 ++ interface->unregistering = 1;
1487 + usb_remove_sysfs_intf_files(interface);
1488 + device_del(&interface->dev);
1489 + }
1490 +diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
1491 +index 5e1f5d5..668a6d6 100644
1492 +--- a/drivers/usb/core/sysfs.c
1493 ++++ b/drivers/usb/core/sysfs.c
1494 +@@ -816,7 +816,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
1495 + struct usb_host_interface *alt = intf->cur_altsetting;
1496 + int retval;
1497 +
1498 +- if (intf->sysfs_files_created)
1499 ++ if (intf->sysfs_files_created || intf->unregistering)
1500 + return 0;
1501 +
1502 + /* The interface string may be present in some altsettings
1503 +diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
1504 +index 5ee1590..c1d34df 100644
1505 +--- a/drivers/usb/gadget/f_acm.c
1506 ++++ b/drivers/usb/gadget/f_acm.c
1507 +@@ -463,7 +463,11 @@ static int acm_cdc_notify(struct f_acm *acm, u8 type, u16 value,
1508 + notify->wLength = cpu_to_le16(length);
1509 + memcpy(buf, data, length);
1510 +
1511 ++ /* ep_queue() can complete immediately if it fills the fifo... */
1512 ++ spin_unlock(&acm->lock);
1513 + status = usb_ep_queue(ep, req, GFP_ATOMIC);
1514 ++ spin_lock(&acm->lock);
1515 ++
1516 + if (status < 0) {
1517 + ERROR(acm->port.func.config->cdev,
1518 + "acm ttyGS%d can't notify serial state, %d\n",
1519 +diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
1520 +index 228797e..a657c94 100644
1521 +--- a/drivers/usb/host/Kconfig
1522 ++++ b/drivers/usb/host/Kconfig
1523 +@@ -110,29 +110,18 @@ config USB_ISP116X_HCD
1524 +
1525 + config USB_ISP1760_HCD
1526 + tristate "ISP 1760 HCD support"
1527 +- depends on USB && EXPERIMENTAL
1528 ++ depends on USB && EXPERIMENTAL && (PCI || PPC_OF)
1529 + ---help---
1530 + The ISP1760 chip is a USB 2.0 host controller.
1531 +
1532 + This driver does not support isochronous transfers or OTG.
1533 ++ This USB controller is usually attached to a non-DMA-Master
1534 ++ capable bus. NXP's eval kit brings this chip on PCI card
1535 ++ where the chip itself is behind a PLB to simulate such
1536 ++ a bus.
1537 +
1538 + To compile this driver as a module, choose M here: the
1539 +- module will be called isp1760-hcd.
1540 +-
1541 +-config USB_ISP1760_PCI
1542 +- bool "Support for the PCI bus"
1543 +- depends on USB_ISP1760_HCD && PCI
1544 +- ---help---
1545 +- Enables support for the device present on the PCI bus.
1546 +- This should only be required if you happen to have the eval kit from
1547 +- NXP and you are going to test it.
1548 +-
1549 +-config USB_ISP1760_OF
1550 +- bool "Support for the OF platform bus"
1551 +- depends on USB_ISP1760_HCD && PPC_OF
1552 +- ---help---
1553 +- Enables support for the device present on the PowerPC
1554 +- OpenFirmware platform bus.
1555 ++ module will be called isp1760.
1556 +
1557 + config USB_OHCI_HCD
1558 + tristate "OHCI HCD support"
1559 +diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
1560 +index 86e38b0..dc21ade 100644
1561 +--- a/drivers/usb/host/ehci-hcd.c
1562 ++++ b/drivers/usb/host/ehci-hcd.c
1563 +@@ -643,7 +643,7 @@ static int ehci_run (struct usb_hcd *hcd)
1564 + static irqreturn_t ehci_irq (struct usb_hcd *hcd)
1565 + {
1566 + struct ehci_hcd *ehci = hcd_to_ehci (hcd);
1567 +- u32 status, pcd_status = 0, cmd;
1568 ++ u32 status, masked_status, pcd_status = 0, cmd;
1569 + int bh;
1570 +
1571 + spin_lock (&ehci->lock);
1572 +@@ -656,14 +656,14 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
1573 + goto dead;
1574 + }
1575 +
1576 +- status &= INTR_MASK;
1577 +- if (!status) { /* irq sharing? */
1578 ++ masked_status = status & INTR_MASK;
1579 ++ if (!masked_status) { /* irq sharing? */
1580 + spin_unlock(&ehci->lock);
1581 + return IRQ_NONE;
1582 + }
1583 +
1584 + /* clear (just) interrupts */
1585 +- ehci_writel(ehci, status, &ehci->regs->status);
1586 ++ ehci_writel(ehci, masked_status, &ehci->regs->status);
1587 + cmd = ehci_readl(ehci, &ehci->regs->command);
1588 + bh = 0;
1589 +
1590 +@@ -731,19 +731,18 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
1591 +
1592 + /* PCI errors [4.15.2.4] */
1593 + if (unlikely ((status & STS_FATAL) != 0)) {
1594 ++ ehci_err(ehci, "fatal error\n");
1595 + dbg_cmd (ehci, "fatal", ehci_readl(ehci,
1596 + &ehci->regs->command));
1597 + dbg_status (ehci, "fatal", status);
1598 +- if (status & STS_HALT) {
1599 +- ehci_err (ehci, "fatal error\n");
1600 ++ ehci_halt(ehci);
1601 + dead:
1602 +- ehci_reset (ehci);
1603 +- ehci_writel(ehci, 0, &ehci->regs->configured_flag);
1604 +- /* generic layer kills/unlinks all urbs, then
1605 +- * uses ehci_stop to clean up the rest
1606 +- */
1607 +- bh = 1;
1608 +- }
1609 ++ ehci_reset(ehci);
1610 ++ ehci_writel(ehci, 0, &ehci->regs->configured_flag);
1611 ++ /* generic layer kills/unlinks all urbs, then
1612 ++ * uses ehci_stop to clean up the rest
1613 ++ */
1614 ++ bh = 1;
1615 + }
1616 +
1617 + if (bh)
1618 +diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c
1619 +index 0eba894..9c9da35 100644
1620 +--- a/drivers/usb/host/ehci-ps3.c
1621 ++++ b/drivers/usb/host/ehci-ps3.c
1622 +@@ -205,6 +205,7 @@ static int ps3_ehci_remove(struct ps3_system_bus_device *dev)
1623 +
1624 + tmp = hcd->irq;
1625 +
1626 ++ ehci_shutdown(hcd);
1627 + usb_remove_hcd(hcd);
1628 +
1629 + ps3_system_bus_set_driver_data(dev, NULL);
1630 +diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
1631 +index 4a0c5a7..a081ee6 100644
1632 +--- a/drivers/usb/host/ehci-sched.c
1633 ++++ b/drivers/usb/host/ehci-sched.c
1634 +@@ -918,7 +918,7 @@ iso_stream_init (
1635 + */
1636 + stream->usecs = HS_USECS_ISO (maxp);
1637 + bandwidth = stream->usecs * 8;
1638 +- bandwidth /= 1 << (interval - 1);
1639 ++ bandwidth /= interval;
1640 +
1641 + } else {
1642 + u32 addr;
1643 +@@ -951,7 +951,7 @@ iso_stream_init (
1644 + } else
1645 + stream->raw_mask = smask_out [hs_transfers - 1];
1646 + bandwidth = stream->usecs + stream->c_usecs;
1647 +- bandwidth /= 1 << (interval + 2);
1648 ++ bandwidth /= interval << 3;
1649 +
1650 + /* stream->splits gets created from raw_mask later */
1651 + stream->address = cpu_to_hc32(ehci, addr);
1652 +diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
1653 +index 051ef7b..78b8aaa 100644
1654 +--- a/drivers/usb/host/isp1760-if.c
1655 ++++ b/drivers/usb/host/isp1760-if.c
1656 +@@ -14,16 +14,16 @@
1657 + #include "../core/hcd.h"
1658 + #include "isp1760-hcd.h"
1659 +
1660 +-#ifdef CONFIG_USB_ISP1760_OF
1661 ++#ifdef CONFIG_PPC_OF
1662 + #include <linux/of.h>
1663 + #include <linux/of_platform.h>
1664 + #endif
1665 +
1666 +-#ifdef CONFIG_USB_ISP1760_PCI
1667 ++#ifdef CONFIG_PCI
1668 + #include <linux/pci.h>
1669 + #endif
1670 +
1671 +-#ifdef CONFIG_USB_ISP1760_OF
1672 ++#ifdef CONFIG_PPC_OF
1673 + static int of_isp1760_probe(struct of_device *dev,
1674 + const struct of_device_id *match)
1675 + {
1676 +@@ -128,7 +128,7 @@ static struct of_platform_driver isp1760_of_driver = {
1677 + };
1678 + #endif
1679 +
1680 +-#ifdef CONFIG_USB_ISP1760_PCI
1681 ++#ifdef CONFIG_PCI
1682 + static u32 nxp_pci_io_base;
1683 + static u32 iolength;
1684 + static u32 pci_mem_phy0;
1685 +@@ -287,28 +287,28 @@ static struct pci_driver isp1761_pci_driver = {
1686 +
1687 + static int __init isp1760_init(void)
1688 + {
1689 +- int ret = -ENODEV;
1690 ++ int ret;
1691 +
1692 + init_kmem_once();
1693 +
1694 +-#ifdef CONFIG_USB_ISP1760_OF
1695 ++#ifdef CONFIG_PPC_OF
1696 + ret = of_register_platform_driver(&isp1760_of_driver);
1697 + if (ret) {
1698 + deinit_kmem_cache();
1699 + return ret;
1700 + }
1701 + #endif
1702 +-#ifdef CONFIG_USB_ISP1760_PCI
1703 ++#ifdef CONFIG_PCI
1704 + ret = pci_register_driver(&isp1761_pci_driver);
1705 + if (ret)
1706 + goto unreg_of;
1707 + #endif
1708 + return ret;
1709 +
1710 +-#ifdef CONFIG_USB_ISP1760_PCI
1711 ++#ifdef CONFIG_PCI
1712 + unreg_of:
1713 + #endif
1714 +-#ifdef CONFIG_USB_ISP1760_OF
1715 ++#ifdef CONFIG_PPC_OF
1716 + of_unregister_platform_driver(&isp1760_of_driver);
1717 + #endif
1718 + deinit_kmem_cache();
1719 +@@ -318,10 +318,10 @@ module_init(isp1760_init);
1720 +
1721 + static void __exit isp1760_exit(void)
1722 + {
1723 +-#ifdef CONFIG_USB_ISP1760_OF
1724 ++#ifdef CONFIG_PPC_OF
1725 + of_unregister_platform_driver(&isp1760_of_driver);
1726 + #endif
1727 +-#ifdef CONFIG_USB_ISP1760_PCI
1728 ++#ifdef CONFIG_PCI
1729 + pci_unregister_driver(&isp1761_pci_driver);
1730 + #endif
1731 + deinit_kmem_cache();
1732 +diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c
1733 +index 2089d8a..3c1a3b5 100644
1734 +--- a/drivers/usb/host/ohci-ps3.c
1735 ++++ b/drivers/usb/host/ohci-ps3.c
1736 +@@ -192,7 +192,7 @@ fail_start:
1737 + return result;
1738 + }
1739 +
1740 +-static int ps3_ohci_remove (struct ps3_system_bus_device *dev)
1741 ++static int ps3_ohci_remove(struct ps3_system_bus_device *dev)
1742 + {
1743 + unsigned int tmp;
1744 + struct usb_hcd *hcd =
1745 +@@ -205,6 +205,7 @@ static int ps3_ohci_remove (struct ps3_system_bus_device *dev)
1746 +
1747 + tmp = hcd->irq;
1748 +
1749 ++ ohci_shutdown(hcd);
1750 + usb_remove_hcd(hcd);
1751 +
1752 + ps3_system_bus_set_driver_data(dev, NULL);
1753 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
1754 +index 061df9b..ccebf89 100644
1755 +--- a/drivers/usb/storage/unusual_devs.h
1756 ++++ b/drivers/usb/storage/unusual_devs.h
1757 +@@ -1251,6 +1251,13 @@ UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001,
1758 + US_SC_DEVICE, US_PR_DEVICE, NULL,
1759 + US_FL_FIX_INQUIRY),
1760 +
1761 ++/* Reported by Luciano Rocha <luciano@×××××××.com> */
1762 ++UNUSUAL_DEV( 0x0840, 0x0082, 0x0001, 0x0001,
1763 ++ "Argosy",
1764 ++ "Storage",
1765 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
1766 ++ US_FL_FIX_CAPACITY),
1767 ++
1768 + /* Entry and supporting patch by Theodore Kilgore <kilgota@××××××.edu>.
1769 + * Flag will support Bulk devices which use a standards-violating 32-byte
1770 + * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with
1771 +diff --git a/fs/namespace.c b/fs/namespace.c
1772 +index 6e283c9..1bd5ba2 100644
1773 +--- a/fs/namespace.c
1774 ++++ b/fs/namespace.c
1775 +@@ -1553,8 +1553,13 @@ static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags,
1776 + if (!err)
1777 + nd->path.mnt->mnt_flags = mnt_flags;
1778 + up_write(&sb->s_umount);
1779 +- if (!err)
1780 ++ if (!err) {
1781 + security_sb_post_remount(nd->path.mnt, flags, data);
1782 ++
1783 ++ spin_lock(&vfsmount_lock);
1784 ++ touch_mnt_namespace(nd->path.mnt->mnt_ns);
1785 ++ spin_unlock(&vfsmount_lock);
1786 ++ }
1787 + return err;
1788 + }
1789 +
1790 +diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
1791 +index f9a8b89..7a510a6 100644
1792 +--- a/fs/proc/proc_sysctl.c
1793 ++++ b/fs/proc/proc_sysctl.c
1794 +@@ -31,6 +31,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
1795 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
1796 + inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */
1797 + inode->i_mode = table->mode;
1798 ++ inode->i_uid = inode->i_gid = 0;
1799 + if (!table->child) {
1800 + inode->i_mode |= S_IFREG;
1801 + inode->i_op = &proc_sys_inode_operations;
1802 +diff --git a/include/linux/bio.h b/include/linux/bio.h
1803 +index 0933a14..3d83947 100644
1804 +--- a/include/linux/bio.h
1805 ++++ b/include/linux/bio.h
1806 +@@ -98,6 +98,13 @@ struct bio {
1807 + unsigned int bi_size; /* residual I/O count */
1808 +
1809 + /*
1810 ++ * To keep track of the max segment size, we account for the
1811 ++ * sizes of the first and last mergeable segments in this bio.
1812 ++ */
1813 ++ unsigned int bi_seg_front_size;
1814 ++ unsigned int bi_seg_back_size;
1815 ++
1816 ++ /*
1817 + * To keep track of the max hw size, we account for the
1818 + * sizes of the first and last virtually mergeable segments
1819 + * in this bio
1820 +diff --git a/include/linux/usb.h b/include/linux/usb.h
1821 +index 94ac74a..2e434dc 100644
1822 +--- a/include/linux/usb.h
1823 ++++ b/include/linux/usb.h
1824 +@@ -108,6 +108,7 @@ enum usb_interface_condition {
1825 + * (in probe()), bound to a driver, or unbinding (in disconnect())
1826 + * @is_active: flag set when the interface is bound and not suspended.
1827 + * @sysfs_files_created: sysfs attributes exist
1828 ++ * @unregistering: flag set when the interface is being unregistered
1829 + * @needs_remote_wakeup: flag set when the driver requires remote-wakeup
1830 + * capability during autosuspend.
1831 + * @needs_altsetting0: flag set when a set-interface request for altsetting 0
1832 +@@ -163,6 +164,7 @@ struct usb_interface {
1833 + enum usb_interface_condition condition; /* state of binding */
1834 + unsigned is_active:1; /* the interface is not suspended */
1835 + unsigned sysfs_files_created:1; /* the sysfs attributes exist */
1836 ++ unsigned unregistering:1; /* unregistration is in progress */
1837 + unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
1838 + unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */
1839 + unsigned needs_binding:1; /* needs delayed unbind/rebind */
1840 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
1841 +index 77427c8..81e9a82 100644
1842 +--- a/mm/hugetlb.c
1843 ++++ b/mm/hugetlb.c
1844 +@@ -1797,6 +1797,7 @@ int unmap_ref_private(struct mm_struct *mm,
1845 + struct page *page,
1846 + unsigned long address)
1847 + {
1848 ++ struct hstate *h = hstate_vma(vma);
1849 + struct vm_area_struct *iter_vma;
1850 + struct address_space *mapping;
1851 + struct prio_tree_iter iter;
1852 +@@ -1806,7 +1807,7 @@ int unmap_ref_private(struct mm_struct *mm,
1853 + * vm_pgoff is in PAGE_SIZE units, hence the different calculation
1854 + * from page cache lookup which is in HPAGE_SIZE units.
1855 + */
1856 +- address = address & huge_page_mask(hstate_vma(vma));
1857 ++ address = address & huge_page_mask(h);
1858 + pgoff = ((address - vma->vm_start) >> PAGE_SHIFT)
1859 + + (vma->vm_pgoff >> PAGE_SHIFT);
1860 + mapping = (struct address_space *)page_private(page);
1861 +@@ -1825,7 +1826,7 @@ int unmap_ref_private(struct mm_struct *mm,
1862 + */
1863 + if (!is_vma_resv_set(iter_vma, HPAGE_RESV_OWNER))
1864 + unmap_hugepage_range(iter_vma,
1865 +- address, address + HPAGE_SIZE,
1866 ++ address, address + huge_page_size(h),
1867 + page);
1868 + }
1869 +
1870 +diff --git a/mm/page_isolation.c b/mm/page_isolation.c
1871 +index b70a7fe..5e0ffd9 100644
1872 +--- a/mm/page_isolation.c
1873 ++++ b/mm/page_isolation.c
1874 +@@ -130,10 +130,11 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn)
1875 + if (page && get_pageblock_migratetype(page) != MIGRATE_ISOLATE)
1876 + break;
1877 + }
1878 +- if (pfn < end_pfn)
1879 ++ page = __first_valid_page(start_pfn, end_pfn - start_pfn);
1880 ++ if ((pfn < end_pfn) || !page)
1881 + return -EBUSY;
1882 + /* Check all pages are free or Marked as ISOLATED */
1883 +- zone = page_zone(pfn_to_page(pfn));
1884 ++ zone = page_zone(page);
1885 + spin_lock_irqsave(&zone->lock, flags);
1886 + ret = __test_page_isolated_in_pageblock(start_pfn, end_pfn);
1887 + spin_unlock_irqrestore(&zone->lock, flags);
1888 +diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
1889 +index 8f5a403..a631a1f 100644
1890 +--- a/net/ipv4/proc.c
1891 ++++ b/net/ipv4/proc.c
1892 +@@ -237,43 +237,45 @@ static const struct snmp_mib snmp4_net_list[] = {
1893 + SNMP_MIB_SENTINEL
1894 + };
1895 +
1896 ++static void icmpmsg_put_line(struct seq_file *seq, unsigned long *vals,
1897 ++ unsigned short *type, int count)
1898 ++{
1899 ++ int j;
1900 ++
1901 ++ if (count) {
1902 ++ seq_printf(seq, "\nIcmpMsg:");
1903 ++ for (j = 0; j < count; ++j)
1904 ++ seq_printf(seq, " %sType%u",
1905 ++ type[j] & 0x100 ? "Out" : "In",
1906 ++ type[j] & 0xff);
1907 ++ seq_printf(seq, "\nIcmpMsg:");
1908 ++ for (j = 0; j < count; ++j)
1909 ++ seq_printf(seq, " %lu", vals[j]);
1910 ++ }
1911 ++}
1912 ++
1913 + static void icmpmsg_put(struct seq_file *seq)
1914 + {
1915 + #define PERLINE 16
1916 +
1917 +- int j, i, count;
1918 +- static int out[PERLINE];
1919 ++ int i, count;
1920 ++ unsigned short type[PERLINE];
1921 ++ unsigned long vals[PERLINE], val;
1922 + struct net *net = seq->private;
1923 +
1924 + count = 0;
1925 + for (i = 0; i < ICMPMSG_MIB_MAX; i++) {
1926 +-
1927 +- if (snmp_fold_field((void **) net->mib.icmpmsg_statistics, i))
1928 +- out[count++] = i;
1929 +- if (count < PERLINE)
1930 +- continue;
1931 +-
1932 +- seq_printf(seq, "\nIcmpMsg:");
1933 +- for (j = 0; j < PERLINE; ++j)
1934 +- seq_printf(seq, " %sType%u", i & 0x100 ? "Out" : "In",
1935 +- i & 0xff);
1936 +- seq_printf(seq, "\nIcmpMsg: ");
1937 +- for (j = 0; j < PERLINE; ++j)
1938 +- seq_printf(seq, " %lu",
1939 +- snmp_fold_field((void **) net->mib.icmpmsg_statistics,
1940 +- out[j]));
1941 +- seq_putc(seq, '\n');
1942 +- }
1943 +- if (count) {
1944 +- seq_printf(seq, "\nIcmpMsg:");
1945 +- for (j = 0; j < count; ++j)
1946 +- seq_printf(seq, " %sType%u", out[j] & 0x100 ? "Out" :
1947 +- "In", out[j] & 0xff);
1948 +- seq_printf(seq, "\nIcmpMsg:");
1949 +- for (j = 0; j < count; ++j)
1950 +- seq_printf(seq, " %lu", snmp_fold_field((void **)
1951 +- net->mib.icmpmsg_statistics, out[j]));
1952 ++ val = snmp_fold_field((void **) net->mib.icmpmsg_statistics, i);
1953 ++ if (val) {
1954 ++ type[count] = i;
1955 ++ vals[count++] = val;
1956 ++ }
1957 ++ if (count == PERLINE) {
1958 ++ icmpmsg_put_line(seq, vals, type, count);
1959 ++ count = 0;
1960 ++ }
1961 + }
1962 ++ icmpmsg_put_line(seq, vals, type, count);
1963 +
1964 + #undef PERLINE
1965 + }
1966 +diff --git a/scripts/package/builddeb b/scripts/package/builddeb
1967 +index ba6bf5d..1264b8e 100644
1968 +--- a/scripts/package/builddeb
1969 ++++ b/scripts/package/builddeb
1970 +@@ -15,15 +15,18 @@ set -e
1971 + version=$KERNELRELEASE
1972 + revision=`cat .version`
1973 + tmpdir="$objtree/debian/tmp"
1974 ++fwdir="$objtree/debian/fwtmp"
1975 + packagename=linux-$version
1976 ++fwpackagename=linux-firmware-image
1977 +
1978 + if [ "$ARCH" == "um" ] ; then
1979 + packagename=user-mode-linux-$version
1980 + fi
1981 +
1982 + # Setup the directory structure
1983 +-rm -rf "$tmpdir"
1984 ++rm -rf "$tmpdir" "$fwdir"
1985 + mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
1986 ++mkdir -p "$fwdir/DEBIAN" "$fwdir/lib"
1987 + if [ "$ARCH" == "um" ] ; then
1988 + mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin"
1989 + fi
1990 +@@ -107,6 +110,7 @@ Standards-Version: 3.6.1
1991 +
1992 + Package: $packagename
1993 + Provides: kernel-image-$version, linux-image-$version
1994 ++Suggests: $fwpackagename
1995 + Architecture: any
1996 + Description: Linux kernel, version $version
1997 + This package contains the Linux kernel, modules and corresponding other
1998 +@@ -118,8 +122,24 @@ fi
1999 + chown -R root:root "$tmpdir"
2000 + chmod -R go-w "$tmpdir"
2001 +
2002 ++# Do we have firmware? Move it out of the way and build it into a package.
2003 ++if [ -e "$tmpdir/lib/firmware" ]; then
2004 ++ mv "$tmpdir/lib/firmware" "$fwdir/lib/"
2005 ++
2006 ++ cat <<EOF >> debian/control
2007 ++
2008 ++Package: $fwpackagename
2009 ++Architecture: all
2010 ++Description: Linux kernel firmware, version $version
2011 ++ This package contains firmware from the Linux kernel, version $version
2012 ++EOF
2013 ++
2014 ++ dpkg-gencontrol -isp -p$fwpackagename -P"$fwdir"
2015 ++ dpkg --build "$fwdir" ..
2016 ++fi
2017 ++
2018 + # Perform the final magic
2019 +-dpkg-gencontrol -isp
2020 ++dpkg-gencontrol -isp -p$packagename
2021 + dpkg --build "$tmpdir" ..
2022 +
2023 + exit 0