aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firewire/fw-card.c4
-rw-r--r--drivers/firewire/fw-device.c123
-rw-r--r--drivers/firewire/fw-device.h1
-rw-r--r--drivers/firewire/fw-ohci.c6
-rw-r--r--drivers/firewire/fw-sbp2.c89
-rw-r--r--drivers/firewire/fw-topology.c12
-rw-r--r--drivers/firewire/fw-transaction.h9
-rw-r--r--drivers/gpio/gpiolib.c1
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c2
-rw-r--r--drivers/hid/hid-core.c4
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-microsoft.c13
-rw-r--r--drivers/hid/usbhid/hiddev.c2
-rw-r--r--drivers/hwmon/applesmc.c30
-rw-r--r--drivers/ieee1394/ieee1394.h4
-rw-r--r--drivers/ieee1394/ieee1394_core.c16
-rw-r--r--drivers/ieee1394/ohci1394.h2
-rw-r--r--drivers/ieee1394/sbp2.c54
-rw-r--r--drivers/lguest/core.c2
-rw-r--r--drivers/lguest/lguest_user.c5
-rw-r--r--drivers/misc/hpilo.c2
-rw-r--r--drivers/misc/sgi-xp/xpc_channel.c3
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c34
-rw-r--r--drivers/misc/sgi-xp/xpc_uv.c2
-rw-r--r--drivers/mtd/ubi/Kconfig.debug10
-rw-r--r--drivers/mtd/ubi/build.c21
-rw-r--r--drivers/mtd/ubi/cdev.c184
-rw-r--r--drivers/mtd/ubi/gluebi.c11
-rw-r--r--drivers/mtd/ubi/scan.c8
-rw-r--r--drivers/mtd/ubi/ubi.h11
-rw-r--r--drivers/mtd/ubi/upd.c21
-rw-r--r--drivers/mtd/ubi/vmt.c17
-rw-r--r--drivers/platform/x86/hp-wmi.c6
-rw-r--r--drivers/video/Kconfig2
34 files changed, 471 insertions, 242 deletions
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 6bd91a15d5e..7be2cf3514e 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -232,7 +232,7 @@ fw_card_bm_work(struct work_struct *work)
232 root_id = root_node->node_id; 232 root_id = root_node->node_id;
233 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); 233 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10));
234 234
235 if (card->bm_generation + 1 == generation || 235 if (is_next_generation(generation, card->bm_generation) ||
236 (card->bm_generation != generation && grace)) { 236 (card->bm_generation != generation && grace)) {
237 /* 237 /*
238 * This first step is to figure out who is IRM and 238 * This first step is to figure out who is IRM and
@@ -512,7 +512,7 @@ fw_core_remove_card(struct fw_card *card)
512 fw_core_initiate_bus_reset(card, 1); 512 fw_core_initiate_bus_reset(card, 1);
513 513
514 mutex_lock(&card_mutex); 514 mutex_lock(&card_mutex);
515 list_del(&card->link); 515 list_del_init(&card->link);
516 mutex_unlock(&card_mutex); 516 mutex_unlock(&card_mutex);
517 517
518 /* Set up the dummy driver. */ 518 /* Set up the dummy driver. */
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 2af5a8d1e01..bf53acb4565 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -25,6 +25,7 @@
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/idr.h> 27#include <linux/idr.h>
28#include <linux/jiffies.h>
28#include <linux/string.h> 29#include <linux/string.h>
29#include <linux/rwsem.h> 30#include <linux/rwsem.h>
30#include <linux/semaphore.h> 31#include <linux/semaphore.h>
@@ -634,12 +635,39 @@ struct fw_device *fw_device_get_by_devt(dev_t devt)
634 return device; 635 return device;
635} 636}
636 637
638/*
639 * These defines control the retry behavior for reading the config
640 * rom. It shouldn't be necessary to tweak these; if the device
641 * doesn't respond to a config rom read within 10 seconds, it's not
642 * going to respond at all. As for the initial delay, a lot of
643 * devices will be able to respond within half a second after bus
644 * reset. On the other hand, it's not really worth being more
645 * aggressive than that, since it scales pretty well; if 10 devices
646 * are plugged in, they're all getting read within one second.
647 */
648
649#define MAX_RETRIES 10
650#define RETRY_DELAY (3 * HZ)
651#define INITIAL_DELAY (HZ / 2)
652#define SHUTDOWN_DELAY (2 * HZ)
653
637static void fw_device_shutdown(struct work_struct *work) 654static void fw_device_shutdown(struct work_struct *work)
638{ 655{
639 struct fw_device *device = 656 struct fw_device *device =
640 container_of(work, struct fw_device, work.work); 657 container_of(work, struct fw_device, work.work);
641 int minor = MINOR(device->device.devt); 658 int minor = MINOR(device->device.devt);
642 659
660 if (time_is_after_jiffies(device->card->reset_jiffies + SHUTDOWN_DELAY)
661 && !list_empty(&device->card->link)) {
662 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
663 return;
664 }
665
666 if (atomic_cmpxchg(&device->state,
667 FW_DEVICE_GONE,
668 FW_DEVICE_SHUTDOWN) != FW_DEVICE_GONE)
669 return;
670
643 fw_device_cdev_remove(device); 671 fw_device_cdev_remove(device);
644 device_for_each_child(&device->device, NULL, shutdown_unit); 672 device_for_each_child(&device->device, NULL, shutdown_unit);
645 device_unregister(&device->device); 673 device_unregister(&device->device);
@@ -647,6 +675,7 @@ static void fw_device_shutdown(struct work_struct *work)
647 down_write(&fw_device_rwsem); 675 down_write(&fw_device_rwsem);
648 idr_remove(&fw_device_idr, minor); 676 idr_remove(&fw_device_idr, minor);
649 up_write(&fw_device_rwsem); 677 up_write(&fw_device_rwsem);
678
650 fw_device_put(device); 679 fw_device_put(device);
651} 680}
652 681
@@ -654,25 +683,63 @@ static struct device_type fw_device_type = {
654 .release = fw_device_release, 683 .release = fw_device_release,
655}; 684};
656 685
686static void fw_device_update(struct work_struct *work);
687
657/* 688/*
658 * These defines control the retry behavior for reading the config 689 * If a device was pending for deletion because its node went away but its
659 * rom. It shouldn't be necessary to tweak these; if the device 690 * bus info block and root directory header matches that of a newly discovered
660 * doesn't respond to a config rom read within 10 seconds, it's not 691 * device, revive the existing fw_device.
661 * going to respond at all. As for the initial delay, a lot of 692 * The newly allocated fw_device becomes obsolete instead.
662 * devices will be able to respond within half a second after bus
663 * reset. On the other hand, it's not really worth being more
664 * aggressive than that, since it scales pretty well; if 10 devices
665 * are plugged in, they're all getting read within one second.
666 */ 693 */
694static int lookup_existing_device(struct device *dev, void *data)
695{
696 struct fw_device *old = fw_device(dev);
697 struct fw_device *new = data;
698 struct fw_card *card = new->card;
699 int match = 0;
700
701 down_read(&fw_device_rwsem); /* serialize config_rom access */
702 spin_lock_irq(&card->lock); /* serialize node access */
703
704 if (memcmp(old->config_rom, new->config_rom, 6 * 4) == 0 &&
705 atomic_cmpxchg(&old->state,
706 FW_DEVICE_GONE,
707 FW_DEVICE_RUNNING) == FW_DEVICE_GONE) {
708 struct fw_node *current_node = new->node;
709 struct fw_node *obsolete_node = old->node;
710
711 new->node = obsolete_node;
712 new->node->data = new;
713 old->node = current_node;
714 old->node->data = old;
715
716 old->max_speed = new->max_speed;
717 old->node_id = current_node->node_id;
718 smp_wmb(); /* update node_id before generation */
719 old->generation = card->generation;
720 old->config_rom_retries = 0;
721 fw_notify("rediscovered device %s\n", dev_name(dev));
667 722
668#define MAX_RETRIES 10 723 PREPARE_DELAYED_WORK(&old->work, fw_device_update);
669#define RETRY_DELAY (3 * HZ) 724 schedule_delayed_work(&old->work, 0);
670#define INITIAL_DELAY (HZ / 2) 725
726 if (current_node == card->root_node)
727 fw_schedule_bm_work(card, 0);
728
729 match = 1;
730 }
731
732 spin_unlock_irq(&card->lock);
733 up_read(&fw_device_rwsem);
734
735 return match;
736}
671 737
672static void fw_device_init(struct work_struct *work) 738static void fw_device_init(struct work_struct *work)
673{ 739{
674 struct fw_device *device = 740 struct fw_device *device =
675 container_of(work, struct fw_device, work.work); 741 container_of(work, struct fw_device, work.work);
742 struct device *revived_dev;
676 int minor, err; 743 int minor, err;
677 744
678 /* 745 /*
@@ -696,6 +763,15 @@ static void fw_device_init(struct work_struct *work)
696 return; 763 return;
697 } 764 }
698 765
766 revived_dev = device_find_child(device->card->device,
767 device, lookup_existing_device);
768 if (revived_dev) {
769 put_device(revived_dev);
770 fw_device_release(&device->device);
771
772 return;
773 }
774
699 device_initialize(&device->device); 775 device_initialize(&device->device);
700 776
701 fw_device_get(device); 777 fw_device_get(device);
@@ -734,9 +810,10 @@ static void fw_device_init(struct work_struct *work)
734 * fw_node_event(). 810 * fw_node_event().
735 */ 811 */
736 if (atomic_cmpxchg(&device->state, 812 if (atomic_cmpxchg(&device->state,
737 FW_DEVICE_INITIALIZING, 813 FW_DEVICE_INITIALIZING,
738 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) { 814 FW_DEVICE_RUNNING) == FW_DEVICE_GONE) {
739 fw_device_shutdown(work); 815 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
816 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
740 } else { 817 } else {
741 if (device->config_rom_retries) 818 if (device->config_rom_retries)
742 fw_notify("created device %s: GUID %08x%08x, S%d00, " 819 fw_notify("created device %s: GUID %08x%08x, S%d00, "
@@ -847,8 +924,8 @@ static void fw_device_refresh(struct work_struct *work)
847 924
848 case REREAD_BIB_UNCHANGED: 925 case REREAD_BIB_UNCHANGED:
849 if (atomic_cmpxchg(&device->state, 926 if (atomic_cmpxchg(&device->state,
850 FW_DEVICE_INITIALIZING, 927 FW_DEVICE_INITIALIZING,
851 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) 928 FW_DEVICE_RUNNING) == FW_DEVICE_GONE)
852 goto gone; 929 goto gone;
853 930
854 fw_device_update(work); 931 fw_device_update(work);
@@ -879,8 +956,8 @@ static void fw_device_refresh(struct work_struct *work)
879 create_units(device); 956 create_units(device);
880 957
881 if (atomic_cmpxchg(&device->state, 958 if (atomic_cmpxchg(&device->state,
882 FW_DEVICE_INITIALIZING, 959 FW_DEVICE_INITIALIZING,
883 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) 960 FW_DEVICE_RUNNING) == FW_DEVICE_GONE)
884 goto gone; 961 goto gone;
885 962
886 fw_notify("refreshed device %s\n", dev_name(&device->device)); 963 fw_notify("refreshed device %s\n", dev_name(&device->device));
@@ -890,8 +967,9 @@ static void fw_device_refresh(struct work_struct *work)
890 give_up: 967 give_up:
891 fw_notify("giving up on refresh of device %s\n", dev_name(&device->device)); 968 fw_notify("giving up on refresh of device %s\n", dev_name(&device->device));
892 gone: 969 gone:
893 atomic_set(&device->state, FW_DEVICE_SHUTDOWN); 970 atomic_set(&device->state, FW_DEVICE_GONE);
894 fw_device_shutdown(work); 971 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
972 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
895 out: 973 out:
896 if (node_id == card->root_node->node_id) 974 if (node_id == card->root_node->node_id)
897 fw_schedule_bm_work(card, 0); 975 fw_schedule_bm_work(card, 0);
@@ -995,9 +1073,10 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
995 */ 1073 */
996 device = node->data; 1074 device = node->data;
997 if (atomic_xchg(&device->state, 1075 if (atomic_xchg(&device->state,
998 FW_DEVICE_SHUTDOWN) == FW_DEVICE_RUNNING) { 1076 FW_DEVICE_GONE) == FW_DEVICE_RUNNING) {
999 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); 1077 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
1000 schedule_delayed_work(&device->work, 0); 1078 schedule_delayed_work(&device->work,
1079 list_empty(&card->link) ? 0 : SHUTDOWN_DELAY);
1001 } 1080 }
1002 break; 1081 break;
1003 } 1082 }
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index df51732608d..8ef6ec2ca21 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -28,6 +28,7 @@
28enum fw_device_state { 28enum fw_device_state {
29 FW_DEVICE_INITIALIZING, 29 FW_DEVICE_INITIALIZING,
30 FW_DEVICE_RUNNING, 30 FW_DEVICE_RUNNING,
31 FW_DEVICE_GONE,
31 FW_DEVICE_SHUTDOWN, 32 FW_DEVICE_SHUTDOWN,
32}; 33};
33 34
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index ab9c01e462e..6d19828a93a 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -226,7 +226,7 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
226#define CONTEXT_DEAD 0x0800 226#define CONTEXT_DEAD 0x0800
227#define CONTEXT_ACTIVE 0x0400 227#define CONTEXT_ACTIVE 0x0400
228 228
229#define OHCI1394_MAX_AT_REQ_RETRIES 0x2 229#define OHCI1394_MAX_AT_REQ_RETRIES 0xf
230#define OHCI1394_MAX_AT_RESP_RETRIES 0x2 230#define OHCI1394_MAX_AT_RESP_RETRIES 0x2
231#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 231#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8
232 232
@@ -896,11 +896,11 @@ static void context_stop(struct context *ctx)
896 for (i = 0; i < 10; i++) { 896 for (i = 0; i < 10; i++) {
897 reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); 897 reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs));
898 if ((reg & CONTEXT_ACTIVE) == 0) 898 if ((reg & CONTEXT_ACTIVE) == 0)
899 break; 899 return;
900 900
901 fw_notify("context_stop: still active (0x%08x)\n", reg);
902 mdelay(1); 901 mdelay(1);
903 } 902 }
903 fw_error("Error: DMA context still active (0x%08x)\n", reg);
904} 904}
905 905
906struct driver_data { 906struct driver_data {
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index e88d5067448..c71c4419d9e 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -168,6 +168,7 @@ struct sbp2_target {
168 int address_high; 168 int address_high;
169 unsigned int workarounds; 169 unsigned int workarounds;
170 unsigned int mgt_orb_timeout; 170 unsigned int mgt_orb_timeout;
171 unsigned int max_payload;
171 172
172 int dont_block; /* counter for each logical unit */ 173 int dont_block; /* counter for each logical unit */
173 int blocked; /* ditto */ 174 int blocked; /* ditto */
@@ -310,14 +311,16 @@ struct sbp2_command_orb {
310 dma_addr_t page_table_bus; 311 dma_addr_t page_table_bus;
311}; 312};
312 313
314#define SBP2_ROM_VALUE_WILDCARD ~0 /* match all */
315#define SBP2_ROM_VALUE_MISSING 0xff000000 /* not present in the unit dir. */
316
313/* 317/*
314 * List of devices with known bugs. 318 * List of devices with known bugs.
315 * 319 *
316 * The firmware_revision field, masked with 0xffff00, is the best 320 * The firmware_revision field, masked with 0xffff00, is the best
317 * indicator for the type of bridge chip of a device. It yields a few 321 * indicator for the type of bridge chip of a device. It yields a few
318 * false positives but this did not break correctly behaving devices 322 * false positives but this did not break correctly behaving devices
319 * so far. We use ~0 as a wildcard, since the 24 bit values we get 323 * so far.
320 * from the config rom can never match that.
321 */ 324 */
322static const struct { 325static const struct {
323 u32 firmware_revision; 326 u32 firmware_revision;
@@ -339,33 +342,35 @@ static const struct {
339 }, 342 },
340 /* Initio bridges, actually only needed for some older ones */ { 343 /* Initio bridges, actually only needed for some older ones */ {
341 .firmware_revision = 0x000200, 344 .firmware_revision = 0x000200,
342 .model = ~0, 345 .model = SBP2_ROM_VALUE_WILDCARD,
343 .workarounds = SBP2_WORKAROUND_INQUIRY_36, 346 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
344 }, 347 },
345 /* PL-3507 bridge with Prolific firmware */ { 348 /* PL-3507 bridge with Prolific firmware */ {
346 .firmware_revision = 0x012800, 349 .firmware_revision = 0x012800,
347 .model = ~0, 350 .model = SBP2_ROM_VALUE_WILDCARD,
348 .workarounds = SBP2_WORKAROUND_POWER_CONDITION, 351 .workarounds = SBP2_WORKAROUND_POWER_CONDITION,
349 }, 352 },
350 /* Symbios bridge */ { 353 /* Symbios bridge */ {
351 .firmware_revision = 0xa0b800, 354 .firmware_revision = 0xa0b800,
352 .model = ~0, 355 .model = SBP2_ROM_VALUE_WILDCARD,
353 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 356 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
354 }, 357 },
355 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { 358 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ {
356 .firmware_revision = 0x002600, 359 .firmware_revision = 0x002600,
357 .model = ~0, 360 .model = SBP2_ROM_VALUE_WILDCARD,
358 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 361 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
359 }, 362 },
360
361 /* 363 /*
362 * There are iPods (2nd gen, 3rd gen) with model_id == 0, but 364 * iPod 2nd generation: needs 128k max transfer size workaround
363 * these iPods do not feature the read_capacity bug according 365 * iPod 3rd generation: needs fix capacity workaround
364 * to one report. Read_capacity behaviour as well as model_id
365 * could change due to Apple-supplied firmware updates though.
366 */ 366 */
367 367 {
368 /* iPod 4th generation. */ { 368 .firmware_revision = 0x0a2700,
369 .model = 0x000000,
370 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS |
371 SBP2_WORKAROUND_FIX_CAPACITY,
372 },
373 /* iPod 4th generation */ {
369 .firmware_revision = 0x0a2700, 374 .firmware_revision = 0x0a2700,
370 .model = 0x000021, 375 .model = 0x000021,
371 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 376 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
@@ -1092,7 +1097,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
1092 continue; 1097 continue;
1093 1098
1094 if (sbp2_workarounds_table[i].model != model && 1099 if (sbp2_workarounds_table[i].model != model &&
1095 sbp2_workarounds_table[i].model != ~0) 1100 sbp2_workarounds_table[i].model != SBP2_ROM_VALUE_WILDCARD)
1096 continue; 1101 continue;
1097 1102
1098 w |= sbp2_workarounds_table[i].workarounds; 1103 w |= sbp2_workarounds_table[i].workarounds;
@@ -1142,20 +1147,28 @@ static int sbp2_probe(struct device *dev)
1142 fw_device_get(device); 1147 fw_device_get(device);
1143 fw_unit_get(unit); 1148 fw_unit_get(unit);
1144 1149
1145 /* Initialize to values that won't match anything in our table. */
1146 firmware_revision = 0xff000000;
1147 model = 0xff000000;
1148
1149 /* implicit directory ID */ 1150 /* implicit directory ID */
1150 tgt->directory_id = ((unit->directory - device->config_rom) * 4 1151 tgt->directory_id = ((unit->directory - device->config_rom) * 4
1151 + CSR_CONFIG_ROM) & 0xffffff; 1152 + CSR_CONFIG_ROM) & 0xffffff;
1152 1153
1154 firmware_revision = SBP2_ROM_VALUE_MISSING;
1155 model = SBP2_ROM_VALUE_MISSING;
1156
1153 if (sbp2_scan_unit_dir(tgt, unit->directory, &model, 1157 if (sbp2_scan_unit_dir(tgt, unit->directory, &model,
1154 &firmware_revision) < 0) 1158 &firmware_revision) < 0)
1155 goto fail_tgt_put; 1159 goto fail_tgt_put;
1156 1160
1157 sbp2_init_workarounds(tgt, model, firmware_revision); 1161 sbp2_init_workarounds(tgt, model, firmware_revision);
1158 1162
1163 /*
1164 * At S100 we can do 512 bytes per packet, at S200 1024 bytes,
1165 * and so on up to 4096 bytes. The SBP-2 max_payload field
1166 * specifies the max payload size as 2 ^ (max_payload + 2), so
1167 * if we set this to max_speed + 7, we get the right value.
1168 */
1169 tgt->max_payload = min(device->max_speed + 7, 10U);
1170 tgt->max_payload = min(tgt->max_payload, device->card->max_receive - 1);
1171
1159 /* Do the login in a workqueue so we can easily reschedule retries. */ 1172 /* Do the login in a workqueue so we can easily reschedule retries. */
1160 list_for_each_entry(lu, &tgt->lu_list, link) 1173 list_for_each_entry(lu, &tgt->lu_list, link)
1161 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); 1174 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
@@ -1273,6 +1286,19 @@ static struct fw_driver sbp2_driver = {
1273 .id_table = sbp2_id_table, 1286 .id_table = sbp2_id_table,
1274}; 1287};
1275 1288
1289static void sbp2_unmap_scatterlist(struct device *card_device,
1290 struct sbp2_command_orb *orb)
1291{
1292 if (scsi_sg_count(orb->cmd))
1293 dma_unmap_sg(card_device, scsi_sglist(orb->cmd),
1294 scsi_sg_count(orb->cmd),
1295 orb->cmd->sc_data_direction);
1296
1297 if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT))
1298 dma_unmap_single(card_device, orb->page_table_bus,
1299 sizeof(orb->page_table), DMA_TO_DEVICE);
1300}
1301
1276static unsigned int 1302static unsigned int
1277sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data) 1303sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
1278{ 1304{
@@ -1352,15 +1378,7 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
1352 1378
1353 dma_unmap_single(device->card->device, orb->base.request_bus, 1379 dma_unmap_single(device->card->device, orb->base.request_bus,
1354 sizeof(orb->request), DMA_TO_DEVICE); 1380 sizeof(orb->request), DMA_TO_DEVICE);
1355 1381 sbp2_unmap_scatterlist(device->card->device, orb);
1356 if (scsi_sg_count(orb->cmd) > 0)
1357 dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd),
1358 scsi_sg_count(orb->cmd),
1359 orb->cmd->sc_data_direction);
1360
1361 if (orb->page_table_bus != 0)
1362 dma_unmap_single(device->card->device, orb->page_table_bus,
1363 sizeof(orb->page_table), DMA_TO_DEVICE);
1364 1382
1365 orb->cmd->result = result; 1383 orb->cmd->result = result;
1366 orb->done(orb->cmd); 1384 orb->done(orb->cmd);
@@ -1434,7 +1452,6 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1434 struct sbp2_logical_unit *lu = cmd->device->hostdata; 1452 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1435 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 1453 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
1436 struct sbp2_command_orb *orb; 1454 struct sbp2_command_orb *orb;
1437 unsigned int max_payload;
1438 int generation, retval = SCSI_MLQUEUE_HOST_BUSY; 1455 int generation, retval = SCSI_MLQUEUE_HOST_BUSY;
1439 1456
1440 /* 1457 /*
@@ -1462,17 +1479,9 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1462 orb->done = done; 1479 orb->done = done;
1463 orb->cmd = cmd; 1480 orb->cmd = cmd;
1464 1481
1465 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL); 1482 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL);
1466 /*
1467 * At speed 100 we can do 512 bytes per packet, at speed 200,
1468 * 1024 bytes per packet etc. The SBP-2 max_payload field
1469 * specifies the max payload size as 2 ^ (max_payload + 2), so
1470 * if we set this to max_speed + 7, we get the right value.
1471 */
1472 max_payload = min(device->max_speed + 7,
1473 device->card->max_receive - 1);
1474 orb->request.misc = cpu_to_be32( 1483 orb->request.misc = cpu_to_be32(
1475 COMMAND_ORB_MAX_PAYLOAD(max_payload) | 1484 COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) |
1476 COMMAND_ORB_SPEED(device->max_speed) | 1485 COMMAND_ORB_SPEED(device->max_speed) |
1477 COMMAND_ORB_NOTIFY); 1486 COMMAND_ORB_NOTIFY);
1478 1487
@@ -1491,8 +1500,10 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1491 orb->base.request_bus = 1500 orb->base.request_bus =
1492 dma_map_single(device->card->device, &orb->request, 1501 dma_map_single(device->card->device, &orb->request,
1493 sizeof(orb->request), DMA_TO_DEVICE); 1502 sizeof(orb->request), DMA_TO_DEVICE);
1494 if (dma_mapping_error(device->card->device, orb->base.request_bus)) 1503 if (dma_mapping_error(device->card->device, orb->base.request_bus)) {
1504 sbp2_unmap_scatterlist(device->card->device, orb);
1495 goto out; 1505 goto out;
1506 }
1496 1507
1497 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation, 1508 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1498 lu->command_block_agent_address + SBP2_ORB_POINTER); 1509 lu->command_block_agent_address + SBP2_ORB_POINTER);
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
index c9be6e6948c..8dd6703b55c 100644
--- a/drivers/firewire/fw-topology.c
+++ b/drivers/firewire/fw-topology.c
@@ -518,6 +518,18 @@ fw_core_handle_bus_reset(struct fw_card *card,
518 struct fw_node *local_node; 518 struct fw_node *local_node;
519 unsigned long flags; 519 unsigned long flags;
520 520
521 /*
522 * If the selfID buffer is not the immediate successor of the
523 * previously processed one, we cannot reliably compare the
524 * old and new topologies.
525 */
526 if (!is_next_generation(generation, card->generation) &&
527 card->local_node != NULL) {
528 fw_notify("skipped bus generations, destroying all nodes\n");
529 fw_destroy_nodes(card);
530 card->bm_retries = 0;
531 }
532
521 spin_lock_irqsave(&card->lock, flags); 533 spin_lock_irqsave(&card->lock, flags);
522 534
523 card->node_id = node_id; 535 card->node_id = node_id;
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index c9ab12a15f6..1d78e9cc594 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -276,6 +276,15 @@ static inline void fw_card_put(struct fw_card *card)
276extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay); 276extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
277 277
278/* 278/*
279 * Check whether new_generation is the immediate successor of old_generation.
280 * Take counter roll-over at 255 (as per to OHCI) into account.
281 */
282static inline bool is_next_generation(int new_generation, int old_generation)
283{
284 return (new_generation & 0xff) == ((old_generation + 1) & 0xff);
285}
286
287/*
279 * The iso packet format allows for an immediate header/payload part 288 * The iso packet format allows for an immediate header/payload part
280 * stored in 'header' immediately after the packet info plus an 289 * stored in 'header' immediately after the packet info plus an
281 * indirect payload part that is pointer to by the 'payload' field. 290 * indirect payload part that is pointer to by the 'payload' field.
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 35e7aea4222..42fb2fd24c0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -789,6 +789,7 @@ int gpio_request(unsigned gpio, const char *label)
789 } else { 789 } else {
790 status = -EBUSY; 790 status = -EBUSY;
791 module_put(chip->owner); 791 module_put(chip->owner);
792 goto done;
792 } 793 }
793 794
794 if (chip->request) { 795 if (chip->request) {
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 6b1148fc2cb..b36a5214d8d 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -311,7 +311,7 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
311 if (dev_priv->panel_fixed_mode != NULL) { 311 if (dev_priv->panel_fixed_mode != NULL) {
312 struct drm_display_mode *mode; 312 struct drm_display_mode *mode;
313 313
314 mutex_unlock(&dev->mode_config.mutex); 314 mutex_lock(&dev->mode_config.mutex);
315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); 315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode);
316 drm_mode_probed_add(connector, mode); 316 drm_mode_probed_add(connector, mode);
317 mutex_unlock(&dev->mode_config.mutex); 317 mutex_unlock(&dev->mode_config.mutex);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 5d7640e49dc..6cad69ed21c 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1218,6 +1218,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
1218} 1218}
1219EXPORT_SYMBOL_GPL(hid_connect); 1219EXPORT_SYMBOL_GPL(hid_connect);
1220 1220
1221/* a list of devices for which there is a specialized driver on HID bus */
1221static const struct hid_device_id hid_blacklist[] = { 1222static const struct hid_device_id hid_blacklist[] = {
1222 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 1223 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1223 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1224 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
@@ -1476,6 +1477,7 @@ static struct bus_type hid_bus_type = {
1476 .uevent = hid_uevent, 1477 .uevent = hid_uevent,
1477}; 1478};
1478 1479
1480/* a list of devices that shouldn't be handled by HID core at all */
1479static const struct hid_device_id hid_ignore_list[] = { 1481static const struct hid_device_id hid_ignore_list[] = {
1480 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1482 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
1481 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1483 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
@@ -1606,6 +1608,8 @@ static const struct hid_device_id hid_ignore_list[] = {
1606 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, 1608 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) },
1607 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) }, 1609 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) },
1608 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) }, 1610 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) },
1611 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD4) },
1612 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD5) },
1609 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) }, 1613 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1610 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) }, 1614 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1611 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1615 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index acc1abc834a..e899f510ebe 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -362,6 +362,8 @@
362#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038 362#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038
363#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2 0x0036 363#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2 0x0036
364#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3 0x0034 364#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3 0x0034
365#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD4 0x0044
366#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD5 0x0045
365 367
366#define USB_VENDOR_ID_SUN 0x0430 368#define USB_VENDOR_ID_SUN 0x0430
367#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab 369#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index d718b1607d0..25b10dcad90 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -30,7 +30,7 @@
30#define MS_NOGET 0x10 30#define MS_NOGET 0x10
31 31
32/* 32/*
33 * Microsoft Wireless Desktop Receiver (Model 1028) has several 33 * Microsoft Wireless Desktop Receiver (Model 1028) has
34 * 'Usage Min/Max' where it ought to have 'Physical Min/Max' 34 * 'Usage Min/Max' where it ought to have 'Physical Min/Max'
35 */ 35 */
36static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, 36static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -38,17 +38,12 @@ static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
38{ 38{
39 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev); 39 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
40 40
41 if ((quirks & MS_RDESC) && rsize == 571 && rdesc[284] == 0x19 && 41 if ((quirks & MS_RDESC) && rsize == 571 && rdesc[557] == 0x19 &&
42 rdesc[286] == 0x2a && rdesc[304] == 0x19 &&
43 rdesc[306] == 0x29 && rdesc[352] == 0x1a &&
44 rdesc[355] == 0x2a && rdesc[557] == 0x19 &&
45 rdesc[559] == 0x29) { 42 rdesc[559] == 0x29) {
46 dev_info(&hdev->dev, "fixing up Microsoft Wireless Receiver " 43 dev_info(&hdev->dev, "fixing up Microsoft Wireless Receiver "
47 "Model 1028 report descriptor\n"); 44 "Model 1028 report descriptor\n");
48 rdesc[284] = rdesc[304] = rdesc[557] = 0x35; 45 rdesc[557] = 0x35;
49 rdesc[352] = 0x36; 46 rdesc[559] = 0x45;
50 rdesc[286] = rdesc[355] = 0x46;
51 rdesc[306] = rdesc[559] = 0x45;
52 } 47 }
53} 48}
54 49
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index d73eea382ab..4940e4d70c2 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -656,7 +656,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
656 656
657 case HIDIOCGSTRING: 657 case HIDIOCGSTRING:
658 mutex_lock(&hiddev->existancelock); 658 mutex_lock(&hiddev->existancelock);
659 if (!hiddev->exist) 659 if (hiddev->exist)
660 r = hiddev_ioctl_string(hiddev, cmd, user_arg); 660 r = hiddev_ioctl_string(hiddev, cmd, user_arg);
661 else 661 else
662 r = -ENODEV; 662 r = -ENODEV;
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index e3018623658..678e34b01e5 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -83,7 +83,7 @@
83/* 83/*
84 * Temperature sensors keys (sp78 - 2 bytes). 84 * Temperature sensors keys (sp78 - 2 bytes).
85 */ 85 */
86static const char* temperature_sensors_sets[][36] = { 86static const char *temperature_sensors_sets[][41] = {
87/* Set 0: Macbook Pro */ 87/* Set 0: Macbook Pro */
88 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H", 88 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
89 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL }, 89 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
@@ -135,6 +135,13 @@ static const char* temperature_sensors_sets[][36] = {
135 { "TB0T", "TB1S", "TB1T", "TB2S", "TB2T", "TC0D", "TN0D", "TTF0", 135 { "TB0T", "TB1S", "TB1T", "TB2S", "TB2T", "TC0D", "TN0D", "TTF0",
136 "TV0P", "TVFP", "TW0P", "Th0P", "Tp0P", "Tp1P", "TpFP", "Ts0P", 136 "TV0P", "TVFP", "TW0P", "Th0P", "Tp0P", "Tp1P", "TpFP", "Ts0P",
137 "Ts0S", NULL }, 137 "Ts0S", NULL },
138/* Set 16: Mac Pro 3,1 (2 x Quad-Core) */
139 { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", "TC0C", "TC0D", "TC0P",
140 "TC1C", "TC1D", "TC2C", "TC2D", "TC3C", "TC3D", "TH0P", "TH1P",
141 "TH2P", "TH3P", "TMAP", "TMAS", "TMBS", "TM0P", "TM0S", "TM1P",
142 "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P", "TM9S",
143 "TN0C", "TN0D", "TN0H", "TS0C", "Tp0C", "Tp1C", "Tv0S", "Tv1S",
144 NULL },
138}; 145};
139 146
140/* List of keys used to read/write fan speeds */ 147/* List of keys used to read/write fan speeds */
@@ -1153,6 +1160,16 @@ static SENSOR_DEVICE_ATTR(temp34_input, S_IRUGO,
1153 applesmc_show_temperature, NULL, 33); 1160 applesmc_show_temperature, NULL, 33);
1154static SENSOR_DEVICE_ATTR(temp35_input, S_IRUGO, 1161static SENSOR_DEVICE_ATTR(temp35_input, S_IRUGO,
1155 applesmc_show_temperature, NULL, 34); 1162 applesmc_show_temperature, NULL, 34);
1163static SENSOR_DEVICE_ATTR(temp36_input, S_IRUGO,
1164 applesmc_show_temperature, NULL, 35);
1165static SENSOR_DEVICE_ATTR(temp37_input, S_IRUGO,
1166 applesmc_show_temperature, NULL, 36);
1167static SENSOR_DEVICE_ATTR(temp38_input, S_IRUGO,
1168 applesmc_show_temperature, NULL, 37);
1169static SENSOR_DEVICE_ATTR(temp39_input, S_IRUGO,
1170 applesmc_show_temperature, NULL, 38);
1171static SENSOR_DEVICE_ATTR(temp40_input, S_IRUGO,
1172 applesmc_show_temperature, NULL, 39);
1156 1173
1157static struct attribute *temperature_attributes[] = { 1174static struct attribute *temperature_attributes[] = {
1158 &sensor_dev_attr_temp1_input.dev_attr.attr, 1175 &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -1190,6 +1207,11 @@ static struct attribute *temperature_attributes[] = {
1190 &sensor_dev_attr_temp33_input.dev_attr.attr, 1207 &sensor_dev_attr_temp33_input.dev_attr.attr,
1191 &sensor_dev_attr_temp34_input.dev_attr.attr, 1208 &sensor_dev_attr_temp34_input.dev_attr.attr,
1192 &sensor_dev_attr_temp35_input.dev_attr.attr, 1209 &sensor_dev_attr_temp35_input.dev_attr.attr,
1210 &sensor_dev_attr_temp36_input.dev_attr.attr,
1211 &sensor_dev_attr_temp37_input.dev_attr.attr,
1212 &sensor_dev_attr_temp38_input.dev_attr.attr,
1213 &sensor_dev_attr_temp39_input.dev_attr.attr,
1214 &sensor_dev_attr_temp40_input.dev_attr.attr,
1193 NULL 1215 NULL
1194}; 1216};
1195 1217
@@ -1312,6 +1334,8 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1312 { .accelerometer = 0, .light = 0, .temperature_set = 14 }, 1334 { .accelerometer = 0, .light = 0, .temperature_set = 14 },
1313/* MacBook Air 2,1: accelerometer, backlight and temperature set 15 */ 1335/* MacBook Air 2,1: accelerometer, backlight and temperature set 15 */
1314 { .accelerometer = 1, .light = 1, .temperature_set = 15 }, 1336 { .accelerometer = 1, .light = 1, .temperature_set = 15 },
1337/* MacPro3,1: temperature set 16 */
1338 { .accelerometer = 0, .light = 0, .temperature_set = 16 },
1315}; 1339};
1316 1340
1317/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1341/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
@@ -1369,6 +1393,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
1369 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), 1393 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
1370 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") }, 1394 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") },
1371 &applesmc_dmi_data[4]}, 1395 &applesmc_dmi_data[4]},
1396 { applesmc_dmi_match, "Apple MacPro3", {
1397 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1398 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro3") },
1399 &applesmc_dmi_data[16]},
1372 { applesmc_dmi_match, "Apple MacPro", { 1400 { applesmc_dmi_match, "Apple MacPro", {
1373 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1401 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1374 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, 1402 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
diff --git a/drivers/ieee1394/ieee1394.h b/drivers/ieee1394/ieee1394.h
index e0ae0d3d747..af320e2c507 100644
--- a/drivers/ieee1394/ieee1394.h
+++ b/drivers/ieee1394/ieee1394.h
@@ -54,9 +54,7 @@
54#define IEEE1394_SPEED_800 0x03 54#define IEEE1394_SPEED_800 0x03
55#define IEEE1394_SPEED_1600 0x04 55#define IEEE1394_SPEED_1600 0x04
56#define IEEE1394_SPEED_3200 0x05 56#define IEEE1394_SPEED_3200 0x05
57 57#define IEEE1394_SPEED_MAX IEEE1394_SPEED_3200
58/* The current highest tested speed supported by the subsystem */
59#define IEEE1394_SPEED_MAX IEEE1394_SPEED_800
60 58
61/* Maps speed values above to a string representation */ 59/* Maps speed values above to a string representation */
62extern const char *hpsb_speedto_str[]; 60extern const char *hpsb_speedto_str[];
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index dcdb71a7718..2beb8d94f7b 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -338,6 +338,7 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
338 u8 cldcnt[nodecount]; 338 u8 cldcnt[nodecount];
339 u8 *map = host->speed_map; 339 u8 *map = host->speed_map;
340 u8 *speedcap = host->speed; 340 u8 *speedcap = host->speed;
341 u8 local_link_speed = host->csr.lnk_spd;
341 struct selfid *sid; 342 struct selfid *sid;
342 struct ext_selfid *esid; 343 struct ext_selfid *esid;
343 int i, j, n; 344 int i, j, n;
@@ -373,8 +374,8 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
373 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++; 374 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++;
374 375
375 speedcap[n] = sid->speed; 376 speedcap[n] = sid->speed;
376 if (speedcap[n] > host->csr.lnk_spd) 377 if (speedcap[n] > local_link_speed)
377 speedcap[n] = host->csr.lnk_spd; 378 speedcap[n] = local_link_speed;
378 n--; 379 n--;
379 } 380 }
380 } 381 }
@@ -407,12 +408,11 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
407 } 408 }
408 } 409 }
409 410
410#if SELFID_SPEED_UNKNOWN != IEEE1394_SPEED_MAX 411 /* assume a maximum speed for 1394b PHYs, nodemgr will correct it */
411 /* assume maximum speed for 1394b PHYs, nodemgr will correct it */ 412 if (local_link_speed > SELFID_SPEED_UNKNOWN)
412 for (n = 0; n < nodecount; n++) 413 for (i = 0; i < nodecount; i++)
413 if (speedcap[n] == SELFID_SPEED_UNKNOWN) 414 if (speedcap[i] == SELFID_SPEED_UNKNOWN)
414 speedcap[n] = IEEE1394_SPEED_MAX; 415 speedcap[i] = local_link_speed;
415#endif
416} 416}
417 417
418 418
diff --git a/drivers/ieee1394/ohci1394.h b/drivers/ieee1394/ohci1394.h
index 4320bf01049..7fb8ab9780a 100644
--- a/drivers/ieee1394/ohci1394.h
+++ b/drivers/ieee1394/ohci1394.h
@@ -26,7 +26,7 @@
26 26
27#define OHCI1394_DRIVER_NAME "ohci1394" 27#define OHCI1394_DRIVER_NAME "ohci1394"
28 28
29#define OHCI1394_MAX_AT_REQ_RETRIES 0x2 29#define OHCI1394_MAX_AT_REQ_RETRIES 0xf
30#define OHCI1394_MAX_AT_RESP_RETRIES 0x2 30#define OHCI1394_MAX_AT_RESP_RETRIES 0x2
31#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 31#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8
32#define OHCI1394_MAX_SELF_ID_ERRORS 16 32#define OHCI1394_MAX_SELF_ID_ERRORS 16
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index ab1034ccb7f..f3fd8657ce4 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -115,8 +115,8 @@
115 */ 115 */
116static int sbp2_max_speed = IEEE1394_SPEED_MAX; 116static int sbp2_max_speed = IEEE1394_SPEED_MAX;
117module_param_named(max_speed, sbp2_max_speed, int, 0644); 117module_param_named(max_speed, sbp2_max_speed, int, 0644);
118MODULE_PARM_DESC(max_speed, "Force max speed " 118MODULE_PARM_DESC(max_speed, "Limit data transfer speed (5 <= 3200, "
119 "(3 = 800Mb/s, 2 = 400Mb/s, 1 = 200Mb/s, 0 = 100Mb/s)"); 119 "4 <= 1600, 3 <= 800, 2 <= 400, 1 <= 200, 0 = 100 Mb/s)");
120 120
121/* 121/*
122 * Set serialize_io to 0 or N to use dynamically appended lists of command ORBs. 122 * Set serialize_io to 0 or N to use dynamically appended lists of command ORBs.
@@ -256,7 +256,7 @@ static int sbp2_set_busy_timeout(struct sbp2_lu *);
256static int sbp2_max_speed_and_size(struct sbp2_lu *); 256static int sbp2_max_speed_and_size(struct sbp2_lu *);
257 257
258 258
259static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC }; 259static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xa, 0xa, 0xa };
260 260
261static DEFINE_RWLOCK(sbp2_hi_logical_units_lock); 261static DEFINE_RWLOCK(sbp2_hi_logical_units_lock);
262 262
@@ -347,8 +347,8 @@ static struct scsi_host_template sbp2_shost_template = {
347 .sdev_attrs = sbp2_sysfs_sdev_attrs, 347 .sdev_attrs = sbp2_sysfs_sdev_attrs,
348}; 348};
349 349
350/* for match-all entries in sbp2_workarounds_table */ 350#define SBP2_ROM_VALUE_WILDCARD ~0 /* match all */
351#define SBP2_ROM_VALUE_WILDCARD 0x1000000 351#define SBP2_ROM_VALUE_MISSING 0xff000000 /* not present in the unit dir. */
352 352
353/* 353/*
354 * List of devices with known bugs. 354 * List of devices with known bugs.
@@ -359,60 +359,70 @@ static struct scsi_host_template sbp2_shost_template = {
359 */ 359 */
360static const struct { 360static const struct {
361 u32 firmware_revision; 361 u32 firmware_revision;
362 u32 model_id; 362 u32 model;
363 unsigned workarounds; 363 unsigned workarounds;
364} sbp2_workarounds_table[] = { 364} sbp2_workarounds_table[] = {
365 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ { 365 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
366 .firmware_revision = 0x002800, 366 .firmware_revision = 0x002800,
367 .model_id = 0x001010, 367 .model = 0x001010,
368 .workarounds = SBP2_WORKAROUND_INQUIRY_36 | 368 .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
369 SBP2_WORKAROUND_MODE_SENSE_8 | 369 SBP2_WORKAROUND_MODE_SENSE_8 |
370 SBP2_WORKAROUND_POWER_CONDITION, 370 SBP2_WORKAROUND_POWER_CONDITION,
371 }, 371 },
372 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ { 372 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
373 .firmware_revision = 0x002800, 373 .firmware_revision = 0x002800,
374 .model_id = 0x000000, 374 .model = 0x000000,
375 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY | 375 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY |
376 SBP2_WORKAROUND_POWER_CONDITION, 376 SBP2_WORKAROUND_POWER_CONDITION,
377 }, 377 },
378 /* Initio bridges, actually only needed for some older ones */ { 378 /* Initio bridges, actually only needed for some older ones */ {
379 .firmware_revision = 0x000200, 379 .firmware_revision = 0x000200,
380 .model_id = SBP2_ROM_VALUE_WILDCARD, 380 .model = SBP2_ROM_VALUE_WILDCARD,
381 .workarounds = SBP2_WORKAROUND_INQUIRY_36, 381 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
382 }, 382 },
383 /* PL-3507 bridge with Prolific firmware */ { 383 /* PL-3507 bridge with Prolific firmware */ {
384 .firmware_revision = 0x012800, 384 .firmware_revision = 0x012800,
385 .model_id = SBP2_ROM_VALUE_WILDCARD, 385 .model = SBP2_ROM_VALUE_WILDCARD,
386 .workarounds = SBP2_WORKAROUND_POWER_CONDITION, 386 .workarounds = SBP2_WORKAROUND_POWER_CONDITION,
387 }, 387 },
388 /* Symbios bridge */ { 388 /* Symbios bridge */ {
389 .firmware_revision = 0xa0b800, 389 .firmware_revision = 0xa0b800,
390 .model_id = SBP2_ROM_VALUE_WILDCARD, 390 .model = SBP2_ROM_VALUE_WILDCARD,
391 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 391 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
392 }, 392 },
393 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { 393 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ {
394 .firmware_revision = 0x002600, 394 .firmware_revision = 0x002600,
395 .model_id = SBP2_ROM_VALUE_WILDCARD, 395 .model = SBP2_ROM_VALUE_WILDCARD,
396 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 396 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
397 }, 397 },
398 /*
399 * iPod 2nd generation: needs 128k max transfer size workaround
400 * iPod 3rd generation: needs fix capacity workaround
401 */
402 {
403 .firmware_revision = 0x0a2700,
404 .model = 0x000000,
405 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS |
406 SBP2_WORKAROUND_FIX_CAPACITY,
407 },
398 /* iPod 4th generation */ { 408 /* iPod 4th generation */ {
399 .firmware_revision = 0x0a2700, 409 .firmware_revision = 0x0a2700,
400 .model_id = 0x000021, 410 .model = 0x000021,
401 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 411 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
402 }, 412 },
403 /* iPod mini */ { 413 /* iPod mini */ {
404 .firmware_revision = 0x0a2700, 414 .firmware_revision = 0x0a2700,
405 .model_id = 0x000022, 415 .model = 0x000022,
406 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 416 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
407 }, 417 },
408 /* iPod mini */ { 418 /* iPod mini */ {
409 .firmware_revision = 0x0a2700, 419 .firmware_revision = 0x0a2700,
410 .model_id = 0x000023, 420 .model = 0x000023,
411 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 421 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
412 }, 422 },
413 /* iPod Photo */ { 423 /* iPod Photo */ {
414 .firmware_revision = 0x0a2700, 424 .firmware_revision = 0x0a2700,
415 .model_id = 0x00007e, 425 .model = 0x00007e,
416 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 426 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
417 } 427 }
418}; 428};
@@ -1341,13 +1351,15 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1341 struct csr1212_keyval *kv; 1351 struct csr1212_keyval *kv;
1342 struct csr1212_dentry *dentry; 1352 struct csr1212_dentry *dentry;
1343 u64 management_agent_addr; 1353 u64 management_agent_addr;
1344 u32 unit_characteristics, firmware_revision; 1354 u32 unit_characteristics, firmware_revision, model;
1345 unsigned workarounds; 1355 unsigned workarounds;
1346 int i; 1356 int i;
1347 1357
1348 management_agent_addr = 0; 1358 management_agent_addr = 0;
1349 unit_characteristics = 0; 1359 unit_characteristics = 0;
1350 firmware_revision = 0; 1360 firmware_revision = SBP2_ROM_VALUE_MISSING;
1361 model = ud->flags & UNIT_DIRECTORY_MODEL_ID ?
1362 ud->model_id : SBP2_ROM_VALUE_MISSING;
1351 1363
1352 csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) { 1364 csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) {
1353 switch (kv->key.id) { 1365 switch (kv->key.id) {
@@ -1388,9 +1400,9 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1388 sbp2_workarounds_table[i].firmware_revision != 1400 sbp2_workarounds_table[i].firmware_revision !=
1389 (firmware_revision & 0xffff00)) 1401 (firmware_revision & 0xffff00))
1390 continue; 1402 continue;
1391 if (sbp2_workarounds_table[i].model_id != 1403 if (sbp2_workarounds_table[i].model !=
1392 SBP2_ROM_VALUE_WILDCARD && 1404 SBP2_ROM_VALUE_WILDCARD &&
1393 sbp2_workarounds_table[i].model_id != ud->model_id) 1405 sbp2_workarounds_table[i].model != model)
1394 continue; 1406 continue;
1395 workarounds |= sbp2_workarounds_table[i].workarounds; 1407 workarounds |= sbp2_workarounds_table[i].workarounds;
1396 break; 1408 break;
@@ -1403,7 +1415,7 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1403 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid), 1415 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
1404 workarounds, firmware_revision, 1416 workarounds, firmware_revision,
1405 ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id, 1417 ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id,
1406 ud->model_id); 1418 model);
1407 1419
1408 /* We would need one SCSI host template for each target to adjust 1420 /* We would need one SCSI host template for each target to adjust
1409 * max_sectors on the fly, therefore warn only. */ 1421 * max_sectors on the fly, therefore warn only. */
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index 90663e01a56..60156dfdc60 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -224,7 +224,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
224 break; 224 break;
225 225
226 /* If the Guest asked to be stopped, we sleep. The Guest's 226 /* If the Guest asked to be stopped, we sleep. The Guest's
227 * clock timer or LHCALL_BREAK from the Waker will wake us. */ 227 * clock timer or LHREQ_BREAK from the Waker will wake us. */
228 if (cpu->halted) { 228 if (cpu->halted) {
229 set_current_state(TASK_INTERRUPTIBLE); 229 set_current_state(TASK_INTERRUPTIBLE);
230 schedule(); 230 schedule();
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 34bc017b8b3..b8ee103eed5 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -307,9 +307,8 @@ static int close(struct inode *inode, struct file *file)
307 * kmalloc()ed string, either of which is ok to hand to kfree(). */ 307 * kmalloc()ed string, either of which is ok to hand to kfree(). */
308 if (!IS_ERR(lg->dead)) 308 if (!IS_ERR(lg->dead))
309 kfree(lg->dead); 309 kfree(lg->dead);
310 /* We clear the entire structure, which also marks it as free for the 310 /* Free the memory allocated to the lguest_struct */
311 * next user. */ 311 kfree(lg);
312 memset(lg, 0, sizeof(*lg));
313 /* Release lock and exit. */ 312 /* Release lock and exit. */
314 mutex_unlock(&lguest_lock); 313 mutex_unlock(&lguest_lock);
315 314
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index 05e29828923..10c421b73ea 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -758,7 +758,7 @@ static void __exit ilo_exit(void)
758 class_destroy(ilo_class); 758 class_destroy(ilo_class);
759} 759}
760 760
761MODULE_VERSION("0.05"); 761MODULE_VERSION("0.06");
762MODULE_ALIAS(ILO_NAME); 762MODULE_ALIAS(ILO_NAME);
763MODULE_DESCRIPTION(ILO_NAME); 763MODULE_DESCRIPTION(ILO_NAME);
764MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>"); 764MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>");
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c
index 9cd2ebe2a3b..45fd653dbe3 100644
--- a/drivers/misc/sgi-xp/xpc_channel.c
+++ b/drivers/misc/sgi-xp/xpc_channel.c
@@ -49,9 +49,6 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
49 49
50 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING)) 50 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING))
51 return; 51 return;
52
53 DBUG_ON(ch->local_msgqueue == NULL);
54 DBUG_ON(ch->remote_msgqueue == NULL);
55 } 52 }
56 53
57 if (!(ch->flags & XPC_C_OPENREPLY)) { 54 if (!(ch->flags & XPC_C_OPENREPLY)) {
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index 82fb9958f22..2e975762c32 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -1106,8 +1106,6 @@ xpc_process_activate_IRQ_rcvd_sn2(void)
1106 int n_IRQs_expected; 1106 int n_IRQs_expected;
1107 int n_IRQs_detected; 1107 int n_IRQs_detected;
1108 1108
1109 DBUG_ON(xpc_activate_IRQ_rcvd == 0);
1110
1111 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags); 1109 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
1112 n_IRQs_expected = xpc_activate_IRQ_rcvd; 1110 n_IRQs_expected = xpc_activate_IRQ_rcvd;
1113 xpc_activate_IRQ_rcvd = 0; 1111 xpc_activate_IRQ_rcvd = 0;
@@ -1726,6 +1724,7 @@ xpc_clear_local_msgqueue_flags_sn2(struct xpc_channel *ch)
1726 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->local_msgqueue + 1724 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->local_msgqueue +
1727 (get % ch->local_nentries) * 1725 (get % ch->local_nentries) *
1728 ch->entry_size); 1726 ch->entry_size);
1727 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1729 msg->flags = 0; 1728 msg->flags = 0;
1730 } while (++get < ch_sn2->remote_GP.get); 1729 } while (++get < ch_sn2->remote_GP.get);
1731} 1730}
@@ -1740,11 +1739,18 @@ xpc_clear_remote_msgqueue_flags_sn2(struct xpc_channel *ch)
1740 struct xpc_msg_sn2 *msg; 1739 struct xpc_msg_sn2 *msg;
1741 s64 put; 1740 s64 put;
1742 1741
1743 put = ch_sn2->w_remote_GP.put; 1742 /* flags are zeroed when the buffer is allocated */
1743 if (ch_sn2->remote_GP.put < ch->remote_nentries)
1744 return;
1745
1746 put = max(ch_sn2->w_remote_GP.put, ch->remote_nentries);
1744 do { 1747 do {
1745 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->remote_msgqueue + 1748 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->remote_msgqueue +
1746 (put % ch->remote_nentries) * 1749 (put % ch->remote_nentries) *
1747 ch->entry_size); 1750 ch->entry_size);
1751 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1752 DBUG_ON(!(msg->flags & XPC_M_SN2_DONE));
1753 DBUG_ON(msg->number != put - ch->remote_nentries);
1748 msg->flags = 0; 1754 msg->flags = 0;
1749 } while (++put < ch_sn2->remote_GP.put); 1755 } while (++put < ch_sn2->remote_GP.put);
1750} 1756}
@@ -1836,6 +1842,7 @@ xpc_process_msg_chctl_flags_sn2(struct xpc_partition *part, int ch_number)
1836 */ 1842 */
1837 xpc_clear_remote_msgqueue_flags_sn2(ch); 1843 xpc_clear_remote_msgqueue_flags_sn2(ch);
1838 1844
1845 smp_wmb(); /* ensure flags have been cleared before bte_copy */
1839 ch_sn2->w_remote_GP.put = ch_sn2->remote_GP.put; 1846 ch_sn2->w_remote_GP.put = ch_sn2->remote_GP.put;
1840 1847
1841 dev_dbg(xpc_chan, "w_remote_GP.put changed to %ld, partid=%d, " 1848 dev_dbg(xpc_chan, "w_remote_GP.put changed to %ld, partid=%d, "
@@ -1934,7 +1941,7 @@ xpc_get_deliverable_payload_sn2(struct xpc_channel *ch)
1934 break; 1941 break;
1935 1942
1936 get = ch_sn2->w_local_GP.get; 1943 get = ch_sn2->w_local_GP.get;
1937 rmb(); /* guarantee that .get loads before .put */ 1944 smp_rmb(); /* guarantee that .get loads before .put */
1938 if (get == ch_sn2->w_remote_GP.put) 1945 if (get == ch_sn2->w_remote_GP.put)
1939 break; 1946 break;
1940 1947
@@ -1956,11 +1963,13 @@ xpc_get_deliverable_payload_sn2(struct xpc_channel *ch)
1956 1963
1957 msg = xpc_pull_remote_msg_sn2(ch, get); 1964 msg = xpc_pull_remote_msg_sn2(ch, get);
1958 1965
1959 DBUG_ON(msg != NULL && msg->number != get); 1966 if (msg != NULL) {
1960 DBUG_ON(msg != NULL && (msg->flags & XPC_M_SN2_DONE)); 1967 DBUG_ON(msg->number != get);
1961 DBUG_ON(msg != NULL && !(msg->flags & XPC_M_SN2_READY)); 1968 DBUG_ON(msg->flags & XPC_M_SN2_DONE);
1969 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1962 1970
1963 payload = &msg->payload; 1971 payload = &msg->payload;
1972 }
1964 break; 1973 break;
1965 } 1974 }
1966 1975
@@ -2053,7 +2062,7 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
2053 while (1) { 2062 while (1) {
2054 2063
2055 put = ch_sn2->w_local_GP.put; 2064 put = ch_sn2->w_local_GP.put;
2056 rmb(); /* guarantee that .put loads before .get */ 2065 smp_rmb(); /* guarantee that .put loads before .get */
2057 if (put - ch_sn2->w_remote_GP.get < ch->local_nentries) { 2066 if (put - ch_sn2->w_remote_GP.get < ch->local_nentries) {
2058 2067
2059 /* There are available message entries. We need to try 2068 /* There are available message entries. We need to try
@@ -2186,7 +2195,7 @@ xpc_send_payload_sn2(struct xpc_channel *ch, u32 flags, void *payload,
2186 * The preceding store of msg->flags must occur before the following 2195 * The preceding store of msg->flags must occur before the following
2187 * load of local_GP->put. 2196 * load of local_GP->put.
2188 */ 2197 */
2189 mb(); 2198 smp_mb();
2190 2199
2191 /* see if the message is next in line to be sent, if so send it */ 2200 /* see if the message is next in line to be sent, if so send it */
2192 2201
@@ -2277,8 +2286,9 @@ xpc_received_payload_sn2(struct xpc_channel *ch, void *payload)
2277 dev_dbg(xpc_chan, "msg=0x%p, msg_number=%ld, partid=%d, channel=%d\n", 2286 dev_dbg(xpc_chan, "msg=0x%p, msg_number=%ld, partid=%d, channel=%d\n",
2278 (void *)msg, msg_number, ch->partid, ch->number); 2287 (void *)msg, msg_number, ch->partid, ch->number);
2279 2288
2280 DBUG_ON((((u64)msg - (u64)ch->remote_msgqueue) / ch->entry_size) != 2289 DBUG_ON((((u64)msg - (u64)ch->sn.sn2.remote_msgqueue) / ch->entry_size) !=
2281 msg_number % ch->remote_nentries); 2290 msg_number % ch->remote_nentries);
2291 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
2282 DBUG_ON(msg->flags & XPC_M_SN2_DONE); 2292 DBUG_ON(msg->flags & XPC_M_SN2_DONE);
2283 2293
2284 msg->flags |= XPC_M_SN2_DONE; 2294 msg->flags |= XPC_M_SN2_DONE;
@@ -2287,7 +2297,7 @@ xpc_received_payload_sn2(struct xpc_channel *ch, void *payload)
2287 * The preceding store of msg->flags must occur before the following 2297 * The preceding store of msg->flags must occur before the following
2288 * load of local_GP->get. 2298 * load of local_GP->get.
2289 */ 2299 */
2290 mb(); 2300 smp_mb();
2291 2301
2292 /* 2302 /*
2293 * See if this message is next in line to be acknowledged as having 2303 * See if this message is next in line to be acknowledged as having
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index 91a55b1b103..f17f7d40ea2 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -1423,7 +1423,7 @@ xpc_send_payload_uv(struct xpc_channel *ch, u32 flags, void *payload,
1423 atomic_inc(&ch->n_to_notify); 1423 atomic_inc(&ch->n_to_notify);
1424 1424
1425 msg_slot->key = key; 1425 msg_slot->key = key;
1426 wmb(); /* a non-NULL func must hit memory after the key */ 1426 smp_wmb(); /* a non-NULL func must hit memory after the key */
1427 msg_slot->func = func; 1427 msg_slot->func = func;
1428 1428
1429 if (ch->flags & XPC_C_DISCONNECTING) { 1429 if (ch->flags & XPC_C_DISCONNECTING) {
diff --git a/drivers/mtd/ubi/Kconfig.debug b/drivers/mtd/ubi/Kconfig.debug
index 1e2ee22edef..2246f154e2f 100644
--- a/drivers/mtd/ubi/Kconfig.debug
+++ b/drivers/mtd/ubi/Kconfig.debug
@@ -33,16 +33,6 @@ config MTD_UBI_DEBUG_DISABLE_BGT
33 This option switches the background thread off by default. The thread 33 This option switches the background thread off by default. The thread
34 may be also be enabled/disabled via UBI sysfs. 34 may be also be enabled/disabled via UBI sysfs.
35 35
36config MTD_UBI_DEBUG_USERSPACE_IO
37 bool "Direct user-space write/erase support"
38 default n
39 depends on MTD_UBI_DEBUG
40 help
41 By default, users cannot directly write and erase individual
42 eraseblocks of dynamic volumes, and have to use update operation
43 instead. This option enables this capability - it is very useful for
44 debugging and testing.
45
46config MTD_UBI_DEBUG_EMULATE_BITFLIPS 36config MTD_UBI_DEBUG_EMULATE_BITFLIPS
47 bool "Emulate flash bit-flips" 37 bool "Emulate flash bit-flips"
48 depends on MTD_UBI_DEBUG 38 depends on MTD_UBI_DEBUG
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 9082768cc6c..4048db83aef 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -263,8 +263,12 @@ static ssize_t dev_attribute_show(struct device *dev,
263 return ret; 263 return ret;
264} 264}
265 265
266/* Fake "release" method for UBI devices */ 266static void dev_release(struct device *dev)
267static void dev_release(struct device *dev) { } 267{
268 struct ubi_device *ubi = container_of(dev, struct ubi_device, dev);
269
270 kfree(ubi);
271}
268 272
269/** 273/**
270 * ubi_sysfs_init - initialize sysfs for an UBI device. 274 * ubi_sysfs_init - initialize sysfs for an UBI device.
@@ -380,7 +384,7 @@ static void free_user_volumes(struct ubi_device *ubi)
380 */ 384 */
381static int uif_init(struct ubi_device *ubi) 385static int uif_init(struct ubi_device *ubi)
382{ 386{
383 int i, err, do_free = 0; 387 int i, err;
384 dev_t dev; 388 dev_t dev;
385 389
386 sprintf(ubi->ubi_name, UBI_NAME_STR "%d", ubi->ubi_num); 390 sprintf(ubi->ubi_name, UBI_NAME_STR "%d", ubi->ubi_num);
@@ -427,13 +431,10 @@ static int uif_init(struct ubi_device *ubi)
427 431
428out_volumes: 432out_volumes:
429 kill_volumes(ubi); 433 kill_volumes(ubi);
430 do_free = 0;
431out_sysfs: 434out_sysfs:
432 ubi_sysfs_close(ubi); 435 ubi_sysfs_close(ubi);
433 cdev_del(&ubi->cdev); 436 cdev_del(&ubi->cdev);
434out_unreg: 437out_unreg:
435 if (do_free)
436 free_user_volumes(ubi);
437 unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1); 438 unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1);
438 ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err); 439 ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err);
439 return err; 440 return err;
@@ -947,6 +948,12 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
947 if (ubi->bgt_thread) 948 if (ubi->bgt_thread)
948 kthread_stop(ubi->bgt_thread); 949 kthread_stop(ubi->bgt_thread);
949 950
951 /*
952 * Get a reference to the device in order to prevent 'dev_release()'
953 * from freeing @ubi object.
954 */
955 get_device(&ubi->dev);
956
950 uif_close(ubi); 957 uif_close(ubi);
951 ubi_wl_close(ubi); 958 ubi_wl_close(ubi);
952 free_internal_volumes(ubi); 959 free_internal_volumes(ubi);
@@ -958,7 +965,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
958 vfree(ubi->dbg_peb_buf); 965 vfree(ubi->dbg_peb_buf);
959#endif 966#endif
960 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); 967 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num);
961 kfree(ubi); 968 put_device(&ubi->dev);
962 return 0; 969 return 0;
963} 970}
964 971
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 98cf31ed081..e63c8fc3df3 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -40,9 +40,9 @@
40#include <linux/ioctl.h> 40#include <linux/ioctl.h>
41#include <linux/capability.h> 41#include <linux/capability.h>
42#include <linux/uaccess.h> 42#include <linux/uaccess.h>
43#include <linux/smp_lock.h> 43#include <linux/compat.h>
44#include <linux/math64.h>
44#include <mtd/ubi-user.h> 45#include <mtd/ubi-user.h>
45#include <asm/div64.h>
46#include "ubi.h" 46#include "ubi.h"
47 47
48/** 48/**
@@ -195,7 +195,6 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
195 int err, lnum, off, len, tbuf_size; 195 int err, lnum, off, len, tbuf_size;
196 size_t count_save = count; 196 size_t count_save = count;
197 void *tbuf; 197 void *tbuf;
198 uint64_t tmp;
199 198
200 dbg_gen("read %zd bytes from offset %lld of volume %d", 199 dbg_gen("read %zd bytes from offset %lld of volume %d",
201 count, *offp, vol->vol_id); 200 count, *offp, vol->vol_id);
@@ -225,10 +224,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
225 return -ENOMEM; 224 return -ENOMEM;
226 225
227 len = count > tbuf_size ? tbuf_size : count; 226 len = count > tbuf_size ? tbuf_size : count;
228 227 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
229 tmp = *offp;
230 off = do_div(tmp, vol->usable_leb_size);
231 lnum = tmp;
232 228
233 do { 229 do {
234 cond_resched(); 230 cond_resched();
@@ -263,12 +259,9 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
263 return err ? err : count_save - count; 259 return err ? err : count_save - count;
264} 260}
265 261
266#ifdef CONFIG_MTD_UBI_DEBUG_USERSPACE_IO
267
268/* 262/*
269 * This function allows to directly write to dynamic UBI volumes, without 263 * This function allows to directly write to dynamic UBI volumes, without
270 * issuing the volume update operation. Available only as a debugging feature. 264 * issuing the volume update operation.
271 * Very useful for testing UBI.
272 */ 265 */
273static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, 266static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
274 size_t count, loff_t *offp) 267 size_t count, loff_t *offp)
@@ -279,7 +272,9 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
279 int lnum, off, len, tbuf_size, err = 0; 272 int lnum, off, len, tbuf_size, err = 0;
280 size_t count_save = count; 273 size_t count_save = count;
281 char *tbuf; 274 char *tbuf;
282 uint64_t tmp; 275
276 if (!vol->direct_writes)
277 return -EPERM;
283 278
284 dbg_gen("requested: write %zd bytes to offset %lld of volume %u", 279 dbg_gen("requested: write %zd bytes to offset %lld of volume %u",
285 count, *offp, vol->vol_id); 280 count, *offp, vol->vol_id);
@@ -287,10 +282,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
287 if (vol->vol_type == UBI_STATIC_VOLUME) 282 if (vol->vol_type == UBI_STATIC_VOLUME)
288 return -EROFS; 283 return -EROFS;
289 284
290 tmp = *offp; 285 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
291 off = do_div(tmp, vol->usable_leb_size);
292 lnum = tmp;
293
294 if (off & (ubi->min_io_size - 1)) { 286 if (off & (ubi->min_io_size - 1)) {
295 dbg_err("unaligned position"); 287 dbg_err("unaligned position");
296 return -EINVAL; 288 return -EINVAL;
@@ -347,10 +339,6 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
347 return err ? err : count_save - count; 339 return err ? err : count_save - count;
348} 340}
349 341
350#else
351#define vol_cdev_direct_write(file, buf, count, offp) (-EPERM)
352#endif /* CONFIG_MTD_UBI_DEBUG_USERSPACE_IO */
353
354static ssize_t vol_cdev_write(struct file *file, const char __user *buf, 342static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
355 size_t count, loff_t *offp) 343 size_t count, loff_t *offp)
356{ 344{
@@ -402,8 +390,8 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
402 return count; 390 return count;
403} 391}
404 392
405static int vol_cdev_ioctl(struct inode *inode, struct file *file, 393static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
406 unsigned int cmd, unsigned long arg) 394 unsigned long arg)
407{ 395{
408 int err = 0; 396 int err = 0;
409 struct ubi_volume_desc *desc = file->private_data; 397 struct ubi_volume_desc *desc = file->private_data;
@@ -487,7 +475,6 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
487 break; 475 break;
488 } 476 }
489 477
490#ifdef CONFIG_MTD_UBI_DEBUG_USERSPACE_IO
491 /* Logical eraseblock erasure command */ 478 /* Logical eraseblock erasure command */
492 case UBI_IOCEBER: 479 case UBI_IOCEBER:
493 { 480 {
@@ -518,13 +505,77 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
518 err = ubi_wl_flush(ubi); 505 err = ubi_wl_flush(ubi);
519 break; 506 break;
520 } 507 }
521#endif 508
509 /* Logical eraseblock map command */
510 case UBI_IOCEBMAP:
511 {
512 struct ubi_map_req req;
513
514 err = copy_from_user(&req, argp, sizeof(struct ubi_map_req));
515 if (err) {
516 err = -EFAULT;
517 break;
518 }
519 err = ubi_leb_map(desc, req.lnum, req.dtype);
520 break;
521 }
522
523 /* Logical eraseblock un-map command */
524 case UBI_IOCEBUNMAP:
525 {
526 int32_t lnum;
527
528 err = get_user(lnum, (__user int32_t *)argp);
529 if (err) {
530 err = -EFAULT;
531 break;
532 }
533 err = ubi_leb_unmap(desc, lnum);
534 break;
535 }
536
537 /* Check if logical eraseblock is mapped command */
538 case UBI_IOCEBISMAP:
539 {
540 int32_t lnum;
541
542 err = get_user(lnum, (__user int32_t *)argp);
543 if (err) {
544 err = -EFAULT;
545 break;
546 }
547 err = ubi_is_mapped(desc, lnum);
548 break;
549 }
550
551 /* Set volume property command*/
552 case UBI_IOCSETPROP:
553 {
554 struct ubi_set_prop_req req;
555
556 err = copy_from_user(&req, argp,
557 sizeof(struct ubi_set_prop_req));
558 if (err) {
559 err = -EFAULT;
560 break;
561 }
562 switch (req.property) {
563 case UBI_PROP_DIRECT_WRITE:
564 mutex_lock(&ubi->volumes_mutex);
565 desc->vol->direct_writes = !!req.value;
566 mutex_unlock(&ubi->volumes_mutex);
567 break;
568 default:
569 err = -EINVAL;
570 break;
571 }
572 break;
573 }
522 574
523 default: 575 default:
524 err = -ENOTTY; 576 err = -ENOTTY;
525 break; 577 break;
526 } 578 }
527
528 return err; 579 return err;
529} 580}
530 581
@@ -762,8 +813,8 @@ out_free:
762 return err; 813 return err;
763} 814}
764 815
765static int ubi_cdev_ioctl(struct inode *inode, struct file *file, 816static long ubi_cdev_ioctl(struct file *file, unsigned int cmd,
766 unsigned int cmd, unsigned long arg) 817 unsigned long arg)
767{ 818{
768 int err = 0; 819 int err = 0;
769 struct ubi_device *ubi; 820 struct ubi_device *ubi;
@@ -773,7 +824,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
773 if (!capable(CAP_SYS_RESOURCE)) 824 if (!capable(CAP_SYS_RESOURCE))
774 return -EPERM; 825 return -EPERM;
775 826
776 ubi = ubi_get_by_major(imajor(inode)); 827 ubi = ubi_get_by_major(imajor(file->f_mapping->host));
777 if (!ubi) 828 if (!ubi)
778 return -ENODEV; 829 return -ENODEV;
779 830
@@ -843,7 +894,6 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
843 case UBI_IOCRSVOL: 894 case UBI_IOCRSVOL:
844 { 895 {
845 int pebs; 896 int pebs;
846 uint64_t tmp;
847 struct ubi_rsvol_req req; 897 struct ubi_rsvol_req req;
848 898
849 dbg_gen("re-size volume"); 899 dbg_gen("re-size volume");
@@ -863,9 +913,8 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
863 break; 913 break;
864 } 914 }
865 915
866 tmp = req.bytes; 916 pebs = div_u64(req.bytes + desc->vol->usable_leb_size - 1,
867 pebs = !!do_div(tmp, desc->vol->usable_leb_size); 917 desc->vol->usable_leb_size);
868 pebs += tmp;
869 918
870 mutex_lock(&ubi->volumes_mutex); 919 mutex_lock(&ubi->volumes_mutex);
871 err = ubi_resize_volume(desc, pebs); 920 err = ubi_resize_volume(desc, pebs);
@@ -909,8 +958,8 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
909 return err; 958 return err;
910} 959}
911 960
912static int ctrl_cdev_ioctl(struct inode *inode, struct file *file, 961static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,
913 unsigned int cmd, unsigned long arg) 962 unsigned long arg)
914{ 963{
915 int err = 0; 964 int err = 0;
916 void __user *argp = (void __user *)arg; 965 void __user *argp = (void __user *)arg;
@@ -986,26 +1035,59 @@ static int ctrl_cdev_ioctl(struct inode *inode, struct file *file,
986 return err; 1035 return err;
987} 1036}
988 1037
989/* UBI control character device operations */ 1038#ifdef CONFIG_COMPAT
990struct file_operations ubi_ctrl_cdev_operations = { 1039static long vol_cdev_compat_ioctl(struct file *file, unsigned int cmd,
991 .ioctl = ctrl_cdev_ioctl, 1040 unsigned long arg)
992 .owner = THIS_MODULE, 1041{
1042 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1043
1044 return vol_cdev_ioctl(file, cmd, translated_arg);
1045}
1046
1047static long ubi_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1048 unsigned long arg)
1049{
1050 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1051
1052 return ubi_cdev_ioctl(file, cmd, translated_arg);
1053}
1054
1055static long ctrl_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1056 unsigned long arg)
1057{
1058 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1059
1060 return ctrl_cdev_ioctl(file, cmd, translated_arg);
1061}
1062#else
1063#define vol_cdev_compat_ioctl NULL
1064#define ubi_cdev_compat_ioctl NULL
1065#define ctrl_cdev_compat_ioctl NULL
1066#endif
1067
1068/* UBI volume character device operations */
1069const struct file_operations ubi_vol_cdev_operations = {
1070 .owner = THIS_MODULE,
1071 .open = vol_cdev_open,
1072 .release = vol_cdev_release,
1073 .llseek = vol_cdev_llseek,
1074 .read = vol_cdev_read,
1075 .write = vol_cdev_write,
1076 .unlocked_ioctl = vol_cdev_ioctl,
1077 .compat_ioctl = vol_cdev_compat_ioctl,
993}; 1078};
994 1079
995/* UBI character device operations */ 1080/* UBI character device operations */
996struct file_operations ubi_cdev_operations = { 1081const struct file_operations ubi_cdev_operations = {
997 .owner = THIS_MODULE, 1082 .owner = THIS_MODULE,
998 .ioctl = ubi_cdev_ioctl, 1083 .llseek = no_llseek,
999 .llseek = no_llseek, 1084 .unlocked_ioctl = ubi_cdev_ioctl,
1085 .compat_ioctl = ubi_cdev_compat_ioctl,
1000}; 1086};
1001 1087
1002/* UBI volume character device operations */ 1088/* UBI control character device operations */
1003struct file_operations ubi_vol_cdev_operations = { 1089const struct file_operations ubi_ctrl_cdev_operations = {
1004 .owner = THIS_MODULE, 1090 .owner = THIS_MODULE,
1005 .open = vol_cdev_open, 1091 .unlocked_ioctl = ctrl_cdev_ioctl,
1006 .release = vol_cdev_release, 1092 .compat_ioctl = ctrl_cdev_compat_ioctl,
1007 .llseek = vol_cdev_llseek,
1008 .read = vol_cdev_read,
1009 .write = vol_cdev_write,
1010 .ioctl = vol_cdev_ioctl,
1011}; 1093};
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index 6dd4f5e77f8..49cd55ade9c 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -28,7 +28,7 @@
28 * eraseblock size is equivalent to the logical eraseblock size of the volume. 28 * eraseblock size is equivalent to the logical eraseblock size of the volume.
29 */ 29 */
30 30
31#include <asm/div64.h> 31#include <linux/math64.h>
32#include "ubi.h" 32#include "ubi.h"
33 33
34/** 34/**
@@ -109,7 +109,6 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
109 int err = 0, lnum, offs, total_read; 109 int err = 0, lnum, offs, total_read;
110 struct ubi_volume *vol; 110 struct ubi_volume *vol;
111 struct ubi_device *ubi; 111 struct ubi_device *ubi;
112 uint64_t tmp = from;
113 112
114 dbg_gen("read %zd bytes from offset %lld", len, from); 113 dbg_gen("read %zd bytes from offset %lld", len, from);
115 114
@@ -119,9 +118,7 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
119 vol = container_of(mtd, struct ubi_volume, gluebi_mtd); 118 vol = container_of(mtd, struct ubi_volume, gluebi_mtd);
120 ubi = vol->ubi; 119 ubi = vol->ubi;
121 120
122 offs = do_div(tmp, mtd->erasesize); 121 lnum = div_u64_rem(from, mtd->erasesize, &offs);
123 lnum = tmp;
124
125 total_read = len; 122 total_read = len;
126 while (total_read) { 123 while (total_read) {
127 size_t to_read = mtd->erasesize - offs; 124 size_t to_read = mtd->erasesize - offs;
@@ -160,7 +157,6 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
160 int err = 0, lnum, offs, total_written; 157 int err = 0, lnum, offs, total_written;
161 struct ubi_volume *vol; 158 struct ubi_volume *vol;
162 struct ubi_device *ubi; 159 struct ubi_device *ubi;
163 uint64_t tmp = to;
164 160
165 dbg_gen("write %zd bytes to offset %lld", len, to); 161 dbg_gen("write %zd bytes to offset %lld", len, to);
166 162
@@ -173,8 +169,7 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
173 if (ubi->ro_mode) 169 if (ubi->ro_mode)
174 return -EROFS; 170 return -EROFS;
175 171
176 offs = do_div(tmp, mtd->erasesize); 172 lnum = div_u64_rem(to, mtd->erasesize, &offs);
177 lnum = tmp;
178 173
179 if (len % mtd->writesize || offs % mtd->writesize) 174 if (len % mtd->writesize || offs % mtd->writesize)
180 return -EINVAL; 175 return -EINVAL;
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index ecde202a5a1..c3d653ba5ca 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -42,7 +42,7 @@
42 42
43#include <linux/err.h> 43#include <linux/err.h>
44#include <linux/crc32.h> 44#include <linux/crc32.h>
45#include <asm/div64.h> 45#include <linux/math64.h>
46#include "ubi.h" 46#include "ubi.h"
47 47
48#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 48#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
@@ -904,10 +904,8 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
904 dbg_msg("scanning is finished"); 904 dbg_msg("scanning is finished");
905 905
906 /* Calculate mean erase counter */ 906 /* Calculate mean erase counter */
907 if (si->ec_count) { 907 if (si->ec_count)
908 do_div(si->ec_sum, si->ec_count); 908 si->mean_ec = div_u64(si->ec_sum, si->ec_count);
909 si->mean_ec = si->ec_sum;
910 }
911 909
912 if (si->is_empty) 910 if (si->is_empty)
913 ubi_msg("empty MTD device detected"); 911 ubi_msg("empty MTD device detected");
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 4a8ec485c91..c055511bb1b 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -206,6 +206,7 @@ struct ubi_volume_desc;
206 * @upd_marker: %1 if the update marker is set for this volume 206 * @upd_marker: %1 if the update marker is set for this volume
207 * @updating: %1 if the volume is being updated 207 * @updating: %1 if the volume is being updated
208 * @changing_leb: %1 if the atomic LEB change ioctl command is in progress 208 * @changing_leb: %1 if the atomic LEB change ioctl command is in progress
209 * @direct_writes: %1 if direct writes are enabled for this volume
209 * 210 *
210 * @gluebi_desc: gluebi UBI volume descriptor 211 * @gluebi_desc: gluebi UBI volume descriptor
211 * @gluebi_refcount: reference count of the gluebi MTD device 212 * @gluebi_refcount: reference count of the gluebi MTD device
@@ -253,6 +254,7 @@ struct ubi_volume {
253 unsigned int upd_marker:1; 254 unsigned int upd_marker:1;
254 unsigned int updating:1; 255 unsigned int updating:1;
255 unsigned int changing_leb:1; 256 unsigned int changing_leb:1;
257 unsigned int direct_writes:1;
256 258
257#ifdef CONFIG_MTD_UBI_GLUEBI 259#ifdef CONFIG_MTD_UBI_GLUEBI
258 /* 260 /*
@@ -304,7 +306,8 @@ struct ubi_wl_entry;
304 * @vtbl_size: size of the volume table in bytes 306 * @vtbl_size: size of the volume table in bytes
305 * @vtbl: in-RAM volume table copy 307 * @vtbl: in-RAM volume table copy
306 * @volumes_mutex: protects on-flash volume table and serializes volume 308 * @volumes_mutex: protects on-flash volume table and serializes volume
307 * changes, like creation, deletion, update, re-size and re-name 309 * changes, like creation, deletion, update, re-size,
310 * re-name and set property
308 * 311 *
309 * @max_ec: current highest erase counter value 312 * @max_ec: current highest erase counter value
310 * @mean_ec: current mean erase counter value 313 * @mean_ec: current mean erase counter value
@@ -449,9 +452,9 @@ struct ubi_device {
449}; 452};
450 453
451extern struct kmem_cache *ubi_wl_entry_slab; 454extern struct kmem_cache *ubi_wl_entry_slab;
452extern struct file_operations ubi_ctrl_cdev_operations; 455extern const struct file_operations ubi_ctrl_cdev_operations;
453extern struct file_operations ubi_cdev_operations; 456extern const struct file_operations ubi_cdev_operations;
454extern struct file_operations ubi_vol_cdev_operations; 457extern const struct file_operations ubi_vol_cdev_operations;
455extern struct class *ubi_class; 458extern struct class *ubi_class;
456extern struct mutex ubi_devices_mutex; 459extern struct mutex ubi_devices_mutex;
457 460
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index 8b89cc18ff0..6b4d1ae891a 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -40,7 +40,7 @@
40 40
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/uaccess.h> 42#include <linux/uaccess.h>
43#include <asm/div64.h> 43#include <linux/math64.h>
44#include "ubi.h" 44#include "ubi.h"
45 45
46/** 46/**
@@ -89,7 +89,6 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
89 long long bytes) 89 long long bytes)
90{ 90{
91 int err; 91 int err;
92 uint64_t tmp;
93 struct ubi_vtbl_record vtbl_rec; 92 struct ubi_vtbl_record vtbl_rec;
94 93
95 dbg_gen("clear update marker for volume %d", vol->vol_id); 94 dbg_gen("clear update marker for volume %d", vol->vol_id);
@@ -101,9 +100,9 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
101 100
102 if (vol->vol_type == UBI_STATIC_VOLUME) { 101 if (vol->vol_type == UBI_STATIC_VOLUME) {
103 vol->corrupted = 0; 102 vol->corrupted = 0;
104 vol->used_bytes = tmp = bytes; 103 vol->used_bytes = bytes;
105 vol->last_eb_bytes = do_div(tmp, vol->usable_leb_size); 104 vol->used_ebs = div_u64_rem(bytes, vol->usable_leb_size,
106 vol->used_ebs = tmp; 105 &vol->last_eb_bytes);
107 if (vol->last_eb_bytes) 106 if (vol->last_eb_bytes)
108 vol->used_ebs += 1; 107 vol->used_ebs += 1;
109 else 108 else
@@ -131,7 +130,6 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
131 long long bytes) 130 long long bytes)
132{ 131{
133 int i, err; 132 int i, err;
134 uint64_t tmp;
135 133
136 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes); 134 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes);
137 ubi_assert(!vol->updating && !vol->changing_leb); 135 ubi_assert(!vol->updating && !vol->changing_leb);
@@ -161,9 +159,8 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
161 if (!vol->upd_buf) 159 if (!vol->upd_buf)
162 return -ENOMEM; 160 return -ENOMEM;
163 161
164 tmp = bytes; 162 vol->upd_ebs = div_u64(bytes + vol->usable_leb_size - 1,
165 vol->upd_ebs = !!do_div(tmp, vol->usable_leb_size); 163 vol->usable_leb_size);
166 vol->upd_ebs += tmp;
167 vol->upd_bytes = bytes; 164 vol->upd_bytes = bytes;
168 vol->upd_received = 0; 165 vol->upd_received = 0;
169 return 0; 166 return 0;
@@ -282,7 +279,6 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
282int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol, 279int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
283 const void __user *buf, int count) 280 const void __user *buf, int count)
284{ 281{
285 uint64_t tmp;
286 int lnum, offs, err = 0, len, to_write = count; 282 int lnum, offs, err = 0, len, to_write = count;
287 283
288 dbg_gen("write %d of %lld bytes, %lld already passed", 284 dbg_gen("write %d of %lld bytes, %lld already passed",
@@ -291,10 +287,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
291 if (ubi->ro_mode) 287 if (ubi->ro_mode)
292 return -EROFS; 288 return -EROFS;
293 289
294 tmp = vol->upd_received; 290 lnum = div_u64_rem(vol->upd_received, vol->usable_leb_size, &offs);
295 offs = do_div(tmp, vol->usable_leb_size);
296 lnum = tmp;
297
298 if (vol->upd_received + count > vol->upd_bytes) 291 if (vol->upd_received + count > vol->upd_bytes)
299 to_write = count = vol->upd_bytes - vol->upd_received; 292 to_write = count = vol->upd_bytes - vol->upd_received;
300 293
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 22e1d7398fc..df5483562b7 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include <linux/err.h> 26#include <linux/err.h>
27#include <asm/div64.h> 27#include <linux/math64.h>
28#include "ubi.h" 28#include "ubi.h"
29 29
30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
@@ -205,7 +205,6 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
205 int i, err, vol_id = req->vol_id, do_free = 1; 205 int i, err, vol_id = req->vol_id, do_free = 1;
206 struct ubi_volume *vol; 206 struct ubi_volume *vol;
207 struct ubi_vtbl_record vtbl_rec; 207 struct ubi_vtbl_record vtbl_rec;
208 uint64_t bytes;
209 dev_t dev; 208 dev_t dev;
210 209
211 if (ubi->ro_mode) 210 if (ubi->ro_mode)
@@ -255,10 +254,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
255 254
256 /* Calculate how many eraseblocks are requested */ 255 /* Calculate how many eraseblocks are requested */
257 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment; 256 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment;
258 bytes = req->bytes; 257 vol->reserved_pebs += div_u64(req->bytes + vol->usable_leb_size - 1,
259 if (do_div(bytes, vol->usable_leb_size)) 258 vol->usable_leb_size);
260 vol->reserved_pebs = 1;
261 vol->reserved_pebs += bytes;
262 259
263 /* Reserve physical eraseblocks */ 260 /* Reserve physical eraseblocks */
264 if (vol->reserved_pebs > ubi->avail_pebs) { 261 if (vol->reserved_pebs > ubi->avail_pebs) {
@@ -301,10 +298,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
301 vol->used_bytes = 298 vol->used_bytes =
302 (long long)vol->used_ebs * vol->usable_leb_size; 299 (long long)vol->used_ebs * vol->usable_leb_size;
303 } else { 300 } else {
304 bytes = vol->used_bytes; 301 vol->used_ebs = div_u64_rem(vol->used_bytes,
305 vol->last_eb_bytes = do_div(bytes, vol->usable_leb_size); 302 vol->usable_leb_size,
306 vol->used_ebs = bytes; 303 &vol->last_eb_bytes);
307 if (vol->last_eb_bytes) 304 if (vol->last_eb_bytes != 0)
308 vol->used_ebs += 1; 305 vol->used_ebs += 1;
309 else 306 else
310 vol->last_eb_bytes = vol->usable_leb_size; 307 vol->last_eb_bytes = vol->usable_leb_size;
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 7c789f0a94d..de91ddab0a8 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -382,6 +382,11 @@ static int __init hp_wmi_input_setup(void)
382 case KE_SW: 382 case KE_SW:
383 set_bit(EV_SW, hp_wmi_input_dev->evbit); 383 set_bit(EV_SW, hp_wmi_input_dev->evbit);
384 set_bit(key->keycode, hp_wmi_input_dev->swbit); 384 set_bit(key->keycode, hp_wmi_input_dev->swbit);
385
386 /* Set initial dock state */
387 input_report_switch(hp_wmi_input_dev, key->keycode,
388 hp_wmi_dock_state());
389 input_sync(hp_wmi_input_dev);
385 break; 390 break;
386 } 391 }
387 } 392 }
@@ -441,6 +446,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
441 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; 446 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set;
442 bluetooth_rfkill->user_claim_unsupported = 1; 447 bluetooth_rfkill->user_claim_unsupported = 1;
443 err = rfkill_register(bluetooth_rfkill); 448 err = rfkill_register(bluetooth_rfkill);
449 if (err)
444 goto register_bluetooth_error; 450 goto register_bluetooth_error;
445 } 451 }
446 452
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index c94f71980c1..f0267706cb4 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -41,7 +41,7 @@ menuconfig FB
41 You need an utility program called fbset to make full use of frame 41 You need an utility program called fbset to make full use of frame
42 buffer devices. Please read <file:Documentation/fb/framebuffer.txt> 42 buffer devices. Please read <file:Documentation/fb/framebuffer.txt>
43 and the Framebuffer-HOWTO at 43 and the Framebuffer-HOWTO at
44 <http://www.tahallah.demon.co.uk/programming/prog.html> for more 44 <http://www.munted.org.uk/programming/Framebuffer-HOWTO-1.2.html> for more
45 information. 45 information.
46 46
47 Say Y here and to the driver for your graphics board below if you 47 Say Y here and to the driver for your graphics board below if you