diff options
Diffstat (limited to 'drivers')
246 files changed, 6385 insertions, 3513 deletions
diff --git a/drivers/Makefile b/drivers/Makefile index 81e36596b1e9..34f1e1064dbc 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -99,6 +99,7 @@ obj-$(CONFIG_SGI_SN) += sn/ | |||
99 | obj-y += firmware/ | 99 | obj-y += firmware/ |
100 | obj-$(CONFIG_CRYPTO) += crypto/ | 100 | obj-$(CONFIG_CRYPTO) += crypto/ |
101 | obj-$(CONFIG_SUPERH) += sh/ | 101 | obj-$(CONFIG_SUPERH) += sh/ |
102 | obj-$(CONFIG_ARCH_SHMOBILE) += sh/ | ||
102 | obj-$(CONFIG_GENERIC_TIME) += clocksource/ | 103 | obj-$(CONFIG_GENERIC_TIME) += clocksource/ |
103 | obj-$(CONFIG_DMA_ENGINE) += dma/ | 104 | obj-$(CONFIG_DMA_ENGINE) += dma/ |
104 | obj-$(CONFIG_DCA) += dca/ | 105 | obj-$(CONFIG_DCA) += dca/ |
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index a206a12da78a..743f2445e2a1 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -101,6 +101,7 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr, | |||
101 | struct acpi_table_header *header = NULL; | 101 | struct acpi_table_header *header = NULL; |
102 | struct acpi_table_attr *attr = NULL; | 102 | struct acpi_table_attr *attr = NULL; |
103 | 103 | ||
104 | sysfs_attr_init(&table_attr->attr.attr); | ||
104 | if (table_header->signature[0] != '\0') | 105 | if (table_header->signature[0] != '\0') |
105 | memcpy(table_attr->name, table_header->signature, | 106 | memcpy(table_attr->name, table_header->signature, |
106 | ACPI_NAME_SIZE); | 107 | ACPI_NAME_SIZE); |
@@ -475,6 +476,7 @@ void acpi_irq_stats_init(void) | |||
475 | goto fail; | 476 | goto fail; |
476 | strncpy(name, buffer, strlen(buffer) + 1); | 477 | strncpy(name, buffer, strlen(buffer) + 1); |
477 | 478 | ||
479 | sysfs_attr_init(&counter_attrs[i].attr); | ||
478 | counter_attrs[i].attr.name = name; | 480 | counter_attrs[i].attr.name = name; |
479 | counter_attrs[i].attr.mode = 0644; | 481 | counter_attrs[i].attr.mode = 0644; |
480 | counter_attrs[i].show = counter_show; | 482 | counter_attrs[i].show = counter_show; |
diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c index fe3a865be4e5..b0ca5a47f47d 100644 --- a/drivers/auxdisplay/cfag12864bfb.c +++ b/drivers/auxdisplay/cfag12864bfb.c | |||
@@ -81,7 +81,7 @@ static struct fb_ops cfag12864bfb_ops = { | |||
81 | .fb_mmap = cfag12864bfb_mmap, | 81 | .fb_mmap = cfag12864bfb_mmap, |
82 | }; | 82 | }; |
83 | 83 | ||
84 | static int __init cfag12864bfb_probe(struct platform_device *device) | 84 | static int __devinit cfag12864bfb_probe(struct platform_device *device) |
85 | { | 85 | { |
86 | int ret = -EINVAL; | 86 | int ret = -EINVAL; |
87 | struct fb_info *info = framebuffer_alloc(0, &device->dev); | 87 | struct fb_info *info = framebuffer_alloc(0, &device->dev); |
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index ee377270beb9..fd52c48ee762 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig | |||
@@ -3,35 +3,50 @@ menu "Generic Driver Options" | |||
3 | config UEVENT_HELPER_PATH | 3 | config UEVENT_HELPER_PATH |
4 | string "path to uevent helper" | 4 | string "path to uevent helper" |
5 | depends on HOTPLUG | 5 | depends on HOTPLUG |
6 | default "/sbin/hotplug" | 6 | default "" |
7 | help | 7 | help |
8 | Path to uevent helper program forked by the kernel for | 8 | Path to uevent helper program forked by the kernel for |
9 | every uevent. | 9 | every uevent. |
10 | Before the switch to the netlink-based uevent source, this was | ||
11 | used to hook hotplug scripts into kernel device events. It | ||
12 | usually pointed to a shell script at /sbin/hotplug. | ||
13 | This should not be used today, because usual systems create | ||
14 | many events at bootup or device discovery in a very short time | ||
15 | frame. One forked process per event can create so many processes | ||
16 | that it creates a high system load, or on smaller systems | ||
17 | it is known to create out-of-memory situations during bootup. | ||
10 | 18 | ||
11 | config DEVTMPFS | 19 | config DEVTMPFS |
12 | bool "Create a kernel maintained /dev tmpfs (EXPERIMENTAL)" | 20 | bool "Maintain a devtmpfs filesystem to mount at /dev" |
13 | depends on HOTPLUG && SHMEM && TMPFS | 21 | depends on HOTPLUG && SHMEM && TMPFS |
14 | help | 22 | help |
15 | This creates a tmpfs filesystem, and mounts it at bootup | 23 | This creates a tmpfs filesystem instance early at bootup. |
16 | and mounts it at /dev. The kernel driver core creates device | 24 | In this filesystem, the kernel driver core maintains device |
17 | nodes for all registered devices in that filesystem. All device | 25 | nodes with their default names and permissions for all |
18 | nodes are owned by root and have the default mode of 0600. | 26 | registered devices with an assigned major/minor number. |
19 | Userspace can add and delete the nodes as needed. This is | 27 | Userspace can modify the filesystem content as needed, add |
20 | intended to simplify bootup, and make it possible to delay | 28 | symlinks, and apply needed permissions. |
21 | the initial coldplug at bootup done by udev in userspace. | 29 | It provides a fully functional /dev directory, where usually |
22 | It should also provide a simpler way for rescue systems | 30 | udev runs on top, managing permissions and adding meaningful |
23 | to bring up a kernel with dynamic major/minor numbers. | 31 | symlinks. |
24 | Meaningful symlinks, permissions and device ownership must | 32 | In very limited environments, it may provide a sufficient |
25 | still be handled by userspace. | 33 | functional /dev without any further help. It also allows simple |
26 | If unsure, say N here. | 34 | rescue systems, and reliably handles dynamic major/minor numbers. |
27 | 35 | ||
28 | config DEVTMPFS_MOUNT | 36 | config DEVTMPFS_MOUNT |
29 | bool "Automount devtmpfs at /dev" | 37 | bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs" |
30 | depends on DEVTMPFS | 38 | depends on DEVTMPFS |
31 | help | 39 | help |
32 | This will mount devtmpfs at /dev if the kernel mounts the root | 40 | This will instruct the kernel to automatically mount the |
33 | filesystem. It will not affect initramfs based mounting. | 41 | devtmpfs filesystem at /dev, directly after the kernel has |
34 | If unsure, say N here. | 42 | mounted the root filesystem. The behavior can be overridden |
43 | with the commandline parameter: devtmpfs.mount=0|1. | ||
44 | This option does not affect initramfs based booting, here | ||
45 | the devtmpfs filesystem always needs to be mounted manually | ||
46 | after the roots is mounted. | ||
47 | With this option enabled, it allows to bring up a system in | ||
48 | rescue mode with init=/bin/sh, even when the /dev directory | ||
49 | on the rootfs is completely empty. | ||
35 | 50 | ||
36 | config STANDALONE | 51 | config STANDALONE |
37 | bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL | 52 | bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL |
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index c0c5a43d9fb3..71f6af5c8b0b 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -70,7 +70,7 @@ static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr, | |||
70 | return ret; | 70 | return ret; |
71 | } | 71 | } |
72 | 72 | ||
73 | static struct sysfs_ops driver_sysfs_ops = { | 73 | static const struct sysfs_ops driver_sysfs_ops = { |
74 | .show = drv_attr_show, | 74 | .show = drv_attr_show, |
75 | .store = drv_attr_store, | 75 | .store = drv_attr_store, |
76 | }; | 76 | }; |
@@ -115,7 +115,7 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr, | |||
115 | return ret; | 115 | return ret; |
116 | } | 116 | } |
117 | 117 | ||
118 | static struct sysfs_ops bus_sysfs_ops = { | 118 | static const struct sysfs_ops bus_sysfs_ops = { |
119 | .show = bus_attr_show, | 119 | .show = bus_attr_show, |
120 | .store = bus_attr_store, | 120 | .store = bus_attr_store, |
121 | }; | 121 | }; |
@@ -154,7 +154,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj) | |||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | static struct kset_uevent_ops bus_uevent_ops = { | 157 | static const struct kset_uevent_ops bus_uevent_ops = { |
158 | .filter = bus_uevent_filter, | 158 | .filter = bus_uevent_filter, |
159 | }; | 159 | }; |
160 | 160 | ||
@@ -173,10 +173,10 @@ static ssize_t driver_unbind(struct device_driver *drv, | |||
173 | dev = bus_find_device_by_name(bus, NULL, buf); | 173 | dev = bus_find_device_by_name(bus, NULL, buf); |
174 | if (dev && dev->driver == drv) { | 174 | if (dev && dev->driver == drv) { |
175 | if (dev->parent) /* Needed for USB */ | 175 | if (dev->parent) /* Needed for USB */ |
176 | down(&dev->parent->sem); | 176 | device_lock(dev->parent); |
177 | device_release_driver(dev); | 177 | device_release_driver(dev); |
178 | if (dev->parent) | 178 | if (dev->parent) |
179 | up(&dev->parent->sem); | 179 | device_unlock(dev->parent); |
180 | err = count; | 180 | err = count; |
181 | } | 181 | } |
182 | put_device(dev); | 182 | put_device(dev); |
@@ -200,12 +200,12 @@ static ssize_t driver_bind(struct device_driver *drv, | |||
200 | dev = bus_find_device_by_name(bus, NULL, buf); | 200 | dev = bus_find_device_by_name(bus, NULL, buf); |
201 | if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { | 201 | if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { |
202 | if (dev->parent) /* Needed for USB */ | 202 | if (dev->parent) /* Needed for USB */ |
203 | down(&dev->parent->sem); | 203 | device_lock(dev->parent); |
204 | down(&dev->sem); | 204 | device_lock(dev); |
205 | err = driver_probe_device(drv, dev); | 205 | err = driver_probe_device(drv, dev); |
206 | up(&dev->sem); | 206 | device_unlock(dev); |
207 | if (dev->parent) | 207 | if (dev->parent) |
208 | up(&dev->parent->sem); | 208 | device_unlock(dev->parent); |
209 | 209 | ||
210 | if (err > 0) { | 210 | if (err > 0) { |
211 | /* success */ | 211 | /* success */ |
@@ -744,10 +744,10 @@ static int __must_check bus_rescan_devices_helper(struct device *dev, | |||
744 | 744 | ||
745 | if (!dev->driver) { | 745 | if (!dev->driver) { |
746 | if (dev->parent) /* Needed for USB */ | 746 | if (dev->parent) /* Needed for USB */ |
747 | down(&dev->parent->sem); | 747 | device_lock(dev->parent); |
748 | ret = device_attach(dev); | 748 | ret = device_attach(dev); |
749 | if (dev->parent) | 749 | if (dev->parent) |
750 | up(&dev->parent->sem); | 750 | device_unlock(dev->parent); |
751 | } | 751 | } |
752 | return ret < 0 ? ret : 0; | 752 | return ret < 0 ? ret : 0; |
753 | } | 753 | } |
@@ -779,10 +779,10 @@ int device_reprobe(struct device *dev) | |||
779 | { | 779 | { |
780 | if (dev->driver) { | 780 | if (dev->driver) { |
781 | if (dev->parent) /* Needed for USB */ | 781 | if (dev->parent) /* Needed for USB */ |
782 | down(&dev->parent->sem); | 782 | device_lock(dev->parent); |
783 | device_release_driver(dev); | 783 | device_release_driver(dev); |
784 | if (dev->parent) | 784 | if (dev->parent) |
785 | up(&dev->parent->sem); | 785 | device_unlock(dev->parent); |
786 | } | 786 | } |
787 | return bus_rescan_devices_helper(dev, NULL); | 787 | return bus_rescan_devices_helper(dev, NULL); |
788 | } | 788 | } |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 6e2c3b064f53..0147f476b8a9 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -31,7 +31,7 @@ static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr, | |||
31 | ssize_t ret = -EIO; | 31 | ssize_t ret = -EIO; |
32 | 32 | ||
33 | if (class_attr->show) | 33 | if (class_attr->show) |
34 | ret = class_attr->show(cp->class, buf); | 34 | ret = class_attr->show(cp->class, class_attr, buf); |
35 | return ret; | 35 | return ret; |
36 | } | 36 | } |
37 | 37 | ||
@@ -43,7 +43,7 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr, | |||
43 | ssize_t ret = -EIO; | 43 | ssize_t ret = -EIO; |
44 | 44 | ||
45 | if (class_attr->store) | 45 | if (class_attr->store) |
46 | ret = class_attr->store(cp->class, buf, count); | 46 | ret = class_attr->store(cp->class, class_attr, buf, count); |
47 | return ret; | 47 | return ret; |
48 | } | 48 | } |
49 | 49 | ||
@@ -63,7 +63,7 @@ static void class_release(struct kobject *kobj) | |||
63 | kfree(cp); | 63 | kfree(cp); |
64 | } | 64 | } |
65 | 65 | ||
66 | static struct sysfs_ops class_sysfs_ops = { | 66 | static const struct sysfs_ops class_sysfs_ops = { |
67 | .show = class_attr_show, | 67 | .show = class_attr_show, |
68 | .store = class_attr_store, | 68 | .store = class_attr_store, |
69 | }; | 69 | }; |
@@ -490,6 +490,16 @@ void class_interface_unregister(struct class_interface *class_intf) | |||
490 | class_put(parent); | 490 | class_put(parent); |
491 | } | 491 | } |
492 | 492 | ||
493 | ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr, | ||
494 | char *buf) | ||
495 | { | ||
496 | struct class_attribute_string *cs; | ||
497 | cs = container_of(attr, struct class_attribute_string, attr); | ||
498 | return snprintf(buf, PAGE_SIZE, "%s\n", cs->str); | ||
499 | } | ||
500 | |||
501 | EXPORT_SYMBOL_GPL(show_class_attr_string); | ||
502 | |||
493 | struct class_compat { | 503 | struct class_compat { |
494 | struct kobject *kobj; | 504 | struct kobject *kobj; |
495 | }; | 505 | }; |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 282025770429..ef55df34ddd0 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -100,7 +100,7 @@ static ssize_t dev_attr_store(struct kobject *kobj, struct attribute *attr, | |||
100 | return ret; | 100 | return ret; |
101 | } | 101 | } |
102 | 102 | ||
103 | static struct sysfs_ops dev_sysfs_ops = { | 103 | static const struct sysfs_ops dev_sysfs_ops = { |
104 | .show = dev_attr_show, | 104 | .show = dev_attr_show, |
105 | .store = dev_attr_store, | 105 | .store = dev_attr_store, |
106 | }; | 106 | }; |
@@ -252,7 +252,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, | |||
252 | return retval; | 252 | return retval; |
253 | } | 253 | } |
254 | 254 | ||
255 | static struct kset_uevent_ops device_uevent_ops = { | 255 | static const struct kset_uevent_ops device_uevent_ops = { |
256 | .filter = dev_uevent_filter, | 256 | .filter = dev_uevent_filter, |
257 | .name = dev_uevent_name, | 257 | .name = dev_uevent_name, |
258 | .uevent = dev_uevent, | 258 | .uevent = dev_uevent, |
@@ -306,15 +306,10 @@ static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, | |||
306 | { | 306 | { |
307 | enum kobject_action action; | 307 | enum kobject_action action; |
308 | 308 | ||
309 | if (kobject_action_type(buf, count, &action) == 0) { | 309 | if (kobject_action_type(buf, count, &action) == 0) |
310 | kobject_uevent(&dev->kobj, action); | 310 | kobject_uevent(&dev->kobj, action); |
311 | goto out; | 311 | else |
312 | } | 312 | dev_err(dev, "uevent: unknown action-string\n"); |
313 | |||
314 | dev_err(dev, "uevent: unsupported action-string; this will " | ||
315 | "be ignored in a future kernel version\n"); | ||
316 | kobject_uevent(&dev->kobj, KOBJ_ADD); | ||
317 | out: | ||
318 | return count; | 313 | return count; |
319 | } | 314 | } |
320 | 315 | ||
@@ -607,6 +602,7 @@ static struct kobject *get_device_parent(struct device *dev, | |||
607 | int retval; | 602 | int retval; |
608 | 603 | ||
609 | if (dev->class) { | 604 | if (dev->class) { |
605 | static DEFINE_MUTEX(gdp_mutex); | ||
610 | struct kobject *kobj = NULL; | 606 | struct kobject *kobj = NULL; |
611 | struct kobject *parent_kobj; | 607 | struct kobject *parent_kobj; |
612 | struct kobject *k; | 608 | struct kobject *k; |
@@ -623,6 +619,8 @@ static struct kobject *get_device_parent(struct device *dev, | |||
623 | else | 619 | else |
624 | parent_kobj = &parent->kobj; | 620 | parent_kobj = &parent->kobj; |
625 | 621 | ||
622 | mutex_lock(&gdp_mutex); | ||
623 | |||
626 | /* find our class-directory at the parent and reference it */ | 624 | /* find our class-directory at the parent and reference it */ |
627 | spin_lock(&dev->class->p->class_dirs.list_lock); | 625 | spin_lock(&dev->class->p->class_dirs.list_lock); |
628 | list_for_each_entry(k, &dev->class->p->class_dirs.list, entry) | 626 | list_for_each_entry(k, &dev->class->p->class_dirs.list, entry) |
@@ -631,20 +629,26 @@ static struct kobject *get_device_parent(struct device *dev, | |||
631 | break; | 629 | break; |
632 | } | 630 | } |
633 | spin_unlock(&dev->class->p->class_dirs.list_lock); | 631 | spin_unlock(&dev->class->p->class_dirs.list_lock); |
634 | if (kobj) | 632 | if (kobj) { |
633 | mutex_unlock(&gdp_mutex); | ||
635 | return kobj; | 634 | return kobj; |
635 | } | ||
636 | 636 | ||
637 | /* or create a new class-directory at the parent device */ | 637 | /* or create a new class-directory at the parent device */ |
638 | k = kobject_create(); | 638 | k = kobject_create(); |
639 | if (!k) | 639 | if (!k) { |
640 | mutex_unlock(&gdp_mutex); | ||
640 | return NULL; | 641 | return NULL; |
642 | } | ||
641 | k->kset = &dev->class->p->class_dirs; | 643 | k->kset = &dev->class->p->class_dirs; |
642 | retval = kobject_add(k, parent_kobj, "%s", dev->class->name); | 644 | retval = kobject_add(k, parent_kobj, "%s", dev->class->name); |
643 | if (retval < 0) { | 645 | if (retval < 0) { |
646 | mutex_unlock(&gdp_mutex); | ||
644 | kobject_put(k); | 647 | kobject_put(k); |
645 | return NULL; | 648 | return NULL; |
646 | } | 649 | } |
647 | /* do not emit an uevent for this simple "glue" directory */ | 650 | /* do not emit an uevent for this simple "glue" directory */ |
651 | mutex_unlock(&gdp_mutex); | ||
648 | return k; | 652 | return k; |
649 | } | 653 | } |
650 | 654 | ||
@@ -1574,22 +1578,16 @@ int device_rename(struct device *dev, char *new_name) | |||
1574 | if (old_class_name) { | 1578 | if (old_class_name) { |
1575 | new_class_name = make_class_name(dev->class->name, &dev->kobj); | 1579 | new_class_name = make_class_name(dev->class->name, &dev->kobj); |
1576 | if (new_class_name) { | 1580 | if (new_class_name) { |
1577 | error = sysfs_create_link_nowarn(&dev->parent->kobj, | 1581 | error = sysfs_rename_link(&dev->parent->kobj, |
1578 | &dev->kobj, | 1582 | &dev->kobj, |
1579 | new_class_name); | 1583 | old_class_name, |
1580 | if (error) | 1584 | new_class_name); |
1581 | goto out; | ||
1582 | sysfs_remove_link(&dev->parent->kobj, old_class_name); | ||
1583 | } | 1585 | } |
1584 | } | 1586 | } |
1585 | #else | 1587 | #else |
1586 | if (dev->class) { | 1588 | if (dev->class) { |
1587 | error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj, | 1589 | error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, |
1588 | &dev->kobj, dev_name(dev)); | 1590 | &dev->kobj, old_device_name, new_name); |
1589 | if (error) | ||
1590 | goto out; | ||
1591 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, | ||
1592 | old_device_name); | ||
1593 | } | 1591 | } |
1594 | #endif | 1592 | #endif |
1595 | 1593 | ||
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 958bd1540c30..7036e8e96ab8 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -13,8 +13,11 @@ | |||
13 | 13 | ||
14 | #include "base.h" | 14 | #include "base.h" |
15 | 15 | ||
16 | static struct sysdev_class_attribute *cpu_sysdev_class_attrs[]; | ||
17 | |||
16 | struct sysdev_class cpu_sysdev_class = { | 18 | struct sysdev_class cpu_sysdev_class = { |
17 | .name = "cpu", | 19 | .name = "cpu", |
20 | .attrs = cpu_sysdev_class_attrs, | ||
18 | }; | 21 | }; |
19 | EXPORT_SYMBOL(cpu_sysdev_class); | 22 | EXPORT_SYMBOL(cpu_sysdev_class); |
20 | 23 | ||
@@ -76,34 +79,24 @@ void unregister_cpu(struct cpu *cpu) | |||
76 | } | 79 | } |
77 | 80 | ||
78 | #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE | 81 | #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE |
79 | static ssize_t cpu_probe_store(struct class *class, const char *buf, | 82 | static ssize_t cpu_probe_store(struct sys_device *dev, |
83 | struct sysdev_attribute *attr, | ||
84 | const char *buf, | ||
80 | size_t count) | 85 | size_t count) |
81 | { | 86 | { |
82 | return arch_cpu_probe(buf, count); | 87 | return arch_cpu_probe(buf, count); |
83 | } | 88 | } |
84 | 89 | ||
85 | static ssize_t cpu_release_store(struct class *class, const char *buf, | 90 | static ssize_t cpu_release_store(struct sys_device *dev, |
91 | struct sysdev_attribute *attr, | ||
92 | const char *buf, | ||
86 | size_t count) | 93 | size_t count) |
87 | { | 94 | { |
88 | return arch_cpu_release(buf, count); | 95 | return arch_cpu_release(buf, count); |
89 | } | 96 | } |
90 | 97 | ||
91 | static CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); | 98 | static SYSDEV_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); |
92 | static CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store); | 99 | static SYSDEV_ATTR(release, S_IWUSR, NULL, cpu_release_store); |
93 | |||
94 | int __init cpu_probe_release_init(void) | ||
95 | { | ||
96 | int rc; | ||
97 | |||
98 | rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj, | ||
99 | &class_attr_probe.attr); | ||
100 | if (!rc) | ||
101 | rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj, | ||
102 | &class_attr_release.attr); | ||
103 | |||
104 | return rc; | ||
105 | } | ||
106 | device_initcall(cpu_probe_release_init); | ||
107 | #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ | 100 | #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ |
108 | 101 | ||
109 | #else /* ... !CONFIG_HOTPLUG_CPU */ | 102 | #else /* ... !CONFIG_HOTPLUG_CPU */ |
@@ -141,31 +134,39 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); | |||
141 | /* | 134 | /* |
142 | * Print cpu online, possible, present, and system maps | 135 | * Print cpu online, possible, present, and system maps |
143 | */ | 136 | */ |
144 | static ssize_t print_cpus_map(char *buf, const struct cpumask *map) | 137 | |
138 | struct cpu_attr { | ||
139 | struct sysdev_class_attribute attr; | ||
140 | const struct cpumask *const * const map; | ||
141 | }; | ||
142 | |||
143 | static ssize_t show_cpus_attr(struct sysdev_class *class, | ||
144 | struct sysdev_class_attribute *attr, | ||
145 | char *buf) | ||
145 | { | 146 | { |
146 | int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map); | 147 | struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr); |
148 | int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *(ca->map)); | ||
147 | 149 | ||
148 | buf[n++] = '\n'; | 150 | buf[n++] = '\n'; |
149 | buf[n] = '\0'; | 151 | buf[n] = '\0'; |
150 | return n; | 152 | return n; |
151 | } | 153 | } |
152 | 154 | ||
153 | #define print_cpus_func(type) \ | 155 | #define _CPU_ATTR(name, map) \ |
154 | static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \ | 156 | { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map } |
155 | { \ | ||
156 | return print_cpus_map(buf, cpu_##type##_mask); \ | ||
157 | } \ | ||
158 | static struct sysdev_class_attribute attr_##type##_map = \ | ||
159 | _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL) | ||
160 | 157 | ||
161 | print_cpus_func(online); | 158 | /* Keep in sync with cpu_sysdev_class_attrs */ |
162 | print_cpus_func(possible); | 159 | static struct cpu_attr cpu_attrs[] = { |
163 | print_cpus_func(present); | 160 | _CPU_ATTR(online, &cpu_online_mask), |
161 | _CPU_ATTR(possible, &cpu_possible_mask), | ||
162 | _CPU_ATTR(present, &cpu_present_mask), | ||
163 | }; | ||
164 | 164 | ||
165 | /* | 165 | /* |
166 | * Print values for NR_CPUS and offlined cpus | 166 | * Print values for NR_CPUS and offlined cpus |
167 | */ | 167 | */ |
168 | static ssize_t print_cpus_kernel_max(struct sysdev_class *class, char *buf) | 168 | static ssize_t print_cpus_kernel_max(struct sysdev_class *class, |
169 | struct sysdev_class_attribute *attr, char *buf) | ||
169 | { | 170 | { |
170 | int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); | 171 | int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); |
171 | return n; | 172 | return n; |
@@ -175,7 +176,8 @@ static SYSDEV_CLASS_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL); | |||
175 | /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ | 176 | /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ |
176 | unsigned int total_cpus; | 177 | unsigned int total_cpus; |
177 | 178 | ||
178 | static ssize_t print_cpus_offline(struct sysdev_class *class, char *buf) | 179 | static ssize_t print_cpus_offline(struct sysdev_class *class, |
180 | struct sysdev_class_attribute *attr, char *buf) | ||
179 | { | 181 | { |
180 | int n = 0, len = PAGE_SIZE-2; | 182 | int n = 0, len = PAGE_SIZE-2; |
181 | cpumask_var_t offline; | 183 | cpumask_var_t offline; |
@@ -204,29 +206,6 @@ static ssize_t print_cpus_offline(struct sysdev_class *class, char *buf) | |||
204 | } | 206 | } |
205 | static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); | 207 | static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); |
206 | 208 | ||
207 | static struct sysdev_class_attribute *cpu_state_attr[] = { | ||
208 | &attr_online_map, | ||
209 | &attr_possible_map, | ||
210 | &attr_present_map, | ||
211 | &attr_kernel_max, | ||
212 | &attr_offline, | ||
213 | }; | ||
214 | |||
215 | static int cpu_states_init(void) | ||
216 | { | ||
217 | int i; | ||
218 | int err = 0; | ||
219 | |||
220 | for (i = 0; i < ARRAY_SIZE(cpu_state_attr); i++) { | ||
221 | int ret; | ||
222 | ret = sysdev_class_create_file(&cpu_sysdev_class, | ||
223 | cpu_state_attr[i]); | ||
224 | if (!err) | ||
225 | err = ret; | ||
226 | } | ||
227 | return err; | ||
228 | } | ||
229 | |||
230 | /* | 209 | /* |
231 | * register_cpu - Setup a sysfs device for a CPU. | 210 | * register_cpu - Setup a sysfs device for a CPU. |
232 | * @cpu - cpu->hotpluggable field set to 1 will generate a control file in | 211 | * @cpu - cpu->hotpluggable field set to 1 will generate a control file in |
@@ -272,9 +251,6 @@ int __init cpu_dev_init(void) | |||
272 | int err; | 251 | int err; |
273 | 252 | ||
274 | err = sysdev_class_register(&cpu_sysdev_class); | 253 | err = sysdev_class_register(&cpu_sysdev_class); |
275 | if (!err) | ||
276 | err = cpu_states_init(); | ||
277 | |||
278 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) | 254 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) |
279 | if (!err) | 255 | if (!err) |
280 | err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); | 256 | err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); |
@@ -282,3 +258,16 @@ int __init cpu_dev_init(void) | |||
282 | 258 | ||
283 | return err; | 259 | return err; |
284 | } | 260 | } |
261 | |||
262 | static struct sysdev_class_attribute *cpu_sysdev_class_attrs[] = { | ||
263 | #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE | ||
264 | &attr_probe, | ||
265 | &attr_release, | ||
266 | #endif | ||
267 | &cpu_attrs[0].attr, | ||
268 | &cpu_attrs[1].attr, | ||
269 | &cpu_attrs[2].attr, | ||
270 | &attr_kernel_max, | ||
271 | &attr_offline, | ||
272 | NULL | ||
273 | }; | ||
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index ee95c76bfd3d..c89291f8a16b 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -85,7 +85,7 @@ static void driver_sysfs_remove(struct device *dev) | |||
85 | * for before calling this. (It is ok to call with no other effort | 85 | * for before calling this. (It is ok to call with no other effort |
86 | * from a driver's probe() method.) | 86 | * from a driver's probe() method.) |
87 | * | 87 | * |
88 | * This function must be called with @dev->sem held. | 88 | * This function must be called with the device lock held. |
89 | */ | 89 | */ |
90 | int device_bind_driver(struct device *dev) | 90 | int device_bind_driver(struct device *dev) |
91 | { | 91 | { |
@@ -190,8 +190,8 @@ EXPORT_SYMBOL_GPL(wait_for_device_probe); | |||
190 | * This function returns -ENODEV if the device is not registered, | 190 | * This function returns -ENODEV if the device is not registered, |
191 | * 1 if the device is bound successfully and 0 otherwise. | 191 | * 1 if the device is bound successfully and 0 otherwise. |
192 | * | 192 | * |
193 | * This function must be called with @dev->sem held. When called for a | 193 | * This function must be called with @dev lock held. When called for a |
194 | * USB interface, @dev->parent->sem must be held as well. | 194 | * USB interface, @dev->parent lock must be held as well. |
195 | */ | 195 | */ |
196 | int driver_probe_device(struct device_driver *drv, struct device *dev) | 196 | int driver_probe_device(struct device_driver *drv, struct device *dev) |
197 | { | 197 | { |
@@ -233,13 +233,13 @@ static int __device_attach(struct device_driver *drv, void *data) | |||
233 | * 0 if no matching driver was found; | 233 | * 0 if no matching driver was found; |
234 | * -ENODEV if the device is not registered. | 234 | * -ENODEV if the device is not registered. |
235 | * | 235 | * |
236 | * When called for a USB interface, @dev->parent->sem must be held. | 236 | * When called for a USB interface, @dev->parent lock must be held. |
237 | */ | 237 | */ |
238 | int device_attach(struct device *dev) | 238 | int device_attach(struct device *dev) |
239 | { | 239 | { |
240 | int ret = 0; | 240 | int ret = 0; |
241 | 241 | ||
242 | down(&dev->sem); | 242 | device_lock(dev); |
243 | if (dev->driver) { | 243 | if (dev->driver) { |
244 | ret = device_bind_driver(dev); | 244 | ret = device_bind_driver(dev); |
245 | if (ret == 0) | 245 | if (ret == 0) |
@@ -253,7 +253,7 @@ int device_attach(struct device *dev) | |||
253 | ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); | 253 | ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); |
254 | pm_runtime_put_sync(dev); | 254 | pm_runtime_put_sync(dev); |
255 | } | 255 | } |
256 | up(&dev->sem); | 256 | device_unlock(dev); |
257 | return ret; | 257 | return ret; |
258 | } | 258 | } |
259 | EXPORT_SYMBOL_GPL(device_attach); | 259 | EXPORT_SYMBOL_GPL(device_attach); |
@@ -276,13 +276,13 @@ static int __driver_attach(struct device *dev, void *data) | |||
276 | return 0; | 276 | return 0; |
277 | 277 | ||
278 | if (dev->parent) /* Needed for USB */ | 278 | if (dev->parent) /* Needed for USB */ |
279 | down(&dev->parent->sem); | 279 | device_lock(dev->parent); |
280 | down(&dev->sem); | 280 | device_lock(dev); |
281 | if (!dev->driver) | 281 | if (!dev->driver) |
282 | driver_probe_device(drv, dev); | 282 | driver_probe_device(drv, dev); |
283 | up(&dev->sem); | 283 | device_unlock(dev); |
284 | if (dev->parent) | 284 | if (dev->parent) |
285 | up(&dev->parent->sem); | 285 | device_unlock(dev->parent); |
286 | 286 | ||
287 | return 0; | 287 | return 0; |
288 | } | 288 | } |
@@ -303,8 +303,8 @@ int driver_attach(struct device_driver *drv) | |||
303 | EXPORT_SYMBOL_GPL(driver_attach); | 303 | EXPORT_SYMBOL_GPL(driver_attach); |
304 | 304 | ||
305 | /* | 305 | /* |
306 | * __device_release_driver() must be called with @dev->sem held. | 306 | * __device_release_driver() must be called with @dev lock held. |
307 | * When called for a USB interface, @dev->parent->sem must be held as well. | 307 | * When called for a USB interface, @dev->parent lock must be held as well. |
308 | */ | 308 | */ |
309 | static void __device_release_driver(struct device *dev) | 309 | static void __device_release_driver(struct device *dev) |
310 | { | 310 | { |
@@ -343,7 +343,7 @@ static void __device_release_driver(struct device *dev) | |||
343 | * @dev: device. | 343 | * @dev: device. |
344 | * | 344 | * |
345 | * Manually detach device from driver. | 345 | * Manually detach device from driver. |
346 | * When called for a USB interface, @dev->parent->sem must be held. | 346 | * When called for a USB interface, @dev->parent lock must be held. |
347 | */ | 347 | */ |
348 | void device_release_driver(struct device *dev) | 348 | void device_release_driver(struct device *dev) |
349 | { | 349 | { |
@@ -352,9 +352,9 @@ void device_release_driver(struct device *dev) | |||
352 | * within their ->remove callback for the same device, they | 352 | * within their ->remove callback for the same device, they |
353 | * will deadlock right here. | 353 | * will deadlock right here. |
354 | */ | 354 | */ |
355 | down(&dev->sem); | 355 | device_lock(dev); |
356 | __device_release_driver(dev); | 356 | __device_release_driver(dev); |
357 | up(&dev->sem); | 357 | device_unlock(dev); |
358 | } | 358 | } |
359 | EXPORT_SYMBOL_GPL(device_release_driver); | 359 | EXPORT_SYMBOL_GPL(device_release_driver); |
360 | 360 | ||
@@ -381,13 +381,13 @@ void driver_detach(struct device_driver *drv) | |||
381 | spin_unlock(&drv->p->klist_devices.k_lock); | 381 | spin_unlock(&drv->p->klist_devices.k_lock); |
382 | 382 | ||
383 | if (dev->parent) /* Needed for USB */ | 383 | if (dev->parent) /* Needed for USB */ |
384 | down(&dev->parent->sem); | 384 | device_lock(dev->parent); |
385 | down(&dev->sem); | 385 | device_lock(dev); |
386 | if (dev->driver == drv) | 386 | if (dev->driver == drv) |
387 | __device_release_driver(dev); | 387 | __device_release_driver(dev); |
388 | up(&dev->sem); | 388 | device_unlock(dev); |
389 | if (dev->parent) | 389 | if (dev->parent) |
390 | up(&dev->parent->sem); | 390 | device_unlock(dev->parent); |
391 | put_device(dev); | 391 | put_device(dev); |
392 | } | 392 | } |
393 | } | 393 | } |
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 42ae452b36b0..dac478c6e460 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c | |||
@@ -301,6 +301,19 @@ int devtmpfs_delete_node(struct device *dev) | |||
301 | if (dentry->d_inode) { | 301 | if (dentry->d_inode) { |
302 | err = vfs_getattr(nd.path.mnt, dentry, &stat); | 302 | err = vfs_getattr(nd.path.mnt, dentry, &stat); |
303 | if (!err && dev_mynode(dev, dentry->d_inode, &stat)) { | 303 | if (!err && dev_mynode(dev, dentry->d_inode, &stat)) { |
304 | struct iattr newattrs; | ||
305 | /* | ||
306 | * before unlinking this node, reset permissions | ||
307 | * of possible references like hardlinks | ||
308 | */ | ||
309 | newattrs.ia_uid = 0; | ||
310 | newattrs.ia_gid = 0; | ||
311 | newattrs.ia_mode = stat.mode & ~0777; | ||
312 | newattrs.ia_valid = | ||
313 | ATTR_UID|ATTR_GID|ATTR_MODE; | ||
314 | mutex_lock(&dentry->d_inode->i_mutex); | ||
315 | notify_change(dentry, &newattrs); | ||
316 | mutex_unlock(&dentry->d_inode->i_mutex); | ||
304 | err = vfs_unlink(nd.path.dentry->d_inode, | 317 | err = vfs_unlink(nd.path.dentry->d_inode, |
305 | dentry); | 318 | dentry); |
306 | if (!err || err == -ENOENT) | 319 | if (!err || err == -ENOENT) |
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index a95024166b66..d0dc26ad5387 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/kthread.h> | 19 | #include <linux/kthread.h> |
20 | #include <linux/highmem.h> | 20 | #include <linux/highmem.h> |
21 | #include <linux/firmware.h> | 21 | #include <linux/firmware.h> |
22 | #include "base.h" | ||
23 | 22 | ||
24 | #define to_dev(obj) container_of(obj, struct device, kobj) | 23 | #define to_dev(obj) container_of(obj, struct device, kobj) |
25 | 24 | ||
@@ -69,7 +68,9 @@ fw_load_abort(struct firmware_priv *fw_priv) | |||
69 | } | 68 | } |
70 | 69 | ||
71 | static ssize_t | 70 | static ssize_t |
72 | firmware_timeout_show(struct class *class, char *buf) | 71 | firmware_timeout_show(struct class *class, |
72 | struct class_attribute *attr, | ||
73 | char *buf) | ||
73 | { | 74 | { |
74 | return sprintf(buf, "%d\n", loading_timeout); | 75 | return sprintf(buf, "%d\n", loading_timeout); |
75 | } | 76 | } |
@@ -87,7 +88,9 @@ firmware_timeout_show(struct class *class, char *buf) | |||
87 | * Note: zero means 'wait forever'. | 88 | * Note: zero means 'wait forever'. |
88 | **/ | 89 | **/ |
89 | static ssize_t | 90 | static ssize_t |
90 | firmware_timeout_store(struct class *class, const char *buf, size_t count) | 91 | firmware_timeout_store(struct class *class, |
92 | struct class_attribute *attr, | ||
93 | const char *buf, size_t count) | ||
91 | { | 94 | { |
92 | loading_timeout = simple_strtol(buf, NULL, 10); | 95 | loading_timeout = simple_strtol(buf, NULL, 10); |
93 | if (loading_timeout < 0) | 96 | if (loading_timeout < 0) |
@@ -610,7 +613,7 @@ request_firmware_work_func(void *arg) | |||
610 | } | 613 | } |
611 | 614 | ||
612 | /** | 615 | /** |
613 | * request_firmware_nowait: asynchronous version of request_firmware | 616 | * request_firmware_nowait - asynchronous version of request_firmware |
614 | * @module: module requesting the firmware | 617 | * @module: module requesting the firmware |
615 | * @uevent: sends uevent to copy the firmware image if this flag | 618 | * @uevent: sends uevent to copy the firmware image if this flag |
616 | * is non-zero else the firmware copy must be done manually. | 619 | * is non-zero else the firmware copy must be done manually. |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index bd025059711f..2f8691511190 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -44,7 +44,7 @@ static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uev | |||
44 | return retval; | 44 | return retval; |
45 | } | 45 | } |
46 | 46 | ||
47 | static struct kset_uevent_ops memory_uevent_ops = { | 47 | static const struct kset_uevent_ops memory_uevent_ops = { |
48 | .name = memory_uevent_name, | 48 | .name = memory_uevent_name, |
49 | .uevent = memory_uevent, | 49 | .uevent = memory_uevent, |
50 | }; | 50 | }; |
@@ -309,17 +309,18 @@ static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL); | |||
309 | * Block size attribute stuff | 309 | * Block size attribute stuff |
310 | */ | 310 | */ |
311 | static ssize_t | 311 | static ssize_t |
312 | print_block_size(struct class *class, char *buf) | 312 | print_block_size(struct sysdev_class *class, struct sysdev_class_attribute *attr, |
313 | char *buf) | ||
313 | { | 314 | { |
314 | return sprintf(buf, "%#lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE); | 315 | return sprintf(buf, "%#lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE); |
315 | } | 316 | } |
316 | 317 | ||
317 | static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); | 318 | static SYSDEV_CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); |
318 | 319 | ||
319 | static int block_size_init(void) | 320 | static int block_size_init(void) |
320 | { | 321 | { |
321 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, | 322 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, |
322 | &class_attr_block_size_bytes.attr); | 323 | &attr_block_size_bytes.attr); |
323 | } | 324 | } |
324 | 325 | ||
325 | /* | 326 | /* |
@@ -330,7 +331,8 @@ static int block_size_init(void) | |||
330 | */ | 331 | */ |
331 | #ifdef CONFIG_ARCH_MEMORY_PROBE | 332 | #ifdef CONFIG_ARCH_MEMORY_PROBE |
332 | static ssize_t | 333 | static ssize_t |
333 | memory_probe_store(struct class *class, const char *buf, size_t count) | 334 | memory_probe_store(struct class *class, struct class_attribute *attr, |
335 | const char *buf, size_t count) | ||
334 | { | 336 | { |
335 | u64 phys_addr; | 337 | u64 phys_addr; |
336 | int nid; | 338 | int nid; |
@@ -367,7 +369,9 @@ static inline int memory_probe_init(void) | |||
367 | 369 | ||
368 | /* Soft offline a page */ | 370 | /* Soft offline a page */ |
369 | static ssize_t | 371 | static ssize_t |
370 | store_soft_offline_page(struct class *class, const char *buf, size_t count) | 372 | store_soft_offline_page(struct class *class, |
373 | struct class_attribute *attr, | ||
374 | const char *buf, size_t count) | ||
371 | { | 375 | { |
372 | int ret; | 376 | int ret; |
373 | u64 pfn; | 377 | u64 pfn; |
@@ -384,7 +388,9 @@ store_soft_offline_page(struct class *class, const char *buf, size_t count) | |||
384 | 388 | ||
385 | /* Forcibly offline a page, including killing processes. */ | 389 | /* Forcibly offline a page, including killing processes. */ |
386 | static ssize_t | 390 | static ssize_t |
387 | store_hard_offline_page(struct class *class, const char *buf, size_t count) | 391 | store_hard_offline_page(struct class *class, |
392 | struct class_attribute *attr, | ||
393 | const char *buf, size_t count) | ||
388 | { | 394 | { |
389 | int ret; | 395 | int ret; |
390 | u64 pfn; | 396 | u64 pfn; |
diff --git a/drivers/base/node.c b/drivers/base/node.c index 70122791683d..ad43185ec15a 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -16,8 +16,11 @@ | |||
16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
17 | #include <linux/swap.h> | 17 | #include <linux/swap.h> |
18 | 18 | ||
19 | static struct sysdev_class_attribute *node_state_attrs[]; | ||
20 | |||
19 | static struct sysdev_class node_class = { | 21 | static struct sysdev_class node_class = { |
20 | .name = "node", | 22 | .name = "node", |
23 | .attrs = node_state_attrs, | ||
21 | }; | 24 | }; |
22 | 25 | ||
23 | 26 | ||
@@ -544,76 +547,52 @@ static ssize_t print_nodes_state(enum node_states state, char *buf) | |||
544 | return n; | 547 | return n; |
545 | } | 548 | } |
546 | 549 | ||
547 | static ssize_t print_nodes_possible(struct sysdev_class *class, char *buf) | 550 | struct node_attr { |
548 | { | 551 | struct sysdev_class_attribute attr; |
549 | return print_nodes_state(N_POSSIBLE, buf); | 552 | enum node_states state; |
550 | } | 553 | }; |
551 | |||
552 | static ssize_t print_nodes_online(struct sysdev_class *class, char *buf) | ||
553 | { | ||
554 | return print_nodes_state(N_ONLINE, buf); | ||
555 | } | ||
556 | |||
557 | static ssize_t print_nodes_has_normal_memory(struct sysdev_class *class, | ||
558 | char *buf) | ||
559 | { | ||
560 | return print_nodes_state(N_NORMAL_MEMORY, buf); | ||
561 | } | ||
562 | 554 | ||
563 | static ssize_t print_nodes_has_cpu(struct sysdev_class *class, char *buf) | 555 | static ssize_t show_node_state(struct sysdev_class *class, |
556 | struct sysdev_class_attribute *attr, char *buf) | ||
564 | { | 557 | { |
565 | return print_nodes_state(N_CPU, buf); | 558 | struct node_attr *na = container_of(attr, struct node_attr, attr); |
559 | return print_nodes_state(na->state, buf); | ||
566 | } | 560 | } |
567 | 561 | ||
568 | static SYSDEV_CLASS_ATTR(possible, 0444, print_nodes_possible, NULL); | 562 | #define _NODE_ATTR(name, state) \ |
569 | static SYSDEV_CLASS_ATTR(online, 0444, print_nodes_online, NULL); | 563 | { _SYSDEV_CLASS_ATTR(name, 0444, show_node_state, NULL), state } |
570 | static SYSDEV_CLASS_ATTR(has_normal_memory, 0444, print_nodes_has_normal_memory, | ||
571 | NULL); | ||
572 | static SYSDEV_CLASS_ATTR(has_cpu, 0444, print_nodes_has_cpu, NULL); | ||
573 | 564 | ||
565 | static struct node_attr node_state_attr[] = { | ||
566 | _NODE_ATTR(possible, N_POSSIBLE), | ||
567 | _NODE_ATTR(online, N_ONLINE), | ||
568 | _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY), | ||
569 | _NODE_ATTR(has_cpu, N_CPU), | ||
574 | #ifdef CONFIG_HIGHMEM | 570 | #ifdef CONFIG_HIGHMEM |
575 | static ssize_t print_nodes_has_high_memory(struct sysdev_class *class, | 571 | _NODE_ATTR(has_high_memory, N_HIGH_MEMORY), |
576 | char *buf) | ||
577 | { | ||
578 | return print_nodes_state(N_HIGH_MEMORY, buf); | ||
579 | } | ||
580 | |||
581 | static SYSDEV_CLASS_ATTR(has_high_memory, 0444, print_nodes_has_high_memory, | ||
582 | NULL); | ||
583 | #endif | 572 | #endif |
573 | }; | ||
584 | 574 | ||
585 | struct sysdev_class_attribute *node_state_attr[] = { | 575 | static struct sysdev_class_attribute *node_state_attrs[] = { |
586 | &attr_possible, | 576 | &node_state_attr[0].attr, |
587 | &attr_online, | 577 | &node_state_attr[1].attr, |
588 | &attr_has_normal_memory, | 578 | &node_state_attr[2].attr, |
579 | &node_state_attr[3].attr, | ||
589 | #ifdef CONFIG_HIGHMEM | 580 | #ifdef CONFIG_HIGHMEM |
590 | &attr_has_high_memory, | 581 | &node_state_attr[4].attr, |
591 | #endif | 582 | #endif |
592 | &attr_has_cpu, | 583 | NULL |
593 | }; | 584 | }; |
594 | 585 | ||
595 | static int node_states_init(void) | ||
596 | { | ||
597 | int i; | ||
598 | int err = 0; | ||
599 | |||
600 | for (i = 0; i < NR_NODE_STATES; i++) { | ||
601 | int ret; | ||
602 | ret = sysdev_class_create_file(&node_class, node_state_attr[i]); | ||
603 | if (!err) | ||
604 | err = ret; | ||
605 | } | ||
606 | return err; | ||
607 | } | ||
608 | |||
609 | #define NODE_CALLBACK_PRI 2 /* lower than SLAB */ | 586 | #define NODE_CALLBACK_PRI 2 /* lower than SLAB */ |
610 | static int __init register_node_type(void) | 587 | static int __init register_node_type(void) |
611 | { | 588 | { |
612 | int ret; | 589 | int ret; |
613 | 590 | ||
591 | BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES); | ||
592 | BUILD_BUG_ON(ARRAY_SIZE(node_state_attrs)-1 != NR_NODE_STATES); | ||
593 | |||
614 | ret = sysdev_class_register(&node_class); | 594 | ret = sysdev_class_register(&node_class); |
615 | if (!ret) { | 595 | if (!ret) { |
616 | ret = node_states_init(); | ||
617 | hotplug_memory_notifier(node_memory_callback, | 596 | hotplug_memory_notifier(node_memory_callback, |
618 | NODE_CALLBACK_PRI); | 597 | NODE_CALLBACK_PRI); |
619 | } | 598 | } |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 58efaf2f1259..1ba9d617d241 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -128,7 +128,7 @@ struct platform_object { | |||
128 | }; | 128 | }; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * platform_device_put | 131 | * platform_device_put - destroy a platform device |
132 | * @pdev: platform device to free | 132 | * @pdev: platform device to free |
133 | * | 133 | * |
134 | * Free all memory associated with a platform device. This function must | 134 | * Free all memory associated with a platform device. This function must |
@@ -152,7 +152,7 @@ static void platform_device_release(struct device *dev) | |||
152 | } | 152 | } |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * platform_device_alloc | 155 | * platform_device_alloc - create a platform device |
156 | * @name: base name of the device we're adding | 156 | * @name: base name of the device we're adding |
157 | * @id: instance id | 157 | * @id: instance id |
158 | * | 158 | * |
@@ -177,7 +177,7 @@ struct platform_device *platform_device_alloc(const char *name, int id) | |||
177 | EXPORT_SYMBOL_GPL(platform_device_alloc); | 177 | EXPORT_SYMBOL_GPL(platform_device_alloc); |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * platform_device_add_resources | 180 | * platform_device_add_resources - add resources to a platform device |
181 | * @pdev: platform device allocated by platform_device_alloc to add resources to | 181 | * @pdev: platform device allocated by platform_device_alloc to add resources to |
182 | * @res: set of resources that needs to be allocated for the device | 182 | * @res: set of resources that needs to be allocated for the device |
183 | * @num: number of resources | 183 | * @num: number of resources |
@@ -202,7 +202,7 @@ int platform_device_add_resources(struct platform_device *pdev, | |||
202 | EXPORT_SYMBOL_GPL(platform_device_add_resources); | 202 | EXPORT_SYMBOL_GPL(platform_device_add_resources); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * platform_device_add_data | 205 | * platform_device_add_data - add platform-specific data to a platform device |
206 | * @pdev: platform device allocated by platform_device_alloc to add resources to | 206 | * @pdev: platform device allocated by platform_device_alloc to add resources to |
207 | * @data: platform specific data for this platform device | 207 | * @data: platform specific data for this platform device |
208 | * @size: size of platform specific data | 208 | * @size: size of platform specific data |
@@ -344,7 +344,7 @@ void platform_device_unregister(struct platform_device *pdev) | |||
344 | EXPORT_SYMBOL_GPL(platform_device_unregister); | 344 | EXPORT_SYMBOL_GPL(platform_device_unregister); |
345 | 345 | ||
346 | /** | 346 | /** |
347 | * platform_device_register_simple | 347 | * platform_device_register_simple - add a platform-level device and its resources |
348 | * @name: base name of the device we're adding | 348 | * @name: base name of the device we're adding |
349 | * @id: instance id | 349 | * @id: instance id |
350 | * @res: set of resources that needs to be allocated for the device | 350 | * @res: set of resources that needs to be allocated for the device |
@@ -396,7 +396,7 @@ error: | |||
396 | EXPORT_SYMBOL_GPL(platform_device_register_simple); | 396 | EXPORT_SYMBOL_GPL(platform_device_register_simple); |
397 | 397 | ||
398 | /** | 398 | /** |
399 | * platform_device_register_data | 399 | * platform_device_register_data - add a platform-level device with platform-specific data |
400 | * @parent: parent device for the device we're adding | 400 | * @parent: parent device for the device we're adding |
401 | * @name: base name of the device we're adding | 401 | * @name: base name of the device we're adding |
402 | * @id: instance id | 402 | * @id: instance id |
@@ -473,7 +473,7 @@ static void platform_drv_shutdown(struct device *_dev) | |||
473 | } | 473 | } |
474 | 474 | ||
475 | /** | 475 | /** |
476 | * platform_driver_register | 476 | * platform_driver_register - register a driver for platform-level devices |
477 | * @drv: platform driver structure | 477 | * @drv: platform driver structure |
478 | */ | 478 | */ |
479 | int platform_driver_register(struct platform_driver *drv) | 479 | int platform_driver_register(struct platform_driver *drv) |
@@ -491,7 +491,7 @@ int platform_driver_register(struct platform_driver *drv) | |||
491 | EXPORT_SYMBOL_GPL(platform_driver_register); | 491 | EXPORT_SYMBOL_GPL(platform_driver_register); |
492 | 492 | ||
493 | /** | 493 | /** |
494 | * platform_driver_unregister | 494 | * platform_driver_unregister - unregister a driver for platform-level devices |
495 | * @drv: platform driver structure | 495 | * @drv: platform driver structure |
496 | */ | 496 | */ |
497 | void platform_driver_unregister(struct platform_driver *drv) | 497 | void platform_driver_unregister(struct platform_driver *drv) |
@@ -548,6 +548,64 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv, | |||
548 | } | 548 | } |
549 | EXPORT_SYMBOL_GPL(platform_driver_probe); | 549 | EXPORT_SYMBOL_GPL(platform_driver_probe); |
550 | 550 | ||
551 | /** | ||
552 | * platform_create_bundle - register driver and create corresponding device | ||
553 | * @driver: platform driver structure | ||
554 | * @probe: the driver probe routine, probably from an __init section | ||
555 | * @res: set of resources that needs to be allocated for the device | ||
556 | * @n_res: number of resources | ||
557 | * @data: platform specific data for this platform device | ||
558 | * @size: size of platform specific data | ||
559 | * | ||
560 | * Use this in legacy-style modules that probe hardware directly and | ||
561 | * register a single platform device and corresponding platform driver. | ||
562 | */ | ||
563 | struct platform_device * __init_or_module platform_create_bundle( | ||
564 | struct platform_driver *driver, | ||
565 | int (*probe)(struct platform_device *), | ||
566 | struct resource *res, unsigned int n_res, | ||
567 | const void *data, size_t size) | ||
568 | { | ||
569 | struct platform_device *pdev; | ||
570 | int error; | ||
571 | |||
572 | pdev = platform_device_alloc(driver->driver.name, -1); | ||
573 | if (!pdev) { | ||
574 | error = -ENOMEM; | ||
575 | goto err_out; | ||
576 | } | ||
577 | |||
578 | if (res) { | ||
579 | error = platform_device_add_resources(pdev, res, n_res); | ||
580 | if (error) | ||
581 | goto err_pdev_put; | ||
582 | } | ||
583 | |||
584 | if (data) { | ||
585 | error = platform_device_add_data(pdev, data, size); | ||
586 | if (error) | ||
587 | goto err_pdev_put; | ||
588 | } | ||
589 | |||
590 | error = platform_device_add(pdev); | ||
591 | if (error) | ||
592 | goto err_pdev_put; | ||
593 | |||
594 | error = platform_driver_probe(driver, probe); | ||
595 | if (error) | ||
596 | goto err_pdev_del; | ||
597 | |||
598 | return pdev; | ||
599 | |||
600 | err_pdev_del: | ||
601 | platform_device_del(pdev); | ||
602 | err_pdev_put: | ||
603 | platform_device_put(pdev); | ||
604 | err_out: | ||
605 | return ERR_PTR(error); | ||
606 | } | ||
607 | EXPORT_SYMBOL_GPL(platform_create_bundle); | ||
608 | |||
551 | /* modalias support enables more hands-off userspace setup: | 609 | /* modalias support enables more hands-off userspace setup: |
552 | * (a) environment variable lets new-style hotplug events work once system is | 610 | * (a) environment variable lets new-style hotplug events work once system is |
553 | * fully running: "modprobe $MODALIAS" | 611 | * fully running: "modprobe $MODALIAS" |
@@ -578,7 +636,7 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
578 | } | 636 | } |
579 | 637 | ||
580 | static const struct platform_device_id *platform_match_id( | 638 | static const struct platform_device_id *platform_match_id( |
581 | struct platform_device_id *id, | 639 | const struct platform_device_id *id, |
582 | struct platform_device *pdev) | 640 | struct platform_device *pdev) |
583 | { | 641 | { |
584 | while (id->name[0]) { | 642 | while (id->name[0]) { |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 0e26a6f6fd48..d477f4dc5e51 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -35,8 +35,8 @@ | |||
35 | * because children are guaranteed to be discovered after parents, and | 35 | * because children are guaranteed to be discovered after parents, and |
36 | * are inserted at the back of the list on discovery. | 36 | * are inserted at the back of the list on discovery. |
37 | * | 37 | * |
38 | * Since device_pm_add() may be called with a device semaphore held, | 38 | * Since device_pm_add() may be called with a device lock held, |
39 | * we must never try to acquire a device semaphore while holding | 39 | * we must never try to acquire a device lock while holding |
40 | * dpm_list_mutex. | 40 | * dpm_list_mutex. |
41 | */ | 41 | */ |
42 | 42 | ||
@@ -508,7 +508,7 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) | |||
508 | TRACE_RESUME(0); | 508 | TRACE_RESUME(0); |
509 | 509 | ||
510 | dpm_wait(dev->parent, async); | 510 | dpm_wait(dev->parent, async); |
511 | down(&dev->sem); | 511 | device_lock(dev); |
512 | 512 | ||
513 | dev->power.status = DPM_RESUMING; | 513 | dev->power.status = DPM_RESUMING; |
514 | 514 | ||
@@ -543,7 +543,7 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) | |||
543 | } | 543 | } |
544 | } | 544 | } |
545 | End: | 545 | End: |
546 | up(&dev->sem); | 546 | device_unlock(dev); |
547 | complete_all(&dev->power.completion); | 547 | complete_all(&dev->power.completion); |
548 | 548 | ||
549 | TRACE_RESUME(error); | 549 | TRACE_RESUME(error); |
@@ -629,7 +629,7 @@ static void dpm_resume(pm_message_t state) | |||
629 | */ | 629 | */ |
630 | static void device_complete(struct device *dev, pm_message_t state) | 630 | static void device_complete(struct device *dev, pm_message_t state) |
631 | { | 631 | { |
632 | down(&dev->sem); | 632 | device_lock(dev); |
633 | 633 | ||
634 | if (dev->class && dev->class->pm && dev->class->pm->complete) { | 634 | if (dev->class && dev->class->pm && dev->class->pm->complete) { |
635 | pm_dev_dbg(dev, state, "completing class "); | 635 | pm_dev_dbg(dev, state, "completing class "); |
@@ -646,7 +646,7 @@ static void device_complete(struct device *dev, pm_message_t state) | |||
646 | dev->bus->pm->complete(dev); | 646 | dev->bus->pm->complete(dev); |
647 | } | 647 | } |
648 | 648 | ||
649 | up(&dev->sem); | 649 | device_unlock(dev); |
650 | } | 650 | } |
651 | 651 | ||
652 | /** | 652 | /** |
@@ -809,7 +809,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) | |||
809 | int error = 0; | 809 | int error = 0; |
810 | 810 | ||
811 | dpm_wait_for_children(dev, async); | 811 | dpm_wait_for_children(dev, async); |
812 | down(&dev->sem); | 812 | device_lock(dev); |
813 | 813 | ||
814 | if (async_error) | 814 | if (async_error) |
815 | goto End; | 815 | goto End; |
@@ -849,7 +849,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) | |||
849 | dev->power.status = DPM_OFF; | 849 | dev->power.status = DPM_OFF; |
850 | 850 | ||
851 | End: | 851 | End: |
852 | up(&dev->sem); | 852 | device_unlock(dev); |
853 | complete_all(&dev->power.completion); | 853 | complete_all(&dev->power.completion); |
854 | 854 | ||
855 | return error; | 855 | return error; |
@@ -938,7 +938,7 @@ static int device_prepare(struct device *dev, pm_message_t state) | |||
938 | { | 938 | { |
939 | int error = 0; | 939 | int error = 0; |
940 | 940 | ||
941 | down(&dev->sem); | 941 | device_lock(dev); |
942 | 942 | ||
943 | if (dev->bus && dev->bus->pm && dev->bus->pm->prepare) { | 943 | if (dev->bus && dev->bus->pm && dev->bus->pm->prepare) { |
944 | pm_dev_dbg(dev, state, "preparing "); | 944 | pm_dev_dbg(dev, state, "preparing "); |
@@ -962,7 +962,7 @@ static int device_prepare(struct device *dev, pm_message_t state) | |||
962 | suspend_report_result(dev->class->pm->prepare, error); | 962 | suspend_report_result(dev->class->pm->prepare, error); |
963 | } | 963 | } |
964 | End: | 964 | End: |
965 | up(&dev->sem); | 965 | device_unlock(dev); |
966 | 966 | ||
967 | return error; | 967 | return error; |
968 | } | 968 | } |
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index 0d903909af7e..8980feec5d14 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c | |||
@@ -54,7 +54,7 @@ sysdev_store(struct kobject *kobj, struct attribute *attr, | |||
54 | return -EIO; | 54 | return -EIO; |
55 | } | 55 | } |
56 | 56 | ||
57 | static struct sysfs_ops sysfs_ops = { | 57 | static const struct sysfs_ops sysfs_ops = { |
58 | .show = sysdev_show, | 58 | .show = sysdev_show, |
59 | .store = sysdev_store, | 59 | .store = sysdev_store, |
60 | }; | 60 | }; |
@@ -89,7 +89,7 @@ static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr, | |||
89 | struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); | 89 | struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); |
90 | 90 | ||
91 | if (class_attr->show) | 91 | if (class_attr->show) |
92 | return class_attr->show(class, buffer); | 92 | return class_attr->show(class, class_attr, buffer); |
93 | return -EIO; | 93 | return -EIO; |
94 | } | 94 | } |
95 | 95 | ||
@@ -100,11 +100,11 @@ static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr, | |||
100 | struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); | 100 | struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); |
101 | 101 | ||
102 | if (class_attr->store) | 102 | if (class_attr->store) |
103 | return class_attr->store(class, buffer, count); | 103 | return class_attr->store(class, class_attr, buffer, count); |
104 | return -EIO; | 104 | return -EIO; |
105 | } | 105 | } |
106 | 106 | ||
107 | static struct sysfs_ops sysfs_class_ops = { | 107 | static const struct sysfs_ops sysfs_class_ops = { |
108 | .show = sysdev_class_show, | 108 | .show = sysdev_class_show, |
109 | .store = sysdev_class_store, | 109 | .store = sysdev_class_store, |
110 | }; | 110 | }; |
@@ -145,13 +145,20 @@ int sysdev_class_register(struct sysdev_class *cls) | |||
145 | if (retval) | 145 | if (retval) |
146 | return retval; | 146 | return retval; |
147 | 147 | ||
148 | return kset_register(&cls->kset); | 148 | retval = kset_register(&cls->kset); |
149 | if (!retval && cls->attrs) | ||
150 | retval = sysfs_create_files(&cls->kset.kobj, | ||
151 | (const struct attribute **)cls->attrs); | ||
152 | return retval; | ||
149 | } | 153 | } |
150 | 154 | ||
151 | void sysdev_class_unregister(struct sysdev_class *cls) | 155 | void sysdev_class_unregister(struct sysdev_class *cls) |
152 | { | 156 | { |
153 | pr_debug("Unregistering sysdev class '%s'\n", | 157 | pr_debug("Unregistering sysdev class '%s'\n", |
154 | kobject_name(&cls->kset.kobj)); | 158 | kobject_name(&cls->kset.kobj)); |
159 | if (cls->attrs) | ||
160 | sysfs_remove_files(&cls->kset.kobj, | ||
161 | (const struct attribute **)cls->attrs); | ||
155 | kset_unregister(&cls->kset); | 162 | kset_unregister(&cls->kset); |
156 | } | 163 | } |
157 | 164 | ||
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index b9b117059b62..90c4038702da 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -144,13 +144,23 @@ | |||
144 | * Better audit of register_blkdev. | 144 | * Better audit of register_blkdev. |
145 | */ | 145 | */ |
146 | 146 | ||
147 | #define FLOPPY_SANITY_CHECK | ||
148 | #undef FLOPPY_SILENT_DCL_CLEAR | 147 | #undef FLOPPY_SILENT_DCL_CLEAR |
149 | 148 | ||
150 | #define REALLY_SLOW_IO | 149 | #define REALLY_SLOW_IO |
151 | 150 | ||
152 | #define DEBUGT 2 | 151 | #define DEBUGT 2 |
153 | #define DCL_DEBUG /* debug disk change line */ | 152 | |
153 | #define DPRINT(format, args...) \ | ||
154 | pr_info("floppy%d: " format, current_drive, ##args) | ||
155 | |||
156 | #define DCL_DEBUG /* debug disk change line */ | ||
157 | #ifdef DCL_DEBUG | ||
158 | #define debug_dcl(test, fmt, args...) \ | ||
159 | do { if ((test) & FD_DEBUG) DPRINT(fmt, ##args); } while (0) | ||
160 | #else | ||
161 | #define debug_dcl(test, fmt, args...) \ | ||
162 | do { if (0) DPRINT(fmt, ##args); } while (0) | ||
163 | #endif | ||
154 | 164 | ||
155 | /* do print messages for unexpected interrupts */ | 165 | /* do print messages for unexpected interrupts */ |
156 | static int print_unex = 1; | 166 | static int print_unex = 1; |
@@ -180,6 +190,8 @@ static int print_unex = 1; | |||
180 | #include <linux/mod_devicetable.h> | 190 | #include <linux/mod_devicetable.h> |
181 | #include <linux/buffer_head.h> /* for invalidate_buffers() */ | 191 | #include <linux/buffer_head.h> /* for invalidate_buffers() */ |
182 | #include <linux/mutex.h> | 192 | #include <linux/mutex.h> |
193 | #include <linux/io.h> | ||
194 | #include <linux/uaccess.h> | ||
183 | 195 | ||
184 | /* | 196 | /* |
185 | * PS/2 floppies have much slower step rates than regular floppies. | 197 | * PS/2 floppies have much slower step rates than regular floppies. |
@@ -191,8 +203,6 @@ static int slow_floppy; | |||
191 | #include <asm/dma.h> | 203 | #include <asm/dma.h> |
192 | #include <asm/irq.h> | 204 | #include <asm/irq.h> |
193 | #include <asm/system.h> | 205 | #include <asm/system.h> |
194 | #include <asm/io.h> | ||
195 | #include <asm/uaccess.h> | ||
196 | 206 | ||
197 | static int FLOPPY_IRQ = 6; | 207 | static int FLOPPY_IRQ = 6; |
198 | static int FLOPPY_DMA = 2; | 208 | static int FLOPPY_DMA = 2; |
@@ -241,8 +251,6 @@ static int allowed_drive_mask = 0x33; | |||
241 | 251 | ||
242 | static int irqdma_allocated; | 252 | static int irqdma_allocated; |
243 | 253 | ||
244 | #define DEVICE_NAME "floppy" | ||
245 | |||
246 | #include <linux/blkdev.h> | 254 | #include <linux/blkdev.h> |
247 | #include <linux/blkpg.h> | 255 | #include <linux/blkpg.h> |
248 | #include <linux/cdrom.h> /* for the compatibility eject ioctl */ | 256 | #include <linux/cdrom.h> /* for the compatibility eject ioctl */ |
@@ -250,7 +258,7 @@ static int irqdma_allocated; | |||
250 | 258 | ||
251 | static struct request *current_req; | 259 | static struct request *current_req; |
252 | static struct request_queue *floppy_queue; | 260 | static struct request_queue *floppy_queue; |
253 | static void do_fd_request(struct request_queue * q); | 261 | static void do_fd_request(struct request_queue *q); |
254 | 262 | ||
255 | #ifndef fd_get_dma_residue | 263 | #ifndef fd_get_dma_residue |
256 | #define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA) | 264 | #define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA) |
@@ -263,7 +271,7 @@ static void do_fd_request(struct request_queue * q); | |||
263 | #endif | 271 | #endif |
264 | 272 | ||
265 | #ifndef fd_dma_mem_alloc | 273 | #ifndef fd_dma_mem_alloc |
266 | #define fd_dma_mem_alloc(size) __get_dma_pages(GFP_KERNEL,get_order(size)) | 274 | #define fd_dma_mem_alloc(size) __get_dma_pages(GFP_KERNEL, get_order(size)) |
267 | #endif | 275 | #endif |
268 | 276 | ||
269 | static inline void fallback_on_nodma_alloc(char **addr, size_t l) | 277 | static inline void fallback_on_nodma_alloc(char **addr, size_t l) |
@@ -273,7 +281,7 @@ static inline void fallback_on_nodma_alloc(char **addr, size_t l) | |||
273 | return; /* we have the memory */ | 281 | return; /* we have the memory */ |
274 | if (can_use_virtual_dma != 2) | 282 | if (can_use_virtual_dma != 2) |
275 | return; /* no fallback allowed */ | 283 | return; /* no fallback allowed */ |
276 | printk("DMA memory shortage. Temporarily falling back on virtual DMA\n"); | 284 | pr_info("DMA memory shortage. Temporarily falling back on virtual DMA\n"); |
277 | *addr = (char *)nodma_mem_alloc(l); | 285 | *addr = (char *)nodma_mem_alloc(l); |
278 | #else | 286 | #else |
279 | return; | 287 | return; |
@@ -283,59 +291,50 @@ static inline void fallback_on_nodma_alloc(char **addr, size_t l) | |||
283 | /* End dma memory related stuff */ | 291 | /* End dma memory related stuff */ |
284 | 292 | ||
285 | static unsigned long fake_change; | 293 | static unsigned long fake_change; |
286 | static int initialising = 1; | 294 | static bool initialized; |
287 | 295 | ||
288 | #define ITYPE(x) (((x)>>2) & 0x1f) | 296 | #define ITYPE(x) (((x) >> 2) & 0x1f) |
289 | #define TOMINOR(x) ((x & 3) | ((x & 4) << 5)) | 297 | #define TOMINOR(x) ((x & 3) | ((x & 4) << 5)) |
290 | #define UNIT(x) ((x) & 0x03) /* drive on fdc */ | 298 | #define UNIT(x) ((x) & 0x03) /* drive on fdc */ |
291 | #define FDC(x) (((x) & 0x04) >> 2) /* fdc of drive */ | 299 | #define FDC(x) (((x) & 0x04) >> 2) /* fdc of drive */ |
292 | /* reverse mapping from unit and fdc to drive */ | 300 | /* reverse mapping from unit and fdc to drive */ |
293 | #define REVDRIVE(fdc, unit) ((unit) + ((fdc) << 2)) | 301 | #define REVDRIVE(fdc, unit) ((unit) + ((fdc) << 2)) |
294 | #define DP (&drive_params[current_drive]) | ||
295 | #define DRS (&drive_state[current_drive]) | ||
296 | #define DRWE (&write_errors[current_drive]) | ||
297 | #define FDCS (&fdc_state[fdc]) | ||
298 | #define CLEARF(x) clear_bit(x##_BIT, &DRS->flags) | ||
299 | #define SETF(x) set_bit(x##_BIT, &DRS->flags) | ||
300 | #define TESTF(x) test_bit(x##_BIT, &DRS->flags) | ||
301 | 302 | ||
302 | #define UDP (&drive_params[drive]) | 303 | #define DP (&drive_params[current_drive]) |
303 | #define UDRS (&drive_state[drive]) | 304 | #define DRS (&drive_state[current_drive]) |
304 | #define UDRWE (&write_errors[drive]) | 305 | #define DRWE (&write_errors[current_drive]) |
305 | #define UFDCS (&fdc_state[FDC(drive)]) | 306 | #define FDCS (&fdc_state[fdc]) |
306 | #define UCLEARF(x) clear_bit(x##_BIT, &UDRS->flags) | ||
307 | #define USETF(x) set_bit(x##_BIT, &UDRS->flags) | ||
308 | #define UTESTF(x) test_bit(x##_BIT, &UDRS->flags) | ||
309 | 307 | ||
310 | #define DPRINT(format, args...) printk(DEVICE_NAME "%d: " format, current_drive , ## args) | 308 | #define UDP (&drive_params[drive]) |
309 | #define UDRS (&drive_state[drive]) | ||
310 | #define UDRWE (&write_errors[drive]) | ||
311 | #define UFDCS (&fdc_state[FDC(drive)]) | ||
311 | 312 | ||
312 | #define PH_HEAD(floppy,head) (((((floppy)->stretch & 2) >>1) ^ head) << 2) | 313 | #define PH_HEAD(floppy, head) (((((floppy)->stretch & 2) >> 1) ^ head) << 2) |
313 | #define STRETCH(floppy) ((floppy)->stretch & FD_STRETCH) | 314 | #define STRETCH(floppy) ((floppy)->stretch & FD_STRETCH) |
314 | |||
315 | #define CLEARSTRUCT(x) memset((x), 0, sizeof(*(x))) | ||
316 | 315 | ||
317 | /* read/write */ | 316 | /* read/write */ |
318 | #define COMMAND raw_cmd->cmd[0] | 317 | #define COMMAND (raw_cmd->cmd[0]) |
319 | #define DR_SELECT raw_cmd->cmd[1] | 318 | #define DR_SELECT (raw_cmd->cmd[1]) |
320 | #define TRACK raw_cmd->cmd[2] | 319 | #define TRACK (raw_cmd->cmd[2]) |
321 | #define HEAD raw_cmd->cmd[3] | 320 | #define HEAD (raw_cmd->cmd[3]) |
322 | #define SECTOR raw_cmd->cmd[4] | 321 | #define SECTOR (raw_cmd->cmd[4]) |
323 | #define SIZECODE raw_cmd->cmd[5] | 322 | #define SIZECODE (raw_cmd->cmd[5]) |
324 | #define SECT_PER_TRACK raw_cmd->cmd[6] | 323 | #define SECT_PER_TRACK (raw_cmd->cmd[6]) |
325 | #define GAP raw_cmd->cmd[7] | 324 | #define GAP (raw_cmd->cmd[7]) |
326 | #define SIZECODE2 raw_cmd->cmd[8] | 325 | #define SIZECODE2 (raw_cmd->cmd[8]) |
327 | #define NR_RW 9 | 326 | #define NR_RW 9 |
328 | 327 | ||
329 | /* format */ | 328 | /* format */ |
330 | #define F_SIZECODE raw_cmd->cmd[2] | 329 | #define F_SIZECODE (raw_cmd->cmd[2]) |
331 | #define F_SECT_PER_TRACK raw_cmd->cmd[3] | 330 | #define F_SECT_PER_TRACK (raw_cmd->cmd[3]) |
332 | #define F_GAP raw_cmd->cmd[4] | 331 | #define F_GAP (raw_cmd->cmd[4]) |
333 | #define F_FILL raw_cmd->cmd[5] | 332 | #define F_FILL (raw_cmd->cmd[5]) |
334 | #define NR_F 6 | 333 | #define NR_F 6 |
335 | 334 | ||
336 | /* | 335 | /* |
337 | * Maximum disk size (in kilobytes). This default is used whenever the | 336 | * Maximum disk size (in kilobytes). |
338 | * current disk size is unknown. | 337 | * This default is used whenever the current disk size is unknown. |
339 | * [Now it is rather a minimum] | 338 | * [Now it is rather a minimum] |
340 | */ | 339 | */ |
341 | #define MAX_DISK_SIZE 4 /* 3984 */ | 340 | #define MAX_DISK_SIZE 4 /* 3984 */ |
@@ -345,16 +344,17 @@ static int initialising = 1; | |||
345 | */ | 344 | */ |
346 | #define MAX_REPLIES 16 | 345 | #define MAX_REPLIES 16 |
347 | static unsigned char reply_buffer[MAX_REPLIES]; | 346 | static unsigned char reply_buffer[MAX_REPLIES]; |
348 | static int inr; /* size of reply buffer, when called from interrupt */ | 347 | static int inr; /* size of reply buffer, when called from interrupt */ |
349 | #define ST0 (reply_buffer[0]) | 348 | #define ST0 (reply_buffer[0]) |
350 | #define ST1 (reply_buffer[1]) | 349 | #define ST1 (reply_buffer[1]) |
351 | #define ST2 (reply_buffer[2]) | 350 | #define ST2 (reply_buffer[2]) |
352 | #define ST3 (reply_buffer[0]) /* result of GETSTATUS */ | 351 | #define ST3 (reply_buffer[0]) /* result of GETSTATUS */ |
353 | #define R_TRACK (reply_buffer[3]) | 352 | #define R_TRACK (reply_buffer[3]) |
354 | #define R_HEAD (reply_buffer[4]) | 353 | #define R_HEAD (reply_buffer[4]) |
355 | #define R_SECTOR (reply_buffer[5]) | 354 | #define R_SECTOR (reply_buffer[5]) |
356 | #define R_SIZECODE (reply_buffer[6]) | 355 | #define R_SIZECODE (reply_buffer[6]) |
357 | #define SEL_DLY (2*HZ/100) | 356 | |
357 | #define SEL_DLY (2 * HZ / 100) | ||
358 | 358 | ||
359 | /* | 359 | /* |
360 | * this struct defines the different floppy drive types. | 360 | * this struct defines the different floppy drive types. |
@@ -505,9 +505,9 @@ static char floppy_device_name[] = "floppy"; | |||
505 | static int probing; | 505 | static int probing; |
506 | 506 | ||
507 | /* Synchronization of FDC access. */ | 507 | /* Synchronization of FDC access. */ |
508 | #define FD_COMMAND_NONE -1 | 508 | #define FD_COMMAND_NONE -1 |
509 | #define FD_COMMAND_ERROR 2 | 509 | #define FD_COMMAND_ERROR 2 |
510 | #define FD_COMMAND_OKAY 3 | 510 | #define FD_COMMAND_OKAY 3 |
511 | 511 | ||
512 | static volatile int command_status = FD_COMMAND_NONE; | 512 | static volatile int command_status = FD_COMMAND_NONE; |
513 | static unsigned long fdc_busy; | 513 | static unsigned long fdc_busy; |
@@ -515,11 +515,6 @@ static DECLARE_WAIT_QUEUE_HEAD(fdc_wait); | |||
515 | static DECLARE_WAIT_QUEUE_HEAD(command_done); | 515 | static DECLARE_WAIT_QUEUE_HEAD(command_done); |
516 | 516 | ||
517 | #define NO_SIGNAL (!interruptible || !signal_pending(current)) | 517 | #define NO_SIGNAL (!interruptible || !signal_pending(current)) |
518 | #define CALL(x) if ((x) == -EINTR) return -EINTR | ||
519 | #define ECALL(x) if ((ret = (x))) return ret; | ||
520 | #define _WAIT(x,i) CALL(ret=wait_til_done((x),i)) | ||
521 | #define WAIT(x) _WAIT((x),interruptible) | ||
522 | #define IWAIT(x) _WAIT((x),1) | ||
523 | 518 | ||
524 | /* Errors during formatting are counted here. */ | 519 | /* Errors during formatting are counted here. */ |
525 | static int format_errors; | 520 | static int format_errors; |
@@ -545,8 +540,9 @@ static int max_buffer_sectors; | |||
545 | static int *errors; | 540 | static int *errors; |
546 | typedef void (*done_f)(int); | 541 | typedef void (*done_f)(int); |
547 | static struct cont_t { | 542 | static struct cont_t { |
548 | void (*interrupt)(void); /* this is called after the interrupt of the | 543 | void (*interrupt)(void); |
549 | * main command */ | 544 | /* this is called after the interrupt of the |
545 | * main command */ | ||
550 | void (*redo)(void); /* this is called to retry the operation */ | 546 | void (*redo)(void); /* this is called to retry the operation */ |
551 | void (*error)(void); /* this is called to tally an error */ | 547 | void (*error)(void); /* this is called to tally an error */ |
552 | done_f done; /* this is called to say if the operation has | 548 | done_f done; /* this is called to say if the operation has |
@@ -571,7 +567,6 @@ static void floppy_release_irq_and_dma(void); | |||
571 | * reset doesn't need to be tested before sending commands, because | 567 | * reset doesn't need to be tested before sending commands, because |
572 | * output_byte is automatically disabled when reset is set. | 568 | * output_byte is automatically disabled when reset is set. |
573 | */ | 569 | */ |
574 | #define CHECK_RESET { if (FDCS->reset){ reset_fdc(); return; } } | ||
575 | static void reset_fdc(void); | 570 | static void reset_fdc(void); |
576 | 571 | ||
577 | /* | 572 | /* |
@@ -579,9 +574,9 @@ static void reset_fdc(void); | |||
579 | * information to interrupts. They are the data used for the current | 574 | * information to interrupts. They are the data used for the current |
580 | * request. | 575 | * request. |
581 | */ | 576 | */ |
582 | #define NO_TRACK -1 | 577 | #define NO_TRACK -1 |
583 | #define NEED_1_RECAL -2 | 578 | #define NEED_1_RECAL -2 |
584 | #define NEED_2_RECAL -3 | 579 | #define NEED_2_RECAL -3 |
585 | 580 | ||
586 | static int usage_count; | 581 | static int usage_count; |
587 | 582 | ||
@@ -621,39 +616,35 @@ static inline void set_debugt(void) | |||
621 | debugtimer = jiffies; | 616 | debugtimer = jiffies; |
622 | } | 617 | } |
623 | 618 | ||
624 | static inline void debugt(const char *message) | 619 | static inline void debugt(const char *func, const char *msg) |
625 | { | 620 | { |
626 | if (DP->flags & DEBUGT) | 621 | if (DP->flags & DEBUGT) |
627 | printk("%s dtime=%lu\n", message, jiffies - debugtimer); | 622 | pr_info("%s:%s dtime=%lu\n", func, msg, jiffies - debugtimer); |
628 | } | 623 | } |
629 | #else | 624 | #else |
630 | static inline void set_debugt(void) { } | 625 | static inline void set_debugt(void) { } |
631 | static inline void debugt(const char *message) { } | 626 | static inline void debugt(const char *func, const char *msg) { } |
632 | #endif /* DEBUGT */ | 627 | #endif /* DEBUGT */ |
633 | 628 | ||
634 | typedef void (*timeout_fn) (unsigned long); | 629 | typedef void (*timeout_fn)(unsigned long); |
635 | static DEFINE_TIMER(fd_timeout, floppy_shutdown, 0, 0); | 630 | static DEFINE_TIMER(fd_timeout, floppy_shutdown, 0, 0); |
636 | 631 | ||
637 | static const char *timeout_message; | 632 | static const char *timeout_message; |
638 | 633 | ||
639 | #ifdef FLOPPY_SANITY_CHECK | 634 | static void is_alive(const char *func, const char *message) |
640 | static void is_alive(const char *message) | ||
641 | { | 635 | { |
642 | /* this routine checks whether the floppy driver is "alive" */ | 636 | /* this routine checks whether the floppy driver is "alive" */ |
643 | if (test_bit(0, &fdc_busy) && command_status < 2 | 637 | if (test_bit(0, &fdc_busy) && command_status < 2 && |
644 | && !timer_pending(&fd_timeout)) { | 638 | !timer_pending(&fd_timeout)) { |
645 | DPRINT("timeout handler died: %s\n", message); | 639 | DPRINT("%s: timeout handler died. %s\n", func, message); |
646 | } | 640 | } |
647 | } | 641 | } |
648 | #endif | ||
649 | 642 | ||
650 | static void (*do_floppy) (void) = NULL; | 643 | static void (*do_floppy)(void) = NULL; |
651 | |||
652 | #ifdef FLOPPY_SANITY_CHECK | ||
653 | 644 | ||
654 | #define OLOGSIZE 20 | 645 | #define OLOGSIZE 20 |
655 | 646 | ||
656 | static void (*lasthandler) (void); | 647 | static void (*lasthandler)(void); |
657 | static unsigned long interruptjiffies; | 648 | static unsigned long interruptjiffies; |
658 | static unsigned long resultjiffies; | 649 | static unsigned long resultjiffies; |
659 | static int resultsize; | 650 | static int resultsize; |
@@ -666,12 +657,11 @@ static struct output_log { | |||
666 | } output_log[OLOGSIZE]; | 657 | } output_log[OLOGSIZE]; |
667 | 658 | ||
668 | static int output_log_pos; | 659 | static int output_log_pos; |
669 | #endif | ||
670 | 660 | ||
671 | #define current_reqD -1 | 661 | #define current_reqD -1 |
672 | #define MAXTIMEOUT -2 | 662 | #define MAXTIMEOUT -2 |
673 | 663 | ||
674 | static void __reschedule_timeout(int drive, const char *message, int marg) | 664 | static void __reschedule_timeout(int drive, const char *message) |
675 | { | 665 | { |
676 | if (drive == current_reqD) | 666 | if (drive == current_reqD) |
677 | drive = current_drive; | 667 | drive = current_drive; |
@@ -682,25 +672,22 @@ static void __reschedule_timeout(int drive, const char *message, int marg) | |||
682 | } else | 672 | } else |
683 | fd_timeout.expires = jiffies + UDP->timeout; | 673 | fd_timeout.expires = jiffies + UDP->timeout; |
684 | add_timer(&fd_timeout); | 674 | add_timer(&fd_timeout); |
685 | if (UDP->flags & FD_DEBUG) { | 675 | if (UDP->flags & FD_DEBUG) |
686 | DPRINT("reschedule timeout "); | 676 | DPRINT("reschedule timeout %s\n", message); |
687 | printk(message, marg); | ||
688 | printk("\n"); | ||
689 | } | ||
690 | timeout_message = message; | 677 | timeout_message = message; |
691 | } | 678 | } |
692 | 679 | ||
693 | static void reschedule_timeout(int drive, const char *message, int marg) | 680 | static void reschedule_timeout(int drive, const char *message) |
694 | { | 681 | { |
695 | unsigned long flags; | 682 | unsigned long flags; |
696 | 683 | ||
697 | spin_lock_irqsave(&floppy_lock, flags); | 684 | spin_lock_irqsave(&floppy_lock, flags); |
698 | __reschedule_timeout(drive, message, marg); | 685 | __reschedule_timeout(drive, message); |
699 | spin_unlock_irqrestore(&floppy_lock, flags); | 686 | spin_unlock_irqrestore(&floppy_lock, flags); |
700 | } | 687 | } |
701 | 688 | ||
702 | #define INFBOUND(a,b) (a)=max_t(int, a, b) | 689 | #define INFBOUND(a, b) (a) = max_t(int, a, b) |
703 | #define SUPBOUND(a,b) (a)=min_t(int, a, b) | 690 | #define SUPBOUND(a, b) (a) = min_t(int, a, b) |
704 | 691 | ||
705 | /* | 692 | /* |
706 | * Bottom half floppy driver. | 693 | * Bottom half floppy driver. |
@@ -739,7 +726,6 @@ static int disk_change(int drive) | |||
739 | { | 726 | { |
740 | int fdc = FDC(drive); | 727 | int fdc = FDC(drive); |
741 | 728 | ||
742 | #ifdef FLOPPY_SANITY_CHECK | ||
743 | if (time_before(jiffies, UDRS->select_date + UDP->select_delay)) | 729 | if (time_before(jiffies, UDRS->select_date + UDP->select_delay)) |
744 | DPRINT("WARNING disk change called early\n"); | 730 | DPRINT("WARNING disk change called early\n"); |
745 | if (!(FDCS->dor & (0x10 << UNIT(drive))) || | 731 | if (!(FDCS->dor & (0x10 << UNIT(drive))) || |
@@ -748,31 +734,27 @@ static int disk_change(int drive) | |||
748 | DPRINT("drive=%d fdc=%d dor=%x\n", drive, FDC(drive), | 734 | DPRINT("drive=%d fdc=%d dor=%x\n", drive, FDC(drive), |
749 | (unsigned int)FDCS->dor); | 735 | (unsigned int)FDCS->dor); |
750 | } | 736 | } |
751 | #endif | ||
752 | 737 | ||
753 | #ifdef DCL_DEBUG | 738 | debug_dcl(UDP->flags, |
754 | if (UDP->flags & FD_DEBUG) { | 739 | "checking disk change line for drive %d\n", drive); |
755 | DPRINT("checking disk change line for drive %d\n", drive); | 740 | debug_dcl(UDP->flags, "jiffies=%lu\n", jiffies); |
756 | DPRINT("jiffies=%lu\n", jiffies); | 741 | debug_dcl(UDP->flags, "disk change line=%x\n", fd_inb(FD_DIR) & 0x80); |
757 | DPRINT("disk change line=%x\n", fd_inb(FD_DIR) & 0x80); | 742 | debug_dcl(UDP->flags, "flags=%lx\n", UDRS->flags); |
758 | DPRINT("flags=%lx\n", UDRS->flags); | 743 | |
759 | } | ||
760 | #endif | ||
761 | if (UDP->flags & FD_BROKEN_DCL) | 744 | if (UDP->flags & FD_BROKEN_DCL) |
762 | return UTESTF(FD_DISK_CHANGED); | 745 | return test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags); |
763 | if ((fd_inb(FD_DIR) ^ UDP->flags) & 0x80) { | 746 | if ((fd_inb(FD_DIR) ^ UDP->flags) & 0x80) { |
764 | USETF(FD_VERIFY); /* verify write protection */ | 747 | set_bit(FD_VERIFY_BIT, &UDRS->flags); |
765 | if (UDRS->maxblock) { | 748 | /* verify write protection */ |
766 | /* mark it changed */ | 749 | |
767 | USETF(FD_DISK_CHANGED); | 750 | if (UDRS->maxblock) /* mark it changed */ |
768 | } | 751 | set_bit(FD_DISK_CHANGED_BIT, &UDRS->flags); |
769 | 752 | ||
770 | /* invalidate its geometry */ | 753 | /* invalidate its geometry */ |
771 | if (UDRS->keep_data >= 0) { | 754 | if (UDRS->keep_data >= 0) { |
772 | if ((UDP->flags & FTD_MSG) && | 755 | if ((UDP->flags & FTD_MSG) && |
773 | current_type[drive] != NULL) | 756 | current_type[drive] != NULL) |
774 | DPRINT("Disk type is undefined after " | 757 | DPRINT("Disk type is undefined after disk change\n"); |
775 | "disk change\n"); | ||
776 | current_type[drive] = NULL; | 758 | current_type[drive] = NULL; |
777 | floppy_sizes[TOMINOR(drive)] = MAX_DISK_SIZE << 1; | 759 | floppy_sizes[TOMINOR(drive)] = MAX_DISK_SIZE << 1; |
778 | } | 760 | } |
@@ -780,7 +762,7 @@ static int disk_change(int drive) | |||
780 | return 1; | 762 | return 1; |
781 | } else { | 763 | } else { |
782 | UDRS->last_checked = jiffies; | 764 | UDRS->last_checked = jiffies; |
783 | UCLEARF(FD_DISK_NEWCHANGE); | 765 | clear_bit(FD_DISK_NEWCHANGE_BIT, &UDRS->flags); |
784 | } | 766 | } |
785 | return 0; | 767 | return 0; |
786 | } | 768 | } |
@@ -790,6 +772,12 @@ static inline int is_selected(int dor, int unit) | |||
790 | return ((dor & (0x10 << unit)) && (dor & 3) == unit); | 772 | return ((dor & (0x10 << unit)) && (dor & 3) == unit); |
791 | } | 773 | } |
792 | 774 | ||
775 | static bool is_ready_state(int status) | ||
776 | { | ||
777 | int state = status & (STATUS_READY | STATUS_DIR | STATUS_DMA); | ||
778 | return state == STATUS_READY; | ||
779 | } | ||
780 | |||
793 | static int set_dor(int fdc, char mask, char data) | 781 | static int set_dor(int fdc, char mask, char data) |
794 | { | 782 | { |
795 | unsigned char unit; | 783 | unsigned char unit; |
@@ -806,11 +794,8 @@ static int set_dor(int fdc, char mask, char data) | |||
806 | unit = olddor & 0x3; | 794 | unit = olddor & 0x3; |
807 | if (is_selected(olddor, unit) && !is_selected(newdor, unit)) { | 795 | if (is_selected(olddor, unit) && !is_selected(newdor, unit)) { |
808 | drive = REVDRIVE(fdc, unit); | 796 | drive = REVDRIVE(fdc, unit); |
809 | #ifdef DCL_DEBUG | 797 | debug_dcl(UDP->flags, |
810 | if (UDP->flags & FD_DEBUG) { | 798 | "calling disk change from set_dor\n"); |
811 | DPRINT("calling disk change from set_dor\n"); | ||
812 | } | ||
813 | #endif | ||
814 | disk_change(drive); | 799 | disk_change(drive); |
815 | } | 800 | } |
816 | FDCS->dor = newdor; | 801 | FDCS->dor = newdor; |
@@ -834,8 +819,10 @@ static void twaddle(void) | |||
834 | DRS->select_date = jiffies; | 819 | DRS->select_date = jiffies; |
835 | } | 820 | } |
836 | 821 | ||
837 | /* reset all driver information about the current fdc. This is needed after | 822 | /* |
838 | * a reset, and after a raw command. */ | 823 | * Reset all driver information about the current fdc. |
824 | * This is needed after a reset, and after a raw command. | ||
825 | */ | ||
839 | static void reset_fdc_info(int mode) | 826 | static void reset_fdc_info(int mode) |
840 | { | 827 | { |
841 | int drive; | 828 | int drive; |
@@ -857,7 +844,7 @@ static void set_fdc(int drive) | |||
857 | current_drive = drive; | 844 | current_drive = drive; |
858 | } | 845 | } |
859 | if (fdc != 1 && fdc != 0) { | 846 | if (fdc != 1 && fdc != 0) { |
860 | printk("bad fdc value\n"); | 847 | pr_info("bad fdc value\n"); |
861 | return; | 848 | return; |
862 | } | 849 | } |
863 | set_dor(fdc, ~0, 8); | 850 | set_dor(fdc, ~0, 8); |
@@ -871,11 +858,10 @@ static void set_fdc(int drive) | |||
871 | } | 858 | } |
872 | 859 | ||
873 | /* locks the driver */ | 860 | /* locks the driver */ |
874 | static int _lock_fdc(int drive, int interruptible, int line) | 861 | static int _lock_fdc(int drive, bool interruptible, int line) |
875 | { | 862 | { |
876 | if (!usage_count) { | 863 | if (!usage_count) { |
877 | printk(KERN_ERR | 864 | pr_err("Trying to lock fdc while usage count=0 at line %d\n", |
878 | "Trying to lock fdc while usage count=0 at line %d\n", | ||
879 | line); | 865 | line); |
880 | return -1; | 866 | return -1; |
881 | } | 867 | } |
@@ -904,15 +890,13 @@ static int _lock_fdc(int drive, int interruptible, int line) | |||
904 | } | 890 | } |
905 | command_status = FD_COMMAND_NONE; | 891 | command_status = FD_COMMAND_NONE; |
906 | 892 | ||
907 | __reschedule_timeout(drive, "lock fdc", 0); | 893 | __reschedule_timeout(drive, "lock fdc"); |
908 | set_fdc(drive); | 894 | set_fdc(drive); |
909 | return 0; | 895 | return 0; |
910 | } | 896 | } |
911 | 897 | ||
912 | #define lock_fdc(drive,interruptible) _lock_fdc(drive,interruptible, __LINE__) | 898 | #define lock_fdc(drive, interruptible) \ |
913 | 899 | _lock_fdc(drive, interruptible, __LINE__) | |
914 | #define LOCK_FDC(drive,interruptible) \ | ||
915 | if (lock_fdc(drive,interruptible)) return -EINTR; | ||
916 | 900 | ||
917 | /* unlocks the driver */ | 901 | /* unlocks the driver */ |
918 | static inline void unlock_fdc(void) | 902 | static inline void unlock_fdc(void) |
@@ -924,7 +908,7 @@ static inline void unlock_fdc(void) | |||
924 | DPRINT("FDC access conflict!\n"); | 908 | DPRINT("FDC access conflict!\n"); |
925 | 909 | ||
926 | if (do_floppy) | 910 | if (do_floppy) |
927 | DPRINT("device interrupt still active at FDC release: %p!\n", | 911 | DPRINT("device interrupt still active at FDC release: %pf!\n", |
928 | do_floppy); | 912 | do_floppy); |
929 | command_status = FD_COMMAND_NONE; | 913 | command_status = FD_COMMAND_NONE; |
930 | spin_lock_irqsave(&floppy_lock, flags); | 914 | spin_lock_irqsave(&floppy_lock, flags); |
@@ -1003,7 +987,7 @@ static void empty(void) | |||
1003 | 987 | ||
1004 | static DECLARE_WORK(floppy_work, NULL); | 988 | static DECLARE_WORK(floppy_work, NULL); |
1005 | 989 | ||
1006 | static void schedule_bh(void (*handler) (void)) | 990 | static void schedule_bh(void (*handler)(void)) |
1007 | { | 991 | { |
1008 | PREPARE_WORK(&floppy_work, (work_func_t)handler); | 992 | PREPARE_WORK(&floppy_work, (work_func_t)handler); |
1009 | schedule_work(&floppy_work); | 993 | schedule_work(&floppy_work); |
@@ -1026,11 +1010,7 @@ static void cancel_activity(void) | |||
1026 | * transfer */ | 1010 | * transfer */ |
1027 | static void fd_watchdog(void) | 1011 | static void fd_watchdog(void) |
1028 | { | 1012 | { |
1029 | #ifdef DCL_DEBUG | 1013 | debug_dcl(DP->flags, "calling disk change from watchdog\n"); |
1030 | if (DP->flags & FD_DEBUG) { | ||
1031 | DPRINT("calling disk change from watchdog\n"); | ||
1032 | } | ||
1033 | #endif | ||
1034 | 1014 | ||
1035 | if (disk_change(current_drive)) { | 1015 | if (disk_change(current_drive)) { |
1036 | DPRINT("disk removed during i/o\n"); | 1016 | DPRINT("disk removed during i/o\n"); |
@@ -1039,7 +1019,7 @@ static void fd_watchdog(void) | |||
1039 | reset_fdc(); | 1019 | reset_fdc(); |
1040 | } else { | 1020 | } else { |
1041 | del_timer(&fd_timer); | 1021 | del_timer(&fd_timer); |
1042 | fd_timer.function = (timeout_fn) fd_watchdog; | 1022 | fd_timer.function = (timeout_fn)fd_watchdog; |
1043 | fd_timer.expires = jiffies + HZ / 10; | 1023 | fd_timer.expires = jiffies + HZ / 10; |
1044 | add_timer(&fd_timer); | 1024 | add_timer(&fd_timer); |
1045 | } | 1025 | } |
@@ -1105,25 +1085,23 @@ static void setup_DMA(void) | |||
1105 | { | 1085 | { |
1106 | unsigned long f; | 1086 | unsigned long f; |
1107 | 1087 | ||
1108 | #ifdef FLOPPY_SANITY_CHECK | ||
1109 | if (raw_cmd->length == 0) { | 1088 | if (raw_cmd->length == 0) { |
1110 | int i; | 1089 | int i; |
1111 | 1090 | ||
1112 | printk("zero dma transfer size:"); | 1091 | pr_info("zero dma transfer size:"); |
1113 | for (i = 0; i < raw_cmd->cmd_count; i++) | 1092 | for (i = 0; i < raw_cmd->cmd_count; i++) |
1114 | printk("%x,", raw_cmd->cmd[i]); | 1093 | pr_cont("%x,", raw_cmd->cmd[i]); |
1115 | printk("\n"); | 1094 | pr_cont("\n"); |
1116 | cont->done(0); | 1095 | cont->done(0); |
1117 | FDCS->reset = 1; | 1096 | FDCS->reset = 1; |
1118 | return; | 1097 | return; |
1119 | } | 1098 | } |
1120 | if (((unsigned long)raw_cmd->kernel_data) % 512) { | 1099 | if (((unsigned long)raw_cmd->kernel_data) % 512) { |
1121 | printk("non aligned address: %p\n", raw_cmd->kernel_data); | 1100 | pr_info("non aligned address: %p\n", raw_cmd->kernel_data); |
1122 | cont->done(0); | 1101 | cont->done(0); |
1123 | FDCS->reset = 1; | 1102 | FDCS->reset = 1; |
1124 | return; | 1103 | return; |
1125 | } | 1104 | } |
1126 | #endif | ||
1127 | f = claim_dma_lock(); | 1105 | f = claim_dma_lock(); |
1128 | fd_disable_dma(); | 1106 | fd_disable_dma(); |
1129 | #ifdef fd_dma_setup | 1107 | #ifdef fd_dma_setup |
@@ -1165,7 +1143,7 @@ static int wait_til_ready(void) | |||
1165 | if (status & STATUS_READY) | 1143 | if (status & STATUS_READY) |
1166 | return status; | 1144 | return status; |
1167 | } | 1145 | } |
1168 | if (!initialising) { | 1146 | if (initialized) { |
1169 | DPRINT("Getstatus times out (%x) on fdc %d\n", status, fdc); | 1147 | DPRINT("Getstatus times out (%x) on fdc %d\n", status, fdc); |
1170 | show_floppy(); | 1148 | show_floppy(); |
1171 | } | 1149 | } |
@@ -1176,22 +1154,21 @@ static int wait_til_ready(void) | |||
1176 | /* sends a command byte to the fdc */ | 1154 | /* sends a command byte to the fdc */ |
1177 | static int output_byte(char byte) | 1155 | static int output_byte(char byte) |
1178 | { | 1156 | { |
1179 | int status; | 1157 | int status = wait_til_ready(); |
1180 | 1158 | ||
1181 | if ((status = wait_til_ready()) < 0) | 1159 | if (status < 0) |
1182 | return -1; | 1160 | return -1; |
1183 | if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) { | 1161 | |
1162 | if (is_ready_state(status)) { | ||
1184 | fd_outb(byte, FD_DATA); | 1163 | fd_outb(byte, FD_DATA); |
1185 | #ifdef FLOPPY_SANITY_CHECK | ||
1186 | output_log[output_log_pos].data = byte; | 1164 | output_log[output_log_pos].data = byte; |
1187 | output_log[output_log_pos].status = status; | 1165 | output_log[output_log_pos].status = status; |
1188 | output_log[output_log_pos].jiffies = jiffies; | 1166 | output_log[output_log_pos].jiffies = jiffies; |
1189 | output_log_pos = (output_log_pos + 1) % OLOGSIZE; | 1167 | output_log_pos = (output_log_pos + 1) % OLOGSIZE; |
1190 | #endif | ||
1191 | return 0; | 1168 | return 0; |
1192 | } | 1169 | } |
1193 | FDCS->reset = 1; | 1170 | FDCS->reset = 1; |
1194 | if (!initialising) { | 1171 | if (initialized) { |
1195 | DPRINT("Unable to send byte %x to FDC. Fdc=%x Status=%x\n", | 1172 | DPRINT("Unable to send byte %x to FDC. Fdc=%x Status=%x\n", |
1196 | byte, fdc, status); | 1173 | byte, fdc, status); |
1197 | show_floppy(); | 1174 | show_floppy(); |
@@ -1199,8 +1176,6 @@ static int output_byte(char byte) | |||
1199 | return -1; | 1176 | return -1; |
1200 | } | 1177 | } |
1201 | 1178 | ||
1202 | #define LAST_OUT(x) if (output_byte(x)<0){ reset_fdc();return;} | ||
1203 | |||
1204 | /* gets the response from the fdc */ | 1179 | /* gets the response from the fdc */ |
1205 | static int result(void) | 1180 | static int result(void) |
1206 | { | 1181 | { |
@@ -1208,14 +1183,13 @@ static int result(void) | |||
1208 | int status = 0; | 1183 | int status = 0; |
1209 | 1184 | ||
1210 | for (i = 0; i < MAX_REPLIES; i++) { | 1185 | for (i = 0; i < MAX_REPLIES; i++) { |
1211 | if ((status = wait_til_ready()) < 0) | 1186 | status = wait_til_ready(); |
1187 | if (status < 0) | ||
1212 | break; | 1188 | break; |
1213 | status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA; | 1189 | status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA; |
1214 | if ((status & ~STATUS_BUSY) == STATUS_READY) { | 1190 | if ((status & ~STATUS_BUSY) == STATUS_READY) { |
1215 | #ifdef FLOPPY_SANITY_CHECK | ||
1216 | resultjiffies = jiffies; | 1191 | resultjiffies = jiffies; |
1217 | resultsize = i; | 1192 | resultsize = i; |
1218 | #endif | ||
1219 | return i; | 1193 | return i; |
1220 | } | 1194 | } |
1221 | if (status == (STATUS_DIR | STATUS_READY | STATUS_BUSY)) | 1195 | if (status == (STATUS_DIR | STATUS_READY | STATUS_BUSY)) |
@@ -1223,10 +1197,9 @@ static int result(void) | |||
1223 | else | 1197 | else |
1224 | break; | 1198 | break; |
1225 | } | 1199 | } |
1226 | if (!initialising) { | 1200 | if (initialized) { |
1227 | DPRINT | 1201 | DPRINT("get result error. Fdc=%d Last status=%x Read bytes=%d\n", |
1228 | ("get result error. Fdc=%d Last status=%x Read bytes=%d\n", | 1202 | fdc, status, i); |
1229 | fdc, status, i); | ||
1230 | show_floppy(); | 1203 | show_floppy(); |
1231 | } | 1204 | } |
1232 | FDCS->reset = 1; | 1205 | FDCS->reset = 1; |
@@ -1237,12 +1210,14 @@ static int result(void) | |||
1237 | /* does the fdc need more output? */ | 1210 | /* does the fdc need more output? */ |
1238 | static int need_more_output(void) | 1211 | static int need_more_output(void) |
1239 | { | 1212 | { |
1240 | int status; | 1213 | int status = wait_til_ready(); |
1241 | 1214 | ||
1242 | if ((status = wait_til_ready()) < 0) | 1215 | if (status < 0) |
1243 | return -1; | 1216 | return -1; |
1244 | if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) | 1217 | |
1218 | if (is_ready_state(status)) | ||
1245 | return MORE_OUTPUT; | 1219 | return MORE_OUTPUT; |
1220 | |||
1246 | return result(); | 1221 | return result(); |
1247 | } | 1222 | } |
1248 | 1223 | ||
@@ -1264,9 +1239,12 @@ static inline void perpendicular_mode(void) | |||
1264 | default: | 1239 | default: |
1265 | DPRINT("Invalid data rate for perpendicular mode!\n"); | 1240 | DPRINT("Invalid data rate for perpendicular mode!\n"); |
1266 | cont->done(0); | 1241 | cont->done(0); |
1267 | FDCS->reset = 1; /* convenient way to return to | 1242 | FDCS->reset = 1; |
1268 | * redo without to much hassle (deep | 1243 | /* |
1269 | * stack et al. */ | 1244 | * convenient way to return to |
1245 | * redo without too much hassle | ||
1246 | * (deep stack et al.) | ||
1247 | */ | ||
1270 | return; | 1248 | return; |
1271 | } | 1249 | } |
1272 | } else | 1250 | } else |
@@ -1366,9 +1344,9 @@ static void fdc_specify(void) | |||
1366 | 1344 | ||
1367 | /* Convert step rate from microseconds to milliseconds and 4 bits */ | 1345 | /* Convert step rate from microseconds to milliseconds and 4 bits */ |
1368 | srt = 16 - DIV_ROUND_UP(DP->srt * scale_dtr / 1000, NOMINAL_DTR); | 1346 | srt = 16 - DIV_ROUND_UP(DP->srt * scale_dtr / 1000, NOMINAL_DTR); |
1369 | if (slow_floppy) { | 1347 | if (slow_floppy) |
1370 | srt = srt / 4; | 1348 | srt = srt / 4; |
1371 | } | 1349 | |
1372 | SUPBOUND(srt, 0xf); | 1350 | SUPBOUND(srt, 0xf); |
1373 | INFBOUND(srt, 0); | 1351 | INFBOUND(srt, 0); |
1374 | 1352 | ||
@@ -1415,16 +1393,46 @@ static int fdc_dtr(void) | |||
1415 | * Pause 5 msec to avoid trouble. (Needs to be 2 jiffies) | 1393 | * Pause 5 msec to avoid trouble. (Needs to be 2 jiffies) |
1416 | */ | 1394 | */ |
1417 | FDCS->dtr = raw_cmd->rate & 3; | 1395 | FDCS->dtr = raw_cmd->rate & 3; |
1418 | return (fd_wait_for_completion(jiffies + 2UL * HZ / 100, | 1396 | return fd_wait_for_completion(jiffies + 2UL * HZ / 100, |
1419 | (timeout_fn) floppy_ready)); | 1397 | (timeout_fn)floppy_ready); |
1420 | } /* fdc_dtr */ | 1398 | } /* fdc_dtr */ |
1421 | 1399 | ||
1422 | static void tell_sector(void) | 1400 | static void tell_sector(void) |
1423 | { | 1401 | { |
1424 | printk(": track %d, head %d, sector %d, size %d", | 1402 | pr_cont(": track %d, head %d, sector %d, size %d", |
1425 | R_TRACK, R_HEAD, R_SECTOR, R_SIZECODE); | 1403 | R_TRACK, R_HEAD, R_SECTOR, R_SIZECODE); |
1426 | } /* tell_sector */ | 1404 | } /* tell_sector */ |
1427 | 1405 | ||
1406 | static void print_errors(void) | ||
1407 | { | ||
1408 | DPRINT(""); | ||
1409 | if (ST0 & ST0_ECE) { | ||
1410 | pr_cont("Recalibrate failed!"); | ||
1411 | } else if (ST2 & ST2_CRC) { | ||
1412 | pr_cont("data CRC error"); | ||
1413 | tell_sector(); | ||
1414 | } else if (ST1 & ST1_CRC) { | ||
1415 | pr_cont("CRC error"); | ||
1416 | tell_sector(); | ||
1417 | } else if ((ST1 & (ST1_MAM | ST1_ND)) || | ||
1418 | (ST2 & ST2_MAM)) { | ||
1419 | if (!probing) { | ||
1420 | pr_cont("sector not found"); | ||
1421 | tell_sector(); | ||
1422 | } else | ||
1423 | pr_cont("probe failed..."); | ||
1424 | } else if (ST2 & ST2_WC) { /* seek error */ | ||
1425 | pr_cont("wrong cylinder"); | ||
1426 | } else if (ST2 & ST2_BC) { /* cylinder marked as bad */ | ||
1427 | pr_cont("bad cylinder"); | ||
1428 | } else { | ||
1429 | pr_cont("unknown error. ST[0..2] are: 0x%x 0x%x 0x%x", | ||
1430 | ST0, ST1, ST2); | ||
1431 | tell_sector(); | ||
1432 | } | ||
1433 | pr_cont("\n"); | ||
1434 | } | ||
1435 | |||
1428 | /* | 1436 | /* |
1429 | * OK, this error interpreting routine is called after a | 1437 | * OK, this error interpreting routine is called after a |
1430 | * DMA read/write has succeeded | 1438 | * DMA read/write has succeeded |
@@ -1437,7 +1445,7 @@ static int interpret_errors(void) | |||
1437 | char bad; | 1445 | char bad; |
1438 | 1446 | ||
1439 | if (inr != 7) { | 1447 | if (inr != 7) { |
1440 | DPRINT("-- FDC reply error"); | 1448 | DPRINT("-- FDC reply error\n"); |
1441 | FDCS->reset = 1; | 1449 | FDCS->reset = 1; |
1442 | return 1; | 1450 | return 1; |
1443 | } | 1451 | } |
@@ -1450,43 +1458,17 @@ static int interpret_errors(void) | |||
1450 | bad = 1; | 1458 | bad = 1; |
1451 | if (ST1 & ST1_WP) { | 1459 | if (ST1 & ST1_WP) { |
1452 | DPRINT("Drive is write protected\n"); | 1460 | DPRINT("Drive is write protected\n"); |
1453 | CLEARF(FD_DISK_WRITABLE); | 1461 | clear_bit(FD_DISK_WRITABLE_BIT, &DRS->flags); |
1454 | cont->done(0); | 1462 | cont->done(0); |
1455 | bad = 2; | 1463 | bad = 2; |
1456 | } else if (ST1 & ST1_ND) { | 1464 | } else if (ST1 & ST1_ND) { |
1457 | SETF(FD_NEED_TWADDLE); | 1465 | set_bit(FD_NEED_TWADDLE_BIT, &DRS->flags); |
1458 | } else if (ST1 & ST1_OR) { | 1466 | } else if (ST1 & ST1_OR) { |
1459 | if (DP->flags & FTD_MSG) | 1467 | if (DP->flags & FTD_MSG) |
1460 | DPRINT("Over/Underrun - retrying\n"); | 1468 | DPRINT("Over/Underrun - retrying\n"); |
1461 | bad = 0; | 1469 | bad = 0; |
1462 | } else if (*errors >= DP->max_errors.reporting) { | 1470 | } else if (*errors >= DP->max_errors.reporting) { |
1463 | DPRINT(""); | 1471 | print_errors(); |
1464 | if (ST0 & ST0_ECE) { | ||
1465 | printk("Recalibrate failed!"); | ||
1466 | } else if (ST2 & ST2_CRC) { | ||
1467 | printk("data CRC error"); | ||
1468 | tell_sector(); | ||
1469 | } else if (ST1 & ST1_CRC) { | ||
1470 | printk("CRC error"); | ||
1471 | tell_sector(); | ||
1472 | } else if ((ST1 & (ST1_MAM | ST1_ND)) | ||
1473 | || (ST2 & ST2_MAM)) { | ||
1474 | if (!probing) { | ||
1475 | printk("sector not found"); | ||
1476 | tell_sector(); | ||
1477 | } else | ||
1478 | printk("probe failed..."); | ||
1479 | } else if (ST2 & ST2_WC) { /* seek error */ | ||
1480 | printk("wrong cylinder"); | ||
1481 | } else if (ST2 & ST2_BC) { /* cylinder marked as bad */ | ||
1482 | printk("bad cylinder"); | ||
1483 | } else { | ||
1484 | printk | ||
1485 | ("unknown error. ST[0..2] are: 0x%x 0x%x 0x%x", | ||
1486 | ST0, ST1, ST2); | ||
1487 | tell_sector(); | ||
1488 | } | ||
1489 | printk("\n"); | ||
1490 | } | 1472 | } |
1491 | if (ST2 & ST2_WC || ST2 & ST2_BC) | 1473 | if (ST2 & ST2_WC || ST2 & ST2_BC) |
1492 | /* wrong cylinder => recal */ | 1474 | /* wrong cylinder => recal */ |
@@ -1531,9 +1513,9 @@ static void setup_rw_floppy(void) | |||
1531 | */ | 1513 | */ |
1532 | if (time_after(ready_date, jiffies + DP->select_delay)) { | 1514 | if (time_after(ready_date, jiffies + DP->select_delay)) { |
1533 | ready_date -= DP->select_delay; | 1515 | ready_date -= DP->select_delay; |
1534 | function = (timeout_fn) floppy_start; | 1516 | function = (timeout_fn)floppy_start; |
1535 | } else | 1517 | } else |
1536 | function = (timeout_fn) setup_rw_floppy; | 1518 | function = (timeout_fn)setup_rw_floppy; |
1537 | 1519 | ||
1538 | /* wait until the floppy is spinning fast enough */ | 1520 | /* wait until the floppy is spinning fast enough */ |
1539 | if (fd_wait_for_completion(ready_date, function)) | 1521 | if (fd_wait_for_completion(ready_date, function)) |
@@ -1551,7 +1533,7 @@ static void setup_rw_floppy(void) | |||
1551 | for (i = 0; i < raw_cmd->cmd_count; i++) | 1533 | for (i = 0; i < raw_cmd->cmd_count; i++) |
1552 | r |= output_byte(raw_cmd->cmd[i]); | 1534 | r |= output_byte(raw_cmd->cmd[i]); |
1553 | 1535 | ||
1554 | debugt("rw_command: "); | 1536 | debugt(__func__, "rw_command"); |
1555 | 1537 | ||
1556 | if (r) { | 1538 | if (r) { |
1557 | cont->error(); | 1539 | cont->error(); |
@@ -1574,7 +1556,7 @@ static int blind_seek; | |||
1574 | */ | 1556 | */ |
1575 | static void seek_interrupt(void) | 1557 | static void seek_interrupt(void) |
1576 | { | 1558 | { |
1577 | debugt("seek interrupt:"); | 1559 | debugt(__func__, ""); |
1578 | if (inr != 2 || (ST0 & 0xF8) != 0x20) { | 1560 | if (inr != 2 || (ST0 & 0xF8) != 0x20) { |
1579 | DPRINT("seek failed\n"); | 1561 | DPRINT("seek failed\n"); |
1580 | DRS->track = NEED_2_RECAL; | 1562 | DRS->track = NEED_2_RECAL; |
@@ -1583,14 +1565,11 @@ static void seek_interrupt(void) | |||
1583 | return; | 1565 | return; |
1584 | } | 1566 | } |
1585 | if (DRS->track >= 0 && DRS->track != ST1 && !blind_seek) { | 1567 | if (DRS->track >= 0 && DRS->track != ST1 && !blind_seek) { |
1586 | #ifdef DCL_DEBUG | 1568 | debug_dcl(DP->flags, |
1587 | if (DP->flags & FD_DEBUG) { | 1569 | "clearing NEWCHANGE flag because of effective seek\n"); |
1588 | DPRINT | 1570 | debug_dcl(DP->flags, "jiffies=%lu\n", jiffies); |
1589 | ("clearing NEWCHANGE flag because of effective seek\n"); | 1571 | clear_bit(FD_DISK_NEWCHANGE_BIT, &DRS->flags); |
1590 | DPRINT("jiffies=%lu\n", jiffies); | 1572 | /* effective seek */ |
1591 | } | ||
1592 | #endif | ||
1593 | CLEARF(FD_DISK_NEWCHANGE); /* effective seek */ | ||
1594 | DRS->select_date = jiffies; | 1573 | DRS->select_date = jiffies; |
1595 | } | 1574 | } |
1596 | DRS->track = ST1; | 1575 | DRS->track = ST1; |
@@ -1599,26 +1578,23 @@ static void seek_interrupt(void) | |||
1599 | 1578 | ||
1600 | static void check_wp(void) | 1579 | static void check_wp(void) |
1601 | { | 1580 | { |
1602 | if (TESTF(FD_VERIFY)) { | 1581 | if (test_bit(FD_VERIFY_BIT, &DRS->flags)) { |
1603 | /* check write protection */ | 1582 | /* check write protection */ |
1604 | output_byte(FD_GETSTATUS); | 1583 | output_byte(FD_GETSTATUS); |
1605 | output_byte(UNIT(current_drive)); | 1584 | output_byte(UNIT(current_drive)); |
1606 | if (result() != 1) { | 1585 | if (result() != 1) { |
1607 | FDCS->reset = 1; | 1586 | FDCS->reset = 1; |
1608 | return; | 1587 | return; |
1609 | } | 1588 | } |
1610 | CLEARF(FD_VERIFY); | 1589 | clear_bit(FD_VERIFY_BIT, &DRS->flags); |
1611 | CLEARF(FD_NEED_TWADDLE); | 1590 | clear_bit(FD_NEED_TWADDLE_BIT, &DRS->flags); |
1612 | #ifdef DCL_DEBUG | 1591 | debug_dcl(DP->flags, |
1613 | if (DP->flags & FD_DEBUG) { | 1592 | "checking whether disk is write protected\n"); |
1614 | DPRINT("checking whether disk is write protected\n"); | 1593 | debug_dcl(DP->flags, "wp=%x\n", ST3 & 0x40); |
1615 | DPRINT("wp=%x\n", ST3 & 0x40); | ||
1616 | } | ||
1617 | #endif | ||
1618 | if (!(ST3 & 0x40)) | 1594 | if (!(ST3 & 0x40)) |
1619 | SETF(FD_DISK_WRITABLE); | 1595 | set_bit(FD_DISK_WRITABLE_BIT, &DRS->flags); |
1620 | else | 1596 | else |
1621 | CLEARF(FD_DISK_WRITABLE); | 1597 | clear_bit(FD_DISK_WRITABLE_BIT, &DRS->flags); |
1622 | } | 1598 | } |
1623 | } | 1599 | } |
1624 | 1600 | ||
@@ -1628,19 +1604,15 @@ static void seek_floppy(void) | |||
1628 | 1604 | ||
1629 | blind_seek = 0; | 1605 | blind_seek = 0; |
1630 | 1606 | ||
1631 | #ifdef DCL_DEBUG | 1607 | debug_dcl(DP->flags, "calling disk change from %s\n", __func__); |
1632 | if (DP->flags & FD_DEBUG) { | ||
1633 | DPRINT("calling disk change from seek\n"); | ||
1634 | } | ||
1635 | #endif | ||
1636 | 1608 | ||
1637 | if (!TESTF(FD_DISK_NEWCHANGE) && | 1609 | if (!test_bit(FD_DISK_NEWCHANGE_BIT, &DRS->flags) && |
1638 | disk_change(current_drive) && (raw_cmd->flags & FD_RAW_NEED_DISK)) { | 1610 | disk_change(current_drive) && (raw_cmd->flags & FD_RAW_NEED_DISK)) { |
1639 | /* the media changed flag should be cleared after the seek. | 1611 | /* the media changed flag should be cleared after the seek. |
1640 | * If it isn't, this means that there is really no disk in | 1612 | * If it isn't, this means that there is really no disk in |
1641 | * the drive. | 1613 | * the drive. |
1642 | */ | 1614 | */ |
1643 | SETF(FD_DISK_CHANGED); | 1615 | set_bit(FD_DISK_CHANGED_BIT, &DRS->flags); |
1644 | cont->done(0); | 1616 | cont->done(0); |
1645 | cont->redo(); | 1617 | cont->redo(); |
1646 | return; | 1618 | return; |
@@ -1648,7 +1620,7 @@ static void seek_floppy(void) | |||
1648 | if (DRS->track <= NEED_1_RECAL) { | 1620 | if (DRS->track <= NEED_1_RECAL) { |
1649 | recalibrate_floppy(); | 1621 | recalibrate_floppy(); |
1650 | return; | 1622 | return; |
1651 | } else if (TESTF(FD_DISK_NEWCHANGE) && | 1623 | } else if (test_bit(FD_DISK_NEWCHANGE_BIT, &DRS->flags) && |
1652 | (raw_cmd->flags & FD_RAW_NEED_DISK) && | 1624 | (raw_cmd->flags & FD_RAW_NEED_DISK) && |
1653 | (DRS->track <= NO_TRACK || DRS->track == raw_cmd->track)) { | 1625 | (DRS->track <= NO_TRACK || DRS->track == raw_cmd->track)) { |
1654 | /* we seek to clear the media-changed condition. Does anybody | 1626 | /* we seek to clear the media-changed condition. Does anybody |
@@ -1677,19 +1649,22 @@ static void seek_floppy(void) | |||
1677 | do_floppy = seek_interrupt; | 1649 | do_floppy = seek_interrupt; |
1678 | output_byte(FD_SEEK); | 1650 | output_byte(FD_SEEK); |
1679 | output_byte(UNIT(current_drive)); | 1651 | output_byte(UNIT(current_drive)); |
1680 | LAST_OUT(track); | 1652 | if (output_byte(track) < 0) { |
1681 | debugt("seek command:"); | 1653 | reset_fdc(); |
1654 | return; | ||
1655 | } | ||
1656 | debugt(__func__, ""); | ||
1682 | } | 1657 | } |
1683 | 1658 | ||
1684 | static void recal_interrupt(void) | 1659 | static void recal_interrupt(void) |
1685 | { | 1660 | { |
1686 | debugt("recal interrupt:"); | 1661 | debugt(__func__, ""); |
1687 | if (inr != 2) | 1662 | if (inr != 2) |
1688 | FDCS->reset = 1; | 1663 | FDCS->reset = 1; |
1689 | else if (ST0 & ST0_ECE) { | 1664 | else if (ST0 & ST0_ECE) { |
1690 | switch (DRS->track) { | 1665 | switch (DRS->track) { |
1691 | case NEED_1_RECAL: | 1666 | case NEED_1_RECAL: |
1692 | debugt("recal interrupt need 1 recal:"); | 1667 | debugt(__func__, "need 1 recal"); |
1693 | /* after a second recalibrate, we still haven't | 1668 | /* after a second recalibrate, we still haven't |
1694 | * reached track 0. Probably no drive. Raise an | 1669 | * reached track 0. Probably no drive. Raise an |
1695 | * error, as failing immediately might upset | 1670 | * error, as failing immediately might upset |
@@ -1698,25 +1673,21 @@ static void recal_interrupt(void) | |||
1698 | cont->redo(); | 1673 | cont->redo(); |
1699 | return; | 1674 | return; |
1700 | case NEED_2_RECAL: | 1675 | case NEED_2_RECAL: |
1701 | debugt("recal interrupt need 2 recal:"); | 1676 | debugt(__func__, "need 2 recal"); |
1702 | /* If we already did a recalibrate, | 1677 | /* If we already did a recalibrate, |
1703 | * and we are not at track 0, this | 1678 | * and we are not at track 0, this |
1704 | * means we have moved. (The only way | 1679 | * means we have moved. (The only way |
1705 | * not to move at recalibration is to | 1680 | * not to move at recalibration is to |
1706 | * be already at track 0.) Clear the | 1681 | * be already at track 0.) Clear the |
1707 | * new change flag */ | 1682 | * new change flag */ |
1708 | #ifdef DCL_DEBUG | 1683 | debug_dcl(DP->flags, |
1709 | if (DP->flags & FD_DEBUG) { | 1684 | "clearing NEWCHANGE flag because of second recalibrate\n"); |
1710 | DPRINT | ||
1711 | ("clearing NEWCHANGE flag because of second recalibrate\n"); | ||
1712 | } | ||
1713 | #endif | ||
1714 | 1685 | ||
1715 | CLEARF(FD_DISK_NEWCHANGE); | 1686 | clear_bit(FD_DISK_NEWCHANGE_BIT, &DRS->flags); |
1716 | DRS->select_date = jiffies; | 1687 | DRS->select_date = jiffies; |
1717 | /* fall through */ | 1688 | /* fall through */ |
1718 | default: | 1689 | default: |
1719 | debugt("recal interrupt default:"); | 1690 | debugt(__func__, "default"); |
1720 | /* Recalibrate moves the head by at | 1691 | /* Recalibrate moves the head by at |
1721 | * most 80 steps. If after one | 1692 | * most 80 steps. If after one |
1722 | * recalibrate we don't have reached | 1693 | * recalibrate we don't have reached |
@@ -1738,8 +1709,8 @@ static void print_result(char *message, int inr) | |||
1738 | DPRINT("%s ", message); | 1709 | DPRINT("%s ", message); |
1739 | if (inr >= 0) | 1710 | if (inr >= 0) |
1740 | for (i = 0; i < inr; i++) | 1711 | for (i = 0; i < inr; i++) |
1741 | printk("repl[%d]=%x ", i, reply_buffer[i]); | 1712 | pr_cont("repl[%d]=%x ", i, reply_buffer[i]); |
1742 | printk("\n"); | 1713 | pr_cont("\n"); |
1743 | } | 1714 | } |
1744 | 1715 | ||
1745 | /* interrupt handler. Note that this can be called externally on the Sparc */ | 1716 | /* interrupt handler. Note that this can be called externally on the Sparc */ |
@@ -1760,10 +1731,10 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id) | |||
1760 | do_floppy = NULL; | 1731 | do_floppy = NULL; |
1761 | if (fdc >= N_FDC || FDCS->address == -1) { | 1732 | if (fdc >= N_FDC || FDCS->address == -1) { |
1762 | /* we don't even know which FDC is the culprit */ | 1733 | /* we don't even know which FDC is the culprit */ |
1763 | printk("DOR0=%x\n", fdc_state[0].dor); | 1734 | pr_info("DOR0=%x\n", fdc_state[0].dor); |
1764 | printk("floppy interrupt on bizarre fdc %d\n", fdc); | 1735 | pr_info("floppy interrupt on bizarre fdc %d\n", fdc); |
1765 | printk("handler=%p\n", handler); | 1736 | pr_info("handler=%pf\n", handler); |
1766 | is_alive("bizarre fdc"); | 1737 | is_alive(__func__, "bizarre fdc"); |
1767 | return IRQ_NONE; | 1738 | return IRQ_NONE; |
1768 | } | 1739 | } |
1769 | 1740 | ||
@@ -1777,7 +1748,7 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id) | |||
1777 | * activity. | 1748 | * activity. |
1778 | */ | 1749 | */ |
1779 | 1750 | ||
1780 | do_print = !handler && print_unex && !initialising; | 1751 | do_print = !handler && print_unex && initialized; |
1781 | 1752 | ||
1782 | inr = result(); | 1753 | inr = result(); |
1783 | if (do_print) | 1754 | if (do_print) |
@@ -1790,15 +1761,15 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id) | |||
1790 | if (do_print) | 1761 | if (do_print) |
1791 | print_result("sensei", inr); | 1762 | print_result("sensei", inr); |
1792 | max_sensei--; | 1763 | max_sensei--; |
1793 | } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2 | 1764 | } while ((ST0 & 0x83) != UNIT(current_drive) && |
1794 | && max_sensei); | 1765 | inr == 2 && max_sensei); |
1795 | } | 1766 | } |
1796 | if (!handler) { | 1767 | if (!handler) { |
1797 | FDCS->reset = 1; | 1768 | FDCS->reset = 1; |
1798 | return IRQ_NONE; | 1769 | return IRQ_NONE; |
1799 | } | 1770 | } |
1800 | schedule_bh(handler); | 1771 | schedule_bh(handler); |
1801 | is_alive("normal interrupt end"); | 1772 | is_alive(__func__, "normal interrupt end"); |
1802 | 1773 | ||
1803 | /* FIXME! Was it really for us? */ | 1774 | /* FIXME! Was it really for us? */ |
1804 | return IRQ_HANDLED; | 1775 | return IRQ_HANDLED; |
@@ -1806,10 +1777,11 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id) | |||
1806 | 1777 | ||
1807 | static void recalibrate_floppy(void) | 1778 | static void recalibrate_floppy(void) |
1808 | { | 1779 | { |
1809 | debugt("recalibrate floppy:"); | 1780 | debugt(__func__, ""); |
1810 | do_floppy = recal_interrupt; | 1781 | do_floppy = recal_interrupt; |
1811 | output_byte(FD_RECALIBRATE); | 1782 | output_byte(FD_RECALIBRATE); |
1812 | LAST_OUT(UNIT(current_drive)); | 1783 | if (output_byte(UNIT(current_drive)) < 0) |
1784 | reset_fdc(); | ||
1813 | } | 1785 | } |
1814 | 1786 | ||
1815 | /* | 1787 | /* |
@@ -1817,10 +1789,10 @@ static void recalibrate_floppy(void) | |||
1817 | */ | 1789 | */ |
1818 | static void reset_interrupt(void) | 1790 | static void reset_interrupt(void) |
1819 | { | 1791 | { |
1820 | debugt("reset interrupt:"); | 1792 | debugt(__func__, ""); |
1821 | result(); /* get the status ready for set_fdc */ | 1793 | result(); /* get the status ready for set_fdc */ |
1822 | if (FDCS->reset) { | 1794 | if (FDCS->reset) { |
1823 | printk("reset set in interrupt, calling %p\n", cont->error); | 1795 | pr_info("reset set in interrupt, calling %pf\n", cont->error); |
1824 | cont->error(); /* a reset just after a reset. BAD! */ | 1796 | cont->error(); /* a reset just after a reset. BAD! */ |
1825 | } | 1797 | } |
1826 | cont->redo(); | 1798 | cont->redo(); |
@@ -1858,53 +1830,49 @@ static void show_floppy(void) | |||
1858 | { | 1830 | { |
1859 | int i; | 1831 | int i; |
1860 | 1832 | ||
1861 | printk("\n"); | 1833 | pr_info("\n"); |
1862 | printk("floppy driver state\n"); | 1834 | pr_info("floppy driver state\n"); |
1863 | printk("-------------------\n"); | 1835 | pr_info("-------------------\n"); |
1864 | printk("now=%lu last interrupt=%lu diff=%lu last called handler=%p\n", | 1836 | pr_info("now=%lu last interrupt=%lu diff=%lu last called handler=%pf\n", |
1865 | jiffies, interruptjiffies, jiffies - interruptjiffies, | 1837 | jiffies, interruptjiffies, jiffies - interruptjiffies, |
1866 | lasthandler); | 1838 | lasthandler); |
1867 | 1839 | ||
1868 | #ifdef FLOPPY_SANITY_CHECK | 1840 | pr_info("timeout_message=%s\n", timeout_message); |
1869 | printk("timeout_message=%s\n", timeout_message); | 1841 | pr_info("last output bytes:\n"); |
1870 | printk("last output bytes:\n"); | ||
1871 | for (i = 0; i < OLOGSIZE; i++) | 1842 | for (i = 0; i < OLOGSIZE; i++) |
1872 | printk("%2x %2x %lu\n", | 1843 | pr_info("%2x %2x %lu\n", |
1873 | output_log[(i + output_log_pos) % OLOGSIZE].data, | 1844 | output_log[(i + output_log_pos) % OLOGSIZE].data, |
1874 | output_log[(i + output_log_pos) % OLOGSIZE].status, | 1845 | output_log[(i + output_log_pos) % OLOGSIZE].status, |
1875 | output_log[(i + output_log_pos) % OLOGSIZE].jiffies); | 1846 | output_log[(i + output_log_pos) % OLOGSIZE].jiffies); |
1876 | printk("last result at %lu\n", resultjiffies); | 1847 | pr_info("last result at %lu\n", resultjiffies); |
1877 | printk("last redo_fd_request at %lu\n", lastredo); | 1848 | pr_info("last redo_fd_request at %lu\n", lastredo); |
1878 | for (i = 0; i < resultsize; i++) { | 1849 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1, |
1879 | printk("%2x ", reply_buffer[i]); | 1850 | reply_buffer, resultsize, true); |
1880 | } | 1851 | |
1881 | printk("\n"); | 1852 | pr_info("status=%x\n", fd_inb(FD_STATUS)); |
1882 | #endif | 1853 | pr_info("fdc_busy=%lu\n", fdc_busy); |
1883 | |||
1884 | printk("status=%x\n", fd_inb(FD_STATUS)); | ||
1885 | printk("fdc_busy=%lu\n", fdc_busy); | ||
1886 | if (do_floppy) | 1854 | if (do_floppy) |
1887 | printk("do_floppy=%p\n", do_floppy); | 1855 | pr_info("do_floppy=%pf\n", do_floppy); |
1888 | if (work_pending(&floppy_work)) | 1856 | if (work_pending(&floppy_work)) |
1889 | printk("floppy_work.func=%p\n", floppy_work.func); | 1857 | pr_info("floppy_work.func=%pf\n", floppy_work.func); |
1890 | if (timer_pending(&fd_timer)) | 1858 | if (timer_pending(&fd_timer)) |
1891 | printk("fd_timer.function=%p\n", fd_timer.function); | 1859 | pr_info("fd_timer.function=%pf\n", fd_timer.function); |
1892 | if (timer_pending(&fd_timeout)) { | 1860 | if (timer_pending(&fd_timeout)) { |
1893 | printk("timer_function=%p\n", fd_timeout.function); | 1861 | pr_info("timer_function=%pf\n", fd_timeout.function); |
1894 | printk("expires=%lu\n", fd_timeout.expires - jiffies); | 1862 | pr_info("expires=%lu\n", fd_timeout.expires - jiffies); |
1895 | printk("now=%lu\n", jiffies); | 1863 | pr_info("now=%lu\n", jiffies); |
1896 | } | 1864 | } |
1897 | printk("cont=%p\n", cont); | 1865 | pr_info("cont=%p\n", cont); |
1898 | printk("current_req=%p\n", current_req); | 1866 | pr_info("current_req=%p\n", current_req); |
1899 | printk("command_status=%d\n", command_status); | 1867 | pr_info("command_status=%d\n", command_status); |
1900 | printk("\n"); | 1868 | pr_info("\n"); |
1901 | } | 1869 | } |
1902 | 1870 | ||
1903 | static void floppy_shutdown(unsigned long data) | 1871 | static void floppy_shutdown(unsigned long data) |
1904 | { | 1872 | { |
1905 | unsigned long flags; | 1873 | unsigned long flags; |
1906 | 1874 | ||
1907 | if (!initialising) | 1875 | if (initialized) |
1908 | show_floppy(); | 1876 | show_floppy(); |
1909 | cancel_activity(); | 1877 | cancel_activity(); |
1910 | 1878 | ||
@@ -1916,17 +1884,17 @@ static void floppy_shutdown(unsigned long data) | |||
1916 | 1884 | ||
1917 | /* avoid dma going to a random drive after shutdown */ | 1885 | /* avoid dma going to a random drive after shutdown */ |
1918 | 1886 | ||
1919 | if (!initialising) | 1887 | if (initialized) |
1920 | DPRINT("floppy timeout called\n"); | 1888 | DPRINT("floppy timeout called\n"); |
1921 | FDCS->reset = 1; | 1889 | FDCS->reset = 1; |
1922 | if (cont) { | 1890 | if (cont) { |
1923 | cont->done(0); | 1891 | cont->done(0); |
1924 | cont->redo(); /* this will recall reset when needed */ | 1892 | cont->redo(); /* this will recall reset when needed */ |
1925 | } else { | 1893 | } else { |
1926 | printk("no cont in shutdown!\n"); | 1894 | pr_info("no cont in shutdown!\n"); |
1927 | process_fd_request(); | 1895 | process_fd_request(); |
1928 | } | 1896 | } |
1929 | is_alive("floppy shutdown"); | 1897 | is_alive(__func__, ""); |
1930 | } | 1898 | } |
1931 | 1899 | ||
1932 | /* start motor, check media-changed condition and write protection */ | 1900 | /* start motor, check media-changed condition and write protection */ |
@@ -1954,27 +1922,26 @@ static int start_motor(void (*function)(void)) | |||
1954 | set_dor(fdc, mask, data); | 1922 | set_dor(fdc, mask, data); |
1955 | 1923 | ||
1956 | /* wait_for_completion also schedules reset if needed. */ | 1924 | /* wait_for_completion also schedules reset if needed. */ |
1957 | return (fd_wait_for_completion(DRS->select_date + DP->select_delay, | 1925 | return fd_wait_for_completion(DRS->select_date + DP->select_delay, |
1958 | (timeout_fn) function)); | 1926 | (timeout_fn)function); |
1959 | } | 1927 | } |
1960 | 1928 | ||
1961 | static void floppy_ready(void) | 1929 | static void floppy_ready(void) |
1962 | { | 1930 | { |
1963 | CHECK_RESET; | 1931 | if (FDCS->reset) { |
1932 | reset_fdc(); | ||
1933 | return; | ||
1934 | } | ||
1964 | if (start_motor(floppy_ready)) | 1935 | if (start_motor(floppy_ready)) |
1965 | return; | 1936 | return; |
1966 | if (fdc_dtr()) | 1937 | if (fdc_dtr()) |
1967 | return; | 1938 | return; |
1968 | 1939 | ||
1969 | #ifdef DCL_DEBUG | 1940 | debug_dcl(DP->flags, "calling disk change from floppy_ready\n"); |
1970 | if (DP->flags & FD_DEBUG) { | ||
1971 | DPRINT("calling disk change from floppy_ready\n"); | ||
1972 | } | ||
1973 | #endif | ||
1974 | if (!(raw_cmd->flags & FD_RAW_NO_MOTOR) && | 1941 | if (!(raw_cmd->flags & FD_RAW_NO_MOTOR) && |
1975 | disk_change(current_drive) && !DP->select_delay) | 1942 | disk_change(current_drive) && !DP->select_delay) |
1976 | twaddle(); /* this clears the dcl on certain drive/controller | 1943 | twaddle(); /* this clears the dcl on certain |
1977 | * combinations */ | 1944 | * drive/controller combinations */ |
1978 | 1945 | ||
1979 | #ifdef fd_chose_dma_mode | 1946 | #ifdef fd_chose_dma_mode |
1980 | if ((raw_cmd->flags & FD_RAW_READ) || (raw_cmd->flags & FD_RAW_WRITE)) { | 1947 | if ((raw_cmd->flags & FD_RAW_READ) || (raw_cmd->flags & FD_RAW_WRITE)) { |
@@ -1998,15 +1965,11 @@ static void floppy_ready(void) | |||
1998 | 1965 | ||
1999 | static void floppy_start(void) | 1966 | static void floppy_start(void) |
2000 | { | 1967 | { |
2001 | reschedule_timeout(current_reqD, "floppy start", 0); | 1968 | reschedule_timeout(current_reqD, "floppy start"); |
2002 | 1969 | ||
2003 | scandrives(); | 1970 | scandrives(); |
2004 | #ifdef DCL_DEBUG | 1971 | debug_dcl(DP->flags, "setting NEWCHANGE in floppy_start\n"); |
2005 | if (DP->flags & FD_DEBUG) { | 1972 | set_bit(FD_DISK_NEWCHANGE_BIT, &DRS->flags); |
2006 | DPRINT("setting NEWCHANGE in floppy_start\n"); | ||
2007 | } | ||
2008 | #endif | ||
2009 | SETF(FD_DISK_NEWCHANGE); | ||
2010 | floppy_ready(); | 1973 | floppy_ready(); |
2011 | } | 1974 | } |
2012 | 1975 | ||
@@ -2026,7 +1989,7 @@ static void floppy_start(void) | |||
2026 | 1989 | ||
2027 | static void do_wakeup(void) | 1990 | static void do_wakeup(void) |
2028 | { | 1991 | { |
2029 | reschedule_timeout(MAXTIMEOUT, "do wakeup", 0); | 1992 | reschedule_timeout(MAXTIMEOUT, "do wakeup"); |
2030 | cont = NULL; | 1993 | cont = NULL; |
2031 | command_status += 2; | 1994 | command_status += 2; |
2032 | wake_up(&command_done); | 1995 | wake_up(&command_done); |
@@ -2046,7 +2009,7 @@ static struct cont_t intr_cont = { | |||
2046 | .done = (done_f)empty | 2009 | .done = (done_f)empty |
2047 | }; | 2010 | }; |
2048 | 2011 | ||
2049 | static int wait_til_done(void (*handler)(void), int interruptible) | 2012 | static int wait_til_done(void (*handler)(void), bool interruptible) |
2050 | { | 2013 | { |
2051 | int ret; | 2014 | int ret; |
2052 | 2015 | ||
@@ -2064,7 +2027,7 @@ static int wait_til_done(void (*handler)(void), int interruptible) | |||
2064 | if (command_status >= 2 || !NO_SIGNAL) | 2027 | if (command_status >= 2 || !NO_SIGNAL) |
2065 | break; | 2028 | break; |
2066 | 2029 | ||
2067 | is_alive("wait_til_done"); | 2030 | is_alive(__func__, ""); |
2068 | schedule(); | 2031 | schedule(); |
2069 | } | 2032 | } |
2070 | 2033 | ||
@@ -2180,9 +2143,9 @@ static void format_interrupt(void) | |||
2180 | cont->redo(); | 2143 | cont->redo(); |
2181 | } | 2144 | } |
2182 | 2145 | ||
2183 | #define CODE2SIZE (ssize = ((1 << SIZECODE) + 3) >> 2) | 2146 | #define FM_MODE(x, y) ((y) & ~(((x)->rate & 0x80) >> 1)) |
2184 | #define FM_MODE(x,y) ((y) & ~(((x)->rate & 0x80) >>1)) | ||
2185 | #define CT(x) ((x) | 0xc0) | 2147 | #define CT(x) ((x) | 0xc0) |
2148 | |||
2186 | static void setup_format_params(int track) | 2149 | static void setup_format_params(int track) |
2187 | { | 2150 | { |
2188 | int n; | 2151 | int n; |
@@ -2197,8 +2160,8 @@ static void setup_format_params(int track) | |||
2197 | raw_cmd = &default_raw_cmd; | 2160 | raw_cmd = &default_raw_cmd; |
2198 | raw_cmd->track = track; | 2161 | raw_cmd->track = track; |
2199 | 2162 | ||
2200 | raw_cmd->flags = FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN | | 2163 | raw_cmd->flags = (FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN | |
2201 | FD_RAW_NEED_DISK | FD_RAW_NEED_SEEK; | 2164 | FD_RAW_NEED_DISK | FD_RAW_NEED_SEEK); |
2202 | raw_cmd->rate = _floppy->rate & 0x43; | 2165 | raw_cmd->rate = _floppy->rate & 0x43; |
2203 | raw_cmd->cmd_count = NR_F; | 2166 | raw_cmd->cmd_count = NR_F; |
2204 | COMMAND = FM_MODE(_floppy, FD_FORMAT); | 2167 | COMMAND = FM_MODE(_floppy, FD_FORMAT); |
@@ -2257,7 +2220,7 @@ static void redo_format(void) | |||
2257 | buffer_track = -1; | 2220 | buffer_track = -1; |
2258 | setup_format_params(format_req.track << STRETCH(_floppy)); | 2221 | setup_format_params(format_req.track << STRETCH(_floppy)); |
2259 | floppy_start(); | 2222 | floppy_start(); |
2260 | debugt("queue format request"); | 2223 | debugt(__func__, "queue format request"); |
2261 | } | 2224 | } |
2262 | 2225 | ||
2263 | static struct cont_t format_cont = { | 2226 | static struct cont_t format_cont = { |
@@ -2271,7 +2234,9 @@ static int do_format(int drive, struct format_descr *tmp_format_req) | |||
2271 | { | 2234 | { |
2272 | int ret; | 2235 | int ret; |
2273 | 2236 | ||
2274 | LOCK_FDC(drive, 1); | 2237 | if (lock_fdc(drive, true)) |
2238 | return -EINTR; | ||
2239 | |||
2275 | set_floppy(drive); | 2240 | set_floppy(drive); |
2276 | if (!_floppy || | 2241 | if (!_floppy || |
2277 | _floppy->track > DP->tracks || | 2242 | _floppy->track > DP->tracks || |
@@ -2286,7 +2251,9 @@ static int do_format(int drive, struct format_descr *tmp_format_req) | |||
2286 | format_errors = 0; | 2251 | format_errors = 0; |
2287 | cont = &format_cont; | 2252 | cont = &format_cont; |
2288 | errors = &format_errors; | 2253 | errors = &format_errors; |
2289 | IWAIT(redo_format); | 2254 | ret = wait_til_done(redo_format, true); |
2255 | if (ret == -EINTR) | ||
2256 | return -EINTR; | ||
2290 | process_fd_request(); | 2257 | process_fd_request(); |
2291 | return ret; | 2258 | return ret; |
2292 | } | 2259 | } |
@@ -2320,12 +2287,14 @@ static void request_done(int uptodate) | |||
2320 | struct request *req = current_req; | 2287 | struct request *req = current_req; |
2321 | unsigned long flags; | 2288 | unsigned long flags; |
2322 | int block; | 2289 | int block; |
2290 | char msg[sizeof("request done ") + sizeof(int) * 3]; | ||
2323 | 2291 | ||
2324 | probing = 0; | 2292 | probing = 0; |
2325 | reschedule_timeout(MAXTIMEOUT, "request done %d", uptodate); | 2293 | snprintf(msg, sizeof(msg), "request done %d", uptodate); |
2294 | reschedule_timeout(MAXTIMEOUT, msg); | ||
2326 | 2295 | ||
2327 | if (!req) { | 2296 | if (!req) { |
2328 | printk("floppy.c: no request in request_done\n"); | 2297 | pr_info("floppy.c: no request in request_done\n"); |
2329 | return; | 2298 | return; |
2330 | } | 2299 | } |
2331 | 2300 | ||
@@ -2377,7 +2346,7 @@ static void rw_interrupt(void) | |||
2377 | DRS->first_read_date = jiffies; | 2346 | DRS->first_read_date = jiffies; |
2378 | 2347 | ||
2379 | nr_sectors = 0; | 2348 | nr_sectors = 0; |
2380 | CODE2SIZE; | 2349 | ssize = DIV_ROUND_UP(1 << SIZECODE, 4); |
2381 | 2350 | ||
2382 | if (ST1 & ST1_EOC) | 2351 | if (ST1 & ST1_EOC) |
2383 | eoc = 1; | 2352 | eoc = 1; |
@@ -2393,20 +2362,18 @@ static void rw_interrupt(void) | |||
2393 | R_HEAD - HEAD) * SECT_PER_TRACK + | 2362 | R_HEAD - HEAD) * SECT_PER_TRACK + |
2394 | R_SECTOR - SECTOR + eoc) << SIZECODE >> 2; | 2363 | R_SECTOR - SECTOR + eoc) << SIZECODE >> 2; |
2395 | 2364 | ||
2396 | #ifdef FLOPPY_SANITY_CHECK | ||
2397 | if (nr_sectors / ssize > | 2365 | if (nr_sectors / ssize > |
2398 | DIV_ROUND_UP(in_sector_offset + current_count_sectors, ssize)) { | 2366 | DIV_ROUND_UP(in_sector_offset + current_count_sectors, ssize)) { |
2399 | DPRINT("long rw: %x instead of %lx\n", | 2367 | DPRINT("long rw: %x instead of %lx\n", |
2400 | nr_sectors, current_count_sectors); | 2368 | nr_sectors, current_count_sectors); |
2401 | printk("rs=%d s=%d\n", R_SECTOR, SECTOR); | 2369 | pr_info("rs=%d s=%d\n", R_SECTOR, SECTOR); |
2402 | printk("rh=%d h=%d\n", R_HEAD, HEAD); | 2370 | pr_info("rh=%d h=%d\n", R_HEAD, HEAD); |
2403 | printk("rt=%d t=%d\n", R_TRACK, TRACK); | 2371 | pr_info("rt=%d t=%d\n", R_TRACK, TRACK); |
2404 | printk("heads=%d eoc=%d\n", heads, eoc); | 2372 | pr_info("heads=%d eoc=%d\n", heads, eoc); |
2405 | printk("spt=%d st=%d ss=%d\n", SECT_PER_TRACK, | 2373 | pr_info("spt=%d st=%d ss=%d\n", |
2406 | fsector_t, ssize); | 2374 | SECT_PER_TRACK, fsector_t, ssize); |
2407 | printk("in_sector_offset=%d\n", in_sector_offset); | 2375 | pr_info("in_sector_offset=%d\n", in_sector_offset); |
2408 | } | 2376 | } |
2409 | #endif | ||
2410 | 2377 | ||
2411 | nr_sectors -= in_sector_offset; | 2378 | nr_sectors -= in_sector_offset; |
2412 | INFBOUND(nr_sectors, 0); | 2379 | INFBOUND(nr_sectors, 0); |
@@ -2511,19 +2478,17 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2511 | blk_rq_sectors(current_req)); | 2478 | blk_rq_sectors(current_req)); |
2512 | 2479 | ||
2513 | remaining = current_count_sectors << 9; | 2480 | remaining = current_count_sectors << 9; |
2514 | #ifdef FLOPPY_SANITY_CHECK | ||
2515 | if (remaining > blk_rq_bytes(current_req) && CT(COMMAND) == FD_WRITE) { | 2481 | if (remaining > blk_rq_bytes(current_req) && CT(COMMAND) == FD_WRITE) { |
2516 | DPRINT("in copy buffer\n"); | 2482 | DPRINT("in copy buffer\n"); |
2517 | printk("current_count_sectors=%ld\n", current_count_sectors); | 2483 | pr_info("current_count_sectors=%ld\n", current_count_sectors); |
2518 | printk("remaining=%d\n", remaining >> 9); | 2484 | pr_info("remaining=%d\n", remaining >> 9); |
2519 | printk("current_req->nr_sectors=%u\n", | 2485 | pr_info("current_req->nr_sectors=%u\n", |
2520 | blk_rq_sectors(current_req)); | 2486 | blk_rq_sectors(current_req)); |
2521 | printk("current_req->current_nr_sectors=%u\n", | 2487 | pr_info("current_req->current_nr_sectors=%u\n", |
2522 | blk_rq_cur_sectors(current_req)); | 2488 | blk_rq_cur_sectors(current_req)); |
2523 | printk("max_sector=%d\n", max_sector); | 2489 | pr_info("max_sector=%d\n", max_sector); |
2524 | printk("ssize=%d\n", ssize); | 2490 | pr_info("ssize=%d\n", ssize); |
2525 | } | 2491 | } |
2526 | #endif | ||
2527 | 2492 | ||
2528 | buffer_max = max(max_sector, buffer_max); | 2493 | buffer_max = max(max_sector, buffer_max); |
2529 | 2494 | ||
@@ -2539,26 +2504,24 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2539 | SUPBOUND(size, remaining); | 2504 | SUPBOUND(size, remaining); |
2540 | 2505 | ||
2541 | buffer = page_address(bv->bv_page) + bv->bv_offset; | 2506 | buffer = page_address(bv->bv_page) + bv->bv_offset; |
2542 | #ifdef FLOPPY_SANITY_CHECK | ||
2543 | if (dma_buffer + size > | 2507 | if (dma_buffer + size > |
2544 | floppy_track_buffer + (max_buffer_sectors << 10) || | 2508 | floppy_track_buffer + (max_buffer_sectors << 10) || |
2545 | dma_buffer < floppy_track_buffer) { | 2509 | dma_buffer < floppy_track_buffer) { |
2546 | DPRINT("buffer overrun in copy buffer %d\n", | 2510 | DPRINT("buffer overrun in copy buffer %d\n", |
2547 | (int)((floppy_track_buffer - | 2511 | (int)((floppy_track_buffer - dma_buffer) >> 9)); |
2548 | dma_buffer) >> 9)); | 2512 | pr_info("fsector_t=%d buffer_min=%d\n", |
2549 | printk("fsector_t=%d buffer_min=%d\n", | 2513 | fsector_t, buffer_min); |
2550 | fsector_t, buffer_min); | 2514 | pr_info("current_count_sectors=%ld\n", |
2551 | printk("current_count_sectors=%ld\n", | 2515 | current_count_sectors); |
2552 | current_count_sectors); | ||
2553 | if (CT(COMMAND) == FD_READ) | 2516 | if (CT(COMMAND) == FD_READ) |
2554 | printk("read\n"); | 2517 | pr_info("read\n"); |
2555 | if (CT(COMMAND) == FD_WRITE) | 2518 | if (CT(COMMAND) == FD_WRITE) |
2556 | printk("write\n"); | 2519 | pr_info("write\n"); |
2557 | break; | 2520 | break; |
2558 | } | 2521 | } |
2559 | if (((unsigned long)buffer) % 512) | 2522 | if (((unsigned long)buffer) % 512) |
2560 | DPRINT("%p buffer not aligned\n", buffer); | 2523 | DPRINT("%p buffer not aligned\n", buffer); |
2561 | #endif | 2524 | |
2562 | if (CT(COMMAND) == FD_READ) | 2525 | if (CT(COMMAND) == FD_READ) |
2563 | memcpy(buffer, dma_buffer, size); | 2526 | memcpy(buffer, dma_buffer, size); |
2564 | else | 2527 | else |
@@ -2567,13 +2530,11 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2567 | remaining -= size; | 2530 | remaining -= size; |
2568 | dma_buffer += size; | 2531 | dma_buffer += size; |
2569 | } | 2532 | } |
2570 | #ifdef FLOPPY_SANITY_CHECK | ||
2571 | if (remaining) { | 2533 | if (remaining) { |
2572 | if (remaining > 0) | 2534 | if (remaining > 0) |
2573 | max_sector -= remaining >> 9; | 2535 | max_sector -= remaining >> 9; |
2574 | DPRINT("weirdness: remaining %d\n", remaining >> 9); | 2536 | DPRINT("weirdness: remaining %d\n", remaining >> 9); |
2575 | } | 2537 | } |
2576 | #endif | ||
2577 | } | 2538 | } |
2578 | 2539 | ||
2579 | /* work around a bug in pseudo DMA | 2540 | /* work around a bug in pseudo DMA |
@@ -2593,15 +2554,14 @@ static void virtualdmabug_workaround(void) | |||
2593 | 2554 | ||
2594 | hard_sectors = raw_cmd->length >> (7 + SIZECODE); | 2555 | hard_sectors = raw_cmd->length >> (7 + SIZECODE); |
2595 | end_sector = SECTOR + hard_sectors - 1; | 2556 | end_sector = SECTOR + hard_sectors - 1; |
2596 | #ifdef FLOPPY_SANITY_CHECK | ||
2597 | if (end_sector > SECT_PER_TRACK) { | 2557 | if (end_sector > SECT_PER_TRACK) { |
2598 | printk("too many sectors %d > %d\n", | 2558 | pr_info("too many sectors %d > %d\n", |
2599 | end_sector, SECT_PER_TRACK); | 2559 | end_sector, SECT_PER_TRACK); |
2600 | return; | 2560 | return; |
2601 | } | 2561 | } |
2602 | #endif | 2562 | SECT_PER_TRACK = end_sector; |
2603 | SECT_PER_TRACK = end_sector; /* make sure SECT_PER_TRACK points | 2563 | /* make sure SECT_PER_TRACK |
2604 | * to end of transfer */ | 2564 | * points to end of transfer */ |
2605 | } | 2565 | } |
2606 | } | 2566 | } |
2607 | 2567 | ||
@@ -2624,7 +2584,7 @@ static int make_raw_rw_request(void) | |||
2624 | int ssize; | 2584 | int ssize; |
2625 | 2585 | ||
2626 | if (max_buffer_sectors == 0) { | 2586 | if (max_buffer_sectors == 0) { |
2627 | printk("VFS: Block I/O scheduled on unopened device\n"); | 2587 | pr_info("VFS: Block I/O scheduled on unopened device\n"); |
2628 | return 0; | 2588 | return 0; |
2629 | } | 2589 | } |
2630 | 2590 | ||
@@ -2641,7 +2601,7 @@ static int make_raw_rw_request(void) | |||
2641 | raw_cmd->flags |= FD_RAW_WRITE; | 2601 | raw_cmd->flags |= FD_RAW_WRITE; |
2642 | COMMAND = FM_MODE(_floppy, FD_WRITE); | 2602 | COMMAND = FM_MODE(_floppy, FD_WRITE); |
2643 | } else { | 2603 | } else { |
2644 | DPRINT("make_raw_rw_request: unknown command\n"); | 2604 | DPRINT("%s: unknown command\n", __func__); |
2645 | return 0; | 2605 | return 0; |
2646 | } | 2606 | } |
2647 | 2607 | ||
@@ -2659,7 +2619,8 @@ static int make_raw_rw_request(void) | |||
2659 | HEAD = fsector_t / _floppy->sect; | 2619 | HEAD = fsector_t / _floppy->sect; |
2660 | 2620 | ||
2661 | if (((_floppy->stretch & (FD_SWAPSIDES | FD_SECTBASEMASK)) || | 2621 | if (((_floppy->stretch & (FD_SWAPSIDES | FD_SECTBASEMASK)) || |
2662 | TESTF(FD_NEED_TWADDLE)) && fsector_t < _floppy->sect) | 2622 | test_bit(FD_NEED_TWADDLE_BIT, &DRS->flags)) && |
2623 | fsector_t < _floppy->sect) | ||
2663 | max_sector = _floppy->sect; | 2624 | max_sector = _floppy->sect; |
2664 | 2625 | ||
2665 | /* 2M disks have phantom sectors on the first track */ | 2626 | /* 2M disks have phantom sectors on the first track */ |
@@ -2685,7 +2646,7 @@ static int make_raw_rw_request(void) | |||
2685 | raw_cmd->track = TRACK << STRETCH(_floppy); | 2646 | raw_cmd->track = TRACK << STRETCH(_floppy); |
2686 | DR_SELECT = UNIT(current_drive) + PH_HEAD(_floppy, HEAD); | 2647 | DR_SELECT = UNIT(current_drive) + PH_HEAD(_floppy, HEAD); |
2687 | GAP = _floppy->gap; | 2648 | GAP = _floppy->gap; |
2688 | CODE2SIZE; | 2649 | ssize = DIV_ROUND_UP(1 << SIZECODE, 4); |
2689 | SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE; | 2650 | SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE; |
2690 | SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + | 2651 | SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + |
2691 | FD_SECTBASE(_floppy); | 2652 | FD_SECTBASE(_floppy); |
@@ -2730,8 +2691,10 @@ static int make_raw_rw_request(void) | |||
2730 | } | 2691 | } |
2731 | } else if (in_sector_offset || blk_rq_sectors(current_req) < ssize) { | 2692 | } else if (in_sector_offset || blk_rq_sectors(current_req) < ssize) { |
2732 | if (CT(COMMAND) == FD_WRITE) { | 2693 | if (CT(COMMAND) == FD_WRITE) { |
2733 | if (fsector_t + blk_rq_sectors(current_req) > ssize && | 2694 | unsigned int sectors; |
2734 | fsector_t + blk_rq_sectors(current_req) < ssize + ssize) | 2695 | |
2696 | sectors = fsector_t + blk_rq_sectors(current_req); | ||
2697 | if (sectors > ssize && sectors < ssize + ssize) | ||
2735 | max_size = ssize + ssize; | 2698 | max_size = ssize + ssize; |
2736 | else | 2699 | else |
2737 | max_size = ssize; | 2700 | max_size = ssize; |
@@ -2752,12 +2715,10 @@ static int make_raw_rw_request(void) | |||
2752 | * on a 64 bit machine! | 2715 | * on a 64 bit machine! |
2753 | */ | 2716 | */ |
2754 | max_size = buffer_chain_size(); | 2717 | max_size = buffer_chain_size(); |
2755 | dma_limit = | 2718 | dma_limit = (MAX_DMA_ADDRESS - |
2756 | (MAX_DMA_ADDRESS - | 2719 | ((unsigned long)current_req->buffer)) >> 9; |
2757 | ((unsigned long)current_req->buffer)) >> 9; | 2720 | if ((unsigned long)max_size > dma_limit) |
2758 | if ((unsigned long)max_size > dma_limit) { | ||
2759 | max_size = dma_limit; | 2721 | max_size = dma_limit; |
2760 | } | ||
2761 | /* 64 kb boundaries */ | 2722 | /* 64 kb boundaries */ |
2762 | if (CROSS_64KB(current_req->buffer, max_size << 9)) | 2723 | if (CROSS_64KB(current_req->buffer, max_size << 9)) |
2763 | max_size = (K_64 - | 2724 | max_size = (K_64 - |
@@ -2773,16 +2734,16 @@ static int make_raw_rw_request(void) | |||
2773 | */ | 2734 | */ |
2774 | if (!direct || | 2735 | if (!direct || |
2775 | (indirect * 2 > direct * 3 && | 2736 | (indirect * 2 > direct * 3 && |
2776 | *errors < DP->max_errors.read_track && ((!probing | 2737 | *errors < DP->max_errors.read_track && |
2777 | || (DP->read_track & (1 << DRS->probed_format)))))) { | 2738 | ((!probing || |
2739 | (DP->read_track & (1 << DRS->probed_format)))))) { | ||
2778 | max_size = blk_rq_sectors(current_req); | 2740 | max_size = blk_rq_sectors(current_req); |
2779 | } else { | 2741 | } else { |
2780 | raw_cmd->kernel_data = current_req->buffer; | 2742 | raw_cmd->kernel_data = current_req->buffer; |
2781 | raw_cmd->length = current_count_sectors << 9; | 2743 | raw_cmd->length = current_count_sectors << 9; |
2782 | if (raw_cmd->length == 0) { | 2744 | if (raw_cmd->length == 0) { |
2783 | DPRINT | 2745 | DPRINT("%s: zero dma transfer attempted\n", __func__); |
2784 | ("zero dma transfer attempted from make_raw_request\n"); | 2746 | DPRINT("indirect=%d direct=%d fsector_t=%d\n", |
2785 | DPRINT("indirect=%d direct=%d fsector_t=%d", | ||
2786 | indirect, direct, fsector_t); | 2747 | indirect, direct, fsector_t); |
2787 | return 0; | 2748 | return 0; |
2788 | } | 2749 | } |
@@ -2802,25 +2763,22 @@ static int make_raw_rw_request(void) | |||
2802 | ((CT(COMMAND) == FD_READ || | 2763 | ((CT(COMMAND) == FD_READ || |
2803 | (!in_sector_offset && blk_rq_sectors(current_req) >= ssize)) && | 2764 | (!in_sector_offset && blk_rq_sectors(current_req) >= ssize)) && |
2804 | max_sector > 2 * max_buffer_sectors + buffer_min && | 2765 | max_sector > 2 * max_buffer_sectors + buffer_min && |
2805 | max_size + fsector_t > 2 * max_buffer_sectors + buffer_min) | 2766 | max_size + fsector_t > 2 * max_buffer_sectors + buffer_min)) { |
2806 | /* not enough space */ | 2767 | /* not enough space */ |
2807 | ) { | ||
2808 | buffer_track = -1; | 2768 | buffer_track = -1; |
2809 | buffer_drive = current_drive; | 2769 | buffer_drive = current_drive; |
2810 | buffer_max = buffer_min = aligned_sector_t; | 2770 | buffer_max = buffer_min = aligned_sector_t; |
2811 | } | 2771 | } |
2812 | raw_cmd->kernel_data = floppy_track_buffer + | 2772 | raw_cmd->kernel_data = floppy_track_buffer + |
2813 | ((aligned_sector_t - buffer_min) << 9); | 2773 | ((aligned_sector_t - buffer_min) << 9); |
2814 | 2774 | ||
2815 | if (CT(COMMAND) == FD_WRITE) { | 2775 | if (CT(COMMAND) == FD_WRITE) { |
2816 | /* copy write buffer to track buffer. | 2776 | /* copy write buffer to track buffer. |
2817 | * if we get here, we know that the write | 2777 | * if we get here, we know that the write |
2818 | * is either aligned or the data already in the buffer | 2778 | * is either aligned or the data already in the buffer |
2819 | * (buffer will be overwritten) */ | 2779 | * (buffer will be overwritten) */ |
2820 | #ifdef FLOPPY_SANITY_CHECK | ||
2821 | if (in_sector_offset && buffer_track == -1) | 2780 | if (in_sector_offset && buffer_track == -1) |
2822 | DPRINT("internal error offset !=0 on write\n"); | 2781 | DPRINT("internal error offset !=0 on write\n"); |
2823 | #endif | ||
2824 | buffer_track = raw_cmd->track; | 2782 | buffer_track = raw_cmd->track; |
2825 | buffer_drive = current_drive; | 2783 | buffer_drive = current_drive; |
2826 | copy_buffer(ssize, max_sector, | 2784 | copy_buffer(ssize, max_sector, |
@@ -2834,7 +2792,6 @@ static int make_raw_rw_request(void) | |||
2834 | raw_cmd->length = in_sector_offset + current_count_sectors; | 2792 | raw_cmd->length = in_sector_offset + current_count_sectors; |
2835 | raw_cmd->length = ((raw_cmd->length - 1) | (ssize - 1)) + 1; | 2793 | raw_cmd->length = ((raw_cmd->length - 1) | (ssize - 1)) + 1; |
2836 | raw_cmd->length <<= 9; | 2794 | raw_cmd->length <<= 9; |
2837 | #ifdef FLOPPY_SANITY_CHECK | ||
2838 | if ((raw_cmd->length < current_count_sectors << 9) || | 2795 | if ((raw_cmd->length < current_count_sectors << 9) || |
2839 | (raw_cmd->kernel_data != current_req->buffer && | 2796 | (raw_cmd->kernel_data != current_req->buffer && |
2840 | CT(COMMAND) == FD_WRITE && | 2797 | CT(COMMAND) == FD_WRITE && |
@@ -2845,19 +2802,19 @@ static int make_raw_rw_request(void) | |||
2845 | DPRINT("fractionary current count b=%lx s=%lx\n", | 2802 | DPRINT("fractionary current count b=%lx s=%lx\n", |
2846 | raw_cmd->length, current_count_sectors); | 2803 | raw_cmd->length, current_count_sectors); |
2847 | if (raw_cmd->kernel_data != current_req->buffer) | 2804 | if (raw_cmd->kernel_data != current_req->buffer) |
2848 | printk("addr=%d, length=%ld\n", | 2805 | pr_info("addr=%d, length=%ld\n", |
2849 | (int)((raw_cmd->kernel_data - | 2806 | (int)((raw_cmd->kernel_data - |
2850 | floppy_track_buffer) >> 9), | 2807 | floppy_track_buffer) >> 9), |
2851 | current_count_sectors); | 2808 | current_count_sectors); |
2852 | printk("st=%d ast=%d mse=%d msi=%d\n", | 2809 | pr_info("st=%d ast=%d mse=%d msi=%d\n", |
2853 | fsector_t, aligned_sector_t, max_sector, max_size); | 2810 | fsector_t, aligned_sector_t, max_sector, max_size); |
2854 | printk("ssize=%x SIZECODE=%d\n", ssize, SIZECODE); | 2811 | pr_info("ssize=%x SIZECODE=%d\n", ssize, SIZECODE); |
2855 | printk("command=%x SECTOR=%d HEAD=%d, TRACK=%d\n", | 2812 | pr_info("command=%x SECTOR=%d HEAD=%d, TRACK=%d\n", |
2856 | COMMAND, SECTOR, HEAD, TRACK); | 2813 | COMMAND, SECTOR, HEAD, TRACK); |
2857 | printk("buffer drive=%d\n", buffer_drive); | 2814 | pr_info("buffer drive=%d\n", buffer_drive); |
2858 | printk("buffer track=%d\n", buffer_track); | 2815 | pr_info("buffer track=%d\n", buffer_track); |
2859 | printk("buffer_min=%d\n", buffer_min); | 2816 | pr_info("buffer_min=%d\n", buffer_min); |
2860 | printk("buffer_max=%d\n", buffer_max); | 2817 | pr_info("buffer_max=%d\n", buffer_max); |
2861 | return 0; | 2818 | return 0; |
2862 | } | 2819 | } |
2863 | 2820 | ||
@@ -2868,14 +2825,14 @@ static int make_raw_rw_request(void) | |||
2868 | raw_cmd->kernel_data + raw_cmd->length > | 2825 | raw_cmd->kernel_data + raw_cmd->length > |
2869 | floppy_track_buffer + (max_buffer_sectors << 10)) { | 2826 | floppy_track_buffer + (max_buffer_sectors << 10)) { |
2870 | DPRINT("buffer overrun in schedule dma\n"); | 2827 | DPRINT("buffer overrun in schedule dma\n"); |
2871 | printk("fsector_t=%d buffer_min=%d current_count=%ld\n", | 2828 | pr_info("fsector_t=%d buffer_min=%d current_count=%ld\n", |
2872 | fsector_t, buffer_min, raw_cmd->length >> 9); | 2829 | fsector_t, buffer_min, raw_cmd->length >> 9); |
2873 | printk("current_count_sectors=%ld\n", | 2830 | pr_info("current_count_sectors=%ld\n", |
2874 | current_count_sectors); | 2831 | current_count_sectors); |
2875 | if (CT(COMMAND) == FD_READ) | 2832 | if (CT(COMMAND) == FD_READ) |
2876 | printk("read\n"); | 2833 | pr_info("read\n"); |
2877 | if (CT(COMMAND) == FD_WRITE) | 2834 | if (CT(COMMAND) == FD_WRITE) |
2878 | printk("write\n"); | 2835 | pr_info("write\n"); |
2879 | return 0; | 2836 | return 0; |
2880 | } | 2837 | } |
2881 | } else if (raw_cmd->length > blk_rq_bytes(current_req) || | 2838 | } else if (raw_cmd->length > blk_rq_bytes(current_req) || |
@@ -2884,14 +2841,13 @@ static int make_raw_rw_request(void) | |||
2884 | return 0; | 2841 | return 0; |
2885 | } else if (raw_cmd->length < current_count_sectors << 9) { | 2842 | } else if (raw_cmd->length < current_count_sectors << 9) { |
2886 | DPRINT("more sectors than bytes\n"); | 2843 | DPRINT("more sectors than bytes\n"); |
2887 | printk("bytes=%ld\n", raw_cmd->length >> 9); | 2844 | pr_info("bytes=%ld\n", raw_cmd->length >> 9); |
2888 | printk("sectors=%ld\n", current_count_sectors); | 2845 | pr_info("sectors=%ld\n", current_count_sectors); |
2889 | } | 2846 | } |
2890 | if (raw_cmd->length == 0) { | 2847 | if (raw_cmd->length == 0) { |
2891 | DPRINT("zero dma transfer attempted from make_raw_request\n"); | 2848 | DPRINT("zero dma transfer attempted from make_raw_request\n"); |
2892 | return 0; | 2849 | return 0; |
2893 | } | 2850 | } |
2894 | #endif | ||
2895 | 2851 | ||
2896 | virtualdmabug_workaround(); | 2852 | virtualdmabug_workaround(); |
2897 | return 2; | 2853 | return 2; |
@@ -2899,7 +2855,6 @@ static int make_raw_rw_request(void) | |||
2899 | 2855 | ||
2900 | static void redo_fd_request(void) | 2856 | static void redo_fd_request(void) |
2901 | { | 2857 | { |
2902 | #define REPEAT {request_done(0); continue; } | ||
2903 | int drive; | 2858 | int drive; |
2904 | int tmp; | 2859 | int tmp; |
2905 | 2860 | ||
@@ -2907,63 +2862,63 @@ static void redo_fd_request(void) | |||
2907 | if (current_drive < N_DRIVE) | 2862 | if (current_drive < N_DRIVE) |
2908 | floppy_off(current_drive); | 2863 | floppy_off(current_drive); |
2909 | 2864 | ||
2910 | for (;;) { | 2865 | do_request: |
2911 | if (!current_req) { | 2866 | if (!current_req) { |
2912 | struct request *req; | 2867 | struct request *req; |
2913 | |||
2914 | spin_lock_irq(floppy_queue->queue_lock); | ||
2915 | req = blk_fetch_request(floppy_queue); | ||
2916 | spin_unlock_irq(floppy_queue->queue_lock); | ||
2917 | if (!req) { | ||
2918 | do_floppy = NULL; | ||
2919 | unlock_fdc(); | ||
2920 | return; | ||
2921 | } | ||
2922 | current_req = req; | ||
2923 | } | ||
2924 | drive = (long)current_req->rq_disk->private_data; | ||
2925 | set_fdc(drive); | ||
2926 | reschedule_timeout(current_reqD, "redo fd request", 0); | ||
2927 | 2868 | ||
2928 | set_floppy(drive); | 2869 | spin_lock_irq(floppy_queue->queue_lock); |
2929 | raw_cmd = &default_raw_cmd; | 2870 | req = blk_fetch_request(floppy_queue); |
2930 | raw_cmd->flags = 0; | 2871 | spin_unlock_irq(floppy_queue->queue_lock); |
2931 | if (start_motor(redo_fd_request)) | 2872 | if (!req) { |
2873 | do_floppy = NULL; | ||
2874 | unlock_fdc(); | ||
2932 | return; | 2875 | return; |
2933 | disk_change(current_drive); | ||
2934 | if (test_bit(current_drive, &fake_change) || | ||
2935 | TESTF(FD_DISK_CHANGED)) { | ||
2936 | DPRINT("disk absent or changed during operation\n"); | ||
2937 | REPEAT; | ||
2938 | } | ||
2939 | if (!_floppy) { /* Autodetection */ | ||
2940 | if (!probing) { | ||
2941 | DRS->probed_format = 0; | ||
2942 | if (next_valid_format()) { | ||
2943 | DPRINT("no autodetectable formats\n"); | ||
2944 | _floppy = NULL; | ||
2945 | REPEAT; | ||
2946 | } | ||
2947 | } | ||
2948 | probing = 1; | ||
2949 | _floppy = | ||
2950 | floppy_type + DP->autodetect[DRS->probed_format]; | ||
2951 | } else | ||
2952 | probing = 0; | ||
2953 | errors = &(current_req->errors); | ||
2954 | tmp = make_raw_rw_request(); | ||
2955 | if (tmp < 2) { | ||
2956 | request_done(tmp); | ||
2957 | continue; | ||
2958 | } | 2876 | } |
2877 | current_req = req; | ||
2878 | } | ||
2879 | drive = (long)current_req->rq_disk->private_data; | ||
2880 | set_fdc(drive); | ||
2881 | reschedule_timeout(current_reqD, "redo fd request"); | ||
2959 | 2882 | ||
2960 | if (TESTF(FD_NEED_TWADDLE)) | 2883 | set_floppy(drive); |
2961 | twaddle(); | 2884 | raw_cmd = &default_raw_cmd; |
2962 | schedule_bh(floppy_start); | 2885 | raw_cmd->flags = 0; |
2963 | debugt("queue fd request"); | 2886 | if (start_motor(redo_fd_request)) |
2964 | return; | 2887 | return; |
2888 | |||
2889 | disk_change(current_drive); | ||
2890 | if (test_bit(current_drive, &fake_change) || | ||
2891 | test_bit(FD_DISK_CHANGED_BIT, &DRS->flags)) { | ||
2892 | DPRINT("disk absent or changed during operation\n"); | ||
2893 | request_done(0); | ||
2894 | goto do_request; | ||
2895 | } | ||
2896 | if (!_floppy) { /* Autodetection */ | ||
2897 | if (!probing) { | ||
2898 | DRS->probed_format = 0; | ||
2899 | if (next_valid_format()) { | ||
2900 | DPRINT("no autodetectable formats\n"); | ||
2901 | _floppy = NULL; | ||
2902 | request_done(0); | ||
2903 | goto do_request; | ||
2904 | } | ||
2905 | } | ||
2906 | probing = 1; | ||
2907 | _floppy = floppy_type + DP->autodetect[DRS->probed_format]; | ||
2908 | } else | ||
2909 | probing = 0; | ||
2910 | errors = &(current_req->errors); | ||
2911 | tmp = make_raw_rw_request(); | ||
2912 | if (tmp < 2) { | ||
2913 | request_done(tmp); | ||
2914 | goto do_request; | ||
2965 | } | 2915 | } |
2966 | #undef REPEAT | 2916 | |
2917 | if (test_bit(FD_NEED_TWADDLE_BIT, &DRS->flags)) | ||
2918 | twaddle(); | ||
2919 | schedule_bh(floppy_start); | ||
2920 | debugt(__func__, "queue fd request"); | ||
2921 | return; | ||
2967 | } | 2922 | } |
2968 | 2923 | ||
2969 | static struct cont_t rw_cont = { | 2924 | static struct cont_t rw_cont = { |
@@ -2979,30 +2934,30 @@ static void process_fd_request(void) | |||
2979 | schedule_bh(redo_fd_request); | 2934 | schedule_bh(redo_fd_request); |
2980 | } | 2935 | } |
2981 | 2936 | ||
2982 | static void do_fd_request(struct request_queue * q) | 2937 | static void do_fd_request(struct request_queue *q) |
2983 | { | 2938 | { |
2984 | if (max_buffer_sectors == 0) { | 2939 | if (max_buffer_sectors == 0) { |
2985 | printk("VFS: do_fd_request called on non-open device\n"); | 2940 | pr_info("VFS: %s called on non-open device\n", __func__); |
2986 | return; | 2941 | return; |
2987 | } | 2942 | } |
2988 | 2943 | ||
2989 | if (usage_count == 0) { | 2944 | if (usage_count == 0) { |
2990 | printk("warning: usage count=0, current_req=%p exiting\n", | 2945 | pr_info("warning: usage count=0, current_req=%p exiting\n", |
2991 | current_req); | 2946 | current_req); |
2992 | printk("sect=%ld type=%x flags=%x\n", | 2947 | pr_info("sect=%ld type=%x flags=%x\n", |
2993 | (long)blk_rq_pos(current_req), current_req->cmd_type, | 2948 | (long)blk_rq_pos(current_req), current_req->cmd_type, |
2994 | current_req->cmd_flags); | 2949 | current_req->cmd_flags); |
2995 | return; | 2950 | return; |
2996 | } | 2951 | } |
2997 | if (test_bit(0, &fdc_busy)) { | 2952 | if (test_bit(0, &fdc_busy)) { |
2998 | /* fdc busy, this new request will be treated when the | 2953 | /* fdc busy, this new request will be treated when the |
2999 | current one is done */ | 2954 | current one is done */ |
3000 | is_alive("do fd request, old request running"); | 2955 | is_alive(__func__, "old request running"); |
3001 | return; | 2956 | return; |
3002 | } | 2957 | } |
3003 | lock_fdc(MAXTIMEOUT, 0); | 2958 | lock_fdc(MAXTIMEOUT, false); |
3004 | process_fd_request(); | 2959 | process_fd_request(); |
3005 | is_alive("do fd request"); | 2960 | is_alive(__func__, ""); |
3006 | } | 2961 | } |
3007 | 2962 | ||
3008 | static struct cont_t poll_cont = { | 2963 | static struct cont_t poll_cont = { |
@@ -3012,24 +2967,18 @@ static struct cont_t poll_cont = { | |||
3012 | .done = generic_done | 2967 | .done = generic_done |
3013 | }; | 2968 | }; |
3014 | 2969 | ||
3015 | static int poll_drive(int interruptible, int flag) | 2970 | static int poll_drive(bool interruptible, int flag) |
3016 | { | 2971 | { |
3017 | int ret; | ||
3018 | |||
3019 | /* no auto-sense, just clear dcl */ | 2972 | /* no auto-sense, just clear dcl */ |
3020 | raw_cmd = &default_raw_cmd; | 2973 | raw_cmd = &default_raw_cmd; |
3021 | raw_cmd->flags = flag; | 2974 | raw_cmd->flags = flag; |
3022 | raw_cmd->track = 0; | 2975 | raw_cmd->track = 0; |
3023 | raw_cmd->cmd_count = 0; | 2976 | raw_cmd->cmd_count = 0; |
3024 | cont = &poll_cont; | 2977 | cont = &poll_cont; |
3025 | #ifdef DCL_DEBUG | 2978 | debug_dcl(DP->flags, "setting NEWCHANGE in poll_drive\n"); |
3026 | if (DP->flags & FD_DEBUG) { | 2979 | set_bit(FD_DISK_NEWCHANGE_BIT, &DRS->flags); |
3027 | DPRINT("setting NEWCHANGE in poll_drive\n"); | 2980 | |
3028 | } | 2981 | return wait_til_done(floppy_ready, interruptible); |
3029 | #endif | ||
3030 | SETF(FD_DISK_NEWCHANGE); | ||
3031 | WAIT(floppy_ready); | ||
3032 | return ret; | ||
3033 | } | 2982 | } |
3034 | 2983 | ||
3035 | /* | 2984 | /* |
@@ -3039,7 +2988,7 @@ static int poll_drive(int interruptible, int flag) | |||
3039 | 2988 | ||
3040 | static void reset_intr(void) | 2989 | static void reset_intr(void) |
3041 | { | 2990 | { |
3042 | printk("weird, reset interrupt called\n"); | 2991 | pr_info("weird, reset interrupt called\n"); |
3043 | } | 2992 | } |
3044 | 2993 | ||
3045 | static struct cont_t reset_cont = { | 2994 | static struct cont_t reset_cont = { |
@@ -3049,20 +2998,23 @@ static struct cont_t reset_cont = { | |||
3049 | .done = generic_done | 2998 | .done = generic_done |
3050 | }; | 2999 | }; |
3051 | 3000 | ||
3052 | static int user_reset_fdc(int drive, int arg, int interruptible) | 3001 | static int user_reset_fdc(int drive, int arg, bool interruptible) |
3053 | { | 3002 | { |
3054 | int ret; | 3003 | int ret; |
3055 | 3004 | ||
3056 | ret = 0; | 3005 | if (lock_fdc(drive, interruptible)) |
3057 | LOCK_FDC(drive, interruptible); | 3006 | return -EINTR; |
3007 | |||
3058 | if (arg == FD_RESET_ALWAYS) | 3008 | if (arg == FD_RESET_ALWAYS) |
3059 | FDCS->reset = 1; | 3009 | FDCS->reset = 1; |
3060 | if (FDCS->reset) { | 3010 | if (FDCS->reset) { |
3061 | cont = &reset_cont; | 3011 | cont = &reset_cont; |
3062 | WAIT(reset_fdc); | 3012 | ret = wait_til_done(reset_fdc, interruptible); |
3013 | if (ret == -EINTR) | ||
3014 | return -EINTR; | ||
3063 | } | 3015 | } |
3064 | process_fd_request(); | 3016 | process_fd_request(); |
3065 | return ret; | 3017 | return 0; |
3066 | } | 3018 | } |
3067 | 3019 | ||
3068 | /* | 3020 | /* |
@@ -3075,17 +3027,12 @@ static inline int fd_copyout(void __user *param, const void *address, | |||
3075 | return copy_to_user(param, address, size) ? -EFAULT : 0; | 3027 | return copy_to_user(param, address, size) ? -EFAULT : 0; |
3076 | } | 3028 | } |
3077 | 3029 | ||
3078 | static inline int fd_copyin(void __user *param, void *address, unsigned long size) | 3030 | static inline int fd_copyin(void __user *param, void *address, |
3031 | unsigned long size) | ||
3079 | { | 3032 | { |
3080 | return copy_from_user(address, param, size) ? -EFAULT : 0; | 3033 | return copy_from_user(address, param, size) ? -EFAULT : 0; |
3081 | } | 3034 | } |
3082 | 3035 | ||
3083 | #define _COPYOUT(x) (copy_to_user((void __user *)param, &(x), sizeof(x)) ? -EFAULT : 0) | ||
3084 | #define _COPYIN(x) (copy_from_user(&(x), (void __user *)param, sizeof(x)) ? -EFAULT : 0) | ||
3085 | |||
3086 | #define COPYOUT(x) ECALL(_COPYOUT(x)) | ||
3087 | #define COPYIN(x) ECALL(_COPYIN(x)) | ||
3088 | |||
3089 | static inline const char *drive_name(int type, int drive) | 3036 | static inline const char *drive_name(int type, int drive) |
3090 | { | 3037 | { |
3091 | struct floppy_struct *floppy; | 3038 | struct floppy_struct *floppy; |
@@ -3156,23 +3103,29 @@ static struct cont_t raw_cmd_cont = { | |||
3156 | .done = raw_cmd_done | 3103 | .done = raw_cmd_done |
3157 | }; | 3104 | }; |
3158 | 3105 | ||
3159 | static inline int raw_cmd_copyout(int cmd, char __user *param, | 3106 | static inline int raw_cmd_copyout(int cmd, void __user *param, |
3160 | struct floppy_raw_cmd *ptr) | 3107 | struct floppy_raw_cmd *ptr) |
3161 | { | 3108 | { |
3162 | int ret; | 3109 | int ret; |
3163 | 3110 | ||
3164 | while (ptr) { | 3111 | while (ptr) { |
3165 | COPYOUT(*ptr); | 3112 | ret = copy_to_user(param, ptr, sizeof(*ptr)); |
3113 | if (ret) | ||
3114 | return -EFAULT; | ||
3166 | param += sizeof(struct floppy_raw_cmd); | 3115 | param += sizeof(struct floppy_raw_cmd); |
3167 | if ((ptr->flags & FD_RAW_READ) && ptr->buffer_length) { | 3116 | if ((ptr->flags & FD_RAW_READ) && ptr->buffer_length) { |
3168 | if (ptr->length >= 0 | 3117 | if (ptr->length >= 0 && |
3169 | && ptr->length <= ptr->buffer_length) | 3118 | ptr->length <= ptr->buffer_length) { |
3170 | ECALL(fd_copyout | 3119 | long length = ptr->buffer_length - ptr->length; |
3171 | (ptr->data, ptr->kernel_data, | 3120 | ret = fd_copyout(ptr->data, ptr->kernel_data, |
3172 | ptr->buffer_length - ptr->length)); | 3121 | length); |
3122 | if (ret) | ||
3123 | return ret; | ||
3124 | } | ||
3173 | } | 3125 | } |
3174 | ptr = ptr->next; | 3126 | ptr = ptr->next; |
3175 | } | 3127 | } |
3128 | |||
3176 | return 0; | 3129 | return 0; |
3177 | } | 3130 | } |
3178 | 3131 | ||
@@ -3195,7 +3148,7 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) | |||
3195 | } | 3148 | } |
3196 | } | 3149 | } |
3197 | 3150 | ||
3198 | static inline int raw_cmd_copyin(int cmd, char __user *param, | 3151 | static inline int raw_cmd_copyin(int cmd, void __user *param, |
3199 | struct floppy_raw_cmd **rcmd) | 3152 | struct floppy_raw_cmd **rcmd) |
3200 | { | 3153 | { |
3201 | struct floppy_raw_cmd *ptr; | 3154 | struct floppy_raw_cmd *ptr; |
@@ -3203,17 +3156,19 @@ static inline int raw_cmd_copyin(int cmd, char __user *param, | |||
3203 | int i; | 3156 | int i; |
3204 | 3157 | ||
3205 | *rcmd = NULL; | 3158 | *rcmd = NULL; |
3206 | while (1) { | 3159 | |
3207 | ptr = (struct floppy_raw_cmd *) | 3160 | loop: |
3208 | kmalloc(sizeof(struct floppy_raw_cmd), GFP_USER); | 3161 | ptr = kmalloc(sizeof(struct floppy_raw_cmd), GFP_USER); |
3209 | if (!ptr) | 3162 | if (!ptr) |
3210 | return -ENOMEM; | 3163 | return -ENOMEM; |
3211 | *rcmd = ptr; | 3164 | *rcmd = ptr; |
3212 | COPYIN(*ptr); | 3165 | ret = copy_from_user(ptr, param, sizeof(*ptr)); |
3213 | ptr->next = NULL; | 3166 | if (ret) |
3214 | ptr->buffer_length = 0; | 3167 | return -EFAULT; |
3215 | param += sizeof(struct floppy_raw_cmd); | 3168 | ptr->next = NULL; |
3216 | if (ptr->cmd_count > 33) | 3169 | ptr->buffer_length = 0; |
3170 | param += sizeof(struct floppy_raw_cmd); | ||
3171 | if (ptr->cmd_count > 33) | ||
3217 | /* the command may now also take up the space | 3172 | /* the command may now also take up the space |
3218 | * initially intended for the reply & the | 3173 | * initially intended for the reply & the |
3219 | * reply count. Needed for long 82078 commands | 3174 | * reply count. Needed for long 82078 commands |
@@ -3222,31 +3177,35 @@ static inline int raw_cmd_copyin(int cmd, char __user *param, | |||
3222 | * 16 bytes for a structure, you'll one day | 3177 | * 16 bytes for a structure, you'll one day |
3223 | * discover that you really need 17... | 3178 | * discover that you really need 17... |
3224 | */ | 3179 | */ |
3180 | return -EINVAL; | ||
3181 | |||
3182 | for (i = 0; i < 16; i++) | ||
3183 | ptr->reply[i] = 0; | ||
3184 | ptr->resultcode = 0; | ||
3185 | ptr->kernel_data = NULL; | ||
3186 | |||
3187 | if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { | ||
3188 | if (ptr->length <= 0) | ||
3225 | return -EINVAL; | 3189 | return -EINVAL; |
3190 | ptr->kernel_data = (char *)fd_dma_mem_alloc(ptr->length); | ||
3191 | fallback_on_nodma_alloc(&ptr->kernel_data, ptr->length); | ||
3192 | if (!ptr->kernel_data) | ||
3193 | return -ENOMEM; | ||
3194 | ptr->buffer_length = ptr->length; | ||
3195 | } | ||
3196 | if (ptr->flags & FD_RAW_WRITE) { | ||
3197 | ret = fd_copyin(ptr->data, ptr->kernel_data, ptr->length); | ||
3198 | if (ret) | ||
3199 | return ret; | ||
3200 | } | ||
3226 | 3201 | ||
3227 | for (i = 0; i < 16; i++) | 3202 | if (ptr->flags & FD_RAW_MORE) { |
3228 | ptr->reply[i] = 0; | ||
3229 | ptr->resultcode = 0; | ||
3230 | ptr->kernel_data = NULL; | ||
3231 | |||
3232 | if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { | ||
3233 | if (ptr->length <= 0) | ||
3234 | return -EINVAL; | ||
3235 | ptr->kernel_data = | ||
3236 | (char *)fd_dma_mem_alloc(ptr->length); | ||
3237 | fallback_on_nodma_alloc(&ptr->kernel_data, ptr->length); | ||
3238 | if (!ptr->kernel_data) | ||
3239 | return -ENOMEM; | ||
3240 | ptr->buffer_length = ptr->length; | ||
3241 | } | ||
3242 | if (ptr->flags & FD_RAW_WRITE) | ||
3243 | ECALL(fd_copyin(ptr->data, ptr->kernel_data, | ||
3244 | ptr->length)); | ||
3245 | rcmd = &(ptr->next); | 3203 | rcmd = &(ptr->next); |
3246 | if (!(ptr->flags & FD_RAW_MORE)) | ||
3247 | return 0; | ||
3248 | ptr->rate &= 0x43; | 3204 | ptr->rate &= 0x43; |
3205 | goto loop; | ||
3249 | } | 3206 | } |
3207 | |||
3208 | return 0; | ||
3250 | } | 3209 | } |
3251 | 3210 | ||
3252 | static int raw_cmd_ioctl(int cmd, void __user *param) | 3211 | static int raw_cmd_ioctl(int cmd, void __user *param) |
@@ -3283,12 +3242,8 @@ static int raw_cmd_ioctl(int cmd, void __user *param) | |||
3283 | 3242 | ||
3284 | raw_cmd = my_raw_cmd; | 3243 | raw_cmd = my_raw_cmd; |
3285 | cont = &raw_cmd_cont; | 3244 | cont = &raw_cmd_cont; |
3286 | ret = wait_til_done(floppy_start, 1); | 3245 | ret = wait_til_done(floppy_start, true); |
3287 | #ifdef DCL_DEBUG | 3246 | debug_dcl(DP->flags, "calling disk change from raw_cmd ioctl\n"); |
3288 | if (DP->flags & FD_DEBUG) { | ||
3289 | DPRINT("calling disk change from raw_cmd ioctl\n"); | ||
3290 | } | ||
3291 | #endif | ||
3292 | 3247 | ||
3293 | if (ret != -EINTR && FDCS->reset) | 3248 | if (ret != -EINTR && FDCS->reset) |
3294 | ret = -EIO; | 3249 | ret = -EIO; |
@@ -3327,7 +3282,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3327 | if (!capable(CAP_SYS_ADMIN)) | 3282 | if (!capable(CAP_SYS_ADMIN)) |
3328 | return -EPERM; | 3283 | return -EPERM; |
3329 | mutex_lock(&open_lock); | 3284 | mutex_lock(&open_lock); |
3330 | if (lock_fdc(drive, 1)) { | 3285 | if (lock_fdc(drive, true)) { |
3331 | mutex_unlock(&open_lock); | 3286 | mutex_unlock(&open_lock); |
3332 | return -EINTR; | 3287 | return -EINTR; |
3333 | } | 3288 | } |
@@ -3346,11 +3301,15 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3346 | mutex_unlock(&open_lock); | 3301 | mutex_unlock(&open_lock); |
3347 | } else { | 3302 | } else { |
3348 | int oldStretch; | 3303 | int oldStretch; |
3349 | LOCK_FDC(drive, 1); | 3304 | |
3350 | if (cmd != FDDEFPRM) | 3305 | if (lock_fdc(drive, true)) |
3306 | return -EINTR; | ||
3307 | if (cmd != FDDEFPRM) { | ||
3351 | /* notice a disk change immediately, else | 3308 | /* notice a disk change immediately, else |
3352 | * we lose our settings immediately*/ | 3309 | * we lose our settings immediately*/ |
3353 | CALL(poll_drive(1, FD_RAW_NEED_DISK)); | 3310 | if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR) |
3311 | return -EINTR; | ||
3312 | } | ||
3354 | oldStretch = g->stretch; | 3313 | oldStretch = g->stretch; |
3355 | user_params[drive] = *g; | 3314 | user_params[drive] = *g; |
3356 | if (buffer_drive == drive) | 3315 | if (buffer_drive == drive) |
@@ -3415,7 +3374,7 @@ static inline int normalize_ioctl(int *cmd, int *size) | |||
3415 | *size = _IOC_SIZE(*cmd); | 3374 | *size = _IOC_SIZE(*cmd); |
3416 | *cmd = ioctl_table[i]; | 3375 | *cmd = ioctl_table[i]; |
3417 | if (*size > _IOC_SIZE(*cmd)) { | 3376 | if (*size > _IOC_SIZE(*cmd)) { |
3418 | printk("ioctl not yet supported\n"); | 3377 | pr_info("ioctl not yet supported\n"); |
3419 | return -EFAULT; | 3378 | return -EFAULT; |
3420 | } | 3379 | } |
3421 | return 0; | 3380 | return 0; |
@@ -3429,8 +3388,10 @@ static int get_floppy_geometry(int drive, int type, struct floppy_struct **g) | |||
3429 | if (type) | 3388 | if (type) |
3430 | *g = &floppy_type[type]; | 3389 | *g = &floppy_type[type]; |
3431 | else { | 3390 | else { |
3432 | LOCK_FDC(drive, 0); | 3391 | if (lock_fdc(drive, false)) |
3433 | CALL(poll_drive(0, 0)); | 3392 | return -EINTR; |
3393 | if (poll_drive(false, 0) == -EINTR) | ||
3394 | return -EINTR; | ||
3434 | process_fd_request(); | 3395 | process_fd_request(); |
3435 | *g = current_type[drive]; | 3396 | *g = current_type[drive]; |
3436 | } | 3397 | } |
@@ -3459,10 +3420,6 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
3459 | static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, | 3420 | static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, |
3460 | unsigned long param) | 3421 | unsigned long param) |
3461 | { | 3422 | { |
3462 | #define FD_IOCTL_ALLOWED (mode & (FMODE_WRITE|FMODE_WRITE_IOCTL)) | ||
3463 | #define OUT(c,x) case c: outparam = (const char *) (x); break | ||
3464 | #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0 | ||
3465 | |||
3466 | int drive = (long)bdev->bd_disk->private_data; | 3423 | int drive = (long)bdev->bd_disk->private_data; |
3467 | int type = ITYPE(UDRS->fd_device); | 3424 | int type = ITYPE(UDRS->fd_device); |
3468 | int i; | 3425 | int i; |
@@ -3474,26 +3431,28 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, | |||
3474 | struct floppy_max_errors max_errors; | 3431 | struct floppy_max_errors max_errors; |
3475 | struct floppy_drive_params dp; | 3432 | struct floppy_drive_params dp; |
3476 | } inparam; /* parameters coming from user space */ | 3433 | } inparam; /* parameters coming from user space */ |
3477 | const char *outparam; /* parameters passed back to user space */ | 3434 | const void *outparam; /* parameters passed back to user space */ |
3478 | 3435 | ||
3479 | /* convert compatibility eject ioctls into floppy eject ioctl. | 3436 | /* convert compatibility eject ioctls into floppy eject ioctl. |
3480 | * We do this in order to provide a means to eject floppy disks before | 3437 | * We do this in order to provide a means to eject floppy disks before |
3481 | * installing the new fdutils package */ | 3438 | * installing the new fdutils package */ |
3482 | if (cmd == CDROMEJECT || /* CD-ROM eject */ | 3439 | if (cmd == CDROMEJECT || /* CD-ROM eject */ |
3483 | cmd == 0x6470 /* SunOS floppy eject */ ) { | 3440 | cmd == 0x6470) { /* SunOS floppy eject */ |
3484 | DPRINT("obsolete eject ioctl\n"); | 3441 | DPRINT("obsolete eject ioctl\n"); |
3485 | DPRINT("please use floppycontrol --eject\n"); | 3442 | DPRINT("please use floppycontrol --eject\n"); |
3486 | cmd = FDEJECT; | 3443 | cmd = FDEJECT; |
3487 | } | 3444 | } |
3488 | 3445 | ||
3489 | /* convert the old style command into a new style command */ | 3446 | if (!((cmd & 0xff00) == 0x0200)) |
3490 | if ((cmd & 0xff00) == 0x0200) { | ||
3491 | ECALL(normalize_ioctl(&cmd, &size)); | ||
3492 | } else | ||
3493 | return -EINVAL; | 3447 | return -EINVAL; |
3494 | 3448 | ||
3449 | /* convert the old style command into a new style command */ | ||
3450 | ret = normalize_ioctl(&cmd, &size); | ||
3451 | if (ret) | ||
3452 | return ret; | ||
3453 | |||
3495 | /* permission checks */ | 3454 | /* permission checks */ |
3496 | if (((cmd & 0x40) && !FD_IOCTL_ALLOWED) || | 3455 | if (((cmd & 0x40) && !(mode & (FMODE_WRITE | FMODE_WRITE_IOCTL))) || |
3497 | ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))) | 3456 | ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))) |
3498 | return -EPERM; | 3457 | return -EPERM; |
3499 | 3458 | ||
@@ -3501,129 +3460,142 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, | |||
3501 | return -EINVAL; | 3460 | return -EINVAL; |
3502 | 3461 | ||
3503 | /* copyin */ | 3462 | /* copyin */ |
3504 | CLEARSTRUCT(&inparam); | 3463 | memset(&inparam, 0, sizeof(inparam)); |
3505 | if (_IOC_DIR(cmd) & _IOC_WRITE) | 3464 | if (_IOC_DIR(cmd) & _IOC_WRITE) { |
3506 | ECALL(fd_copyin((void __user *)param, &inparam, size)) | 3465 | ret = fd_copyin((void __user *)param, &inparam, size); |
3507 | 3466 | if (ret) | |
3508 | switch (cmd) { | ||
3509 | case FDEJECT: | ||
3510 | if (UDRS->fd_ref != 1) | ||
3511 | /* somebody else has this drive open */ | ||
3512 | return -EBUSY; | ||
3513 | LOCK_FDC(drive, 1); | ||
3514 | |||
3515 | /* do the actual eject. Fails on | ||
3516 | * non-Sparc architectures */ | ||
3517 | ret = fd_eject(UNIT(drive)); | ||
3518 | |||
3519 | USETF(FD_DISK_CHANGED); | ||
3520 | USETF(FD_VERIFY); | ||
3521 | process_fd_request(); | ||
3522 | return ret; | 3467 | return ret; |
3523 | case FDCLRPRM: | 3468 | } |
3524 | LOCK_FDC(drive, 1); | ||
3525 | current_type[drive] = NULL; | ||
3526 | floppy_sizes[drive] = MAX_DISK_SIZE << 1; | ||
3527 | UDRS->keep_data = 0; | ||
3528 | return invalidate_drive(bdev); | ||
3529 | case FDSETPRM: | ||
3530 | case FDDEFPRM: | ||
3531 | return set_geometry(cmd, &inparam.g, | ||
3532 | drive, type, bdev); | ||
3533 | case FDGETPRM: | ||
3534 | ECALL(get_floppy_geometry(drive, type, | ||
3535 | (struct floppy_struct **) | ||
3536 | &outparam)); | ||
3537 | break; | ||
3538 | |||
3539 | case FDMSGON: | ||
3540 | UDP->flags |= FTD_MSG; | ||
3541 | return 0; | ||
3542 | case FDMSGOFF: | ||
3543 | UDP->flags &= ~FTD_MSG; | ||
3544 | return 0; | ||
3545 | |||
3546 | case FDFMTBEG: | ||
3547 | LOCK_FDC(drive, 1); | ||
3548 | CALL(poll_drive(1, FD_RAW_NEED_DISK)); | ||
3549 | ret = UDRS->flags; | ||
3550 | process_fd_request(); | ||
3551 | if (ret & FD_VERIFY) | ||
3552 | return -ENODEV; | ||
3553 | if (!(ret & FD_DISK_WRITABLE)) | ||
3554 | return -EROFS; | ||
3555 | return 0; | ||
3556 | case FDFMTTRK: | ||
3557 | if (UDRS->fd_ref != 1) | ||
3558 | return -EBUSY; | ||
3559 | return do_format(drive, &inparam.f); | ||
3560 | case FDFMTEND: | ||
3561 | case FDFLUSH: | ||
3562 | LOCK_FDC(drive, 1); | ||
3563 | return invalidate_drive(bdev); | ||
3564 | |||
3565 | case FDSETEMSGTRESH: | ||
3566 | UDP->max_errors.reporting = | ||
3567 | (unsigned short)(param & 0x0f); | ||
3568 | return 0; | ||
3569 | OUT(FDGETMAXERRS, &UDP->max_errors); | ||
3570 | IN(FDSETMAXERRS, &UDP->max_errors, max_errors); | ||
3571 | |||
3572 | case FDGETDRVTYP: | ||
3573 | outparam = drive_name(type, drive); | ||
3574 | SUPBOUND(size, strlen(outparam) + 1); | ||
3575 | break; | ||
3576 | |||
3577 | IN(FDSETDRVPRM, UDP, dp); | ||
3578 | OUT(FDGETDRVPRM, UDP); | ||
3579 | |||
3580 | case FDPOLLDRVSTAT: | ||
3581 | LOCK_FDC(drive, 1); | ||
3582 | CALL(poll_drive(1, FD_RAW_NEED_DISK)); | ||
3583 | process_fd_request(); | ||
3584 | /* fall through */ | ||
3585 | OUT(FDGETDRVSTAT, UDRS); | ||
3586 | |||
3587 | case FDRESET: | ||
3588 | return user_reset_fdc(drive, (int)param, 1); | ||
3589 | |||
3590 | OUT(FDGETFDCSTAT, UFDCS); | ||
3591 | 3469 | ||
3592 | case FDWERRORCLR: | 3470 | switch (cmd) { |
3593 | CLEARSTRUCT(UDRWE); | 3471 | case FDEJECT: |
3594 | return 0; | 3472 | if (UDRS->fd_ref != 1) |
3595 | OUT(FDWERRORGET, UDRWE); | 3473 | /* somebody else has this drive open */ |
3596 | 3474 | return -EBUSY; | |
3597 | case FDRAWCMD: | 3475 | if (lock_fdc(drive, true)) |
3598 | if (type) | 3476 | return -EINTR; |
3599 | return -EINVAL; | ||
3600 | LOCK_FDC(drive, 1); | ||
3601 | set_floppy(drive); | ||
3602 | CALL(i = raw_cmd_ioctl(cmd, (void __user *)param)); | ||
3603 | process_fd_request(); | ||
3604 | return i; | ||
3605 | 3477 | ||
3606 | case FDTWADDLE: | 3478 | /* do the actual eject. Fails on |
3607 | LOCK_FDC(drive, 1); | 3479 | * non-Sparc architectures */ |
3608 | twaddle(); | 3480 | ret = fd_eject(UNIT(drive)); |
3609 | process_fd_request(); | ||
3610 | return 0; | ||
3611 | 3481 | ||
3612 | default: | 3482 | set_bit(FD_DISK_CHANGED_BIT, &UDRS->flags); |
3483 | set_bit(FD_VERIFY_BIT, &UDRS->flags); | ||
3484 | process_fd_request(); | ||
3485 | return ret; | ||
3486 | case FDCLRPRM: | ||
3487 | if (lock_fdc(drive, true)) | ||
3488 | return -EINTR; | ||
3489 | current_type[drive] = NULL; | ||
3490 | floppy_sizes[drive] = MAX_DISK_SIZE << 1; | ||
3491 | UDRS->keep_data = 0; | ||
3492 | return invalidate_drive(bdev); | ||
3493 | case FDSETPRM: | ||
3494 | case FDDEFPRM: | ||
3495 | return set_geometry(cmd, &inparam.g, drive, type, bdev); | ||
3496 | case FDGETPRM: | ||
3497 | ret = get_floppy_geometry(drive, type, | ||
3498 | (struct floppy_struct **)&outparam); | ||
3499 | if (ret) | ||
3500 | return ret; | ||
3501 | break; | ||
3502 | case FDMSGON: | ||
3503 | UDP->flags |= FTD_MSG; | ||
3504 | return 0; | ||
3505 | case FDMSGOFF: | ||
3506 | UDP->flags &= ~FTD_MSG; | ||
3507 | return 0; | ||
3508 | case FDFMTBEG: | ||
3509 | if (lock_fdc(drive, true)) | ||
3510 | return -EINTR; | ||
3511 | if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR) | ||
3512 | return -EINTR; | ||
3513 | ret = UDRS->flags; | ||
3514 | process_fd_request(); | ||
3515 | if (ret & FD_VERIFY) | ||
3516 | return -ENODEV; | ||
3517 | if (!(ret & FD_DISK_WRITABLE)) | ||
3518 | return -EROFS; | ||
3519 | return 0; | ||
3520 | case FDFMTTRK: | ||
3521 | if (UDRS->fd_ref != 1) | ||
3522 | return -EBUSY; | ||
3523 | return do_format(drive, &inparam.f); | ||
3524 | case FDFMTEND: | ||
3525 | case FDFLUSH: | ||
3526 | if (lock_fdc(drive, true)) | ||
3527 | return -EINTR; | ||
3528 | return invalidate_drive(bdev); | ||
3529 | case FDSETEMSGTRESH: | ||
3530 | UDP->max_errors.reporting = (unsigned short)(param & 0x0f); | ||
3531 | return 0; | ||
3532 | case FDGETMAXERRS: | ||
3533 | outparam = &UDP->max_errors; | ||
3534 | break; | ||
3535 | case FDSETMAXERRS: | ||
3536 | UDP->max_errors = inparam.max_errors; | ||
3537 | break; | ||
3538 | case FDGETDRVTYP: | ||
3539 | outparam = drive_name(type, drive); | ||
3540 | SUPBOUND(size, strlen((const char *)outparam) + 1); | ||
3541 | break; | ||
3542 | case FDSETDRVPRM: | ||
3543 | *UDP = inparam.dp; | ||
3544 | break; | ||
3545 | case FDGETDRVPRM: | ||
3546 | outparam = UDP; | ||
3547 | break; | ||
3548 | case FDPOLLDRVSTAT: | ||
3549 | if (lock_fdc(drive, true)) | ||
3550 | return -EINTR; | ||
3551 | if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR) | ||
3552 | return -EINTR; | ||
3553 | process_fd_request(); | ||
3554 | /* fall through */ | ||
3555 | case FDGETDRVSTAT: | ||
3556 | outparam = UDRS; | ||
3557 | break; | ||
3558 | case FDRESET: | ||
3559 | return user_reset_fdc(drive, (int)param, true); | ||
3560 | case FDGETFDCSTAT: | ||
3561 | outparam = UFDCS; | ||
3562 | break; | ||
3563 | case FDWERRORCLR: | ||
3564 | memset(UDRWE, 0, sizeof(*UDRWE)); | ||
3565 | return 0; | ||
3566 | case FDWERRORGET: | ||
3567 | outparam = UDRWE; | ||
3568 | break; | ||
3569 | case FDRAWCMD: | ||
3570 | if (type) | ||
3613 | return -EINVAL; | 3571 | return -EINVAL; |
3614 | } | 3572 | if (lock_fdc(drive, true)) |
3573 | return -EINTR; | ||
3574 | set_floppy(drive); | ||
3575 | i = raw_cmd_ioctl(cmd, (void __user *)param); | ||
3576 | if (i == -EINTR) | ||
3577 | return -EINTR; | ||
3578 | process_fd_request(); | ||
3579 | return i; | ||
3580 | case FDTWADDLE: | ||
3581 | if (lock_fdc(drive, true)) | ||
3582 | return -EINTR; | ||
3583 | twaddle(); | ||
3584 | process_fd_request(); | ||
3585 | return 0; | ||
3586 | default: | ||
3587 | return -EINVAL; | ||
3588 | } | ||
3615 | 3589 | ||
3616 | if (_IOC_DIR(cmd) & _IOC_READ) | 3590 | if (_IOC_DIR(cmd) & _IOC_READ) |
3617 | return fd_copyout((void __user *)param, outparam, size); | 3591 | return fd_copyout((void __user *)param, outparam, size); |
3618 | else | 3592 | |
3619 | return 0; | 3593 | return 0; |
3620 | #undef OUT | ||
3621 | #undef IN | ||
3622 | } | 3594 | } |
3623 | 3595 | ||
3624 | static void __init config_types(void) | 3596 | static void __init config_types(void) |
3625 | { | 3597 | { |
3626 | int first = 1; | 3598 | bool has_drive = false; |
3627 | int drive; | 3599 | int drive; |
3628 | 3600 | ||
3629 | /* read drive info out of physical CMOS */ | 3601 | /* read drive info out of physical CMOS */ |
@@ -3655,17 +3627,22 @@ static void __init config_types(void) | |||
3655 | name = temparea; | 3627 | name = temparea; |
3656 | } | 3628 | } |
3657 | if (name) { | 3629 | if (name) { |
3658 | const char *prepend = ","; | 3630 | const char *prepend; |
3659 | if (first) { | 3631 | if (!has_drive) { |
3660 | prepend = KERN_INFO "Floppy drive(s):"; | 3632 | prepend = ""; |
3661 | first = 0; | 3633 | has_drive = true; |
3634 | pr_info("Floppy drive(s):"); | ||
3635 | } else { | ||
3636 | prepend = ","; | ||
3662 | } | 3637 | } |
3663 | printk("%s fd%d is %s", prepend, drive, name); | 3638 | |
3639 | pr_cont("%s fd%d is %s", prepend, drive, name); | ||
3664 | } | 3640 | } |
3665 | *UDP = *params; | 3641 | *UDP = *params; |
3666 | } | 3642 | } |
3667 | if (!first) | 3643 | |
3668 | printk("\n"); | 3644 | if (has_drive) |
3645 | pr_cont("\n"); | ||
3669 | } | 3646 | } |
3670 | 3647 | ||
3671 | static int floppy_release(struct gendisk *disk, fmode_t mode) | 3648 | static int floppy_release(struct gendisk *disk, fmode_t mode) |
@@ -3705,8 +3682,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
3705 | goto out2; | 3682 | goto out2; |
3706 | 3683 | ||
3707 | if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) { | 3684 | if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) { |
3708 | USETF(FD_DISK_CHANGED); | 3685 | set_bit(FD_DISK_CHANGED_BIT, &UDRS->flags); |
3709 | USETF(FD_VERIFY); | 3686 | set_bit(FD_VERIFY_BIT, &UDRS->flags); |
3710 | } | 3687 | } |
3711 | 3688 | ||
3712 | if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL))) | 3689 | if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL))) |
@@ -3735,9 +3712,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
3735 | INFBOUND(try, 16); | 3712 | INFBOUND(try, 16); |
3736 | tmp = (char *)fd_dma_mem_alloc(1024 * try); | 3713 | tmp = (char *)fd_dma_mem_alloc(1024 * try); |
3737 | } | 3714 | } |
3738 | if (!tmp && !floppy_track_buffer) { | 3715 | if (!tmp && !floppy_track_buffer) |
3739 | fallback_on_nodma_alloc(&tmp, 2048 * try); | 3716 | fallback_on_nodma_alloc(&tmp, 2048 * try); |
3740 | } | ||
3741 | if (!tmp && !floppy_track_buffer) { | 3717 | if (!tmp && !floppy_track_buffer) { |
3742 | DPRINT("Unable to allocate DMA memory\n"); | 3718 | DPRINT("Unable to allocate DMA memory\n"); |
3743 | goto out; | 3719 | goto out; |
@@ -3767,11 +3743,12 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
3767 | if (mode & (FMODE_READ|FMODE_WRITE)) { | 3743 | if (mode & (FMODE_READ|FMODE_WRITE)) { |
3768 | UDRS->last_checked = 0; | 3744 | UDRS->last_checked = 0; |
3769 | check_disk_change(bdev); | 3745 | check_disk_change(bdev); |
3770 | if (UTESTF(FD_DISK_CHANGED)) | 3746 | if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) |
3771 | goto out; | 3747 | goto out; |
3772 | } | 3748 | } |
3773 | res = -EROFS; | 3749 | res = -EROFS; |
3774 | if ((mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE))) | 3750 | if ((mode & FMODE_WRITE) && |
3751 | !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) | ||
3775 | goto out; | 3752 | goto out; |
3776 | } | 3753 | } |
3777 | mutex_unlock(&open_lock); | 3754 | mutex_unlock(&open_lock); |
@@ -3795,17 +3772,18 @@ static int check_floppy_change(struct gendisk *disk) | |||
3795 | { | 3772 | { |
3796 | int drive = (long)disk->private_data; | 3773 | int drive = (long)disk->private_data; |
3797 | 3774 | ||
3798 | if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY)) | 3775 | if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) || |
3776 | test_bit(FD_VERIFY_BIT, &UDRS->flags)) | ||
3799 | return 1; | 3777 | return 1; |
3800 | 3778 | ||
3801 | if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) { | 3779 | if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) { |
3802 | lock_fdc(drive, 0); | 3780 | lock_fdc(drive, false); |
3803 | poll_drive(0, 0); | 3781 | poll_drive(false, 0); |
3804 | process_fd_request(); | 3782 | process_fd_request(); |
3805 | } | 3783 | } |
3806 | 3784 | ||
3807 | if (UTESTF(FD_DISK_CHANGED) || | 3785 | if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) || |
3808 | UTESTF(FD_VERIFY) || | 3786 | test_bit(FD_VERIFY_BIT, &UDRS->flags) || |
3809 | test_bit(drive, &fake_change) || | 3787 | test_bit(drive, &fake_change) || |
3810 | (!ITYPE(UDRS->fd_device) && !current_type[drive])) | 3788 | (!ITYPE(UDRS->fd_device) && !current_type[drive])) |
3811 | return 1; | 3789 | return 1; |
@@ -3818,8 +3796,7 @@ static int check_floppy_change(struct gendisk *disk) | |||
3818 | * a disk in the drive, and whether that disk is writable. | 3796 | * a disk in the drive, and whether that disk is writable. |
3819 | */ | 3797 | */ |
3820 | 3798 | ||
3821 | static void floppy_rb0_complete(struct bio *bio, | 3799 | static void floppy_rb0_complete(struct bio *bio, int err) |
3822 | int err) | ||
3823 | { | 3800 | { |
3824 | complete((struct completion *)bio->bi_private); | 3801 | complete((struct completion *)bio->bi_private); |
3825 | } | 3802 | } |
@@ -3877,14 +3854,16 @@ static int floppy_revalidate(struct gendisk *disk) | |||
3877 | int cf; | 3854 | int cf; |
3878 | int res = 0; | 3855 | int res = 0; |
3879 | 3856 | ||
3880 | if (UTESTF(FD_DISK_CHANGED) || | 3857 | if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) || |
3881 | UTESTF(FD_VERIFY) || test_bit(drive, &fake_change) || NO_GEOM) { | 3858 | test_bit(FD_VERIFY_BIT, &UDRS->flags) || |
3859 | test_bit(drive, &fake_change) || NO_GEOM) { | ||
3882 | if (usage_count == 0) { | 3860 | if (usage_count == 0) { |
3883 | printk("VFS: revalidate called on non-open device.\n"); | 3861 | pr_info("VFS: revalidate called on non-open device.\n"); |
3884 | return -EFAULT; | 3862 | return -EFAULT; |
3885 | } | 3863 | } |
3886 | lock_fdc(drive, 0); | 3864 | lock_fdc(drive, false); |
3887 | cf = UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY); | 3865 | cf = (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) || |
3866 | test_bit(FD_VERIFY_BIT, &UDRS->flags)); | ||
3888 | if (!(cf || test_bit(drive, &fake_change) || NO_GEOM)) { | 3867 | if (!(cf || test_bit(drive, &fake_change) || NO_GEOM)) { |
3889 | process_fd_request(); /*already done by another thread */ | 3868 | process_fd_request(); /*already done by another thread */ |
3890 | return 0; | 3869 | return 0; |
@@ -3894,7 +3873,7 @@ static int floppy_revalidate(struct gendisk *disk) | |||
3894 | if (buffer_drive == drive) | 3873 | if (buffer_drive == drive) |
3895 | buffer_track = -1; | 3874 | buffer_track = -1; |
3896 | clear_bit(drive, &fake_change); | 3875 | clear_bit(drive, &fake_change); |
3897 | UCLEARF(FD_DISK_CHANGED); | 3876 | clear_bit(FD_DISK_CHANGED_BIT, &UDRS->flags); |
3898 | if (cf) | 3877 | if (cf) |
3899 | UDRS->generation++; | 3878 | UDRS->generation++; |
3900 | if (NO_GEOM) { | 3879 | if (NO_GEOM) { |
@@ -3902,7 +3881,7 @@ static int floppy_revalidate(struct gendisk *disk) | |||
3902 | res = __floppy_read_block_0(opened_bdev[drive]); | 3881 | res = __floppy_read_block_0(opened_bdev[drive]); |
3903 | } else { | 3882 | } else { |
3904 | if (cf) | 3883 | if (cf) |
3905 | poll_drive(0, FD_RAW_NEED_DISK); | 3884 | poll_drive(false, FD_RAW_NEED_DISK); |
3906 | process_fd_request(); | 3885 | process_fd_request(); |
3907 | } | 3886 | } |
3908 | } | 3887 | } |
@@ -3934,21 +3913,21 @@ static char __init get_fdc_version(void) | |||
3934 | output_byte(FD_DUMPREGS); /* 82072 and better know DUMPREGS */ | 3913 | output_byte(FD_DUMPREGS); /* 82072 and better know DUMPREGS */ |
3935 | if (FDCS->reset) | 3914 | if (FDCS->reset) |
3936 | return FDC_NONE; | 3915 | return FDC_NONE; |
3937 | if ((r = result()) <= 0x00) | 3916 | r = result(); |
3917 | if (r <= 0x00) | ||
3938 | return FDC_NONE; /* No FDC present ??? */ | 3918 | return FDC_NONE; /* No FDC present ??? */ |
3939 | if ((r == 1) && (reply_buffer[0] == 0x80)) { | 3919 | if ((r == 1) && (reply_buffer[0] == 0x80)) { |
3940 | printk(KERN_INFO "FDC %d is an 8272A\n", fdc); | 3920 | pr_info("FDC %d is an 8272A\n", fdc); |
3941 | return FDC_8272A; /* 8272a/765 don't know DUMPREGS */ | 3921 | return FDC_8272A; /* 8272a/765 don't know DUMPREGS */ |
3942 | } | 3922 | } |
3943 | if (r != 10) { | 3923 | if (r != 10) { |
3944 | printk | 3924 | pr_info("FDC %d init: DUMPREGS: unexpected return of %d bytes.\n", |
3945 | ("FDC %d init: DUMPREGS: unexpected return of %d bytes.\n", | 3925 | fdc, r); |
3946 | fdc, r); | ||
3947 | return FDC_UNKNOWN; | 3926 | return FDC_UNKNOWN; |
3948 | } | 3927 | } |
3949 | 3928 | ||
3950 | if (!fdc_configure()) { | 3929 | if (!fdc_configure()) { |
3951 | printk(KERN_INFO "FDC %d is an 82072\n", fdc); | 3930 | pr_info("FDC %d is an 82072\n", fdc); |
3952 | return FDC_82072; /* 82072 doesn't know CONFIGURE */ | 3931 | return FDC_82072; /* 82072 doesn't know CONFIGURE */ |
3953 | } | 3932 | } |
3954 | 3933 | ||
@@ -3956,52 +3935,50 @@ static char __init get_fdc_version(void) | |||
3956 | if (need_more_output() == MORE_OUTPUT) { | 3935 | if (need_more_output() == MORE_OUTPUT) { |
3957 | output_byte(0); | 3936 | output_byte(0); |
3958 | } else { | 3937 | } else { |
3959 | printk(KERN_INFO "FDC %d is an 82072A\n", fdc); | 3938 | pr_info("FDC %d is an 82072A\n", fdc); |
3960 | return FDC_82072A; /* 82072A as found on Sparcs. */ | 3939 | return FDC_82072A; /* 82072A as found on Sparcs. */ |
3961 | } | 3940 | } |
3962 | 3941 | ||
3963 | output_byte(FD_UNLOCK); | 3942 | output_byte(FD_UNLOCK); |
3964 | r = result(); | 3943 | r = result(); |
3965 | if ((r == 1) && (reply_buffer[0] == 0x80)) { | 3944 | if ((r == 1) && (reply_buffer[0] == 0x80)) { |
3966 | printk(KERN_INFO "FDC %d is a pre-1991 82077\n", fdc); | 3945 | pr_info("FDC %d is a pre-1991 82077\n", fdc); |
3967 | return FDC_82077_ORIG; /* Pre-1991 82077, doesn't know | 3946 | return FDC_82077_ORIG; /* Pre-1991 82077, doesn't know |
3968 | * LOCK/UNLOCK */ | 3947 | * LOCK/UNLOCK */ |
3969 | } | 3948 | } |
3970 | if ((r != 1) || (reply_buffer[0] != 0x00)) { | 3949 | if ((r != 1) || (reply_buffer[0] != 0x00)) { |
3971 | printk("FDC %d init: UNLOCK: unexpected return of %d bytes.\n", | 3950 | pr_info("FDC %d init: UNLOCK: unexpected return of %d bytes.\n", |
3972 | fdc, r); | 3951 | fdc, r); |
3973 | return FDC_UNKNOWN; | 3952 | return FDC_UNKNOWN; |
3974 | } | 3953 | } |
3975 | output_byte(FD_PARTID); | 3954 | output_byte(FD_PARTID); |
3976 | r = result(); | 3955 | r = result(); |
3977 | if (r != 1) { | 3956 | if (r != 1) { |
3978 | printk("FDC %d init: PARTID: unexpected return of %d bytes.\n", | 3957 | pr_info("FDC %d init: PARTID: unexpected return of %d bytes.\n", |
3979 | fdc, r); | 3958 | fdc, r); |
3980 | return FDC_UNKNOWN; | 3959 | return FDC_UNKNOWN; |
3981 | } | 3960 | } |
3982 | if (reply_buffer[0] == 0x80) { | 3961 | if (reply_buffer[0] == 0x80) { |
3983 | printk(KERN_INFO "FDC %d is a post-1991 82077\n", fdc); | 3962 | pr_info("FDC %d is a post-1991 82077\n", fdc); |
3984 | return FDC_82077; /* Revised 82077AA passes all the tests */ | 3963 | return FDC_82077; /* Revised 82077AA passes all the tests */ |
3985 | } | 3964 | } |
3986 | switch (reply_buffer[0] >> 5) { | 3965 | switch (reply_buffer[0] >> 5) { |
3987 | case 0x0: | 3966 | case 0x0: |
3988 | /* Either a 82078-1 or a 82078SL running at 5Volt */ | 3967 | /* Either a 82078-1 or a 82078SL running at 5Volt */ |
3989 | printk(KERN_INFO "FDC %d is an 82078.\n", fdc); | 3968 | pr_info("FDC %d is an 82078.\n", fdc); |
3990 | return FDC_82078; | 3969 | return FDC_82078; |
3991 | case 0x1: | 3970 | case 0x1: |
3992 | printk(KERN_INFO "FDC %d is a 44pin 82078\n", fdc); | 3971 | pr_info("FDC %d is a 44pin 82078\n", fdc); |
3993 | return FDC_82078; | 3972 | return FDC_82078; |
3994 | case 0x2: | 3973 | case 0x2: |
3995 | printk(KERN_INFO "FDC %d is a S82078B\n", fdc); | 3974 | pr_info("FDC %d is a S82078B\n", fdc); |
3996 | return FDC_S82078B; | 3975 | return FDC_S82078B; |
3997 | case 0x3: | 3976 | case 0x3: |
3998 | printk(KERN_INFO "FDC %d is a National Semiconductor PC87306\n", | 3977 | pr_info("FDC %d is a National Semiconductor PC87306\n", fdc); |
3999 | fdc); | ||
4000 | return FDC_87306; | 3978 | return FDC_87306; |
4001 | default: | 3979 | default: |
4002 | printk(KERN_INFO | 3980 | pr_info("FDC %d init: 82078 variant with unknown PARTID=%d.\n", |
4003 | "FDC %d init: 82078 variant with unknown PARTID=%d.\n", | 3981 | fdc, reply_buffer[0] >> 5); |
4004 | fdc, reply_buffer[0] >> 5); | ||
4005 | return FDC_82078_UNKN; | 3982 | return FDC_82078_UNKN; |
4006 | } | 3983 | } |
4007 | } /* get_fdc_version */ | 3984 | } /* get_fdc_version */ |
@@ -4113,9 +4090,9 @@ static int __init floppy_setup(char *str) | |||
4113 | else | 4090 | else |
4114 | param = config_params[i].def_param; | 4091 | param = config_params[i].def_param; |
4115 | if (config_params[i].fn) | 4092 | if (config_params[i].fn) |
4116 | config_params[i]. | 4093 | config_params[i].fn(ints, param, |
4117 | fn(ints, param, | 4094 | config_params[i]. |
4118 | config_params[i].param2); | 4095 | param2); |
4119 | if (config_params[i].var) { | 4096 | if (config_params[i].var) { |
4120 | DPRINT("%s=%d\n", str, param); | 4097 | DPRINT("%s=%d\n", str, param); |
4121 | *config_params[i].var = param; | 4098 | *config_params[i].var = param; |
@@ -4129,8 +4106,8 @@ static int __init floppy_setup(char *str) | |||
4129 | 4106 | ||
4130 | DPRINT("allowed options are:"); | 4107 | DPRINT("allowed options are:"); |
4131 | for (i = 0; i < ARRAY_SIZE(config_params); i++) | 4108 | for (i = 0; i < ARRAY_SIZE(config_params); i++) |
4132 | printk(" %s", config_params[i].name); | 4109 | pr_cont(" %s", config_params[i].name); |
4133 | printk("\n"); | 4110 | pr_cont("\n"); |
4134 | } else | 4111 | } else |
4135 | DPRINT("botched floppy option\n"); | 4112 | DPRINT("botched floppy option\n"); |
4136 | DPRINT("Read Documentation/blockdev/floppy.txt\n"); | 4113 | DPRINT("Read Documentation/blockdev/floppy.txt\n"); |
@@ -4148,7 +4125,8 @@ static ssize_t floppy_cmos_show(struct device *dev, | |||
4148 | drive = p->id; | 4125 | drive = p->id; |
4149 | return sprintf(buf, "%X\n", UDP->cmos); | 4126 | return sprintf(buf, "%X\n", UDP->cmos); |
4150 | } | 4127 | } |
4151 | DEVICE_ATTR(cmos,S_IRUGO,floppy_cmos_show,NULL); | 4128 | |
4129 | DEVICE_ATTR(cmos, S_IRUGO, floppy_cmos_show, NULL); | ||
4152 | 4130 | ||
4153 | static void floppy_device_release(struct device *dev) | 4131 | static void floppy_device_release(struct device *dev) |
4154 | { | 4132 | { |
@@ -4160,7 +4138,7 @@ static int floppy_resume(struct device *dev) | |||
4160 | 4138 | ||
4161 | for (fdc = 0; fdc < N_FDC; fdc++) | 4139 | for (fdc = 0; fdc < N_FDC; fdc++) |
4162 | if (FDCS->address != -1) | 4140 | if (FDCS->address != -1) |
4163 | user_reset_fdc(-1, FD_RESET_ALWAYS, 0); | 4141 | user_reset_fdc(-1, FD_RESET_ALWAYS, false); |
4164 | 4142 | ||
4165 | return 0; | 4143 | return 0; |
4166 | } | 4144 | } |
@@ -4172,8 +4150,8 @@ static const struct dev_pm_ops floppy_pm_ops = { | |||
4172 | 4150 | ||
4173 | static struct platform_driver floppy_driver = { | 4151 | static struct platform_driver floppy_driver = { |
4174 | .driver = { | 4152 | .driver = { |
4175 | .name = "floppy", | 4153 | .name = "floppy", |
4176 | .pm = &floppy_pm_ops, | 4154 | .pm = &floppy_pm_ops, |
4177 | }, | 4155 | }, |
4178 | }; | 4156 | }; |
4179 | 4157 | ||
@@ -4245,16 +4223,16 @@ static int __init floppy_init(void) | |||
4245 | else | 4223 | else |
4246 | floppy_sizes[i] = MAX_DISK_SIZE << 1; | 4224 | floppy_sizes[i] = MAX_DISK_SIZE << 1; |
4247 | 4225 | ||
4248 | reschedule_timeout(MAXTIMEOUT, "floppy init", MAXTIMEOUT); | 4226 | reschedule_timeout(MAXTIMEOUT, "floppy init"); |
4249 | config_types(); | 4227 | config_types(); |
4250 | 4228 | ||
4251 | for (i = 0; i < N_FDC; i++) { | 4229 | for (i = 0; i < N_FDC; i++) { |
4252 | fdc = i; | 4230 | fdc = i; |
4253 | CLEARSTRUCT(FDCS); | 4231 | memset(FDCS, 0, sizeof(*FDCS)); |
4254 | FDCS->dtr = -1; | 4232 | FDCS->dtr = -1; |
4255 | FDCS->dor = 0x4; | 4233 | FDCS->dor = 0x4; |
4256 | #if defined(__sparc__) || defined(__mc68000__) | 4234 | #if defined(__sparc__) || defined(__mc68000__) |
4257 | /*sparcs/sun3x don't have a DOR reset which we can fall back on to */ | 4235 | /*sparcs/sun3x don't have a DOR reset which we can fall back on to */ |
4258 | #ifdef __mc68000__ | 4236 | #ifdef __mc68000__ |
4259 | if (MACH_IS_SUN3X) | 4237 | if (MACH_IS_SUN3X) |
4260 | #endif | 4238 | #endif |
@@ -4283,11 +4261,11 @@ static int __init floppy_init(void) | |||
4283 | 4261 | ||
4284 | /* initialise drive state */ | 4262 | /* initialise drive state */ |
4285 | for (drive = 0; drive < N_DRIVE; drive++) { | 4263 | for (drive = 0; drive < N_DRIVE; drive++) { |
4286 | CLEARSTRUCT(UDRS); | 4264 | memset(UDRS, 0, sizeof(*UDRS)); |
4287 | CLEARSTRUCT(UDRWE); | 4265 | memset(UDRWE, 0, sizeof(*UDRWE)); |
4288 | USETF(FD_DISK_NEWCHANGE); | 4266 | set_bit(FD_DISK_NEWCHANGE_BIT, &UDRS->flags); |
4289 | USETF(FD_DISK_CHANGED); | 4267 | set_bit(FD_DISK_CHANGED_BIT, &UDRS->flags); |
4290 | USETF(FD_VERIFY); | 4268 | set_bit(FD_VERIFY_BIT, &UDRS->flags); |
4291 | UDRS->fd_device = -1; | 4269 | UDRS->fd_device = -1; |
4292 | floppy_track_buffer = NULL; | 4270 | floppy_track_buffer = NULL; |
4293 | max_buffer_sectors = 0; | 4271 | max_buffer_sectors = 0; |
@@ -4307,7 +4285,7 @@ static int __init floppy_init(void) | |||
4307 | if (FDCS->address == -1) | 4285 | if (FDCS->address == -1) |
4308 | continue; | 4286 | continue; |
4309 | FDCS->rawcmd = 2; | 4287 | FDCS->rawcmd = 2; |
4310 | if (user_reset_fdc(-1, FD_RESET_ALWAYS, 0)) { | 4288 | if (user_reset_fdc(-1, FD_RESET_ALWAYS, false)) { |
4311 | /* free ioports reserved by floppy_grab_irq_and_dma() */ | 4289 | /* free ioports reserved by floppy_grab_irq_and_dma() */ |
4312 | floppy_release_regions(fdc); | 4290 | floppy_release_regions(fdc); |
4313 | FDCS->address = -1; | 4291 | FDCS->address = -1; |
@@ -4330,12 +4308,12 @@ static int __init floppy_init(void) | |||
4330 | * properly, so force a reset for the standard FDC clones, | 4308 | * properly, so force a reset for the standard FDC clones, |
4331 | * to avoid interrupt garbage. | 4309 | * to avoid interrupt garbage. |
4332 | */ | 4310 | */ |
4333 | user_reset_fdc(-1, FD_RESET_ALWAYS, 0); | 4311 | user_reset_fdc(-1, FD_RESET_ALWAYS, false); |
4334 | } | 4312 | } |
4335 | fdc = 0; | 4313 | fdc = 0; |
4336 | del_timer(&fd_timeout); | 4314 | del_timer(&fd_timeout); |
4337 | current_drive = 0; | 4315 | current_drive = 0; |
4338 | initialising = 0; | 4316 | initialized = true; |
4339 | if (have_no_fdc) { | 4317 | if (have_no_fdc) { |
4340 | DPRINT("no floppy controllers found\n"); | 4318 | DPRINT("no floppy controllers found\n"); |
4341 | err = have_no_fdc; | 4319 | err = have_no_fdc; |
@@ -4356,7 +4334,8 @@ static int __init floppy_init(void) | |||
4356 | if (err) | 4334 | if (err) |
4357 | goto out_flush_work; | 4335 | goto out_flush_work; |
4358 | 4336 | ||
4359 | err = device_create_file(&floppy_device[drive].dev,&dev_attr_cmos); | 4337 | err = device_create_file(&floppy_device[drive].dev, |
4338 | &dev_attr_cmos); | ||
4360 | if (err) | 4339 | if (err) |
4361 | goto out_unreg_platform_dev; | 4340 | goto out_unreg_platform_dev; |
4362 | 4341 | ||
@@ -4420,8 +4399,10 @@ static int floppy_request_regions(int fdc) | |||
4420 | const struct io_region *p; | 4399 | const struct io_region *p; |
4421 | 4400 | ||
4422 | for (p = io_regions; p < ARRAY_END(io_regions); p++) { | 4401 | for (p = io_regions; p < ARRAY_END(io_regions); p++) { |
4423 | if (!request_region(FDCS->address + p->offset, p->size, "floppy")) { | 4402 | if (!request_region(FDCS->address + p->offset, |
4424 | DPRINT("Floppy io-port 0x%04lx in use\n", FDCS->address + p->offset); | 4403 | p->size, "floppy")) { |
4404 | DPRINT("Floppy io-port 0x%04lx in use\n", | ||
4405 | FDCS->address + p->offset); | ||
4425 | floppy_release_allocated_regions(fdc, p); | 4406 | floppy_release_allocated_regions(fdc, p); |
4426 | return -EBUSY; | 4407 | return -EBUSY; |
4427 | } | 4408 | } |
@@ -4512,11 +4493,9 @@ cleanup: | |||
4512 | static void floppy_release_irq_and_dma(void) | 4493 | static void floppy_release_irq_and_dma(void) |
4513 | { | 4494 | { |
4514 | int old_fdc; | 4495 | int old_fdc; |
4515 | #ifdef FLOPPY_SANITY_CHECK | ||
4516 | #ifndef __sparc__ | 4496 | #ifndef __sparc__ |
4517 | int drive; | 4497 | int drive; |
4518 | #endif | 4498 | #endif |
4519 | #endif | ||
4520 | long tmpsize; | 4499 | long tmpsize; |
4521 | unsigned long tmpaddr; | 4500 | unsigned long tmpaddr; |
4522 | unsigned long flags; | 4501 | unsigned long flags; |
@@ -4547,20 +4526,18 @@ static void floppy_release_irq_and_dma(void) | |||
4547 | buffer_min = buffer_max = -1; | 4526 | buffer_min = buffer_max = -1; |
4548 | fd_dma_mem_free(tmpaddr, tmpsize); | 4527 | fd_dma_mem_free(tmpaddr, tmpsize); |
4549 | } | 4528 | } |
4550 | #ifdef FLOPPY_SANITY_CHECK | ||
4551 | #ifndef __sparc__ | 4529 | #ifndef __sparc__ |
4552 | for (drive = 0; drive < N_FDC * 4; drive++) | 4530 | for (drive = 0; drive < N_FDC * 4; drive++) |
4553 | if (timer_pending(motor_off_timer + drive)) | 4531 | if (timer_pending(motor_off_timer + drive)) |
4554 | printk("motor off timer %d still active\n", drive); | 4532 | pr_info("motor off timer %d still active\n", drive); |
4555 | #endif | 4533 | #endif |
4556 | 4534 | ||
4557 | if (timer_pending(&fd_timeout)) | 4535 | if (timer_pending(&fd_timeout)) |
4558 | printk("floppy timer still active:%s\n", timeout_message); | 4536 | pr_info("floppy timer still active:%s\n", timeout_message); |
4559 | if (timer_pending(&fd_timer)) | 4537 | if (timer_pending(&fd_timer)) |
4560 | printk("auxiliary floppy timer still active\n"); | 4538 | pr_info("auxiliary floppy timer still active\n"); |
4561 | if (work_pending(&floppy_work)) | 4539 | if (work_pending(&floppy_work)) |
4562 | printk("work still pending\n"); | 4540 | pr_info("work still pending\n"); |
4563 | #endif | ||
4564 | old_fdc = fdc; | 4541 | old_fdc = fdc; |
4565 | for (fdc = 0; fdc < N_FDC; fdc++) | 4542 | for (fdc = 0; fdc < N_FDC; fdc++) |
4566 | if (FDCS->address != -1) | 4543 | if (FDCS->address != -1) |
@@ -4577,7 +4554,9 @@ static void __init parse_floppy_cfg_string(char *cfg) | |||
4577 | char *ptr; | 4554 | char *ptr; |
4578 | 4555 | ||
4579 | while (*cfg) { | 4556 | while (*cfg) { |
4580 | for (ptr = cfg; *cfg && *cfg != ' ' && *cfg != '\t'; cfg++) ; | 4557 | ptr = cfg; |
4558 | while (*cfg && *cfg != ' ' && *cfg != '\t') | ||
4559 | cfg++; | ||
4581 | if (*cfg) { | 4560 | if (*cfg) { |
4582 | *cfg = '\0'; | 4561 | *cfg = '\0'; |
4583 | cfg++; | 4562 | cfg++; |
@@ -4625,6 +4604,7 @@ static void __exit floppy_module_exit(void) | |||
4625 | /* eject disk, if any */ | 4604 | /* eject disk, if any */ |
4626 | fd_eject(0); | 4605 | fd_eject(0); |
4627 | } | 4606 | } |
4607 | |||
4628 | module_exit(floppy_module_exit); | 4608 | module_exit(floppy_module_exit); |
4629 | 4609 | ||
4630 | module_param(floppy, charp, 0); | 4610 | module_param(floppy, charp, 0); |
@@ -4636,9 +4616,10 @@ MODULE_LICENSE("GPL"); | |||
4636 | 4616 | ||
4637 | /* This doesn't actually get used other than for module information */ | 4617 | /* This doesn't actually get used other than for module information */ |
4638 | static const struct pnp_device_id floppy_pnpids[] = { | 4618 | static const struct pnp_device_id floppy_pnpids[] = { |
4639 | { "PNP0700", 0 }, | 4619 | {"PNP0700", 0}, |
4640 | { } | 4620 | {} |
4641 | }; | 4621 | }; |
4622 | |||
4642 | MODULE_DEVICE_TABLE(pnp, floppy_pnpids); | 4623 | MODULE_DEVICE_TABLE(pnp, floppy_pnpids); |
4643 | 4624 | ||
4644 | #else | 4625 | #else |
diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c index a808b1530b3b..eb2091aa1c19 100644 --- a/drivers/block/osdblk.c +++ b/drivers/block/osdblk.c | |||
@@ -476,7 +476,9 @@ static void class_osdblk_release(struct class *cls) | |||
476 | kfree(cls); | 476 | kfree(cls); |
477 | } | 477 | } |
478 | 478 | ||
479 | static ssize_t class_osdblk_list(struct class *c, char *data) | 479 | static ssize_t class_osdblk_list(struct class *c, |
480 | struct class_attribute *attr, | ||
481 | char *data) | ||
480 | { | 482 | { |
481 | int n = 0; | 483 | int n = 0; |
482 | struct list_head *tmp; | 484 | struct list_head *tmp; |
@@ -500,7 +502,9 @@ static ssize_t class_osdblk_list(struct class *c, char *data) | |||
500 | return n; | 502 | return n; |
501 | } | 503 | } |
502 | 504 | ||
503 | static ssize_t class_osdblk_add(struct class *c, const char *buf, size_t count) | 505 | static ssize_t class_osdblk_add(struct class *c, |
506 | struct class_attribute *attr, | ||
507 | const char *buf, size_t count) | ||
504 | { | 508 | { |
505 | struct osdblk_device *osdev; | 509 | struct osdblk_device *osdev; |
506 | ssize_t rc; | 510 | ssize_t rc; |
@@ -592,7 +596,9 @@ err_out_mod: | |||
592 | return rc; | 596 | return rc; |
593 | } | 597 | } |
594 | 598 | ||
595 | static ssize_t class_osdblk_remove(struct class *c, const char *buf, | 599 | static ssize_t class_osdblk_remove(struct class *c, |
600 | struct class_attribute *attr, | ||
601 | const char *buf, | ||
596 | size_t count) | 602 | size_t count) |
597 | { | 603 | { |
598 | struct osdblk_device *osdev = NULL; | 604 | struct osdblk_device *osdev = NULL; |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index b72935b8f203..39c8514442eb 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -284,7 +284,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj, | |||
284 | return len; | 284 | return len; |
285 | } | 285 | } |
286 | 286 | ||
287 | static struct sysfs_ops kobj_pkt_ops = { | 287 | static const struct sysfs_ops kobj_pkt_ops = { |
288 | .show = kobj_pkt_show, | 288 | .show = kobj_pkt_show, |
289 | .store = kobj_pkt_store | 289 | .store = kobj_pkt_store |
290 | }; | 290 | }; |
@@ -337,7 +337,9 @@ static void class_pktcdvd_release(struct class *cls) | |||
337 | { | 337 | { |
338 | kfree(cls); | 338 | kfree(cls); |
339 | } | 339 | } |
340 | static ssize_t class_pktcdvd_show_map(struct class *c, char *data) | 340 | static ssize_t class_pktcdvd_show_map(struct class *c, |
341 | struct class_attribute *attr, | ||
342 | char *data) | ||
341 | { | 343 | { |
342 | int n = 0; | 344 | int n = 0; |
343 | int idx; | 345 | int idx; |
@@ -356,7 +358,9 @@ static ssize_t class_pktcdvd_show_map(struct class *c, char *data) | |||
356 | return n; | 358 | return n; |
357 | } | 359 | } |
358 | 360 | ||
359 | static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf, | 361 | static ssize_t class_pktcdvd_store_add(struct class *c, |
362 | struct class_attribute *attr, | ||
363 | const char *buf, | ||
360 | size_t count) | 364 | size_t count) |
361 | { | 365 | { |
362 | unsigned int major, minor; | 366 | unsigned int major, minor; |
@@ -376,7 +380,9 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf, | |||
376 | return -EINVAL; | 380 | return -EINVAL; |
377 | } | 381 | } |
378 | 382 | ||
379 | static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf, | 383 | static ssize_t class_pktcdvd_store_remove(struct class *c, |
384 | struct class_attribute *attr, | ||
385 | const char *buf, | ||
380 | size_t count) | 386 | size_t count) |
381 | { | 387 | { |
382 | unsigned int major, minor; | 388 | unsigned int major, minor; |
diff --git a/drivers/char/hvc_iucv.c b/drivers/char/hvc_iucv.c index 21681a81cc35..37b0542a4eeb 100644 --- a/drivers/char/hvc_iucv.c +++ b/drivers/char/hvc_iucv.c | |||
@@ -139,6 +139,8 @@ struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) | |||
139 | * | 139 | * |
140 | * This function allocates a new struct iucv_tty_buffer element and, optionally, | 140 | * This function allocates a new struct iucv_tty_buffer element and, optionally, |
141 | * allocates an internal data buffer with the specified size @size. | 141 | * allocates an internal data buffer with the specified size @size. |
142 | * The internal data buffer is always allocated with GFP_DMA which is | ||
143 | * required for receiving and sending data with IUCV. | ||
142 | * Note: The total message size arises from the internal buffer size and the | 144 | * Note: The total message size arises from the internal buffer size and the |
143 | * members of the iucv_tty_msg structure. | 145 | * members of the iucv_tty_msg structure. |
144 | * The function returns NULL if memory allocation has failed. | 146 | * The function returns NULL if memory allocation has failed. |
@@ -154,7 +156,7 @@ static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags) | |||
154 | 156 | ||
155 | if (size > 0) { | 157 | if (size > 0) { |
156 | bufp->msg.length = MSG_SIZE(size); | 158 | bufp->msg.length = MSG_SIZE(size); |
157 | bufp->mbuf = kmalloc(bufp->msg.length, flags); | 159 | bufp->mbuf = kmalloc(bufp->msg.length, flags | GFP_DMA); |
158 | if (!bufp->mbuf) { | 160 | if (!bufp->mbuf) { |
159 | mempool_free(bufp, hvc_iucv_mempool); | 161 | mempool_free(bufp, hvc_iucv_mempool); |
160 | return NULL; | 162 | return NULL; |
@@ -237,7 +239,7 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv, | |||
237 | if (!rb->mbuf) { /* message not yet received ... */ | 239 | if (!rb->mbuf) { /* message not yet received ... */ |
238 | /* allocate mem to store msg data; if no memory is available | 240 | /* allocate mem to store msg data; if no memory is available |
239 | * then leave the buffer on the list and re-try later */ | 241 | * then leave the buffer on the list and re-try later */ |
240 | rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC); | 242 | rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC | GFP_DMA); |
241 | if (!rb->mbuf) | 243 | if (!rb->mbuf) |
242 | return -ENOMEM; | 244 | return -ENOMEM; |
243 | 245 | ||
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 176f1751237f..4462b113ba3f 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -295,6 +295,9 @@ struct smi_info { | |||
295 | static int force_kipmid[SI_MAX_PARMS]; | 295 | static int force_kipmid[SI_MAX_PARMS]; |
296 | static int num_force_kipmid; | 296 | static int num_force_kipmid; |
297 | 297 | ||
298 | static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; | ||
299 | static int num_max_busy_us; | ||
300 | |||
298 | static int unload_when_empty = 1; | 301 | static int unload_when_empty = 1; |
299 | 302 | ||
300 | static int try_smi_init(struct smi_info *smi); | 303 | static int try_smi_init(struct smi_info *smi); |
@@ -925,23 +928,77 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion) | |||
925 | } | 928 | } |
926 | } | 929 | } |
927 | 930 | ||
931 | /* | ||
932 | * Use -1 in the nsec value of the busy waiting timespec to tell that | ||
933 | * we are spinning in kipmid looking for something and not delaying | ||
934 | * between checks | ||
935 | */ | ||
936 | static inline void ipmi_si_set_not_busy(struct timespec *ts) | ||
937 | { | ||
938 | ts->tv_nsec = -1; | ||
939 | } | ||
940 | static inline int ipmi_si_is_busy(struct timespec *ts) | ||
941 | { | ||
942 | return ts->tv_nsec != -1; | ||
943 | } | ||
944 | |||
945 | static int ipmi_thread_busy_wait(enum si_sm_result smi_result, | ||
946 | const struct smi_info *smi_info, | ||
947 | struct timespec *busy_until) | ||
948 | { | ||
949 | unsigned int max_busy_us = 0; | ||
950 | |||
951 | if (smi_info->intf_num < num_max_busy_us) | ||
952 | max_busy_us = kipmid_max_busy_us[smi_info->intf_num]; | ||
953 | if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY) | ||
954 | ipmi_si_set_not_busy(busy_until); | ||
955 | else if (!ipmi_si_is_busy(busy_until)) { | ||
956 | getnstimeofday(busy_until); | ||
957 | timespec_add_ns(busy_until, max_busy_us*NSEC_PER_USEC); | ||
958 | } else { | ||
959 | struct timespec now; | ||
960 | getnstimeofday(&now); | ||
961 | if (unlikely(timespec_compare(&now, busy_until) > 0)) { | ||
962 | ipmi_si_set_not_busy(busy_until); | ||
963 | return 0; | ||
964 | } | ||
965 | } | ||
966 | return 1; | ||
967 | } | ||
968 | |||
969 | |||
970 | /* | ||
971 | * A busy-waiting loop for speeding up IPMI operation. | ||
972 | * | ||
973 | * Lousy hardware makes this hard. This is only enabled for systems | ||
974 | * that are not BT and do not have interrupts. It starts spinning | ||
975 | * when an operation is complete or until max_busy tells it to stop | ||
976 | * (if that is enabled). See the paragraph on kimid_max_busy_us in | ||
977 | * Documentation/IPMI.txt for details. | ||
978 | */ | ||
928 | static int ipmi_thread(void *data) | 979 | static int ipmi_thread(void *data) |
929 | { | 980 | { |
930 | struct smi_info *smi_info = data; | 981 | struct smi_info *smi_info = data; |
931 | unsigned long flags; | 982 | unsigned long flags; |
932 | enum si_sm_result smi_result; | 983 | enum si_sm_result smi_result; |
984 | struct timespec busy_until; | ||
933 | 985 | ||
986 | ipmi_si_set_not_busy(&busy_until); | ||
934 | set_user_nice(current, 19); | 987 | set_user_nice(current, 19); |
935 | while (!kthread_should_stop()) { | 988 | while (!kthread_should_stop()) { |
989 | int busy_wait; | ||
990 | |||
936 | spin_lock_irqsave(&(smi_info->si_lock), flags); | 991 | spin_lock_irqsave(&(smi_info->si_lock), flags); |
937 | smi_result = smi_event_handler(smi_info, 0); | 992 | smi_result = smi_event_handler(smi_info, 0); |
938 | spin_unlock_irqrestore(&(smi_info->si_lock), flags); | 993 | spin_unlock_irqrestore(&(smi_info->si_lock), flags); |
994 | busy_wait = ipmi_thread_busy_wait(smi_result, smi_info, | ||
995 | &busy_until); | ||
939 | if (smi_result == SI_SM_CALL_WITHOUT_DELAY) | 996 | if (smi_result == SI_SM_CALL_WITHOUT_DELAY) |
940 | ; /* do nothing */ | 997 | ; /* do nothing */ |
941 | else if (smi_result == SI_SM_CALL_WITH_DELAY) | 998 | else if (smi_result == SI_SM_CALL_WITH_DELAY && busy_wait) |
942 | schedule(); | 999 | schedule(); |
943 | else | 1000 | else |
944 | schedule_timeout_interruptible(1); | 1001 | schedule_timeout_interruptible(0); |
945 | } | 1002 | } |
946 | return 0; | 1003 | return 0; |
947 | } | 1004 | } |
@@ -1144,7 +1201,7 @@ static int regsizes[SI_MAX_PARMS]; | |||
1144 | static unsigned int num_regsizes; | 1201 | static unsigned int num_regsizes; |
1145 | static int regshifts[SI_MAX_PARMS]; | 1202 | static int regshifts[SI_MAX_PARMS]; |
1146 | static unsigned int num_regshifts; | 1203 | static unsigned int num_regshifts; |
1147 | static int slave_addrs[SI_MAX_PARMS]; | 1204 | static int slave_addrs[SI_MAX_PARMS]; /* Leaving 0 chooses the default value */ |
1148 | static unsigned int num_slave_addrs; | 1205 | static unsigned int num_slave_addrs; |
1149 | 1206 | ||
1150 | #define IPMI_IO_ADDR_SPACE 0 | 1207 | #define IPMI_IO_ADDR_SPACE 0 |
@@ -1212,6 +1269,11 @@ module_param(unload_when_empty, int, 0); | |||
1212 | MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are" | 1269 | MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are" |
1213 | " specified or found, default is 1. Setting to 0" | 1270 | " specified or found, default is 1. Setting to 0" |
1214 | " is useful for hot add of devices using hotmod."); | 1271 | " is useful for hot add of devices using hotmod."); |
1272 | module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644); | ||
1273 | MODULE_PARM_DESC(kipmid_max_busy_us, | ||
1274 | "Max time (in microseconds) to busy-wait for IPMI data before" | ||
1275 | " sleeping. 0 (default) means to wait forever. Set to 100-500" | ||
1276 | " if kipmid is using up a lot of CPU time."); | ||
1215 | 1277 | ||
1216 | 1278 | ||
1217 | static void std_irq_cleanup(struct smi_info *info) | 1279 | static void std_irq_cleanup(struct smi_info *info) |
@@ -1607,7 +1669,7 @@ static int hotmod_handler(const char *val, struct kernel_param *kp) | |||
1607 | regsize = 1; | 1669 | regsize = 1; |
1608 | regshift = 0; | 1670 | regshift = 0; |
1609 | irq = 0; | 1671 | irq = 0; |
1610 | ipmb = 0x20; | 1672 | ipmb = 0; /* Choose the default if not specified */ |
1611 | 1673 | ||
1612 | next = strchr(curr, ':'); | 1674 | next = strchr(curr, ':'); |
1613 | if (next) { | 1675 | if (next) { |
@@ -1799,6 +1861,7 @@ static __devinit void hardcode_find_bmc(void) | |||
1799 | info->irq = irqs[i]; | 1861 | info->irq = irqs[i]; |
1800 | if (info->irq) | 1862 | if (info->irq) |
1801 | info->irq_setup = std_irq_setup; | 1863 | info->irq_setup = std_irq_setup; |
1864 | info->slave_addr = slave_addrs[i]; | ||
1802 | 1865 | ||
1803 | try_smi_init(info); | 1866 | try_smi_init(info); |
1804 | } | 1867 | } |
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 48788db4e280..1f3215ac085b 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 1991, 1992 Linus Torvalds | 4 | * Copyright (C) 1991, 1992 Linus Torvalds |
5 | * | 5 | * |
6 | * Added devfs support. | 6 | * Added devfs support. |
7 | * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu> | 7 | * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu> |
8 | * Shared /dev/zero mmapping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com> | 8 | * Shared /dev/zero mmapping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com> |
9 | */ | 9 | */ |
@@ -44,36 +44,6 @@ static inline unsigned long size_inside_page(unsigned long start, | |||
44 | return min(sz, size); | 44 | return min(sz, size); |
45 | } | 45 | } |
46 | 46 | ||
47 | /* | ||
48 | * Architectures vary in how they handle caching for addresses | ||
49 | * outside of main memory. | ||
50 | * | ||
51 | */ | ||
52 | static inline int uncached_access(struct file *file, unsigned long addr) | ||
53 | { | ||
54 | #if defined(CONFIG_IA64) | ||
55 | /* | ||
56 | * On ia64, we ignore O_DSYNC because we cannot tolerate memory attribute aliases. | ||
57 | */ | ||
58 | return !(efi_mem_attributes(addr) & EFI_MEMORY_WB); | ||
59 | #elif defined(CONFIG_MIPS) | ||
60 | { | ||
61 | extern int __uncached_access(struct file *file, | ||
62 | unsigned long addr); | ||
63 | |||
64 | return __uncached_access(file, addr); | ||
65 | } | ||
66 | #else | ||
67 | /* | ||
68 | * Accessing memory above the top the kernel knows about or through a file pointer | ||
69 | * that was marked O_DSYNC will be done non-cached. | ||
70 | */ | ||
71 | if (file->f_flags & O_DSYNC) | ||
72 | return 1; | ||
73 | return addr >= __pa(high_memory); | ||
74 | #endif | ||
75 | } | ||
76 | |||
77 | #ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE | 47 | #ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE |
78 | static inline int valid_phys_addr_range(unsigned long addr, size_t count) | 48 | static inline int valid_phys_addr_range(unsigned long addr, size_t count) |
79 | { | 49 | { |
@@ -115,15 +85,15 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size) | |||
115 | } | 85 | } |
116 | #endif | 86 | #endif |
117 | 87 | ||
118 | void __attribute__((weak)) unxlate_dev_mem_ptr(unsigned long phys, void *addr) | 88 | void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr) |
119 | { | 89 | { |
120 | } | 90 | } |
121 | 91 | ||
122 | /* | 92 | /* |
123 | * This funcion reads the *physical* memory. The f_pos points directly to the | 93 | * This funcion reads the *physical* memory. The f_pos points directly to the |
124 | * memory location. | 94 | * memory location. |
125 | */ | 95 | */ |
126 | static ssize_t read_mem(struct file * file, char __user * buf, | 96 | static ssize_t read_mem(struct file *file, char __user *buf, |
127 | size_t count, loff_t *ppos) | 97 | size_t count, loff_t *ppos) |
128 | { | 98 | { |
129 | unsigned long p = *ppos; | 99 | unsigned long p = *ppos; |
@@ -140,10 +110,10 @@ static ssize_t read_mem(struct file * file, char __user * buf, | |||
140 | if (sz > 0) { | 110 | if (sz > 0) { |
141 | if (clear_user(buf, sz)) | 111 | if (clear_user(buf, sz)) |
142 | return -EFAULT; | 112 | return -EFAULT; |
143 | buf += sz; | 113 | buf += sz; |
144 | p += sz; | 114 | p += sz; |
145 | count -= sz; | 115 | count -= sz; |
146 | read += sz; | 116 | read += sz; |
147 | } | 117 | } |
148 | } | 118 | } |
149 | #endif | 119 | #endif |
@@ -157,9 +127,9 @@ static ssize_t read_mem(struct file * file, char __user * buf, | |||
157 | return -EPERM; | 127 | return -EPERM; |
158 | 128 | ||
159 | /* | 129 | /* |
160 | * On ia64 if a page has been mapped somewhere as | 130 | * On ia64 if a page has been mapped somewhere as uncached, then |
161 | * uncached, then it must also be accessed uncached | 131 | * it must also be accessed uncached by the kernel or data |
162 | * by the kernel or data corruption may occur | 132 | * corruption may occur. |
163 | */ | 133 | */ |
164 | ptr = xlate_dev_mem_ptr(p); | 134 | ptr = xlate_dev_mem_ptr(p); |
165 | if (!ptr) | 135 | if (!ptr) |
@@ -180,7 +150,7 @@ static ssize_t read_mem(struct file * file, char __user * buf, | |||
180 | return read; | 150 | return read; |
181 | } | 151 | } |
182 | 152 | ||
183 | static ssize_t write_mem(struct file * file, const char __user * buf, | 153 | static ssize_t write_mem(struct file *file, const char __user *buf, |
184 | size_t count, loff_t *ppos) | 154 | size_t count, loff_t *ppos) |
185 | { | 155 | { |
186 | unsigned long p = *ppos; | 156 | unsigned long p = *ppos; |
@@ -212,9 +182,9 @@ static ssize_t write_mem(struct file * file, const char __user * buf, | |||
212 | return -EPERM; | 182 | return -EPERM; |
213 | 183 | ||
214 | /* | 184 | /* |
215 | * On ia64 if a page has been mapped somewhere as | 185 | * On ia64 if a page has been mapped somewhere as uncached, then |
216 | * uncached, then it must also be accessed uncached | 186 | * it must also be accessed uncached by the kernel or data |
217 | * by the kernel or data corruption may occur | 187 | * corruption may occur. |
218 | */ | 188 | */ |
219 | ptr = xlate_dev_mem_ptr(p); | 189 | ptr = xlate_dev_mem_ptr(p); |
220 | if (!ptr) { | 190 | if (!ptr) { |
@@ -242,13 +212,46 @@ static ssize_t write_mem(struct file * file, const char __user * buf, | |||
242 | return written; | 212 | return written; |
243 | } | 213 | } |
244 | 214 | ||
245 | int __attribute__((weak)) phys_mem_access_prot_allowed(struct file *file, | 215 | int __weak phys_mem_access_prot_allowed(struct file *file, |
246 | unsigned long pfn, unsigned long size, pgprot_t *vma_prot) | 216 | unsigned long pfn, unsigned long size, pgprot_t *vma_prot) |
247 | { | 217 | { |
248 | return 1; | 218 | return 1; |
249 | } | 219 | } |
250 | 220 | ||
251 | #ifndef __HAVE_PHYS_MEM_ACCESS_PROT | 221 | #ifndef __HAVE_PHYS_MEM_ACCESS_PROT |
222 | |||
223 | /* | ||
224 | * Architectures vary in how they handle caching for addresses | ||
225 | * outside of main memory. | ||
226 | * | ||
227 | */ | ||
228 | static int uncached_access(struct file *file, unsigned long addr) | ||
229 | { | ||
230 | #if defined(CONFIG_IA64) | ||
231 | /* | ||
232 | * On ia64, we ignore O_DSYNC because we cannot tolerate memory | ||
233 | * attribute aliases. | ||
234 | */ | ||
235 | return !(efi_mem_attributes(addr) & EFI_MEMORY_WB); | ||
236 | #elif defined(CONFIG_MIPS) | ||
237 | { | ||
238 | extern int __uncached_access(struct file *file, | ||
239 | unsigned long addr); | ||
240 | |||
241 | return __uncached_access(file, addr); | ||
242 | } | ||
243 | #else | ||
244 | /* | ||
245 | * Accessing memory above the top the kernel knows about or through a | ||
246 | * file pointer | ||
247 | * that was marked O_DSYNC will be done non-cached. | ||
248 | */ | ||
249 | if (file->f_flags & O_DSYNC) | ||
250 | return 1; | ||
251 | return addr >= __pa(high_memory); | ||
252 | #endif | ||
253 | } | ||
254 | |||
252 | static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, | 255 | static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, |
253 | unsigned long size, pgprot_t vma_prot) | 256 | unsigned long size, pgprot_t vma_prot) |
254 | { | 257 | { |
@@ -294,7 +297,7 @@ static const struct vm_operations_struct mmap_mem_ops = { | |||
294 | #endif | 297 | #endif |
295 | }; | 298 | }; |
296 | 299 | ||
297 | static int mmap_mem(struct file * file, struct vm_area_struct * vma) | 300 | static int mmap_mem(struct file *file, struct vm_area_struct *vma) |
298 | { | 301 | { |
299 | size_t size = vma->vm_end - vma->vm_start; | 302 | size_t size = vma->vm_end - vma->vm_start; |
300 | 303 | ||
@@ -329,7 +332,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma) | |||
329 | } | 332 | } |
330 | 333 | ||
331 | #ifdef CONFIG_DEVKMEM | 334 | #ifdef CONFIG_DEVKMEM |
332 | static int mmap_kmem(struct file * file, struct vm_area_struct * vma) | 335 | static int mmap_kmem(struct file *file, struct vm_area_struct *vma) |
333 | { | 336 | { |
334 | unsigned long pfn; | 337 | unsigned long pfn; |
335 | 338 | ||
@@ -337,9 +340,9 @@ static int mmap_kmem(struct file * file, struct vm_area_struct * vma) | |||
337 | pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; | 340 | pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; |
338 | 341 | ||
339 | /* | 342 | /* |
340 | * RED-PEN: on some architectures there is more mapped memory | 343 | * RED-PEN: on some architectures there is more mapped memory than |
341 | * than available in mem_map which pfn_valid checks | 344 | * available in mem_map which pfn_valid checks for. Perhaps should add a |
342 | * for. Perhaps should add a new macro here. | 345 | * new macro here. |
343 | * | 346 | * |
344 | * RED-PEN: vmalloc is not supported right now. | 347 | * RED-PEN: vmalloc is not supported right now. |
345 | */ | 348 | */ |
@@ -389,7 +392,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf, | |||
389 | /* | 392 | /* |
390 | * This function reads the *virtual* memory as seen by the kernel. | 393 | * This function reads the *virtual* memory as seen by the kernel. |
391 | */ | 394 | */ |
392 | static ssize_t read_kmem(struct file *file, char __user *buf, | 395 | static ssize_t read_kmem(struct file *file, char __user *buf, |
393 | size_t count, loff_t *ppos) | 396 | size_t count, loff_t *ppos) |
394 | { | 397 | { |
395 | unsigned long p = *ppos; | 398 | unsigned long p = *ppos; |
@@ -400,8 +403,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf, | |||
400 | read = 0; | 403 | read = 0; |
401 | if (p < (unsigned long) high_memory) { | 404 | if (p < (unsigned long) high_memory) { |
402 | low_count = count; | 405 | low_count = count; |
403 | if (count > (unsigned long) high_memory - p) | 406 | if (count > (unsigned long)high_memory - p) |
404 | low_count = (unsigned long) high_memory - p; | 407 | low_count = (unsigned long)high_memory - p; |
405 | 408 | ||
406 | #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED | 409 | #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED |
407 | /* we don't have page 0 mapped on sparc and m68k.. */ | 410 | /* we don't have page 0 mapped on sparc and m68k.. */ |
@@ -465,9 +468,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf, | |||
465 | } | 468 | } |
466 | 469 | ||
467 | 470 | ||
468 | static inline ssize_t | 471 | static ssize_t do_write_kmem(unsigned long p, const char __user *buf, |
469 | do_write_kmem(unsigned long p, const char __user *buf, | 472 | size_t count, loff_t *ppos) |
470 | size_t count, loff_t *ppos) | ||
471 | { | 473 | { |
472 | ssize_t written, sz; | 474 | ssize_t written, sz; |
473 | unsigned long copied; | 475 | unsigned long copied; |
@@ -491,9 +493,9 @@ do_write_kmem(unsigned long p, const char __user *buf, | |||
491 | sz = size_inside_page(p, count); | 493 | sz = size_inside_page(p, count); |
492 | 494 | ||
493 | /* | 495 | /* |
494 | * On ia64 if a page has been mapped somewhere as | 496 | * On ia64 if a page has been mapped somewhere as uncached, then |
495 | * uncached, then it must also be accessed uncached | 497 | * it must also be accessed uncached by the kernel or data |
496 | * by the kernel or data corruption may occur | 498 | * corruption may occur. |
497 | */ | 499 | */ |
498 | ptr = xlate_dev_kmem_ptr((char *)p); | 500 | ptr = xlate_dev_kmem_ptr((char *)p); |
499 | 501 | ||
@@ -514,11 +516,10 @@ do_write_kmem(unsigned long p, const char __user *buf, | |||
514 | return written; | 516 | return written; |
515 | } | 517 | } |
516 | 518 | ||
517 | |||
518 | /* | 519 | /* |
519 | * This function writes to the *virtual* memory as seen by the kernel. | 520 | * This function writes to the *virtual* memory as seen by the kernel. |
520 | */ | 521 | */ |
521 | static ssize_t write_kmem(struct file * file, const char __user * buf, | 522 | static ssize_t write_kmem(struct file *file, const char __user *buf, |
522 | size_t count, loff_t *ppos) | 523 | size_t count, loff_t *ppos) |
523 | { | 524 | { |
524 | unsigned long p = *ppos; | 525 | unsigned long p = *ppos; |
@@ -570,17 +571,17 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, | |||
570 | #endif | 571 | #endif |
571 | 572 | ||
572 | #ifdef CONFIG_DEVPORT | 573 | #ifdef CONFIG_DEVPORT |
573 | static ssize_t read_port(struct file * file, char __user * buf, | 574 | static ssize_t read_port(struct file *file, char __user *buf, |
574 | size_t count, loff_t *ppos) | 575 | size_t count, loff_t *ppos) |
575 | { | 576 | { |
576 | unsigned long i = *ppos; | 577 | unsigned long i = *ppos; |
577 | char __user *tmp = buf; | 578 | char __user *tmp = buf; |
578 | 579 | ||
579 | if (!access_ok(VERIFY_WRITE, buf, count)) | 580 | if (!access_ok(VERIFY_WRITE, buf, count)) |
580 | return -EFAULT; | 581 | return -EFAULT; |
581 | while (count-- > 0 && i < 65536) { | 582 | while (count-- > 0 && i < 65536) { |
582 | if (__put_user(inb(i),tmp) < 0) | 583 | if (__put_user(inb(i), tmp) < 0) |
583 | return -EFAULT; | 584 | return -EFAULT; |
584 | i++; | 585 | i++; |
585 | tmp++; | 586 | tmp++; |
586 | } | 587 | } |
@@ -588,22 +589,22 @@ static ssize_t read_port(struct file * file, char __user * buf, | |||
588 | return tmp-buf; | 589 | return tmp-buf; |
589 | } | 590 | } |
590 | 591 | ||
591 | static ssize_t write_port(struct file * file, const char __user * buf, | 592 | static ssize_t write_port(struct file *file, const char __user *buf, |
592 | size_t count, loff_t *ppos) | 593 | size_t count, loff_t *ppos) |
593 | { | 594 | { |
594 | unsigned long i = *ppos; | 595 | unsigned long i = *ppos; |
595 | const char __user * tmp = buf; | 596 | const char __user * tmp = buf; |
596 | 597 | ||
597 | if (!access_ok(VERIFY_READ,buf,count)) | 598 | if (!access_ok(VERIFY_READ, buf, count)) |
598 | return -EFAULT; | 599 | return -EFAULT; |
599 | while (count-- > 0 && i < 65536) { | 600 | while (count-- > 0 && i < 65536) { |
600 | char c; | 601 | char c; |
601 | if (__get_user(c, tmp)) { | 602 | if (__get_user(c, tmp)) { |
602 | if (tmp > buf) | 603 | if (tmp > buf) |
603 | break; | 604 | break; |
604 | return -EFAULT; | 605 | return -EFAULT; |
605 | } | 606 | } |
606 | outb(c,i); | 607 | outb(c, i); |
607 | i++; | 608 | i++; |
608 | tmp++; | 609 | tmp++; |
609 | } | 610 | } |
@@ -612,13 +613,13 @@ static ssize_t write_port(struct file * file, const char __user * buf, | |||
612 | } | 613 | } |
613 | #endif | 614 | #endif |
614 | 615 | ||
615 | static ssize_t read_null(struct file * file, char __user * buf, | 616 | static ssize_t read_null(struct file *file, char __user *buf, |
616 | size_t count, loff_t *ppos) | 617 | size_t count, loff_t *ppos) |
617 | { | 618 | { |
618 | return 0; | 619 | return 0; |
619 | } | 620 | } |
620 | 621 | ||
621 | static ssize_t write_null(struct file * file, const char __user * buf, | 622 | static ssize_t write_null(struct file *file, const char __user *buf, |
622 | size_t count, loff_t *ppos) | 623 | size_t count, loff_t *ppos) |
623 | { | 624 | { |
624 | return count; | 625 | return count; |
@@ -630,13 +631,13 @@ static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf, | |||
630 | return sd->len; | 631 | return sd->len; |
631 | } | 632 | } |
632 | 633 | ||
633 | static ssize_t splice_write_null(struct pipe_inode_info *pipe,struct file *out, | 634 | static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out, |
634 | loff_t *ppos, size_t len, unsigned int flags) | 635 | loff_t *ppos, size_t len, unsigned int flags) |
635 | { | 636 | { |
636 | return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null); | 637 | return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null); |
637 | } | 638 | } |
638 | 639 | ||
639 | static ssize_t read_zero(struct file * file, char __user * buf, | 640 | static ssize_t read_zero(struct file *file, char __user *buf, |
640 | size_t count, loff_t *ppos) | 641 | size_t count, loff_t *ppos) |
641 | { | 642 | { |
642 | size_t written; | 643 | size_t written; |
@@ -667,7 +668,7 @@ static ssize_t read_zero(struct file * file, char __user * buf, | |||
667 | return written ? written : -EFAULT; | 668 | return written ? written : -EFAULT; |
668 | } | 669 | } |
669 | 670 | ||
670 | static int mmap_zero(struct file * file, struct vm_area_struct * vma) | 671 | static int mmap_zero(struct file *file, struct vm_area_struct *vma) |
671 | { | 672 | { |
672 | #ifndef CONFIG_MMU | 673 | #ifndef CONFIG_MMU |
673 | return -ENOSYS; | 674 | return -ENOSYS; |
@@ -677,7 +678,7 @@ static int mmap_zero(struct file * file, struct vm_area_struct * vma) | |||
677 | return 0; | 678 | return 0; |
678 | } | 679 | } |
679 | 680 | ||
680 | static ssize_t write_full(struct file * file, const char __user * buf, | 681 | static ssize_t write_full(struct file *file, const char __user *buf, |
681 | size_t count, loff_t *ppos) | 682 | size_t count, loff_t *ppos) |
682 | { | 683 | { |
683 | return -ENOSPC; | 684 | return -ENOSPC; |
@@ -688,8 +689,7 @@ static ssize_t write_full(struct file * file, const char __user * buf, | |||
688 | * can fopen() both devices with "a" now. This was previously impossible. | 689 | * can fopen() both devices with "a" now. This was previously impossible. |
689 | * -- SRB. | 690 | * -- SRB. |
690 | */ | 691 | */ |
691 | 692 | static loff_t null_lseek(struct file *file, loff_t offset, int orig) | |
692 | static loff_t null_lseek(struct file * file, loff_t offset, int orig) | ||
693 | { | 693 | { |
694 | return file->f_pos = 0; | 694 | return file->f_pos = 0; |
695 | } | 695 | } |
@@ -702,24 +702,31 @@ static loff_t null_lseek(struct file * file, loff_t offset, int orig) | |||
702 | * also note that seeking relative to the "end of file" isn't supported: | 702 | * also note that seeking relative to the "end of file" isn't supported: |
703 | * it has no meaning, so it returns -EINVAL. | 703 | * it has no meaning, so it returns -EINVAL. |
704 | */ | 704 | */ |
705 | static loff_t memory_lseek(struct file * file, loff_t offset, int orig) | 705 | static loff_t memory_lseek(struct file *file, loff_t offset, int orig) |
706 | { | 706 | { |
707 | loff_t ret; | 707 | loff_t ret; |
708 | 708 | ||
709 | mutex_lock(&file->f_path.dentry->d_inode->i_mutex); | 709 | mutex_lock(&file->f_path.dentry->d_inode->i_mutex); |
710 | switch (orig) { | 710 | switch (orig) { |
711 | case 0: | 711 | case SEEK_CUR: |
712 | file->f_pos = offset; | 712 | offset += file->f_pos; |
713 | ret = file->f_pos; | 713 | if ((unsigned long long)offset < |
714 | force_successful_syscall_return(); | 714 | (unsigned long long)file->f_pos) { |
715 | ret = -EOVERFLOW; | ||
715 | break; | 716 | break; |
716 | case 1: | 717 | } |
717 | file->f_pos += offset; | 718 | case SEEK_SET: |
718 | ret = file->f_pos; | 719 | /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */ |
719 | force_successful_syscall_return(); | 720 | if ((unsigned long long)offset >= ~0xFFFULL) { |
721 | ret = -EOVERFLOW; | ||
720 | break; | 722 | break; |
721 | default: | 723 | } |
722 | ret = -EINVAL; | 724 | file->f_pos = offset; |
725 | ret = file->f_pos; | ||
726 | force_successful_syscall_return(); | ||
727 | break; | ||
728 | default: | ||
729 | ret = -EINVAL; | ||
723 | } | 730 | } |
724 | mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); | 731 | mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); |
725 | return ret; | 732 | return ret; |
@@ -803,7 +810,7 @@ static const struct file_operations oldmem_fops = { | |||
803 | }; | 810 | }; |
804 | #endif | 811 | #endif |
805 | 812 | ||
806 | static ssize_t kmsg_write(struct file * file, const char __user * buf, | 813 | static ssize_t kmsg_write(struct file *file, const char __user *buf, |
807 | size_t count, loff_t *ppos) | 814 | size_t count, loff_t *ppos) |
808 | { | 815 | { |
809 | char *tmp; | 816 | char *tmp; |
@@ -825,7 +832,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf, | |||
825 | } | 832 | } |
826 | 833 | ||
827 | static const struct file_operations kmsg_fops = { | 834 | static const struct file_operations kmsg_fops = { |
828 | .write = kmsg_write, | 835 | .write = kmsg_write, |
829 | }; | 836 | }; |
830 | 837 | ||
831 | static const struct memdev { | 838 | static const struct memdev { |
@@ -876,7 +883,7 @@ static int memory_open(struct inode *inode, struct file *filp) | |||
876 | } | 883 | } |
877 | 884 | ||
878 | static const struct file_operations memory_fops = { | 885 | static const struct file_operations memory_fops = { |
879 | .open = memory_open, | 886 | .open = memory_open, |
880 | }; | 887 | }; |
881 | 888 | ||
882 | static char *mem_devnode(struct device *dev, mode_t *mode) | 889 | static char *mem_devnode(struct device *dev, mode_t *mode) |
@@ -897,7 +904,7 @@ static int __init chr_dev_init(void) | |||
897 | if (err) | 904 | if (err) |
898 | return err; | 905 | return err; |
899 | 906 | ||
900 | if (register_chrdev(MEM_MAJOR,"mem",&memory_fops)) | 907 | if (register_chrdev(MEM_MAJOR, "mem", &memory_fops)) |
901 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); | 908 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); |
902 | 909 | ||
903 | mem_class = class_create(THIS_MODULE, "mem"); | 910 | mem_class = class_create(THIS_MODULE, "mem"); |
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 918711aa56f3..04fd0d843b3b 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c | |||
@@ -546,7 +546,7 @@ static void mmtimer_tasklet(unsigned long data) | |||
546 | { | 546 | { |
547 | int nodeid = data; | 547 | int nodeid = data; |
548 | struct mmtimer_node *mn = &timers[nodeid]; | 548 | struct mmtimer_node *mn = &timers[nodeid]; |
549 | struct mmtimer *x = rb_entry(mn->next, struct mmtimer, list); | 549 | struct mmtimer *x; |
550 | struct k_itimer *t; | 550 | struct k_itimer *t; |
551 | unsigned long flags; | 551 | unsigned long flags; |
552 | 552 | ||
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 2e50f4dfc79c..bdae8327143c 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/audit.h> | 48 | #include <linux/audit.h> |
49 | #include <linux/file.h> | 49 | #include <linux/file.h> |
50 | #include <linux/uaccess.h> | 50 | #include <linux/uaccess.h> |
51 | #include <linux/module.h> | ||
51 | 52 | ||
52 | #include <asm/system.h> | 53 | #include <asm/system.h> |
53 | 54 | ||
@@ -2091,3 +2092,19 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = { | |||
2091 | .receive_buf = n_tty_receive_buf, | 2092 | .receive_buf = n_tty_receive_buf, |
2092 | .write_wakeup = n_tty_write_wakeup | 2093 | .write_wakeup = n_tty_write_wakeup |
2093 | }; | 2094 | }; |
2095 | |||
2096 | /** | ||
2097 | * n_tty_inherit_ops - inherit N_TTY methods | ||
2098 | * @ops: struct tty_ldisc_ops where to save N_TTY methods | ||
2099 | * | ||
2100 | * Used by a generic struct tty_ldisc_ops to easily inherit N_TTY | ||
2101 | * methods. | ||
2102 | */ | ||
2103 | |||
2104 | void n_tty_inherit_ops(struct tty_ldisc_ops *ops) | ||
2105 | { | ||
2106 | *ops = tty_ldisc_N_TTY; | ||
2107 | ops->owner = NULL; | ||
2108 | ops->refcount = ops->flags = 0; | ||
2109 | } | ||
2110 | EXPORT_SYMBOL_GPL(n_tty_inherit_ops); | ||
diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c index ac16fbec72d0..283a15bc84e3 100644 --- a/drivers/char/tty_audit.c +++ b/drivers/char/tty_audit.c | |||
@@ -148,7 +148,6 @@ void tty_audit_fork(struct signal_struct *sig) | |||
148 | spin_lock_irq(¤t->sighand->siglock); | 148 | spin_lock_irq(¤t->sighand->siglock); |
149 | sig->audit_tty = current->signal->audit_tty; | 149 | sig->audit_tty = current->signal->audit_tty; |
150 | spin_unlock_irq(¤t->sighand->siglock); | 150 | spin_unlock_irq(¤t->sighand->siglock); |
151 | sig->tty_audit_buf = NULL; | ||
152 | } | 151 | } |
153 | 152 | ||
154 | /** | 153 | /** |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 67bc2ece7b4b..2d5d575e889d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -766,7 +766,7 @@ static void cpufreq_sysfs_release(struct kobject *kobj) | |||
766 | complete(&policy->kobj_unregister); | 766 | complete(&policy->kobj_unregister); |
767 | } | 767 | } |
768 | 768 | ||
769 | static struct sysfs_ops sysfs_ops = { | 769 | static const struct sysfs_ops sysfs_ops = { |
770 | .show = show, | 770 | .show = show, |
771 | .store = store, | 771 | .store = store, |
772 | }; | 772 | }; |
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 97b003839fb6..8719b36e1a4d 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -22,6 +22,7 @@ static int __init cpuidle_sysfs_setup(char *unused) | |||
22 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); | 22 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); |
23 | 23 | ||
24 | static ssize_t show_available_governors(struct sysdev_class *class, | 24 | static ssize_t show_available_governors(struct sysdev_class *class, |
25 | struct sysdev_class_attribute *attr, | ||
25 | char *buf) | 26 | char *buf) |
26 | { | 27 | { |
27 | ssize_t i = 0; | 28 | ssize_t i = 0; |
@@ -41,6 +42,7 @@ out: | |||
41 | } | 42 | } |
42 | 43 | ||
43 | static ssize_t show_current_driver(struct sysdev_class *class, | 44 | static ssize_t show_current_driver(struct sysdev_class *class, |
45 | struct sysdev_class_attribute *attr, | ||
44 | char *buf) | 46 | char *buf) |
45 | { | 47 | { |
46 | ssize_t ret; | 48 | ssize_t ret; |
@@ -56,6 +58,7 @@ static ssize_t show_current_driver(struct sysdev_class *class, | |||
56 | } | 58 | } |
57 | 59 | ||
58 | static ssize_t show_current_governor(struct sysdev_class *class, | 60 | static ssize_t show_current_governor(struct sysdev_class *class, |
61 | struct sysdev_class_attribute *attr, | ||
59 | char *buf) | 62 | char *buf) |
60 | { | 63 | { |
61 | ssize_t ret; | 64 | ssize_t ret; |
@@ -71,6 +74,7 @@ static ssize_t show_current_governor(struct sysdev_class *class, | |||
71 | } | 74 | } |
72 | 75 | ||
73 | static ssize_t store_current_governor(struct sysdev_class *class, | 76 | static ssize_t store_current_governor(struct sysdev_class *class, |
77 | struct sysdev_class_attribute *attr, | ||
74 | const char *buf, size_t count) | 78 | const char *buf, size_t count) |
75 | { | 79 | { |
76 | char gov_name[CPUIDLE_NAME_LEN]; | 80 | char gov_name[CPUIDLE_NAME_LEN]; |
@@ -191,7 +195,7 @@ static ssize_t cpuidle_store(struct kobject * kobj, struct attribute * attr, | |||
191 | return ret; | 195 | return ret; |
192 | } | 196 | } |
193 | 197 | ||
194 | static struct sysfs_ops cpuidle_sysfs_ops = { | 198 | static const struct sysfs_ops cpuidle_sysfs_ops = { |
195 | .show = cpuidle_show, | 199 | .show = cpuidle_show, |
196 | .store = cpuidle_store, | 200 | .store = cpuidle_store, |
197 | }; | 201 | }; |
@@ -277,7 +281,7 @@ static ssize_t cpuidle_state_show(struct kobject * kobj, | |||
277 | return ret; | 281 | return ret; |
278 | } | 282 | } |
279 | 283 | ||
280 | static struct sysfs_ops cpuidle_state_sysfs_ops = { | 284 | static const struct sysfs_ops cpuidle_state_sysfs_ops = { |
281 | .show = cpuidle_state_show, | 285 | .show = cpuidle_state_show, |
282 | }; | 286 | }; |
283 | 287 | ||
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c index af14c9a5b8d4..0099340b9616 100644 --- a/drivers/dma/ioat/dma.c +++ b/drivers/dma/ioat/dma.c | |||
@@ -1138,7 +1138,7 @@ ioat_attr_show(struct kobject *kobj, struct attribute *attr, char *page) | |||
1138 | return entry->show(&chan->common, page); | 1138 | return entry->show(&chan->common, page); |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | struct sysfs_ops ioat_sysfs_ops = { | 1141 | const struct sysfs_ops ioat_sysfs_ops = { |
1142 | .show = ioat_attr_show, | 1142 | .show = ioat_attr_show, |
1143 | }; | 1143 | }; |
1144 | 1144 | ||
diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h index 4f747a254074..86b97ac8774e 100644 --- a/drivers/dma/ioat/dma.h +++ b/drivers/dma/ioat/dma.h | |||
@@ -346,7 +346,7 @@ bool ioat_cleanup_preamble(struct ioat_chan_common *chan, | |||
346 | unsigned long *phys_complete); | 346 | unsigned long *phys_complete); |
347 | void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type); | 347 | void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type); |
348 | void ioat_kobject_del(struct ioatdma_device *device); | 348 | void ioat_kobject_del(struct ioatdma_device *device); |
349 | extern struct sysfs_ops ioat_sysfs_ops; | 349 | extern const struct sysfs_ops ioat_sysfs_ops; |
350 | extern struct ioat_sysfs_entry ioat_version_attr; | 350 | extern struct ioat_sysfs_entry ioat_version_attr; |
351 | extern struct ioat_sysfs_entry ioat_cap_attr; | 351 | extern struct ioat_sysfs_entry ioat_cap_attr; |
352 | #endif /* IOATDMA_H */ | 352 | #endif /* IOATDMA_H */ |
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c index d205d493a68a..243e9aacad69 100644 --- a/drivers/edac/e752x_edac.c +++ b/drivers/edac/e752x_edac.c | |||
@@ -75,6 +75,14 @@ static struct edac_pci_ctl_info *e752x_pci; | |||
75 | #define E752X_NR_CSROWS 8 /* number of csrows */ | 75 | #define E752X_NR_CSROWS 8 /* number of csrows */ |
76 | 76 | ||
77 | /* E752X register addresses - device 0 function 0 */ | 77 | /* E752X register addresses - device 0 function 0 */ |
78 | #define E752X_MCHSCRB 0x52 /* Memory Scrub register (16b) */ | ||
79 | /* | ||
80 | * 6:5 Scrub Completion Count | ||
81 | * 3:2 Scrub Rate (i3100 only) | ||
82 | * 01=fast 10=normal | ||
83 | * 1:0 Scrub Mode enable | ||
84 | * 00=off 10=on | ||
85 | */ | ||
78 | #define E752X_DRB 0x60 /* DRAM row boundary register (8b) */ | 86 | #define E752X_DRB 0x60 /* DRAM row boundary register (8b) */ |
79 | #define E752X_DRA 0x70 /* DRAM row attribute register (8b) */ | 87 | #define E752X_DRA 0x70 /* DRAM row attribute register (8b) */ |
80 | /* | 88 | /* |
@@ -240,6 +248,41 @@ static const struct e752x_dev_info e752x_devs[] = { | |||
240 | .ctl_name = "3100"}, | 248 | .ctl_name = "3100"}, |
241 | }; | 249 | }; |
242 | 250 | ||
251 | /* Valid scrub rates for the e752x/3100 hardware memory scrubber. We | ||
252 | * map the scrubbing bandwidth to a hardware register value. The 'set' | ||
253 | * operation finds the 'matching or higher value'. Note that scrubbing | ||
254 | * on the e752x can only be enabled/disabled. The 3100 supports | ||
255 | * a normal and fast mode. | ||
256 | */ | ||
257 | |||
258 | #define SDRATE_EOT 0xFFFFFFFF | ||
259 | |||
260 | struct scrubrate { | ||
261 | u32 bandwidth; /* bandwidth consumed by scrubbing in bytes/sec */ | ||
262 | u16 scrubval; /* register value for scrub rate */ | ||
263 | }; | ||
264 | |||
265 | /* Rate below assumes same performance as i3100 using PC3200 DDR2 in | ||
266 | * normal mode. e752x bridges don't support choosing normal or fast mode, | ||
267 | * so the scrubbing bandwidth value isn't all that important - scrubbing is | ||
268 | * either on or off. | ||
269 | */ | ||
270 | static const struct scrubrate scrubrates_e752x[] = { | ||
271 | {0, 0x00}, /* Scrubbing Off */ | ||
272 | {500000, 0x02}, /* Scrubbing On */ | ||
273 | {SDRATE_EOT, 0x00} /* End of Table */ | ||
274 | }; | ||
275 | |||
276 | /* Fast mode: 2 GByte PC3200 DDR2 scrubbed in 33s = 63161283 bytes/s | ||
277 | * Normal mode: 125 (32000 / 256) times slower than fast mode. | ||
278 | */ | ||
279 | static const struct scrubrate scrubrates_i3100[] = { | ||
280 | {0, 0x00}, /* Scrubbing Off */ | ||
281 | {500000, 0x0a}, /* Normal mode - 32k clocks */ | ||
282 | {62500000, 0x06}, /* Fast mode - 256 clocks */ | ||
283 | {SDRATE_EOT, 0x00} /* End of Table */ | ||
284 | }; | ||
285 | |||
243 | static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci, | 286 | static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci, |
244 | unsigned long page) | 287 | unsigned long page) |
245 | { | 288 | { |
@@ -915,6 +958,68 @@ static void e752x_check(struct mem_ctl_info *mci) | |||
915 | e752x_process_error_info(mci, &info, 1); | 958 | e752x_process_error_info(mci, &info, 1); |
916 | } | 959 | } |
917 | 960 | ||
961 | /* Program byte/sec bandwidth scrub rate to hardware */ | ||
962 | static int set_sdram_scrub_rate(struct mem_ctl_info *mci, u32 *new_bw) | ||
963 | { | ||
964 | const struct scrubrate *scrubrates; | ||
965 | struct e752x_pvt *pvt = (struct e752x_pvt *) mci->pvt_info; | ||
966 | struct pci_dev *pdev = pvt->dev_d0f0; | ||
967 | int i; | ||
968 | |||
969 | if (pvt->dev_info->ctl_dev == PCI_DEVICE_ID_INTEL_3100_0) | ||
970 | scrubrates = scrubrates_i3100; | ||
971 | else | ||
972 | scrubrates = scrubrates_e752x; | ||
973 | |||
974 | /* Translate the desired scrub rate to a e752x/3100 register value. | ||
975 | * Search for the bandwidth that is equal or greater than the | ||
976 | * desired rate and program the cooresponding register value. | ||
977 | */ | ||
978 | for (i = 0; scrubrates[i].bandwidth != SDRATE_EOT; i++) | ||
979 | if (scrubrates[i].bandwidth >= *new_bw) | ||
980 | break; | ||
981 | |||
982 | if (scrubrates[i].bandwidth == SDRATE_EOT) | ||
983 | return -1; | ||
984 | |||
985 | pci_write_config_word(pdev, E752X_MCHSCRB, scrubrates[i].scrubval); | ||
986 | |||
987 | return 0; | ||
988 | } | ||
989 | |||
990 | /* Convert current scrub rate value into byte/sec bandwidth */ | ||
991 | static int get_sdram_scrub_rate(struct mem_ctl_info *mci, u32 *bw) | ||
992 | { | ||
993 | const struct scrubrate *scrubrates; | ||
994 | struct e752x_pvt *pvt = (struct e752x_pvt *) mci->pvt_info; | ||
995 | struct pci_dev *pdev = pvt->dev_d0f0; | ||
996 | u16 scrubval; | ||
997 | int i; | ||
998 | |||
999 | if (pvt->dev_info->ctl_dev == PCI_DEVICE_ID_INTEL_3100_0) | ||
1000 | scrubrates = scrubrates_i3100; | ||
1001 | else | ||
1002 | scrubrates = scrubrates_e752x; | ||
1003 | |||
1004 | /* Find the bandwidth matching the memory scrubber configuration */ | ||
1005 | pci_read_config_word(pdev, E752X_MCHSCRB, &scrubval); | ||
1006 | scrubval = scrubval & 0x0f; | ||
1007 | |||
1008 | for (i = 0; scrubrates[i].bandwidth != SDRATE_EOT; i++) | ||
1009 | if (scrubrates[i].scrubval == scrubval) | ||
1010 | break; | ||
1011 | |||
1012 | if (scrubrates[i].bandwidth == SDRATE_EOT) { | ||
1013 | e752x_printk(KERN_WARNING, | ||
1014 | "Invalid sdram scrub control value: 0x%x\n", scrubval); | ||
1015 | return -1; | ||
1016 | } | ||
1017 | |||
1018 | *bw = scrubrates[i].bandwidth; | ||
1019 | |||
1020 | return 0; | ||
1021 | } | ||
1022 | |||
918 | /* Return 1 if dual channel mode is active. Else return 0. */ | 1023 | /* Return 1 if dual channel mode is active. Else return 0. */ |
919 | static inline int dual_channel_active(u16 ddrcsr) | 1024 | static inline int dual_channel_active(u16 ddrcsr) |
920 | { | 1025 | { |
@@ -1073,10 +1178,7 @@ fail: | |||
1073 | 1178 | ||
1074 | /* Setup system bus parity mask register. | 1179 | /* Setup system bus parity mask register. |
1075 | * Sysbus parity supported on: | 1180 | * Sysbus parity supported on: |
1076 | * e7320/e7520/e7525 + Xeon | 1181 | * e7320/e7520/e7525 + Xeon |
1077 | * i3100 + Xeon/Celeron | ||
1078 | * Sysbus parity not supported on: | ||
1079 | * i3100 + Pentium M/Celeron M/Core Duo/Core2 Duo | ||
1080 | */ | 1182 | */ |
1081 | static void e752x_init_sysbus_parity_mask(struct e752x_pvt *pvt) | 1183 | static void e752x_init_sysbus_parity_mask(struct e752x_pvt *pvt) |
1082 | { | 1184 | { |
@@ -1087,10 +1189,7 @@ static void e752x_init_sysbus_parity_mask(struct e752x_pvt *pvt) | |||
1087 | /* Allow module parameter override, else see if CPU supports parity */ | 1189 | /* Allow module parameter override, else see if CPU supports parity */ |
1088 | if (sysbus_parity != -1) { | 1190 | if (sysbus_parity != -1) { |
1089 | enable = sysbus_parity; | 1191 | enable = sysbus_parity; |
1090 | } else if (cpu_id[0] && | 1192 | } else if (cpu_id[0] && !strstr(cpu_id, "Xeon")) { |
1091 | ((strstr(cpu_id, "Pentium") && strstr(cpu_id, " M ")) || | ||
1092 | (strstr(cpu_id, "Celeron") && strstr(cpu_id, " M ")) || | ||
1093 | (strstr(cpu_id, "Core") && strstr(cpu_id, "Duo")))) { | ||
1094 | e752x_printk(KERN_INFO, "System Bus Parity not " | 1193 | e752x_printk(KERN_INFO, "System Bus Parity not " |
1095 | "supported by CPU, disabling\n"); | 1194 | "supported by CPU, disabling\n"); |
1096 | enable = 0; | 1195 | enable = 0; |
@@ -1187,6 +1286,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx) | |||
1187 | mci->dev_name = pci_name(pdev); | 1286 | mci->dev_name = pci_name(pdev); |
1188 | mci->edac_check = e752x_check; | 1287 | mci->edac_check = e752x_check; |
1189 | mci->ctl_page_to_phys = ctl_page_to_phys; | 1288 | mci->ctl_page_to_phys = ctl_page_to_phys; |
1289 | mci->set_sdram_scrub_rate = set_sdram_scrub_rate; | ||
1290 | mci->get_sdram_scrub_rate = get_sdram_scrub_rate; | ||
1190 | 1291 | ||
1191 | /* set the map type. 1 = normal, 0 = reversed | 1292 | /* set the map type. 1 = normal, 0 = reversed |
1192 | * Must be set before e752x_init_csrows in case csrow mapping | 1293 | * Must be set before e752x_init_csrows in case csrow mapping |
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 53764577035f..5fdedbc0f545 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c | |||
@@ -137,7 +137,7 @@ static ssize_t edac_dev_ctl_info_store(struct kobject *kobj, | |||
137 | } | 137 | } |
138 | 138 | ||
139 | /* edac_dev file operations for an 'ctl_info' */ | 139 | /* edac_dev file operations for an 'ctl_info' */ |
140 | static struct sysfs_ops device_ctl_info_ops = { | 140 | static const struct sysfs_ops device_ctl_info_ops = { |
141 | .show = edac_dev_ctl_info_show, | 141 | .show = edac_dev_ctl_info_show, |
142 | .store = edac_dev_ctl_info_store | 142 | .store = edac_dev_ctl_info_store |
143 | }; | 143 | }; |
@@ -373,7 +373,7 @@ static ssize_t edac_dev_instance_store(struct kobject *kobj, | |||
373 | } | 373 | } |
374 | 374 | ||
375 | /* edac_dev file operations for an 'instance' */ | 375 | /* edac_dev file operations for an 'instance' */ |
376 | static struct sysfs_ops device_instance_ops = { | 376 | static const struct sysfs_ops device_instance_ops = { |
377 | .show = edac_dev_instance_show, | 377 | .show = edac_dev_instance_show, |
378 | .store = edac_dev_instance_store | 378 | .store = edac_dev_instance_store |
379 | }; | 379 | }; |
@@ -476,7 +476,7 @@ static ssize_t edac_dev_block_store(struct kobject *kobj, | |||
476 | } | 476 | } |
477 | 477 | ||
478 | /* edac_dev file operations for a 'block' */ | 478 | /* edac_dev file operations for a 'block' */ |
479 | static struct sysfs_ops device_block_ops = { | 479 | static const struct sysfs_ops device_block_ops = { |
480 | .show = edac_dev_block_show, | 480 | .show = edac_dev_block_show, |
481 | .store = edac_dev_block_store | 481 | .store = edac_dev_block_store |
482 | }; | 482 | }; |
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index e1d4ce083481..88840e9fa3e0 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -245,7 +245,7 @@ static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr, | |||
245 | return -EIO; | 245 | return -EIO; |
246 | } | 246 | } |
247 | 247 | ||
248 | static struct sysfs_ops csrowfs_ops = { | 248 | static const struct sysfs_ops csrowfs_ops = { |
249 | .show = csrowdev_show, | 249 | .show = csrowdev_show, |
250 | .store = csrowdev_store | 250 | .store = csrowdev_store |
251 | }; | 251 | }; |
@@ -575,7 +575,7 @@ static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr, | |||
575 | } | 575 | } |
576 | 576 | ||
577 | /* Intermediate show/store table */ | 577 | /* Intermediate show/store table */ |
578 | static struct sysfs_ops mci_ops = { | 578 | static const struct sysfs_ops mci_ops = { |
579 | .show = mcidev_show, | 579 | .show = mcidev_show, |
580 | .store = mcidev_store | 580 | .store = mcidev_store |
581 | }; | 581 | }; |
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c index fb60a877d768..bef94e3d9944 100644 --- a/drivers/edac/edac_pci_sysfs.c +++ b/drivers/edac/edac_pci_sysfs.c | |||
@@ -121,7 +121,7 @@ static ssize_t edac_pci_instance_store(struct kobject *kobj, | |||
121 | } | 121 | } |
122 | 122 | ||
123 | /* fs_ops table */ | 123 | /* fs_ops table */ |
124 | static struct sysfs_ops pci_instance_ops = { | 124 | static const struct sysfs_ops pci_instance_ops = { |
125 | .show = edac_pci_instance_show, | 125 | .show = edac_pci_instance_show, |
126 | .store = edac_pci_instance_store | 126 | .store = edac_pci_instance_store |
127 | }; | 127 | }; |
@@ -261,7 +261,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj, | |||
261 | return -EIO; | 261 | return -EIO; |
262 | } | 262 | } |
263 | 263 | ||
264 | static struct sysfs_ops edac_pci_sysfs_ops = { | 264 | static const struct sysfs_ops edac_pci_sysfs_ops = { |
265 | .show = edac_pci_dev_show, | 265 | .show = edac_pci_dev_show, |
266 | .store = edac_pci_dev_store | 266 | .store = edac_pci_dev_store |
267 | }; | 267 | }; |
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c index ecd5928d7110..94cac0aacea3 100644 --- a/drivers/edac/mpc85xx_edac.c +++ b/drivers/edac/mpc85xx_edac.c | |||
@@ -239,16 +239,15 @@ static int __devinit mpc85xx_pci_err_probe(struct of_device *op, | |||
239 | /* we only need the error registers */ | 239 | /* we only need the error registers */ |
240 | r.start += 0xe00; | 240 | r.start += 0xe00; |
241 | 241 | ||
242 | if (!devm_request_mem_region(&op->dev, r.start, | 242 | if (!devm_request_mem_region(&op->dev, r.start, resource_size(&r), |
243 | r.end - r.start + 1, pdata->name)) { | 243 | pdata->name)) { |
244 | printk(KERN_ERR "%s: Error while requesting mem region\n", | 244 | printk(KERN_ERR "%s: Error while requesting mem region\n", |
245 | __func__); | 245 | __func__); |
246 | res = -EBUSY; | 246 | res = -EBUSY; |
247 | goto err; | 247 | goto err; |
248 | } | 248 | } |
249 | 249 | ||
250 | pdata->pci_vbase = devm_ioremap(&op->dev, r.start, | 250 | pdata->pci_vbase = devm_ioremap(&op->dev, r.start, resource_size(&r)); |
251 | r.end - r.start + 1); | ||
252 | if (!pdata->pci_vbase) { | 251 | if (!pdata->pci_vbase) { |
253 | printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__); | 252 | printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__); |
254 | res = -ENOMEM; | 253 | res = -ENOMEM; |
@@ -668,15 +667,125 @@ static struct of_platform_driver mpc85xx_l2_err_driver = { | |||
668 | 667 | ||
669 | /**************************** MC Err device ***************************/ | 668 | /**************************** MC Err device ***************************/ |
670 | 669 | ||
670 | /* | ||
671 | * Taken from table 8-55 in the MPC8641 User's Manual and/or 9-61 in the | ||
672 | * MPC8572 User's Manual. Each line represents a syndrome bit column as a | ||
673 | * 64-bit value, but split into an upper and lower 32-bit chunk. The labels | ||
674 | * below correspond to Freescale's manuals. | ||
675 | */ | ||
676 | static unsigned int ecc_table[16] = { | ||
677 | /* MSB LSB */ | ||
678 | /* [0:31] [32:63] */ | ||
679 | 0xf00fe11e, 0xc33c0ff7, /* Syndrome bit 7 */ | ||
680 | 0x00ff00ff, 0x00fff0ff, | ||
681 | 0x0f0f0f0f, 0x0f0fff00, | ||
682 | 0x11113333, 0x7777000f, | ||
683 | 0x22224444, 0x8888222f, | ||
684 | 0x44448888, 0xffff4441, | ||
685 | 0x8888ffff, 0x11118882, | ||
686 | 0xffff1111, 0x22221114, /* Syndrome bit 0 */ | ||
687 | }; | ||
688 | |||
689 | /* | ||
690 | * Calculate the correct ECC value for a 64-bit value specified by high:low | ||
691 | */ | ||
692 | static u8 calculate_ecc(u32 high, u32 low) | ||
693 | { | ||
694 | u32 mask_low; | ||
695 | u32 mask_high; | ||
696 | int bit_cnt; | ||
697 | u8 ecc = 0; | ||
698 | int i; | ||
699 | int j; | ||
700 | |||
701 | for (i = 0; i < 8; i++) { | ||
702 | mask_high = ecc_table[i * 2]; | ||
703 | mask_low = ecc_table[i * 2 + 1]; | ||
704 | bit_cnt = 0; | ||
705 | |||
706 | for (j = 0; j < 32; j++) { | ||
707 | if ((mask_high >> j) & 1) | ||
708 | bit_cnt ^= (high >> j) & 1; | ||
709 | if ((mask_low >> j) & 1) | ||
710 | bit_cnt ^= (low >> j) & 1; | ||
711 | } | ||
712 | |||
713 | ecc |= bit_cnt << i; | ||
714 | } | ||
715 | |||
716 | return ecc; | ||
717 | } | ||
718 | |||
719 | /* | ||
720 | * Create the syndrome code which is generated if the data line specified by | ||
721 | * 'bit' failed. Eg generate an 8-bit codes seen in Table 8-55 in the MPC8641 | ||
722 | * User's Manual and 9-61 in the MPC8572 User's Manual. | ||
723 | */ | ||
724 | static u8 syndrome_from_bit(unsigned int bit) { | ||
725 | int i; | ||
726 | u8 syndrome = 0; | ||
727 | |||
728 | /* | ||
729 | * Cycle through the upper or lower 32-bit portion of each value in | ||
730 | * ecc_table depending on if 'bit' is in the upper or lower half of | ||
731 | * 64-bit data. | ||
732 | */ | ||
733 | for (i = bit < 32; i < 16; i += 2) | ||
734 | syndrome |= ((ecc_table[i] >> (bit % 32)) & 1) << (i / 2); | ||
735 | |||
736 | return syndrome; | ||
737 | } | ||
738 | |||
739 | /* | ||
740 | * Decode data and ecc syndrome to determine what went wrong | ||
741 | * Note: This can only decode single-bit errors | ||
742 | */ | ||
743 | static void sbe_ecc_decode(u32 cap_high, u32 cap_low, u32 cap_ecc, | ||
744 | int *bad_data_bit, int *bad_ecc_bit) | ||
745 | { | ||
746 | int i; | ||
747 | u8 syndrome; | ||
748 | |||
749 | *bad_data_bit = -1; | ||
750 | *bad_ecc_bit = -1; | ||
751 | |||
752 | /* | ||
753 | * Calculate the ECC of the captured data and XOR it with the captured | ||
754 | * ECC to find an ECC syndrome value we can search for | ||
755 | */ | ||
756 | syndrome = calculate_ecc(cap_high, cap_low) ^ cap_ecc; | ||
757 | |||
758 | /* Check if a data line is stuck... */ | ||
759 | for (i = 0; i < 64; i++) { | ||
760 | if (syndrome == syndrome_from_bit(i)) { | ||
761 | *bad_data_bit = i; | ||
762 | return; | ||
763 | } | ||
764 | } | ||
765 | |||
766 | /* If data is correct, check ECC bits for errors... */ | ||
767 | for (i = 0; i < 8; i++) { | ||
768 | if ((syndrome >> i) & 0x1) { | ||
769 | *bad_ecc_bit = i; | ||
770 | return; | ||
771 | } | ||
772 | } | ||
773 | } | ||
774 | |||
671 | static void mpc85xx_mc_check(struct mem_ctl_info *mci) | 775 | static void mpc85xx_mc_check(struct mem_ctl_info *mci) |
672 | { | 776 | { |
673 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; | 777 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; |
674 | struct csrow_info *csrow; | 778 | struct csrow_info *csrow; |
779 | u32 bus_width; | ||
675 | u32 err_detect; | 780 | u32 err_detect; |
676 | u32 syndrome; | 781 | u32 syndrome; |
677 | u32 err_addr; | 782 | u32 err_addr; |
678 | u32 pfn; | 783 | u32 pfn; |
679 | int row_index; | 784 | int row_index; |
785 | u32 cap_high; | ||
786 | u32 cap_low; | ||
787 | int bad_data_bit; | ||
788 | int bad_ecc_bit; | ||
680 | 789 | ||
681 | err_detect = in_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DETECT); | 790 | err_detect = in_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DETECT); |
682 | if (!err_detect) | 791 | if (!err_detect) |
@@ -692,6 +801,15 @@ static void mpc85xx_mc_check(struct mem_ctl_info *mci) | |||
692 | } | 801 | } |
693 | 802 | ||
694 | syndrome = in_be32(pdata->mc_vbase + MPC85XX_MC_CAPTURE_ECC); | 803 | syndrome = in_be32(pdata->mc_vbase + MPC85XX_MC_CAPTURE_ECC); |
804 | |||
805 | /* Mask off appropriate bits of syndrome based on bus width */ | ||
806 | bus_width = (in_be32(pdata->mc_vbase + MPC85XX_MC_DDR_SDRAM_CFG) & | ||
807 | DSC_DBW_MASK) ? 32 : 64; | ||
808 | if (bus_width == 64) | ||
809 | syndrome &= 0xff; | ||
810 | else | ||
811 | syndrome &= 0xffff; | ||
812 | |||
695 | err_addr = in_be32(pdata->mc_vbase + MPC85XX_MC_CAPTURE_ADDRESS); | 813 | err_addr = in_be32(pdata->mc_vbase + MPC85XX_MC_CAPTURE_ADDRESS); |
696 | pfn = err_addr >> PAGE_SHIFT; | 814 | pfn = err_addr >> PAGE_SHIFT; |
697 | 815 | ||
@@ -701,14 +819,35 @@ static void mpc85xx_mc_check(struct mem_ctl_info *mci) | |||
701 | break; | 819 | break; |
702 | } | 820 | } |
703 | 821 | ||
704 | mpc85xx_mc_printk(mci, KERN_ERR, "Capture Data High: %#8.8x\n", | 822 | cap_high = in_be32(pdata->mc_vbase + MPC85XX_MC_CAPTURE_DATA_HI); |
705 | in_be32(pdata->mc_vbase + | 823 | cap_low = in_be32(pdata->mc_vbase + MPC85XX_MC_CAPTURE_DATA_LO); |
706 | MPC85XX_MC_CAPTURE_DATA_HI)); | 824 | |
707 | mpc85xx_mc_printk(mci, KERN_ERR, "Capture Data Low: %#8.8x\n", | 825 | /* |
708 | in_be32(pdata->mc_vbase + | 826 | * Analyze single-bit errors on 64-bit wide buses |
709 | MPC85XX_MC_CAPTURE_DATA_LO)); | 827 | * TODO: Add support for 32-bit wide buses |
710 | mpc85xx_mc_printk(mci, KERN_ERR, "syndrome: %#8.8x\n", syndrome); | 828 | */ |
711 | mpc85xx_mc_printk(mci, KERN_ERR, "err addr: %#8.8x\n", err_addr); | 829 | if ((err_detect & DDR_EDE_SBE) && (bus_width == 64)) { |
830 | sbe_ecc_decode(cap_high, cap_low, syndrome, | ||
831 | &bad_data_bit, &bad_ecc_bit); | ||
832 | |||
833 | if (bad_data_bit != -1) | ||
834 | mpc85xx_mc_printk(mci, KERN_ERR, | ||
835 | "Faulty Data bit: %d\n", bad_data_bit); | ||
836 | if (bad_ecc_bit != -1) | ||
837 | mpc85xx_mc_printk(mci, KERN_ERR, | ||
838 | "Faulty ECC bit: %d\n", bad_ecc_bit); | ||
839 | |||
840 | mpc85xx_mc_printk(mci, KERN_ERR, | ||
841 | "Expected Data / ECC:\t%#8.8x_%08x / %#2.2x\n", | ||
842 | cap_high ^ (1 << (bad_data_bit - 32)), | ||
843 | cap_low ^ (1 << bad_data_bit), | ||
844 | syndrome ^ (1 << bad_ecc_bit)); | ||
845 | } | ||
846 | |||
847 | mpc85xx_mc_printk(mci, KERN_ERR, | ||
848 | "Captured Data / ECC:\t%#8.8x_%08x / %#2.2x\n", | ||
849 | cap_high, cap_low, syndrome); | ||
850 | mpc85xx_mc_printk(mci, KERN_ERR, "Err addr: %#8.8x\n", err_addr); | ||
712 | mpc85xx_mc_printk(mci, KERN_ERR, "PFN: %#8.8x\n", pfn); | 851 | mpc85xx_mc_printk(mci, KERN_ERR, "PFN: %#8.8x\n", pfn); |
713 | 852 | ||
714 | /* we are out of range */ | 853 | /* we are out of range */ |
diff --git a/drivers/edac/mpc85xx_edac.h b/drivers/edac/mpc85xx_edac.h index 52432ee7c4b9..cb24df839460 100644 --- a/drivers/edac/mpc85xx_edac.h +++ b/drivers/edac/mpc85xx_edac.h | |||
@@ -48,6 +48,9 @@ | |||
48 | #define DSC_MEM_EN 0x80000000 | 48 | #define DSC_MEM_EN 0x80000000 |
49 | #define DSC_ECC_EN 0x20000000 | 49 | #define DSC_ECC_EN 0x20000000 |
50 | #define DSC_RD_EN 0x10000000 | 50 | #define DSC_RD_EN 0x10000000 |
51 | #define DSC_DBW_MASK 0x00180000 | ||
52 | #define DSC_DBW_32 0x00080000 | ||
53 | #define DSC_DBW_64 0x00000000 | ||
51 | 54 | ||
52 | #define DSC_SDTYPE_MASK 0x07000000 | 55 | #define DSC_SDTYPE_MASK 0x07000000 |
53 | 56 | ||
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 014cabd3afda..5db0518c66da 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <linux/rwsem.h> | 35 | #include <linux/rwsem.h> |
36 | #include <linux/semaphore.h> | ||
37 | #include <linux/spinlock.h> | 36 | #include <linux/spinlock.h> |
38 | #include <linux/string.h> | 37 | #include <linux/string.h> |
39 | #include <linux/workqueue.h> | 38 | #include <linux/workqueue.h> |
@@ -828,9 +827,9 @@ static int update_unit(struct device *dev, void *data) | |||
828 | struct fw_driver *driver = (struct fw_driver *)dev->driver; | 827 | struct fw_driver *driver = (struct fw_driver *)dev->driver; |
829 | 828 | ||
830 | if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) { | 829 | if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) { |
831 | down(&dev->sem); | 830 | device_lock(dev); |
832 | driver->update(unit); | 831 | driver->update(unit); |
833 | up(&dev->sem); | 832 | device_unlock(dev); |
834 | } | 833 | } |
835 | 834 | ||
836 | return 0; | 835 | return 0; |
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index 9e4f59dc7f1e..110e24e50883 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c | |||
@@ -122,7 +122,7 @@ edd_attr_show(struct kobject * kobj, struct attribute *attr, char *buf) | |||
122 | return ret; | 122 | return ret; |
123 | } | 123 | } |
124 | 124 | ||
125 | static struct sysfs_ops edd_attr_ops = { | 125 | static const struct sysfs_ops edd_attr_ops = { |
126 | .show = edd_attr_show, | 126 | .show = edd_attr_show, |
127 | }; | 127 | }; |
128 | 128 | ||
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index f4f709d1370b..082f06ecd327 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c | |||
@@ -362,7 +362,7 @@ static ssize_t efivar_attr_store(struct kobject *kobj, struct attribute *attr, | |||
362 | return ret; | 362 | return ret; |
363 | } | 363 | } |
364 | 364 | ||
365 | static struct sysfs_ops efivar_attr_ops = { | 365 | static const struct sysfs_ops efivar_attr_ops = { |
366 | .show = efivar_attr_show, | 366 | .show = efivar_attr_show, |
367 | .store = efivar_attr_store, | 367 | .store = efivar_attr_store, |
368 | }; | 368 | }; |
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c index a3600e3ed0fa..ed2801c378de 100644 --- a/drivers/firmware/iscsi_ibft.c +++ b/drivers/firmware/iscsi_ibft.c | |||
@@ -519,7 +519,7 @@ static ssize_t ibft_show_attribute(struct kobject *kobj, | |||
519 | return ret; | 519 | return ret; |
520 | } | 520 | } |
521 | 521 | ||
522 | static struct sysfs_ops ibft_attr_ops = { | 522 | static const struct sysfs_ops ibft_attr_ops = { |
523 | .show = ibft_show_attribute, | 523 | .show = ibft_show_attribute, |
524 | }; | 524 | }; |
525 | 525 | ||
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c index 20f645743ead..d59f7cad2269 100644 --- a/drivers/firmware/memmap.c +++ b/drivers/firmware/memmap.c | |||
@@ -74,7 +74,7 @@ static struct attribute *def_attrs[] = { | |||
74 | NULL | 74 | NULL |
75 | }; | 75 | }; |
76 | 76 | ||
77 | static struct sysfs_ops memmap_attr_ops = { | 77 | static const struct sysfs_ops memmap_attr_ops = { |
78 | .show = memmap_attr_show, | 78 | .show = memmap_attr_show, |
79 | }; | 79 | }; |
80 | 80 | ||
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9006fdb26fea..6d1b86661e63 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -623,7 +623,9 @@ static const struct attribute_group gpiochip_attr_group = { | |||
623 | * /sys/class/gpio/unexport ... write-only | 623 | * /sys/class/gpio/unexport ... write-only |
624 | * integer N ... number of GPIO to unexport | 624 | * integer N ... number of GPIO to unexport |
625 | */ | 625 | */ |
626 | static ssize_t export_store(struct class *class, const char *buf, size_t len) | 626 | static ssize_t export_store(struct class *class, |
627 | struct class_attribute *attr, | ||
628 | const char *buf, size_t len) | ||
627 | { | 629 | { |
628 | long gpio; | 630 | long gpio; |
629 | int status; | 631 | int status; |
@@ -653,7 +655,9 @@ done: | |||
653 | return status ? : len; | 655 | return status ? : len; |
654 | } | 656 | } |
655 | 657 | ||
656 | static ssize_t unexport_store(struct class *class, const char *buf, size_t len) | 658 | static ssize_t unexport_store(struct class *class, |
659 | struct class_attribute *attr, | ||
660 | const char *buf, size_t len) | ||
657 | { | 661 | { |
658 | long gpio; | 662 | long gpio; |
659 | int status; | 663 | int status; |
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 7e42b7e9d43a..014ce24761b9 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c | |||
@@ -70,19 +70,17 @@ static int drm_class_resume(struct device *dev) | |||
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | /* Display the version of drm_core. This doesn't work right in current design */ | ||
74 | static ssize_t version_show(struct class *dev, char *buf) | ||
75 | { | ||
76 | return sprintf(buf, "%s %d.%d.%d %s\n", CORE_NAME, CORE_MAJOR, | ||
77 | CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); | ||
78 | } | ||
79 | |||
80 | static char *drm_devnode(struct device *dev, mode_t *mode) | 73 | static char *drm_devnode(struct device *dev, mode_t *mode) |
81 | { | 74 | { |
82 | return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); | 75 | return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); |
83 | } | 76 | } |
84 | 77 | ||
85 | static CLASS_ATTR(version, S_IRUGO, version_show, NULL); | 78 | static CLASS_ATTR_STRING(version, S_IRUGO, |
79 | CORE_NAME " " | ||
80 | __stringify(CORE_MAJOR) "." | ||
81 | __stringify(CORE_MINOR) "." | ||
82 | __stringify(CORE_PATCHLEVEL) " " | ||
83 | CORE_DATE); | ||
86 | 84 | ||
87 | /** | 85 | /** |
88 | * drm_sysfs_create - create a struct drm_sysfs_class structure | 86 | * drm_sysfs_create - create a struct drm_sysfs_class structure |
@@ -109,7 +107,7 @@ struct class *drm_sysfs_create(struct module *owner, char *name) | |||
109 | class->suspend = drm_class_suspend; | 107 | class->suspend = drm_class_suspend; |
110 | class->resume = drm_class_resume; | 108 | class->resume = drm_class_resume; |
111 | 109 | ||
112 | err = class_create_file(class, &class_attr_version); | 110 | err = class_create_file(class, &class_attr_version.attr); |
113 | if (err) | 111 | if (err) |
114 | goto err_out_class; | 112 | goto err_out_class; |
115 | 113 | ||
@@ -132,7 +130,7 @@ void drm_sysfs_destroy(void) | |||
132 | { | 130 | { |
133 | if ((drm_class == NULL) || (IS_ERR(drm_class))) | 131 | if ((drm_class == NULL) || (IS_ERR(drm_class))) |
134 | return; | 132 | return; |
135 | class_remove_file(drm_class, &class_attr_version); | 133 | class_remove_file(drm_class, &class_attr_version.attr); |
136 | class_destroy(drm_class); | 134 | class_destroy(drm_class); |
137 | } | 135 | } |
138 | 136 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c7320ce4567d..89c38c49066f 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -128,7 +128,7 @@ static struct attribute *ttm_bo_global_attrs[] = { | |||
128 | NULL | 128 | NULL |
129 | }; | 129 | }; |
130 | 130 | ||
131 | static struct sysfs_ops ttm_bo_global_ops = { | 131 | static const struct sysfs_ops ttm_bo_global_ops = { |
132 | .show = &ttm_bo_global_show | 132 | .show = &ttm_bo_global_show |
133 | }; | 133 | }; |
134 | 134 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index f5245c02b8fd..eb143e04d402 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c | |||
@@ -152,7 +152,7 @@ static struct attribute *ttm_mem_zone_attrs[] = { | |||
152 | NULL | 152 | NULL |
153 | }; | 153 | }; |
154 | 154 | ||
155 | static struct sysfs_ops ttm_mem_zone_ops = { | 155 | static const struct sysfs_ops ttm_mem_zone_ops = { |
156 | .show = &ttm_mem_zone_show, | 156 | .show = &ttm_mem_zone_show, |
157 | .store = &ttm_mem_zone_store | 157 | .store = &ttm_mem_zone_store |
158 | }; | 158 | }; |
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 913abd7c172f..c7c237537f81 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -850,7 +850,7 @@ static const struct i2c_algorithm omap_i2c_algo = { | |||
850 | .functionality = omap_i2c_func, | 850 | .functionality = omap_i2c_func, |
851 | }; | 851 | }; |
852 | 852 | ||
853 | static int __init | 853 | static int __devinit |
854 | omap_i2c_probe(struct platform_device *pdev) | 854 | omap_i2c_probe(struct platform_device *pdev) |
855 | { | 855 | { |
856 | struct omap_i2c_dev *dev; | 856 | struct omap_i2c_dev *dev; |
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 5122b5a8aa2d..18350213479e 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/moduleparam.h> | 19 | #include <linux/moduleparam.h> |
20 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
21 | #include <linux/freezer.h> | 21 | #include <linux/freezer.h> |
22 | #include <linux/semaphore.h> | ||
23 | #include <asm/atomic.h> | 22 | #include <asm/atomic.h> |
24 | 23 | ||
25 | #include "csr.h" | 24 | #include "csr.h" |
@@ -1397,9 +1396,9 @@ static int update_pdrv(struct device *dev, void *data) | |||
1397 | pdrv = container_of(drv, struct hpsb_protocol_driver, | 1396 | pdrv = container_of(drv, struct hpsb_protocol_driver, |
1398 | driver); | 1397 | driver); |
1399 | if (pdrv->update) { | 1398 | if (pdrv->update) { |
1400 | down(&ud->device.sem); | 1399 | device_lock(&ud->device); |
1401 | error = pdrv->update(ud); | 1400 | error = pdrv->update(ud); |
1402 | up(&ud->device.sem); | 1401 | device_unlock(&ud->device); |
1403 | } | 1402 | } |
1404 | if (error) | 1403 | if (error) |
1405 | device_release_driver(&ud->device); | 1404 | device_release_driver(&ud->device); |
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 5130fc55b8e2..764787ebe8d8 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -3597,7 +3597,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr, | |||
3597 | atomic_long_read(&group->counter[cm_attr->index])); | 3597 | atomic_long_read(&group->counter[cm_attr->index])); |
3598 | } | 3598 | } |
3599 | 3599 | ||
3600 | static struct sysfs_ops cm_counter_ops = { | 3600 | static const struct sysfs_ops cm_counter_ops = { |
3601 | .show = cm_show_counter | 3601 | .show = cm_show_counter |
3602 | }; | 3602 | }; |
3603 | 3603 | ||
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 158a214da2f7..1558bb7fc74d 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -79,7 +79,7 @@ static ssize_t port_attr_show(struct kobject *kobj, | |||
79 | return port_attr->show(p, port_attr, buf); | 79 | return port_attr->show(p, port_attr, buf); |
80 | } | 80 | } |
81 | 81 | ||
82 | static struct sysfs_ops port_sysfs_ops = { | 82 | static const struct sysfs_ops port_sysfs_ops = { |
83 | .show = port_attr_show | 83 | .show = port_attr_show |
84 | }; | 84 | }; |
85 | 85 | ||
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 1b09b735c5a8..017d6e24448f 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -1336,11 +1336,8 @@ static void ib_ucm_remove_one(struct ib_device *device) | |||
1336 | device_unregister(&ucm_dev->dev); | 1336 | device_unregister(&ucm_dev->dev); |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | static ssize_t show_abi_version(struct class *class, char *buf) | 1339 | static CLASS_ATTR_STRING(abi_version, S_IRUGO, |
1340 | { | 1340 | __stringify(IB_USER_CM_ABI_VERSION)); |
1341 | return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION); | ||
1342 | } | ||
1343 | static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); | ||
1344 | 1341 | ||
1345 | static int __init ib_ucm_init(void) | 1342 | static int __init ib_ucm_init(void) |
1346 | { | 1343 | { |
@@ -1353,7 +1350,7 @@ static int __init ib_ucm_init(void) | |||
1353 | goto error1; | 1350 | goto error1; |
1354 | } | 1351 | } |
1355 | 1352 | ||
1356 | ret = class_create_file(&cm_class, &class_attr_abi_version); | 1353 | ret = class_create_file(&cm_class, &class_attr_abi_version.attr); |
1357 | if (ret) { | 1354 | if (ret) { |
1358 | printk(KERN_ERR "ucm: couldn't create abi_version attribute\n"); | 1355 | printk(KERN_ERR "ucm: couldn't create abi_version attribute\n"); |
1359 | goto error2; | 1356 | goto error2; |
@@ -1367,7 +1364,7 @@ static int __init ib_ucm_init(void) | |||
1367 | return 0; | 1364 | return 0; |
1368 | 1365 | ||
1369 | error3: | 1366 | error3: |
1370 | class_remove_file(&cm_class, &class_attr_abi_version); | 1367 | class_remove_file(&cm_class, &class_attr_abi_version.attr); |
1371 | error2: | 1368 | error2: |
1372 | unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); | 1369 | unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); |
1373 | error1: | 1370 | error1: |
@@ -1377,7 +1374,7 @@ error1: | |||
1377 | static void __exit ib_ucm_cleanup(void) | 1374 | static void __exit ib_ucm_cleanup(void) |
1378 | { | 1375 | { |
1379 | ib_unregister_client(&ucm_client); | 1376 | ib_unregister_client(&ucm_client); |
1380 | class_remove_file(&cm_class, &class_attr_abi_version); | 1377 | class_remove_file(&cm_class, &class_attr_abi_version.attr); |
1381 | unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); | 1378 | unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); |
1382 | if (overflow_maj) | 1379 | if (overflow_maj) |
1383 | unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES); | 1380 | unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES); |
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index 02d360cfc2f7..04b585e86cb2 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c | |||
@@ -965,11 +965,8 @@ static ssize_t show_port(struct device *dev, struct device_attribute *attr, | |||
965 | } | 965 | } |
966 | static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); | 966 | static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); |
967 | 967 | ||
968 | static ssize_t show_abi_version(struct class *class, char *buf) | 968 | static CLASS_ATTR_STRING(abi_version, S_IRUGO, |
969 | { | 969 | __stringify(IB_USER_MAD_ABI_VERSION)); |
970 | return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION); | ||
971 | } | ||
972 | static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); | ||
973 | 970 | ||
974 | static dev_t overflow_maj; | 971 | static dev_t overflow_maj; |
975 | static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS); | 972 | static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS); |
@@ -1194,7 +1191,7 @@ static int __init ib_umad_init(void) | |||
1194 | goto out_chrdev; | 1191 | goto out_chrdev; |
1195 | } | 1192 | } |
1196 | 1193 | ||
1197 | ret = class_create_file(umad_class, &class_attr_abi_version); | 1194 | ret = class_create_file(umad_class, &class_attr_abi_version.attr); |
1198 | if (ret) { | 1195 | if (ret) { |
1199 | printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n"); | 1196 | printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n"); |
1200 | goto out_class; | 1197 | goto out_class; |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 4fa2e6516441..d805cf365c8d 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -691,11 +691,8 @@ static ssize_t show_dev_abi_version(struct device *device, | |||
691 | } | 691 | } |
692 | static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); | 692 | static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); |
693 | 693 | ||
694 | static ssize_t show_abi_version(struct class *class, char *buf) | 694 | static CLASS_ATTR_STRING(abi_version, S_IRUGO, |
695 | { | 695 | __stringify(IB_USER_VERBS_ABI_VERSION)); |
696 | return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION); | ||
697 | } | ||
698 | static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); | ||
699 | 696 | ||
700 | static dev_t overflow_maj; | 697 | static dev_t overflow_maj; |
701 | static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES); | 698 | static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES); |
@@ -841,7 +838,7 @@ static int __init ib_uverbs_init(void) | |||
841 | goto out_chrdev; | 838 | goto out_chrdev; |
842 | } | 839 | } |
843 | 840 | ||
844 | ret = class_create_file(uverbs_class, &class_attr_abi_version); | 841 | ret = class_create_file(uverbs_class, &class_attr_abi_version.attr); |
845 | if (ret) { | 842 | if (ret) { |
846 | printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n"); | 843 | printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n"); |
847 | goto out_class; | 844 | goto out_class; |
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 9caed30f3bbb..b1ab29861e1c 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c | |||
@@ -192,11 +192,18 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd) | |||
192 | static irqreturn_t locomokbd_interrupt(int irq, void *dev_id) | 192 | static irqreturn_t locomokbd_interrupt(int irq, void *dev_id) |
193 | { | 193 | { |
194 | struct locomokbd *locomokbd = dev_id; | 194 | struct locomokbd *locomokbd = dev_id; |
195 | u16 r; | ||
196 | |||
197 | r = locomo_readl(locomokbd->base + LOCOMO_KIC); | ||
198 | if ((r & 0x0001) == 0) | ||
199 | return IRQ_HANDLED; | ||
200 | |||
201 | locomo_writel(r & ~0x0100, locomokbd->base + LOCOMO_KIC); /* Ack */ | ||
202 | |||
195 | /** wait chattering delay **/ | 203 | /** wait chattering delay **/ |
196 | udelay(100); | 204 | udelay(100); |
197 | 205 | ||
198 | locomokbd_scankeyboard(locomokbd); | 206 | locomokbd_scankeyboard(locomokbd); |
199 | |||
200 | return IRQ_HANDLED; | 207 | return IRQ_HANDLED; |
201 | } | 208 | } |
202 | 209 | ||
@@ -210,6 +217,25 @@ static void locomokbd_timer_callback(unsigned long data) | |||
210 | locomokbd_scankeyboard(locomokbd); | 217 | locomokbd_scankeyboard(locomokbd); |
211 | } | 218 | } |
212 | 219 | ||
220 | static int locomokbd_open(struct input_dev *dev) | ||
221 | { | ||
222 | struct locomokbd *locomokbd = input_get_drvdata(dev); | ||
223 | u16 r; | ||
224 | |||
225 | r = locomo_readl(locomokbd->base + LOCOMO_KIC) | 0x0010; | ||
226 | locomo_writel(r, locomokbd->base + LOCOMO_KIC); | ||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static void locomokbd_close(struct input_dev *dev) | ||
231 | { | ||
232 | struct locomokbd *locomokbd = input_get_drvdata(dev); | ||
233 | u16 r; | ||
234 | |||
235 | r = locomo_readl(locomokbd->base + LOCOMO_KIC) & ~0x0010; | ||
236 | locomo_writel(r, locomokbd->base + LOCOMO_KIC); | ||
237 | } | ||
238 | |||
213 | static int __devinit locomokbd_probe(struct locomo_dev *dev) | 239 | static int __devinit locomokbd_probe(struct locomo_dev *dev) |
214 | { | 240 | { |
215 | struct locomokbd *locomokbd; | 241 | struct locomokbd *locomokbd; |
@@ -253,6 +279,8 @@ static int __devinit locomokbd_probe(struct locomo_dev *dev) | |||
253 | input_dev->id.vendor = 0x0001; | 279 | input_dev->id.vendor = 0x0001; |
254 | input_dev->id.product = 0x0001; | 280 | input_dev->id.product = 0x0001; |
255 | input_dev->id.version = 0x0100; | 281 | input_dev->id.version = 0x0100; |
282 | input_dev->open = locomokbd_open; | ||
283 | input_dev->close = locomokbd_close; | ||
256 | input_dev->dev.parent = &dev->dev; | 284 | input_dev->dev.parent = &dev->dev; |
257 | 285 | ||
258 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | | 286 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | |
@@ -261,6 +289,8 @@ static int __devinit locomokbd_probe(struct locomo_dev *dev) | |||
261 | input_dev->keycodesize = sizeof(locomokbd_keycode[0]); | 289 | input_dev->keycodesize = sizeof(locomokbd_keycode[0]); |
262 | input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode); | 290 | input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode); |
263 | 291 | ||
292 | input_set_drvdata(input_dev, locomokbd); | ||
293 | |||
264 | memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); | 294 | memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); |
265 | for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) | 295 | for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) |
266 | set_bit(locomokbd->keycode[i], input_dev->keybit); | 296 | set_bit(locomokbd->keycode[i], input_dev->keybit); |
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c index 437f55c5d18d..419795f4a2aa 100644 --- a/drivers/macintosh/windfarm_core.c +++ b/drivers/macintosh/windfarm_core.c | |||
@@ -321,6 +321,7 @@ int wf_register_sensor(struct wf_sensor *new_sr) | |||
321 | kref_init(&new_sr->ref); | 321 | kref_init(&new_sr->ref); |
322 | list_add(&new_sr->link, &wf_sensors); | 322 | list_add(&new_sr->link, &wf_sensors); |
323 | 323 | ||
324 | sysfs_attr_init(&new_sr->attr.attr); | ||
324 | new_sr->attr.attr.name = new_sr->name; | 325 | new_sr->attr.attr.name = new_sr->name; |
325 | new_sr->attr.attr.mode = 0444; | 326 | new_sr->attr.attr.mode = 0444; |
326 | new_sr->attr.show = wf_show_sensor; | 327 | new_sr->attr.show = wf_show_sensor; |
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c index 6c68b9e5f5c4..43137b421f92 100644 --- a/drivers/macintosh/windfarm_smu_controls.c +++ b/drivers/macintosh/windfarm_smu_controls.c | |||
@@ -173,6 +173,7 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node, | |||
173 | 173 | ||
174 | fct->fan_type = pwm_fan; | 174 | fct->fan_type = pwm_fan; |
175 | fct->ctrl.type = pwm_fan ? WF_CONTROL_PWM_FAN : WF_CONTROL_RPM_FAN; | 175 | fct->ctrl.type = pwm_fan ? WF_CONTROL_PWM_FAN : WF_CONTROL_RPM_FAN; |
176 | sysfs_attr_init(&fct->ctrl.attr.attr); | ||
176 | 177 | ||
177 | /* We use the name & location here the same way we do for SMU sensors, | 178 | /* We use the name & location here the same way we do for SMU sensors, |
178 | * see the comment in windfarm_smu_sensors.c. The locations are a bit | 179 | * see the comment in windfarm_smu_sensors.c. The locations are a bit |
diff --git a/drivers/md/dm-sysfs.c b/drivers/md/dm-sysfs.c index f91b40942e07..84d2b91e4efb 100644 --- a/drivers/md/dm-sysfs.c +++ b/drivers/md/dm-sysfs.c | |||
@@ -75,7 +75,7 @@ static struct attribute *dm_attrs[] = { | |||
75 | NULL, | 75 | NULL, |
76 | }; | 76 | }; |
77 | 77 | ||
78 | static struct sysfs_ops dm_sysfs_ops = { | 78 | static const struct sysfs_ops dm_sysfs_ops = { |
79 | .show = dm_attr_show, | 79 | .show = dm_attr_show, |
80 | }; | 80 | }; |
81 | 81 | ||
diff --git a/drivers/md/md.c b/drivers/md/md.c index a20a71e5efd3..fdc1890b6ac5 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -2642,7 +2642,7 @@ static void rdev_free(struct kobject *ko) | |||
2642 | mdk_rdev_t *rdev = container_of(ko, mdk_rdev_t, kobj); | 2642 | mdk_rdev_t *rdev = container_of(ko, mdk_rdev_t, kobj); |
2643 | kfree(rdev); | 2643 | kfree(rdev); |
2644 | } | 2644 | } |
2645 | static struct sysfs_ops rdev_sysfs_ops = { | 2645 | static const struct sysfs_ops rdev_sysfs_ops = { |
2646 | .show = rdev_attr_show, | 2646 | .show = rdev_attr_show, |
2647 | .store = rdev_attr_store, | 2647 | .store = rdev_attr_store, |
2648 | }; | 2648 | }; |
@@ -4059,7 +4059,7 @@ static void md_free(struct kobject *ko) | |||
4059 | kfree(mddev); | 4059 | kfree(mddev); |
4060 | } | 4060 | } |
4061 | 4061 | ||
4062 | static struct sysfs_ops md_sysfs_ops = { | 4062 | static const struct sysfs_ops md_sysfs_ops = { |
4063 | .show = md_attr_show, | 4063 | .show = md_attr_show, |
4064 | .store = md_attr_store, | 4064 | .store = md_attr_store, |
4065 | }; | 4065 | }; |
diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c index 7400eacb4d64..142c327afb32 100644 --- a/drivers/media/video/omap24xxcam.c +++ b/drivers/media/video/omap24xxcam.c | |||
@@ -1735,7 +1735,7 @@ static struct v4l2_int_device omap24xxcam = { | |||
1735 | * | 1735 | * |
1736 | */ | 1736 | */ |
1737 | 1737 | ||
1738 | static int __init omap24xxcam_probe(struct platform_device *pdev) | 1738 | static int __devinit omap24xxcam_probe(struct platform_device *pdev) |
1739 | { | 1739 | { |
1740 | struct omap24xxcam_device *cam; | 1740 | struct omap24xxcam_device *cam; |
1741 | struct resource *mem; | 1741 | struct resource *mem; |
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index 04c27266f567..779aa8ebe4cf 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c | |||
@@ -497,12 +497,7 @@ static struct pci_driver phantom_pci_driver = { | |||
497 | .resume = phantom_resume | 497 | .resume = phantom_resume |
498 | }; | 498 | }; |
499 | 499 | ||
500 | static ssize_t phantom_show_version(struct class *cls, char *buf) | 500 | static CLASS_ATTR_STRING(version, 0444, PHANTOM_VERSION); |
501 | { | ||
502 | return sprintf(buf, PHANTOM_VERSION "\n"); | ||
503 | } | ||
504 | |||
505 | static CLASS_ATTR(version, 0444, phantom_show_version, NULL); | ||
506 | 501 | ||
507 | static int __init phantom_init(void) | 502 | static int __init phantom_init(void) |
508 | { | 503 | { |
@@ -515,7 +510,7 @@ static int __init phantom_init(void) | |||
515 | printk(KERN_ERR "phantom: can't register phantom class\n"); | 510 | printk(KERN_ERR "phantom: can't register phantom class\n"); |
516 | goto err; | 511 | goto err; |
517 | } | 512 | } |
518 | retval = class_create_file(phantom_class, &class_attr_version); | 513 | retval = class_create_file(phantom_class, &class_attr_version.attr); |
519 | if (retval) { | 514 | if (retval) { |
520 | printk(KERN_ERR "phantom: can't create sysfs version file\n"); | 515 | printk(KERN_ERR "phantom: can't create sysfs version file\n"); |
521 | goto err_class; | 516 | goto err_class; |
@@ -541,7 +536,7 @@ static int __init phantom_init(void) | |||
541 | err_unchr: | 536 | err_unchr: |
542 | unregister_chrdev_region(dev, PHANTOM_MAX_MINORS); | 537 | unregister_chrdev_region(dev, PHANTOM_MAX_MINORS); |
543 | err_attr: | 538 | err_attr: |
544 | class_remove_file(phantom_class, &class_attr_version); | 539 | class_remove_file(phantom_class, &class_attr_version.attr); |
545 | err_class: | 540 | err_class: |
546 | class_destroy(phantom_class); | 541 | class_destroy(phantom_class); |
547 | err: | 542 | err: |
@@ -554,7 +549,7 @@ static void __exit phantom_exit(void) | |||
554 | 549 | ||
555 | unregister_chrdev_region(MKDEV(phantom_major, 0), PHANTOM_MAX_MINORS); | 550 | unregister_chrdev_region(MKDEV(phantom_major, 0), PHANTOM_MAX_MINORS); |
556 | 551 | ||
557 | class_remove_file(phantom_class, &class_attr_version); | 552 | class_remove_file(phantom_class, &class_attr_version.attr); |
558 | class_destroy(phantom_class); | 553 | class_destroy(phantom_class); |
559 | 554 | ||
560 | pr_debug("phantom: module successfully removed\n"); | 555 | pr_debug("phantom: module successfully removed\n"); |
diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h index 02a77b8b8eef..7a8b9068ea03 100644 --- a/drivers/misc/sgi-gru/grutables.h +++ b/drivers/misc/sgi-gru/grutables.h | |||
@@ -516,8 +516,7 @@ struct gru_blade_state { | |||
516 | 516 | ||
517 | /* Scan all active GRUs in a GRU bitmap */ | 517 | /* Scan all active GRUs in a GRU bitmap */ |
518 | #define for_each_gru_in_bitmap(gid, map) \ | 518 | #define for_each_gru_in_bitmap(gid, map) \ |
519 | for ((gid) = find_first_bit((map), GRU_MAX_GRUS); (gid) < GRU_MAX_GRUS;\ | 519 | for_each_set_bit((gid), (map), GRU_MAX_GRUS) |
520 | (gid)++, (gid) = find_next_bit((map), GRU_MAX_GRUS, (gid))) | ||
521 | 520 | ||
522 | /* Scan all active GRUs on a specific blade */ | 521 | /* Scan all active GRUs on a specific blade */ |
523 | #define for_each_gru_on_blade(gru, nid, i) \ | 522 | #define for_each_gru_on_blade(gru, nid, i) \ |
@@ -536,23 +535,17 @@ struct gru_blade_state { | |||
536 | 535 | ||
537 | /* Scan each CBR whose bit is set in a TFM (or copy of) */ | 536 | /* Scan each CBR whose bit is set in a TFM (or copy of) */ |
538 | #define for_each_cbr_in_tfm(i, map) \ | 537 | #define for_each_cbr_in_tfm(i, map) \ |
539 | for ((i) = find_first_bit(map, GRU_NUM_CBE); \ | 538 | for_each_set_bit((i), (map), GRU_NUM_CBE) |
540 | (i) < GRU_NUM_CBE; \ | ||
541 | (i)++, (i) = find_next_bit(map, GRU_NUM_CBE, i)) | ||
542 | 539 | ||
543 | /* Scan each CBR in a CBR bitmap. Note: multiple CBRs in an allocation unit */ | 540 | /* Scan each CBR in a CBR bitmap. Note: multiple CBRs in an allocation unit */ |
544 | #define for_each_cbr_in_allocation_map(i, map, k) \ | 541 | #define for_each_cbr_in_allocation_map(i, map, k) \ |
545 | for ((k) = find_first_bit(map, GRU_CBR_AU); (k) < GRU_CBR_AU; \ | 542 | for_each_set_bit((k), (map), GRU_CBR_AU) \ |
546 | (k) = find_next_bit(map, GRU_CBR_AU, (k) + 1)) \ | ||
547 | for ((i) = (k)*GRU_CBR_AU_SIZE; \ | 543 | for ((i) = (k)*GRU_CBR_AU_SIZE; \ |
548 | (i) < ((k) + 1) * GRU_CBR_AU_SIZE; (i)++) | 544 | (i) < ((k) + 1) * GRU_CBR_AU_SIZE; (i)++) |
549 | 545 | ||
550 | /* Scan each DSR in a DSR bitmap. Note: multiple DSRs in an allocation unit */ | 546 | /* Scan each DSR in a DSR bitmap. Note: multiple DSRs in an allocation unit */ |
551 | #define for_each_dsr_in_allocation_map(i, map, k) \ | 547 | #define for_each_dsr_in_allocation_map(i, map, k) \ |
552 | for ((k) = find_first_bit((const unsigned long *)map, GRU_DSR_AU);\ | 548 | for_each_set_bit((k), (const unsigned long *)(map), GRU_DSR_AU) \ |
553 | (k) < GRU_DSR_AU; \ | ||
554 | (k) = find_next_bit((const unsigned long *)map, \ | ||
555 | GRU_DSR_AU, (k) + 1)) \ | ||
556 | for ((i) = (k) * GRU_DSR_AU_CL; \ | 549 | for ((i) = (k) * GRU_DSR_AU_CL; \ |
557 | (i) < ((k) + 1) * GRU_DSR_AU_CL; (i)++) | 550 | (i) < ((k) + 1) * GRU_DSR_AU_CL; (i)++) |
558 | 551 | ||
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index f4b97d3c3d0f..3168ebd616b2 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -1089,6 +1089,7 @@ void mmc_rescan(struct work_struct *work) | |||
1089 | mmc_claim_host(host); | 1089 | mmc_claim_host(host); |
1090 | 1090 | ||
1091 | mmc_power_up(host); | 1091 | mmc_power_up(host); |
1092 | sdio_reset(host); | ||
1092 | mmc_go_idle(host); | 1093 | mmc_go_idle(host); |
1093 | 1094 | ||
1094 | mmc_send_if_cond(host, host->ocr_avail); | 1095 | mmc_send_if_cond(host, host->ocr_avail); |
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c index 4eb7825fd1a7..dea36d9c22e6 100644 --- a/drivers/mmc/core/sdio_ops.c +++ b/drivers/mmc/core/sdio_ops.c | |||
@@ -67,13 +67,13 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | |||
67 | return err; | 67 | return err; |
68 | } | 68 | } |
69 | 69 | ||
70 | int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, | 70 | static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn, |
71 | unsigned addr, u8 in, u8* out) | 71 | unsigned addr, u8 in, u8 *out) |
72 | { | 72 | { |
73 | struct mmc_command cmd; | 73 | struct mmc_command cmd; |
74 | int err; | 74 | int err; |
75 | 75 | ||
76 | BUG_ON(!card); | 76 | BUG_ON(!host); |
77 | BUG_ON(fn > 7); | 77 | BUG_ON(fn > 7); |
78 | 78 | ||
79 | /* sanity check */ | 79 | /* sanity check */ |
@@ -90,11 +90,11 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, | |||
90 | cmd.arg |= in; | 90 | cmd.arg |= in; |
91 | cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC; | 91 | cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC; |
92 | 92 | ||
93 | err = mmc_wait_for_cmd(card->host, &cmd, 0); | 93 | err = mmc_wait_for_cmd(host, &cmd, 0); |
94 | if (err) | 94 | if (err) |
95 | return err; | 95 | return err; |
96 | 96 | ||
97 | if (mmc_host_is_spi(card->host)) { | 97 | if (mmc_host_is_spi(host)) { |
98 | /* host driver already reported errors */ | 98 | /* host driver already reported errors */ |
99 | } else { | 99 | } else { |
100 | if (cmd.resp[0] & R5_ERROR) | 100 | if (cmd.resp[0] & R5_ERROR) |
@@ -106,7 +106,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, | |||
106 | } | 106 | } |
107 | 107 | ||
108 | if (out) { | 108 | if (out) { |
109 | if (mmc_host_is_spi(card->host)) | 109 | if (mmc_host_is_spi(host)) |
110 | *out = (cmd.resp[0] >> 8) & 0xFF; | 110 | *out = (cmd.resp[0] >> 8) & 0xFF; |
111 | else | 111 | else |
112 | *out = cmd.resp[0] & 0xFF; | 112 | *out = cmd.resp[0] & 0xFF; |
@@ -115,6 +115,13 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, | ||
119 | unsigned addr, u8 in, u8 *out) | ||
120 | { | ||
121 | BUG_ON(!card); | ||
122 | return mmc_io_rw_direct_host(card->host, write, fn, addr, in, out); | ||
123 | } | ||
124 | |||
118 | int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, | 125 | int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, |
119 | unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz) | 126 | unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz) |
120 | { | 127 | { |
@@ -182,3 +189,20 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, | |||
182 | return 0; | 189 | return 0; |
183 | } | 190 | } |
184 | 191 | ||
192 | int sdio_reset(struct mmc_host *host) | ||
193 | { | ||
194 | int ret; | ||
195 | u8 abort; | ||
196 | |||
197 | /* SDIO Simplified Specification V2.0, 4.4 Reset for SDIO */ | ||
198 | |||
199 | ret = mmc_io_rw_direct_host(host, 0, 0, SDIO_CCCR_ABORT, 0, &abort); | ||
200 | if (ret) | ||
201 | abort = 0x08; | ||
202 | else | ||
203 | abort |= 0x08; | ||
204 | |||
205 | ret = mmc_io_rw_direct_host(host, 1, 0, SDIO_CCCR_ABORT, abort, NULL); | ||
206 | return ret; | ||
207 | } | ||
208 | |||
diff --git a/drivers/mmc/core/sdio_ops.h b/drivers/mmc/core/sdio_ops.h index e2e74b0d17d8..12a4d3ab174c 100644 --- a/drivers/mmc/core/sdio_ops.h +++ b/drivers/mmc/core/sdio_ops.h | |||
@@ -17,6 +17,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, | |||
17 | unsigned addr, u8 in, u8* out); | 17 | unsigned addr, u8 in, u8* out); |
18 | int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, | 18 | int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, |
19 | unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz); | 19 | unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz); |
20 | int sdio_reset(struct mmc_host *host); | ||
20 | 21 | ||
21 | #endif | 22 | #endif |
22 | 23 | ||
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 16cc91c827c9..2df90412abb5 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c | |||
@@ -708,7 +708,7 @@ static int mxcmci_probe(struct platform_device *pdev) | |||
708 | mmc->max_blk_size = 2048; | 708 | mmc->max_blk_size = 2048; |
709 | mmc->max_blk_count = 65535; | 709 | mmc->max_blk_count = 65535; |
710 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; | 710 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; |
711 | mmc->max_seg_size = mmc->max_seg_size; | 711 | mmc->max_seg_size = mmc->max_req_size; |
712 | 712 | ||
713 | host = mmc_priv(mmc); | 713 | host = mmc_priv(mmc); |
714 | host->base = ioremap(r->start, resource_size(r)); | 714 | host->base = ioremap(r->start, resource_size(r)); |
diff --git a/drivers/mtd/maps/pismo.c b/drivers/mtd/maps/pismo.c index c48cad271f5d..30e12c88d1da 100644 --- a/drivers/mtd/maps/pismo.c +++ b/drivers/mtd/maps/pismo.c | |||
@@ -118,7 +118,7 @@ static int __devinit pismo_add_device(struct pismo_data *pismo, int i, | |||
118 | { | 118 | { |
119 | struct platform_device *dev; | 119 | struct platform_device *dev; |
120 | struct resource res = { }; | 120 | struct resource res = { }; |
121 | phys_addr_t base = region.base; | 121 | phys_addr_t base = region->base; |
122 | int ret; | 122 | int ret; |
123 | 123 | ||
124 | if (base == ~0) | 124 | if (base == ~0) |
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index bb6465604235..1157d5679e66 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
@@ -444,7 +444,7 @@ config MTD_NAND_FSL_UPM | |||
444 | 444 | ||
445 | config MTD_NAND_MXC | 445 | config MTD_NAND_MXC |
446 | tristate "MXC NAND support" | 446 | tristate "MXC NAND support" |
447 | depends on ARCH_MX2 || ARCH_MX3 | 447 | depends on ARCH_MX2 || ARCH_MX25 || ARCH_MX3 |
448 | help | 448 | help |
449 | This enables the driver for the NAND flash controller on the | 449 | This enables the driver for the NAND flash controller on the |
450 | MXC processors. | 450 | MXC processors. |
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index bc45ef9af17d..fad40aa6f099 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -89,7 +89,8 @@ DEFINE_MUTEX(ubi_devices_mutex); | |||
89 | static DEFINE_SPINLOCK(ubi_devices_lock); | 89 | static DEFINE_SPINLOCK(ubi_devices_lock); |
90 | 90 | ||
91 | /* "Show" method for files in '/<sysfs>/class/ubi/' */ | 91 | /* "Show" method for files in '/<sysfs>/class/ubi/' */ |
92 | static ssize_t ubi_version_show(struct class *class, char *buf) | 92 | static ssize_t ubi_version_show(struct class *class, struct class_attribute *attr, |
93 | char *buf) | ||
93 | { | 94 | { |
94 | return sprintf(buf, "%d\n", UBI_VERSION); | 95 | return sprintf(buf, "%d\n", UBI_VERSION); |
95 | } | 96 | } |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 5acd557cea9b..b8bec086daa1 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -51,7 +51,9 @@ | |||
51 | * "show" function for the bond_masters attribute. | 51 | * "show" function for the bond_masters attribute. |
52 | * The class parameter is ignored. | 52 | * The class parameter is ignored. |
53 | */ | 53 | */ |
54 | static ssize_t bonding_show_bonds(struct class *cls, char *buf) | 54 | static ssize_t bonding_show_bonds(struct class *cls, |
55 | struct class_attribute *attr, | ||
56 | char *buf) | ||
55 | { | 57 | { |
56 | struct net *net = current->nsproxy->net_ns; | 58 | struct net *net = current->nsproxy->net_ns; |
57 | struct bond_net *bn = net_generic(net, bond_net_id); | 59 | struct bond_net *bn = net_generic(net, bond_net_id); |
@@ -98,6 +100,7 @@ static struct net_device *bond_get_by_name(struct net *net, const char *ifname) | |||
98 | */ | 100 | */ |
99 | 101 | ||
100 | static ssize_t bonding_store_bonds(struct class *cls, | 102 | static ssize_t bonding_store_bonds(struct class *cls, |
103 | struct class_attribute *attr, | ||
101 | const char *buffer, size_t count) | 104 | const char *buffer, size_t count) |
102 | { | 105 | { |
103 | struct net *net = current->nsproxy->net_ns; | 106 | struct net *net = current->nsproxy->net_ns; |
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index f2b937966950..0bc777bac9b4 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -1577,7 +1577,7 @@ static struct attribute * veth_pool_attrs[] = { | |||
1577 | NULL, | 1577 | NULL, |
1578 | }; | 1578 | }; |
1579 | 1579 | ||
1580 | static struct sysfs_ops veth_pool_ops = { | 1580 | static const struct sysfs_ops veth_pool_ops = { |
1581 | .show = veth_pool_show, | 1581 | .show = veth_pool_show, |
1582 | .store = veth_pool_store, | 1582 | .store = veth_pool_store, |
1583 | }; | 1583 | }; |
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c index 966de5d69521..e6e972d9b7ca 100644 --- a/drivers/net/iseries_veth.c +++ b/drivers/net/iseries_veth.c | |||
@@ -384,7 +384,7 @@ static struct attribute *veth_cnx_default_attrs[] = { | |||
384 | NULL | 384 | NULL |
385 | }; | 385 | }; |
386 | 386 | ||
387 | static struct sysfs_ops veth_cnx_sysfs_ops = { | 387 | static const struct sysfs_ops veth_cnx_sysfs_ops = { |
388 | .show = veth_cnx_attribute_show | 388 | .show = veth_cnx_attribute_show |
389 | }; | 389 | }; |
390 | 390 | ||
@@ -441,7 +441,7 @@ static struct attribute *veth_port_default_attrs[] = { | |||
441 | NULL | 441 | NULL |
442 | }; | 442 | }; |
443 | 443 | ||
444 | static struct sysfs_ops veth_port_sysfs_ops = { | 444 | static const struct sysfs_ops veth_port_sysfs_ops = { |
445 | .show = veth_port_attribute_show | 445 | .show = veth_port_attribute_show |
446 | }; | 446 | }; |
447 | 447 | ||
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c index 0bc5d474b168..1062b8ffe244 100644 --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c | |||
@@ -481,7 +481,7 @@ pdcspath_attr_store(struct kobject *kobj, struct attribute *attr, | |||
481 | return ret; | 481 | return ret; |
482 | } | 482 | } |
483 | 483 | ||
484 | static struct sysfs_ops pdcspath_attr_ops = { | 484 | static const struct sysfs_ops pdcspath_attr_ops = { |
485 | .show = pdcspath_attr_show, | 485 | .show = pdcspath_attr_show, |
486 | .store = pdcspath_attr_store, | 486 | .store = pdcspath_attr_store, |
487 | }; | 487 | }; |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 712250f5874a..26301cb25e7f 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -288,9 +288,9 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), | |||
288 | next = dev->bus_list.next; | 288 | next = dev->bus_list.next; |
289 | 289 | ||
290 | /* Run device routines with the device locked */ | 290 | /* Run device routines with the device locked */ |
291 | down(&dev->dev.sem); | 291 | device_lock(&dev->dev); |
292 | retval = cb(dev, userdata); | 292 | retval = cb(dev, userdata); |
293 | up(&dev->dev.sem); | 293 | device_unlock(&dev->dev); |
294 | if (retval) | 294 | if (retval) |
295 | break; | 295 | break; |
296 | } | 296 | } |
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c index 6151389fd903..0a894efd4b9b 100644 --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c | |||
@@ -73,7 +73,7 @@ static void legacy_release(struct kobject *kobj) | |||
73 | } | 73 | } |
74 | 74 | ||
75 | static struct kobj_type legacy_ktype = { | 75 | static struct kobj_type legacy_ktype = { |
76 | .sysfs_ops = &(struct sysfs_ops){ | 76 | .sysfs_ops = &(const struct sysfs_ops){ |
77 | .store = legacy_store, .show = legacy_show | 77 | .store = legacy_store, .show = legacy_show |
78 | }, | 78 | }, |
79 | .release = &legacy_release, | 79 | .release = &legacy_release, |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 807224ec8351..de296452c957 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -642,6 +642,7 @@ void pci_create_legacy_files(struct pci_bus *b) | |||
642 | if (!b->legacy_io) | 642 | if (!b->legacy_io) |
643 | goto kzalloc_err; | 643 | goto kzalloc_err; |
644 | 644 | ||
645 | sysfs_bin_attr_init(b->legacy_io); | ||
645 | b->legacy_io->attr.name = "legacy_io"; | 646 | b->legacy_io->attr.name = "legacy_io"; |
646 | b->legacy_io->size = 0xffff; | 647 | b->legacy_io->size = 0xffff; |
647 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; | 648 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; |
@@ -654,6 +655,7 @@ void pci_create_legacy_files(struct pci_bus *b) | |||
654 | goto legacy_io_err; | 655 | goto legacy_io_err; |
655 | 656 | ||
656 | /* Allocated above after the legacy_io struct */ | 657 | /* Allocated above after the legacy_io struct */ |
658 | sysfs_bin_attr_init(b->legacy_mem); | ||
657 | b->legacy_mem = b->legacy_io + 1; | 659 | b->legacy_mem = b->legacy_io + 1; |
658 | b->legacy_mem->attr.name = "legacy_mem"; | 660 | b->legacy_mem->attr.name = "legacy_mem"; |
659 | b->legacy_mem->size = 1024*1024; | 661 | b->legacy_mem->size = 1024*1024; |
@@ -800,6 +802,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine) | |||
800 | if (res_attr) { | 802 | if (res_attr) { |
801 | char *res_attr_name = (char *)(res_attr + 1); | 803 | char *res_attr_name = (char *)(res_attr + 1); |
802 | 804 | ||
805 | sysfs_bin_attr_init(res_attr); | ||
803 | if (write_combine) { | 806 | if (write_combine) { |
804 | pdev->res_attr_wc[num] = res_attr; | 807 | pdev->res_attr_wc[num] = res_attr; |
805 | sprintf(res_attr_name, "resource%d_wc", num); | 808 | sprintf(res_attr_name, "resource%d_wc", num); |
@@ -972,6 +975,7 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev) | |||
972 | if (!attr) | 975 | if (!attr) |
973 | return -ENOMEM; | 976 | return -ENOMEM; |
974 | 977 | ||
978 | sysfs_bin_attr_init(attr); | ||
975 | attr->size = dev->vpd->len; | 979 | attr->size = dev->vpd->len; |
976 | attr->attr.name = "vpd"; | 980 | attr->attr.name = "vpd"; |
977 | attr->attr.mode = S_IRUSR | S_IWUSR; | 981 | attr->attr.mode = S_IRUSR | S_IWUSR; |
@@ -1038,6 +1042,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
1038 | retval = -ENOMEM; | 1042 | retval = -ENOMEM; |
1039 | goto err_resource_files; | 1043 | goto err_resource_files; |
1040 | } | 1044 | } |
1045 | sysfs_bin_attr_init(attr); | ||
1041 | attr->size = rom_size; | 1046 | attr->size = rom_size; |
1042 | attr->attr.name = "rom"; | 1047 | attr->attr.name = "rom"; |
1043 | attr->attr.mode = S_IRUSR; | 1048 | attr->attr.mode = S_IRUSR; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 77b493b3d97b..cb1dd5f4988c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1583,8 +1583,10 @@ void pci_pm_init(struct pci_dev *dev) | |||
1583 | int pm; | 1583 | int pm; |
1584 | u16 pmc; | 1584 | u16 pmc; |
1585 | 1585 | ||
1586 | pm_runtime_forbid(&dev->dev); | ||
1586 | device_enable_async_suspend(&dev->dev); | 1587 | device_enable_async_suspend(&dev->dev); |
1587 | dev->wakeup_prepared = false; | 1588 | dev->wakeup_prepared = false; |
1589 | |||
1588 | dev->pm_cap = 0; | 1590 | dev->pm_cap = 0; |
1589 | 1591 | ||
1590 | /* find PCI PM capability in list */ | 1592 | /* find PCI PM capability in list */ |
@@ -2296,35 +2298,6 @@ void pci_msi_off(struct pci_dev *dev) | |||
2296 | } | 2298 | } |
2297 | } | 2299 | } |
2298 | 2300 | ||
2299 | #ifndef HAVE_ARCH_PCI_SET_DMA_MASK | ||
2300 | /* | ||
2301 | * These can be overridden by arch-specific implementations | ||
2302 | */ | ||
2303 | int | ||
2304 | pci_set_dma_mask(struct pci_dev *dev, u64 mask) | ||
2305 | { | ||
2306 | if (!pci_dma_supported(dev, mask)) | ||
2307 | return -EIO; | ||
2308 | |||
2309 | dev->dma_mask = mask; | ||
2310 | dev_dbg(&dev->dev, "using %dbit DMA mask\n", fls64(mask)); | ||
2311 | |||
2312 | return 0; | ||
2313 | } | ||
2314 | |||
2315 | int | ||
2316 | pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) | ||
2317 | { | ||
2318 | if (!pci_dma_supported(dev, mask)) | ||
2319 | return -EIO; | ||
2320 | |||
2321 | dev->dev.coherent_dma_mask = mask; | ||
2322 | dev_dbg(&dev->dev, "using %dbit consistent DMA mask\n", fls64(mask)); | ||
2323 | |||
2324 | return 0; | ||
2325 | } | ||
2326 | #endif | ||
2327 | |||
2328 | #ifndef HAVE_ARCH_PCI_SET_DMA_MAX_SEGMENT_SIZE | 2301 | #ifndef HAVE_ARCH_PCI_SET_DMA_MAX_SEGMENT_SIZE |
2329 | int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size) | 2302 | int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size) |
2330 | { | 2303 | { |
@@ -2486,7 +2459,7 @@ static int pci_dev_reset(struct pci_dev *dev, int probe) | |||
2486 | if (!probe) { | 2459 | if (!probe) { |
2487 | pci_block_user_cfg_access(dev); | 2460 | pci_block_user_cfg_access(dev); |
2488 | /* block PM suspend, driver probe, etc. */ | 2461 | /* block PM suspend, driver probe, etc. */ |
2489 | down(&dev->dev.sem); | 2462 | device_lock(&dev->dev); |
2490 | } | 2463 | } |
2491 | 2464 | ||
2492 | rc = pci_dev_specific_reset(dev, probe); | 2465 | rc = pci_dev_specific_reset(dev, probe); |
@@ -2508,7 +2481,7 @@ static int pci_dev_reset(struct pci_dev *dev, int probe) | |||
2508 | rc = pci_parent_bus_reset(dev, probe); | 2481 | rc = pci_parent_bus_reset(dev, probe); |
2509 | done: | 2482 | done: |
2510 | if (!probe) { | 2483 | if (!probe) { |
2511 | up(&dev->dev.sem); | 2484 | device_unlock(&dev->dev); |
2512 | pci_unblock_user_cfg_access(dev); | 2485 | pci_unblock_user_cfg_access(dev); |
2513 | } | 2486 | } |
2514 | 2487 | ||
@@ -3066,8 +3039,6 @@ EXPORT_SYMBOL(pci_set_mwi); | |||
3066 | EXPORT_SYMBOL(pci_try_set_mwi); | 3039 | EXPORT_SYMBOL(pci_try_set_mwi); |
3067 | EXPORT_SYMBOL(pci_clear_mwi); | 3040 | EXPORT_SYMBOL(pci_clear_mwi); |
3068 | EXPORT_SYMBOL_GPL(pci_intx); | 3041 | EXPORT_SYMBOL_GPL(pci_intx); |
3069 | EXPORT_SYMBOL(pci_set_dma_mask); | ||
3070 | EXPORT_SYMBOL(pci_set_consistent_dma_mask); | ||
3071 | EXPORT_SYMBOL(pci_assign_resource); | 3042 | EXPORT_SYMBOL(pci_assign_resource); |
3072 | EXPORT_SYMBOL(pci_find_parent_resource); | 3043 | EXPORT_SYMBOL(pci_find_parent_resource); |
3073 | EXPORT_SYMBOL(pci_select_bars); | 3044 | EXPORT_SYMBOL(pci_select_bars); |
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c index 49c9e6c9779a..f75a44d37fbe 100644 --- a/drivers/pci/slot.c +++ b/drivers/pci/slot.c | |||
@@ -29,7 +29,7 @@ static ssize_t pci_slot_attr_store(struct kobject *kobj, | |||
29 | return attribute->store ? attribute->store(slot, buf, len) : -EIO; | 29 | return attribute->store ? attribute->store(slot, buf, len) : -EIO; |
30 | } | 30 | } |
31 | 31 | ||
32 | static struct sysfs_ops pci_slot_sysfs_ops = { | 32 | static const struct sysfs_ops pci_slot_sysfs_ops = { |
33 | .show = pci_slot_attr_show, | 33 | .show = pci_slot_attr_show, |
34 | .store = pci_slot_attr_store, | 34 | .store = pci_slot_attr_store, |
35 | }; | 35 | }; |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 0f98be4450b7..ad93ebd7b2a2 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -971,9 +971,9 @@ static int runtime_suspend(struct device *dev) | |||
971 | { | 971 | { |
972 | int rc; | 972 | int rc; |
973 | 973 | ||
974 | down(&dev->sem); | 974 | device_lock(dev); |
975 | rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND); | 975 | rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND); |
976 | up(&dev->sem); | 976 | device_unlock(dev); |
977 | return rc; | 977 | return rc; |
978 | } | 978 | } |
979 | 979 | ||
@@ -981,9 +981,9 @@ static int runtime_resume(struct device *dev) | |||
981 | { | 981 | { |
982 | int rc; | 982 | int rc; |
983 | 983 | ||
984 | down(&dev->sem); | 984 | device_lock(dev); |
985 | rc = pcmcia_dev_resume(dev); | 985 | rc = pcmcia_dev_resume(dev); |
986 | up(&dev->sem); | 986 | device_unlock(dev); |
987 | return rc; | 987 | return rc; |
988 | } | 988 | } |
989 | 989 | ||
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c index de6bc333d299..db79ca61cf96 100644 --- a/drivers/pcmcia/sa1111_generic.c +++ b/drivers/pcmcia/sa1111_generic.c | |||
@@ -21,11 +21,18 @@ | |||
21 | 21 | ||
22 | #include "sa1111_generic.h" | 22 | #include "sa1111_generic.h" |
23 | 23 | ||
24 | #define IDX_IRQ_S0_READY_NINT (0) | ||
25 | #define IDX_IRQ_S0_CD_VALID (1) | ||
26 | #define IDX_IRQ_S0_BVD1_STSCHG (2) | ||
27 | #define IDX_IRQ_S1_READY_NINT (3) | ||
28 | #define IDX_IRQ_S1_CD_VALID (4) | ||
29 | #define IDX_IRQ_S1_BVD1_STSCHG (5) | ||
30 | |||
24 | static struct pcmcia_irqs irqs[] = { | 31 | static struct pcmcia_irqs irqs[] = { |
25 | { 0, IRQ_S0_CD_VALID, "SA1111 PCMCIA card detect" }, | 32 | { 0, NO_IRQ, "SA1111 PCMCIA card detect" }, |
26 | { 0, IRQ_S0_BVD1_STSCHG, "SA1111 PCMCIA BVD1" }, | 33 | { 0, NO_IRQ, "SA1111 PCMCIA BVD1" }, |
27 | { 1, IRQ_S1_CD_VALID, "SA1111 CF card detect" }, | 34 | { 1, NO_IRQ, "SA1111 CF card detect" }, |
28 | { 1, IRQ_S1_BVD1_STSCHG, "SA1111 CF BVD1" }, | 35 | { 1, NO_IRQ, "SA1111 CF BVD1" }, |
29 | }; | 36 | }; |
30 | 37 | ||
31 | static int sa1111_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | 38 | static int sa1111_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
@@ -136,7 +143,9 @@ int sa1111_pcmcia_add(struct sa1111_dev *dev, struct pcmcia_low_level *ops, | |||
136 | s->soc.ops = ops; | 143 | s->soc.ops = ops; |
137 | s->soc.socket.owner = ops->owner; | 144 | s->soc.socket.owner = ops->owner; |
138 | s->soc.socket.dev.parent = &dev->dev; | 145 | s->soc.socket.dev.parent = &dev->dev; |
139 | s->soc.socket.pci_irq = s->soc.nr ? IRQ_S1_READY_NINT : IRQ_S0_READY_NINT; | 146 | s->soc.socket.pci_irq = s->soc.nr ? |
147 | dev->irq[IDX_IRQ_S0_READY_NINT] : | ||
148 | dev->irq[IDX_IRQ_S1_READY_NINT]; | ||
140 | s->dev = dev; | 149 | s->dev = dev; |
141 | 150 | ||
142 | ret = add(&s->soc); | 151 | ret = add(&s->soc); |
@@ -162,6 +171,12 @@ static int pcmcia_probe(struct sa1111_dev *dev) | |||
162 | 171 | ||
163 | base = dev->mapbase; | 172 | base = dev->mapbase; |
164 | 173 | ||
174 | /* Initialize PCMCIA IRQs */ | ||
175 | irqs[0].irq = dev->irq[IDX_IRQ_S0_CD_VALID]; | ||
176 | irqs[1].irq = dev->irq[IDX_IRQ_S0_BVD1_STSCHG]; | ||
177 | irqs[2].irq = dev->irq[IDX_IRQ_S1_CD_VALID]; | ||
178 | irqs[3].irq = dev->irq[IDX_IRQ_S1_BVD1_STSCHG]; | ||
179 | |||
165 | /* | 180 | /* |
166 | * Initialise the suspend state. | 181 | * Initialise the suspend state. |
167 | */ | 182 | */ |
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index cd2ee6fce1b4..e631dbeafd79 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -150,6 +150,7 @@ config MSI_LAPTOP | |||
150 | tristate "MSI Laptop Extras" | 150 | tristate "MSI Laptop Extras" |
151 | depends on ACPI | 151 | depends on ACPI |
152 | depends on BACKLIGHT_CLASS_DEVICE | 152 | depends on BACKLIGHT_CLASS_DEVICE |
153 | depends on RFKILL | ||
153 | ---help--- | 154 | ---help--- |
154 | This is a driver for laptops built by MSI (MICRO-STAR | 155 | This is a driver for laptops built by MSI (MICRO-STAR |
155 | INTERNATIONAL): | 156 | INTERNATIONAL): |
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 3aa57da8b43b..7ccf33c08967 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c | |||
@@ -57,7 +57,7 @@ enum hp_wmi_radio { | |||
57 | HPWMI_WWAN = 2, | 57 | HPWMI_WWAN = 2, |
58 | }; | 58 | }; |
59 | 59 | ||
60 | static int __init hp_wmi_bios_setup(struct platform_device *device); | 60 | static int __devinit hp_wmi_bios_setup(struct platform_device *device); |
61 | static int __exit hp_wmi_bios_remove(struct platform_device *device); | 61 | static int __exit hp_wmi_bios_remove(struct platform_device *device); |
62 | static int hp_wmi_resume_handler(struct device *device); | 62 | static int hp_wmi_resume_handler(struct device *device); |
63 | 63 | ||
@@ -447,7 +447,7 @@ static void cleanup_sysfs(struct platform_device *device) | |||
447 | device_remove_file(&device->dev, &dev_attr_tablet); | 447 | device_remove_file(&device->dev, &dev_attr_tablet); |
448 | } | 448 | } |
449 | 449 | ||
450 | static int __init hp_wmi_bios_setup(struct platform_device *device) | 450 | static int __devinit hp_wmi_bios_setup(struct platform_device *device) |
451 | { | 451 | { |
452 | int err; | 452 | int err; |
453 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | 453 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); |
diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c index 759763d18e4c..c2b05da4289a 100644 --- a/drivers/platform/x86/msi-laptop.c +++ b/drivers/platform/x86/msi-laptop.c | |||
@@ -58,6 +58,7 @@ | |||
58 | #include <linux/dmi.h> | 58 | #include <linux/dmi.h> |
59 | #include <linux/backlight.h> | 59 | #include <linux/backlight.h> |
60 | #include <linux/platform_device.h> | 60 | #include <linux/platform_device.h> |
61 | #include <linux/rfkill.h> | ||
61 | 62 | ||
62 | #define MSI_DRIVER_VERSION "0.5" | 63 | #define MSI_DRIVER_VERSION "0.5" |
63 | 64 | ||
@@ -66,6 +67,20 @@ | |||
66 | #define MSI_EC_COMMAND_WIRELESS 0x10 | 67 | #define MSI_EC_COMMAND_WIRELESS 0x10 |
67 | #define MSI_EC_COMMAND_LCD_LEVEL 0x11 | 68 | #define MSI_EC_COMMAND_LCD_LEVEL 0x11 |
68 | 69 | ||
70 | #define MSI_STANDARD_EC_COMMAND_ADDRESS 0x2e | ||
71 | #define MSI_STANDARD_EC_BLUETOOTH_MASK (1 << 0) | ||
72 | #define MSI_STANDARD_EC_WEBCAM_MASK (1 << 1) | ||
73 | #define MSI_STANDARD_EC_WLAN_MASK (1 << 3) | ||
74 | #define MSI_STANDARD_EC_3G_MASK (1 << 4) | ||
75 | |||
76 | /* For set SCM load flag to disable BIOS fn key */ | ||
77 | #define MSI_STANDARD_EC_SCM_LOAD_ADDRESS 0x2d | ||
78 | #define MSI_STANDARD_EC_SCM_LOAD_MASK (1 << 0) | ||
79 | |||
80 | static int msi_laptop_resume(struct platform_device *device); | ||
81 | |||
82 | #define MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS 0x2f | ||
83 | |||
69 | static int force; | 84 | static int force; |
70 | module_param(force, bool, 0); | 85 | module_param(force, bool, 0); |
71 | MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); | 86 | MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); |
@@ -74,6 +89,23 @@ static int auto_brightness; | |||
74 | module_param(auto_brightness, int, 0); | 89 | module_param(auto_brightness, int, 0); |
75 | MODULE_PARM_DESC(auto_brightness, "Enable automatic brightness control (0: disabled; 1: enabled; 2: don't touch)"); | 90 | MODULE_PARM_DESC(auto_brightness, "Enable automatic brightness control (0: disabled; 1: enabled; 2: don't touch)"); |
76 | 91 | ||
92 | static bool old_ec_model; | ||
93 | static int wlan_s, bluetooth_s, threeg_s; | ||
94 | static int threeg_exists; | ||
95 | |||
96 | /* Some MSI 3G netbook only have one fn key to control Wlan/Bluetooth/3G, | ||
97 | * those netbook will load the SCM (windows app) to disable the original | ||
98 | * Wlan/Bluetooth control by BIOS when user press fn key, then control | ||
99 | * Wlan/Bluetooth/3G by SCM (software control by OS). Without SCM, user | ||
100 | * cann't on/off 3G module on those 3G netbook. | ||
101 | * On Linux, msi-laptop driver will do the same thing to disable the | ||
102 | * original BIOS control, then might need use HAL or other userland | ||
103 | * application to do the software control that simulate with SCM. | ||
104 | * e.g. MSI N034 netbook | ||
105 | */ | ||
106 | static bool load_scm_model; | ||
107 | static struct rfkill *rfk_wlan, *rfk_bluetooth, *rfk_threeg; | ||
108 | |||
77 | /* Hardware access */ | 109 | /* Hardware access */ |
78 | 110 | ||
79 | static int set_lcd_level(int level) | 111 | static int set_lcd_level(int level) |
@@ -130,6 +162,35 @@ static int set_auto_brightness(int enable) | |||
130 | return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 2, NULL, 0, 1); | 162 | return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 2, NULL, 0, 1); |
131 | } | 163 | } |
132 | 164 | ||
165 | static ssize_t set_device_state(const char *buf, size_t count, u8 mask) | ||
166 | { | ||
167 | int status; | ||
168 | u8 wdata = 0, rdata; | ||
169 | int result; | ||
170 | |||
171 | if (sscanf(buf, "%i", &status) != 1 || (status < 0 || status > 1)) | ||
172 | return -EINVAL; | ||
173 | |||
174 | /* read current device state */ | ||
175 | result = ec_read(MSI_STANDARD_EC_COMMAND_ADDRESS, &rdata); | ||
176 | if (result < 0) | ||
177 | return -EINVAL; | ||
178 | |||
179 | if (!!(rdata & mask) != status) { | ||
180 | /* reverse device bit */ | ||
181 | if (rdata & mask) | ||
182 | wdata = rdata & ~mask; | ||
183 | else | ||
184 | wdata = rdata | mask; | ||
185 | |||
186 | result = ec_write(MSI_STANDARD_EC_COMMAND_ADDRESS, wdata); | ||
187 | if (result < 0) | ||
188 | return -EINVAL; | ||
189 | } | ||
190 | |||
191 | return count; | ||
192 | } | ||
193 | |||
133 | static int get_wireless_state(int *wlan, int *bluetooth) | 194 | static int get_wireless_state(int *wlan, int *bluetooth) |
134 | { | 195 | { |
135 | u8 wdata = 0, rdata; | 196 | u8 wdata = 0, rdata; |
@@ -148,6 +209,38 @@ static int get_wireless_state(int *wlan, int *bluetooth) | |||
148 | return 0; | 209 | return 0; |
149 | } | 210 | } |
150 | 211 | ||
212 | static int get_wireless_state_ec_standard(void) | ||
213 | { | ||
214 | u8 rdata; | ||
215 | int result; | ||
216 | |||
217 | result = ec_read(MSI_STANDARD_EC_COMMAND_ADDRESS, &rdata); | ||
218 | if (result < 0) | ||
219 | return -1; | ||
220 | |||
221 | wlan_s = !!(rdata & MSI_STANDARD_EC_WLAN_MASK); | ||
222 | |||
223 | bluetooth_s = !!(rdata & MSI_STANDARD_EC_BLUETOOTH_MASK); | ||
224 | |||
225 | threeg_s = !!(rdata & MSI_STANDARD_EC_3G_MASK); | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static int get_threeg_exists(void) | ||
231 | { | ||
232 | u8 rdata; | ||
233 | int result; | ||
234 | |||
235 | result = ec_read(MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS, &rdata); | ||
236 | if (result < 0) | ||
237 | return -1; | ||
238 | |||
239 | threeg_exists = !!(rdata & MSI_STANDARD_EC_3G_MASK); | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | |||
151 | /* Backlight device stuff */ | 244 | /* Backlight device stuff */ |
152 | 245 | ||
153 | static int bl_get_brightness(struct backlight_device *b) | 246 | static int bl_get_brightness(struct backlight_device *b) |
@@ -176,26 +269,71 @@ static ssize_t show_wlan(struct device *dev, | |||
176 | 269 | ||
177 | int ret, enabled; | 270 | int ret, enabled; |
178 | 271 | ||
179 | ret = get_wireless_state(&enabled, NULL); | 272 | if (old_ec_model) { |
273 | ret = get_wireless_state(&enabled, NULL); | ||
274 | } else { | ||
275 | ret = get_wireless_state_ec_standard(); | ||
276 | enabled = wlan_s; | ||
277 | } | ||
180 | if (ret < 0) | 278 | if (ret < 0) |
181 | return ret; | 279 | return ret; |
182 | 280 | ||
183 | return sprintf(buf, "%i\n", enabled); | 281 | return sprintf(buf, "%i\n", enabled); |
184 | } | 282 | } |
185 | 283 | ||
284 | static ssize_t store_wlan(struct device *dev, | ||
285 | struct device_attribute *attr, const char *buf, size_t count) | ||
286 | { | ||
287 | return set_device_state(buf, count, MSI_STANDARD_EC_WLAN_MASK); | ||
288 | } | ||
289 | |||
186 | static ssize_t show_bluetooth(struct device *dev, | 290 | static ssize_t show_bluetooth(struct device *dev, |
187 | struct device_attribute *attr, char *buf) | 291 | struct device_attribute *attr, char *buf) |
188 | { | 292 | { |
189 | 293 | ||
190 | int ret, enabled; | 294 | int ret, enabled; |
191 | 295 | ||
192 | ret = get_wireless_state(NULL, &enabled); | 296 | if (old_ec_model) { |
297 | ret = get_wireless_state(NULL, &enabled); | ||
298 | } else { | ||
299 | ret = get_wireless_state_ec_standard(); | ||
300 | enabled = bluetooth_s; | ||
301 | } | ||
193 | if (ret < 0) | 302 | if (ret < 0) |
194 | return ret; | 303 | return ret; |
195 | 304 | ||
196 | return sprintf(buf, "%i\n", enabled); | 305 | return sprintf(buf, "%i\n", enabled); |
197 | } | 306 | } |
198 | 307 | ||
308 | static ssize_t store_bluetooth(struct device *dev, | ||
309 | struct device_attribute *attr, const char *buf, size_t count) | ||
310 | { | ||
311 | return set_device_state(buf, count, MSI_STANDARD_EC_BLUETOOTH_MASK); | ||
312 | } | ||
313 | |||
314 | static ssize_t show_threeg(struct device *dev, | ||
315 | struct device_attribute *attr, char *buf) | ||
316 | { | ||
317 | |||
318 | int ret; | ||
319 | |||
320 | /* old msi ec not support 3G */ | ||
321 | if (old_ec_model) | ||
322 | return -1; | ||
323 | |||
324 | ret = get_wireless_state_ec_standard(); | ||
325 | if (ret < 0) | ||
326 | return ret; | ||
327 | |||
328 | return sprintf(buf, "%i\n", threeg_s); | ||
329 | } | ||
330 | |||
331 | static ssize_t store_threeg(struct device *dev, | ||
332 | struct device_attribute *attr, const char *buf, size_t count) | ||
333 | { | ||
334 | return set_device_state(buf, count, MSI_STANDARD_EC_3G_MASK); | ||
335 | } | ||
336 | |||
199 | static ssize_t show_lcd_level(struct device *dev, | 337 | static ssize_t show_lcd_level(struct device *dev, |
200 | struct device_attribute *attr, char *buf) | 338 | struct device_attribute *attr, char *buf) |
201 | { | 339 | { |
@@ -258,6 +396,7 @@ static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level); | |||
258 | static DEVICE_ATTR(auto_brightness, 0644, show_auto_brightness, store_auto_brightness); | 396 | static DEVICE_ATTR(auto_brightness, 0644, show_auto_brightness, store_auto_brightness); |
259 | static DEVICE_ATTR(bluetooth, 0444, show_bluetooth, NULL); | 397 | static DEVICE_ATTR(bluetooth, 0444, show_bluetooth, NULL); |
260 | static DEVICE_ATTR(wlan, 0444, show_wlan, NULL); | 398 | static DEVICE_ATTR(wlan, 0444, show_wlan, NULL); |
399 | static DEVICE_ATTR(threeg, 0444, show_threeg, NULL); | ||
261 | 400 | ||
262 | static struct attribute *msipf_attributes[] = { | 401 | static struct attribute *msipf_attributes[] = { |
263 | &dev_attr_lcd_level.attr, | 402 | &dev_attr_lcd_level.attr, |
@@ -275,7 +414,8 @@ static struct platform_driver msipf_driver = { | |||
275 | .driver = { | 414 | .driver = { |
276 | .name = "msi-laptop-pf", | 415 | .name = "msi-laptop-pf", |
277 | .owner = THIS_MODULE, | 416 | .owner = THIS_MODULE, |
278 | } | 417 | }, |
418 | .resume = msi_laptop_resume, | ||
279 | }; | 419 | }; |
280 | 420 | ||
281 | static struct platform_device *msipf_device; | 421 | static struct platform_device *msipf_device; |
@@ -332,6 +472,192 @@ static struct dmi_system_id __initdata msi_dmi_table[] = { | |||
332 | { } | 472 | { } |
333 | }; | 473 | }; |
334 | 474 | ||
475 | static struct dmi_system_id __initdata msi_load_scm_models_dmi_table[] = { | ||
476 | { | ||
477 | .ident = "MSI N034", | ||
478 | .matches = { | ||
479 | DMI_MATCH(DMI_SYS_VENDOR, | ||
480 | "MICRO-STAR INTERNATIONAL CO., LTD"), | ||
481 | DMI_MATCH(DMI_PRODUCT_NAME, "MS-N034"), | ||
482 | DMI_MATCH(DMI_CHASSIS_VENDOR, | ||
483 | "MICRO-STAR INTERNATIONAL CO., LTD") | ||
484 | }, | ||
485 | .callback = dmi_check_cb | ||
486 | }, | ||
487 | { } | ||
488 | }; | ||
489 | |||
490 | static int rfkill_bluetooth_set(void *data, bool blocked) | ||
491 | { | ||
492 | /* Do something with blocked...*/ | ||
493 | /* | ||
494 | * blocked == false is on | ||
495 | * blocked == true is off | ||
496 | */ | ||
497 | if (blocked) | ||
498 | set_device_state("0", 0, MSI_STANDARD_EC_BLUETOOTH_MASK); | ||
499 | else | ||
500 | set_device_state("1", 0, MSI_STANDARD_EC_BLUETOOTH_MASK); | ||
501 | |||
502 | return 0; | ||
503 | } | ||
504 | |||
505 | static int rfkill_wlan_set(void *data, bool blocked) | ||
506 | { | ||
507 | if (blocked) | ||
508 | set_device_state("0", 0, MSI_STANDARD_EC_WLAN_MASK); | ||
509 | else | ||
510 | set_device_state("1", 0, MSI_STANDARD_EC_WLAN_MASK); | ||
511 | |||
512 | return 0; | ||
513 | } | ||
514 | |||
515 | static int rfkill_threeg_set(void *data, bool blocked) | ||
516 | { | ||
517 | if (blocked) | ||
518 | set_device_state("0", 0, MSI_STANDARD_EC_3G_MASK); | ||
519 | else | ||
520 | set_device_state("1", 0, MSI_STANDARD_EC_3G_MASK); | ||
521 | |||
522 | return 0; | ||
523 | } | ||
524 | |||
525 | static struct rfkill_ops rfkill_bluetooth_ops = { | ||
526 | .set_block = rfkill_bluetooth_set | ||
527 | }; | ||
528 | |||
529 | static struct rfkill_ops rfkill_wlan_ops = { | ||
530 | .set_block = rfkill_wlan_set | ||
531 | }; | ||
532 | |||
533 | static struct rfkill_ops rfkill_threeg_ops = { | ||
534 | .set_block = rfkill_threeg_set | ||
535 | }; | ||
536 | |||
537 | static void rfkill_cleanup(void) | ||
538 | { | ||
539 | if (rfk_bluetooth) { | ||
540 | rfkill_unregister(rfk_bluetooth); | ||
541 | rfkill_destroy(rfk_bluetooth); | ||
542 | } | ||
543 | |||
544 | if (rfk_threeg) { | ||
545 | rfkill_unregister(rfk_threeg); | ||
546 | rfkill_destroy(rfk_threeg); | ||
547 | } | ||
548 | |||
549 | if (rfk_wlan) { | ||
550 | rfkill_unregister(rfk_wlan); | ||
551 | rfkill_destroy(rfk_wlan); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | static int rfkill_init(struct platform_device *sdev) | ||
556 | { | ||
557 | /* add rfkill */ | ||
558 | int retval; | ||
559 | |||
560 | rfk_bluetooth = rfkill_alloc("msi-bluetooth", &sdev->dev, | ||
561 | RFKILL_TYPE_BLUETOOTH, | ||
562 | &rfkill_bluetooth_ops, NULL); | ||
563 | if (!rfk_bluetooth) { | ||
564 | retval = -ENOMEM; | ||
565 | goto err_bluetooth; | ||
566 | } | ||
567 | retval = rfkill_register(rfk_bluetooth); | ||
568 | if (retval) | ||
569 | goto err_bluetooth; | ||
570 | |||
571 | rfk_wlan = rfkill_alloc("msi-wlan", &sdev->dev, RFKILL_TYPE_WLAN, | ||
572 | &rfkill_wlan_ops, NULL); | ||
573 | if (!rfk_wlan) { | ||
574 | retval = -ENOMEM; | ||
575 | goto err_wlan; | ||
576 | } | ||
577 | retval = rfkill_register(rfk_wlan); | ||
578 | if (retval) | ||
579 | goto err_wlan; | ||
580 | |||
581 | if (threeg_exists) { | ||
582 | rfk_threeg = rfkill_alloc("msi-threeg", &sdev->dev, | ||
583 | RFKILL_TYPE_WWAN, &rfkill_threeg_ops, NULL); | ||
584 | if (!rfk_threeg) { | ||
585 | retval = -ENOMEM; | ||
586 | goto err_threeg; | ||
587 | } | ||
588 | retval = rfkill_register(rfk_threeg); | ||
589 | if (retval) | ||
590 | goto err_threeg; | ||
591 | } | ||
592 | |||
593 | return 0; | ||
594 | |||
595 | err_threeg: | ||
596 | rfkill_destroy(rfk_threeg); | ||
597 | if (rfk_wlan) | ||
598 | rfkill_unregister(rfk_wlan); | ||
599 | err_wlan: | ||
600 | rfkill_destroy(rfk_wlan); | ||
601 | if (rfk_bluetooth) | ||
602 | rfkill_unregister(rfk_bluetooth); | ||
603 | err_bluetooth: | ||
604 | rfkill_destroy(rfk_bluetooth); | ||
605 | |||
606 | return retval; | ||
607 | } | ||
608 | |||
609 | static int msi_laptop_resume(struct platform_device *device) | ||
610 | { | ||
611 | u8 data; | ||
612 | int result; | ||
613 | |||
614 | if (!load_scm_model) | ||
615 | return 0; | ||
616 | |||
617 | /* set load SCM to disable hardware control by fn key */ | ||
618 | result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data); | ||
619 | if (result < 0) | ||
620 | return result; | ||
621 | |||
622 | result = ec_write(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, | ||
623 | data | MSI_STANDARD_EC_SCM_LOAD_MASK); | ||
624 | if (result < 0) | ||
625 | return result; | ||
626 | |||
627 | return 0; | ||
628 | } | ||
629 | |||
630 | static int load_scm_model_init(struct platform_device *sdev) | ||
631 | { | ||
632 | u8 data; | ||
633 | int result; | ||
634 | |||
635 | /* allow userland write sysfs file */ | ||
636 | dev_attr_bluetooth.store = store_bluetooth; | ||
637 | dev_attr_wlan.store = store_wlan; | ||
638 | dev_attr_threeg.store = store_threeg; | ||
639 | dev_attr_bluetooth.attr.mode |= S_IWUSR; | ||
640 | dev_attr_wlan.attr.mode |= S_IWUSR; | ||
641 | dev_attr_threeg.attr.mode |= S_IWUSR; | ||
642 | |||
643 | /* disable hardware control by fn key */ | ||
644 | result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data); | ||
645 | if (result < 0) | ||
646 | return result; | ||
647 | |||
648 | result = ec_write(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, | ||
649 | data | MSI_STANDARD_EC_SCM_LOAD_MASK); | ||
650 | if (result < 0) | ||
651 | return result; | ||
652 | |||
653 | /* initial rfkill */ | ||
654 | result = rfkill_init(sdev); | ||
655 | if (result < 0) | ||
656 | return result; | ||
657 | |||
658 | return 0; | ||
659 | } | ||
660 | |||
335 | static int __init msi_init(void) | 661 | static int __init msi_init(void) |
336 | { | 662 | { |
337 | int ret; | 663 | int ret; |
@@ -339,8 +665,14 @@ static int __init msi_init(void) | |||
339 | if (acpi_disabled) | 665 | if (acpi_disabled) |
340 | return -ENODEV; | 666 | return -ENODEV; |
341 | 667 | ||
342 | if (!force && !dmi_check_system(msi_dmi_table)) | 668 | if (force || dmi_check_system(msi_dmi_table)) |
343 | return -ENODEV; | 669 | old_ec_model = 1; |
670 | |||
671 | if (!old_ec_model) | ||
672 | get_threeg_exists(); | ||
673 | |||
674 | if (!old_ec_model && dmi_check_system(msi_load_scm_models_dmi_table)) | ||
675 | load_scm_model = 1; | ||
344 | 676 | ||
345 | if (auto_brightness < 0 || auto_brightness > 2) | 677 | if (auto_brightness < 0 || auto_brightness > 2) |
346 | return -EINVAL; | 678 | return -EINVAL; |
@@ -374,10 +706,23 @@ static int __init msi_init(void) | |||
374 | if (ret) | 706 | if (ret) |
375 | goto fail_platform_device1; | 707 | goto fail_platform_device1; |
376 | 708 | ||
709 | if (load_scm_model && (load_scm_model_init(msipf_device) < 0)) { | ||
710 | ret = -EINVAL; | ||
711 | goto fail_platform_device1; | ||
712 | } | ||
713 | |||
377 | ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group); | 714 | ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group); |
378 | if (ret) | 715 | if (ret) |
379 | goto fail_platform_device2; | 716 | goto fail_platform_device2; |
380 | 717 | ||
718 | if (!old_ec_model) { | ||
719 | if (threeg_exists) | ||
720 | ret = device_create_file(&msipf_device->dev, | ||
721 | &dev_attr_threeg); | ||
722 | if (ret) | ||
723 | goto fail_platform_device2; | ||
724 | } | ||
725 | |||
381 | /* Disable automatic brightness control by default because | 726 | /* Disable automatic brightness control by default because |
382 | * this module was probably loaded to do brightness control in | 727 | * this module was probably loaded to do brightness control in |
383 | * software. */ | 728 | * software. */ |
@@ -412,10 +757,14 @@ static void __exit msi_cleanup(void) | |||
412 | { | 757 | { |
413 | 758 | ||
414 | sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); | 759 | sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); |
760 | if (!old_ec_model && threeg_exists) | ||
761 | device_remove_file(&msipf_device->dev, &dev_attr_threeg); | ||
415 | platform_device_unregister(msipf_device); | 762 | platform_device_unregister(msipf_device); |
416 | platform_driver_unregister(&msipf_driver); | 763 | platform_driver_unregister(&msipf_driver); |
417 | backlight_device_unregister(msibl_device); | 764 | backlight_device_unregister(msibl_device); |
418 | 765 | ||
766 | rfkill_cleanup(); | ||
767 | |||
419 | /* Enable automatic brightness control again */ | 768 | /* Enable automatic brightness control again */ |
420 | if (auto_brightness != 2) | 769 | if (auto_brightness != 2) |
421 | set_auto_brightness(1); | 770 | set_auto_brightness(1); |
@@ -435,3 +784,4 @@ MODULE_ALIAS("dmi:*:svnMICRO-STARINT'LCO.,LTD:pnMS-1013:pvr0131*:cvnMICRO-STARIN | |||
435 | MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1058:pvr0581:rvnMSI:rnMS-1058:*:ct10:*"); | 784 | MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1058:pvr0581:rvnMSI:rnMS-1058:*:ct10:*"); |
436 | MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1412:*:rvnMSI:rnMS-1412:*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); | 785 | MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1412:*:rvnMSI:rnMS-1412:*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); |
437 | MODULE_ALIAS("dmi:*:svnNOTEBOOK:pnSAM2000:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); | 786 | MODULE_ALIAS("dmi:*:svnNOTEBOOK:pnSAM2000:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); |
787 | MODULE_ALIAS("dmi:*:svnMICRO-STARINTERNATIONAL*:pnMS-N034:*"); | ||
diff --git a/drivers/pps/Kconfig b/drivers/pps/Kconfig index cc2eb8edb514..1afe4e03440f 100644 --- a/drivers/pps/Kconfig +++ b/drivers/pps/Kconfig | |||
@@ -30,4 +30,6 @@ config PPS_DEBUG | |||
30 | messages to the system log. Select this if you are having a | 30 | messages to the system log. Select this if you are having a |
31 | problem with PPS support and want to see more of what is going on. | 31 | problem with PPS support and want to see more of what is going on. |
32 | 32 | ||
33 | source drivers/pps/clients/Kconfig | ||
34 | |||
33 | endmenu | 35 | endmenu |
diff --git a/drivers/pps/Makefile b/drivers/pps/Makefile index 19ea582f431d..98960ddd3188 100644 --- a/drivers/pps/Makefile +++ b/drivers/pps/Makefile | |||
@@ -4,5 +4,6 @@ | |||
4 | 4 | ||
5 | pps_core-y := pps.o kapi.o sysfs.o | 5 | pps_core-y := pps.o kapi.o sysfs.o |
6 | obj-$(CONFIG_PPS) := pps_core.o | 6 | obj-$(CONFIG_PPS) := pps_core.o |
7 | obj-y += clients/ | ||
7 | 8 | ||
8 | ccflags-$(CONFIG_PPS_DEBUG) := -DDEBUG | 9 | ccflags-$(CONFIG_PPS_DEBUG) := -DDEBUG |
diff --git a/drivers/pps/clients/Kconfig b/drivers/pps/clients/Kconfig new file mode 100644 index 000000000000..4e801bd7254f --- /dev/null +++ b/drivers/pps/clients/Kconfig | |||
@@ -0,0 +1,25 @@ | |||
1 | # | ||
2 | # PPS clients configuration | ||
3 | # | ||
4 | |||
5 | if PPS | ||
6 | |||
7 | comment "PPS clients support" | ||
8 | |||
9 | config PPS_CLIENT_KTIMER | ||
10 | tristate "Kernel timer client (Testing client, use for debug)" | ||
11 | help | ||
12 | If you say yes here you get support for a PPS debugging client | ||
13 | which uses a kernel timer to generate the PPS signal. | ||
14 | |||
15 | This driver can also be built as a module. If so, the module | ||
16 | will be called pps-ktimer. | ||
17 | |||
18 | config PPS_CLIENT_LDISC | ||
19 | tristate "PPS line discipline" | ||
20 | depends on PPS | ||
21 | help | ||
22 | If you say yes here you get support for a PPS source connected | ||
23 | with the CD (Carrier Detect) pin of your serial port. | ||
24 | |||
25 | endif | ||
diff --git a/drivers/pps/clients/Makefile b/drivers/pps/clients/Makefile new file mode 100644 index 000000000000..812c9b19b430 --- /dev/null +++ b/drivers/pps/clients/Makefile | |||
@@ -0,0 +1,10 @@ | |||
1 | # | ||
2 | # Makefile for PPS clients. | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_PPS_CLIENT_KTIMER) += pps-ktimer.o | ||
6 | obj-$(CONFIG_PPS_CLIENT_LDISC) += pps-ldisc.o | ||
7 | |||
8 | ifeq ($(CONFIG_PPS_DEBUG),y) | ||
9 | EXTRA_CFLAGS += -DDEBUG | ||
10 | endif | ||
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c new file mode 100644 index 000000000000..e7ef5b8186d0 --- /dev/null +++ b/drivers/pps/clients/pps-ktimer.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * pps-ktimer.c -- kernel timer test client | ||
3 | * | ||
4 | * | ||
5 | * Copyright (C) 2005-2006 Rodolfo Giometti <giometti@linux.it> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/time.h> | ||
27 | #include <linux/timer.h> | ||
28 | #include <linux/pps_kernel.h> | ||
29 | |||
30 | /* | ||
31 | * Global variables | ||
32 | */ | ||
33 | |||
34 | static int source; | ||
35 | static struct timer_list ktimer; | ||
36 | |||
37 | /* | ||
38 | * The kernel timer | ||
39 | */ | ||
40 | |||
41 | static void pps_ktimer_event(unsigned long ptr) | ||
42 | { | ||
43 | struct timespec __ts; | ||
44 | struct pps_ktime ts; | ||
45 | |||
46 | /* First of all we get the time stamp... */ | ||
47 | getnstimeofday(&__ts); | ||
48 | |||
49 | pr_info("PPS event at %lu\n", jiffies); | ||
50 | |||
51 | /* ... and translate it to PPS time data struct */ | ||
52 | ts.sec = __ts.tv_sec; | ||
53 | ts.nsec = __ts.tv_nsec; | ||
54 | |||
55 | pps_event(source, &ts, PPS_CAPTUREASSERT, NULL); | ||
56 | |||
57 | mod_timer(&ktimer, jiffies + HZ); | ||
58 | } | ||
59 | |||
60 | /* | ||
61 | * The echo function | ||
62 | */ | ||
63 | |||
64 | static void pps_ktimer_echo(int source, int event, void *data) | ||
65 | { | ||
66 | pr_info("echo %s %s for source %d\n", | ||
67 | event & PPS_CAPTUREASSERT ? "assert" : "", | ||
68 | event & PPS_CAPTURECLEAR ? "clear" : "", | ||
69 | source); | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * The PPS info struct | ||
74 | */ | ||
75 | |||
76 | static struct pps_source_info pps_ktimer_info = { | ||
77 | .name = "ktimer", | ||
78 | .path = "", | ||
79 | .mode = PPS_CAPTUREASSERT | PPS_OFFSETASSERT | | ||
80 | PPS_ECHOASSERT | | ||
81 | PPS_CANWAIT | PPS_TSFMT_TSPEC, | ||
82 | .echo = pps_ktimer_echo, | ||
83 | .owner = THIS_MODULE, | ||
84 | }; | ||
85 | |||
86 | /* | ||
87 | * Module staff | ||
88 | */ | ||
89 | |||
90 | static void __exit pps_ktimer_exit(void) | ||
91 | { | ||
92 | del_timer_sync(&ktimer); | ||
93 | pps_unregister_source(source); | ||
94 | |||
95 | pr_info("ktimer PPS source unregistered\n"); | ||
96 | } | ||
97 | |||
98 | static int __init pps_ktimer_init(void) | ||
99 | { | ||
100 | int ret; | ||
101 | |||
102 | ret = pps_register_source(&pps_ktimer_info, | ||
103 | PPS_CAPTUREASSERT | PPS_OFFSETASSERT); | ||
104 | if (ret < 0) { | ||
105 | printk(KERN_ERR "cannot register ktimer source\n"); | ||
106 | return ret; | ||
107 | } | ||
108 | source = ret; | ||
109 | |||
110 | setup_timer(&ktimer, pps_ktimer_event, 0); | ||
111 | mod_timer(&ktimer, jiffies + HZ); | ||
112 | |||
113 | pr_info("ktimer PPS source registered at %d\n", source); | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | module_init(pps_ktimer_init); | ||
119 | module_exit(pps_ktimer_exit); | ||
120 | |||
121 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); | ||
122 | MODULE_DESCRIPTION("dummy PPS source by using a kernel timer (just for debug)"); | ||
123 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c new file mode 100644 index 000000000000..8e1932d29fd4 --- /dev/null +++ b/drivers/pps/clients/pps-ldisc.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * pps-ldisc.c -- PPS line discipline | ||
3 | * | ||
4 | * | ||
5 | * Copyright (C) 2008 Rodolfo Giometti <giometti@linux.it> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/serial_core.h> | ||
24 | #include <linux/tty.h> | ||
25 | #include <linux/pps_kernel.h> | ||
26 | |||
27 | #define PPS_TTY_MAGIC 0x0001 | ||
28 | |||
29 | static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, | ||
30 | struct timespec *ts) | ||
31 | { | ||
32 | int id = (long)tty->disc_data; | ||
33 | struct timespec __ts; | ||
34 | struct pps_ktime pps_ts; | ||
35 | |||
36 | /* First of all we get the time stamp... */ | ||
37 | getnstimeofday(&__ts); | ||
38 | |||
39 | /* Does caller give us a timestamp? */ | ||
40 | if (ts) { /* Yes. Let's use it! */ | ||
41 | pps_ts.sec = ts->tv_sec; | ||
42 | pps_ts.nsec = ts->tv_nsec; | ||
43 | } else { /* No. Do it ourself! */ | ||
44 | pps_ts.sec = __ts.tv_sec; | ||
45 | pps_ts.nsec = __ts.tv_nsec; | ||
46 | } | ||
47 | |||
48 | /* Now do the PPS event report */ | ||
49 | pps_event(id, &pps_ts, status ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR, | ||
50 | NULL); | ||
51 | |||
52 | pr_debug("PPS %s at %lu on source #%d\n", | ||
53 | status ? "assert" : "clear", jiffies, id); | ||
54 | } | ||
55 | |||
56 | static int (*alias_n_tty_open)(struct tty_struct *tty); | ||
57 | |||
58 | static int pps_tty_open(struct tty_struct *tty) | ||
59 | { | ||
60 | struct pps_source_info info; | ||
61 | struct tty_driver *drv = tty->driver; | ||
62 | int index = tty->index + drv->name_base; | ||
63 | int ret; | ||
64 | |||
65 | info.owner = THIS_MODULE; | ||
66 | info.dev = NULL; | ||
67 | snprintf(info.name, PPS_MAX_NAME_LEN, "%s%d", drv->driver_name, index); | ||
68 | snprintf(info.path, PPS_MAX_NAME_LEN, "/dev/%s%d", drv->name, index); | ||
69 | info.mode = PPS_CAPTUREBOTH | \ | ||
70 | PPS_OFFSETASSERT | PPS_OFFSETCLEAR | \ | ||
71 | PPS_CANWAIT | PPS_TSFMT_TSPEC; | ||
72 | |||
73 | ret = pps_register_source(&info, PPS_CAPTUREBOTH | \ | ||
74 | PPS_OFFSETASSERT | PPS_OFFSETCLEAR); | ||
75 | if (ret < 0) { | ||
76 | pr_err("cannot register PPS source \"%s\"\n", info.path); | ||
77 | return ret; | ||
78 | } | ||
79 | tty->disc_data = (void *)(long)ret; | ||
80 | |||
81 | /* Should open N_TTY ldisc too */ | ||
82 | ret = alias_n_tty_open(tty); | ||
83 | if (ret < 0) | ||
84 | pps_unregister_source((long)tty->disc_data); | ||
85 | |||
86 | pr_info("PPS source #%d \"%s\" added\n", ret, info.path); | ||
87 | |||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | static void (*alias_n_tty_close)(struct tty_struct *tty); | ||
92 | |||
93 | static void pps_tty_close(struct tty_struct *tty) | ||
94 | { | ||
95 | int id = (long)tty->disc_data; | ||
96 | |||
97 | pps_unregister_source(id); | ||
98 | alias_n_tty_close(tty); | ||
99 | |||
100 | pr_info("PPS source #%d removed\n", id); | ||
101 | } | ||
102 | |||
103 | static struct tty_ldisc_ops pps_ldisc_ops; | ||
104 | |||
105 | /* | ||
106 | * Module stuff | ||
107 | */ | ||
108 | |||
109 | static int __init pps_tty_init(void) | ||
110 | { | ||
111 | int err; | ||
112 | |||
113 | /* Inherit the N_TTY's ops */ | ||
114 | n_tty_inherit_ops(&pps_ldisc_ops); | ||
115 | |||
116 | /* Save N_TTY's open()/close() methods */ | ||
117 | alias_n_tty_open = pps_ldisc_ops.open; | ||
118 | alias_n_tty_close = pps_ldisc_ops.close; | ||
119 | |||
120 | /* Init PPS_TTY data */ | ||
121 | pps_ldisc_ops.owner = THIS_MODULE; | ||
122 | pps_ldisc_ops.magic = PPS_TTY_MAGIC; | ||
123 | pps_ldisc_ops.name = "pps_tty"; | ||
124 | pps_ldisc_ops.dcd_change = pps_tty_dcd_change; | ||
125 | pps_ldisc_ops.open = pps_tty_open; | ||
126 | pps_ldisc_ops.close = pps_tty_close; | ||
127 | |||
128 | err = tty_register_ldisc(N_PPS, &pps_ldisc_ops); | ||
129 | if (err) | ||
130 | pr_err("can't register PPS line discipline\n"); | ||
131 | else | ||
132 | pr_info("PPS line discipline registered\n"); | ||
133 | |||
134 | return err; | ||
135 | } | ||
136 | |||
137 | static void __exit pps_tty_cleanup(void) | ||
138 | { | ||
139 | int err; | ||
140 | |||
141 | err = tty_unregister_ldisc(N_PPS); | ||
142 | if (err) | ||
143 | pr_err("can't unregister PPS line discipline\n"); | ||
144 | else | ||
145 | pr_info("PPS line discipline removed\n"); | ||
146 | } | ||
147 | |||
148 | module_init(pps_tty_init); | ||
149 | module_exit(pps_tty_cleanup); | ||
150 | |||
151 | MODULE_ALIAS_LDISC(N_PPS); | ||
152 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); | ||
153 | MODULE_DESCRIPTION("PPS TTY device driver"); | ||
154 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c index 33c0e98243ee..bc90b091f195 100644 --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c | |||
@@ -22,48 +22,57 @@ | |||
22 | * the best guess is to add 0.5s. | 22 | * the best guess is to add 0.5s. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | int rtc_hctosys_ret = -ENODEV; | ||
26 | |||
25 | static int __init rtc_hctosys(void) | 27 | static int __init rtc_hctosys(void) |
26 | { | 28 | { |
27 | int err; | 29 | int err = -ENODEV; |
28 | struct rtc_time tm; | 30 | struct rtc_time tm; |
31 | struct timespec tv = { | ||
32 | .tv_nsec = NSEC_PER_SEC >> 1, | ||
33 | }; | ||
29 | struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); | 34 | struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); |
30 | 35 | ||
31 | if (rtc == NULL) { | 36 | if (rtc == NULL) { |
32 | printk("%s: unable to open rtc device (%s)\n", | 37 | pr_err("%s: unable to open rtc device (%s)\n", |
33 | __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); | 38 | __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); |
34 | return -ENODEV; | 39 | goto err_open; |
35 | } | 40 | } |
36 | 41 | ||
37 | err = rtc_read_time(rtc, &tm); | 42 | err = rtc_read_time(rtc, &tm); |
38 | if (err == 0) { | 43 | if (err) { |
39 | err = rtc_valid_tm(&tm); | 44 | dev_err(rtc->dev.parent, |
40 | if (err == 0) { | 45 | "hctosys: unable to read the hardware clock\n"); |
41 | struct timespec tv; | 46 | goto err_read; |
42 | 47 | ||
43 | tv.tv_nsec = NSEC_PER_SEC >> 1; | 48 | } |
44 | 49 | ||
45 | rtc_tm_to_time(&tm, &tv.tv_sec); | 50 | err = rtc_valid_tm(&tm); |
51 | if (err) { | ||
52 | dev_err(rtc->dev.parent, | ||
53 | "hctosys: invalid date/time\n"); | ||
54 | goto err_invalid; | ||
55 | } | ||
46 | 56 | ||
47 | do_settimeofday(&tv); | 57 | rtc_tm_to_time(&tm, &tv.tv_sec); |
48 | 58 | ||
49 | dev_info(rtc->dev.parent, | 59 | do_settimeofday(&tv); |
50 | "setting system clock to " | ||
51 | "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", | ||
52 | tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | ||
53 | tm.tm_hour, tm.tm_min, tm.tm_sec, | ||
54 | (unsigned int) tv.tv_sec); | ||
55 | } | ||
56 | else | ||
57 | dev_err(rtc->dev.parent, | ||
58 | "hctosys: invalid date/time\n"); | ||
59 | } | ||
60 | else | ||
61 | dev_err(rtc->dev.parent, | ||
62 | "hctosys: unable to read the hardware clock\n"); | ||
63 | 60 | ||
61 | dev_info(rtc->dev.parent, | ||
62 | "setting system clock to " | ||
63 | "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", | ||
64 | tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | ||
65 | tm.tm_hour, tm.tm_min, tm.tm_sec, | ||
66 | (unsigned int) tv.tv_sec); | ||
67 | |||
68 | err_invalid: | ||
69 | err_read: | ||
64 | rtc_class_close(rtc); | 70 | rtc_class_close(rtc); |
65 | 71 | ||
66 | return 0; | 72 | err_open: |
73 | rtc_hctosys_ret = err; | ||
74 | |||
75 | return err; | ||
67 | } | 76 | } |
68 | 77 | ||
69 | late_initcall(rtc_hctosys); | 78 | late_initcall(rtc_hctosys); |
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index 7dd23a6fc825..380083ca572f 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c | |||
@@ -107,8 +107,9 @@ rtc_sysfs_show_hctosys(struct device *dev, struct device_attribute *attr, | |||
107 | char *buf) | 107 | char *buf) |
108 | { | 108 | { |
109 | #ifdef CONFIG_RTC_HCTOSYS_DEVICE | 109 | #ifdef CONFIG_RTC_HCTOSYS_DEVICE |
110 | if (strcmp(dev_name(&to_rtc_device(dev)->dev), | 110 | if (rtc_hctosys_ret == 0 && |
111 | CONFIG_RTC_HCTOSYS_DEVICE) == 0) | 111 | strcmp(dev_name(&to_rtc_device(dev)->dev), |
112 | CONFIG_RTC_HCTOSYS_DEVICE) == 0) | ||
112 | return sprintf(buf, "1\n"); | 113 | return sprintf(buf, "1\n"); |
113 | else | 114 | else |
114 | #endif | 115 | #endif |
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 4951aa82e9f5..bbea90baf98f 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <asm/ebcdic.h> | 26 | #include <asm/ebcdic.h> |
27 | #include <asm/idals.h> | 27 | #include <asm/idals.h> |
28 | #include <asm/itcw.h> | 28 | #include <asm/itcw.h> |
29 | #include <asm/diag.h> | ||
29 | 30 | ||
30 | /* This is ugly... */ | 31 | /* This is ugly... */ |
31 | #define PRINTK_HEADER "dasd:" | 32 | #define PRINTK_HEADER "dasd:" |
@@ -2212,6 +2213,13 @@ static int dasd_open(struct block_device *bdev, fmode_t mode) | |||
2212 | goto out; | 2213 | goto out; |
2213 | } | 2214 | } |
2214 | 2215 | ||
2216 | if ((mode & FMODE_WRITE) && | ||
2217 | (test_bit(DASD_FLAG_DEVICE_RO, &base->flags) || | ||
2218 | (base->features & DASD_FEATURE_READONLY))) { | ||
2219 | rc = -EROFS; | ||
2220 | goto out; | ||
2221 | } | ||
2222 | |||
2215 | return 0; | 2223 | return 0; |
2216 | 2224 | ||
2217 | out: | 2225 | out: |
@@ -2289,6 +2297,34 @@ dasd_exit(void) | |||
2289 | * SECTION: common functions for ccw_driver use | 2297 | * SECTION: common functions for ccw_driver use |
2290 | */ | 2298 | */ |
2291 | 2299 | ||
2300 | /* | ||
2301 | * Is the device read-only? | ||
2302 | * Note that this function does not report the setting of the | ||
2303 | * readonly device attribute, but how it is configured in z/VM. | ||
2304 | */ | ||
2305 | int dasd_device_is_ro(struct dasd_device *device) | ||
2306 | { | ||
2307 | struct ccw_dev_id dev_id; | ||
2308 | struct diag210 diag_data; | ||
2309 | int rc; | ||
2310 | |||
2311 | if (!MACHINE_IS_VM) | ||
2312 | return 0; | ||
2313 | ccw_device_get_id(device->cdev, &dev_id); | ||
2314 | memset(&diag_data, 0, sizeof(diag_data)); | ||
2315 | diag_data.vrdcdvno = dev_id.devno; | ||
2316 | diag_data.vrdclen = sizeof(diag_data); | ||
2317 | rc = diag210(&diag_data); | ||
2318 | if (rc == 0 || rc == 2) { | ||
2319 | return diag_data.vrdcvfla & 0x80; | ||
2320 | } else { | ||
2321 | DBF_EVENT(DBF_WARNING, "diag210 failed for dev=%04x with rc=%d", | ||
2322 | dev_id.devno, rc); | ||
2323 | return 0; | ||
2324 | } | ||
2325 | } | ||
2326 | EXPORT_SYMBOL_GPL(dasd_device_is_ro); | ||
2327 | |||
2292 | static void dasd_generic_auto_online(void *data, async_cookie_t cookie) | 2328 | static void dasd_generic_auto_online(void *data, async_cookie_t cookie) |
2293 | { | 2329 | { |
2294 | struct ccw_device *cdev = data; | 2330 | struct ccw_device *cdev = data; |
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c index 44796ba4eb9b..51224f76b980 100644 --- a/drivers/s390/block/dasd_3990_erp.c +++ b/drivers/s390/block/dasd_3990_erp.c | |||
@@ -1045,6 +1045,10 @@ dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense) | |||
1045 | 1045 | ||
1046 | erp->retries = 5; | 1046 | erp->retries = 5; |
1047 | 1047 | ||
1048 | } else if (sense[1] & SNS1_WRITE_INHIBITED) { | ||
1049 | dev_err(&device->cdev->dev, "An I/O request was rejected" | ||
1050 | " because writing is inhibited\n"); | ||
1051 | erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED); | ||
1048 | } else { | 1052 | } else { |
1049 | /* fatal error - set status to FAILED | 1053 | /* fatal error - set status to FAILED |
1050 | internal error 09 - Command Reject */ | 1054 | internal error 09 - Command Reject */ |
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c index d49766f3b940..8e23919c8704 100644 --- a/drivers/s390/block/dasd_devmap.c +++ b/drivers/s390/block/dasd_devmap.c | |||
@@ -742,6 +742,7 @@ dasd_ro_store(struct device *dev, struct device_attribute *attr, | |||
742 | const char *buf, size_t count) | 742 | const char *buf, size_t count) |
743 | { | 743 | { |
744 | struct dasd_devmap *devmap; | 744 | struct dasd_devmap *devmap; |
745 | struct dasd_device *device; | ||
745 | int val; | 746 | int val; |
746 | char *endp; | 747 | char *endp; |
747 | 748 | ||
@@ -758,12 +759,14 @@ dasd_ro_store(struct device *dev, struct device_attribute *attr, | |||
758 | devmap->features |= DASD_FEATURE_READONLY; | 759 | devmap->features |= DASD_FEATURE_READONLY; |
759 | else | 760 | else |
760 | devmap->features &= ~DASD_FEATURE_READONLY; | 761 | devmap->features &= ~DASD_FEATURE_READONLY; |
761 | if (devmap->device) | 762 | device = devmap->device; |
762 | devmap->device->features = devmap->features; | 763 | if (device) { |
763 | if (devmap->device && devmap->device->block | 764 | device->features = devmap->features; |
764 | && devmap->device->block->gdp) | 765 | val = val || test_bit(DASD_FLAG_DEVICE_RO, &device->flags); |
765 | set_disk_ro(devmap->device->block->gdp, val); | 766 | } |
766 | spin_unlock(&dasd_devmap_lock); | 767 | spin_unlock(&dasd_devmap_lock); |
768 | if (device && device->block && device->block->gdp) | ||
769 | set_disk_ro(device->block->gdp, val); | ||
767 | return count; | 770 | return count; |
768 | } | 771 | } |
769 | 772 | ||
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c index 6e14863f5c70..687f323cdc38 100644 --- a/drivers/s390/block/dasd_diag.c +++ b/drivers/s390/block/dasd_diag.c | |||
@@ -145,12 +145,10 @@ dasd_diag_erp(struct dasd_device *device) | |||
145 | mdsk_term_io(device); | 145 | mdsk_term_io(device); |
146 | rc = mdsk_init_io(device, device->block->bp_block, 0, NULL); | 146 | rc = mdsk_init_io(device, device->block->bp_block, 0, NULL); |
147 | if (rc == 4) { | 147 | if (rc == 4) { |
148 | if (!(device->features & DASD_FEATURE_READONLY)) { | 148 | if (!(test_and_set_bit(DASD_FLAG_DEVICE_RO, &device->flags))) |
149 | pr_warning("%s: The access mode of a DIAG device " | 149 | pr_warning("%s: The access mode of a DIAG device " |
150 | "changed to read-only\n", | 150 | "changed to read-only\n", |
151 | dev_name(&device->cdev->dev)); | 151 | dev_name(&device->cdev->dev)); |
152 | device->features |= DASD_FEATURE_READONLY; | ||
153 | } | ||
154 | rc = 0; | 152 | rc = 0; |
155 | } | 153 | } |
156 | if (rc) | 154 | if (rc) |
@@ -449,7 +447,7 @@ dasd_diag_check_device(struct dasd_device *device) | |||
449 | rc = -EIO; | 447 | rc = -EIO; |
450 | } else { | 448 | } else { |
451 | if (rc == 4) | 449 | if (rc == 4) |
452 | device->features |= DASD_FEATURE_READONLY; | 450 | set_bit(DASD_FLAG_DEVICE_RO, &device->flags); |
453 | pr_info("%s: New DASD with %ld byte/block, total size %ld " | 451 | pr_info("%s: New DASD with %ld byte/block, total size %ld " |
454 | "KB%s\n", dev_name(&device->cdev->dev), | 452 | "KB%s\n", dev_name(&device->cdev->dev), |
455 | (unsigned long) block->bp_block, | 453 | (unsigned long) block->bp_block, |
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index 1cca21aafaba..01f4e7a34aa8 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c | |||
@@ -1089,6 +1089,7 @@ dasd_eckd_check_characteristics(struct dasd_device *device) | |||
1089 | struct dasd_eckd_private *private; | 1089 | struct dasd_eckd_private *private; |
1090 | struct dasd_block *block; | 1090 | struct dasd_block *block; |
1091 | int is_known, rc; | 1091 | int is_known, rc; |
1092 | int readonly; | ||
1092 | 1093 | ||
1093 | if (!ccw_device_is_pathgroup(device->cdev)) { | 1094 | if (!ccw_device_is_pathgroup(device->cdev)) { |
1094 | dev_warn(&device->cdev->dev, | 1095 | dev_warn(&device->cdev->dev, |
@@ -1182,15 +1183,20 @@ dasd_eckd_check_characteristics(struct dasd_device *device) | |||
1182 | else | 1183 | else |
1183 | private->real_cyl = private->rdc_data.no_cyl; | 1184 | private->real_cyl = private->rdc_data.no_cyl; |
1184 | 1185 | ||
1186 | readonly = dasd_device_is_ro(device); | ||
1187 | if (readonly) | ||
1188 | set_bit(DASD_FLAG_DEVICE_RO, &device->flags); | ||
1189 | |||
1185 | dev_info(&device->cdev->dev, "New DASD %04X/%02X (CU %04X/%02X) " | 1190 | dev_info(&device->cdev->dev, "New DASD %04X/%02X (CU %04X/%02X) " |
1186 | "with %d cylinders, %d heads, %d sectors\n", | 1191 | "with %d cylinders, %d heads, %d sectors%s\n", |
1187 | private->rdc_data.dev_type, | 1192 | private->rdc_data.dev_type, |
1188 | private->rdc_data.dev_model, | 1193 | private->rdc_data.dev_model, |
1189 | private->rdc_data.cu_type, | 1194 | private->rdc_data.cu_type, |
1190 | private->rdc_data.cu_model.model, | 1195 | private->rdc_data.cu_model.model, |
1191 | private->real_cyl, | 1196 | private->real_cyl, |
1192 | private->rdc_data.trk_per_cyl, | 1197 | private->rdc_data.trk_per_cyl, |
1193 | private->rdc_data.sec_per_trk); | 1198 | private->rdc_data.sec_per_trk, |
1199 | readonly ? ", read-only device" : ""); | ||
1194 | return 0; | 1200 | return 0; |
1195 | 1201 | ||
1196 | out_err3: | 1202 | out_err3: |
@@ -2839,8 +2845,13 @@ static int dasd_symm_io(struct dasd_device *device, void __user *argp) | |||
2839 | char *psf_data, *rssd_result; | 2845 | char *psf_data, *rssd_result; |
2840 | struct dasd_ccw_req *cqr; | 2846 | struct dasd_ccw_req *cqr; |
2841 | struct ccw1 *ccw; | 2847 | struct ccw1 *ccw; |
2848 | char psf0, psf1; | ||
2842 | int rc; | 2849 | int rc; |
2843 | 2850 | ||
2851 | if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO)) | ||
2852 | return -EACCES; | ||
2853 | psf0 = psf1 = 0; | ||
2854 | |||
2844 | /* Copy parms from caller */ | 2855 | /* Copy parms from caller */ |
2845 | rc = -EFAULT; | 2856 | rc = -EFAULT; |
2846 | if (copy_from_user(&usrparm, argp, sizeof(usrparm))) | 2857 | if (copy_from_user(&usrparm, argp, sizeof(usrparm))) |
@@ -2869,12 +2880,8 @@ static int dasd_symm_io(struct dasd_device *device, void __user *argp) | |||
2869 | (void __user *)(unsigned long) usrparm.psf_data, | 2880 | (void __user *)(unsigned long) usrparm.psf_data, |
2870 | usrparm.psf_data_len)) | 2881 | usrparm.psf_data_len)) |
2871 | goto out_free; | 2882 | goto out_free; |
2872 | 2883 | psf0 = psf_data[0]; | |
2873 | /* sanity check on syscall header */ | 2884 | psf1 = psf_data[1]; |
2874 | if (psf_data[0] != 0x17 && psf_data[1] != 0xce) { | ||
2875 | rc = -EINVAL; | ||
2876 | goto out_free; | ||
2877 | } | ||
2878 | 2885 | ||
2879 | /* setup CCWs for PSF + RSSD */ | 2886 | /* setup CCWs for PSF + RSSD */ |
2880 | cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 2 , 0, device); | 2887 | cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 2 , 0, device); |
@@ -2925,7 +2932,9 @@ out_free: | |||
2925 | kfree(rssd_result); | 2932 | kfree(rssd_result); |
2926 | kfree(psf_data); | 2933 | kfree(psf_data); |
2927 | out: | 2934 | out: |
2928 | DBF_DEV_EVENT(DBF_WARNING, device, "Symmetrix ioctl: rc=%d", rc); | 2935 | DBF_DEV_EVENT(DBF_WARNING, device, |
2936 | "Symmetrix ioctl (0x%02x 0x%02x): rc=%d", | ||
2937 | (int) psf0, (int) psf1, rc); | ||
2929 | return rc; | 2938 | return rc; |
2930 | } | 2939 | } |
2931 | 2940 | ||
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c index 0f152444ac77..37282b90eecc 100644 --- a/drivers/s390/block/dasd_fba.c +++ b/drivers/s390/block/dasd_fba.c | |||
@@ -124,6 +124,7 @@ dasd_fba_check_characteristics(struct dasd_device *device) | |||
124 | struct dasd_fba_private *private; | 124 | struct dasd_fba_private *private; |
125 | struct ccw_device *cdev = device->cdev; | 125 | struct ccw_device *cdev = device->cdev; |
126 | int rc; | 126 | int rc; |
127 | int readonly; | ||
127 | 128 | ||
128 | private = (struct dasd_fba_private *) device->private; | 129 | private = (struct dasd_fba_private *) device->private; |
129 | if (!private) { | 130 | if (!private) { |
@@ -162,16 +163,21 @@ dasd_fba_check_characteristics(struct dasd_device *device) | |||
162 | return rc; | 163 | return rc; |
163 | } | 164 | } |
164 | 165 | ||
166 | readonly = dasd_device_is_ro(device); | ||
167 | if (readonly) | ||
168 | set_bit(DASD_FLAG_DEVICE_RO, &device->flags); | ||
169 | |||
165 | dev_info(&device->cdev->dev, | 170 | dev_info(&device->cdev->dev, |
166 | "New FBA DASD %04X/%02X (CU %04X/%02X) with %d MB " | 171 | "New FBA DASD %04X/%02X (CU %04X/%02X) with %d MB " |
167 | "and %d B/blk\n", | 172 | "and %d B/blk%s\n", |
168 | cdev->id.dev_type, | 173 | cdev->id.dev_type, |
169 | cdev->id.dev_model, | 174 | cdev->id.dev_model, |
170 | cdev->id.cu_type, | 175 | cdev->id.cu_type, |
171 | cdev->id.cu_model, | 176 | cdev->id.cu_model, |
172 | ((private->rdc_data.blk_bdsa * | 177 | ((private->rdc_data.blk_bdsa * |
173 | (private->rdc_data.blk_size >> 9)) >> 11), | 178 | (private->rdc_data.blk_size >> 9)) >> 11), |
174 | private->rdc_data.blk_size); | 179 | private->rdc_data.blk_size, |
180 | readonly ? ", read-only device" : ""); | ||
175 | return 0; | 181 | return 0; |
176 | } | 182 | } |
177 | 183 | ||
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c index 94f92a1247f2..30a1ca3d08b7 100644 --- a/drivers/s390/block/dasd_genhd.c +++ b/drivers/s390/block/dasd_genhd.c | |||
@@ -70,7 +70,8 @@ int dasd_gendisk_alloc(struct dasd_block *block) | |||
70 | } | 70 | } |
71 | len += sprintf(gdp->disk_name + len, "%c", 'a'+(base->devindex%26)); | 71 | len += sprintf(gdp->disk_name + len, "%c", 'a'+(base->devindex%26)); |
72 | 72 | ||
73 | if (block->base->features & DASD_FEATURE_READONLY) | 73 | if (base->features & DASD_FEATURE_READONLY || |
74 | test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) | ||
74 | set_disk_ro(gdp, 1); | 75 | set_disk_ro(gdp, 1); |
75 | gdp->private_data = block; | 76 | gdp->private_data = block; |
76 | gdp->queue = block->request_queue; | 77 | gdp->queue = block->request_queue; |
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h index ed73ce550822..a91d4a97d4f2 100644 --- a/drivers/s390/block/dasd_int.h +++ b/drivers/s390/block/dasd_int.h | |||
@@ -436,6 +436,10 @@ struct dasd_block { | |||
436 | #define DASD_FLAG_OFFLINE 3 /* device is in offline processing */ | 436 | #define DASD_FLAG_OFFLINE 3 /* device is in offline processing */ |
437 | #define DASD_FLAG_EER_SNSS 4 /* A SNSS is required */ | 437 | #define DASD_FLAG_EER_SNSS 4 /* A SNSS is required */ |
438 | #define DASD_FLAG_EER_IN_USE 5 /* A SNSS request is running */ | 438 | #define DASD_FLAG_EER_IN_USE 5 /* A SNSS request is running */ |
439 | #define DASD_FLAG_DEVICE_RO 6 /* The device itself is read-only. Don't | ||
440 | * confuse this with the user specified | ||
441 | * read-only feature. | ||
442 | */ | ||
439 | 443 | ||
440 | void dasd_put_device_wake(struct dasd_device *); | 444 | void dasd_put_device_wake(struct dasd_device *); |
441 | 445 | ||
@@ -609,6 +613,9 @@ char *dasd_get_sense(struct irb *); | |||
609 | void dasd_device_set_stop_bits(struct dasd_device *, int); | 613 | void dasd_device_set_stop_bits(struct dasd_device *, int); |
610 | void dasd_device_remove_stop_bits(struct dasd_device *, int); | 614 | void dasd_device_remove_stop_bits(struct dasd_device *, int); |
611 | 615 | ||
616 | int dasd_device_is_ro(struct dasd_device *); | ||
617 | |||
618 | |||
612 | /* externals in dasd_devmap.c */ | 619 | /* externals in dasd_devmap.c */ |
613 | extern int dasd_max_devindex; | 620 | extern int dasd_max_devindex; |
614 | extern int dasd_probeonly; | 621 | extern int dasd_probeonly; |
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index 7039d9cf0fb4..3479f8158a1b 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c | |||
@@ -199,7 +199,8 @@ dasd_ioctl_format(struct block_device *bdev, void __user *argp) | |||
199 | if (!argp) | 199 | if (!argp) |
200 | return -EINVAL; | 200 | return -EINVAL; |
201 | 201 | ||
202 | if (block->base->features & DASD_FEATURE_READONLY) | 202 | if (block->base->features & DASD_FEATURE_READONLY || |
203 | test_bit(DASD_FLAG_DEVICE_RO, &block->base->flags)) | ||
203 | return -EROFS; | 204 | return -EROFS; |
204 | if (copy_from_user(&fdata, argp, sizeof(struct format_data_t))) | 205 | if (copy_from_user(&fdata, argp, sizeof(struct format_data_t))) |
205 | return -EFAULT; | 206 | return -EFAULT; |
@@ -349,7 +350,8 @@ dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp) | |||
349 | return -EINVAL; | 350 | return -EINVAL; |
350 | if (get_user(intval, (int __user *)argp)) | 351 | if (get_user(intval, (int __user *)argp)) |
351 | return -EFAULT; | 352 | return -EFAULT; |
352 | 353 | if (!intval && test_bit(DASD_FLAG_DEVICE_RO, &block->base->flags)) | |
354 | return -EROFS; | ||
353 | set_disk_ro(bdev->bd_disk, intval); | 355 | set_disk_ro(bdev->bd_disk, intval); |
354 | return dasd_set_feature(block->base->cdev, DASD_FEATURE_READONLY, intval); | 356 | return dasd_set_feature(block->base->cdev, DASD_FEATURE_READONLY, intval); |
355 | } | 357 | } |
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index c6abb75c4615..6d229f3523a0 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c | |||
@@ -764,7 +764,7 @@ static void sch_create_and_recog_new_device(struct subchannel *sch) | |||
764 | static void io_subchannel_register(struct ccw_device *cdev) | 764 | static void io_subchannel_register(struct ccw_device *cdev) |
765 | { | 765 | { |
766 | struct subchannel *sch; | 766 | struct subchannel *sch; |
767 | int ret; | 767 | int ret, adjust_init_count = 1; |
768 | unsigned long flags; | 768 | unsigned long flags; |
769 | 769 | ||
770 | sch = to_subchannel(cdev->dev.parent); | 770 | sch = to_subchannel(cdev->dev.parent); |
@@ -793,6 +793,7 @@ static void io_subchannel_register(struct ccw_device *cdev) | |||
793 | cdev->private->dev_id.ssid, | 793 | cdev->private->dev_id.ssid, |
794 | cdev->private->dev_id.devno); | 794 | cdev->private->dev_id.devno); |
795 | } | 795 | } |
796 | adjust_init_count = 0; | ||
796 | goto out; | 797 | goto out; |
797 | } | 798 | } |
798 | /* | 799 | /* |
@@ -818,7 +819,7 @@ out: | |||
818 | cdev->private->flags.recog_done = 1; | 819 | cdev->private->flags.recog_done = 1; |
819 | wake_up(&cdev->private->wait_q); | 820 | wake_up(&cdev->private->wait_q); |
820 | out_err: | 821 | out_err: |
821 | if (atomic_dec_and_test(&ccw_device_init_count)) | 822 | if (adjust_init_count && atomic_dec_and_test(&ccw_device_init_count)) |
822 | wake_up(&ccw_device_init_wq); | 823 | wake_up(&ccw_device_init_wq); |
823 | } | 824 | } |
824 | 825 | ||
diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c index c94eb2a0fa2e..6ce83f56d537 100644 --- a/drivers/s390/cio/qdio_debug.c +++ b/drivers/s390/cio/qdio_debug.c | |||
@@ -33,7 +33,6 @@ void qdio_allocate_dbf(struct qdio_initialize *init_data, | |||
33 | DBF_HEX(&init_data->input_handler, sizeof(void *)); | 33 | DBF_HEX(&init_data->input_handler, sizeof(void *)); |
34 | DBF_HEX(&init_data->output_handler, sizeof(void *)); | 34 | DBF_HEX(&init_data->output_handler, sizeof(void *)); |
35 | DBF_HEX(&init_data->int_parm, sizeof(long)); | 35 | DBF_HEX(&init_data->int_parm, sizeof(long)); |
36 | DBF_HEX(&init_data->flags, sizeof(long)); | ||
37 | DBF_HEX(&init_data->input_sbal_addr_array, sizeof(void *)); | 36 | DBF_HEX(&init_data->input_sbal_addr_array, sizeof(void *)); |
38 | DBF_HEX(&init_data->output_sbal_addr_array, sizeof(void *)); | 37 | DBF_HEX(&init_data->output_sbal_addr_array, sizeof(void *)); |
39 | DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr); | 38 | DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr); |
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c index 232ef047ba34..4f8f74311778 100644 --- a/drivers/s390/cio/qdio_main.c +++ b/drivers/s390/cio/qdio_main.c | |||
@@ -588,10 +588,11 @@ static void qdio_kick_handler(struct qdio_q *q) | |||
588 | if (q->is_input_q) { | 588 | if (q->is_input_q) { |
589 | qperf_inc(q, inbound_handler); | 589 | qperf_inc(q, inbound_handler); |
590 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "kih s:%02x c:%02x", start, count); | 590 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "kih s:%02x c:%02x", start, count); |
591 | } else | 591 | } else { |
592 | qperf_inc(q, outbound_handler); | 592 | qperf_inc(q, outbound_handler); |
593 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "koh: s:%02x c:%02x", | 593 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "koh: s:%02x c:%02x", |
594 | start, count); | 594 | start, count); |
595 | } | ||
595 | 596 | ||
596 | q->handler(q->irq_ptr->cdev, q->qdio_error, q->nr, start, count, | 597 | q->handler(q->irq_ptr->cdev, q->qdio_error, q->nr, start, count, |
597 | q->irq_ptr->int_parm); | 598 | q->irq_ptr->int_parm); |
diff --git a/drivers/s390/net/Kconfig b/drivers/s390/net/Kconfig index cb909a5b5047..977bb4d4ed15 100644 --- a/drivers/s390/net/Kconfig +++ b/drivers/s390/net/Kconfig | |||
@@ -43,6 +43,16 @@ config SMSGIUCV | |||
43 | Select this option if you want to be able to receive SMSG messages | 43 | Select this option if you want to be able to receive SMSG messages |
44 | from other VM guest systems. | 44 | from other VM guest systems. |
45 | 45 | ||
46 | config SMSGIUCV_EVENT | ||
47 | tristate "Deliver IUCV special messages as uevents (VM only)" | ||
48 | depends on SMSGIUCV | ||
49 | help | ||
50 | Select this option to deliver CP special messages (SMSGs) as | ||
51 | uevents. The driver handles only those special messages that | ||
52 | start with "APP". | ||
53 | |||
54 | To compile as a module, choose M. The module name is "smsgiucv_app". | ||
55 | |||
46 | config CLAW | 56 | config CLAW |
47 | tristate "CLAW device support" | 57 | tristate "CLAW device support" |
48 | depends on CCW && NETDEVICES | 58 | depends on CCW && NETDEVICES |
diff --git a/drivers/s390/net/Makefile b/drivers/s390/net/Makefile index 6cab5a62f99e..4dfe8c1092da 100644 --- a/drivers/s390/net/Makefile +++ b/drivers/s390/net/Makefile | |||
@@ -6,6 +6,7 @@ ctcm-y += ctcm_main.o ctcm_fsms.o ctcm_mpc.o ctcm_sysfs.o ctcm_dbug.o | |||
6 | obj-$(CONFIG_CTCM) += ctcm.o fsm.o | 6 | obj-$(CONFIG_CTCM) += ctcm.o fsm.o |
7 | obj-$(CONFIG_NETIUCV) += netiucv.o fsm.o | 7 | obj-$(CONFIG_NETIUCV) += netiucv.o fsm.o |
8 | obj-$(CONFIG_SMSGIUCV) += smsgiucv.o | 8 | obj-$(CONFIG_SMSGIUCV) += smsgiucv.o |
9 | obj-$(CONFIG_SMSGIUCV_EVENT) += smsgiucv_app.o | ||
9 | obj-$(CONFIG_LCS) += lcs.o | 10 | obj-$(CONFIG_LCS) += lcs.o |
10 | obj-$(CONFIG_CLAW) += claw.o | 11 | obj-$(CONFIG_CLAW) += claw.o |
11 | qeth-y += qeth_core_sys.o qeth_core_main.o qeth_core_mpc.o | 12 | qeth-y += qeth_core_sys.o qeth_core_main.o qeth_core_mpc.o |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index fa8a519218ac..7d25bdd443cd 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
@@ -3805,9 +3805,6 @@ static int qeth_qdio_establish(struct qeth_card *card) | |||
3805 | init_data.input_handler = card->discipline.input_handler; | 3805 | init_data.input_handler = card->discipline.input_handler; |
3806 | init_data.output_handler = card->discipline.output_handler; | 3806 | init_data.output_handler = card->discipline.output_handler; |
3807 | init_data.int_parm = (unsigned long) card; | 3807 | init_data.int_parm = (unsigned long) card; |
3808 | init_data.flags = QDIO_INBOUND_0COPY_SBALS | | ||
3809 | QDIO_OUTBOUND_0COPY_SBALS | | ||
3810 | QDIO_USE_OUTBOUND_PCIS; | ||
3811 | init_data.input_sbal_addr_array = (void **) in_sbal_ptrs; | 3808 | init_data.input_sbal_addr_array = (void **) in_sbal_ptrs; |
3812 | init_data.output_sbal_addr_array = (void **) out_sbal_ptrs; | 3809 | init_data.output_sbal_addr_array = (void **) out_sbal_ptrs; |
3813 | 3810 | ||
diff --git a/drivers/s390/net/smsgiucv.c b/drivers/s390/net/smsgiucv.c index 67f2485d2372..ecef1edee701 100644 --- a/drivers/s390/net/smsgiucv.c +++ b/drivers/s390/net/smsgiucv.c | |||
@@ -31,9 +31,9 @@ | |||
31 | 31 | ||
32 | struct smsg_callback { | 32 | struct smsg_callback { |
33 | struct list_head list; | 33 | struct list_head list; |
34 | char *prefix; | 34 | const char *prefix; |
35 | int len; | 35 | int len; |
36 | void (*callback)(char *from, char *str); | 36 | void (*callback)(const char *from, char *str); |
37 | }; | 37 | }; |
38 | 38 | ||
39 | MODULE_AUTHOR | 39 | MODULE_AUTHOR |
@@ -100,8 +100,8 @@ static void smsg_message_pending(struct iucv_path *path, | |||
100 | kfree(buffer); | 100 | kfree(buffer); |
101 | } | 101 | } |
102 | 102 | ||
103 | int smsg_register_callback(char *prefix, | 103 | int smsg_register_callback(const char *prefix, |
104 | void (*callback)(char *from, char *str)) | 104 | void (*callback)(const char *from, char *str)) |
105 | { | 105 | { |
106 | struct smsg_callback *cb; | 106 | struct smsg_callback *cb; |
107 | 107 | ||
@@ -117,8 +117,9 @@ int smsg_register_callback(char *prefix, | |||
117 | return 0; | 117 | return 0; |
118 | } | 118 | } |
119 | 119 | ||
120 | void smsg_unregister_callback(char *prefix, | 120 | void smsg_unregister_callback(const char *prefix, |
121 | void (*callback)(char *from, char *str)) | 121 | void (*callback)(const char *from, |
122 | char *str)) | ||
122 | { | 123 | { |
123 | struct smsg_callback *cb, *tmp; | 124 | struct smsg_callback *cb, *tmp; |
124 | 125 | ||
@@ -176,7 +177,7 @@ static const struct dev_pm_ops smsg_pm_ops = { | |||
176 | 177 | ||
177 | static struct device_driver smsg_driver = { | 178 | static struct device_driver smsg_driver = { |
178 | .owner = THIS_MODULE, | 179 | .owner = THIS_MODULE, |
179 | .name = "SMSGIUCV", | 180 | .name = SMSGIUCV_DRV_NAME, |
180 | .bus = &iucv_bus, | 181 | .bus = &iucv_bus, |
181 | .pm = &smsg_pm_ops, | 182 | .pm = &smsg_pm_ops, |
182 | }; | 183 | }; |
diff --git a/drivers/s390/net/smsgiucv.h b/drivers/s390/net/smsgiucv.h index 67f5d4f8378d..149a1151608d 100644 --- a/drivers/s390/net/smsgiucv.h +++ b/drivers/s390/net/smsgiucv.h | |||
@@ -5,6 +5,10 @@ | |||
5 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) | 5 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) |
6 | */ | 6 | */ |
7 | 7 | ||
8 | int smsg_register_callback(char *, void (*)(char *, char *)); | 8 | #define SMSGIUCV_DRV_NAME "SMSGIUCV" |
9 | void smsg_unregister_callback(char *, void (*)(char *, char *)); | 9 | |
10 | int smsg_register_callback(const char *, | ||
11 | void (*)(const char *, char *)); | ||
12 | void smsg_unregister_callback(const char *, | ||
13 | void (*)(const char *, char *)); | ||
10 | 14 | ||
diff --git a/drivers/s390/net/smsgiucv_app.c b/drivers/s390/net/smsgiucv_app.c new file mode 100644 index 000000000000..91579dc6a2b0 --- /dev/null +++ b/drivers/s390/net/smsgiucv_app.c | |||
@@ -0,0 +1,211 @@ | |||
1 | /* | ||
2 | * Deliver z/VM CP special messages (SMSG) as uevents. | ||
3 | * | ||
4 | * The driver registers for z/VM CP special messages with the | ||
5 | * "APP" prefix. Incoming messages are delivered to user space | ||
6 | * as uevents. | ||
7 | * | ||
8 | * Copyright IBM Corp. 2010 | ||
9 | * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | ||
10 | * | ||
11 | */ | ||
12 | #define KMSG_COMPONENT "smsgiucv_app" | ||
13 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | ||
14 | |||
15 | #include <linux/ctype.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/list.h> | ||
19 | #include <linux/kobject.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/spinlock.h> | ||
22 | #include <linux/workqueue.h> | ||
23 | #include <net/iucv/iucv.h> | ||
24 | #include "smsgiucv.h" | ||
25 | |||
26 | /* prefix used for SMSG registration */ | ||
27 | #define SMSG_PREFIX "APP" | ||
28 | |||
29 | /* SMSG related uevent environment variables */ | ||
30 | #define ENV_SENDER_STR "SMSG_SENDER=" | ||
31 | #define ENV_SENDER_LEN (strlen(ENV_SENDER_STR) + 8 + 1) | ||
32 | #define ENV_PREFIX_STR "SMSG_ID=" | ||
33 | #define ENV_PREFIX_LEN (strlen(ENV_PREFIX_STR) + \ | ||
34 | strlen(SMSG_PREFIX) + 1) | ||
35 | #define ENV_TEXT_STR "SMSG_TEXT=" | ||
36 | #define ENV_TEXT_LEN(msg) (strlen(ENV_TEXT_STR) + strlen((msg)) + 1) | ||
37 | |||
38 | /* z/VM user ID which is permitted to send SMSGs | ||
39 | * If the value is undefined or empty (""), special messages are | ||
40 | * accepted from any z/VM user ID. */ | ||
41 | static char *sender; | ||
42 | module_param(sender, charp, 0400); | ||
43 | MODULE_PARM_DESC(sender, "z/VM user ID from which CP SMSGs are accepted"); | ||
44 | |||
45 | /* SMSG device representation */ | ||
46 | static struct device *smsg_app_dev; | ||
47 | |||
48 | /* list element for queuing received messages for delivery */ | ||
49 | struct smsg_app_event { | ||
50 | struct list_head list; | ||
51 | char *buf; | ||
52 | char *envp[4]; | ||
53 | }; | ||
54 | |||
55 | /* queue for outgoing uevents */ | ||
56 | static LIST_HEAD(smsg_event_queue); | ||
57 | static DEFINE_SPINLOCK(smsg_event_queue_lock); | ||
58 | |||
59 | static void smsg_app_event_free(struct smsg_app_event *ev) | ||
60 | { | ||
61 | kfree(ev->buf); | ||
62 | kfree(ev); | ||
63 | } | ||
64 | |||
65 | static struct smsg_app_event *smsg_app_event_alloc(const char *from, | ||
66 | const char *msg) | ||
67 | { | ||
68 | struct smsg_app_event *ev; | ||
69 | |||
70 | ev = kzalloc(sizeof(*ev), GFP_ATOMIC); | ||
71 | if (!ev) | ||
72 | return NULL; | ||
73 | |||
74 | ev->buf = kzalloc(ENV_SENDER_LEN + ENV_PREFIX_LEN + | ||
75 | ENV_TEXT_LEN(msg), GFP_ATOMIC); | ||
76 | if (!ev->buf) { | ||
77 | kfree(ev); | ||
78 | return NULL; | ||
79 | } | ||
80 | |||
81 | /* setting up environment pointers into buf */ | ||
82 | ev->envp[0] = ev->buf; | ||
83 | ev->envp[1] = ev->envp[0] + ENV_SENDER_LEN; | ||
84 | ev->envp[2] = ev->envp[1] + ENV_PREFIX_LEN; | ||
85 | ev->envp[3] = NULL; | ||
86 | |||
87 | /* setting up environment: sender, prefix name, and message text */ | ||
88 | snprintf(ev->envp[0], ENV_SENDER_LEN, ENV_SENDER_STR "%s", from); | ||
89 | snprintf(ev->envp[1], ENV_PREFIX_LEN, ENV_PREFIX_STR "%s", SMSG_PREFIX); | ||
90 | snprintf(ev->envp[2], ENV_TEXT_LEN(msg), ENV_TEXT_STR "%s", msg); | ||
91 | |||
92 | return ev; | ||
93 | } | ||
94 | |||
95 | static void smsg_event_work_fn(struct work_struct *work) | ||
96 | { | ||
97 | LIST_HEAD(event_queue); | ||
98 | struct smsg_app_event *p, *n; | ||
99 | struct device *dev; | ||
100 | |||
101 | dev = get_device(smsg_app_dev); | ||
102 | if (!dev) | ||
103 | return; | ||
104 | |||
105 | spin_lock_bh(&smsg_event_queue_lock); | ||
106 | list_splice_init(&smsg_event_queue, &event_queue); | ||
107 | spin_unlock_bh(&smsg_event_queue_lock); | ||
108 | |||
109 | list_for_each_entry_safe(p, n, &event_queue, list) { | ||
110 | list_del(&p->list); | ||
111 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, p->envp); | ||
112 | smsg_app_event_free(p); | ||
113 | } | ||
114 | |||
115 | put_device(dev); | ||
116 | } | ||
117 | static DECLARE_WORK(smsg_event_work, smsg_event_work_fn); | ||
118 | |||
119 | static void smsg_app_callback(const char *from, char *msg) | ||
120 | { | ||
121 | struct smsg_app_event *se; | ||
122 | |||
123 | /* check if the originating z/VM user ID matches | ||
124 | * the configured sender. */ | ||
125 | if (sender && strlen(sender) > 0 && strcmp(from, sender) != 0) | ||
126 | return; | ||
127 | |||
128 | /* get start of message text (skip prefix and leading blanks) */ | ||
129 | msg += strlen(SMSG_PREFIX); | ||
130 | while (*msg && isspace(*msg)) | ||
131 | msg++; | ||
132 | if (*msg == '\0') | ||
133 | return; | ||
134 | |||
135 | /* allocate event list element and its environment */ | ||
136 | se = smsg_app_event_alloc(from, msg); | ||
137 | if (!se) | ||
138 | return; | ||
139 | |||
140 | /* queue event and schedule work function */ | ||
141 | spin_lock(&smsg_event_queue_lock); | ||
142 | list_add_tail(&se->list, &smsg_event_queue); | ||
143 | spin_unlock(&smsg_event_queue_lock); | ||
144 | |||
145 | schedule_work(&smsg_event_work); | ||
146 | return; | ||
147 | } | ||
148 | |||
149 | static int __init smsgiucv_app_init(void) | ||
150 | { | ||
151 | struct device_driver *smsgiucv_drv; | ||
152 | int rc; | ||
153 | |||
154 | if (!MACHINE_IS_VM) | ||
155 | return -ENODEV; | ||
156 | |||
157 | smsg_app_dev = kzalloc(sizeof(*smsg_app_dev), GFP_KERNEL); | ||
158 | if (!smsg_app_dev) | ||
159 | return -ENOMEM; | ||
160 | |||
161 | smsgiucv_drv = driver_find(SMSGIUCV_DRV_NAME, &iucv_bus); | ||
162 | if (!smsgiucv_drv) { | ||
163 | kfree(smsg_app_dev); | ||
164 | return -ENODEV; | ||
165 | } | ||
166 | |||
167 | rc = dev_set_name(smsg_app_dev, KMSG_COMPONENT); | ||
168 | if (rc) { | ||
169 | kfree(smsg_app_dev); | ||
170 | goto fail_put_driver; | ||
171 | } | ||
172 | smsg_app_dev->bus = &iucv_bus; | ||
173 | smsg_app_dev->parent = iucv_root; | ||
174 | smsg_app_dev->release = (void (*)(struct device *)) kfree; | ||
175 | smsg_app_dev->driver = smsgiucv_drv; | ||
176 | rc = device_register(smsg_app_dev); | ||
177 | if (rc) { | ||
178 | put_device(smsg_app_dev); | ||
179 | goto fail_put_driver; | ||
180 | } | ||
181 | |||
182 | /* register with the smsgiucv device driver */ | ||
183 | rc = smsg_register_callback(SMSG_PREFIX, smsg_app_callback); | ||
184 | if (rc) { | ||
185 | device_unregister(smsg_app_dev); | ||
186 | goto fail_put_driver; | ||
187 | } | ||
188 | |||
189 | rc = 0; | ||
190 | fail_put_driver: | ||
191 | put_driver(smsgiucv_drv); | ||
192 | return rc; | ||
193 | } | ||
194 | module_init(smsgiucv_app_init); | ||
195 | |||
196 | static void __exit smsgiucv_app_exit(void) | ||
197 | { | ||
198 | /* unregister callback */ | ||
199 | smsg_unregister_callback(SMSG_PREFIX, smsg_app_callback); | ||
200 | |||
201 | /* cancel pending work and flush any queued event work */ | ||
202 | cancel_work_sync(&smsg_event_work); | ||
203 | smsg_event_work_fn(&smsg_event_work); | ||
204 | |||
205 | device_unregister(smsg_app_dev); | ||
206 | } | ||
207 | module_exit(smsgiucv_app_exit); | ||
208 | |||
209 | MODULE_LICENSE("GPL v2"); | ||
210 | MODULE_DESCRIPTION("Deliver z/VM CP SMSG as uevents"); | ||
211 | MODULE_AUTHOR("Hendrik Brueckner <brueckner@linux.vnet.ibm.com>"); | ||
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 71b97ff77cf0..6479273a3094 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c | |||
@@ -319,8 +319,6 @@ static void zfcp_qdio_setup_init_data(struct qdio_initialize *id, | |||
319 | id->input_handler = zfcp_qdio_int_resp; | 319 | id->input_handler = zfcp_qdio_int_resp; |
320 | id->output_handler = zfcp_qdio_int_req; | 320 | id->output_handler = zfcp_qdio_int_req; |
321 | id->int_parm = (unsigned long) qdio; | 321 | id->int_parm = (unsigned long) qdio; |
322 | id->flags = QDIO_INBOUND_0COPY_SBALS | | ||
323 | QDIO_OUTBOUND_0COPY_SBALS | QDIO_USE_OUTBOUND_PCIS; | ||
324 | id->input_sbal_addr_array = (void **) (qdio->resp_q.sbal); | 322 | id->input_sbal_addr_array = (void **) (qdio->resp_q.sbal); |
325 | id->output_sbal_addr_array = (void **) (qdio->req_q.sbal); | 323 | id->output_sbal_addr_array = (void **) (qdio->req_q.sbal); |
326 | 324 | ||
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 1d7a8780e00c..0d9d6f7567f5 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -595,8 +595,6 @@ static int ses_intf_add(struct device *cdev, | |||
595 | ses_dev->page10_len = len; | 595 | ses_dev->page10_len = len; |
596 | buf = NULL; | 596 | buf = NULL; |
597 | } | 597 | } |
598 | kfree(hdr_buf); | ||
599 | |||
600 | scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL); | 598 | scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL); |
601 | if (!scomp) | 599 | if (!scomp) |
602 | goto err_free; | 600 | goto err_free; |
@@ -608,6 +606,8 @@ static int ses_intf_add(struct device *cdev, | |||
608 | goto err_free; | 606 | goto err_free; |
609 | } | 607 | } |
610 | 608 | ||
609 | kfree(hdr_buf); | ||
610 | |||
611 | edev->scratch = ses_dev; | 611 | edev->scratch = ses_dev; |
612 | for (i = 0; i < components; i++) | 612 | for (i = 0; i < components; i++) |
613 | edev->component[i].scratch = scomp + i; | 613 | edev->component[i].scratch = scomp + i; |
diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c index 0807b260268b..fef0e3c75b16 100644 --- a/drivers/scsi/sgiwd93.c +++ b/drivers/scsi/sgiwd93.c | |||
@@ -226,7 +226,7 @@ static struct scsi_host_template sgiwd93_template = { | |||
226 | .use_clustering = DISABLE_CLUSTERING, | 226 | .use_clustering = DISABLE_CLUSTERING, |
227 | }; | 227 | }; |
228 | 228 | ||
229 | static int __init sgiwd93_probe(struct platform_device *pdev) | 229 | static int __devinit sgiwd93_probe(struct platform_device *pdev) |
230 | { | 230 | { |
231 | struct sgiwd93_platform_data *pd = pdev->dev.platform_data; | 231 | struct sgiwd93_platform_data *pd = pdev->dev.platform_data; |
232 | unsigned char *wdregs = pd->wdregs; | 232 | unsigned char *wdregs = pd->wdregs; |
diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c index 37b3359e863e..56cf0bb4ed1f 100644 --- a/drivers/scsi/sni_53c710.c +++ b/drivers/scsi/sni_53c710.c | |||
@@ -64,7 +64,7 @@ static struct scsi_host_template snirm710_template = { | |||
64 | .module = THIS_MODULE, | 64 | .module = THIS_MODULE, |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static int __init snirm710_probe(struct platform_device *dev) | 67 | static int __devinit snirm710_probe(struct platform_device *dev) |
68 | { | 68 | { |
69 | unsigned long base; | 69 | unsigned long base; |
70 | struct NCR_700_Host_Parameters *hostdata; | 70 | struct NCR_700_Host_Parameters *hostdata; |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 7c4ebe6ee18b..c3db16b7afa1 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -2408,6 +2408,21 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios, | |||
2408 | } | 2408 | } |
2409 | 2409 | ||
2410 | static void | 2410 | static void |
2411 | serial8250_set_ldisc(struct uart_port *port) | ||
2412 | { | ||
2413 | int line = port->line; | ||
2414 | |||
2415 | if (line >= port->state->port.tty->driver->num) | ||
2416 | return; | ||
2417 | |||
2418 | if (port->state->port.tty->ldisc->ops->num == N_PPS) { | ||
2419 | port->flags |= UPF_HARDPPS_CD; | ||
2420 | serial8250_enable_ms(port); | ||
2421 | } else | ||
2422 | port->flags &= ~UPF_HARDPPS_CD; | ||
2423 | } | ||
2424 | |||
2425 | static void | ||
2411 | serial8250_pm(struct uart_port *port, unsigned int state, | 2426 | serial8250_pm(struct uart_port *port, unsigned int state, |
2412 | unsigned int oldstate) | 2427 | unsigned int oldstate) |
2413 | { | 2428 | { |
@@ -2628,6 +2643,7 @@ static struct uart_ops serial8250_pops = { | |||
2628 | .startup = serial8250_startup, | 2643 | .startup = serial8250_startup, |
2629 | .shutdown = serial8250_shutdown, | 2644 | .shutdown = serial8250_shutdown, |
2630 | .set_termios = serial8250_set_termios, | 2645 | .set_termios = serial8250_set_termios, |
2646 | .set_ldisc = serial8250_set_ldisc, | ||
2631 | .pm = serial8250_pm, | 2647 | .pm = serial8250_pm, |
2632 | .type = serial8250_type, | 2648 | .type = serial8250_type, |
2633 | .release_port = serial8250_release_port, | 2649 | .release_port = serial8250_release_port, |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index d6ff73395623..f55c49475a8c 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -447,7 +447,7 @@ config SERIAL_CLPS711X_CONSOLE | |||
447 | 447 | ||
448 | config SERIAL_SAMSUNG | 448 | config SERIAL_SAMSUNG |
449 | tristate "Samsung SoC serial support" | 449 | tristate "Samsung SoC serial support" |
450 | depends on ARM && PLAT_S3C | 450 | depends on ARM && PLAT_SAMSUNG |
451 | select SERIAL_CORE | 451 | select SERIAL_CORE |
452 | help | 452 | help |
453 | Support for the on-chip UARTs on the Samsung S3C24XX series CPUs, | 453 | Support for the on-chip UARTs on the Samsung S3C24XX series CPUs, |
@@ -455,11 +455,18 @@ config SERIAL_SAMSUNG | |||
455 | provide all of these ports, depending on how the serial port | 455 | provide all of these ports, depending on how the serial port |
456 | pins are configured. | 456 | pins are configured. |
457 | 457 | ||
458 | config SERIAL_SAMSUNG_UARTS_4 | ||
459 | bool | ||
460 | depends on ARM && PLAT_SAMSUNG | ||
461 | default y if CPU_S3C2443 | ||
462 | help | ||
463 | Internal node for the common case of 4 Samsung compatible UARTs | ||
464 | |||
458 | config SERIAL_SAMSUNG_UARTS | 465 | config SERIAL_SAMSUNG_UARTS |
459 | int | 466 | int |
460 | depends on ARM && PLAT_S3C | 467 | depends on ARM && PLAT_SAMSUNG |
461 | default 2 if ARCH_S3C2400 | 468 | default 2 if ARCH_S3C2400 |
462 | default 4 if ARCH_S5PC1XX || ARCH_S3C64XX || CPU_S3C2443 | 469 | default 4 if SERIAL_SAMSUNG_UARTS_4 |
463 | default 3 | 470 | default 3 |
464 | help | 471 | help |
465 | Select the number of available UART ports for the Samsung S3C | 472 | Select the number of available UART ports for the Samsung S3C |
@@ -526,20 +533,30 @@ config SERIAL_S3C24A0 | |||
526 | Serial port support for the Samsung S3C24A0 SoC | 533 | Serial port support for the Samsung S3C24A0 SoC |
527 | 534 | ||
528 | config SERIAL_S3C6400 | 535 | config SERIAL_S3C6400 |
529 | tristate "Samsung S3C6400/S3C6410 Serial port support" | 536 | tristate "Samsung S3C6400/S3C6410/S5P6440 Seria port support" |
530 | depends on SERIAL_SAMSUNG && (CPU_S3C6400 || CPU_S3C6410) | 537 | depends on SERIAL_SAMSUNG && (CPU_S3C6400 || CPU_S3C6410 || CPU_S5P6440) |
538 | select SERIAL_SAMSUNG_UARTS_4 | ||
531 | default y | 539 | default y |
532 | help | 540 | help |
533 | Serial port support for the Samsung S3C6400 and S3C6410 | 541 | Serial port support for the Samsung S3C6400, S3C6410 and S5P6440 |
534 | SoCs | 542 | SoCs |
535 | 543 | ||
536 | config SERIAL_S5PC100 | 544 | config SERIAL_S5PC100 |
537 | tristate "Samsung S5PC100 Serial port support" | 545 | tristate "Samsung S5PC100 Serial port support" |
538 | depends on SERIAL_SAMSUNG && CPU_S5PC100 | 546 | depends on SERIAL_SAMSUNG && CPU_S5PC100 |
547 | select SERIAL_SAMSUNG_UARTS_4 | ||
539 | default y | 548 | default y |
540 | help | 549 | help |
541 | Serial port support for the Samsung S5PC100 SoCs | 550 | Serial port support for the Samsung S5PC100 SoCs |
542 | 551 | ||
552 | config SERIAL_S5PV210 | ||
553 | tristate "Samsung S5PV210 Serial port support" | ||
554 | depends on SERIAL_SAMSUNG && (CPU_S5PV210 || CPU_S5P6442) | ||
555 | select SERIAL_SAMSUNG_UARTS_4 if CPU_S5PV210 | ||
556 | default y | ||
557 | help | ||
558 | Serial port support for Samsung's S5P Family of SoC's | ||
559 | |||
543 | config SERIAL_MAX3100 | 560 | config SERIAL_MAX3100 |
544 | tristate "MAX3100 support" | 561 | tristate "MAX3100 support" |
545 | depends on SPI | 562 | depends on SPI |
@@ -996,7 +1013,7 @@ config SERIAL_IP22_ZILOG_CONSOLE | |||
996 | 1013 | ||
997 | config SERIAL_SH_SCI | 1014 | config SERIAL_SH_SCI |
998 | tristate "SuperH SCI(F) serial port support" | 1015 | tristate "SuperH SCI(F) serial port support" |
999 | depends on HAVE_CLK && (SUPERH || H8300) | 1016 | depends on HAVE_CLK && (SUPERH || H8300 || ARCH_SHMOBILE) |
1000 | select SERIAL_CORE | 1017 | select SERIAL_CORE |
1001 | 1018 | ||
1002 | config SERIAL_SH_SCI_NR_UARTS | 1019 | config SERIAL_SH_SCI_NR_UARTS |
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 5548fe7df61d..6aa4723b74ee 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile | |||
@@ -45,6 +45,7 @@ obj-$(CONFIG_SERIAL_S3C2440) += s3c2440.o | |||
45 | obj-$(CONFIG_SERIAL_S3C24A0) += s3c24a0.o | 45 | obj-$(CONFIG_SERIAL_S3C24A0) += s3c24a0.o |
46 | obj-$(CONFIG_SERIAL_S3C6400) += s3c6400.o | 46 | obj-$(CONFIG_SERIAL_S3C6400) += s3c6400.o |
47 | obj-$(CONFIG_SERIAL_S5PC100) += s3c6400.o | 47 | obj-$(CONFIG_SERIAL_S5PC100) += s3c6400.o |
48 | obj-$(CONFIG_SERIAL_S5PV210) += s5pv210.o | ||
48 | obj-$(CONFIG_SERIAL_MAX3100) += max3100.o | 49 | obj-$(CONFIG_SERIAL_MAX3100) += max3100.o |
49 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o | 50 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o |
50 | obj-$(CONFIG_SERIAL_MUX) += mux.o | 51 | obj-$(CONFIG_SERIAL_MUX) += mux.o |
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c index 429a8ae86933..e4b3c2c88bb6 100644 --- a/drivers/serial/amba-pl010.c +++ b/drivers/serial/amba-pl010.c | |||
@@ -471,6 +471,20 @@ pl010_set_termios(struct uart_port *port, struct ktermios *termios, | |||
471 | spin_unlock_irqrestore(&uap->port.lock, flags); | 471 | spin_unlock_irqrestore(&uap->port.lock, flags); |
472 | } | 472 | } |
473 | 473 | ||
474 | static void pl010_set_ldisc(struct uart_port *port) | ||
475 | { | ||
476 | int line = port->line; | ||
477 | |||
478 | if (line >= port->state->port.tty->driver->num) | ||
479 | return; | ||
480 | |||
481 | if (port->state->port.tty->ldisc->ops->num == N_PPS) { | ||
482 | port->flags |= UPF_HARDPPS_CD; | ||
483 | pl010_enable_ms(port); | ||
484 | } else | ||
485 | port->flags &= ~UPF_HARDPPS_CD; | ||
486 | } | ||
487 | |||
474 | static const char *pl010_type(struct uart_port *port) | 488 | static const char *pl010_type(struct uart_port *port) |
475 | { | 489 | { |
476 | return port->type == PORT_AMBA ? "AMBA" : NULL; | 490 | return port->type == PORT_AMBA ? "AMBA" : NULL; |
@@ -531,6 +545,7 @@ static struct uart_ops amba_pl010_pops = { | |||
531 | .startup = pl010_startup, | 545 | .startup = pl010_startup, |
532 | .shutdown = pl010_shutdown, | 546 | .shutdown = pl010_shutdown, |
533 | .set_termios = pl010_set_termios, | 547 | .set_termios = pl010_set_termios, |
548 | .set_ldisc = pl010_set_ldisc, | ||
534 | .type = pl010_type, | 549 | .type = pl010_type, |
535 | .release_port = pl010_release_port, | 550 | .release_port = pl010_release_port, |
536 | .request_port = pl010_request_port, | 551 | .request_port = pl010_request_port, |
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index d00fcf8e6c70..e579d7a1807a 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c | |||
@@ -440,7 +440,7 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) | |||
440 | 440 | ||
441 | temp = readl(sport->port.membase + USR2); | 441 | temp = readl(sport->port.membase + USR2); |
442 | if (temp & USR2_BRCD) { | 442 | if (temp & USR2_BRCD) { |
443 | writel(temp | USR2_BRCD, sport->port.membase + USR2); | 443 | writel(USR2_BRCD, sport->port.membase + USR2); |
444 | if (uart_handle_break(&sport->port)) | 444 | if (uart_handle_break(&sport->port)) |
445 | continue; | 445 | continue; |
446 | } | 446 | } |
diff --git a/drivers/serial/s3c2412.c b/drivers/serial/s3c2412.c index ce75e28e36ef..1700b1a2fb7e 100644 --- a/drivers/serial/s3c2412.c +++ b/drivers/serial/s3c2412.c | |||
@@ -102,6 +102,7 @@ static struct s3c24xx_uart_info s3c2412_uart_inf = { | |||
102 | .name = "Samsung S3C2412 UART", | 102 | .name = "Samsung S3C2412 UART", |
103 | .type = PORT_S3C2412, | 103 | .type = PORT_S3C2412, |
104 | .fifosize = 64, | 104 | .fifosize = 64, |
105 | .has_divslot = 1, | ||
105 | .rx_fifomask = S3C2440_UFSTAT_RXMASK, | 106 | .rx_fifomask = S3C2440_UFSTAT_RXMASK, |
106 | .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT, | 107 | .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT, |
107 | .rx_fifofull = S3C2440_UFSTAT_RXFULL, | 108 | .rx_fifofull = S3C2440_UFSTAT_RXFULL, |
diff --git a/drivers/serial/s5pv210.c b/drivers/serial/s5pv210.c new file mode 100644 index 000000000000..8dc03837617b --- /dev/null +++ b/drivers/serial/s5pv210.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* linux/drivers/serial/s5pv210.c | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com/ | ||
5 | * | ||
6 | * Based on drivers/serial/s3c6400.c | ||
7 | * | ||
8 | * Driver for Samsung S5PV210 SoC UARTs. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/ioport.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/serial_core.h> | ||
21 | #include <linux/serial.h> | ||
22 | |||
23 | #include <asm/irq.h> | ||
24 | #include <mach/hardware.h> | ||
25 | #include <plat/regs-serial.h> | ||
26 | #include "samsung.h" | ||
27 | |||
28 | static int s5pv210_serial_setsource(struct uart_port *port, | ||
29 | struct s3c24xx_uart_clksrc *clk) | ||
30 | { | ||
31 | unsigned long ucon = rd_regl(port, S3C2410_UCON); | ||
32 | |||
33 | if (strcmp(clk->name, "pclk") == 0) | ||
34 | ucon &= ~S5PV210_UCON_CLKMASK; | ||
35 | else if (strcmp(clk->name, "uclk1") == 0) | ||
36 | ucon |= S5PV210_UCON_CLKMASK; | ||
37 | else { | ||
38 | printk(KERN_ERR "unknown clock source %s\n", clk->name); | ||
39 | return -EINVAL; | ||
40 | } | ||
41 | |||
42 | wr_regl(port, S3C2410_UCON, ucon); | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | |||
47 | static int s5pv210_serial_getsource(struct uart_port *port, | ||
48 | struct s3c24xx_uart_clksrc *clk) | ||
49 | { | ||
50 | u32 ucon = rd_regl(port, S3C2410_UCON); | ||
51 | |||
52 | clk->divisor = 1; | ||
53 | |||
54 | switch (ucon & S5PV210_UCON_CLKMASK) { | ||
55 | case S5PV210_UCON_PCLK: | ||
56 | clk->name = "pclk"; | ||
57 | break; | ||
58 | case S5PV210_UCON_UCLK: | ||
59 | clk->name = "uclk1"; | ||
60 | break; | ||
61 | } | ||
62 | |||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | static int s5pv210_serial_resetport(struct uart_port *port, | ||
67 | struct s3c2410_uartcfg *cfg) | ||
68 | { | ||
69 | unsigned long ucon = rd_regl(port, S3C2410_UCON); | ||
70 | |||
71 | ucon &= S5PV210_UCON_CLKMASK; | ||
72 | wr_regl(port, S3C2410_UCON, ucon | cfg->ucon); | ||
73 | wr_regl(port, S3C2410_ULCON, cfg->ulcon); | ||
74 | |||
75 | /* reset both fifos */ | ||
76 | wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH); | ||
77 | wr_regl(port, S3C2410_UFCON, cfg->ufcon); | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | #define S5PV210_UART_DEFAULT_INFO(fifo_size) \ | ||
83 | .name = "Samsung S5PV210 UART0", \ | ||
84 | .type = PORT_S3C6400, \ | ||
85 | .fifosize = fifo_size, \ | ||
86 | .has_divslot = 1, \ | ||
87 | .rx_fifomask = S5PV210_UFSTAT_RXMASK, \ | ||
88 | .rx_fifoshift = S5PV210_UFSTAT_RXSHIFT, \ | ||
89 | .rx_fifofull = S5PV210_UFSTAT_RXFULL, \ | ||
90 | .tx_fifofull = S5PV210_UFSTAT_TXFULL, \ | ||
91 | .tx_fifomask = S5PV210_UFSTAT_TXMASK, \ | ||
92 | .tx_fifoshift = S5PV210_UFSTAT_TXSHIFT, \ | ||
93 | .get_clksrc = s5pv210_serial_getsource, \ | ||
94 | .set_clksrc = s5pv210_serial_setsource, \ | ||
95 | .reset_port = s5pv210_serial_resetport | ||
96 | |||
97 | static struct s3c24xx_uart_info s5p_port_fifo256 = { | ||
98 | S5PV210_UART_DEFAULT_INFO(256), | ||
99 | }; | ||
100 | |||
101 | static struct s3c24xx_uart_info s5p_port_fifo64 = { | ||
102 | S5PV210_UART_DEFAULT_INFO(64), | ||
103 | }; | ||
104 | |||
105 | static struct s3c24xx_uart_info s5p_port_fifo16 = { | ||
106 | S5PV210_UART_DEFAULT_INFO(16), | ||
107 | }; | ||
108 | |||
109 | static struct s3c24xx_uart_info *s5p_uart_inf[] = { | ||
110 | [0] = &s5p_port_fifo256, | ||
111 | [1] = &s5p_port_fifo64, | ||
112 | [2] = &s5p_port_fifo16, | ||
113 | [3] = &s5p_port_fifo16, | ||
114 | }; | ||
115 | |||
116 | /* device management */ | ||
117 | static int s5p_serial_probe(struct platform_device *pdev) | ||
118 | { | ||
119 | return s3c24xx_serial_probe(pdev, s5p_uart_inf[pdev->id]); | ||
120 | } | ||
121 | |||
122 | static struct platform_driver s5p_serial_drv = { | ||
123 | .probe = s5p_serial_probe, | ||
124 | .remove = __devexit_p(s3c24xx_serial_remove), | ||
125 | .driver = { | ||
126 | .name = "s5pv210-uart", | ||
127 | .owner = THIS_MODULE, | ||
128 | }, | ||
129 | }; | ||
130 | |||
131 | static int __init s5pv210_serial_console_init(void) | ||
132 | { | ||
133 | return s3c24xx_serial_initconsole(&s5p_serial_drv, s5p_uart_inf); | ||
134 | } | ||
135 | |||
136 | console_initcall(s5pv210_serial_console_init); | ||
137 | |||
138 | static int __init s5p_serial_init(void) | ||
139 | { | ||
140 | return s3c24xx_serial_init(&s5p_serial_drv, *s5p_uart_inf); | ||
141 | } | ||
142 | |||
143 | static void __exit s5p_serial_exit(void) | ||
144 | { | ||
145 | platform_driver_unregister(&s5p_serial_drv); | ||
146 | } | ||
147 | |||
148 | module_init(s5p_serial_init); | ||
149 | module_exit(s5p_serial_exit); | ||
150 | |||
151 | MODULE_LICENSE("GPL"); | ||
152 | MODULE_ALIAS("platform:s5pv210-uart"); | ||
153 | MODULE_DESCRIPTION("Samsung S5PV210 UART Driver support"); | ||
154 | MODULE_AUTHOR("Thomas Abraham <thomas.ab@samsung.com>"); | ||
diff --git a/drivers/serial/samsung.c b/drivers/serial/samsung.c index 03c010af966b..a9d6c5626a0a 100644 --- a/drivers/serial/samsung.c +++ b/drivers/serial/samsung.c | |||
@@ -1374,7 +1374,7 @@ s3c24xx_serial_get_options(struct uart_port *port, int *baud, | |||
1374 | * data. | 1374 | * data. |
1375 | */ | 1375 | */ |
1376 | 1376 | ||
1377 | static int s3c24xx_serial_init_ports(struct s3c24xx_uart_info *info) | 1377 | static int s3c24xx_serial_init_ports(struct s3c24xx_uart_info **info) |
1378 | { | 1378 | { |
1379 | struct s3c24xx_uart_port *ptr = s3c24xx_serial_ports; | 1379 | struct s3c24xx_uart_port *ptr = s3c24xx_serial_ports; |
1380 | struct platform_device **platdev_ptr; | 1380 | struct platform_device **platdev_ptr; |
@@ -1385,7 +1385,7 @@ static int s3c24xx_serial_init_ports(struct s3c24xx_uart_info *info) | |||
1385 | platdev_ptr = s3c24xx_uart_devs; | 1385 | platdev_ptr = s3c24xx_uart_devs; |
1386 | 1386 | ||
1387 | for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++, ptr++, platdev_ptr++) { | 1387 | for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++, ptr++, platdev_ptr++) { |
1388 | s3c24xx_serial_init_port(ptr, info, *platdev_ptr); | 1388 | s3c24xx_serial_init_port(ptr, info[i], *platdev_ptr); |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | return 0; | 1391 | return 0; |
@@ -1451,7 +1451,7 @@ static struct console s3c24xx_serial_console = { | |||
1451 | }; | 1451 | }; |
1452 | 1452 | ||
1453 | int s3c24xx_serial_initconsole(struct platform_driver *drv, | 1453 | int s3c24xx_serial_initconsole(struct platform_driver *drv, |
1454 | struct s3c24xx_uart_info *info) | 1454 | struct s3c24xx_uart_info **info) |
1455 | 1455 | ||
1456 | { | 1456 | { |
1457 | struct platform_device *dev = s3c24xx_uart_devs[0]; | 1457 | struct platform_device *dev = s3c24xx_uart_devs[0]; |
diff --git a/drivers/serial/samsung.h b/drivers/serial/samsung.h index 1fb22343df42..0ac06a07d25f 100644 --- a/drivers/serial/samsung.h +++ b/drivers/serial/samsung.h | |||
@@ -75,19 +75,24 @@ extern int s3c24xx_serial_probe(struct platform_device *dev, | |||
75 | extern int __devexit s3c24xx_serial_remove(struct platform_device *dev); | 75 | extern int __devexit s3c24xx_serial_remove(struct platform_device *dev); |
76 | 76 | ||
77 | extern int s3c24xx_serial_initconsole(struct platform_driver *drv, | 77 | extern int s3c24xx_serial_initconsole(struct platform_driver *drv, |
78 | struct s3c24xx_uart_info *uart); | 78 | struct s3c24xx_uart_info **uart); |
79 | 79 | ||
80 | extern int s3c24xx_serial_init(struct platform_driver *drv, | 80 | extern int s3c24xx_serial_init(struct platform_driver *drv, |
81 | struct s3c24xx_uart_info *info); | 81 | struct s3c24xx_uart_info *info); |
82 | 82 | ||
83 | #ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE | 83 | #ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE |
84 | 84 | ||
85 | #define s3c24xx_console_init(__drv, __inf) \ | 85 | #define s3c24xx_console_init(__drv, __inf) \ |
86 | static int __init s3c_serial_console_init(void) \ | 86 | static int __init s3c_serial_console_init(void) \ |
87 | { \ | 87 | { \ |
88 | return s3c24xx_serial_initconsole(__drv, __inf); \ | 88 | struct s3c24xx_uart_info *uinfo[CONFIG_SERIAL_SAMSUNG_UARTS]; \ |
89 | } \ | 89 | int i; \ |
90 | \ | 90 | \ |
91 | for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++) \ | ||
92 | uinfo[i] = __inf; \ | ||
93 | return s3c24xx_serial_initconsole(__drv, uinfo); \ | ||
94 | } \ | ||
95 | \ | ||
91 | console_initcall(s3c_serial_console_init) | 96 | console_initcall(s3c_serial_console_init) |
92 | 97 | ||
93 | #else | 98 | #else |
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index f7d2589926d2..fad67d33b0bd 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h | |||
@@ -30,7 +30,8 @@ | |||
30 | */ | 30 | */ |
31 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 | 31 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 |
32 | #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 32 | #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
33 | defined(CONFIG_CPU_SUBTYPE_SH7721) | 33 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
34 | defined(CONFIG_ARCH_SHMOBILE) | ||
34 | # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ | 35 | # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ |
35 | # define PORT_PTCR 0xA405011EUL | 36 | # define PORT_PTCR 0xA405011EUL |
36 | # define PORT_PVCR 0xA4050122UL | 37 | # define PORT_PVCR 0xA4050122UL |
@@ -228,7 +229,8 @@ | |||
228 | 229 | ||
229 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 230 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
230 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 231 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
231 | defined(CONFIG_CPU_SUBTYPE_SH7721) | 232 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
233 | defined(CONFIG_ARCH_SHMOBILE) | ||
232 | # define SCIF_ORER 0x0200 | 234 | # define SCIF_ORER 0x0200 |
233 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) | 235 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) |
234 | # define SCIF_RFDC_MASK 0x007f | 236 | # define SCIF_RFDC_MASK 0x007f |
@@ -261,7 +263,8 @@ | |||
261 | 263 | ||
262 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 264 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
263 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 265 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
264 | defined(CONFIG_CPU_SUBTYPE_SH7721) | 266 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
267 | defined(CONFIG_ARCH_SHMOBILE) | ||
265 | # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) | 268 | # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) |
266 | # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) | 269 | # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) |
267 | # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) | 270 | # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) |
@@ -356,7 +359,7 @@ | |||
356 | SCI_OUT(sci_size, sci_offset, value); \ | 359 | SCI_OUT(sci_size, sci_offset, value); \ |
357 | } | 360 | } |
358 | 361 | ||
359 | #ifdef CONFIG_CPU_SH3 | 362 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_ARCH_SHMOBILE) |
360 | #if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) | 363 | #if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) |
361 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ | 364 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
362 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ | 365 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
@@ -366,7 +369,8 @@ | |||
366 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) | 369 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
367 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 370 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
368 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 371 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
369 | defined(CONFIG_CPU_SUBTYPE_SH7721) | 372 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
373 | defined(CONFIG_ARCH_SHMOBILE) | ||
370 | #define SCIF_FNS(name, scif_offset, scif_size) \ | 374 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
371 | CPU_SCIF_FNS(name, scif_offset, scif_size) | 375 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
372 | #else | 376 | #else |
@@ -401,7 +405,8 @@ | |||
401 | 405 | ||
402 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 406 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
403 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 407 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
404 | defined(CONFIG_CPU_SUBTYPE_SH7721) | 408 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
409 | defined(CONFIG_ARCH_SHMOBILE) | ||
405 | 410 | ||
406 | SCIF_FNS(SCSMR, 0x00, 16) | 411 | SCIF_FNS(SCSMR, 0x00, 16) |
407 | SCIF_FNS(SCBRR, 0x04, 8) | 412 | SCIF_FNS(SCBRR, 0x04, 8) |
@@ -413,7 +418,7 @@ SCIF_FNS(SCFCR, 0x18, 16) | |||
413 | SCIF_FNS(SCFDR, 0x1c, 16) | 418 | SCIF_FNS(SCFDR, 0x1c, 16) |
414 | SCIF_FNS(SCxTDR, 0x20, 8) | 419 | SCIF_FNS(SCxTDR, 0x20, 8) |
415 | SCIF_FNS(SCxRDR, 0x24, 8) | 420 | SCIF_FNS(SCxRDR, 0x24, 8) |
416 | SCIF_FNS(SCLSR, 0x24, 16) | 421 | SCIF_FNS(SCLSR, 0x00, 0) |
417 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ | 422 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
418 | defined(CONFIG_CPU_SUBTYPE_SH7724) | 423 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
419 | SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16) | 424 | SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16) |
@@ -583,7 +588,8 @@ static inline int sci_rxd_in(struct uart_port *port) | |||
583 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) | 588 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) |
584 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 589 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
585 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 590 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
586 | defined(CONFIG_CPU_SUBTYPE_SH7721) | 591 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
592 | defined(CONFIG_ARCH_SHMOBILE) | ||
587 | #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) | 593 | #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) |
588 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ | 594 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
589 | defined(CONFIG_CPU_SUBTYPE_SH7724) | 595 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
diff --git a/drivers/sh/intc.c b/drivers/sh/intc.c index 3a5a17db9474..c2750391fd34 100644 --- a/drivers/sh/intc.c +++ b/drivers/sh/intc.c | |||
@@ -762,6 +762,10 @@ static void __init intc_register_irq(struct intc_desc *desc, | |||
762 | 762 | ||
763 | if (desc->hw.ack_regs) | 763 | if (desc->hw.ack_regs) |
764 | ack_handle[irq] = intc_ack_data(desc, d, enum_id); | 764 | ack_handle[irq] = intc_ack_data(desc, d, enum_id); |
765 | |||
766 | #ifdef CONFIG_ARM | ||
767 | set_irq_flags(irq, IRQF_VALID); /* Enable IRQ on ARM systems */ | ||
768 | #endif | ||
765 | } | 769 | } |
766 | 770 | ||
767 | static unsigned int __init save_reg(struct intc_desc_int *d, | 771 | static unsigned int __init save_reg(struct intc_desc_int *d, |
@@ -1024,8 +1028,12 @@ unsigned int create_irq_nr(unsigned int irq_want, int node) | |||
1024 | out_unlock: | 1028 | out_unlock: |
1025 | spin_unlock_irqrestore(&vector_lock, flags); | 1029 | spin_unlock_irqrestore(&vector_lock, flags); |
1026 | 1030 | ||
1027 | if (irq > 0) | 1031 | if (irq > 0) { |
1028 | dynamic_irq_init(irq); | 1032 | dynamic_irq_init(irq); |
1033 | #ifdef CONFIG_ARM | ||
1034 | set_irq_flags(irq, IRQF_VALID); /* Enable IRQ on ARM systems */ | ||
1035 | #endif | ||
1036 | } | ||
1029 | 1037 | ||
1030 | return irq; | 1038 | return irq; |
1031 | } | 1039 | } |
diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c index cadb6f7321ad..7ebecc92c61b 100644 --- a/drivers/staging/asus_oled/asus_oled.c +++ b/drivers/staging/asus_oled/asus_oled.c | |||
@@ -770,13 +770,8 @@ static struct usb_driver oled_driver = { | |||
770 | .id_table = id_table, | 770 | .id_table = id_table, |
771 | }; | 771 | }; |
772 | 772 | ||
773 | static ssize_t version_show(struct class *dev, char *buf) | 773 | static CLASS_ATTR_STRING(version, S_IRUGO, |
774 | { | 774 | ASUS_OLED_UNDERSCORE_NAME " " ASUS_OLED_VERSION); |
775 | return sprintf(buf, ASUS_OLED_UNDERSCORE_NAME " %s\n", | ||
776 | ASUS_OLED_VERSION); | ||
777 | } | ||
778 | |||
779 | static CLASS_ATTR(version, S_IRUGO, version_show, NULL); | ||
780 | 775 | ||
781 | static int __init asus_oled_init(void) | 776 | static int __init asus_oled_init(void) |
782 | { | 777 | { |
@@ -788,7 +783,7 @@ static int __init asus_oled_init(void) | |||
788 | return PTR_ERR(oled_class); | 783 | return PTR_ERR(oled_class); |
789 | } | 784 | } |
790 | 785 | ||
791 | retval = class_create_file(oled_class, &class_attr_version); | 786 | retval = class_create_file(oled_class, &class_attr_version.attr); |
792 | if (retval) { | 787 | if (retval) { |
793 | err("Error creating class version file"); | 788 | err("Error creating class version file"); |
794 | goto error; | 789 | goto error; |
@@ -810,7 +805,7 @@ error: | |||
810 | 805 | ||
811 | static void __exit asus_oled_exit(void) | 806 | static void __exit asus_oled_exit(void) |
812 | { | 807 | { |
813 | class_remove_file(oled_class, &class_attr_version); | 808 | class_remove_file(oled_class, &class_attr_version.attr); |
814 | class_destroy(oled_class); | 809 | class_destroy(oled_class); |
815 | 810 | ||
816 | usb_deregister(&oled_driver); | 811 | usb_deregister(&oled_driver); |
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 8aa1955f35ed..1da73ecd9799 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig | |||
@@ -44,17 +44,6 @@ config UIO_PDRV_GENIRQ | |||
44 | 44 | ||
45 | If you don't know what to do here, say N. | 45 | If you don't know what to do here, say N. |
46 | 46 | ||
47 | config UIO_SMX | ||
48 | tristate "SMX cryptengine UIO interface" | ||
49 | help | ||
50 | Userspace IO interface to the Cryptography engine found on the | ||
51 | Nias Digital SMX boards. These will be available from Q4 2008 | ||
52 | from http://www.niasdigital.com. The userspace part of this | ||
53 | driver will be released under the GPL at the same time as the | ||
54 | hardware and will be able to be downloaded from the same site. | ||
55 | |||
56 | If you compile this as a module, it will be called uio_smx. | ||
57 | |||
58 | config UIO_AEC | 47 | config UIO_AEC |
59 | tristate "AEC video timestamp device" | 48 | tristate "AEC video timestamp device" |
60 | depends on PCI | 49 | depends on PCI |
@@ -74,6 +63,7 @@ config UIO_AEC | |||
74 | 63 | ||
75 | config UIO_SERCOS3 | 64 | config UIO_SERCOS3 |
76 | tristate "Automata Sercos III PCI card driver" | 65 | tristate "Automata Sercos III PCI card driver" |
66 | depends on PCI | ||
77 | help | 67 | help |
78 | Userspace I/O interface for the Sercos III PCI card from | 68 | Userspace I/O interface for the Sercos III PCI card from |
79 | Automata GmbH. The userspace part of this driver will be | 69 | Automata GmbH. The userspace part of this driver will be |
@@ -87,11 +77,21 @@ config UIO_SERCOS3 | |||
87 | config UIO_PCI_GENERIC | 77 | config UIO_PCI_GENERIC |
88 | tristate "Generic driver for PCI 2.3 and PCI Express cards" | 78 | tristate "Generic driver for PCI 2.3 and PCI Express cards" |
89 | depends on PCI | 79 | depends on PCI |
90 | default n | ||
91 | help | 80 | help |
92 | Generic driver that you can bind, dynamically, to any | 81 | Generic driver that you can bind, dynamically, to any |
93 | PCI 2.3 compliant and PCI Express card. It is useful, | 82 | PCI 2.3 compliant and PCI Express card. It is useful, |
94 | primarily, for virtualization scenarios. | 83 | primarily, for virtualization scenarios. |
95 | If you compile this as a module, it will be called uio_pci_generic. | 84 | If you compile this as a module, it will be called uio_pci_generic. |
96 | 85 | ||
86 | config UIO_NETX | ||
87 | tristate "Hilscher NetX Card driver" | ||
88 | depends on PCI | ||
89 | help | ||
90 | Driver for Hilscher NetX based fieldbus cards (cifX, comX). | ||
91 | This driver requires a userspace component that comes with the card | ||
92 | or is available from Hilscher (http://www.hilscher.com). | ||
93 | |||
94 | To compile this driver as a module, choose M here; the module | ||
95 | will be called uio_netx. | ||
96 | |||
97 | endif | 97 | endif |
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index 73b2e7516729..18fd818c5b97 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile | |||
@@ -2,7 +2,7 @@ obj-$(CONFIG_UIO) += uio.o | |||
2 | obj-$(CONFIG_UIO_CIF) += uio_cif.o | 2 | obj-$(CONFIG_UIO_CIF) += uio_cif.o |
3 | obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o | 3 | obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o |
4 | obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o | 4 | obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o |
5 | obj-$(CONFIG_UIO_SMX) += uio_smx.o | ||
6 | obj-$(CONFIG_UIO_AEC) += uio_aec.o | 5 | obj-$(CONFIG_UIO_AEC) += uio_aec.o |
7 | obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o | 6 | obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o |
8 | obj-$(CONFIG_UIO_PCI_GENERIC) += uio_pci_generic.o | 7 | obj-$(CONFIG_UIO_PCI_GENERIC) += uio_pci_generic.o |
8 | obj-$(CONFIG_UIO_NETX) += uio_netx.o | ||
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index e941367dd28f..4de382acd8f2 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -129,7 +129,7 @@ static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr, | |||
129 | return entry->show(mem, buf); | 129 | return entry->show(mem, buf); |
130 | } | 130 | } |
131 | 131 | ||
132 | static struct sysfs_ops map_sysfs_ops = { | 132 | static const struct sysfs_ops map_sysfs_ops = { |
133 | .show = map_type_show, | 133 | .show = map_type_show, |
134 | }; | 134 | }; |
135 | 135 | ||
@@ -217,7 +217,7 @@ static ssize_t portio_type_show(struct kobject *kobj, struct attribute *attr, | |||
217 | return entry->show(port, buf); | 217 | return entry->show(port, buf); |
218 | } | 218 | } |
219 | 219 | ||
220 | static struct sysfs_ops portio_sysfs_ops = { | 220 | static const struct sysfs_ops portio_sysfs_ops = { |
221 | .show = portio_type_show, | 221 | .show = portio_type_show, |
222 | }; | 222 | }; |
223 | 223 | ||
diff --git a/drivers/uio/uio_netx.c b/drivers/uio/uio_netx.c new file mode 100644 index 000000000000..afbf0bd55cc9 --- /dev/null +++ b/drivers/uio/uio_netx.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* | ||
2 | * UIO driver for Hilscher NetX based fieldbus cards (cifX, comX). | ||
3 | * See http://www.hilscher.com for details. | ||
4 | * | ||
5 | * (C) 2007 Hans J. Koch <hjk@linutronix.de> | ||
6 | * (C) 2008 Manuel Traut <manut@linutronix.de> | ||
7 | * | ||
8 | * Licensed under GPL version 2 only. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/device.h> | ||
13 | #include <linux/io.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/pci.h> | ||
16 | #include <linux/uio_driver.h> | ||
17 | |||
18 | #define PCI_VENDOR_ID_HILSCHER 0x15CF | ||
19 | #define PCI_DEVICE_ID_HILSCHER_NETX 0x0000 | ||
20 | #define PCI_SUBDEVICE_ID_NXSB_PCA 0x3235 | ||
21 | #define PCI_SUBDEVICE_ID_NXPCA 0x3335 | ||
22 | |||
23 | #define DPM_HOST_INT_EN0 0xfff0 | ||
24 | #define DPM_HOST_INT_STAT0 0xffe0 | ||
25 | |||
26 | #define DPM_HOST_INT_MASK 0xe600ffff | ||
27 | #define DPM_HOST_INT_GLOBAL_EN 0x80000000 | ||
28 | |||
29 | static irqreturn_t netx_handler(int irq, struct uio_info *dev_info) | ||
30 | { | ||
31 | void __iomem *int_enable_reg = dev_info->mem[0].internal_addr | ||
32 | + DPM_HOST_INT_EN0; | ||
33 | void __iomem *int_status_reg = dev_info->mem[0].internal_addr | ||
34 | + DPM_HOST_INT_STAT0; | ||
35 | |||
36 | /* Is one of our interrupts enabled and active ? */ | ||
37 | if (!(ioread32(int_enable_reg) & ioread32(int_status_reg) | ||
38 | & DPM_HOST_INT_MASK)) | ||
39 | return IRQ_NONE; | ||
40 | |||
41 | /* Disable interrupt */ | ||
42 | iowrite32(ioread32(int_enable_reg) & ~DPM_HOST_INT_GLOBAL_EN, | ||
43 | int_enable_reg); | ||
44 | return IRQ_HANDLED; | ||
45 | } | ||
46 | |||
47 | static int __devinit netx_pci_probe(struct pci_dev *dev, | ||
48 | const struct pci_device_id *id) | ||
49 | { | ||
50 | struct uio_info *info; | ||
51 | int bar; | ||
52 | |||
53 | info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); | ||
54 | if (!info) | ||
55 | return -ENOMEM; | ||
56 | |||
57 | if (pci_enable_device(dev)) | ||
58 | goto out_free; | ||
59 | |||
60 | if (pci_request_regions(dev, "netx")) | ||
61 | goto out_disable; | ||
62 | |||
63 | switch (id->device) { | ||
64 | case PCI_DEVICE_ID_HILSCHER_NETX: | ||
65 | bar = 0; | ||
66 | info->name = "netx"; | ||
67 | break; | ||
68 | default: | ||
69 | bar = 2; | ||
70 | info->name = "netx_plx"; | ||
71 | } | ||
72 | |||
73 | /* BAR0 or 2 points to the card's dual port memory */ | ||
74 | info->mem[0].addr = pci_resource_start(dev, bar); | ||
75 | if (!info->mem[0].addr) | ||
76 | goto out_release; | ||
77 | info->mem[0].internal_addr = ioremap(pci_resource_start(dev, bar), | ||
78 | pci_resource_len(dev, bar)); | ||
79 | |||
80 | if (!info->mem[0].internal_addr) | ||
81 | goto out_release; | ||
82 | |||
83 | info->mem[0].size = pci_resource_len(dev, bar); | ||
84 | info->mem[0].memtype = UIO_MEM_PHYS; | ||
85 | info->irq = dev->irq; | ||
86 | info->irq_flags = IRQF_SHARED; | ||
87 | info->handler = netx_handler; | ||
88 | info->version = "0.0.1"; | ||
89 | |||
90 | /* Make sure all interrupts are disabled */ | ||
91 | iowrite32(0, info->mem[0].internal_addr + DPM_HOST_INT_EN0); | ||
92 | |||
93 | if (uio_register_device(&dev->dev, info)) | ||
94 | goto out_unmap; | ||
95 | |||
96 | pci_set_drvdata(dev, info); | ||
97 | dev_info(&dev->dev, "Found %s card, registered UIO device.\n", | ||
98 | info->name); | ||
99 | |||
100 | return 0; | ||
101 | |||
102 | out_unmap: | ||
103 | iounmap(info->mem[0].internal_addr); | ||
104 | out_release: | ||
105 | pci_release_regions(dev); | ||
106 | out_disable: | ||
107 | pci_disable_device(dev); | ||
108 | out_free: | ||
109 | kfree(info); | ||
110 | return -ENODEV; | ||
111 | } | ||
112 | |||
113 | static void netx_pci_remove(struct pci_dev *dev) | ||
114 | { | ||
115 | struct uio_info *info = pci_get_drvdata(dev); | ||
116 | |||
117 | /* Disable all interrupts */ | ||
118 | iowrite32(0, info->mem[0].internal_addr + DPM_HOST_INT_EN0); | ||
119 | uio_unregister_device(info); | ||
120 | pci_release_regions(dev); | ||
121 | pci_disable_device(dev); | ||
122 | pci_set_drvdata(dev, NULL); | ||
123 | iounmap(info->mem[0].internal_addr); | ||
124 | |||
125 | kfree(info); | ||
126 | } | ||
127 | |||
128 | static struct pci_device_id netx_pci_ids[] = { | ||
129 | { | ||
130 | .vendor = PCI_VENDOR_ID_HILSCHER, | ||
131 | .device = PCI_DEVICE_ID_HILSCHER_NETX, | ||
132 | .subvendor = 0, | ||
133 | .subdevice = 0, | ||
134 | }, | ||
135 | { | ||
136 | .vendor = PCI_VENDOR_ID_PLX, | ||
137 | .device = PCI_DEVICE_ID_PLX_9030, | ||
138 | .subvendor = PCI_VENDOR_ID_PLX, | ||
139 | .subdevice = PCI_SUBDEVICE_ID_NXSB_PCA, | ||
140 | }, | ||
141 | { | ||
142 | .vendor = PCI_VENDOR_ID_PLX, | ||
143 | .device = PCI_DEVICE_ID_PLX_9030, | ||
144 | .subvendor = PCI_VENDOR_ID_PLX, | ||
145 | .subdevice = PCI_SUBDEVICE_ID_NXPCA, | ||
146 | }, | ||
147 | { 0, } | ||
148 | }; | ||
149 | |||
150 | static struct pci_driver netx_pci_driver = { | ||
151 | .name = "netx", | ||
152 | .id_table = netx_pci_ids, | ||
153 | .probe = netx_pci_probe, | ||
154 | .remove = netx_pci_remove, | ||
155 | }; | ||
156 | |||
157 | static int __init netx_init_module(void) | ||
158 | { | ||
159 | return pci_register_driver(&netx_pci_driver); | ||
160 | } | ||
161 | |||
162 | static void __exit netx_exit_module(void) | ||
163 | { | ||
164 | pci_unregister_driver(&netx_pci_driver); | ||
165 | } | ||
166 | |||
167 | module_init(netx_init_module); | ||
168 | module_exit(netx_exit_module); | ||
169 | |||
170 | MODULE_DEVICE_TABLE(pci, netx_pci_ids); | ||
171 | MODULE_LICENSE("GPL v2"); | ||
172 | MODULE_AUTHOR("Hans J. Koch, Manuel Traut"); | ||
diff --git a/drivers/uio/uio_smx.c b/drivers/uio/uio_smx.c deleted file mode 100644 index 44054a650a8a..000000000000 --- a/drivers/uio/uio_smx.c +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
1 | /* | ||
2 | * UIO SMX Cryptengine driver. | ||
3 | * | ||
4 | * (C) 2008 Nias Digital P/L <bn@niasdigital.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/device.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/uio_driver.h> | ||
16 | #include <linux/io.h> | ||
17 | |||
18 | #define DRV_NAME "smx-ce" | ||
19 | #define DRV_VERSION "0.03" | ||
20 | |||
21 | #define SMX_CSR 0x00000000 | ||
22 | #define SMX_EnD 0x00000001 | ||
23 | #define SMX_RUN 0x00000002 | ||
24 | #define SMX_DRDY 0x00000004 | ||
25 | #define SMX_ERR 0x00000008 | ||
26 | |||
27 | static irqreturn_t smx_handler(int irq, struct uio_info *dev_info) | ||
28 | { | ||
29 | void __iomem *csr = dev_info->mem[0].internal_addr + SMX_CSR; | ||
30 | |||
31 | u32 status = ioread32(csr); | ||
32 | |||
33 | if (!(status & SMX_DRDY)) | ||
34 | return IRQ_NONE; | ||
35 | |||
36 | /* Disable interrupt */ | ||
37 | iowrite32(status & ~SMX_DRDY, csr); | ||
38 | return IRQ_HANDLED; | ||
39 | } | ||
40 | |||
41 | static int __devinit smx_ce_probe(struct platform_device *dev) | ||
42 | { | ||
43 | |||
44 | int ret = -ENODEV; | ||
45 | struct uio_info *info; | ||
46 | struct resource *regs; | ||
47 | |||
48 | info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); | ||
49 | if (!info) | ||
50 | return -ENOMEM; | ||
51 | |||
52 | regs = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
53 | if (!regs) { | ||
54 | dev_err(&dev->dev, "No memory resource specified\n"); | ||
55 | goto out_free; | ||
56 | } | ||
57 | |||
58 | info->mem[0].addr = regs->start; | ||
59 | if (!info->mem[0].addr) { | ||
60 | dev_err(&dev->dev, "Invalid memory resource\n"); | ||
61 | goto out_free; | ||
62 | } | ||
63 | |||
64 | info->mem[0].size = regs->end - regs->start + 1; | ||
65 | info->mem[0].internal_addr = ioremap(regs->start, info->mem[0].size); | ||
66 | |||
67 | if (!info->mem[0].internal_addr) { | ||
68 | dev_err(&dev->dev, "Can't remap memory address range\n"); | ||
69 | goto out_free; | ||
70 | } | ||
71 | |||
72 | info->mem[0].memtype = UIO_MEM_PHYS; | ||
73 | |||
74 | info->name = "smx-ce"; | ||
75 | info->version = "0.03"; | ||
76 | |||
77 | info->irq = platform_get_irq(dev, 0); | ||
78 | if (info->irq < 0) { | ||
79 | ret = info->irq; | ||
80 | dev_err(&dev->dev, "No (or invalid) IRQ resource specified\n"); | ||
81 | goto out_unmap; | ||
82 | } | ||
83 | |||
84 | info->irq_flags = IRQF_SHARED; | ||
85 | info->handler = smx_handler; | ||
86 | |||
87 | platform_set_drvdata(dev, info); | ||
88 | |||
89 | ret = uio_register_device(&dev->dev, info); | ||
90 | |||
91 | if (ret) | ||
92 | goto out_unmap; | ||
93 | |||
94 | return 0; | ||
95 | |||
96 | out_unmap: | ||
97 | iounmap(info->mem[0].internal_addr); | ||
98 | out_free: | ||
99 | kfree(info); | ||
100 | |||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | static int __devexit smx_ce_remove(struct platform_device *dev) | ||
105 | { | ||
106 | struct uio_info *info = platform_get_drvdata(dev); | ||
107 | |||
108 | uio_unregister_device(info); | ||
109 | platform_set_drvdata(dev, NULL); | ||
110 | iounmap(info->mem[0].internal_addr); | ||
111 | |||
112 | kfree(info); | ||
113 | |||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static struct platform_driver smx_ce_driver = { | ||
118 | .probe = smx_ce_probe, | ||
119 | .remove = __devexit_p(smx_ce_remove), | ||
120 | .driver = { | ||
121 | .name = DRV_NAME, | ||
122 | .owner = THIS_MODULE, | ||
123 | }, | ||
124 | }; | ||
125 | |||
126 | static int __init smx_ce_init_module(void) | ||
127 | { | ||
128 | return platform_driver_register(&smx_ce_driver); | ||
129 | } | ||
130 | module_init(smx_ce_init_module); | ||
131 | |||
132 | static void __exit smx_ce_exit_module(void) | ||
133 | { | ||
134 | platform_driver_unregister(&smx_ce_driver); | ||
135 | } | ||
136 | module_exit(smx_ce_exit_module); | ||
137 | |||
138 | MODULE_LICENSE("GPL v2"); | ||
139 | MODULE_VERSION(DRV_VERSION); | ||
140 | MODULE_AUTHOR("Ben Nizette <bn@niasdigital.com>"); | ||
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index a7037bf81688..f3c233806fa3 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -489,10 +489,10 @@ void usb_driver_release_interface(struct usb_driver *driver, | |||
489 | if (device_is_registered(dev)) { | 489 | if (device_is_registered(dev)) { |
490 | device_release_driver(dev); | 490 | device_release_driver(dev); |
491 | } else { | 491 | } else { |
492 | down(&dev->sem); | 492 | device_lock(dev); |
493 | usb_unbind_interface(dev); | 493 | usb_unbind_interface(dev); |
494 | dev->driver = NULL; | 494 | dev->driver = NULL; |
495 | up(&dev->sem); | 495 | device_unlock(dev); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | EXPORT_SYMBOL_GPL(usb_driver_release_interface); | 498 | EXPORT_SYMBOL_GPL(usb_driver_release_interface); |
diff --git a/drivers/usb/gadget/fsl_mx3_udc.c b/drivers/usb/gadget/fsl_mx3_udc.c index 4bc2bf3d602e..20a802ecaa15 100644 --- a/drivers/usb/gadget/fsl_mx3_udc.c +++ b/drivers/usb/gadget/fsl_mx3_udc.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/fsl_devices.h> | 17 | #include <linux/fsl_devices.h> |
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | 19 | ||
20 | #include <mach/hardware.h> | ||
21 | |||
20 | static struct clk *mxc_ahb_clk; | 22 | static struct clk *mxc_ahb_clk; |
21 | static struct clk *mxc_usb_clk; | 23 | static struct clk *mxc_usb_clk; |
22 | 24 | ||
@@ -28,14 +30,16 @@ int fsl_udc_clk_init(struct platform_device *pdev) | |||
28 | 30 | ||
29 | pdata = pdev->dev.platform_data; | 31 | pdata = pdev->dev.platform_data; |
30 | 32 | ||
31 | mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb"); | 33 | if (!cpu_is_mx35()) { |
32 | if (IS_ERR(mxc_ahb_clk)) | 34 | mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb"); |
33 | return PTR_ERR(mxc_ahb_clk); | 35 | if (IS_ERR(mxc_ahb_clk)) |
36 | return PTR_ERR(mxc_ahb_clk); | ||
34 | 37 | ||
35 | ret = clk_enable(mxc_ahb_clk); | 38 | ret = clk_enable(mxc_ahb_clk); |
36 | if (ret < 0) { | 39 | if (ret < 0) { |
37 | dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n"); | 40 | dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n"); |
38 | goto eenahb; | 41 | goto eenahb; |
42 | } | ||
39 | } | 43 | } |
40 | 44 | ||
41 | /* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */ | 45 | /* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */ |
@@ -50,6 +54,7 @@ int fsl_udc_clk_init(struct platform_device *pdev) | |||
50 | if (pdata->phy_mode != FSL_USB2_PHY_ULPI && | 54 | if (pdata->phy_mode != FSL_USB2_PHY_ULPI && |
51 | (freq < 59999000 || freq > 60001000)) { | 55 | (freq < 59999000 || freq > 60001000)) { |
52 | dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq); | 56 | dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq); |
57 | ret = -EINVAL; | ||
53 | goto eclkrate; | 58 | goto eclkrate; |
54 | } | 59 | } |
55 | 60 | ||
@@ -66,9 +71,11 @@ eclkrate: | |||
66 | clk_put(mxc_usb_clk); | 71 | clk_put(mxc_usb_clk); |
67 | mxc_usb_clk = NULL; | 72 | mxc_usb_clk = NULL; |
68 | egusb: | 73 | egusb: |
69 | clk_disable(mxc_ahb_clk); | 74 | if (!cpu_is_mx35()) |
75 | clk_disable(mxc_ahb_clk); | ||
70 | eenahb: | 76 | eenahb: |
71 | clk_put(mxc_ahb_clk); | 77 | if (!cpu_is_mx35()) |
78 | clk_put(mxc_ahb_clk); | ||
72 | return ret; | 79 | return ret; |
73 | } | 80 | } |
74 | 81 | ||
@@ -90,6 +97,8 @@ void fsl_udc_clk_release(void) | |||
90 | clk_disable(mxc_usb_clk); | 97 | clk_disable(mxc_usb_clk); |
91 | clk_put(mxc_usb_clk); | 98 | clk_put(mxc_usb_clk); |
92 | } | 99 | } |
93 | clk_disable(mxc_ahb_clk); | 100 | if (!cpu_is_mx35()) { |
94 | clk_put(mxc_ahb_clk); | 101 | clk_disable(mxc_ahb_clk); |
102 | clk_put(mxc_ahb_clk); | ||
103 | } | ||
95 | } | 104 | } |
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index e6fedbd5a654..be5fb34d9602 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c | |||
@@ -65,6 +65,10 @@ | |||
65 | #include <mach/pxa25x-udc.h> | 65 | #include <mach/pxa25x-udc.h> |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #ifdef CONFIG_ARCH_LUBBOCK | ||
69 | #include <mach/lubbock.h> | ||
70 | #endif | ||
71 | |||
68 | #include <asm/mach/udc_pxa2xx.h> | 72 | #include <asm/mach/udc_pxa2xx.h> |
69 | 73 | ||
70 | 74 | ||
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 7e5bf593d386..f742c8e7397c 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #include <plat/regs-usb-hsotg-phy.h> | 31 | #include <plat/regs-usb-hsotg-phy.h> |
32 | #include <plat/regs-usb-hsotg.h> | 32 | #include <plat/regs-usb-hsotg.h> |
33 | #include <plat/regs-sys.h> | 33 | #include <mach/regs-sys.h> |
34 | #include <plat/udc-hs.h> | 34 | #include <plat/udc-hs.h> |
35 | 35 | ||
36 | #define DMA_ADDR_INVALID (~((dma_addr_t)0)) | 36 | #define DMA_ADDR_INVALID (~((dma_addr_t)0)) |
diff --git a/drivers/uwb/driver.c b/drivers/uwb/driver.c index da77e41de990..08bd6dbfd4a6 100644 --- a/drivers/uwb/driver.c +++ b/drivers/uwb/driver.c | |||
@@ -74,13 +74,16 @@ | |||
74 | unsigned long beacon_timeout_ms = 500; | 74 | unsigned long beacon_timeout_ms = 500; |
75 | 75 | ||
76 | static | 76 | static |
77 | ssize_t beacon_timeout_ms_show(struct class *class, char *buf) | 77 | ssize_t beacon_timeout_ms_show(struct class *class, |
78 | struct class_attribute *attr, | ||
79 | char *buf) | ||
78 | { | 80 | { |
79 | return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms); | 81 | return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms); |
80 | } | 82 | } |
81 | 83 | ||
82 | static | 84 | static |
83 | ssize_t beacon_timeout_ms_store(struct class *class, | 85 | ssize_t beacon_timeout_ms_store(struct class *class, |
86 | struct class_attribute *attr, | ||
84 | const char *buf, size_t size) | 87 | const char *buf, size_t size) |
85 | { | 88 | { |
86 | unsigned long bt; | 89 | unsigned long bt; |
diff --git a/drivers/uwb/umc-bus.c b/drivers/uwb/umc-bus.c index cdd6c8efc9f8..5fad4e791b3e 100644 --- a/drivers/uwb/umc-bus.c +++ b/drivers/uwb/umc-bus.c | |||
@@ -62,12 +62,12 @@ int umc_controller_reset(struct umc_dev *umc) | |||
62 | struct device *parent = umc->dev.parent; | 62 | struct device *parent = umc->dev.parent; |
63 | int ret = 0; | 63 | int ret = 0; |
64 | 64 | ||
65 | if(down_trylock(&parent->sem)) | 65 | if (device_trylock(parent)) |
66 | return -EAGAIN; | 66 | return -EAGAIN; |
67 | ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper); | 67 | ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper); |
68 | if (ret >= 0) | 68 | if (ret >= 0) |
69 | ret = device_for_each_child(parent, parent, umc_bus_post_reset_helper); | 69 | ret = device_for_each_child(parent, parent, umc_bus_post_reset_helper); |
70 | up(&parent->sem); | 70 | device_unlock(parent); |
71 | 71 | ||
72 | return ret; | 72 | return ret; |
73 | } | 73 | } |
diff --git a/drivers/uwb/uwb-internal.h b/drivers/uwb/uwb-internal.h index d5bcfc1c227a..157485c862c0 100644 --- a/drivers/uwb/uwb-internal.h +++ b/drivers/uwb/uwb-internal.h | |||
@@ -366,12 +366,12 @@ struct dentry *uwb_dbg_create_pal_dir(struct uwb_pal *pal); | |||
366 | 366 | ||
367 | static inline void uwb_dev_lock(struct uwb_dev *uwb_dev) | 367 | static inline void uwb_dev_lock(struct uwb_dev *uwb_dev) |
368 | { | 368 | { |
369 | down(&uwb_dev->dev.sem); | 369 | device_lock(&uwb_dev->dev); |
370 | } | 370 | } |
371 | 371 | ||
372 | static inline void uwb_dev_unlock(struct uwb_dev *uwb_dev) | 372 | static inline void uwb_dev_unlock(struct uwb_dev *uwb_dev) |
373 | { | 373 | { |
374 | up(&uwb_dev->dev.sem); | 374 | device_unlock(&uwb_dev->dev); |
375 | } | 375 | } |
376 | 376 | ||
377 | #endif /* #ifndef __UWB_INTERNAL_H__ */ | 377 | #endif /* #ifndef __UWB_INTERNAL_H__ */ |
diff --git a/drivers/uwb/wlp/sysfs.c b/drivers/uwb/wlp/sysfs.c index 0370399ff4bb..6627c94cc854 100644 --- a/drivers/uwb/wlp/sysfs.c +++ b/drivers/uwb/wlp/sysfs.c | |||
@@ -615,8 +615,7 @@ ssize_t wlp_wss_attr_store(struct kobject *kobj, struct attribute *attr, | |||
615 | return ret; | 615 | return ret; |
616 | } | 616 | } |
617 | 617 | ||
618 | static | 618 | static const struct sysfs_ops wss_sysfs_ops = { |
619 | struct sysfs_ops wss_sysfs_ops = { | ||
620 | .show = wlp_wss_attr_show, | 619 | .show = wlp_wss_attr_show, |
621 | .store = wlp_wss_attr_store, | 620 | .store = wlp_wss_attr_store, |
622 | }; | 621 | }; |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 5a5c303a6373..1c60053439a9 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -400,9 +400,12 @@ config FB_SA1100 | |||
400 | If you plan to use the LCD display with your SA-1100 system, say | 400 | If you plan to use the LCD display with your SA-1100 system, say |
401 | Y here. | 401 | Y here. |
402 | 402 | ||
403 | config HAVE_FB_IMX | ||
404 | bool | ||
405 | |||
403 | config FB_IMX | 406 | config FB_IMX |
404 | tristate "Motorola i.MX LCD support" | 407 | tristate "Motorola i.MX LCD support" |
405 | depends on FB && (ARCH_MX1 || ARCH_MX2) | 408 | depends on FB && (HAVE_FB_IMX || ARCH_MX1 || ARCH_MX2) |
406 | select FB_CFB_FILLRECT | 409 | select FB_CFB_FILLRECT |
407 | select FB_CFB_COPYAREA | 410 | select FB_CFB_COPYAREA |
408 | select FB_CFB_IMAGEBLIT | 411 | select FB_CFB_IMAGEBLIT |
@@ -1494,7 +1497,6 @@ config FB_VIA | |||
1494 | select FB_CFB_FILLRECT | 1497 | select FB_CFB_FILLRECT |
1495 | select FB_CFB_COPYAREA | 1498 | select FB_CFB_COPYAREA |
1496 | select FB_CFB_IMAGEBLIT | 1499 | select FB_CFB_IMAGEBLIT |
1497 | select FB_SOFT_CURSOR | ||
1498 | select I2C_ALGOBIT | 1500 | select I2C_ALGOBIT |
1499 | select I2C | 1501 | select I2C |
1500 | help | 1502 | help |
@@ -1945,6 +1947,27 @@ config FB_S3C2410_DEBUG | |||
1945 | Turn on debugging messages. Note that you can set/unset at run time | 1947 | Turn on debugging messages. Note that you can set/unset at run time |
1946 | through sysfs | 1948 | through sysfs |
1947 | 1949 | ||
1950 | config FB_NUC900 | ||
1951 | bool "NUC900 LCD framebuffer support" | ||
1952 | depends on FB && ARCH_W90X900 | ||
1953 | select FB_CFB_FILLRECT | ||
1954 | select FB_CFB_COPYAREA | ||
1955 | select FB_CFB_IMAGEBLIT | ||
1956 | ---help--- | ||
1957 | Frame buffer driver for the built-in LCD controller in the Nuvoton | ||
1958 | NUC900 processor | ||
1959 | |||
1960 | config GPM1040A0_320X240 | ||
1961 | bool "Giantplus Technology GPM1040A0 320x240 Color TFT LCD" | ||
1962 | depends on FB_NUC900 | ||
1963 | |||
1964 | config FB_NUC900_DEBUG | ||
1965 | bool "NUC900 lcd debug messages" | ||
1966 | depends on FB_NUC900 | ||
1967 | help | ||
1968 | Turn on debugging messages. Note that you can set/unset at run time | ||
1969 | through sysfs | ||
1970 | |||
1948 | config FB_SM501 | 1971 | config FB_SM501 |
1949 | tristate "Silicon Motion SM501 framebuffer support" | 1972 | tristate "Silicon Motion SM501 framebuffer support" |
1950 | depends on FB && MFD_SM501 | 1973 | depends on FB && MFD_SM501 |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 4ecb30c4f3f2..a42ad55e3a15 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -129,6 +129,7 @@ obj-$(CONFIG_XEN_FBDEV_FRONTEND) += xen-fbfront.o | |||
129 | obj-$(CONFIG_FB_CARMINE) += carminefb.o | 129 | obj-$(CONFIG_FB_CARMINE) += carminefb.o |
130 | obj-$(CONFIG_FB_MB862XX) += mb862xx/ | 130 | obj-$(CONFIG_FB_MB862XX) += mb862xx/ |
131 | obj-$(CONFIG_FB_MSM) += msm/ | 131 | obj-$(CONFIG_FB_MSM) += msm/ |
132 | obj-$(CONFIG_FB_NUC900) += nuc900fb.o | ||
132 | 133 | ||
133 | # Platform or fallback drivers go here | 134 | # Platform or fallback drivers go here |
134 | obj-$(CONFIG_FB_UVESA) += uvesafb.o | 135 | obj-$(CONFIG_FB_UVESA) += uvesafb.o |
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c index 0bcc59eb37fa..43d7d5067361 100644 --- a/drivers/video/acornfb.c +++ b/drivers/video/acornfb.c | |||
@@ -1221,7 +1221,7 @@ free_unused_pages(unsigned int virtual_start, unsigned int virtual_end) | |||
1221 | printk("acornfb: freed %dK memory\n", mb_freed); | 1221 | printk("acornfb: freed %dK memory\n", mb_freed); |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | static int __init acornfb_probe(struct platform_device *dev) | 1224 | static int __devinit acornfb_probe(struct platform_device *dev) |
1225 | { | 1225 | { |
1226 | unsigned long size; | 1226 | unsigned long size; |
1227 | u_int h_sync, v_sync; | 1227 | u_int h_sync, v_sync; |
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c index c3431691c9f2..01554d696528 100644 --- a/drivers/video/arcfb.c +++ b/drivers/video/arcfb.c | |||
@@ -504,7 +504,7 @@ static struct fb_ops arcfb_ops = { | |||
504 | .fb_ioctl = arcfb_ioctl, | 504 | .fb_ioctl = arcfb_ioctl, |
505 | }; | 505 | }; |
506 | 506 | ||
507 | static int __init arcfb_probe(struct platform_device *dev) | 507 | static int __devinit arcfb_probe(struct platform_device *dev) |
508 | { | 508 | { |
509 | struct fb_info *info; | 509 | struct fb_info *info; |
510 | int retval = -ENOMEM; | 510 | int retval = -ENOMEM; |
diff --git a/drivers/video/asiliantfb.c b/drivers/video/asiliantfb.c index 9fe90ce928fb..e70bc225fe31 100644 --- a/drivers/video/asiliantfb.c +++ b/drivers/video/asiliantfb.c | |||
@@ -140,7 +140,7 @@ static void asiliant_calc_dclk2(u32 *ppixclock, u8 *dclk2_m, u8 *dclk2_n, u8 *dc | |||
140 | 140 | ||
141 | /* 3 <= m <= 257 */ | 141 | /* 3 <= m <= 257 */ |
142 | if (m >= 3 && m <= 257) { | 142 | if (m >= 3 && m <= 257) { |
143 | unsigned new_error = ((Ftarget * n) - (Fref * m)) >= 0 ? | 143 | unsigned new_error = Ftarget * n >= Fref * m ? |
144 | ((Ftarget * n) - (Fref * m)) : ((Fref * m) - (Ftarget * n)); | 144 | ((Ftarget * n) - (Fref * m)) : ((Fref * m) - (Ftarget * n)); |
145 | if (new_error < best_error) { | 145 | if (new_error < best_error) { |
146 | best_n = n; | 146 | best_n = n; |
@@ -152,7 +152,7 @@ static void asiliant_calc_dclk2(u32 *ppixclock, u8 *dclk2_m, u8 *dclk2_n, u8 *dc | |||
152 | else if (m <= 1028) { | 152 | else if (m <= 1028) { |
153 | /* remember there are still only 8-bits of precision in m, so | 153 | /* remember there are still only 8-bits of precision in m, so |
154 | * avoid over-optimistic error calculations */ | 154 | * avoid over-optimistic error calculations */ |
155 | unsigned new_error = ((Ftarget * n) - (Fref * (m & ~3))) >= 0 ? | 155 | unsigned new_error = Ftarget * n >= Fref * (m & ~3) ? |
156 | ((Ftarget * n) - (Fref * (m & ~3))) : ((Fref * (m & ~3)) - (Ftarget * n)); | 156 | ((Ftarget * n) - (Fref * (m & ~3))) : ((Fref * (m & ~3)) - (Ftarget * n)); |
157 | if (new_error < best_error) { | 157 | if (new_error < best_error) { |
158 | best_n = n; | 158 | best_n = n; |
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c index e49ae5edcc00..814312a7452f 100644 --- a/drivers/video/bf54x-lq043fb.c +++ b/drivers/video/bf54x-lq043fb.c | |||
@@ -82,7 +82,6 @@ struct bfin_bf54xfb_info { | |||
82 | unsigned char *fb_buffer; /* RGB Buffer */ | 82 | unsigned char *fb_buffer; /* RGB Buffer */ |
83 | 83 | ||
84 | dma_addr_t dma_handle; | 84 | dma_addr_t dma_handle; |
85 | int lq043_mmap; | ||
86 | int lq043_open_cnt; | 85 | int lq043_open_cnt; |
87 | int irq; | 86 | int irq; |
88 | spinlock_t lock; /* lock */ | 87 | spinlock_t lock; /* lock */ |
@@ -316,7 +315,6 @@ static int bfin_bf54x_fb_release(struct fb_info *info, int user) | |||
316 | spin_lock(&fbi->lock); | 315 | spin_lock(&fbi->lock); |
317 | 316 | ||
318 | fbi->lq043_open_cnt--; | 317 | fbi->lq043_open_cnt--; |
319 | fbi->lq043_mmap = 0; | ||
320 | 318 | ||
321 | if (fbi->lq043_open_cnt <= 0) { | 319 | if (fbi->lq043_open_cnt <= 0) { |
322 | 320 | ||
@@ -374,33 +372,6 @@ static int bfin_bf54x_fb_check_var(struct fb_var_screeninfo *var, | |||
374 | return 0; | 372 | return 0; |
375 | } | 373 | } |
376 | 374 | ||
377 | static int bfin_bf54x_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) | ||
378 | { | ||
379 | |||
380 | struct bfin_bf54xfb_info *fbi = info->par; | ||
381 | |||
382 | if (fbi->lq043_mmap) | ||
383 | return -1; | ||
384 | |||
385 | spin_lock(&fbi->lock); | ||
386 | fbi->lq043_mmap = 1; | ||
387 | spin_unlock(&fbi->lock); | ||
388 | |||
389 | vma->vm_start = (unsigned long)(fbi->fb_buffer); | ||
390 | |||
391 | vma->vm_end = vma->vm_start + info->fix.smem_len; | ||
392 | /* For those who don't understand how mmap works, go read | ||
393 | * Documentation/nommu-mmap.txt. | ||
394 | * For those that do, you will know that the VM_MAYSHARE flag | ||
395 | * must be set in the vma->vm_flags structure on noMMU | ||
396 | * Other flags can be set, and are documented in | ||
397 | * include/linux/mm.h | ||
398 | */ | ||
399 | vma->vm_flags |= VM_MAYSHARE | VM_SHARED; | ||
400 | |||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | int bfin_bf54x_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) | 375 | int bfin_bf54x_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) |
405 | { | 376 | { |
406 | if (nocursor) | 377 | if (nocursor) |
@@ -452,7 +423,6 @@ static struct fb_ops bfin_bf54x_fb_ops = { | |||
452 | .fb_fillrect = cfb_fillrect, | 423 | .fb_fillrect = cfb_fillrect, |
453 | .fb_copyarea = cfb_copyarea, | 424 | .fb_copyarea = cfb_copyarea, |
454 | .fb_imageblit = cfb_imageblit, | 425 | .fb_imageblit = cfb_imageblit, |
455 | .fb_mmap = bfin_bf54x_fb_mmap, | ||
456 | .fb_cursor = bfin_bf54x_fb_cursor, | 426 | .fb_cursor = bfin_bf54x_fb_cursor, |
457 | .fb_setcolreg = bfin_bf54x_fb_setcolreg, | 427 | .fb_setcolreg = bfin_bf54x_fb_setcolreg, |
458 | }; | 428 | }; |
diff --git a/drivers/video/bfin-lq035q1-fb.c b/drivers/video/bfin-lq035q1-fb.c index b690c269784a..03872365a36d 100644 --- a/drivers/video/bfin-lq035q1-fb.c +++ b/drivers/video/bfin-lq035q1-fb.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/dma-mapping.h> | 22 | #include <linux/dma-mapping.h> |
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/spi/spi.h> | 24 | #include <linux/spi/spi.h> |
25 | #include <linux/dma-mapping.h> | ||
26 | 25 | ||
27 | #include <asm/blackfin.h> | 26 | #include <asm/blackfin.h> |
28 | #include <asm/irq.h> | 27 | #include <asm/irq.h> |
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c index 2549c53b26a0..5653d083a983 100644 --- a/drivers/video/bfin-t350mcqb-fb.c +++ b/drivers/video/bfin-t350mcqb-fb.c | |||
@@ -87,7 +87,6 @@ struct bfin_t350mcqbfb_info { | |||
87 | struct device *dev; | 87 | struct device *dev; |
88 | unsigned char *fb_buffer; /* RGB Buffer */ | 88 | unsigned char *fb_buffer; /* RGB Buffer */ |
89 | dma_addr_t dma_handle; | 89 | dma_addr_t dma_handle; |
90 | int lq043_mmap; | ||
91 | int lq043_open_cnt; | 90 | int lq043_open_cnt; |
92 | int irq; | 91 | int irq; |
93 | spinlock_t lock; /* lock */ | 92 | spinlock_t lock; /* lock */ |
@@ -235,7 +234,6 @@ static int bfin_t350mcqb_fb_release(struct fb_info *info, int user) | |||
235 | spin_lock(&fbi->lock); | 234 | spin_lock(&fbi->lock); |
236 | 235 | ||
237 | fbi->lq043_open_cnt--; | 236 | fbi->lq043_open_cnt--; |
238 | fbi->lq043_mmap = 0; | ||
239 | 237 | ||
240 | if (fbi->lq043_open_cnt <= 0) { | 238 | if (fbi->lq043_open_cnt <= 0) { |
241 | bfin_t350mcqb_disable_ppi(); | 239 | bfin_t350mcqb_disable_ppi(); |
@@ -293,32 +291,6 @@ static int bfin_t350mcqb_fb_check_var(struct fb_var_screeninfo *var, | |||
293 | return 0; | 291 | return 0; |
294 | } | 292 | } |
295 | 293 | ||
296 | static int bfin_t350mcqb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) | ||
297 | { | ||
298 | struct bfin_t350mcqbfb_info *fbi = info->par; | ||
299 | |||
300 | if (fbi->lq043_mmap) | ||
301 | return -1; | ||
302 | |||
303 | spin_lock(&fbi->lock); | ||
304 | fbi->lq043_mmap = 1; | ||
305 | spin_unlock(&fbi->lock); | ||
306 | |||
307 | vma->vm_start = (unsigned long)(fbi->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET); | ||
308 | |||
309 | vma->vm_end = vma->vm_start + info->fix.smem_len; | ||
310 | /* For those who don't understand how mmap works, go read | ||
311 | * Documentation/nommu-mmap.txt. | ||
312 | * For those that do, you will know that the VM_MAYSHARE flag | ||
313 | * must be set in the vma->vm_flags structure on noMMU | ||
314 | * Other flags can be set, and are documented in | ||
315 | * include/linux/mm.h | ||
316 | */ | ||
317 | vma->vm_flags |= VM_MAYSHARE | VM_SHARED; | ||
318 | |||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | int bfin_t350mcqb_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) | 294 | int bfin_t350mcqb_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) |
323 | { | 295 | { |
324 | if (nocursor) | 296 | if (nocursor) |
@@ -370,7 +342,6 @@ static struct fb_ops bfin_t350mcqb_fb_ops = { | |||
370 | .fb_fillrect = cfb_fillrect, | 342 | .fb_fillrect = cfb_fillrect, |
371 | .fb_copyarea = cfb_copyarea, | 343 | .fb_copyarea = cfb_copyarea, |
372 | .fb_imageblit = cfb_imageblit, | 344 | .fb_imageblit = cfb_imageblit, |
373 | .fb_mmap = bfin_t350mcqb_fb_mmap, | ||
374 | .fb_cursor = bfin_t350mcqb_fb_cursor, | 345 | .fb_cursor = bfin_t350mcqb_fb_cursor, |
375 | .fb_setcolreg = bfin_t350mcqb_fb_setcolreg, | 346 | .fb_setcolreg = bfin_t350mcqb_fb_setcolreg, |
376 | }; | 347 | }; |
diff --git a/drivers/video/broadsheetfb.c b/drivers/video/broadsheetfb.c index df9ccb901d86..ebda6876d3a9 100644 --- a/drivers/video/broadsheetfb.c +++ b/drivers/video/broadsheetfb.c | |||
@@ -29,11 +29,65 @@ | |||
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/list.h> | 31 | #include <linux/list.h> |
32 | #include <linux/firmware.h> | ||
32 | #include <linux/uaccess.h> | 33 | #include <linux/uaccess.h> |
33 | 34 | ||
34 | #include <video/broadsheetfb.h> | 35 | #include <video/broadsheetfb.h> |
35 | 36 | ||
36 | /* Display specific information */ | 37 | /* track panel specific parameters */ |
38 | struct panel_info { | ||
39 | int w; | ||
40 | int h; | ||
41 | u16 sdcfg; | ||
42 | u16 gdcfg; | ||
43 | u16 lutfmt; | ||
44 | u16 fsynclen; | ||
45 | u16 fendfbegin; | ||
46 | u16 lsynclen; | ||
47 | u16 lendlbegin; | ||
48 | u16 pixclk; | ||
49 | }; | ||
50 | |||
51 | /* table of panel specific parameters to be indexed into by the board drivers */ | ||
52 | static struct panel_info panel_table[] = { | ||
53 | { /* standard 6" on TFT backplane */ | ||
54 | .w = 800, | ||
55 | .h = 600, | ||
56 | .sdcfg = (100 | (1 << 8) | (1 << 9)), | ||
57 | .gdcfg = 2, | ||
58 | .lutfmt = (4 | (1 << 7)), | ||
59 | .fsynclen = 4, | ||
60 | .fendfbegin = (10 << 8) | 4, | ||
61 | .lsynclen = 10, | ||
62 | .lendlbegin = (100 << 8) | 4, | ||
63 | .pixclk = 6, | ||
64 | }, | ||
65 | { /* custom 3.7" flexible on PET or steel */ | ||
66 | .w = 320, | ||
67 | .h = 240, | ||
68 | .sdcfg = (67 | (0 << 8) | (0 << 9) | (0 << 10) | (0 << 12)), | ||
69 | .gdcfg = 3, | ||
70 | .lutfmt = (4 | (1 << 7)), | ||
71 | .fsynclen = 0, | ||
72 | .fendfbegin = (80 << 8) | 4, | ||
73 | .lsynclen = 10, | ||
74 | .lendlbegin = (80 << 8) | 20, | ||
75 | .pixclk = 14, | ||
76 | }, | ||
77 | { /* standard 9.7" on TFT backplane */ | ||
78 | .w = 1200, | ||
79 | .h = 825, | ||
80 | .sdcfg = (100 | (1 << 8) | (1 << 9) | (0 << 10) | (0 << 12)), | ||
81 | .gdcfg = 2, | ||
82 | .lutfmt = (4 | (1 << 7)), | ||
83 | .fsynclen = 0, | ||
84 | .fendfbegin = (4 << 8) | 4, | ||
85 | .lsynclen = 4, | ||
86 | .lendlbegin = (60 << 8) | 10, | ||
87 | .pixclk = 3, | ||
88 | }, | ||
89 | }; | ||
90 | |||
37 | #define DPY_W 800 | 91 | #define DPY_W 800 |
38 | #define DPY_H 600 | 92 | #define DPY_H 600 |
39 | 93 | ||
@@ -62,30 +116,30 @@ static struct fb_var_screeninfo broadsheetfb_var __devinitdata = { | |||
62 | }; | 116 | }; |
63 | 117 | ||
64 | /* main broadsheetfb functions */ | 118 | /* main broadsheetfb functions */ |
65 | static void broadsheet_issue_data(struct broadsheetfb_par *par, u16 data) | 119 | static void broadsheet_gpio_issue_data(struct broadsheetfb_par *par, u16 data) |
66 | { | 120 | { |
67 | par->board->set_ctl(par, BS_WR, 0); | 121 | par->board->set_ctl(par, BS_WR, 0); |
68 | par->board->set_hdb(par, data); | 122 | par->board->set_hdb(par, data); |
69 | par->board->set_ctl(par, BS_WR, 1); | 123 | par->board->set_ctl(par, BS_WR, 1); |
70 | } | 124 | } |
71 | 125 | ||
72 | static void broadsheet_issue_cmd(struct broadsheetfb_par *par, u16 data) | 126 | static void broadsheet_gpio_issue_cmd(struct broadsheetfb_par *par, u16 data) |
73 | { | 127 | { |
74 | par->board->set_ctl(par, BS_DC, 0); | 128 | par->board->set_ctl(par, BS_DC, 0); |
75 | broadsheet_issue_data(par, data); | 129 | broadsheet_gpio_issue_data(par, data); |
76 | } | 130 | } |
77 | 131 | ||
78 | static void broadsheet_send_command(struct broadsheetfb_par *par, u16 data) | 132 | static void broadsheet_gpio_send_command(struct broadsheetfb_par *par, u16 data) |
79 | { | 133 | { |
80 | par->board->wait_for_rdy(par); | 134 | par->board->wait_for_rdy(par); |
81 | 135 | ||
82 | par->board->set_ctl(par, BS_CS, 0); | 136 | par->board->set_ctl(par, BS_CS, 0); |
83 | broadsheet_issue_cmd(par, data); | 137 | broadsheet_gpio_issue_cmd(par, data); |
84 | par->board->set_ctl(par, BS_DC, 1); | 138 | par->board->set_ctl(par, BS_DC, 1); |
85 | par->board->set_ctl(par, BS_CS, 1); | 139 | par->board->set_ctl(par, BS_CS, 1); |
86 | } | 140 | } |
87 | 141 | ||
88 | static void broadsheet_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, | 142 | static void broadsheet_gpio_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, |
89 | int argc, u16 *argv) | 143 | int argc, u16 *argv) |
90 | { | 144 | { |
91 | int i; | 145 | int i; |
@@ -93,15 +147,43 @@ static void broadsheet_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, | |||
93 | par->board->wait_for_rdy(par); | 147 | par->board->wait_for_rdy(par); |
94 | 148 | ||
95 | par->board->set_ctl(par, BS_CS, 0); | 149 | par->board->set_ctl(par, BS_CS, 0); |
96 | broadsheet_issue_cmd(par, cmd); | 150 | broadsheet_gpio_issue_cmd(par, cmd); |
97 | par->board->set_ctl(par, BS_DC, 1); | 151 | par->board->set_ctl(par, BS_DC, 1); |
98 | 152 | ||
99 | for (i = 0; i < argc; i++) | 153 | for (i = 0; i < argc; i++) |
100 | broadsheet_issue_data(par, argv[i]); | 154 | broadsheet_gpio_issue_data(par, argv[i]); |
101 | par->board->set_ctl(par, BS_CS, 1); | 155 | par->board->set_ctl(par, BS_CS, 1); |
102 | } | 156 | } |
103 | 157 | ||
104 | static void broadsheet_burst_write(struct broadsheetfb_par *par, int size, | 158 | static void broadsheet_mmio_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, |
159 | int argc, u16 *argv) | ||
160 | { | ||
161 | int i; | ||
162 | |||
163 | par->board->mmio_write(par, BS_MMIO_CMD, cmd); | ||
164 | |||
165 | for (i = 0; i < argc; i++) | ||
166 | par->board->mmio_write(par, BS_MMIO_DATA, argv[i]); | ||
167 | } | ||
168 | |||
169 | static void broadsheet_send_command(struct broadsheetfb_par *par, u16 data) | ||
170 | { | ||
171 | if (par->board->mmio_write) | ||
172 | par->board->mmio_write(par, BS_MMIO_CMD, data); | ||
173 | else | ||
174 | broadsheet_gpio_send_command(par, data); | ||
175 | } | ||
176 | |||
177 | static void broadsheet_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, | ||
178 | int argc, u16 *argv) | ||
179 | { | ||
180 | if (par->board->mmio_write) | ||
181 | broadsheet_mmio_send_cmdargs(par, cmd, argc, argv); | ||
182 | else | ||
183 | broadsheet_gpio_send_cmdargs(par, cmd, argc, argv); | ||
184 | } | ||
185 | |||
186 | static void broadsheet_gpio_burst_write(struct broadsheetfb_par *par, int size, | ||
105 | u16 *data) | 187 | u16 *data) |
106 | { | 188 | { |
107 | int i; | 189 | int i; |
@@ -121,7 +203,30 @@ static void broadsheet_burst_write(struct broadsheetfb_par *par, int size, | |||
121 | par->board->set_ctl(par, BS_CS, 1); | 203 | par->board->set_ctl(par, BS_CS, 1); |
122 | } | 204 | } |
123 | 205 | ||
124 | static u16 broadsheet_get_data(struct broadsheetfb_par *par) | 206 | static void broadsheet_mmio_burst_write(struct broadsheetfb_par *par, int size, |
207 | u16 *data) | ||
208 | { | ||
209 | int i; | ||
210 | u16 tmp; | ||
211 | |||
212 | for (i = 0; i < size; i++) { | ||
213 | tmp = (data[i] & 0x0F) << 4; | ||
214 | tmp |= (data[i] & 0x0F00) << 4; | ||
215 | par->board->mmio_write(par, BS_MMIO_DATA, tmp); | ||
216 | } | ||
217 | |||
218 | } | ||
219 | |||
220 | static void broadsheet_burst_write(struct broadsheetfb_par *par, int size, | ||
221 | u16 *data) | ||
222 | { | ||
223 | if (par->board->mmio_write) | ||
224 | broadsheet_mmio_burst_write(par, size, data); | ||
225 | else | ||
226 | broadsheet_gpio_burst_write(par, size, data); | ||
227 | } | ||
228 | |||
229 | static u16 broadsheet_gpio_get_data(struct broadsheetfb_par *par) | ||
125 | { | 230 | { |
126 | u16 res; | 231 | u16 res; |
127 | /* wait for ready to go hi. (lo is busy) */ | 232 | /* wait for ready to go hi. (lo is busy) */ |
@@ -141,7 +246,16 @@ static u16 broadsheet_get_data(struct broadsheetfb_par *par) | |||
141 | return res; | 246 | return res; |
142 | } | 247 | } |
143 | 248 | ||
144 | static void broadsheet_write_reg(struct broadsheetfb_par *par, u16 reg, | 249 | |
250 | static u16 broadsheet_get_data(struct broadsheetfb_par *par) | ||
251 | { | ||
252 | if (par->board->mmio_read) | ||
253 | return par->board->mmio_read(par); | ||
254 | else | ||
255 | return broadsheet_gpio_get_data(par); | ||
256 | } | ||
257 | |||
258 | static void broadsheet_gpio_write_reg(struct broadsheetfb_par *par, u16 reg, | ||
145 | u16 data) | 259 | u16 data) |
146 | { | 260 | { |
147 | /* wait for ready to go hi. (lo is busy) */ | 261 | /* wait for ready to go hi. (lo is busy) */ |
@@ -150,44 +264,541 @@ static void broadsheet_write_reg(struct broadsheetfb_par *par, u16 reg, | |||
150 | /* cs lo, dc lo for cmd, we lo for each data, db as usual */ | 264 | /* cs lo, dc lo for cmd, we lo for each data, db as usual */ |
151 | par->board->set_ctl(par, BS_CS, 0); | 265 | par->board->set_ctl(par, BS_CS, 0); |
152 | 266 | ||
153 | broadsheet_issue_cmd(par, BS_CMD_WR_REG); | 267 | broadsheet_gpio_issue_cmd(par, BS_CMD_WR_REG); |
154 | 268 | ||
155 | par->board->set_ctl(par, BS_DC, 1); | 269 | par->board->set_ctl(par, BS_DC, 1); |
156 | 270 | ||
157 | broadsheet_issue_data(par, reg); | 271 | broadsheet_gpio_issue_data(par, reg); |
158 | broadsheet_issue_data(par, data); | 272 | broadsheet_gpio_issue_data(par, data); |
159 | 273 | ||
160 | par->board->set_ctl(par, BS_CS, 1); | 274 | par->board->set_ctl(par, BS_CS, 1); |
161 | } | 275 | } |
162 | 276 | ||
277 | static void broadsheet_mmio_write_reg(struct broadsheetfb_par *par, u16 reg, | ||
278 | u16 data) | ||
279 | { | ||
280 | par->board->mmio_write(par, BS_MMIO_CMD, BS_CMD_WR_REG); | ||
281 | par->board->mmio_write(par, BS_MMIO_DATA, reg); | ||
282 | par->board->mmio_write(par, BS_MMIO_DATA, data); | ||
283 | |||
284 | } | ||
285 | |||
286 | static void broadsheet_write_reg(struct broadsheetfb_par *par, u16 reg, | ||
287 | u16 data) | ||
288 | { | ||
289 | if (par->board->mmio_write) | ||
290 | broadsheet_mmio_write_reg(par, reg, data); | ||
291 | else | ||
292 | broadsheet_gpio_write_reg(par, reg, data); | ||
293 | } | ||
294 | |||
295 | static void broadsheet_write_reg32(struct broadsheetfb_par *par, u16 reg, | ||
296 | u32 data) | ||
297 | { | ||
298 | broadsheet_write_reg(par, reg, cpu_to_le32(data) & 0xFFFF); | ||
299 | broadsheet_write_reg(par, reg + 2, (cpu_to_le32(data) >> 16) & 0xFFFF); | ||
300 | } | ||
301 | |||
302 | |||
163 | static u16 broadsheet_read_reg(struct broadsheetfb_par *par, u16 reg) | 303 | static u16 broadsheet_read_reg(struct broadsheetfb_par *par, u16 reg) |
164 | { | 304 | { |
165 | broadsheet_send_command(par, reg); | 305 | broadsheet_send_cmdargs(par, BS_CMD_RD_REG, 1, ®); |
166 | msleep(100); | 306 | par->board->wait_for_rdy(par); |
167 | return broadsheet_get_data(par); | 307 | return broadsheet_get_data(par); |
168 | } | 308 | } |
169 | 309 | ||
310 | /* functions for waveform manipulation */ | ||
311 | static int is_broadsheet_pll_locked(struct broadsheetfb_par *par) | ||
312 | { | ||
313 | return broadsheet_read_reg(par, 0x000A) & 0x0001; | ||
314 | } | ||
315 | |||
316 | static int broadsheet_setup_plls(struct broadsheetfb_par *par) | ||
317 | { | ||
318 | int retry_count = 0; | ||
319 | u16 tmp; | ||
320 | |||
321 | /* disable arral saemipu mode */ | ||
322 | broadsheet_write_reg(par, 0x0006, 0x0000); | ||
323 | |||
324 | broadsheet_write_reg(par, 0x0010, 0x0004); | ||
325 | broadsheet_write_reg(par, 0x0012, 0x5949); | ||
326 | broadsheet_write_reg(par, 0x0014, 0x0040); | ||
327 | broadsheet_write_reg(par, 0x0016, 0x0000); | ||
328 | |||
329 | do { | ||
330 | if (retry_count++ > 100) | ||
331 | return -ETIMEDOUT; | ||
332 | mdelay(1); | ||
333 | } while (!is_broadsheet_pll_locked(par)); | ||
334 | |||
335 | tmp = broadsheet_read_reg(par, 0x0006); | ||
336 | tmp &= ~0x1; | ||
337 | broadsheet_write_reg(par, 0x0006, tmp); | ||
338 | |||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | static int broadsheet_setup_spi(struct broadsheetfb_par *par) | ||
343 | { | ||
344 | |||
345 | broadsheet_write_reg(par, 0x0204, ((3 << 3) | 1)); | ||
346 | broadsheet_write_reg(par, 0x0208, 0x0001); | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
351 | static int broadsheet_setup_spiflash(struct broadsheetfb_par *par, | ||
352 | u16 *orig_sfmcd) | ||
353 | { | ||
354 | |||
355 | *orig_sfmcd = broadsheet_read_reg(par, 0x0204); | ||
356 | broadsheet_write_reg(par, 0x0208, 0); | ||
357 | broadsheet_write_reg(par, 0x0204, 0); | ||
358 | broadsheet_write_reg(par, 0x0204, ((3 << 3) | 1)); | ||
359 | |||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | static int broadsheet_spiflash_wait_for_bit(struct broadsheetfb_par *par, | ||
364 | u16 reg, int bitnum, int val, | ||
365 | int timeout) | ||
366 | { | ||
367 | u16 tmp; | ||
368 | |||
369 | do { | ||
370 | tmp = broadsheet_read_reg(par, reg); | ||
371 | if (((tmp >> bitnum) & 1) == val) | ||
372 | return 0; | ||
373 | mdelay(1); | ||
374 | } while (timeout--); | ||
375 | |||
376 | return -ETIMEDOUT; | ||
377 | } | ||
378 | |||
379 | static int broadsheet_spiflash_write_byte(struct broadsheetfb_par *par, u8 data) | ||
380 | { | ||
381 | broadsheet_write_reg(par, 0x0202, (data | 0x100)); | ||
382 | |||
383 | return broadsheet_spiflash_wait_for_bit(par, 0x0206, 3, 0, 100); | ||
384 | } | ||
385 | |||
386 | static int broadsheet_spiflash_read_byte(struct broadsheetfb_par *par, u8 *data) | ||
387 | { | ||
388 | int err; | ||
389 | u16 tmp; | ||
390 | |||
391 | broadsheet_write_reg(par, 0x0202, 0); | ||
392 | |||
393 | err = broadsheet_spiflash_wait_for_bit(par, 0x0206, 3, 0, 100); | ||
394 | if (err) | ||
395 | return err; | ||
396 | |||
397 | tmp = broadsheet_read_reg(par, 0x200); | ||
398 | |||
399 | *data = tmp & 0xFF; | ||
400 | |||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | static int broadsheet_spiflash_wait_for_status(struct broadsheetfb_par *par, | ||
405 | int timeout) | ||
406 | { | ||
407 | u8 tmp; | ||
408 | int err; | ||
409 | |||
410 | do { | ||
411 | broadsheet_write_reg(par, 0x0208, 1); | ||
412 | |||
413 | err = broadsheet_spiflash_write_byte(par, 0x05); | ||
414 | if (err) | ||
415 | goto failout; | ||
416 | |||
417 | err = broadsheet_spiflash_read_byte(par, &tmp); | ||
418 | if (err) | ||
419 | goto failout; | ||
420 | |||
421 | broadsheet_write_reg(par, 0x0208, 0); | ||
422 | |||
423 | if (!(tmp & 0x1)) | ||
424 | return 0; | ||
425 | |||
426 | mdelay(5); | ||
427 | } while (timeout--); | ||
428 | |||
429 | dev_err(par->info->device, "Timed out waiting for spiflash status\n"); | ||
430 | return -ETIMEDOUT; | ||
431 | |||
432 | failout: | ||
433 | broadsheet_write_reg(par, 0x0208, 0); | ||
434 | return err; | ||
435 | } | ||
436 | |||
437 | static int broadsheet_spiflash_op_on_address(struct broadsheetfb_par *par, | ||
438 | u8 op, u32 addr) | ||
439 | { | ||
440 | int i; | ||
441 | u8 tmp; | ||
442 | int err; | ||
443 | |||
444 | broadsheet_write_reg(par, 0x0208, 1); | ||
445 | |||
446 | err = broadsheet_spiflash_write_byte(par, op); | ||
447 | if (err) | ||
448 | return err; | ||
449 | |||
450 | for (i = 2; i >= 0; i--) { | ||
451 | tmp = ((addr >> (i * 8)) & 0xFF); | ||
452 | err = broadsheet_spiflash_write_byte(par, tmp); | ||
453 | if (err) | ||
454 | return err; | ||
455 | } | ||
456 | |||
457 | return err; | ||
458 | } | ||
459 | |||
460 | static int broadsheet_verify_spiflash(struct broadsheetfb_par *par, | ||
461 | int *flash_type) | ||
462 | { | ||
463 | int err = 0; | ||
464 | u8 sig; | ||
465 | |||
466 | err = broadsheet_spiflash_op_on_address(par, 0xAB, 0x00000000); | ||
467 | if (err) | ||
468 | goto failout; | ||
469 | |||
470 | err = broadsheet_spiflash_read_byte(par, &sig); | ||
471 | if (err) | ||
472 | goto failout; | ||
473 | |||
474 | if ((sig != 0x10) && (sig != 0x11)) { | ||
475 | dev_err(par->info->device, "Unexpected flash type\n"); | ||
476 | err = -EINVAL; | ||
477 | goto failout; | ||
478 | } | ||
479 | |||
480 | *flash_type = sig; | ||
481 | |||
482 | failout: | ||
483 | broadsheet_write_reg(par, 0x0208, 0); | ||
484 | return err; | ||
485 | } | ||
486 | |||
487 | static int broadsheet_setup_for_wfm_write(struct broadsheetfb_par *par, | ||
488 | u16 *initial_sfmcd, int *flash_type) | ||
489 | |||
490 | { | ||
491 | int err; | ||
492 | |||
493 | err = broadsheet_setup_plls(par); | ||
494 | if (err) | ||
495 | return err; | ||
496 | |||
497 | broadsheet_write_reg(par, 0x0106, 0x0203); | ||
498 | |||
499 | err = broadsheet_setup_spi(par); | ||
500 | if (err) | ||
501 | return err; | ||
502 | |||
503 | err = broadsheet_setup_spiflash(par, initial_sfmcd); | ||
504 | if (err) | ||
505 | return err; | ||
506 | |||
507 | return broadsheet_verify_spiflash(par, flash_type); | ||
508 | } | ||
509 | |||
510 | static int broadsheet_spiflash_write_control(struct broadsheetfb_par *par, | ||
511 | int mode) | ||
512 | { | ||
513 | int err; | ||
514 | |||
515 | broadsheet_write_reg(par, 0x0208, 1); | ||
516 | if (mode) | ||
517 | err = broadsheet_spiflash_write_byte(par, 0x06); | ||
518 | else | ||
519 | err = broadsheet_spiflash_write_byte(par, 0x04); | ||
520 | |||
521 | broadsheet_write_reg(par, 0x0208, 0); | ||
522 | return err; | ||
523 | } | ||
524 | |||
525 | static int broadsheet_spiflash_erase_sector(struct broadsheetfb_par *par, | ||
526 | int addr) | ||
527 | { | ||
528 | int err; | ||
529 | |||
530 | broadsheet_spiflash_write_control(par, 1); | ||
531 | |||
532 | err = broadsheet_spiflash_op_on_address(par, 0xD8, addr); | ||
533 | |||
534 | broadsheet_write_reg(par, 0x0208, 0); | ||
535 | |||
536 | if (err) | ||
537 | return err; | ||
538 | |||
539 | err = broadsheet_spiflash_wait_for_status(par, 1000); | ||
540 | |||
541 | return err; | ||
542 | } | ||
543 | |||
544 | static int broadsheet_spiflash_read_range(struct broadsheetfb_par *par, | ||
545 | int addr, int size, char *data) | ||
546 | { | ||
547 | int err; | ||
548 | int i; | ||
549 | |||
550 | err = broadsheet_spiflash_op_on_address(par, 0x03, addr); | ||
551 | if (err) | ||
552 | goto failout; | ||
553 | |||
554 | for (i = 0; i < size; i++) { | ||
555 | err = broadsheet_spiflash_read_byte(par, &data[i]); | ||
556 | if (err) | ||
557 | goto failout; | ||
558 | } | ||
559 | |||
560 | failout: | ||
561 | broadsheet_write_reg(par, 0x0208, 0); | ||
562 | return err; | ||
563 | } | ||
564 | |||
565 | #define BS_SPIFLASH_PAGE_SIZE 256 | ||
566 | static int broadsheet_spiflash_write_page(struct broadsheetfb_par *par, | ||
567 | int addr, const char *data) | ||
568 | { | ||
569 | int err; | ||
570 | int i; | ||
571 | |||
572 | broadsheet_spiflash_write_control(par, 1); | ||
573 | |||
574 | err = broadsheet_spiflash_op_on_address(par, 0x02, addr); | ||
575 | if (err) | ||
576 | goto failout; | ||
577 | |||
578 | for (i = 0; i < BS_SPIFLASH_PAGE_SIZE; i++) { | ||
579 | err = broadsheet_spiflash_write_byte(par, data[i]); | ||
580 | if (err) | ||
581 | goto failout; | ||
582 | } | ||
583 | |||
584 | broadsheet_write_reg(par, 0x0208, 0); | ||
585 | |||
586 | err = broadsheet_spiflash_wait_for_status(par, 100); | ||
587 | |||
588 | failout: | ||
589 | return err; | ||
590 | } | ||
591 | |||
592 | static int broadsheet_spiflash_write_sector(struct broadsheetfb_par *par, | ||
593 | int addr, const char *data, int sector_size) | ||
594 | { | ||
595 | int i; | ||
596 | int err; | ||
597 | |||
598 | for (i = 0; i < sector_size; i += BS_SPIFLASH_PAGE_SIZE) { | ||
599 | err = broadsheet_spiflash_write_page(par, addr + i, &data[i]); | ||
600 | if (err) | ||
601 | return err; | ||
602 | } | ||
603 | return 0; | ||
604 | } | ||
605 | |||
606 | /* | ||
607 | * The caller must guarantee that the data to be rewritten is entirely | ||
608 | * contained within this sector. That is, data_start_addr + data_len | ||
609 | * must be less than sector_start_addr + sector_size. | ||
610 | */ | ||
611 | static int broadsheet_spiflash_rewrite_sector(struct broadsheetfb_par *par, | ||
612 | int sector_size, int data_start_addr, | ||
613 | int data_len, const char *data) | ||
614 | { | ||
615 | int err; | ||
616 | char *sector_buffer; | ||
617 | int tail_start_addr; | ||
618 | int start_sector_addr; | ||
619 | |||
620 | sector_buffer = kzalloc(sizeof(char)*sector_size, GFP_KERNEL); | ||
621 | if (!sector_buffer) | ||
622 | return -ENOMEM; | ||
623 | |||
624 | /* the start address of the sector is the 0th byte of that sector */ | ||
625 | start_sector_addr = (data_start_addr / sector_size) * sector_size; | ||
626 | |||
627 | /* | ||
628 | * check if there is head data that we need to readback into our sector | ||
629 | * buffer first | ||
630 | */ | ||
631 | if (data_start_addr != start_sector_addr) { | ||
632 | /* | ||
633 | * we need to read every byte up till the start address of our | ||
634 | * data and we put it into our sector buffer. | ||
635 | */ | ||
636 | err = broadsheet_spiflash_read_range(par, start_sector_addr, | ||
637 | data_start_addr, sector_buffer); | ||
638 | if (err) | ||
639 | return err; | ||
640 | } | ||
641 | |||
642 | /* now we copy our data into the right place in the sector buffer */ | ||
643 | memcpy(sector_buffer + data_start_addr, data, data_len); | ||
644 | |||
645 | /* | ||
646 | * now we check if there is a tail section of the sector that we need to | ||
647 | * readback. | ||
648 | */ | ||
649 | tail_start_addr = (data_start_addr + data_len) % sector_size; | ||
650 | |||
651 | if (tail_start_addr) { | ||
652 | int tail_len; | ||
653 | |||
654 | tail_len = sector_size - tail_start_addr; | ||
655 | |||
656 | /* now we read this tail into our sector buffer */ | ||
657 | err = broadsheet_spiflash_read_range(par, tail_start_addr, | ||
658 | tail_len, sector_buffer + tail_start_addr); | ||
659 | if (err) | ||
660 | return err; | ||
661 | } | ||
662 | |||
663 | /* if we got here we have the full sector that we want to rewrite. */ | ||
664 | |||
665 | /* first erase the sector */ | ||
666 | err = broadsheet_spiflash_erase_sector(par, start_sector_addr); | ||
667 | if (err) | ||
668 | return err; | ||
669 | |||
670 | /* now write it */ | ||
671 | err = broadsheet_spiflash_write_sector(par, start_sector_addr, | ||
672 | sector_buffer, sector_size); | ||
673 | return err; | ||
674 | } | ||
675 | |||
676 | static int broadsheet_write_spiflash(struct broadsheetfb_par *par, u32 wfm_addr, | ||
677 | const u8 *wfm, int bytecount, int flash_type) | ||
678 | { | ||
679 | int sector_size; | ||
680 | int err; | ||
681 | int cur_addr; | ||
682 | int writecount; | ||
683 | int maxlen; | ||
684 | int offset = 0; | ||
685 | |||
686 | switch (flash_type) { | ||
687 | case 0x10: | ||
688 | sector_size = 32*1024; | ||
689 | break; | ||
690 | case 0x11: | ||
691 | default: | ||
692 | sector_size = 64*1024; | ||
693 | break; | ||
694 | } | ||
695 | |||
696 | while (bytecount) { | ||
697 | cur_addr = wfm_addr + offset; | ||
698 | maxlen = roundup(cur_addr, sector_size) - cur_addr; | ||
699 | writecount = min(bytecount, maxlen); | ||
700 | |||
701 | err = broadsheet_spiflash_rewrite_sector(par, sector_size, | ||
702 | cur_addr, writecount, wfm + offset); | ||
703 | if (err) | ||
704 | return err; | ||
705 | |||
706 | offset += writecount; | ||
707 | bytecount -= writecount; | ||
708 | } | ||
709 | |||
710 | return 0; | ||
711 | } | ||
712 | |||
713 | static int broadsheet_store_waveform_to_spiflash(struct broadsheetfb_par *par, | ||
714 | const u8 *wfm, size_t wfm_size) | ||
715 | { | ||
716 | int err = 0; | ||
717 | u16 initial_sfmcd = 0; | ||
718 | int flash_type = 0; | ||
719 | |||
720 | err = broadsheet_setup_for_wfm_write(par, &initial_sfmcd, &flash_type); | ||
721 | if (err) | ||
722 | goto failout; | ||
723 | |||
724 | err = broadsheet_write_spiflash(par, 0x886, wfm, wfm_size, flash_type); | ||
725 | |||
726 | failout: | ||
727 | broadsheet_write_reg(par, 0x0204, initial_sfmcd); | ||
728 | return err; | ||
729 | } | ||
730 | |||
731 | static ssize_t broadsheet_loadstore_waveform(struct device *dev, | ||
732 | struct device_attribute *attr, | ||
733 | const char *buf, size_t len) | ||
734 | { | ||
735 | int err; | ||
736 | struct fb_info *info = dev_get_drvdata(dev); | ||
737 | struct broadsheetfb_par *par = info->par; | ||
738 | const struct firmware *fw_entry; | ||
739 | |||
740 | if (len < 1) | ||
741 | return -EINVAL; | ||
742 | |||
743 | err = request_firmware(&fw_entry, "broadsheet.wbf", dev); | ||
744 | if (err < 0) { | ||
745 | dev_err(dev, "Failed to get broadsheet waveform\n"); | ||
746 | goto err_failed; | ||
747 | } | ||
748 | |||
749 | /* try to enforce reasonable min max on waveform */ | ||
750 | if ((fw_entry->size < 8*1024) || (fw_entry->size > 64*1024)) { | ||
751 | dev_err(dev, "Invalid waveform\n"); | ||
752 | err = -EINVAL; | ||
753 | goto err_failed; | ||
754 | } | ||
755 | |||
756 | mutex_lock(&(par->io_lock)); | ||
757 | err = broadsheet_store_waveform_to_spiflash(par, fw_entry->data, | ||
758 | fw_entry->size); | ||
759 | |||
760 | mutex_unlock(&(par->io_lock)); | ||
761 | if (err < 0) { | ||
762 | dev_err(dev, "Failed to store broadsheet waveform\n"); | ||
763 | goto err_failed; | ||
764 | } | ||
765 | |||
766 | dev_info(dev, "Stored broadsheet waveform, size %zd\n", fw_entry->size); | ||
767 | |||
768 | return len; | ||
769 | |||
770 | err_failed: | ||
771 | return err; | ||
772 | } | ||
773 | static DEVICE_ATTR(loadstore_waveform, S_IWUSR, NULL, | ||
774 | broadsheet_loadstore_waveform); | ||
775 | |||
776 | /* upper level functions that manipulate the display and other stuff */ | ||
170 | static void __devinit broadsheet_init_display(struct broadsheetfb_par *par) | 777 | static void __devinit broadsheet_init_display(struct broadsheetfb_par *par) |
171 | { | 778 | { |
172 | u16 args[5]; | 779 | u16 args[5]; |
173 | 780 | int xres = par->info->var.xres; | |
174 | args[0] = DPY_W; | 781 | int yres = par->info->var.yres; |
175 | args[1] = DPY_H; | 782 | |
176 | args[2] = (100 | (1 << 8) | (1 << 9)); /* sdcfg */ | 783 | args[0] = panel_table[par->panel_index].w; |
177 | args[3] = 2; /* gdrv cfg */ | 784 | args[1] = panel_table[par->panel_index].h; |
178 | args[4] = (4 | (1 << 7)); /* lut index format */ | 785 | args[2] = panel_table[par->panel_index].sdcfg; |
786 | args[3] = panel_table[par->panel_index].gdcfg; | ||
787 | args[4] = panel_table[par->panel_index].lutfmt; | ||
179 | broadsheet_send_cmdargs(par, BS_CMD_INIT_DSPE_CFG, 5, args); | 788 | broadsheet_send_cmdargs(par, BS_CMD_INIT_DSPE_CFG, 5, args); |
180 | 789 | ||
181 | /* did the controller really set it? */ | 790 | /* did the controller really set it? */ |
182 | broadsheet_send_cmdargs(par, BS_CMD_INIT_DSPE_CFG, 5, args); | 791 | broadsheet_send_cmdargs(par, BS_CMD_INIT_DSPE_CFG, 5, args); |
183 | 792 | ||
184 | args[0] = 4; /* fsync len */ | 793 | args[0] = panel_table[par->panel_index].fsynclen; |
185 | args[1] = (10 << 8) | 4; /* fend/fbegin len */ | 794 | args[1] = panel_table[par->panel_index].fendfbegin; |
186 | args[2] = 10; /* line sync len */ | 795 | args[2] = panel_table[par->panel_index].lsynclen; |
187 | args[3] = (100 << 8) | 4; /* line end/begin len */ | 796 | args[3] = panel_table[par->panel_index].lendlbegin; |
188 | args[4] = 6; /* pixel clock cfg */ | 797 | args[4] = panel_table[par->panel_index].pixclk; |
189 | broadsheet_send_cmdargs(par, BS_CMD_INIT_DSPE_TMG, 5, args); | 798 | broadsheet_send_cmdargs(par, BS_CMD_INIT_DSPE_TMG, 5, args); |
190 | 799 | ||
800 | broadsheet_write_reg32(par, 0x310, xres*yres*2); | ||
801 | |||
191 | /* setup waveform */ | 802 | /* setup waveform */ |
192 | args[0] = 0x886; | 803 | args[0] = 0x886; |
193 | args[1] = 0; | 804 | args[1] = 0; |
@@ -207,8 +818,9 @@ static void __devinit broadsheet_init_display(struct broadsheetfb_par *par) | |||
207 | args[0] = 0x154; | 818 | args[0] = 0x154; |
208 | broadsheet_send_cmdargs(par, BS_CMD_WR_REG, 1, args); | 819 | broadsheet_send_cmdargs(par, BS_CMD_WR_REG, 1, args); |
209 | 820 | ||
210 | broadsheet_burst_write(par, DPY_W*DPY_H/2, | 821 | broadsheet_burst_write(par, (panel_table[par->panel_index].w * |
211 | (u16 *) par->info->screen_base); | 822 | panel_table[par->panel_index].h)/2, |
823 | (u16 *) par->info->screen_base); | ||
212 | 824 | ||
213 | broadsheet_send_command(par, BS_CMD_LD_IMG_END); | 825 | broadsheet_send_command(par, BS_CMD_LD_IMG_END); |
214 | 826 | ||
@@ -222,6 +834,21 @@ static void __devinit broadsheet_init_display(struct broadsheetfb_par *par) | |||
222 | par->board->wait_for_rdy(par); | 834 | par->board->wait_for_rdy(par); |
223 | } | 835 | } |
224 | 836 | ||
837 | static void __devinit broadsheet_identify(struct broadsheetfb_par *par) | ||
838 | { | ||
839 | u16 rev, prc; | ||
840 | struct device *dev = par->info->device; | ||
841 | |||
842 | rev = broadsheet_read_reg(par, BS_REG_REV); | ||
843 | prc = broadsheet_read_reg(par, BS_REG_PRC); | ||
844 | dev_info(dev, "Broadsheet Rev 0x%x, Product Code 0x%x\n", rev, prc); | ||
845 | |||
846 | if (prc != 0x0047) | ||
847 | dev_warn(dev, "Unrecognized Broadsheet Product Code\n"); | ||
848 | if (rev != 0x0100) | ||
849 | dev_warn(dev, "Unrecognized Broadsheet Revision\n"); | ||
850 | } | ||
851 | |||
225 | static void __devinit broadsheet_init(struct broadsheetfb_par *par) | 852 | static void __devinit broadsheet_init(struct broadsheetfb_par *par) |
226 | { | 853 | { |
227 | broadsheet_send_command(par, BS_CMD_INIT_SYS_RUN); | 854 | broadsheet_send_command(par, BS_CMD_INIT_SYS_RUN); |
@@ -236,6 +863,7 @@ static void broadsheetfb_dpy_update_pages(struct broadsheetfb_par *par, | |||
236 | u16 args[5]; | 863 | u16 args[5]; |
237 | unsigned char *buf = (unsigned char *)par->info->screen_base; | 864 | unsigned char *buf = (unsigned char *)par->info->screen_base; |
238 | 865 | ||
866 | mutex_lock(&(par->io_lock)); | ||
239 | /* y1 must be a multiple of 4 so drop the lower bits */ | 867 | /* y1 must be a multiple of 4 so drop the lower bits */ |
240 | y1 &= 0xFFFC; | 868 | y1 &= 0xFFFC; |
241 | /* y2 must be a multiple of 4 , but - 1 so up the lower bits */ | 869 | /* y2 must be a multiple of 4 , but - 1 so up the lower bits */ |
@@ -265,6 +893,7 @@ static void broadsheetfb_dpy_update_pages(struct broadsheetfb_par *par, | |||
265 | broadsheet_send_command(par, BS_CMD_WAIT_DSPE_FREND); | 893 | broadsheet_send_command(par, BS_CMD_WAIT_DSPE_FREND); |
266 | 894 | ||
267 | par->board->wait_for_rdy(par); | 895 | par->board->wait_for_rdy(par); |
896 | mutex_unlock(&(par->io_lock)); | ||
268 | 897 | ||
269 | } | 898 | } |
270 | 899 | ||
@@ -272,13 +901,15 @@ static void broadsheetfb_dpy_update(struct broadsheetfb_par *par) | |||
272 | { | 901 | { |
273 | u16 args[5]; | 902 | u16 args[5]; |
274 | 903 | ||
904 | mutex_lock(&(par->io_lock)); | ||
275 | args[0] = 0x3 << 4; | 905 | args[0] = 0x3 << 4; |
276 | broadsheet_send_cmdargs(par, BS_CMD_LD_IMG, 1, args); | 906 | broadsheet_send_cmdargs(par, BS_CMD_LD_IMG, 1, args); |
277 | 907 | ||
278 | args[0] = 0x154; | 908 | args[0] = 0x154; |
279 | broadsheet_send_cmdargs(par, BS_CMD_WR_REG, 1, args); | 909 | broadsheet_send_cmdargs(par, BS_CMD_WR_REG, 1, args); |
280 | broadsheet_burst_write(par, DPY_W*DPY_H/2, | 910 | broadsheet_burst_write(par, (panel_table[par->panel_index].w * |
281 | (u16 *) par->info->screen_base); | 911 | panel_table[par->panel_index].h)/2, |
912 | (u16 *) par->info->screen_base); | ||
282 | 913 | ||
283 | broadsheet_send_command(par, BS_CMD_LD_IMG_END); | 914 | broadsheet_send_command(par, BS_CMD_LD_IMG_END); |
284 | 915 | ||
@@ -290,7 +921,7 @@ static void broadsheetfb_dpy_update(struct broadsheetfb_par *par) | |||
290 | broadsheet_send_command(par, BS_CMD_WAIT_DSPE_FREND); | 921 | broadsheet_send_command(par, BS_CMD_WAIT_DSPE_FREND); |
291 | 922 | ||
292 | par->board->wait_for_rdy(par); | 923 | par->board->wait_for_rdy(par); |
293 | 924 | mutex_unlock(&(par->io_lock)); | |
294 | } | 925 | } |
295 | 926 | ||
296 | /* this is called back from the deferred io workqueue */ | 927 | /* this is called back from the deferred io workqueue */ |
@@ -436,6 +1067,8 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev) | |||
436 | unsigned char *videomemory; | 1067 | unsigned char *videomemory; |
437 | struct broadsheetfb_par *par; | 1068 | struct broadsheetfb_par *par; |
438 | int i; | 1069 | int i; |
1070 | int dpyw, dpyh; | ||
1071 | int panel_index; | ||
439 | 1072 | ||
440 | /* pick up board specific routines */ | 1073 | /* pick up board specific routines */ |
441 | board = dev->dev.platform_data; | 1074 | board = dev->dev.platform_data; |
@@ -450,7 +1083,24 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev) | |||
450 | if (!info) | 1083 | if (!info) |
451 | goto err; | 1084 | goto err; |
452 | 1085 | ||
453 | videomemorysize = (DPY_W*DPY_H); | 1086 | switch (board->get_panel_type()) { |
1087 | case 37: | ||
1088 | panel_index = 1; | ||
1089 | break; | ||
1090 | case 97: | ||
1091 | panel_index = 2; | ||
1092 | break; | ||
1093 | case 6: | ||
1094 | default: | ||
1095 | panel_index = 0; | ||
1096 | break; | ||
1097 | } | ||
1098 | |||
1099 | dpyw = panel_table[panel_index].w; | ||
1100 | dpyh = panel_table[panel_index].h; | ||
1101 | |||
1102 | videomemorysize = roundup((dpyw*dpyh), PAGE_SIZE); | ||
1103 | |||
454 | videomemory = vmalloc(videomemorysize); | 1104 | videomemory = vmalloc(videomemorysize); |
455 | if (!videomemory) | 1105 | if (!videomemory) |
456 | goto err_fb_rel; | 1106 | goto err_fb_rel; |
@@ -460,16 +1110,25 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev) | |||
460 | info->screen_base = (char *)videomemory; | 1110 | info->screen_base = (char *)videomemory; |
461 | info->fbops = &broadsheetfb_ops; | 1111 | info->fbops = &broadsheetfb_ops; |
462 | 1112 | ||
1113 | broadsheetfb_var.xres = dpyw; | ||
1114 | broadsheetfb_var.yres = dpyh; | ||
1115 | broadsheetfb_var.xres_virtual = dpyw; | ||
1116 | broadsheetfb_var.yres_virtual = dpyh; | ||
463 | info->var = broadsheetfb_var; | 1117 | info->var = broadsheetfb_var; |
1118 | |||
1119 | broadsheetfb_fix.line_length = dpyw; | ||
464 | info->fix = broadsheetfb_fix; | 1120 | info->fix = broadsheetfb_fix; |
465 | info->fix.smem_len = videomemorysize; | 1121 | info->fix.smem_len = videomemorysize; |
466 | par = info->par; | 1122 | par = info->par; |
1123 | par->panel_index = panel_index; | ||
467 | par->info = info; | 1124 | par->info = info; |
468 | par->board = board; | 1125 | par->board = board; |
469 | par->write_reg = broadsheet_write_reg; | 1126 | par->write_reg = broadsheet_write_reg; |
470 | par->read_reg = broadsheet_read_reg; | 1127 | par->read_reg = broadsheet_read_reg; |
471 | init_waitqueue_head(&par->waitq); | 1128 | init_waitqueue_head(&par->waitq); |
472 | 1129 | ||
1130 | mutex_init(&par->io_lock); | ||
1131 | |||
473 | info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB; | 1132 | info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB; |
474 | 1133 | ||
475 | info->fbdefio = &broadsheetfb_defio; | 1134 | info->fbdefio = &broadsheetfb_defio; |
@@ -496,13 +1155,20 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev) | |||
496 | if (retval < 0) | 1155 | if (retval < 0) |
497 | goto err_free_irq; | 1156 | goto err_free_irq; |
498 | 1157 | ||
1158 | broadsheet_identify(par); | ||
1159 | |||
499 | broadsheet_init(par); | 1160 | broadsheet_init(par); |
500 | 1161 | ||
501 | retval = register_framebuffer(info); | 1162 | retval = register_framebuffer(info); |
502 | if (retval < 0) | 1163 | if (retval < 0) |
503 | goto err_free_irq; | 1164 | goto err_free_irq; |
1165 | |||
504 | platform_set_drvdata(dev, info); | 1166 | platform_set_drvdata(dev, info); |
505 | 1167 | ||
1168 | retval = device_create_file(&dev->dev, &dev_attr_loadstore_waveform); | ||
1169 | if (retval < 0) | ||
1170 | goto err_unreg_fb; | ||
1171 | |||
506 | printk(KERN_INFO | 1172 | printk(KERN_INFO |
507 | "fb%d: Broadsheet frame buffer, using %dK of video memory\n", | 1173 | "fb%d: Broadsheet frame buffer, using %dK of video memory\n", |
508 | info->node, videomemorysize >> 10); | 1174 | info->node, videomemorysize >> 10); |
@@ -510,6 +1176,8 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev) | |||
510 | 1176 | ||
511 | return 0; | 1177 | return 0; |
512 | 1178 | ||
1179 | err_unreg_fb: | ||
1180 | unregister_framebuffer(info); | ||
513 | err_free_irq: | 1181 | err_free_irq: |
514 | board->cleanup(par); | 1182 | board->cleanup(par); |
515 | err_cmap: | 1183 | err_cmap: |
@@ -530,6 +1198,8 @@ static int __devexit broadsheetfb_remove(struct platform_device *dev) | |||
530 | 1198 | ||
531 | if (info) { | 1199 | if (info) { |
532 | struct broadsheetfb_par *par = info->par; | 1200 | struct broadsheetfb_par *par = info->par; |
1201 | |||
1202 | device_remove_file(info->dev, &dev_attr_loadstore_waveform); | ||
533 | unregister_framebuffer(info); | 1203 | unregister_framebuffer(info); |
534 | fb_deferred_io_cleanup(info); | 1204 | fb_deferred_io_cleanup(info); |
535 | par->board->cleanup(par); | 1205 | par->board->cleanup(par); |
diff --git a/drivers/video/cobalt_lcdfb.c b/drivers/video/cobalt_lcdfb.c index 108b89e09a80..5eb61b5adfe8 100644 --- a/drivers/video/cobalt_lcdfb.c +++ b/drivers/video/cobalt_lcdfb.c | |||
@@ -287,7 +287,7 @@ static struct fb_ops cobalt_lcd_fbops = { | |||
287 | .fb_cursor = cobalt_lcdfb_cursor, | 287 | .fb_cursor = cobalt_lcdfb_cursor, |
288 | }; | 288 | }; |
289 | 289 | ||
290 | static int __init cobalt_lcdfb_probe(struct platform_device *dev) | 290 | static int __devinit cobalt_lcdfb_probe(struct platform_device *dev) |
291 | { | 291 | { |
292 | struct fb_info *info; | 292 | struct fb_info *info; |
293 | struct resource *res; | 293 | struct resource *res; |
diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c index d25df51bb0d2..581d2dbf675a 100644 --- a/drivers/video/efifb.c +++ b/drivers/video/efifb.c | |||
@@ -210,7 +210,7 @@ static int __init efifb_setup(char *options) | |||
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | static int __init efifb_probe(struct platform_device *dev) | 213 | static int __devinit efifb_probe(struct platform_device *dev) |
214 | { | 214 | { |
215 | struct fb_info *info; | 215 | struct fb_info *info; |
216 | int err; | 216 | int err; |
diff --git a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c index 2735b79e52a1..6d755bb3a2bc 100644 --- a/drivers/video/epson1355fb.c +++ b/drivers/video/epson1355fb.c | |||
@@ -602,7 +602,7 @@ static int epson1355fb_remove(struct platform_device *dev) | |||
602 | return 0; | 602 | return 0; |
603 | } | 603 | } |
604 | 604 | ||
605 | int __init epson1355fb_probe(struct platform_device *dev) | 605 | int __devinit epson1355fb_probe(struct platform_device *dev) |
606 | { | 606 | { |
607 | struct epson1355_par *default_par; | 607 | struct epson1355_par *default_par; |
608 | struct fb_info *info; | 608 | struct fb_info *info; |
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c index 695fa013fe7e..5643a35c1746 100644 --- a/drivers/video/gbefb.c +++ b/drivers/video/gbefb.c | |||
@@ -1128,7 +1128,7 @@ static int __init gbefb_setup(char *options) | |||
1128 | return 0; | 1128 | return 0; |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | static int __init gbefb_probe(struct platform_device *p_dev) | 1131 | static int __devinit gbefb_probe(struct platform_device *p_dev) |
1132 | { | 1132 | { |
1133 | int i, ret = 0; | 1133 | int i, ret = 0; |
1134 | struct fb_info *info; | 1134 | struct fb_info *info; |
diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c index 0129c044f6d6..db9b785b56eb 100644 --- a/drivers/video/hgafb.c +++ b/drivers/video/hgafb.c | |||
@@ -551,7 +551,7 @@ static struct fb_ops hgafb_ops = { | |||
551 | * Initialization | 551 | * Initialization |
552 | */ | 552 | */ |
553 | 553 | ||
554 | static int __init hgafb_probe(struct platform_device *pdev) | 554 | static int __devinit hgafb_probe(struct platform_device *pdev) |
555 | { | 555 | { |
556 | struct fb_info *info; | 556 | struct fb_info *info; |
557 | 557 | ||
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c index 73c83a8de2d3..bf78779199c6 100644 --- a/drivers/video/hitfb.c +++ b/drivers/video/hitfb.c | |||
@@ -325,7 +325,7 @@ static struct fb_ops hitfb_ops = { | |||
325 | .fb_imageblit = cfb_imageblit, | 325 | .fb_imageblit = cfb_imageblit, |
326 | }; | 326 | }; |
327 | 327 | ||
328 | static int __init hitfb_probe(struct platform_device *dev) | 328 | static int __devinit hitfb_probe(struct platform_device *dev) |
329 | { | 329 | { |
330 | unsigned short lcdclor, ldr3, ldvndr; | 330 | unsigned short lcdclor, ldr3, ldvndr; |
331 | struct fb_info *info; | 331 | struct fb_info *info; |
diff --git a/drivers/video/mb862xx/mb862xxfb.c b/drivers/video/mb862xx/mb862xxfb.c index fabb0c59a211..8280a58a0e55 100644 --- a/drivers/video/mb862xx/mb862xxfb.c +++ b/drivers/video/mb862xx/mb862xxfb.c | |||
@@ -31,15 +31,6 @@ | |||
31 | #define CARMINE_MEM_SIZE 0x8000000 | 31 | #define CARMINE_MEM_SIZE 0x8000000 |
32 | #define DRV_NAME "mb862xxfb" | 32 | #define DRV_NAME "mb862xxfb" |
33 | 33 | ||
34 | #if defined(CONFIG_LWMON5) | ||
35 | static struct mb862xx_gc_mode lwmon5_gc_mode = { | ||
36 | /* Mode for Sharp LQ104V1DG61 TFT LCD Panel */ | ||
37 | { "640x480", 60, 640, 480, 40000, 48, 16, 32, 11, 96, 2, 0, 0, 0 }, | ||
38 | /* 16 bits/pixel, 32MB, 100MHz, SDRAM memory mode value */ | ||
39 | 16, 0x2000000, GC_CCF_COT_100, 0x414fb7f2 | ||
40 | }; | ||
41 | #endif | ||
42 | |||
43 | #if defined(CONFIG_SOCRATES) | 34 | #if defined(CONFIG_SOCRATES) |
44 | static struct mb862xx_gc_mode socrates_gc_mode = { | 35 | static struct mb862xx_gc_mode socrates_gc_mode = { |
45 | /* Mode for Prime View PM070WL4 TFT LCD Panel */ | 36 | /* Mode for Prime View PM070WL4 TFT LCD Panel */ |
@@ -600,10 +591,6 @@ static int __devinit of_platform_mb862xx_probe(struct of_device *ofdev, | |||
600 | goto irqdisp; | 591 | goto irqdisp; |
601 | } | 592 | } |
602 | 593 | ||
603 | #if defined(CONFIG_LWMON5) | ||
604 | par->gc_mode = &lwmon5_gc_mode; | ||
605 | #endif | ||
606 | |||
607 | #if defined(CONFIG_SOCRATES) | 594 | #if defined(CONFIG_SOCRATES) |
608 | par->gc_mode = &socrates_gc_mode; | 595 | par->gc_mode = &socrates_gc_mode; |
609 | #endif | 596 | #endif |
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index 0129f1bc3522..b895aae41630 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c | |||
@@ -893,7 +893,7 @@ const struct fb_videomode *fb_match_mode(const struct fb_var_screeninfo *var, | |||
893 | } | 893 | } |
894 | 894 | ||
895 | /** | 895 | /** |
896 | * fb_add_videomode: adds videomode entry to modelist | 896 | * fb_add_videomode - adds videomode entry to modelist |
897 | * @mode: videomode to add | 897 | * @mode: videomode to add |
898 | * @head: struct list_head of modelist | 898 | * @head: struct list_head of modelist |
899 | * | 899 | * |
@@ -928,7 +928,7 @@ int fb_add_videomode(const struct fb_videomode *mode, struct list_head *head) | |||
928 | } | 928 | } |
929 | 929 | ||
930 | /** | 930 | /** |
931 | * fb_delete_videomode: removed videomode entry from modelist | 931 | * fb_delete_videomode - removed videomode entry from modelist |
932 | * @mode: videomode to remove | 932 | * @mode: videomode to remove |
933 | * @head: struct list_head of modelist | 933 | * @head: struct list_head of modelist |
934 | * | 934 | * |
@@ -953,7 +953,7 @@ void fb_delete_videomode(const struct fb_videomode *mode, | |||
953 | } | 953 | } |
954 | 954 | ||
955 | /** | 955 | /** |
956 | * fb_destroy_modelist: destroy modelist | 956 | * fb_destroy_modelist - destroy modelist |
957 | * @head: struct list_head of modelist | 957 | * @head: struct list_head of modelist |
958 | */ | 958 | */ |
959 | void fb_destroy_modelist(struct list_head *head) | 959 | void fb_destroy_modelist(struct list_head *head) |
@@ -968,7 +968,7 @@ void fb_destroy_modelist(struct list_head *head) | |||
968 | EXPORT_SYMBOL_GPL(fb_destroy_modelist); | 968 | EXPORT_SYMBOL_GPL(fb_destroy_modelist); |
969 | 969 | ||
970 | /** | 970 | /** |
971 | * fb_videomode_to_modelist: convert mode array to mode list | 971 | * fb_videomode_to_modelist - convert mode array to mode list |
972 | * @modedb: array of struct fb_videomode | 972 | * @modedb: array of struct fb_videomode |
973 | * @num: number of entries in array | 973 | * @num: number of entries in array |
974 | * @head: struct list_head of modelist | 974 | * @head: struct list_head of modelist |
diff --git a/drivers/video/nuc900fb.c b/drivers/video/nuc900fb.c new file mode 100644 index 000000000000..6bf0d460a738 --- /dev/null +++ b/drivers/video/nuc900fb.c | |||
@@ -0,0 +1,779 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (c) 2009 Nuvoton technology corporation | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * Description: | ||
12 | * Nuvoton LCD Controller Driver | ||
13 | * Author: | ||
14 | * Wang Qiang (rurality.linux@gmail.com) 2009/12/11 | ||
15 | */ | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/string.h> | ||
20 | #include <linux/mm.h> | ||
21 | #include <linux/tty.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/fb.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/dma-mapping.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/workqueue.h> | ||
29 | #include <linux/wait.h> | ||
30 | #include <linux/platform_device.h> | ||
31 | #include <linux/clk.h> | ||
32 | #include <linux/cpufreq.h> | ||
33 | #include <linux/io.h> | ||
34 | #include <linux/pm.h> | ||
35 | #include <linux/device.h> | ||
36 | |||
37 | #include <mach/map.h> | ||
38 | #include <mach/regs-clock.h> | ||
39 | #include <mach/regs-ldm.h> | ||
40 | #include <mach/fb.h> | ||
41 | #include <mach/clkdev.h> | ||
42 | |||
43 | #include "nuc900fb.h" | ||
44 | |||
45 | |||
46 | /* | ||
47 | * Initialize the nuc900 video (dual) buffer address | ||
48 | */ | ||
49 | static void nuc900fb_set_lcdaddr(struct fb_info *info) | ||
50 | { | ||
51 | struct nuc900fb_info *fbi = info->par; | ||
52 | void __iomem *regs = fbi->io; | ||
53 | unsigned long vbaddr1, vbaddr2; | ||
54 | |||
55 | vbaddr1 = info->fix.smem_start; | ||
56 | vbaddr2 = info->fix.smem_start; | ||
57 | vbaddr2 += info->fix.line_length * info->var.yres; | ||
58 | |||
59 | /* set frambuffer start phy addr*/ | ||
60 | writel(vbaddr1, regs + REG_LCM_VA_BADDR0); | ||
61 | writel(vbaddr2, regs + REG_LCM_VA_BADDR1); | ||
62 | |||
63 | writel(fbi->regs.lcd_va_fbctrl, regs + REG_LCM_VA_FBCTRL); | ||
64 | writel(fbi->regs.lcd_va_scale, regs + REG_LCM_VA_SCALE); | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * calculate divider for lcd div | ||
69 | */ | ||
70 | static unsigned int nuc900fb_calc_pixclk(struct nuc900fb_info *fbi, | ||
71 | unsigned long pixclk) | ||
72 | { | ||
73 | unsigned long clk = fbi->clk_rate; | ||
74 | unsigned long long div; | ||
75 | |||
76 | /* pixclk is in picseconds. our clock is in Hz*/ | ||
77 | /* div = (clk * pixclk)/10^12 */ | ||
78 | div = (unsigned long long)clk * pixclk; | ||
79 | div >>= 12; | ||
80 | do_div(div, 625 * 625UL * 625); | ||
81 | |||
82 | dev_dbg(fbi->dev, "pixclk %ld, divisor is %lld\n", pixclk, div); | ||
83 | |||
84 | return div; | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * Check the video params of 'var'. | ||
89 | */ | ||
90 | static int nuc900fb_check_var(struct fb_var_screeninfo *var, | ||
91 | struct fb_info *info) | ||
92 | { | ||
93 | struct nuc900fb_info *fbi = info->par; | ||
94 | struct nuc900fb_mach_info *mach_info = fbi->dev->platform_data; | ||
95 | struct nuc900fb_display *display = NULL; | ||
96 | struct nuc900fb_display *default_display = mach_info->displays + | ||
97 | mach_info->default_display; | ||
98 | int i; | ||
99 | |||
100 | dev_dbg(fbi->dev, "check_var(var=%p, info=%p)\n", var, info); | ||
101 | |||
102 | /* validate x/y resolution */ | ||
103 | /* choose default mode if possible */ | ||
104 | if (var->xres == default_display->xres && | ||
105 | var->yres == default_display->yres && | ||
106 | var->bits_per_pixel == default_display->bpp) | ||
107 | display = default_display; | ||
108 | else | ||
109 | for (i = 0; i < mach_info->num_displays; i++) | ||
110 | if (var->xres == mach_info->displays[i].xres && | ||
111 | var->yres == mach_info->displays[i].yres && | ||
112 | var->bits_per_pixel == mach_info->displays[i].bpp) { | ||
113 | display = mach_info->displays + i; | ||
114 | break; | ||
115 | } | ||
116 | |||
117 | if (display == NULL) { | ||
118 | printk(KERN_ERR "wrong resolution or depth %dx%d at %d bit per pixel\n", | ||
119 | var->xres, var->yres, var->bits_per_pixel); | ||
120 | return -EINVAL; | ||
121 | } | ||
122 | |||
123 | /* it should be the same size as the display */ | ||
124 | var->xres_virtual = display->xres; | ||
125 | var->yres_virtual = display->yres; | ||
126 | var->height = display->height; | ||
127 | var->width = display->width; | ||
128 | |||
129 | /* copy lcd settings */ | ||
130 | var->pixclock = display->pixclock; | ||
131 | var->left_margin = display->left_margin; | ||
132 | var->right_margin = display->right_margin; | ||
133 | var->upper_margin = display->upper_margin; | ||
134 | var->lower_margin = display->lower_margin; | ||
135 | var->vsync_len = display->vsync_len; | ||
136 | var->hsync_len = display->hsync_len; | ||
137 | |||
138 | var->transp.offset = 0; | ||
139 | var->transp.length = 0; | ||
140 | |||
141 | fbi->regs.lcd_dccs = display->dccs; | ||
142 | fbi->regs.lcd_device_ctrl = display->devctl; | ||
143 | fbi->regs.lcd_va_fbctrl = display->fbctrl; | ||
144 | fbi->regs.lcd_va_scale = display->scale; | ||
145 | |||
146 | /* set R/G/B possions */ | ||
147 | switch (var->bits_per_pixel) { | ||
148 | case 1: | ||
149 | case 2: | ||
150 | case 4: | ||
151 | case 8: | ||
152 | default: | ||
153 | var->red.offset = 0; | ||
154 | var->red.length = var->bits_per_pixel; | ||
155 | var->green = var->red; | ||
156 | var->blue = var->red; | ||
157 | break; | ||
158 | case 12: | ||
159 | var->red.length = 4; | ||
160 | var->green.length = 4; | ||
161 | var->blue.length = 4; | ||
162 | var->red.offset = 8; | ||
163 | var->green.offset = 4; | ||
164 | var->blue.offset = 0; | ||
165 | break; | ||
166 | case 16: | ||
167 | var->red.length = 5; | ||
168 | var->green.length = 6; | ||
169 | var->blue.length = 5; | ||
170 | var->red.offset = 11; | ||
171 | var->green.offset = 5; | ||
172 | var->blue.offset = 0; | ||
173 | break; | ||
174 | case 18: | ||
175 | var->red.length = 6; | ||
176 | var->green.length = 6; | ||
177 | var->blue.length = 6; | ||
178 | var->red.offset = 12; | ||
179 | var->green.offset = 6; | ||
180 | var->blue.offset = 0; | ||
181 | break; | ||
182 | case 32: | ||
183 | var->red.length = 8; | ||
184 | var->green.length = 8; | ||
185 | var->blue.length = 8; | ||
186 | var->red.offset = 16; | ||
187 | var->green.offset = 8; | ||
188 | var->blue.offset = 0; | ||
189 | break; | ||
190 | } | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * Calculate lcd register values from var setting & save into hw | ||
197 | */ | ||
198 | static void nuc900fb_calculate_lcd_regs(const struct fb_info *info, | ||
199 | struct nuc900fb_hw *regs) | ||
200 | { | ||
201 | const struct fb_var_screeninfo *var = &info->var; | ||
202 | int vtt = var->height + var->upper_margin + var->lower_margin; | ||
203 | int htt = var->width + var->left_margin + var->right_margin; | ||
204 | int hsync = var->width + var->right_margin; | ||
205 | int vsync = var->height + var->lower_margin; | ||
206 | |||
207 | regs->lcd_crtc_size = LCM_CRTC_SIZE_VTTVAL(vtt) | | ||
208 | LCM_CRTC_SIZE_HTTVAL(htt); | ||
209 | regs->lcd_crtc_dend = LCM_CRTC_DEND_VDENDVAL(var->height) | | ||
210 | LCM_CRTC_DEND_HDENDVAL(var->width); | ||
211 | regs->lcd_crtc_hr = LCM_CRTC_HR_EVAL(var->width + 5) | | ||
212 | LCM_CRTC_HR_SVAL(var->width + 1); | ||
213 | regs->lcd_crtc_hsync = LCM_CRTC_HSYNC_EVAL(hsync + var->hsync_len) | | ||
214 | LCM_CRTC_HSYNC_SVAL(hsync); | ||
215 | regs->lcd_crtc_vr = LCM_CRTC_VR_EVAL(vsync + var->vsync_len) | | ||
216 | LCM_CRTC_VR_SVAL(vsync); | ||
217 | |||
218 | } | ||
219 | |||
220 | /* | ||
221 | * Activate (set) the controller from the given framebuffer | ||
222 | * information | ||
223 | */ | ||
224 | static void nuc900fb_activate_var(struct fb_info *info) | ||
225 | { | ||
226 | struct nuc900fb_info *fbi = info->par; | ||
227 | void __iomem *regs = fbi->io; | ||
228 | struct fb_var_screeninfo *var = &info->var; | ||
229 | int clkdiv; | ||
230 | |||
231 | clkdiv = nuc900fb_calc_pixclk(fbi, var->pixclock) - 1; | ||
232 | if (clkdiv < 0) | ||
233 | clkdiv = 0; | ||
234 | |||
235 | nuc900fb_calculate_lcd_regs(info, &fbi->regs); | ||
236 | |||
237 | /* set the new lcd registers*/ | ||
238 | |||
239 | dev_dbg(fbi->dev, "new lcd register set:\n"); | ||
240 | dev_dbg(fbi->dev, "dccs = 0x%08x\n", fbi->regs.lcd_dccs); | ||
241 | dev_dbg(fbi->dev, "dev_ctl = 0x%08x\n", fbi->regs.lcd_device_ctrl); | ||
242 | dev_dbg(fbi->dev, "crtc_size = 0x%08x\n", fbi->regs.lcd_crtc_size); | ||
243 | dev_dbg(fbi->dev, "crtc_dend = 0x%08x\n", fbi->regs.lcd_crtc_dend); | ||
244 | dev_dbg(fbi->dev, "crtc_hr = 0x%08x\n", fbi->regs.lcd_crtc_hr); | ||
245 | dev_dbg(fbi->dev, "crtc_hsync = 0x%08x\n", fbi->regs.lcd_crtc_hsync); | ||
246 | dev_dbg(fbi->dev, "crtc_vr = 0x%08x\n", fbi->regs.lcd_crtc_vr); | ||
247 | |||
248 | writel(fbi->regs.lcd_device_ctrl, regs + REG_LCM_DEV_CTRL); | ||
249 | writel(fbi->regs.lcd_crtc_size, regs + REG_LCM_CRTC_SIZE); | ||
250 | writel(fbi->regs.lcd_crtc_dend, regs + REG_LCM_CRTC_DEND); | ||
251 | writel(fbi->regs.lcd_crtc_hr, regs + REG_LCM_CRTC_HR); | ||
252 | writel(fbi->regs.lcd_crtc_hsync, regs + REG_LCM_CRTC_HSYNC); | ||
253 | writel(fbi->regs.lcd_crtc_vr, regs + REG_LCM_CRTC_VR); | ||
254 | |||
255 | /* set lcd address pointers */ | ||
256 | nuc900fb_set_lcdaddr(info); | ||
257 | |||
258 | writel(fbi->regs.lcd_dccs, regs + REG_LCM_DCCS); | ||
259 | } | ||
260 | |||
261 | /* | ||
262 | * Alters the hardware state. | ||
263 | * | ||
264 | */ | ||
265 | static int nuc900fb_set_par(struct fb_info *info) | ||
266 | { | ||
267 | struct fb_var_screeninfo *var = &info->var; | ||
268 | |||
269 | switch (var->bits_per_pixel) { | ||
270 | case 32: | ||
271 | case 24: | ||
272 | case 18: | ||
273 | case 16: | ||
274 | case 12: | ||
275 | info->fix.visual = FB_VISUAL_TRUECOLOR; | ||
276 | break; | ||
277 | case 1: | ||
278 | info->fix.visual = FB_VISUAL_MONO01; | ||
279 | break; | ||
280 | default: | ||
281 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
282 | break; | ||
283 | } | ||
284 | |||
285 | info->fix.line_length = (var->xres_virtual * var->bits_per_pixel) / 8; | ||
286 | |||
287 | /* activate this new configuration */ | ||
288 | nuc900fb_activate_var(info); | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static inline unsigned int chan_to_field(unsigned int chan, | ||
293 | struct fb_bitfield *bf) | ||
294 | { | ||
295 | chan &= 0xffff; | ||
296 | chan >>= 16 - bf->length; | ||
297 | return chan << bf->offset; | ||
298 | } | ||
299 | |||
300 | static int nuc900fb_setcolreg(unsigned regno, | ||
301 | unsigned red, unsigned green, unsigned blue, | ||
302 | unsigned transp, struct fb_info *info) | ||
303 | { | ||
304 | unsigned int val; | ||
305 | |||
306 | switch (info->fix.visual) { | ||
307 | case FB_VISUAL_TRUECOLOR: | ||
308 | /* true-colour, use pseuo-palette */ | ||
309 | if (regno < 16) { | ||
310 | u32 *pal = info->pseudo_palette; | ||
311 | |||
312 | val = chan_to_field(red, &info->var.red); | ||
313 | val |= chan_to_field(green, &info->var.green); | ||
314 | val |= chan_to_field(blue, &info->var.blue); | ||
315 | pal[regno] = val; | ||
316 | } | ||
317 | break; | ||
318 | |||
319 | default: | ||
320 | return 1; /* unknown type */ | ||
321 | } | ||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | /** | ||
326 | * nuc900fb_blank | ||
327 | * | ||
328 | */ | ||
329 | static int nuc900fb_blank(int blank_mode, struct fb_info *info) | ||
330 | { | ||
331 | |||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | static struct fb_ops nuc900fb_ops = { | ||
336 | .owner = THIS_MODULE, | ||
337 | .fb_check_var = nuc900fb_check_var, | ||
338 | .fb_set_par = nuc900fb_set_par, | ||
339 | .fb_blank = nuc900fb_blank, | ||
340 | .fb_setcolreg = nuc900fb_setcolreg, | ||
341 | .fb_fillrect = cfb_fillrect, | ||
342 | .fb_copyarea = cfb_copyarea, | ||
343 | .fb_imageblit = cfb_imageblit, | ||
344 | }; | ||
345 | |||
346 | |||
347 | static inline void modify_gpio(void __iomem *reg, | ||
348 | unsigned long set, unsigned long mask) | ||
349 | { | ||
350 | unsigned long tmp; | ||
351 | tmp = readl(reg) & ~mask; | ||
352 | writel(tmp | set, reg); | ||
353 | } | ||
354 | |||
355 | /* | ||
356 | * Initialise LCD-related registers | ||
357 | */ | ||
358 | static int nuc900fb_init_registers(struct fb_info *info) | ||
359 | { | ||
360 | struct nuc900fb_info *fbi = info->par; | ||
361 | struct nuc900fb_mach_info *mach_info = fbi->dev->platform_data; | ||
362 | void __iomem *regs = fbi->io; | ||
363 | |||
364 | /*reset the display engine*/ | ||
365 | writel(0, regs + REG_LCM_DCCS); | ||
366 | writel(readl(regs + REG_LCM_DCCS) | LCM_DCCS_ENG_RST, | ||
367 | regs + REG_LCM_DCCS); | ||
368 | ndelay(100); | ||
369 | writel(readl(regs + REG_LCM_DCCS) & (~LCM_DCCS_ENG_RST), | ||
370 | regs + REG_LCM_DCCS); | ||
371 | ndelay(100); | ||
372 | |||
373 | writel(0, regs + REG_LCM_DEV_CTRL); | ||
374 | |||
375 | /* config gpio output */ | ||
376 | modify_gpio(W90X900_VA_GPIO + 0x54, mach_info->gpio_dir, | ||
377 | mach_info->gpio_dir_mask); | ||
378 | modify_gpio(W90X900_VA_GPIO + 0x58, mach_info->gpio_data, | ||
379 | mach_info->gpio_data_mask); | ||
380 | |||
381 | return 0; | ||
382 | } | ||
383 | |||
384 | |||
385 | /* | ||
386 | * Alloc the SDRAM region of NUC900 for the frame buffer. | ||
387 | * The buffer should be a non-cached, non-buffered, memory region | ||
388 | * to allow palette and pixel writes without flushing the cache. | ||
389 | */ | ||
390 | static int __init nuc900fb_map_video_memory(struct fb_info *info) | ||
391 | { | ||
392 | struct nuc900fb_info *fbi = info->par; | ||
393 | dma_addr_t map_dma; | ||
394 | unsigned long map_size = PAGE_ALIGN(info->fix.smem_len); | ||
395 | |||
396 | dev_dbg(fbi->dev, "nuc900fb_map_video_memory(fbi=%p) map_size %lu\n", | ||
397 | fbi, map_size); | ||
398 | |||
399 | info->screen_base = dma_alloc_writecombine(fbi->dev, map_size, | ||
400 | &map_dma, GFP_KERNEL); | ||
401 | |||
402 | if (!info->screen_base) | ||
403 | return -ENOMEM; | ||
404 | |||
405 | memset(info->screen_base, 0x00, map_size); | ||
406 | info->fix.smem_start = map_dma; | ||
407 | |||
408 | return 0; | ||
409 | } | ||
410 | |||
411 | static inline void nuc900fb_unmap_video_memory(struct fb_info *info) | ||
412 | { | ||
413 | struct nuc900fb_info *fbi = info->par; | ||
414 | dma_free_writecombine(fbi->dev, PAGE_ALIGN(info->fix.smem_len), | ||
415 | info->screen_base, info->fix.smem_start); | ||
416 | } | ||
417 | |||
418 | static irqreturn_t nuc900fb_irqhandler(int irq, void *dev_id) | ||
419 | { | ||
420 | struct nuc900fb_info *fbi = dev_id; | ||
421 | void __iomem *regs = fbi->io; | ||
422 | void __iomem *irq_base = fbi->irq_base; | ||
423 | unsigned long lcdirq = readl(regs + REG_LCM_INT_CS); | ||
424 | |||
425 | if (lcdirq & LCM_INT_CS_DISP_F_STATUS) { | ||
426 | writel(readl(irq_base) | 1<<30, irq_base); | ||
427 | |||
428 | /* wait VA_EN low */ | ||
429 | if ((readl(regs + REG_LCM_DCCS) & | ||
430 | LCM_DCCS_SINGLE) == LCM_DCCS_SINGLE) | ||
431 | while ((readl(regs + REG_LCM_DCCS) & | ||
432 | LCM_DCCS_VA_EN) == LCM_DCCS_VA_EN) | ||
433 | ; | ||
434 | /* display_out-enable */ | ||
435 | writel(readl(regs + REG_LCM_DCCS) | LCM_DCCS_DISP_OUT_EN, | ||
436 | regs + REG_LCM_DCCS); | ||
437 | /* va-enable*/ | ||
438 | writel(readl(regs + REG_LCM_DCCS) | LCM_DCCS_VA_EN, | ||
439 | regs + REG_LCM_DCCS); | ||
440 | } else if (lcdirq & LCM_INT_CS_UNDERRUN_INT) { | ||
441 | writel(readl(irq_base) | LCM_INT_CS_UNDERRUN_INT, irq_base); | ||
442 | } else if (lcdirq & LCM_INT_CS_BUS_ERROR_INT) { | ||
443 | writel(readl(irq_base) | LCM_INT_CS_BUS_ERROR_INT, irq_base); | ||
444 | } | ||
445 | |||
446 | return IRQ_HANDLED; | ||
447 | } | ||
448 | |||
449 | #ifdef CONFIG_CPU_FREQ | ||
450 | |||
451 | static int nuc900fb_cpufreq_transition(struct notifier_block *nb, | ||
452 | unsigned long val, void *data) | ||
453 | { | ||
454 | struct nuc900fb_info *info; | ||
455 | struct fb_info *fbinfo; | ||
456 | long delta_f; | ||
457 | info = container_of(nb, struct nuc900fb_info, freq_transition); | ||
458 | fbinfo = platform_get_drvdata(to_platform_device(info->dev)); | ||
459 | |||
460 | delta_f = info->clk_rate - clk_get_rate(info->clk); | ||
461 | |||
462 | if ((val == CPUFREQ_POSTCHANGE && delta_f > 0) || | ||
463 | (val == CPUFREQ_PRECHANGE && delta_f < 0)) { | ||
464 | info->clk_rate = clk_get_rate(info->clk); | ||
465 | nuc900fb_activate_var(fbinfo); | ||
466 | } | ||
467 | |||
468 | return 0; | ||
469 | } | ||
470 | |||
471 | static inline int nuc900fb_cpufreq_register(struct nuc900fb_info *fbi) | ||
472 | { | ||
473 | fbi->freq_transition.notifier_call = nuc900fb_cpufreq_transition; | ||
474 | return cpufreq_register_notifier(&fbi->freq_transition, | ||
475 | CPUFREQ_TRANSITION_NOTIFIER); | ||
476 | } | ||
477 | |||
478 | static inline void nuc900fb_cpufreq_deregister(struct nuc900fb_info *fbi) | ||
479 | { | ||
480 | cpufreq_unregister_notifier(&fbi->freq_transition, | ||
481 | CPUFREQ_TRANSITION_NOTIFIER); | ||
482 | } | ||
483 | #else | ||
484 | static inline int nuc900fb_cpufreq_transition(struct notifier_block *nb, | ||
485 | unsigned long val, void *data) | ||
486 | { | ||
487 | return 0; | ||
488 | } | ||
489 | |||
490 | static inline int nuc900fb_cpufreq_register(struct nuc900fb_info *fbi) | ||
491 | { | ||
492 | return 0; | ||
493 | } | ||
494 | |||
495 | static inline void nuc900fb_cpufreq_deregister(struct nuc900fb_info *info) | ||
496 | { | ||
497 | } | ||
498 | #endif | ||
499 | |||
500 | static char driver_name[] = "nuc900fb"; | ||
501 | |||
502 | static int __devinit nuc900fb_probe(struct platform_device *pdev) | ||
503 | { | ||
504 | struct nuc900fb_info *fbi; | ||
505 | struct nuc900fb_display *display; | ||
506 | struct fb_info *fbinfo; | ||
507 | struct nuc900fb_mach_info *mach_info; | ||
508 | struct resource *res; | ||
509 | int ret; | ||
510 | int irq; | ||
511 | int i; | ||
512 | int size; | ||
513 | |||
514 | dev_dbg(&pdev->dev, "devinit\n"); | ||
515 | mach_info = pdev->dev.platform_data; | ||
516 | if (mach_info == NULL) { | ||
517 | dev_err(&pdev->dev, | ||
518 | "no platform data for lcd, cannot attach\n"); | ||
519 | return -EINVAL; | ||
520 | } | ||
521 | |||
522 | if (mach_info->default_display > mach_info->num_displays) { | ||
523 | dev_err(&pdev->dev, | ||
524 | "default display No. is %d but only %d displays \n", | ||
525 | mach_info->default_display, mach_info->num_displays); | ||
526 | return -EINVAL; | ||
527 | } | ||
528 | |||
529 | |||
530 | display = mach_info->displays + mach_info->default_display; | ||
531 | |||
532 | irq = platform_get_irq(pdev, 0); | ||
533 | if (irq < 0) { | ||
534 | dev_err(&pdev->dev, "no irq for device\n"); | ||
535 | return -ENOENT; | ||
536 | } | ||
537 | |||
538 | fbinfo = framebuffer_alloc(sizeof(struct nuc900fb_info), &pdev->dev); | ||
539 | if (!fbinfo) | ||
540 | return -ENOMEM; | ||
541 | |||
542 | platform_set_drvdata(pdev, fbinfo); | ||
543 | |||
544 | fbi = fbinfo->par; | ||
545 | fbi->dev = &pdev->dev; | ||
546 | |||
547 | #ifdef CONFIG_CPU_NUC950 | ||
548 | fbi->drv_type = LCDDRV_NUC950; | ||
549 | #endif | ||
550 | |||
551 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
552 | |||
553 | size = (res->end - res->start) + 1; | ||
554 | fbi->mem = request_mem_region(res->start, size, pdev->name); | ||
555 | if (fbi->mem == NULL) { | ||
556 | dev_err(&pdev->dev, "failed to alloc memory region\n"); | ||
557 | ret = -ENOENT; | ||
558 | goto free_fb; | ||
559 | } | ||
560 | |||
561 | fbi->io = ioremap(res->start, size); | ||
562 | if (fbi->io == NULL) { | ||
563 | dev_err(&pdev->dev, "ioremap() of lcd registers failed\n"); | ||
564 | ret = -ENXIO; | ||
565 | goto release_mem_region; | ||
566 | } | ||
567 | |||
568 | fbi->irq_base = fbi->io + REG_LCM_INT_CS; | ||
569 | |||
570 | |||
571 | /* Stop the LCD */ | ||
572 | writel(0, fbi->io + REG_LCM_DCCS); | ||
573 | |||
574 | /* fill the fbinfo*/ | ||
575 | strcpy(fbinfo->fix.id, driver_name); | ||
576 | fbinfo->fix.type = FB_TYPE_PACKED_PIXELS; | ||
577 | fbinfo->fix.type_aux = 0; | ||
578 | fbinfo->fix.xpanstep = 0; | ||
579 | fbinfo->fix.ypanstep = 0; | ||
580 | fbinfo->fix.ywrapstep = 0; | ||
581 | fbinfo->fix.accel = FB_ACCEL_NONE; | ||
582 | fbinfo->var.nonstd = 0; | ||
583 | fbinfo->var.activate = FB_ACTIVATE_NOW; | ||
584 | fbinfo->var.accel_flags = 0; | ||
585 | fbinfo->var.vmode = FB_VMODE_NONINTERLACED; | ||
586 | fbinfo->fbops = &nuc900fb_ops; | ||
587 | fbinfo->flags = FBINFO_FLAG_DEFAULT; | ||
588 | fbinfo->pseudo_palette = &fbi->pseudo_pal; | ||
589 | |||
590 | ret = request_irq(irq, nuc900fb_irqhandler, IRQF_DISABLED, | ||
591 | pdev->name, fbinfo); | ||
592 | if (ret) { | ||
593 | dev_err(&pdev->dev, "cannot register irq handler %d -err %d\n", | ||
594 | irq, ret); | ||
595 | ret = -EBUSY; | ||
596 | goto release_regs; | ||
597 | } | ||
598 | |||
599 | nuc900_driver_clksrc_div(&pdev->dev, "ext", 0x2); | ||
600 | |||
601 | fbi->clk = clk_get(&pdev->dev, NULL); | ||
602 | if (!fbi->clk || IS_ERR(fbi->clk)) { | ||
603 | printk(KERN_ERR "nuc900-lcd:failed to get lcd clock source\n"); | ||
604 | ret = -ENOENT; | ||
605 | goto release_irq; | ||
606 | } | ||
607 | |||
608 | clk_enable(fbi->clk); | ||
609 | dev_dbg(&pdev->dev, "got and enabled clock\n"); | ||
610 | |||
611 | fbi->clk_rate = clk_get_rate(fbi->clk); | ||
612 | |||
613 | /* calutate the video buffer size */ | ||
614 | for (i = 0; i < mach_info->num_displays; i++) { | ||
615 | unsigned long smem_len = mach_info->displays[i].xres; | ||
616 | smem_len *= mach_info->displays[i].yres; | ||
617 | smem_len *= mach_info->displays[i].bpp; | ||
618 | smem_len >>= 3; | ||
619 | if (fbinfo->fix.smem_len < smem_len) | ||
620 | fbinfo->fix.smem_len = smem_len; | ||
621 | } | ||
622 | |||
623 | /* Initialize Video Memory */ | ||
624 | ret = nuc900fb_map_video_memory(fbinfo); | ||
625 | if (ret) { | ||
626 | printk(KERN_ERR "Failed to allocate video RAM: %x\n", ret); | ||
627 | goto release_clock; | ||
628 | } | ||
629 | |||
630 | dev_dbg(&pdev->dev, "got video memory\n"); | ||
631 | |||
632 | fbinfo->var.xres = display->xres; | ||
633 | fbinfo->var.yres = display->yres; | ||
634 | fbinfo->var.bits_per_pixel = display->bpp; | ||
635 | |||
636 | nuc900fb_init_registers(fbinfo); | ||
637 | |||
638 | nuc900fb_check_var(&fbinfo->var, fbinfo); | ||
639 | |||
640 | ret = nuc900fb_cpufreq_register(fbi); | ||
641 | if (ret < 0) { | ||
642 | dev_err(&pdev->dev, "Failed to register cpufreq\n"); | ||
643 | goto free_video_memory; | ||
644 | } | ||
645 | |||
646 | ret = register_framebuffer(fbinfo); | ||
647 | if (ret) { | ||
648 | printk(KERN_ERR "failed to register framebuffer device: %d\n", | ||
649 | ret); | ||
650 | goto free_cpufreq; | ||
651 | } | ||
652 | |||
653 | printk(KERN_INFO "fb%d: %s frame buffer device\n", | ||
654 | fbinfo->node, fbinfo->fix.id); | ||
655 | |||
656 | return 0; | ||
657 | |||
658 | free_cpufreq: | ||
659 | nuc900fb_cpufreq_deregister(fbi); | ||
660 | free_video_memory: | ||
661 | nuc900fb_unmap_video_memory(fbinfo); | ||
662 | release_clock: | ||
663 | clk_disable(fbi->clk); | ||
664 | clk_put(fbi->clk); | ||
665 | release_irq: | ||
666 | free_irq(irq, fbi); | ||
667 | release_regs: | ||
668 | iounmap(fbi->io); | ||
669 | release_mem_region: | ||
670 | release_mem_region((unsigned long)fbi->mem, size); | ||
671 | free_fb: | ||
672 | framebuffer_release(fbinfo); | ||
673 | return ret; | ||
674 | } | ||
675 | |||
676 | /* | ||
677 | * shutdown the lcd controller | ||
678 | */ | ||
679 | static void nuc900fb_stop_lcd(struct fb_info *info) | ||
680 | { | ||
681 | struct nuc900fb_info *fbi = info->par; | ||
682 | void __iomem *regs = fbi->io; | ||
683 | |||
684 | writel((~LCM_DCCS_DISP_INT_EN) | (~LCM_DCCS_VA_EN) | (~LCM_DCCS_OSD_EN), | ||
685 | regs + REG_LCM_DCCS); | ||
686 | } | ||
687 | |||
688 | /* | ||
689 | * Cleanup | ||
690 | */ | ||
691 | static int nuc900fb_remove(struct platform_device *pdev) | ||
692 | { | ||
693 | struct fb_info *fbinfo = platform_get_drvdata(pdev); | ||
694 | struct nuc900fb_info *fbi = fbinfo->par; | ||
695 | int irq; | ||
696 | |||
697 | nuc900fb_stop_lcd(fbinfo); | ||
698 | msleep(1); | ||
699 | |||
700 | nuc900fb_unmap_video_memory(fbinfo); | ||
701 | |||
702 | iounmap(fbi->io); | ||
703 | |||
704 | irq = platform_get_irq(pdev, 0); | ||
705 | free_irq(irq, fbi); | ||
706 | |||
707 | release_resource(fbi->mem); | ||
708 | kfree(fbi->mem); | ||
709 | |||
710 | platform_set_drvdata(pdev, NULL); | ||
711 | framebuffer_release(fbinfo); | ||
712 | |||
713 | return 0; | ||
714 | } | ||
715 | |||
716 | #ifdef CONFIG_PM | ||
717 | |||
718 | /* | ||
719 | * suspend and resume support for the lcd controller | ||
720 | */ | ||
721 | |||
722 | static int nuc900fb_suspend(struct platform_device *dev, pm_message_t state) | ||
723 | { | ||
724 | struct fb_info *fbinfo = platform_get_drvdata(dev); | ||
725 | struct nuc900fb_info *info = fbinfo->par; | ||
726 | |||
727 | nuc900fb_stop_lcd(); | ||
728 | msleep(1); | ||
729 | clk_disable(info->clk); | ||
730 | return 0; | ||
731 | } | ||
732 | |||
733 | static int nuc900fb_resume(struct platform_device *dev) | ||
734 | { | ||
735 | struct fb_info *fbinfo = platform_get_drvdata(dev); | ||
736 | struct nuc900fb_info *fbi = fbinfo->par; | ||
737 | |||
738 | printk(KERN_INFO "nuc900fb resume\n"); | ||
739 | |||
740 | clk_enable(fbi->clk); | ||
741 | msleep(1); | ||
742 | |||
743 | nuc900fb_init_registers(fbinfo); | ||
744 | nuc900fb_activate_var(bfinfo); | ||
745 | |||
746 | return 0; | ||
747 | } | ||
748 | |||
749 | #else | ||
750 | #define nuc900fb_suspend NULL | ||
751 | #define nuc900fb_resume NULL | ||
752 | #endif | ||
753 | |||
754 | static struct platform_driver nuc900fb_driver = { | ||
755 | .probe = nuc900fb_probe, | ||
756 | .remove = nuc900fb_remove, | ||
757 | .suspend = nuc900fb_suspend, | ||
758 | .resume = nuc900fb_resume, | ||
759 | .driver = { | ||
760 | .name = "nuc900-lcd", | ||
761 | .owner = THIS_MODULE, | ||
762 | }, | ||
763 | }; | ||
764 | |||
765 | int __devinit nuc900fb_init(void) | ||
766 | { | ||
767 | return platform_driver_register(&nuc900fb_driver); | ||
768 | } | ||
769 | |||
770 | static void __exit nuc900fb_cleanup(void) | ||
771 | { | ||
772 | platform_driver_unregister(&nuc900fb_driver); | ||
773 | } | ||
774 | |||
775 | module_init(nuc900fb_init); | ||
776 | module_exit(nuc900fb_cleanup); | ||
777 | |||
778 | MODULE_DESCRIPTION("Framebuffer driver for the NUC900"); | ||
779 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/nuc900fb.h b/drivers/video/nuc900fb.h new file mode 100644 index 000000000000..6c23aa3d3b89 --- /dev/null +++ b/drivers/video/nuc900fb.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (c) 2009 Nuvoton technology corporation | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * Auther: | ||
12 | * Wang Qiang(rurality.linux@gmail.com) 2009/12/16 | ||
13 | */ | ||
14 | |||
15 | #ifndef __NUC900FB_H | ||
16 | #define __NUC900FB_H | ||
17 | |||
18 | #include <mach/map.h> | ||
19 | #include <mach/fb.h> | ||
20 | |||
21 | enum nuc900_lcddrv_type { | ||
22 | LCDDRV_NUC910, | ||
23 | LCDDRV_NUC930, | ||
24 | LCDDRV_NUC932, | ||
25 | LCDDRV_NUC950, | ||
26 | LCDDRV_NUC960, | ||
27 | }; | ||
28 | |||
29 | |||
30 | #define PALETTE_BUFFER_SIZE 256 | ||
31 | #define PALETTE_BUFF_CLEAR (0x80000000) /* entry is clear/invalid */ | ||
32 | |||
33 | struct nuc900fb_info { | ||
34 | struct device *dev; | ||
35 | struct clk *clk; | ||
36 | |||
37 | struct resource *mem; | ||
38 | void __iomem *io; | ||
39 | void __iomem *irq_base; | ||
40 | int drv_type; | ||
41 | struct nuc900fb_hw regs; | ||
42 | unsigned long clk_rate; | ||
43 | |||
44 | #ifdef CONFIG_CPU_FREQ | ||
45 | struct notifier_block freq_transition; | ||
46 | #endif | ||
47 | |||
48 | /* keep these registers in case we need to re-write palette */ | ||
49 | u32 palette_buffer[PALETTE_BUFFER_SIZE]; | ||
50 | u32 pseudo_pal[16]; | ||
51 | }; | ||
52 | |||
53 | int nuc900fb_init(void); | ||
54 | |||
55 | #endif /* __NUC900FB_H */ | ||
diff --git a/drivers/video/omap2/dss/manager.c b/drivers/video/omap2/dss/manager.c index 913142d4cab1..9acef00c47ea 100644 --- a/drivers/video/omap2/dss/manager.c +++ b/drivers/video/omap2/dss/manager.c | |||
@@ -341,7 +341,7 @@ static ssize_t manager_attr_store(struct kobject *kobj, struct attribute *attr, | |||
341 | return manager_attr->store(manager, buf, size); | 341 | return manager_attr->store(manager, buf, size); |
342 | } | 342 | } |
343 | 343 | ||
344 | static struct sysfs_ops manager_sysfs_ops = { | 344 | static const struct sysfs_ops manager_sysfs_ops = { |
345 | .show = manager_attr_show, | 345 | .show = manager_attr_show, |
346 | .store = manager_attr_store, | 346 | .store = manager_attr_store, |
347 | }; | 347 | }; |
diff --git a/drivers/video/omap2/dss/overlay.c b/drivers/video/omap2/dss/overlay.c index 0c5bea263ac6..aed3f3194347 100644 --- a/drivers/video/omap2/dss/overlay.c +++ b/drivers/video/omap2/dss/overlay.c | |||
@@ -320,7 +320,7 @@ static ssize_t overlay_attr_store(struct kobject *kobj, struct attribute *attr, | |||
320 | return overlay_attr->store(overlay, buf, size); | 320 | return overlay_attr->store(overlay, buf, size); |
321 | } | 321 | } |
322 | 322 | ||
323 | static struct sysfs_ops overlay_sysfs_ops = { | 323 | static const struct sysfs_ops overlay_sysfs_ops = { |
324 | .show = overlay_attr_show, | 324 | .show = overlay_attr_show, |
325 | .store = overlay_attr_store, | 325 | .store = overlay_attr_store, |
326 | }; | 326 | }; |
diff --git a/drivers/video/q40fb.c b/drivers/video/q40fb.c index 4beac1df617b..de40a626dc76 100644 --- a/drivers/video/q40fb.c +++ b/drivers/video/q40fb.c | |||
@@ -85,7 +85,7 @@ static struct fb_ops q40fb_ops = { | |||
85 | .fb_imageblit = cfb_imageblit, | 85 | .fb_imageblit = cfb_imageblit, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | static int __init q40fb_probe(struct platform_device *dev) | 88 | static int __devinit q40fb_probe(struct platform_device *dev) |
89 | { | 89 | { |
90 | struct fb_info *info; | 90 | struct fb_info *info; |
91 | 91 | ||
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index aac661225c78..2b094dec4a56 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c | |||
@@ -1004,12 +1004,12 @@ dealloc_fb: | |||
1004 | return ret; | 1004 | return ret; |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | static int __init s3c2410fb_probe(struct platform_device *pdev) | 1007 | static int __devinit s3c2410fb_probe(struct platform_device *pdev) |
1008 | { | 1008 | { |
1009 | return s3c24xxfb_probe(pdev, DRV_S3C2410); | 1009 | return s3c24xxfb_probe(pdev, DRV_S3C2410); |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | static int __init s3c2412fb_probe(struct platform_device *pdev) | 1012 | static int __devinit s3c2412fb_probe(struct platform_device *pdev) |
1013 | { | 1013 | { |
1014 | return s3c24xxfb_probe(pdev, DRV_S3C2412); | 1014 | return s3c24xxfb_probe(pdev, DRV_S3C2412); |
1015 | } | 1015 | } |
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c index cdaa873a6054..e8b76d65a070 100644 --- a/drivers/video/sa1100fb.c +++ b/drivers/video/sa1100fb.c | |||
@@ -1435,7 +1435,7 @@ static struct sa1100fb_info * __init sa1100fb_init_fbinfo(struct device *dev) | |||
1435 | return fbi; | 1435 | return fbi; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | static int __init sa1100fb_probe(struct platform_device *pdev) | 1438 | static int __devinit sa1100fb_probe(struct platform_device *pdev) |
1439 | { | 1439 | { |
1440 | struct sa1100fb_info *fbi; | 1440 | struct sa1100fb_info *fbi; |
1441 | int ret, irq; | 1441 | int ret, irq; |
diff --git a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c index f86012239bff..7a3a5e28eca1 100644 --- a/drivers/video/sgivwfb.c +++ b/drivers/video/sgivwfb.c | |||
@@ -745,7 +745,7 @@ int __init sgivwfb_setup(char *options) | |||
745 | /* | 745 | /* |
746 | * Initialisation | 746 | * Initialisation |
747 | */ | 747 | */ |
748 | static int __init sgivwfb_probe(struct platform_device *dev) | 748 | static int __devinit sgivwfb_probe(struct platform_device *dev) |
749 | { | 749 | { |
750 | struct sgivw_par *par; | 750 | struct sgivw_par *par; |
751 | struct fb_info *info; | 751 | struct fb_info *info; |
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c index 8d7653e56df5..bbd1dbf4026a 100644 --- a/drivers/video/sh_mobile_lcdcfb.c +++ b/drivers/video/sh_mobile_lcdcfb.c | |||
@@ -943,7 +943,7 @@ static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = { | |||
943 | 943 | ||
944 | static int sh_mobile_lcdc_remove(struct platform_device *pdev); | 944 | static int sh_mobile_lcdc_remove(struct platform_device *pdev); |
945 | 945 | ||
946 | static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) | 946 | static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev) |
947 | { | 947 | { |
948 | struct fb_info *info; | 948 | struct fb_info *info; |
949 | struct sh_mobile_lcdc_priv *priv; | 949 | struct sh_mobile_lcdc_priv *priv; |
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c index 9d2b6bc49036..a531a0f7cdf2 100644 --- a/drivers/video/sis/sis_main.c +++ b/drivers/video/sis/sis_main.c | |||
@@ -1891,9 +1891,6 @@ static struct fb_ops sisfb_ops = { | |||
1891 | .fb_fillrect = fbcon_sis_fillrect, | 1891 | .fb_fillrect = fbcon_sis_fillrect, |
1892 | .fb_copyarea = fbcon_sis_copyarea, | 1892 | .fb_copyarea = fbcon_sis_copyarea, |
1893 | .fb_imageblit = cfb_imageblit, | 1893 | .fb_imageblit = cfb_imageblit, |
1894 | #ifdef CONFIG_FB_SOFT_CURSOR | ||
1895 | .fb_cursor = soft_cursor, | ||
1896 | #endif | ||
1897 | .fb_sync = fbcon_sis_sync, | 1894 | .fb_sync = fbcon_sis_sync, |
1898 | #ifdef SIS_NEW_CONFIG_COMPAT | 1895 | #ifdef SIS_NEW_CONFIG_COMPAT |
1899 | .fb_compat_ioctl= sisfb_ioctl, | 1896 | .fb_compat_ioctl= sisfb_ioctl, |
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c index bd37ee1f6a25..ef4128c8e57a 100644 --- a/drivers/video/vesafb.c +++ b/drivers/video/vesafb.c | |||
@@ -226,7 +226,7 @@ static int __init vesafb_setup(char *options) | |||
226 | return 0; | 226 | return 0; |
227 | } | 227 | } |
228 | 228 | ||
229 | static int __init vesafb_probe(struct platform_device *dev) | 229 | static int __devinit vesafb_probe(struct platform_device *dev) |
230 | { | 230 | { |
231 | struct fb_info *info; | 231 | struct fb_info *info; |
232 | int i, err; | 232 | int i, err; |
diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c index 050d432c7d95..b8ab995fbda7 100644 --- a/drivers/video/vfb.c +++ b/drivers/video/vfb.c | |||
@@ -479,7 +479,7 @@ static int __init vfb_setup(char *options) | |||
479 | * Initialisation | 479 | * Initialisation |
480 | */ | 480 | */ |
481 | 481 | ||
482 | static int __init vfb_probe(struct platform_device *dev) | 482 | static int __devinit vfb_probe(struct platform_device *dev) |
483 | { | 483 | { |
484 | struct fb_info *info; | 484 | struct fb_info *info; |
485 | int retval = -ENOMEM; | 485 | int retval = -ENOMEM; |
diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c index 5b2938903ac2..76d8dae5b1bb 100644 --- a/drivers/video/vga16fb.c +++ b/drivers/video/vga16fb.c | |||
@@ -1293,7 +1293,7 @@ static int vga16fb_setup(char *options) | |||
1293 | } | 1293 | } |
1294 | #endif | 1294 | #endif |
1295 | 1295 | ||
1296 | static int __init vga16fb_probe(struct platform_device *dev) | 1296 | static int __devinit vga16fb_probe(struct platform_device *dev) |
1297 | { | 1297 | { |
1298 | struct fb_info *info; | 1298 | struct fb_info *info; |
1299 | struct vga16fb_par *par; | 1299 | struct vga16fb_par *par; |
diff --git a/drivers/video/via/Makefile b/drivers/video/via/Makefile index e533b4b6aba4..eeed238ad6a2 100644 --- a/drivers/video/via/Makefile +++ b/drivers/video/via/Makefile | |||
@@ -4,4 +4,4 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_FB_VIA) += viafb.o | 5 | obj-$(CONFIG_FB_VIA) += viafb.o |
6 | 6 | ||
7 | viafb-y :=viafbdev.o hw.o iface.o via_i2c.o dvi.o lcd.o ioctl.o accel.o via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o | 7 | viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o |
diff --git a/drivers/video/via/chip.h b/drivers/video/via/chip.h index 474f428aea92..8c06bd3c0b4d 100644 --- a/drivers/video/via/chip.h +++ b/drivers/video/via/chip.h | |||
@@ -107,7 +107,6 @@ | |||
107 | struct tmds_chip_information { | 107 | struct tmds_chip_information { |
108 | int tmds_chip_name; | 108 | int tmds_chip_name; |
109 | int tmds_chip_slave_addr; | 109 | int tmds_chip_slave_addr; |
110 | int dvi_panel_id; | ||
111 | int data_mode; | 110 | int data_mode; |
112 | int output_interface; | 111 | int output_interface; |
113 | int i2c_port; | 112 | int i2c_port; |
@@ -142,14 +141,9 @@ struct tmds_setting_information { | |||
142 | int iga_path; | 141 | int iga_path; |
143 | int h_active; | 142 | int h_active; |
144 | int v_active; | 143 | int v_active; |
145 | int bpp; | ||
146 | int refresh_rate; | ||
147 | int get_dvi_size_method; | ||
148 | int max_pixel_clock; | 144 | int max_pixel_clock; |
149 | int dvi_panel_size; | 145 | int max_hres; |
150 | int dvi_panel_hres; | 146 | int max_vres; |
151 | int dvi_panel_vres; | ||
152 | int native_size; | ||
153 | }; | 147 | }; |
154 | 148 | ||
155 | struct lvds_setting_information { | 149 | struct lvds_setting_information { |
@@ -160,7 +154,6 @@ struct lvds_setting_information { | |||
160 | int refresh_rate; | 154 | int refresh_rate; |
161 | int get_lcd_size_method; | 155 | int get_lcd_size_method; |
162 | int lcd_panel_id; | 156 | int lcd_panel_id; |
163 | int lcd_panel_size; | ||
164 | int lcd_panel_hres; | 157 | int lcd_panel_hres; |
165 | int lcd_panel_vres; | 158 | int lcd_panel_vres; |
166 | int display_method; | 159 | int display_method; |
diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c index 67b36932212b..abe59b8c7a05 100644 --- a/drivers/video/via/dvi.c +++ b/drivers/video/via/dvi.c | |||
@@ -23,11 +23,10 @@ | |||
23 | static void tmds_register_write(int index, u8 data); | 23 | static void tmds_register_write(int index, u8 data); |
24 | static int tmds_register_read(int index); | 24 | static int tmds_register_read(int index); |
25 | static int tmds_register_read_bytes(int index, u8 *buff, int buff_len); | 25 | static int tmds_register_read_bytes(int index, u8 *buff, int buff_len); |
26 | static int check_reduce_blanking_mode(int mode_index, | 26 | static void dvi_get_panel_size_from_DDCv1(struct tmds_chip_information |
27 | int refresh_rate); | 27 | *tmds_chip, struct tmds_setting_information *tmds_setting); |
28 | static int dvi_get_panel_size_from_DDCv1(void); | 28 | static void dvi_get_panel_size_from_DDCv2(struct tmds_chip_information |
29 | static int dvi_get_panel_size_from_DDCv2(void); | 29 | *tmds_chip, struct tmds_setting_information *tmds_setting); |
30 | static unsigned char dvi_get_panel_info(void); | ||
31 | static int viafb_dvi_query_EDID(void); | 30 | static int viafb_dvi_query_EDID(void); |
32 | 31 | ||
33 | static int check_tmds_chip(int device_id_subaddr, int device_id) | 32 | static int check_tmds_chip(int device_id_subaddr, int device_id) |
@@ -38,23 +37,24 @@ static int check_tmds_chip(int device_id_subaddr, int device_id) | |||
38 | return FAIL; | 37 | return FAIL; |
39 | } | 38 | } |
40 | 39 | ||
41 | void viafb_init_dvi_size(void) | 40 | void viafb_init_dvi_size(struct tmds_chip_information *tmds_chip, |
41 | struct tmds_setting_information *tmds_setting) | ||
42 | { | 42 | { |
43 | DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n"); | 43 | DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n"); |
44 | DEBUG_MSG(KERN_INFO | ||
45 | "viaparinfo->tmds_setting_info->get_dvi_size_method %d\n", | ||
46 | viaparinfo->tmds_setting_info->get_dvi_size_method); | ||
47 | 44 | ||
48 | switch (viaparinfo->tmds_setting_info->get_dvi_size_method) { | 45 | viafb_dvi_sense(); |
49 | case GET_DVI_SIZE_BY_SYSTEM_BIOS: | 46 | switch (viafb_dvi_query_EDID()) { |
47 | case 1: | ||
48 | dvi_get_panel_size_from_DDCv1(tmds_chip, tmds_setting); | ||
50 | break; | 49 | break; |
51 | case GET_DVI_SZIE_BY_HW_STRAPPING: | 50 | case 2: |
51 | dvi_get_panel_size_from_DDCv2(tmds_chip, tmds_setting); | ||
52 | break; | 52 | break; |
53 | case GET_DVI_SIZE_BY_VGA_BIOS: | ||
54 | default: | 53 | default: |
55 | dvi_get_panel_info(); | 54 | printk(KERN_WARNING "viafb_init_dvi_size: DVI panel size undetected!\n"); |
56 | break; | 55 | break; |
57 | } | 56 | } |
57 | |||
58 | return; | 58 | return; |
59 | } | 59 | } |
60 | 60 | ||
@@ -189,42 +189,14 @@ static int tmds_register_read_bytes(int index, u8 *buff, int buff_len) | |||
189 | return 0; | 189 | return 0; |
190 | } | 190 | } |
191 | 191 | ||
192 | static int check_reduce_blanking_mode(int mode_index, | ||
193 | int refresh_rate) | ||
194 | { | ||
195 | if (refresh_rate != 60) | ||
196 | return false; | ||
197 | |||
198 | switch (mode_index) { | ||
199 | /* Following modes have reduce blanking mode. */ | ||
200 | case VIA_RES_1360X768: | ||
201 | case VIA_RES_1400X1050: | ||
202 | case VIA_RES_1440X900: | ||
203 | case VIA_RES_1600X900: | ||
204 | case VIA_RES_1680X1050: | ||
205 | case VIA_RES_1920X1080: | ||
206 | case VIA_RES_1920X1200: | ||
207 | break; | ||
208 | |||
209 | default: | ||
210 | DEBUG_MSG(KERN_INFO | ||
211 | "This dvi mode %d have no reduce blanking mode!\n", | ||
212 | mode_index); | ||
213 | return false; | ||
214 | } | ||
215 | |||
216 | return true; | ||
217 | } | ||
218 | |||
219 | /* DVI Set Mode */ | 192 | /* DVI Set Mode */ |
220 | void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga) | 193 | void viafb_dvi_set_mode(struct VideoModeTable *mode, int mode_bpp, |
194 | int set_iga) | ||
221 | { | 195 | { |
222 | struct VideoModeTable *videoMode = NULL; | 196 | struct VideoModeTable *rb_mode; |
223 | struct crt_mode_table *pDviTiming; | 197 | struct crt_mode_table *pDviTiming; |
224 | unsigned long desirePixelClock, maxPixelClock; | 198 | unsigned long desirePixelClock, maxPixelClock; |
225 | int status = 0; | 199 | pDviTiming = mode->crtc; |
226 | videoMode = viafb_get_modetbl_pointer(video_index); | ||
227 | pDviTiming = videoMode->crtc; | ||
228 | desirePixelClock = pDviTiming->clk / 1000000; | 200 | desirePixelClock = pDviTiming->clk / 1000000; |
229 | maxPixelClock = (unsigned long)viaparinfo-> | 201 | maxPixelClock = (unsigned long)viaparinfo-> |
230 | tmds_setting_info->max_pixel_clock; | 202 | tmds_setting_info->max_pixel_clock; |
@@ -232,20 +204,14 @@ void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga) | |||
232 | DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n"); | 204 | DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n"); |
233 | 205 | ||
234 | if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) { | 206 | if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) { |
235 | /*Check if reduce-blanking mode is exist */ | 207 | rb_mode = viafb_get_rb_mode(mode->crtc[0].crtc.hor_addr, |
236 | status = | 208 | mode->crtc[0].crtc.ver_addr); |
237 | check_reduce_blanking_mode(video_index, | 209 | if (rb_mode) { |
238 | pDviTiming->refresh_rate); | 210 | mode = rb_mode; |
239 | if (status) { | 211 | pDviTiming = rb_mode->crtc; |
240 | video_index += 100; /*Use reduce-blanking mode */ | ||
241 | videoMode = viafb_get_modetbl_pointer(video_index); | ||
242 | pDviTiming = videoMode->crtc; | ||
243 | DEBUG_MSG(KERN_INFO | ||
244 | "DVI use reduce blanking mode %d!!\n", | ||
245 | video_index); | ||
246 | } | 212 | } |
247 | } | 213 | } |
248 | viafb_fill_crtc_timing(pDviTiming, video_index, mode_bpp / 8, set_iga); | 214 | viafb_fill_crtc_timing(pDviTiming, mode, mode_bpp / 8, set_iga); |
249 | viafb_set_output_path(DEVICE_DVI, set_iga, | 215 | viafb_set_output_path(DEVICE_DVI, set_iga, |
250 | viaparinfo->chip_info->tmds_chip_info.output_interface); | 216 | viaparinfo->chip_info->tmds_chip_info.output_interface); |
251 | } | 217 | } |
@@ -350,25 +316,18 @@ static int viafb_dvi_query_EDID(void) | |||
350 | return false; | 316 | return false; |
351 | } | 317 | } |
352 | 318 | ||
353 | /* | 319 | /* Get Panel Size Using EDID1 Table */ |
354 | * | 320 | static void dvi_get_panel_size_from_DDCv1(struct tmds_chip_information |
355 | * int dvi_get_panel_size_from_DDCv1(void) | 321 | *tmds_chip, struct tmds_setting_information *tmds_setting) |
356 | * | ||
357 | * - Get Panel Size Using EDID1 Table | ||
358 | * | ||
359 | * Return Type: int | ||
360 | * | ||
361 | */ | ||
362 | static int dvi_get_panel_size_from_DDCv1(void) | ||
363 | { | 322 | { |
364 | int i, max_h = 0, max_v = 0, tmp, restore; | 323 | int i, max_h = 0, tmp, restore; |
365 | unsigned char rData; | 324 | unsigned char rData; |
366 | unsigned char EDID_DATA[18]; | 325 | unsigned char EDID_DATA[18]; |
367 | 326 | ||
368 | DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n"); | 327 | DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n"); |
369 | 328 | ||
370 | restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr; | 329 | restore = tmds_chip->tmds_chip_slave_addr; |
371 | viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0; | 330 | tmds_chip->tmds_chip_slave_addr = 0xA0; |
372 | 331 | ||
373 | rData = tmds_register_read(0x23); | 332 | rData = tmds_register_read(0x23); |
374 | if (rData & 0x3C) | 333 | if (rData & 0x3C) |
@@ -414,8 +373,8 @@ static int dvi_get_panel_size_from_DDCv1(void) | |||
414 | /* The first two byte must be zero. */ | 373 | /* The first two byte must be zero. */ |
415 | if (EDID_DATA[3] == 0xFD) { | 374 | if (EDID_DATA[3] == 0xFD) { |
416 | /* To get max pixel clock. */ | 375 | /* To get max pixel clock. */ |
417 | viaparinfo->tmds_setting_info-> | 376 | tmds_setting->max_pixel_clock = |
418 | max_pixel_clock = EDID_DATA[9] * 10; | 377 | EDID_DATA[9] * 10; |
419 | } | 378 | } |
420 | } | 379 | } |
421 | break; | 380 | break; |
@@ -425,154 +384,88 @@ static int dvi_get_panel_size_from_DDCv1(void) | |||
425 | } | 384 | } |
426 | } | 385 | } |
427 | 386 | ||
387 | tmds_setting->max_hres = max_h; | ||
428 | switch (max_h) { | 388 | switch (max_h) { |
429 | case 640: | 389 | case 640: |
430 | viaparinfo->tmds_setting_info->dvi_panel_size = | 390 | tmds_setting->max_vres = 480; |
431 | VIA_RES_640X480; | ||
432 | break; | 391 | break; |
433 | case 800: | 392 | case 800: |
434 | viaparinfo->tmds_setting_info->dvi_panel_size = | 393 | tmds_setting->max_vres = 600; |
435 | VIA_RES_800X600; | ||
436 | break; | 394 | break; |
437 | case 1024: | 395 | case 1024: |
438 | viaparinfo->tmds_setting_info->dvi_panel_size = | 396 | tmds_setting->max_vres = 768; |
439 | VIA_RES_1024X768; | ||
440 | break; | 397 | break; |
441 | case 1280: | 398 | case 1280: |
442 | viaparinfo->tmds_setting_info->dvi_panel_size = | 399 | tmds_setting->max_vres = 1024; |
443 | VIA_RES_1280X1024; | ||
444 | break; | 400 | break; |
445 | case 1400: | 401 | case 1400: |
446 | viaparinfo->tmds_setting_info->dvi_panel_size = | 402 | tmds_setting->max_vres = 1050; |
447 | VIA_RES_1400X1050; | ||
448 | break; | 403 | break; |
449 | case 1440: | 404 | case 1440: |
450 | viaparinfo->tmds_setting_info->dvi_panel_size = | 405 | tmds_setting->max_vres = 1050; |
451 | VIA_RES_1440X1050; | ||
452 | break; | 406 | break; |
453 | case 1600: | 407 | case 1600: |
454 | viaparinfo->tmds_setting_info->dvi_panel_size = | 408 | tmds_setting->max_vres = 1200; |
455 | VIA_RES_1600X1200; | ||
456 | break; | 409 | break; |
457 | case 1920: | 410 | case 1920: |
458 | if (max_v == 1200) { | 411 | tmds_setting->max_vres = 1080; |
459 | viaparinfo->tmds_setting_info->dvi_panel_size = | ||
460 | VIA_RES_1920X1200; | ||
461 | } else { | ||
462 | viaparinfo->tmds_setting_info->dvi_panel_size = | ||
463 | VIA_RES_1920X1080; | ||
464 | } | ||
465 | |||
466 | break; | 412 | break; |
467 | default: | 413 | default: |
468 | viaparinfo->tmds_setting_info->dvi_panel_size = | 414 | DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d ! " |
469 | VIA_RES_1024X768; | 415 | "set default panel size.\n", max_h); |
470 | DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d !\ | ||
471 | set default panel size.\n", max_h); | ||
472 | break; | 416 | break; |
473 | } | 417 | } |
474 | 418 | ||
475 | DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n", | 419 | DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n", |
476 | viaparinfo->tmds_setting_info->max_pixel_clock); | 420 | tmds_setting->max_pixel_clock); |
477 | viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; | 421 | tmds_chip->tmds_chip_slave_addr = restore; |
478 | return viaparinfo->tmds_setting_info->dvi_panel_size; | ||
479 | } | 422 | } |
480 | 423 | ||
481 | /* | 424 | /* Get Panel Size Using EDID2 Table */ |
482 | * | 425 | static void dvi_get_panel_size_from_DDCv2(struct tmds_chip_information |
483 | * int dvi_get_panel_size_from_DDCv2(void) | 426 | *tmds_chip, struct tmds_setting_information *tmds_setting) |
484 | * | ||
485 | * - Get Panel Size Using EDID2 Table | ||
486 | * | ||
487 | * Return Type: int | ||
488 | * | ||
489 | */ | ||
490 | static int dvi_get_panel_size_from_DDCv2(void) | ||
491 | { | 427 | { |
492 | int HSize = 0, restore; | 428 | int restore; |
493 | unsigned char R_Buffer[2]; | 429 | unsigned char R_Buffer[2]; |
494 | 430 | ||
495 | DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n"); | 431 | DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n"); |
496 | 432 | ||
497 | restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr; | 433 | restore = tmds_chip->tmds_chip_slave_addr; |
498 | viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA2; | 434 | tmds_chip->tmds_chip_slave_addr = 0xA2; |
499 | 435 | ||
500 | /* Horizontal: 0x76, 0x77 */ | 436 | /* Horizontal: 0x76, 0x77 */ |
501 | tmds_register_read_bytes(0x76, R_Buffer, 2); | 437 | tmds_register_read_bytes(0x76, R_Buffer, 2); |
502 | HSize = R_Buffer[0]; | 438 | tmds_setting->max_hres = R_Buffer[0] + (R_Buffer[1] << 8); |
503 | HSize += R_Buffer[1] << 8; | ||
504 | 439 | ||
505 | switch (HSize) { | 440 | switch (tmds_setting->max_hres) { |
506 | case 640: | 441 | case 640: |
507 | viaparinfo->tmds_setting_info->dvi_panel_size = | 442 | tmds_setting->max_vres = 480; |
508 | VIA_RES_640X480; | ||
509 | break; | 443 | break; |
510 | case 800: | 444 | case 800: |
511 | viaparinfo->tmds_setting_info->dvi_panel_size = | 445 | tmds_setting->max_vres = 600; |
512 | VIA_RES_800X600; | ||
513 | break; | 446 | break; |
514 | case 1024: | 447 | case 1024: |
515 | viaparinfo->tmds_setting_info->dvi_panel_size = | 448 | tmds_setting->max_vres = 768; |
516 | VIA_RES_1024X768; | ||
517 | break; | 449 | break; |
518 | case 1280: | 450 | case 1280: |
519 | viaparinfo->tmds_setting_info->dvi_panel_size = | 451 | tmds_setting->max_vres = 1024; |
520 | VIA_RES_1280X1024; | ||
521 | break; | 452 | break; |
522 | case 1400: | 453 | case 1400: |
523 | viaparinfo->tmds_setting_info->dvi_panel_size = | 454 | tmds_setting->max_vres = 1050; |
524 | VIA_RES_1400X1050; | ||
525 | break; | 455 | break; |
526 | case 1440: | 456 | case 1440: |
527 | viaparinfo->tmds_setting_info->dvi_panel_size = | 457 | tmds_setting->max_vres = 1050; |
528 | VIA_RES_1440X1050; | ||
529 | break; | 458 | break; |
530 | case 1600: | 459 | case 1600: |
531 | viaparinfo->tmds_setting_info->dvi_panel_size = | 460 | tmds_setting->max_vres = 1200; |
532 | VIA_RES_1600X1200; | ||
533 | break; | ||
534 | default: | ||
535 | viaparinfo->tmds_setting_info->dvi_panel_size = | ||
536 | VIA_RES_1024X768; | ||
537 | DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d!\ | ||
538 | set default panel size.\n", HSize); | ||
539 | break; | ||
540 | } | ||
541 | |||
542 | viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; | ||
543 | return viaparinfo->tmds_setting_info->dvi_panel_size; | ||
544 | } | ||
545 | |||
546 | /* | ||
547 | * | ||
548 | * unsigned char dvi_get_panel_info(void) | ||
549 | * | ||
550 | * - Get Panel Size | ||
551 | * | ||
552 | * Return Type: unsigned char | ||
553 | */ | ||
554 | static unsigned char dvi_get_panel_info(void) | ||
555 | { | ||
556 | unsigned char dvipanelsize; | ||
557 | DEBUG_MSG(KERN_INFO "dvi_get_panel_info! \n"); | ||
558 | |||
559 | viafb_dvi_sense(); | ||
560 | switch (viafb_dvi_query_EDID()) { | ||
561 | case 1: | ||
562 | dvi_get_panel_size_from_DDCv1(); | ||
563 | break; | ||
564 | case 2: | ||
565 | dvi_get_panel_size_from_DDCv2(); | ||
566 | break; | 461 | break; |
567 | default: | 462 | default: |
463 | DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d! " | ||
464 | "set default panel size.\n", tmds_setting->max_hres); | ||
568 | break; | 465 | break; |
569 | } | 466 | } |
570 | 467 | ||
571 | DEBUG_MSG(KERN_INFO "dvi panel size is %2d \n", | 468 | tmds_chip->tmds_chip_slave_addr = restore; |
572 | viaparinfo->tmds_setting_info->dvi_panel_size); | ||
573 | dvipanelsize = (unsigned char)(viaparinfo-> | ||
574 | tmds_setting_info->dvi_panel_size); | ||
575 | return dvipanelsize; | ||
576 | } | 469 | } |
577 | 470 | ||
578 | /* If Disable DVI, turn off pad */ | 471 | /* If Disable DVI, turn off pad */ |
diff --git a/drivers/video/via/dvi.h b/drivers/video/via/dvi.h index e1ec37fb0dc3..0dffcfd395f3 100644 --- a/drivers/video/via/dvi.h +++ b/drivers/video/via/dvi.h | |||
@@ -53,12 +53,13 @@ | |||
53 | #define DEV_CONNECT_DVI 0x01 | 53 | #define DEV_CONNECT_DVI 0x01 |
54 | #define DEV_CONNECT_HDMI 0x02 | 54 | #define DEV_CONNECT_HDMI 0x02 |
55 | 55 | ||
56 | struct VideoModeTable *viafb_get_cea_mode_tbl_pointer(int Index); | ||
57 | int viafb_dvi_sense(void); | 56 | int viafb_dvi_sense(void); |
58 | void viafb_dvi_disable(void); | 57 | void viafb_dvi_disable(void); |
59 | void viafb_dvi_enable(void); | 58 | void viafb_dvi_enable(void); |
60 | int viafb_tmds_trasmitter_identify(void); | 59 | int viafb_tmds_trasmitter_identify(void); |
61 | void viafb_init_dvi_size(void); | 60 | void viafb_init_dvi_size(struct tmds_chip_information *tmds_chip, |
62 | void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga); | 61 | struct tmds_setting_information *tmds_setting); |
62 | void viafb_dvi_set_mode(struct VideoModeTable *videoMode, int mode_bpp, | ||
63 | int set_iga); | ||
63 | 64 | ||
64 | #endif /* __DVI_H__ */ | 65 | #endif /* __DVI_H__ */ |
diff --git a/drivers/video/via/global.c b/drivers/video/via/global.c index b675cdbb03ad..1ee511b73307 100644 --- a/drivers/video/via/global.c +++ b/drivers/video/via/global.c | |||
@@ -23,15 +23,12 @@ int viafb_platform_epia_dvi = STATE_OFF; | |||
23 | int viafb_device_lcd_dualedge = STATE_OFF; | 23 | int viafb_device_lcd_dualedge = STATE_OFF; |
24 | int viafb_bus_width = 12; | 24 | int viafb_bus_width = 12; |
25 | int viafb_display_hardware_layout = HW_LAYOUT_LCD_DVI; | 25 | int viafb_display_hardware_layout = HW_LAYOUT_LCD_DVI; |
26 | int viafb_memsize; | ||
27 | int viafb_DeviceStatus = CRT_Device; | 26 | int viafb_DeviceStatus = CRT_Device; |
28 | int viafb_hotplug; | 27 | int viafb_hotplug; |
29 | int viafb_refresh = 60; | 28 | int viafb_refresh = 60; |
30 | int viafb_refresh1 = 60; | 29 | int viafb_refresh1 = 60; |
31 | int viafb_lcd_dsp_method = LCD_EXPANDSION; | 30 | int viafb_lcd_dsp_method = LCD_EXPANDSION; |
32 | int viafb_lcd_mode = LCD_OPENLDI; | 31 | int viafb_lcd_mode = LCD_OPENLDI; |
33 | int viafb_bpp = 32; | ||
34 | int viafb_bpp1 = 32; | ||
35 | int viafb_CRT_ON = 1; | 32 | int viafb_CRT_ON = 1; |
36 | int viafb_DVI_ON; | 33 | int viafb_DVI_ON; |
37 | int viafb_LCD_ON ; | 34 | int viafb_LCD_ON ; |
@@ -42,8 +39,6 @@ int viafb_hotplug_Xres = 640; | |||
42 | int viafb_hotplug_Yres = 480; | 39 | int viafb_hotplug_Yres = 480; |
43 | int viafb_hotplug_bpp = 32; | 40 | int viafb_hotplug_bpp = 32; |
44 | int viafb_hotplug_refresh = 60; | 41 | int viafb_hotplug_refresh = 60; |
45 | unsigned int viafb_second_offset; | ||
46 | int viafb_second_size; | ||
47 | int viafb_primary_dev = None_Device; | 42 | int viafb_primary_dev = None_Device; |
48 | unsigned int viafb_second_xres = 640; | 43 | unsigned int viafb_second_xres = 640; |
49 | unsigned int viafb_second_yres = 480; | 44 | unsigned int viafb_second_yres = 480; |
diff --git a/drivers/video/via/global.h b/drivers/video/via/global.h index d69d0ca99c2f..8d95d5fd1388 100644 --- a/drivers/video/via/global.h +++ b/drivers/video/via/global.h | |||
@@ -35,7 +35,6 @@ | |||
35 | 35 | ||
36 | #include "debug.h" | 36 | #include "debug.h" |
37 | 37 | ||
38 | #include "iface.h" | ||
39 | #include "viafbdev.h" | 38 | #include "viafbdev.h" |
40 | #include "chip.h" | 39 | #include "chip.h" |
41 | #include "accel.h" | 40 | #include "accel.h" |
@@ -68,8 +67,6 @@ extern int viafb_refresh; | |||
68 | extern int viafb_refresh1; | 67 | extern int viafb_refresh1; |
69 | extern int viafb_lcd_dsp_method; | 68 | extern int viafb_lcd_dsp_method; |
70 | extern int viafb_lcd_mode; | 69 | extern int viafb_lcd_mode; |
71 | extern int viafb_bpp; | ||
72 | extern int viafb_bpp1; | ||
73 | 70 | ||
74 | extern int viafb_CRT_ON; | 71 | extern int viafb_CRT_ON; |
75 | extern int viafb_hotplug_Xres; | 72 | extern int viafb_hotplug_Xres; |
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c index 3e083ff67ae2..f2583b1b527f 100644 --- a/drivers/video/via/hw.c +++ b/drivers/video/via/hw.c | |||
@@ -524,7 +524,6 @@ static void dvi_patch_skew_dvp1(void); | |||
524 | static void dvi_patch_skew_dvp_low(void); | 524 | static void dvi_patch_skew_dvp_low(void); |
525 | static void set_dvi_output_path(int set_iga, int output_interface); | 525 | static void set_dvi_output_path(int set_iga, int output_interface); |
526 | static void set_lcd_output_path(int set_iga, int output_interface); | 526 | static void set_lcd_output_path(int set_iga, int output_interface); |
527 | static int search_mode_setting(int ModeInfoIndex); | ||
528 | static void load_fix_bit_crtc_reg(void); | 527 | static void load_fix_bit_crtc_reg(void); |
529 | static void init_gfx_chip_info(struct pci_dev *pdev, | 528 | static void init_gfx_chip_info(struct pci_dev *pdev, |
530 | const struct pci_device_id *pdi); | 529 | const struct pci_device_id *pdi); |
@@ -686,6 +685,84 @@ void viafb_set_secondary_pitch(u32 pitch) | |||
686 | viafb_write_reg_mask(0x71, VIACR, (pitch >> (10 - 7)) & 0x80, 0x80); | 685 | viafb_write_reg_mask(0x71, VIACR, (pitch >> (10 - 7)) & 0x80, 0x80); |
687 | } | 686 | } |
688 | 687 | ||
688 | void viafb_set_primary_color_depth(u8 depth) | ||
689 | { | ||
690 | u8 value; | ||
691 | |||
692 | DEBUG_MSG(KERN_DEBUG "viafb_set_primary_color_depth(%d)\n", depth); | ||
693 | switch (depth) { | ||
694 | case 8: | ||
695 | value = 0x00; | ||
696 | break; | ||
697 | case 15: | ||
698 | value = 0x04; | ||
699 | break; | ||
700 | case 16: | ||
701 | value = 0x14; | ||
702 | break; | ||
703 | case 24: | ||
704 | value = 0x0C; | ||
705 | break; | ||
706 | case 30: | ||
707 | value = 0x08; | ||
708 | break; | ||
709 | default: | ||
710 | printk(KERN_WARNING "viafb_set_primary_color_depth: " | ||
711 | "Unsupported depth: %d\n", depth); | ||
712 | return; | ||
713 | } | ||
714 | |||
715 | viafb_write_reg_mask(0x15, VIASR, value, 0x1C); | ||
716 | } | ||
717 | |||
718 | void viafb_set_secondary_color_depth(u8 depth) | ||
719 | { | ||
720 | u8 value; | ||
721 | |||
722 | DEBUG_MSG(KERN_DEBUG "viafb_set_secondary_color_depth(%d)\n", depth); | ||
723 | switch (depth) { | ||
724 | case 8: | ||
725 | value = 0x00; | ||
726 | break; | ||
727 | case 16: | ||
728 | value = 0x40; | ||
729 | break; | ||
730 | case 24: | ||
731 | value = 0xC0; | ||
732 | break; | ||
733 | case 30: | ||
734 | value = 0x80; | ||
735 | break; | ||
736 | default: | ||
737 | printk(KERN_WARNING "viafb_set_secondary_color_depth: " | ||
738 | "Unsupported depth: %d\n", depth); | ||
739 | return; | ||
740 | } | ||
741 | |||
742 | viafb_write_reg_mask(0x67, VIACR, value, 0xC0); | ||
743 | } | ||
744 | |||
745 | static void set_color_register(u8 index, u8 red, u8 green, u8 blue) | ||
746 | { | ||
747 | outb(0xFF, 0x3C6); /* bit mask of palette */ | ||
748 | outb(index, 0x3C8); | ||
749 | outb(red, 0x3C9); | ||
750 | outb(green, 0x3C9); | ||
751 | outb(blue, 0x3C9); | ||
752 | } | ||
753 | |||
754 | void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue) | ||
755 | { | ||
756 | viafb_write_reg_mask(0x1A, VIASR, 0x00, 0x01); | ||
757 | set_color_register(index, red, green, blue); | ||
758 | } | ||
759 | |||
760 | void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue) | ||
761 | { | ||
762 | viafb_write_reg_mask(0x1A, VIASR, 0x01, 0x01); | ||
763 | set_color_register(index, red, green, blue); | ||
764 | } | ||
765 | |||
689 | void viafb_set_output_path(int device, int set_iga, int output_interface) | 766 | void viafb_set_output_path(int device, int set_iga, int output_interface) |
690 | { | 767 | { |
691 | switch (device) { | 768 | switch (device) { |
@@ -710,11 +787,8 @@ static void set_crt_output_path(int set_iga) | |||
710 | viafb_write_reg_mask(SR16, VIASR, 0x00, BIT6); | 787 | viafb_write_reg_mask(SR16, VIASR, 0x00, BIT6); |
711 | break; | 788 | break; |
712 | case IGA2: | 789 | case IGA2: |
713 | case IGA1_IGA2: | ||
714 | viafb_write_reg_mask(CR6A, VIACR, 0xC0, BIT6 + BIT7); | 790 | viafb_write_reg_mask(CR6A, VIACR, 0xC0, BIT6 + BIT7); |
715 | viafb_write_reg_mask(SR16, VIASR, 0x40, BIT6); | 791 | viafb_write_reg_mask(SR16, VIASR, 0x40, BIT6); |
716 | if (set_iga == IGA1_IGA2) | ||
717 | viafb_write_reg_mask(CR6B, VIACR, 0x08, BIT3); | ||
718 | break; | 792 | break; |
719 | } | 793 | } |
720 | } | 794 | } |
@@ -904,13 +978,6 @@ static void set_lcd_output_path(int set_iga, int output_interface) | |||
904 | 978 | ||
905 | enable_second_display_channel(); | 979 | enable_second_display_channel(); |
906 | break; | 980 | break; |
907 | |||
908 | case IGA1_IGA2: | ||
909 | viafb_write_reg_mask(CR6B, VIACR, 0x08, BIT3); | ||
910 | viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3); | ||
911 | |||
912 | disable_second_display_channel(); | ||
913 | break; | ||
914 | } | 981 | } |
915 | 982 | ||
916 | switch (output_interface) { | 983 | switch (output_interface) { |
@@ -987,49 +1054,6 @@ static void set_lcd_output_path(int set_iga, int output_interface) | |||
987 | } | 1054 | } |
988 | } | 1055 | } |
989 | 1056 | ||
990 | /* Search Mode Index */ | ||
991 | static int search_mode_setting(int ModeInfoIndex) | ||
992 | { | ||
993 | int i = 0; | ||
994 | |||
995 | while ((i < NUM_TOTAL_MODETABLE) && | ||
996 | (ModeInfoIndex != CLE266Modes[i].ModeIndex)) | ||
997 | i++; | ||
998 | if (i >= NUM_TOTAL_MODETABLE) | ||
999 | i = 0; | ||
1000 | return i; | ||
1001 | |||
1002 | } | ||
1003 | |||
1004 | struct VideoModeTable *viafb_get_modetbl_pointer(int Index) | ||
1005 | { | ||
1006 | struct VideoModeTable *TmpTbl = NULL; | ||
1007 | TmpTbl = &CLE266Modes[search_mode_setting(Index)]; | ||
1008 | return TmpTbl; | ||
1009 | } | ||
1010 | |||
1011 | struct VideoModeTable *viafb_get_cea_mode_tbl_pointer(int Index) | ||
1012 | { | ||
1013 | struct VideoModeTable *TmpTbl = NULL; | ||
1014 | int i = 0; | ||
1015 | while ((i < NUM_TOTAL_CEA_MODES) && | ||
1016 | (Index != CEA_HDMI_Modes[i].ModeIndex)) | ||
1017 | i++; | ||
1018 | if ((i < NUM_TOTAL_CEA_MODES)) | ||
1019 | TmpTbl = &CEA_HDMI_Modes[i]; | ||
1020 | else { | ||
1021 | /*Still use general timing if don't find CEA timing */ | ||
1022 | i = 0; | ||
1023 | while ((i < NUM_TOTAL_MODETABLE) && | ||
1024 | (Index != CLE266Modes[i].ModeIndex)) | ||
1025 | i++; | ||
1026 | if (i >= NUM_TOTAL_MODETABLE) | ||
1027 | i = 0; | ||
1028 | TmpTbl = &CLE266Modes[i]; | ||
1029 | } | ||
1030 | return TmpTbl; | ||
1031 | } | ||
1032 | |||
1033 | static void load_fix_bit_crtc_reg(void) | 1057 | static void load_fix_bit_crtc_reg(void) |
1034 | { | 1058 | { |
1035 | /* always set to 1 */ | 1059 | /* always set to 1 */ |
@@ -1121,15 +1145,13 @@ void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga) | |||
1121 | struct io_register *reg = NULL; | 1145 | struct io_register *reg = NULL; |
1122 | 1146 | ||
1123 | switch (set_iga) { | 1147 | switch (set_iga) { |
1124 | case IGA1_IGA2: | ||
1125 | case IGA1: | 1148 | case IGA1: |
1126 | reg_value = IGA1_FETCH_COUNT_FORMULA(h_addr, bpp_byte); | 1149 | reg_value = IGA1_FETCH_COUNT_FORMULA(h_addr, bpp_byte); |
1127 | viafb_load_reg_num = fetch_count_reg. | 1150 | viafb_load_reg_num = fetch_count_reg. |
1128 | iga1_fetch_count_reg.reg_num; | 1151 | iga1_fetch_count_reg.reg_num; |
1129 | reg = fetch_count_reg.iga1_fetch_count_reg.reg; | 1152 | reg = fetch_count_reg.iga1_fetch_count_reg.reg; |
1130 | viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR); | 1153 | viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR); |
1131 | if (set_iga == IGA1) | 1154 | break; |
1132 | break; | ||
1133 | case IGA2: | 1155 | case IGA2: |
1134 | reg_value = IGA2_FETCH_COUNT_FORMULA(h_addr, bpp_byte); | 1156 | reg_value = IGA2_FETCH_COUNT_FORMULA(h_addr, bpp_byte); |
1135 | viafb_load_reg_num = fetch_count_reg. | 1157 | viafb_load_reg_num = fetch_count_reg. |
@@ -1499,7 +1521,7 @@ void viafb_set_vclock(u32 CLK, int set_iga) | |||
1499 | /* H.W. Reset : ON */ | 1521 | /* H.W. Reset : ON */ |
1500 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); | 1522 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); |
1501 | 1523 | ||
1502 | if ((set_iga == IGA1) || (set_iga == IGA1_IGA2)) { | 1524 | if (set_iga == IGA1) { |
1503 | /* Change D,N FOR VCLK */ | 1525 | /* Change D,N FOR VCLK */ |
1504 | switch (viaparinfo->chip_info->gfx_chip_name) { | 1526 | switch (viaparinfo->chip_info->gfx_chip_name) { |
1505 | case UNICHROME_CLE266: | 1527 | case UNICHROME_CLE266: |
@@ -1528,7 +1550,7 @@ void viafb_set_vclock(u32 CLK, int set_iga) | |||
1528 | } | 1550 | } |
1529 | } | 1551 | } |
1530 | 1552 | ||
1531 | if ((set_iga == IGA2) || (set_iga == IGA1_IGA2)) { | 1553 | if (set_iga == IGA2) { |
1532 | /* Change D,N FOR LCK */ | 1554 | /* Change D,N FOR LCK */ |
1533 | switch (viaparinfo->chip_info->gfx_chip_name) { | 1555 | switch (viaparinfo->chip_info->gfx_chip_name) { |
1534 | case UNICHROME_CLE266: | 1556 | case UNICHROME_CLE266: |
@@ -1557,12 +1579,12 @@ void viafb_set_vclock(u32 CLK, int set_iga) | |||
1557 | viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); | 1579 | viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); |
1558 | 1580 | ||
1559 | /* Reset PLL */ | 1581 | /* Reset PLL */ |
1560 | if ((set_iga == IGA1) || (set_iga == IGA1_IGA2)) { | 1582 | if (set_iga == IGA1) { |
1561 | viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); | 1583 | viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); |
1562 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); | 1584 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); |
1563 | } | 1585 | } |
1564 | 1586 | ||
1565 | if ((set_iga == IGA2) || (set_iga == IGA1_IGA2)) { | 1587 | if (set_iga == IGA2) { |
1566 | viafb_write_reg_mask(SR40, VIASR, 0x01, BIT0); | 1588 | viafb_write_reg_mask(SR40, VIASR, 0x01, BIT0); |
1567 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT0); | 1589 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT0); |
1568 | } | 1590 | } |
@@ -1805,47 +1827,15 @@ void viafb_load_crtc_timing(struct display_timing device_timing, | |||
1805 | viafb_lock_crt(); | 1827 | viafb_lock_crt(); |
1806 | } | 1828 | } |
1807 | 1829 | ||
1808 | void viafb_set_color_depth(int bpp_byte, int set_iga) | ||
1809 | { | ||
1810 | if (set_iga == IGA1) { | ||
1811 | switch (bpp_byte) { | ||
1812 | case MODE_8BPP: | ||
1813 | viafb_write_reg_mask(SR15, VIASR, 0x22, 0x7E); | ||
1814 | break; | ||
1815 | case MODE_16BPP: | ||
1816 | viafb_write_reg_mask(SR15, VIASR, 0xB6, 0xFE); | ||
1817 | break; | ||
1818 | case MODE_32BPP: | ||
1819 | viafb_write_reg_mask(SR15, VIASR, 0xAE, 0xFE); | ||
1820 | break; | ||
1821 | } | ||
1822 | } else { | ||
1823 | switch (bpp_byte) { | ||
1824 | case MODE_8BPP: | ||
1825 | viafb_write_reg_mask(CR67, VIACR, 0x00, BIT6 + BIT7); | ||
1826 | break; | ||
1827 | case MODE_16BPP: | ||
1828 | viafb_write_reg_mask(CR67, VIACR, 0x40, BIT6 + BIT7); | ||
1829 | break; | ||
1830 | case MODE_32BPP: | ||
1831 | viafb_write_reg_mask(CR67, VIACR, 0xC0, BIT6 + BIT7); | ||
1832 | break; | ||
1833 | } | ||
1834 | } | ||
1835 | } | ||
1836 | |||
1837 | void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | 1830 | void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, |
1838 | int mode_index, int bpp_byte, int set_iga) | 1831 | struct VideoModeTable *video_mode, int bpp_byte, int set_iga) |
1839 | { | 1832 | { |
1840 | struct VideoModeTable *video_mode; | ||
1841 | struct display_timing crt_reg; | 1833 | struct display_timing crt_reg; |
1842 | int i; | 1834 | int i; |
1843 | int index = 0; | 1835 | int index = 0; |
1844 | int h_addr, v_addr; | 1836 | int h_addr, v_addr; |
1845 | u32 pll_D_N; | 1837 | u32 pll_D_N; |
1846 | 1838 | ||
1847 | video_mode = &CLE266Modes[search_mode_setting(mode_index)]; | ||
1848 | |||
1849 | for (i = 0; i < video_mode->mode_array; i++) { | 1839 | for (i = 0; i < video_mode->mode_array; i++) { |
1850 | index = i; | 1840 | index = i; |
1851 | 1841 | ||
@@ -1858,8 +1848,10 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | |||
1858 | 1848 | ||
1859 | /* Mode 640x480 has border, but LCD/DFP didn't have border. */ | 1849 | /* Mode 640x480 has border, but LCD/DFP didn't have border. */ |
1860 | /* So we would delete border. */ | 1850 | /* So we would delete border. */ |
1861 | if ((viafb_LCD_ON | viafb_DVI_ON) && (mode_index == VIA_RES_640X480) | 1851 | if ((viafb_LCD_ON | viafb_DVI_ON) |
1862 | && (viaparinfo->crt_setting_info->refresh_rate == 60)) { | 1852 | && video_mode->crtc[0].crtc.hor_addr == 640 |
1853 | && video_mode->crtc[0].crtc.ver_addr == 480 | ||
1854 | && viaparinfo->crt_setting_info->refresh_rate == 60) { | ||
1863 | /* The border is 8 pixels. */ | 1855 | /* The border is 8 pixels. */ |
1864 | crt_reg.hor_blank_start = crt_reg.hor_blank_start - 8; | 1856 | crt_reg.hor_blank_start = crt_reg.hor_blank_start - 8; |
1865 | 1857 | ||
@@ -1912,9 +1904,6 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | |||
1912 | && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)) | 1904 | && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)) |
1913 | viafb_load_FIFO_reg(set_iga, h_addr, v_addr); | 1905 | viafb_load_FIFO_reg(set_iga, h_addr, v_addr); |
1914 | 1906 | ||
1915 | /* load SR Register About Memory and Color part */ | ||
1916 | viafb_set_color_depth(bpp_byte, set_iga); | ||
1917 | |||
1918 | pll_D_N = viafb_get_clk_value(crt_table[index].clk); | 1907 | pll_D_N = viafb_get_clk_value(crt_table[index].clk); |
1919 | DEBUG_MSG(KERN_INFO "PLL=%x", pll_D_N); | 1908 | DEBUG_MSG(KERN_INFO "PLL=%x", pll_D_N); |
1920 | viafb_set_vclock(pll_D_N, set_iga); | 1909 | viafb_set_vclock(pll_D_N, set_iga); |
@@ -1956,9 +1945,6 @@ void viafb_update_device_setting(int hres, int vres, | |||
1956 | 1945 | ||
1957 | viaparinfo->tmds_setting_info->h_active = hres; | 1946 | viaparinfo->tmds_setting_info->h_active = hres; |
1958 | viaparinfo->tmds_setting_info->v_active = vres; | 1947 | viaparinfo->tmds_setting_info->v_active = vres; |
1959 | viaparinfo->tmds_setting_info->bpp = bpp; | ||
1960 | viaparinfo->tmds_setting_info->refresh_rate = | ||
1961 | vmode_refresh; | ||
1962 | 1948 | ||
1963 | viaparinfo->lvds_setting_info->h_active = hres; | 1949 | viaparinfo->lvds_setting_info->h_active = hres; |
1964 | viaparinfo->lvds_setting_info->v_active = vres; | 1950 | viaparinfo->lvds_setting_info->v_active = vres; |
@@ -1975,9 +1961,6 @@ void viafb_update_device_setting(int hres, int vres, | |||
1975 | if (viaparinfo->tmds_setting_info->iga_path == IGA2) { | 1961 | if (viaparinfo->tmds_setting_info->iga_path == IGA2) { |
1976 | viaparinfo->tmds_setting_info->h_active = hres; | 1962 | viaparinfo->tmds_setting_info->h_active = hres; |
1977 | viaparinfo->tmds_setting_info->v_active = vres; | 1963 | viaparinfo->tmds_setting_info->v_active = vres; |
1978 | viaparinfo->tmds_setting_info->bpp = bpp; | ||
1979 | viaparinfo->tmds_setting_info->refresh_rate = | ||
1980 | vmode_refresh; | ||
1981 | } | 1964 | } |
1982 | 1965 | ||
1983 | if (viaparinfo->lvds_setting_info->iga_path == IGA2) { | 1966 | if (viaparinfo->lvds_setting_info->iga_path == IGA2) { |
@@ -2076,9 +2059,8 @@ static void init_tmds_chip_info(void) | |||
2076 | 2059 | ||
2077 | DEBUG_MSG(KERN_INFO "TMDS Chip = %d\n", | 2060 | DEBUG_MSG(KERN_INFO "TMDS Chip = %d\n", |
2078 | viaparinfo->chip_info->tmds_chip_info.tmds_chip_name); | 2061 | viaparinfo->chip_info->tmds_chip_info.tmds_chip_name); |
2079 | viaparinfo->tmds_setting_info->get_dvi_size_method = | 2062 | viafb_init_dvi_size(&viaparinfo->shared->chip_info.tmds_chip_info, |
2080 | GET_DVI_SIZE_BY_VGA_BIOS; | 2063 | &viaparinfo->shared->tmds_setting_info); |
2081 | viafb_init_dvi_size(); | ||
2082 | } | 2064 | } |
2083 | 2065 | ||
2084 | static void init_lvds_chip_info(void) | 2066 | static void init_lvds_chip_info(void) |
@@ -2195,28 +2177,19 @@ static void set_display_channel(void) | |||
2195 | } | 2177 | } |
2196 | } | 2178 | } |
2197 | 2179 | ||
2198 | int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp, | 2180 | int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp, |
2199 | int vmode_index1, int hor_res1, int ver_res1, int video_bpp1) | 2181 | struct VideoModeTable *vmode_tbl1, int video_bpp1) |
2200 | { | 2182 | { |
2201 | int i, j; | 2183 | int i, j; |
2202 | int port; | 2184 | int port; |
2203 | u8 value, index, mask; | 2185 | u8 value, index, mask; |
2204 | struct VideoModeTable *vmode_tbl; | ||
2205 | struct crt_mode_table *crt_timing; | 2186 | struct crt_mode_table *crt_timing; |
2206 | struct VideoModeTable *vmode_tbl1 = NULL; | ||
2207 | struct crt_mode_table *crt_timing1 = NULL; | 2187 | struct crt_mode_table *crt_timing1 = NULL; |
2208 | 2188 | ||
2209 | DEBUG_MSG(KERN_INFO "Set Mode!!\n"); | ||
2210 | DEBUG_MSG(KERN_INFO | ||
2211 | "vmode_index=%d hor_res=%d ver_res=%d video_bpp=%d\n", | ||
2212 | vmode_index, hor_res, ver_res, video_bpp); | ||
2213 | |||
2214 | device_screen_off(); | 2189 | device_screen_off(); |
2215 | vmode_tbl = &CLE266Modes[search_mode_setting(vmode_index)]; | ||
2216 | crt_timing = vmode_tbl->crtc; | 2190 | crt_timing = vmode_tbl->crtc; |
2217 | 2191 | ||
2218 | if (viafb_SAMM_ON == 1) { | 2192 | if (viafb_SAMM_ON == 1) { |
2219 | vmode_tbl1 = &CLE266Modes[search_mode_setting(vmode_index1)]; | ||
2220 | crt_timing1 = vmode_tbl1->crtc; | 2193 | crt_timing1 = vmode_tbl1->crtc; |
2221 | } | 2194 | } |
2222 | 2195 | ||
@@ -2267,12 +2240,11 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp, | |||
2267 | outb(VPIT.SR[i - 1], VIASR + 1); | 2240 | outb(VPIT.SR[i - 1], VIASR + 1); |
2268 | } | 2241 | } |
2269 | 2242 | ||
2270 | viafb_set_primary_address(0); | 2243 | viafb_write_reg_mask(0x15, VIASR, 0xA2, 0xA2); |
2271 | viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0); | ||
2272 | viafb_set_iga_path(); | 2244 | viafb_set_iga_path(); |
2273 | 2245 | ||
2274 | /* Write CRTC */ | 2246 | /* Write CRTC */ |
2275 | viafb_fill_crtc_timing(crt_timing, vmode_index, video_bpp / 8, IGA1); | 2247 | viafb_fill_crtc_timing(crt_timing, vmode_tbl, video_bpp / 8, IGA1); |
2276 | 2248 | ||
2277 | /* Write Graphic Controller */ | 2249 | /* Write Graphic Controller */ |
2278 | for (i = 0; i < StdGR; i++) { | 2250 | for (i = 0; i < StdGR; i++) { |
@@ -2292,65 +2264,25 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp, | |||
2292 | 2264 | ||
2293 | /* Update Patch Register */ | 2265 | /* Update Patch Register */ |
2294 | 2266 | ||
2295 | if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) | 2267 | if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266 |
2296 | || (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K400)) { | 2268 | || viaparinfo->chip_info->gfx_chip_name == UNICHROME_K400) |
2297 | for (i = 0; i < NUM_TOTAL_PATCH_MODE; i++) { | 2269 | && vmode_tbl->crtc[0].crtc.hor_addr == 1024 |
2298 | if (res_patch_table[i].mode_index == vmode_index) { | 2270 | && vmode_tbl->crtc[0].crtc.ver_addr == 768) { |
2299 | for (j = 0; | 2271 | for (j = 0; j < res_patch_table[0].table_length; j++) { |
2300 | j < res_patch_table[i].table_length; j++) { | 2272 | index = res_patch_table[0].io_reg_table[j].index; |
2301 | index = | 2273 | port = res_patch_table[0].io_reg_table[j].port; |
2302 | res_patch_table[i]. | 2274 | value = res_patch_table[0].io_reg_table[j].value; |
2303 | io_reg_table[j].index; | 2275 | mask = res_patch_table[0].io_reg_table[j].mask; |
2304 | port = | 2276 | viafb_write_reg_mask(index, port, value, mask); |
2305 | res_patch_table[i]. | ||
2306 | io_reg_table[j].port; | ||
2307 | value = | ||
2308 | res_patch_table[i]. | ||
2309 | io_reg_table[j].value; | ||
2310 | mask = | ||
2311 | res_patch_table[i]. | ||
2312 | io_reg_table[j].mask; | ||
2313 | viafb_write_reg_mask(index, port, value, | ||
2314 | mask); | ||
2315 | } | ||
2316 | } | ||
2317 | } | ||
2318 | } | ||
2319 | |||
2320 | if (viafb_SAMM_ON == 1) { | ||
2321 | if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) | ||
2322 | || (viaparinfo->chip_info->gfx_chip_name == | ||
2323 | UNICHROME_K400)) { | ||
2324 | for (i = 0; i < NUM_TOTAL_PATCH_MODE; i++) { | ||
2325 | if (res_patch_table[i].mode_index == | ||
2326 | vmode_index1) { | ||
2327 | for (j = 0; | ||
2328 | j < | ||
2329 | res_patch_table[i]. | ||
2330 | table_length; j++) { | ||
2331 | index = | ||
2332 | res_patch_table[i]. | ||
2333 | io_reg_table[j].index; | ||
2334 | port = | ||
2335 | res_patch_table[i]. | ||
2336 | io_reg_table[j].port; | ||
2337 | value = | ||
2338 | res_patch_table[i]. | ||
2339 | io_reg_table[j].value; | ||
2340 | mask = | ||
2341 | res_patch_table[i]. | ||
2342 | io_reg_table[j].mask; | ||
2343 | viafb_write_reg_mask(index, | ||
2344 | port, value, mask); | ||
2345 | } | ||
2346 | } | ||
2347 | } | ||
2348 | } | 2277 | } |
2349 | } | 2278 | } |
2350 | 2279 | ||
2351 | viafb_set_primary_pitch(viafbinfo->fix.line_length); | 2280 | viafb_set_primary_pitch(viafbinfo->fix.line_length); |
2352 | viafb_set_secondary_pitch(viafb_dual_fb ? viafbinfo1->fix.line_length | 2281 | viafb_set_secondary_pitch(viafb_dual_fb ? viafbinfo1->fix.line_length |
2353 | : viafbinfo->fix.line_length); | 2282 | : viafbinfo->fix.line_length); |
2283 | viafb_set_primary_color_depth(viaparinfo->depth); | ||
2284 | viafb_set_secondary_color_depth(viafb_dual_fb ? viaparinfo1->depth | ||
2285 | : viaparinfo->depth); | ||
2354 | /* Update Refresh Rate Setting */ | 2286 | /* Update Refresh Rate Setting */ |
2355 | 2287 | ||
2356 | /* Clear On Screen */ | 2288 | /* Clear On Screen */ |
@@ -2359,11 +2291,11 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp, | |||
2359 | if (viafb_CRT_ON) { | 2291 | if (viafb_CRT_ON) { |
2360 | if (viafb_SAMM_ON && (viaparinfo->crt_setting_info->iga_path == | 2292 | if (viafb_SAMM_ON && (viaparinfo->crt_setting_info->iga_path == |
2361 | IGA2)) { | 2293 | IGA2)) { |
2362 | viafb_fill_crtc_timing(crt_timing1, vmode_index1, | 2294 | viafb_fill_crtc_timing(crt_timing1, vmode_tbl1, |
2363 | video_bpp1 / 8, | 2295 | video_bpp1 / 8, |
2364 | viaparinfo->crt_setting_info->iga_path); | 2296 | viaparinfo->crt_setting_info->iga_path); |
2365 | } else { | 2297 | } else { |
2366 | viafb_fill_crtc_timing(crt_timing, vmode_index, | 2298 | viafb_fill_crtc_timing(crt_timing, vmode_tbl, |
2367 | video_bpp / 8, | 2299 | video_bpp / 8, |
2368 | viaparinfo->crt_setting_info->iga_path); | 2300 | viaparinfo->crt_setting_info->iga_path); |
2369 | } | 2301 | } |
@@ -2373,7 +2305,7 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp, | |||
2373 | /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode | 2305 | /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode |
2374 | to 8 alignment (1368),there is several pixels (2 pixels) | 2306 | to 8 alignment (1368),there is several pixels (2 pixels) |
2375 | on right side of screen. */ | 2307 | on right side of screen. */ |
2376 | if (hor_res % 8) { | 2308 | if (vmode_tbl->crtc[0].crtc.hor_addr % 8) { |
2377 | viafb_unlock_crt(); | 2309 | viafb_unlock_crt(); |
2378 | viafb_write_reg(CR02, VIACR, | 2310 | viafb_write_reg(CR02, VIACR, |
2379 | viafb_read_reg(VIACR, CR02) - 1); | 2311 | viafb_read_reg(VIACR, CR02) - 1); |
@@ -2384,14 +2316,14 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp, | |||
2384 | if (viafb_DVI_ON) { | 2316 | if (viafb_DVI_ON) { |
2385 | if (viafb_SAMM_ON && | 2317 | if (viafb_SAMM_ON && |
2386 | (viaparinfo->tmds_setting_info->iga_path == IGA2)) { | 2318 | (viaparinfo->tmds_setting_info->iga_path == IGA2)) { |
2387 | viafb_dvi_set_mode(viafb_get_mode_index | 2319 | viafb_dvi_set_mode(viafb_get_mode |
2388 | (viaparinfo->tmds_setting_info->h_active, | 2320 | (viaparinfo->tmds_setting_info->h_active, |
2389 | viaparinfo->tmds_setting_info-> | 2321 | viaparinfo->tmds_setting_info-> |
2390 | v_active), | 2322 | v_active), |
2391 | video_bpp1, viaparinfo-> | 2323 | video_bpp1, viaparinfo-> |
2392 | tmds_setting_info->iga_path); | 2324 | tmds_setting_info->iga_path); |
2393 | } else { | 2325 | } else { |
2394 | viafb_dvi_set_mode(viafb_get_mode_index | 2326 | viafb_dvi_set_mode(viafb_get_mode |
2395 | (viaparinfo->tmds_setting_info->h_active, | 2327 | (viaparinfo->tmds_setting_info->h_active, |
2396 | viaparinfo-> | 2328 | viaparinfo-> |
2397 | tmds_setting_info->v_active), | 2329 | tmds_setting_info->v_active), |
@@ -2445,8 +2377,8 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp, | |||
2445 | 2377 | ||
2446 | /* If set mode normally, save resolution information for hot-plug . */ | 2378 | /* If set mode normally, save resolution information for hot-plug . */ |
2447 | if (!viafb_hotplug) { | 2379 | if (!viafb_hotplug) { |
2448 | viafb_hotplug_Xres = hor_res; | 2380 | viafb_hotplug_Xres = vmode_tbl->crtc[0].crtc.hor_addr; |
2449 | viafb_hotplug_Yres = ver_res; | 2381 | viafb_hotplug_Yres = vmode_tbl->crtc[0].crtc.ver_addr; |
2450 | viafb_hotplug_bpp = video_bpp; | 2382 | viafb_hotplug_bpp = video_bpp; |
2451 | viafb_hotplug_refresh = viafb_refresh; | 2383 | viafb_hotplug_refresh = viafb_refresh; |
2452 | 2384 | ||
@@ -2706,13 +2638,11 @@ void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ | |||
2706 | 2638 | ||
2707 | /*According var's xres, yres fill var's other timing information*/ | 2639 | /*According var's xres, yres fill var's other timing information*/ |
2708 | void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, | 2640 | void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, |
2709 | int mode_index) | 2641 | struct VideoModeTable *vmode_tbl) |
2710 | { | 2642 | { |
2711 | struct VideoModeTable *vmode_tbl = NULL; | ||
2712 | struct crt_mode_table *crt_timing = NULL; | 2643 | struct crt_mode_table *crt_timing = NULL; |
2713 | struct display_timing crt_reg; | 2644 | struct display_timing crt_reg; |
2714 | int i = 0, index = 0; | 2645 | int i = 0, index = 0; |
2715 | vmode_tbl = &CLE266Modes[search_mode_setting(mode_index)]; | ||
2716 | crt_timing = vmode_tbl->crtc; | 2646 | crt_timing = vmode_tbl->crtc; |
2717 | for (i = 0; i < vmode_tbl->mode_array; i++) { | 2647 | for (i = 0; i < vmode_tbl->mode_array; i++) { |
2718 | index = i; | 2648 | index = i; |
@@ -2721,36 +2651,6 @@ void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, | |||
2721 | } | 2651 | } |
2722 | 2652 | ||
2723 | crt_reg = crt_timing[index].crtc; | 2653 | crt_reg = crt_timing[index].crtc; |
2724 | switch (var->bits_per_pixel) { | ||
2725 | case 8: | ||
2726 | var->red.offset = 0; | ||
2727 | var->green.offset = 0; | ||
2728 | var->blue.offset = 0; | ||
2729 | var->red.length = 6; | ||
2730 | var->green.length = 6; | ||
2731 | var->blue.length = 6; | ||
2732 | break; | ||
2733 | case 16: | ||
2734 | var->red.offset = 11; | ||
2735 | var->green.offset = 5; | ||
2736 | var->blue.offset = 0; | ||
2737 | var->red.length = 5; | ||
2738 | var->green.length = 6; | ||
2739 | var->blue.length = 5; | ||
2740 | break; | ||
2741 | case 32: | ||
2742 | var->red.offset = 16; | ||
2743 | var->green.offset = 8; | ||
2744 | var->blue.offset = 0; | ||
2745 | var->red.length = 8; | ||
2746 | var->green.length = 8; | ||
2747 | var->blue.length = 8; | ||
2748 | break; | ||
2749 | default: | ||
2750 | /* never happed, put here to keep consistent */ | ||
2751 | break; | ||
2752 | } | ||
2753 | |||
2754 | var->pixclock = viafb_get_pixclock(var->xres, var->yres, refresh); | 2654 | var->pixclock = viafb_get_pixclock(var->xres, var->yres, refresh); |
2755 | var->left_margin = | 2655 | var->left_margin = |
2756 | crt_reg.hor_total - (crt_reg.hor_sync_start + crt_reg.hor_sync_end); | 2656 | crt_reg.hor_total - (crt_reg.hor_sync_start + crt_reg.hor_sync_end); |
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h index b874d952b446..12ef32d334cb 100644 --- a/drivers/video/via/hw.h +++ b/drivers/video/via/hw.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #ifndef __HW_H__ | 22 | #ifndef __HW_H__ |
23 | #define __HW_H__ | 23 | #define __HW_H__ |
24 | 24 | ||
25 | #include "viamode.h" | ||
25 | #include "global.h" | 26 | #include "global.h" |
26 | 27 | ||
27 | /*************************************************** | 28 | /*************************************************** |
@@ -862,8 +863,6 @@ struct pci_device_id_info { | |||
862 | }; | 863 | }; |
863 | 864 | ||
864 | extern unsigned int viafb_second_virtual_xres; | 865 | extern unsigned int viafb_second_virtual_xres; |
865 | extern unsigned int viafb_second_offset; | ||
866 | extern int viafb_second_size; | ||
867 | extern int viafb_SAMM_ON; | 866 | extern int viafb_SAMM_ON; |
868 | extern int viafb_dual_fb; | 867 | extern int viafb_dual_fb; |
869 | extern int viafb_LCD2_ON; | 868 | extern int viafb_LCD2_ON; |
@@ -874,8 +873,9 @@ extern int viafb_hotplug; | |||
874 | void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask); | 873 | void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask); |
875 | void viafb_set_output_path(int device, int set_iga, | 874 | void viafb_set_output_path(int device, int set_iga, |
876 | int output_interface); | 875 | int output_interface); |
876 | |||
877 | void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | 877 | void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, |
878 | int mode_index, int bpp_byte, int set_iga); | 878 | struct VideoModeTable *video_mode, int bpp_byte, int set_iga); |
879 | 879 | ||
880 | void viafb_set_vclock(u32 CLK, int set_iga); | 880 | void viafb_set_vclock(u32 CLK, int set_iga); |
881 | void viafb_load_reg(int timing_value, int viafb_load_reg_num, | 881 | void viafb_load_reg(int timing_value, int viafb_load_reg_num, |
@@ -891,16 +891,15 @@ void viafb_lock_crt(void); | |||
891 | void viafb_unlock_crt(void); | 891 | void viafb_unlock_crt(void); |
892 | void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga); | 892 | void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga); |
893 | void viafb_write_regx(struct io_reg RegTable[], int ItemNum); | 893 | void viafb_write_regx(struct io_reg RegTable[], int ItemNum); |
894 | struct VideoModeTable *viafb_get_modetbl_pointer(int Index); | ||
895 | u32 viafb_get_clk_value(int clk); | 894 | u32 viafb_get_clk_value(int clk); |
896 | void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active); | 895 | void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active); |
897 | void viafb_set_color_depth(int bpp_byte, int set_iga); | ||
898 | void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ | 896 | void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ |
899 | *p_gfx_dpa_setting); | 897 | *p_gfx_dpa_setting); |
900 | 898 | ||
901 | int viafb_setmode(int vmode_index, int hor_res, int ver_res, | 899 | int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp, |
902 | int video_bpp, int vmode_index1, int hor_res1, | 900 | struct VideoModeTable *vmode_tbl1, int video_bpp1); |
903 | int ver_res1, int video_bpp1); | 901 | void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, |
902 | struct VideoModeTable *vmode_tbl); | ||
904 | void viafb_init_chip_info(struct pci_dev *pdev, | 903 | void viafb_init_chip_info(struct pci_dev *pdev, |
905 | const struct pci_device_id *pdi); | 904 | const struct pci_device_id *pdi); |
906 | void viafb_init_dac(int set_iga); | 905 | void viafb_init_dac(int set_iga); |
@@ -915,6 +914,8 @@ void viafb_set_primary_address(u32 addr); | |||
915 | void viafb_set_secondary_address(u32 addr); | 914 | void viafb_set_secondary_address(u32 addr); |
916 | void viafb_set_primary_pitch(u32 pitch); | 915 | void viafb_set_primary_pitch(u32 pitch); |
917 | void viafb_set_secondary_pitch(u32 pitch); | 916 | void viafb_set_secondary_pitch(u32 pitch); |
917 | void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue); | ||
918 | void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue); | ||
918 | void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len); | 919 | void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len); |
919 | 920 | ||
920 | #endif /* __HW_H__ */ | 921 | #endif /* __HW_H__ */ |
diff --git a/drivers/video/via/iface.c b/drivers/video/via/iface.c deleted file mode 100644 index 1570636c8d51..000000000000 --- a/drivers/video/via/iface.c +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include "global.h" | ||
23 | |||
24 | /* Get frame buffer size from VGA BIOS */ | ||
25 | |||
26 | unsigned int viafb_get_memsize(void) | ||
27 | { | ||
28 | unsigned int m; | ||
29 | |||
30 | /* If memory size provided by user */ | ||
31 | if (viafb_memsize) | ||
32 | m = viafb_memsize * Mb; | ||
33 | else { | ||
34 | m = (unsigned int)viafb_read_reg(VIASR, SR39); | ||
35 | m = m * (4 * Mb); | ||
36 | |||
37 | if ((m < (16 * Mb)) || (m > (64 * Mb))) | ||
38 | m = 16 * Mb; | ||
39 | } | ||
40 | DEBUG_MSG(KERN_INFO "framebuffer size = %d Mb\n", m / Mb); | ||
41 | return m; | ||
42 | } | ||
43 | |||
44 | /* Get Video Buffer Starting Physical Address(back door)*/ | ||
45 | |||
46 | unsigned long viafb_get_videobuf_addr(void) | ||
47 | { | ||
48 | struct pci_dev *pdev = NULL; | ||
49 | unsigned char sys_mem; | ||
50 | unsigned char video_mem; | ||
51 | unsigned long sys_mem_size; | ||
52 | unsigned long video_mem_size; | ||
53 | /*system memory = 256 MB, video memory 64 MB */ | ||
54 | unsigned long vmem_starting_adr = 0x0C000000; | ||
55 | |||
56 | pdev = | ||
57 | (struct pci_dev *)pci_get_device(VIA_K800_BRIDGE_VID, | ||
58 | VIA_K800_BRIDGE_DID, NULL); | ||
59 | if (pdev != NULL) { | ||
60 | pci_read_config_byte(pdev, VIA_K800_SYSTEM_MEMORY_REG, | ||
61 | &sys_mem); | ||
62 | pci_read_config_byte(pdev, VIA_K800_VIDEO_MEMORY_REG, | ||
63 | &video_mem); | ||
64 | video_mem = (video_mem & 0x70) >> 4; | ||
65 | sys_mem_size = ((unsigned long)sys_mem) << 24; | ||
66 | if (video_mem != 0) | ||
67 | video_mem_size = (1 << (video_mem)) * 1024 * 1024; | ||
68 | else | ||
69 | video_mem_size = 0; | ||
70 | |||
71 | vmem_starting_adr = sys_mem_size - video_mem_size; | ||
72 | pci_dev_put(pdev); | ||
73 | } | ||
74 | |||
75 | DEBUG_MSG(KERN_INFO "Video Memory Starting Address = %lx \n", | ||
76 | vmem_starting_adr); | ||
77 | return vmem_starting_adr; | ||
78 | } | ||
diff --git a/drivers/video/via/iface.h b/drivers/video/via/iface.h deleted file mode 100644 index 790ec3e3aea2..000000000000 --- a/drivers/video/via/iface.h +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef __IFACE_H__ | ||
23 | #define __IFACE_H__ | ||
24 | |||
25 | #define Kb (1024) | ||
26 | #define Mb (Kb*Kb) | ||
27 | |||
28 | #define VIA_K800_BRIDGE_VID 0x1106 | ||
29 | #define VIA_K800_BRIDGE_DID 0x3204 | ||
30 | |||
31 | #define VIA_K800_SYSTEM_MEMORY_REG 0x47 | ||
32 | #define VIA_K800_VIDEO_MEMORY_REG 0xA1 | ||
33 | |||
34 | extern int viafb_memsize; | ||
35 | unsigned int viafb_get_memsize(void); | ||
36 | unsigned long viafb_get_videobuf_addr(void); | ||
37 | |||
38 | #endif /* __IFACE_H__ */ | ||
diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c index 09353e2b92f6..1b1ccdc2d83d 100644 --- a/drivers/video/via/lcd.c +++ b/drivers/video/via/lcd.c | |||
@@ -22,25 +22,7 @@ | |||
22 | #include "global.h" | 22 | #include "global.h" |
23 | #include "lcdtbl.h" | 23 | #include "lcdtbl.h" |
24 | 24 | ||
25 | static struct iga2_shadow_crtc_timing iga2_shadow_crtc_reg = { | 25 | #define viafb_compact_res(x, y) (((x)<<16)|(y)) |
26 | /* IGA2 Shadow Horizontal Total */ | ||
27 | {IGA2_SHADOW_HOR_TOTAL_REG_NUM, {{CR6D, 0, 7}, {CR71, 3, 3} } }, | ||
28 | /* IGA2 Shadow Horizontal Blank End */ | ||
29 | {IGA2_SHADOW_HOR_BLANK_END_REG_NUM, {{CR6E, 0, 7} } }, | ||
30 | /* IGA2 Shadow Vertical Total */ | ||
31 | {IGA2_SHADOW_VER_TOTAL_REG_NUM, {{CR6F, 0, 7}, {CR71, 0, 2} } }, | ||
32 | /* IGA2 Shadow Vertical Addressable Video */ | ||
33 | {IGA2_SHADOW_VER_ADDR_REG_NUM, {{CR70, 0, 7}, {CR71, 4, 6} } }, | ||
34 | /* IGA2 Shadow Vertical Blank Start */ | ||
35 | {IGA2_SHADOW_VER_BLANK_START_REG_NUM, | ||
36 | {{CR72, 0, 7}, {CR74, 4, 6} } }, | ||
37 | /* IGA2 Shadow Vertical Blank End */ | ||
38 | {IGA2_SHADOW_VER_BLANK_END_REG_NUM, {{CR73, 0, 7}, {CR74, 0, 2} } }, | ||
39 | /* IGA2 Shadow Vertical Sync Start */ | ||
40 | {IGA2_SHADOW_VER_SYNC_START_REG_NUM, {{CR75, 0, 7}, {CR76, 4, 6} } }, | ||
41 | /* IGA2 Shadow Vertical Sync End */ | ||
42 | {IGA2_SHADOW_VER_SYNC_END_REG_NUM, {{CR76, 0, 3} } } | ||
43 | }; | ||
44 | 26 | ||
45 | static struct _lcd_scaling_factor lcd_scaling_factor = { | 27 | static struct _lcd_scaling_factor lcd_scaling_factor = { |
46 | /* LCD Horizontal Scaling Factor Register */ | 28 | /* LCD Horizontal Scaling Factor Register */ |
@@ -59,16 +41,10 @@ static struct _lcd_scaling_factor lcd_scaling_factor_CLE = { | |||
59 | 41 | ||
60 | static int check_lvds_chip(int device_id_subaddr, int device_id); | 42 | static int check_lvds_chip(int device_id_subaddr, int device_id); |
61 | static bool lvds_identify_integratedlvds(void); | 43 | static bool lvds_identify_integratedlvds(void); |
62 | static int fp_id_to_vindex(int panel_id); | 44 | static void fp_id_to_vindex(int panel_id); |
63 | static int lvds_register_read(int index); | 45 | static int lvds_register_read(int index); |
64 | static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, | 46 | static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, |
65 | int panel_vres); | 47 | int panel_vres); |
66 | static void load_lcd_k400_patch_tbl(int set_hres, int set_vres, | ||
67 | int panel_id); | ||
68 | static void load_lcd_p880_patch_tbl(int set_hres, int set_vres, | ||
69 | int panel_id); | ||
70 | static void load_lcd_patch_regs(int set_hres, int set_vres, | ||
71 | int panel_id, int set_iga); | ||
72 | static void via_pitch_alignment_patch_lcd( | 48 | static void via_pitch_alignment_patch_lcd( |
73 | struct lvds_setting_information *plvds_setting_info, | 49 | struct lvds_setting_information *plvds_setting_info, |
74 | struct lvds_chip_information | 50 | struct lvds_chip_information |
@@ -98,8 +74,6 @@ static void check_diport_of_integrated_lvds( | |||
98 | static struct display_timing lcd_centering_timging(struct display_timing | 74 | static struct display_timing lcd_centering_timging(struct display_timing |
99 | mode_crt_reg, | 75 | mode_crt_reg, |
100 | struct display_timing panel_crt_reg); | 76 | struct display_timing panel_crt_reg); |
101 | static void load_crtc_shadow_timing(struct display_timing mode_timing, | ||
102 | struct display_timing panel_timing); | ||
103 | static void viafb_load_scaling_factor_for_p4m900(int set_hres, | 77 | static void viafb_load_scaling_factor_for_p4m900(int set_hres, |
104 | int set_vres, int panel_hres, int panel_vres); | 78 | int set_vres, int panel_hres, int panel_vres); |
105 | 79 | ||
@@ -125,33 +99,24 @@ void viafb_init_lcd_size(void) | |||
125 | break; | 99 | break; |
126 | case GET_LCD_SIZE_BY_VGA_BIOS: | 100 | case GET_LCD_SIZE_BY_VGA_BIOS: |
127 | DEBUG_MSG(KERN_INFO "Get LCD Size method by VGA BIOS !!\n"); | 101 | DEBUG_MSG(KERN_INFO "Get LCD Size method by VGA BIOS !!\n"); |
128 | viaparinfo->lvds_setting_info->lcd_panel_size = | 102 | fp_id_to_vindex(viafb_lcd_panel_id); |
129 | fp_id_to_vindex(viafb_lcd_panel_id); | ||
130 | DEBUG_MSG(KERN_INFO "LCD Panel_ID = %d\n", | 103 | DEBUG_MSG(KERN_INFO "LCD Panel_ID = %d\n", |
131 | viaparinfo->lvds_setting_info->lcd_panel_id); | 104 | viaparinfo->lvds_setting_info->lcd_panel_id); |
132 | DEBUG_MSG(KERN_INFO "LCD Panel Size = %d\n", | ||
133 | viaparinfo->lvds_setting_info->lcd_panel_size); | ||
134 | break; | 105 | break; |
135 | case GET_LCD_SIZE_BY_USER_SETTING: | 106 | case GET_LCD_SIZE_BY_USER_SETTING: |
136 | DEBUG_MSG(KERN_INFO "Get LCD Size method by user setting !!\n"); | 107 | DEBUG_MSG(KERN_INFO "Get LCD Size method by user setting !!\n"); |
137 | viaparinfo->lvds_setting_info->lcd_panel_size = | 108 | fp_id_to_vindex(viafb_lcd_panel_id); |
138 | fp_id_to_vindex(viafb_lcd_panel_id); | ||
139 | DEBUG_MSG(KERN_INFO "LCD Panel_ID = %d\n", | 109 | DEBUG_MSG(KERN_INFO "LCD Panel_ID = %d\n", |
140 | viaparinfo->lvds_setting_info->lcd_panel_id); | 110 | viaparinfo->lvds_setting_info->lcd_panel_id); |
141 | DEBUG_MSG(KERN_INFO "LCD Panel Size = %d\n", | ||
142 | viaparinfo->lvds_setting_info->lcd_panel_size); | ||
143 | break; | 111 | break; |
144 | default: | 112 | default: |
145 | DEBUG_MSG(KERN_INFO "viafb_init_lcd_size fail\n"); | 113 | DEBUG_MSG(KERN_INFO "viafb_init_lcd_size fail\n"); |
146 | viaparinfo->lvds_setting_info->lcd_panel_id = | 114 | viaparinfo->lvds_setting_info->lcd_panel_id = |
147 | LCD_PANEL_ID1_800X600; | 115 | LCD_PANEL_ID1_800X600; |
148 | viaparinfo->lvds_setting_info->lcd_panel_size = | 116 | fp_id_to_vindex(LCD_PANEL_ID1_800X600); |
149 | fp_id_to_vindex(LCD_PANEL_ID1_800X600); | ||
150 | } | 117 | } |
151 | viaparinfo->lvds_setting_info2->lcd_panel_id = | 118 | viaparinfo->lvds_setting_info2->lcd_panel_id = |
152 | viaparinfo->lvds_setting_info->lcd_panel_id; | 119 | viaparinfo->lvds_setting_info->lcd_panel_id; |
153 | viaparinfo->lvds_setting_info2->lcd_panel_size = | ||
154 | viaparinfo->lvds_setting_info->lcd_panel_size; | ||
155 | viaparinfo->lvds_setting_info2->lcd_panel_hres = | 120 | viaparinfo->lvds_setting_info2->lcd_panel_hres = |
156 | viaparinfo->lvds_setting_info->lcd_panel_hres; | 121 | viaparinfo->lvds_setting_info->lcd_panel_hres; |
157 | viaparinfo->lvds_setting_info2->lcd_panel_vres = | 122 | viaparinfo->lvds_setting_info2->lcd_panel_vres = |
@@ -171,13 +136,13 @@ static bool lvds_identify_integratedlvds(void) | |||
171 | if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { | 136 | if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { |
172 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name = | 137 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name = |
173 | INTEGRATED_LVDS; | 138 | INTEGRATED_LVDS; |
174 | DEBUG_MSG(KERN_INFO "Support two dual channel LVDS!\ | 139 | DEBUG_MSG(KERN_INFO "Support two dual channel LVDS! " |
175 | (Internal LVDS + External LVDS)\n"); | 140 | "(Internal LVDS + External LVDS)\n"); |
176 | } else { | 141 | } else { |
177 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = | 142 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = |
178 | INTEGRATED_LVDS; | 143 | INTEGRATED_LVDS; |
179 | DEBUG_MSG(KERN_INFO "Not found external LVDS,\ | 144 | DEBUG_MSG(KERN_INFO "Not found external LVDS, " |
180 | so can't support two dual channel LVDS!\n"); | 145 | "so can't support two dual channel LVDS!\n"); |
181 | } | 146 | } |
182 | } else if (viafb_display_hardware_layout == HW_LAYOUT_LCD1_LCD2) { | 147 | } else if (viafb_display_hardware_layout == HW_LAYOUT_LCD1_LCD2) { |
183 | /* Two single channel LCD (Internal LVDS + Internal LVDS): */ | 148 | /* Two single channel LCD (Internal LVDS + Internal LVDS): */ |
@@ -185,8 +150,8 @@ static bool lvds_identify_integratedlvds(void) | |||
185 | INTEGRATED_LVDS; | 150 | INTEGRATED_LVDS; |
186 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name = | 151 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name = |
187 | INTEGRATED_LVDS; | 152 | INTEGRATED_LVDS; |
188 | DEBUG_MSG(KERN_INFO "Support two single channel LVDS!\ | 153 | DEBUG_MSG(KERN_INFO "Support two single channel LVDS! " |
189 | (Internal LVDS + Internal LVDS)\n"); | 154 | "(Internal LVDS + Internal LVDS)\n"); |
190 | } else if (viafb_display_hardware_layout != HW_LAYOUT_DVI_ONLY) { | 155 | } else if (viafb_display_hardware_layout != HW_LAYOUT_DVI_ONLY) { |
191 | /* If we have found external LVDS, just use it, | 156 | /* If we have found external LVDS, just use it, |
192 | otherwise, we will use internal LVDS as default. */ | 157 | otherwise, we will use internal LVDS as default. */ |
@@ -248,7 +213,7 @@ int viafb_lvds_trasmitter_identify(void) | |||
248 | return FAIL; | 213 | return FAIL; |
249 | } | 214 | } |
250 | 215 | ||
251 | static int fp_id_to_vindex(int panel_id) | 216 | static void fp_id_to_vindex(int panel_id) |
252 | { | 217 | { |
253 | DEBUG_MSG(KERN_INFO "fp_get_panel_id()\n"); | 218 | DEBUG_MSG(KERN_INFO "fp_get_panel_id()\n"); |
254 | 219 | ||
@@ -264,7 +229,6 @@ static int fp_id_to_vindex(int panel_id) | |||
264 | LCD_PANEL_ID0_640X480; | 229 | LCD_PANEL_ID0_640X480; |
265 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 230 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
266 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 231 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
267 | return VIA_RES_640X480; | ||
268 | break; | 232 | break; |
269 | case 0x1: | 233 | case 0x1: |
270 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; | 234 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; |
@@ -273,7 +237,6 @@ static int fp_id_to_vindex(int panel_id) | |||
273 | LCD_PANEL_ID1_800X600; | 237 | LCD_PANEL_ID1_800X600; |
274 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 238 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
275 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 239 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
276 | return VIA_RES_800X600; | ||
277 | break; | 240 | break; |
278 | case 0x2: | 241 | case 0x2: |
279 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; | 242 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
@@ -282,7 +245,6 @@ static int fp_id_to_vindex(int panel_id) | |||
282 | LCD_PANEL_ID2_1024X768; | 245 | LCD_PANEL_ID2_1024X768; |
283 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 246 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
284 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 247 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
285 | return VIA_RES_1024X768; | ||
286 | break; | 248 | break; |
287 | case 0x3: | 249 | case 0x3: |
288 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; | 250 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
@@ -291,7 +253,6 @@ static int fp_id_to_vindex(int panel_id) | |||
291 | LCD_PANEL_ID3_1280X768; | 253 | LCD_PANEL_ID3_1280X768; |
292 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 254 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
293 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 255 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
294 | return VIA_RES_1280X768; | ||
295 | break; | 256 | break; |
296 | case 0x4: | 257 | case 0x4: |
297 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; | 258 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
@@ -300,7 +261,6 @@ static int fp_id_to_vindex(int panel_id) | |||
300 | LCD_PANEL_ID4_1280X1024; | 261 | LCD_PANEL_ID4_1280X1024; |
301 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 262 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
302 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 263 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
303 | return VIA_RES_1280X1024; | ||
304 | break; | 264 | break; |
305 | case 0x5: | 265 | case 0x5: |
306 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1400; | 266 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1400; |
@@ -309,7 +269,6 @@ static int fp_id_to_vindex(int panel_id) | |||
309 | LCD_PANEL_ID5_1400X1050; | 269 | LCD_PANEL_ID5_1400X1050; |
310 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 270 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
311 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 271 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
312 | return VIA_RES_1400X1050; | ||
313 | break; | 272 | break; |
314 | case 0x6: | 273 | case 0x6: |
315 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1600; | 274 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1600; |
@@ -318,7 +277,6 @@ static int fp_id_to_vindex(int panel_id) | |||
318 | LCD_PANEL_ID6_1600X1200; | 277 | LCD_PANEL_ID6_1600X1200; |
319 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 278 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
320 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 279 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
321 | return VIA_RES_1600X1200; | ||
322 | break; | 280 | break; |
323 | case 0x8: | 281 | case 0x8: |
324 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; | 282 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; |
@@ -327,7 +285,6 @@ static int fp_id_to_vindex(int panel_id) | |||
327 | LCD_PANEL_IDA_800X480; | 285 | LCD_PANEL_IDA_800X480; |
328 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 286 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
329 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 287 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
330 | return VIA_RES_800X480; | ||
331 | break; | 288 | break; |
332 | case 0x9: | 289 | case 0x9: |
333 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; | 290 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
@@ -336,7 +293,6 @@ static int fp_id_to_vindex(int panel_id) | |||
336 | LCD_PANEL_ID2_1024X768; | 293 | LCD_PANEL_ID2_1024X768; |
337 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 294 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
338 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 295 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
339 | return VIA_RES_1024X768; | ||
340 | break; | 296 | break; |
341 | case 0xA: | 297 | case 0xA: |
342 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; | 298 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
@@ -345,7 +301,6 @@ static int fp_id_to_vindex(int panel_id) | |||
345 | LCD_PANEL_ID2_1024X768; | 301 | LCD_PANEL_ID2_1024X768; |
346 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 302 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
347 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 303 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
348 | return VIA_RES_1024X768; | ||
349 | break; | 304 | break; |
350 | case 0xB: | 305 | case 0xB: |
351 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; | 306 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
@@ -354,7 +309,6 @@ static int fp_id_to_vindex(int panel_id) | |||
354 | LCD_PANEL_ID2_1024X768; | 309 | LCD_PANEL_ID2_1024X768; |
355 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 310 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
356 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 311 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
357 | return VIA_RES_1024X768; | ||
358 | break; | 312 | break; |
359 | case 0xC: | 313 | case 0xC: |
360 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; | 314 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
@@ -363,7 +317,6 @@ static int fp_id_to_vindex(int panel_id) | |||
363 | LCD_PANEL_ID3_1280X768; | 317 | LCD_PANEL_ID3_1280X768; |
364 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 318 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
365 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 319 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
366 | return VIA_RES_1280X768; | ||
367 | break; | 320 | break; |
368 | case 0xD: | 321 | case 0xD: |
369 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; | 322 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
@@ -372,7 +325,6 @@ static int fp_id_to_vindex(int panel_id) | |||
372 | LCD_PANEL_ID4_1280X1024; | 325 | LCD_PANEL_ID4_1280X1024; |
373 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 326 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
374 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 327 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
375 | return VIA_RES_1280X1024; | ||
376 | break; | 328 | break; |
377 | case 0xE: | 329 | case 0xE: |
378 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1400; | 330 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1400; |
@@ -381,7 +333,6 @@ static int fp_id_to_vindex(int panel_id) | |||
381 | LCD_PANEL_ID5_1400X1050; | 333 | LCD_PANEL_ID5_1400X1050; |
382 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 334 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
383 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 335 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
384 | return VIA_RES_1400X1050; | ||
385 | break; | 336 | break; |
386 | case 0xF: | 337 | case 0xF: |
387 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1600; | 338 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1600; |
@@ -390,7 +341,6 @@ static int fp_id_to_vindex(int panel_id) | |||
390 | LCD_PANEL_ID6_1600X1200; | 341 | LCD_PANEL_ID6_1600X1200; |
391 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 342 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
392 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 343 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
393 | return VIA_RES_1600X1200; | ||
394 | break; | 344 | break; |
395 | case 0x10: | 345 | case 0x10: |
396 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1366; | 346 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1366; |
@@ -399,7 +349,6 @@ static int fp_id_to_vindex(int panel_id) | |||
399 | LCD_PANEL_ID7_1366X768; | 349 | LCD_PANEL_ID7_1366X768; |
400 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 350 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
401 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 351 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
402 | return VIA_RES_1368X768; | ||
403 | break; | 352 | break; |
404 | case 0x11: | 353 | case 0x11: |
405 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; | 354 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
@@ -408,7 +357,6 @@ static int fp_id_to_vindex(int panel_id) | |||
408 | LCD_PANEL_ID8_1024X600; | 357 | LCD_PANEL_ID8_1024X600; |
409 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 358 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
410 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 359 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
411 | return VIA_RES_1024X600; | ||
412 | break; | 360 | break; |
413 | case 0x12: | 361 | case 0x12: |
414 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; | 362 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
@@ -417,7 +365,6 @@ static int fp_id_to_vindex(int panel_id) | |||
417 | LCD_PANEL_ID3_1280X768; | 365 | LCD_PANEL_ID3_1280X768; |
418 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 366 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
419 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 367 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
420 | return VIA_RES_1280X768; | ||
421 | break; | 368 | break; |
422 | case 0x13: | 369 | case 0x13: |
423 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; | 370 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
@@ -426,7 +373,6 @@ static int fp_id_to_vindex(int panel_id) | |||
426 | LCD_PANEL_ID9_1280X800; | 373 | LCD_PANEL_ID9_1280X800; |
427 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 374 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
428 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 375 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
429 | return VIA_RES_1280X800; | ||
430 | break; | 376 | break; |
431 | case 0x14: | 377 | case 0x14: |
432 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1360; | 378 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1360; |
@@ -435,7 +381,6 @@ static int fp_id_to_vindex(int panel_id) | |||
435 | LCD_PANEL_IDB_1360X768; | 381 | LCD_PANEL_IDB_1360X768; |
436 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 382 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
437 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 383 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
438 | return VIA_RES_1360X768; | ||
439 | break; | 384 | break; |
440 | case 0x15: | 385 | case 0x15: |
441 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; | 386 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
@@ -444,7 +389,6 @@ static int fp_id_to_vindex(int panel_id) | |||
444 | LCD_PANEL_ID3_1280X768; | 389 | LCD_PANEL_ID3_1280X768; |
445 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; | 390 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
446 | viaparinfo->lvds_setting_info->LCDDithering = 0; | 391 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
447 | return VIA_RES_1280X768; | ||
448 | break; | 392 | break; |
449 | case 0x16: | 393 | case 0x16: |
450 | viaparinfo->lvds_setting_info->lcd_panel_hres = 480; | 394 | viaparinfo->lvds_setting_info->lcd_panel_hres = 480; |
@@ -453,7 +397,6 @@ static int fp_id_to_vindex(int panel_id) | |||
453 | LCD_PANEL_IDC_480X640; | 397 | LCD_PANEL_IDC_480X640; |
454 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 398 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
455 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 399 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
456 | return VIA_RES_480X640; | ||
457 | break; | 400 | break; |
458 | default: | 401 | default: |
459 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; | 402 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; |
@@ -462,7 +405,6 @@ static int fp_id_to_vindex(int panel_id) | |||
462 | LCD_PANEL_ID1_800X600; | 405 | LCD_PANEL_ID1_800X600; |
463 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; | 406 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
464 | viaparinfo->lvds_setting_info->LCDDithering = 1; | 407 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
465 | return VIA_RES_800X600; | ||
466 | } | 408 | } |
467 | } | 409 | } |
468 | 410 | ||
@@ -573,284 +515,6 @@ static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, | |||
573 | } | 515 | } |
574 | } | 516 | } |
575 | 517 | ||
576 | static void load_lcd_k400_patch_tbl(int set_hres, int set_vres, | ||
577 | int panel_id) | ||
578 | { | ||
579 | int vmode_index; | ||
580 | int reg_num = 0; | ||
581 | struct io_reg *lcd_patch_reg = NULL; | ||
582 | |||
583 | vmode_index = viafb_get_mode_index(set_hres, set_vres); | ||
584 | switch (panel_id) { | ||
585 | /* LCD 800x600 */ | ||
586 | case LCD_PANEL_ID1_800X600: | ||
587 | switch (vmode_index) { | ||
588 | case VIA_RES_640X400: | ||
589 | case VIA_RES_640X480: | ||
590 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_8X6; | ||
591 | lcd_patch_reg = K400_LCD_RES_6X4_8X6; | ||
592 | break; | ||
593 | case VIA_RES_720X480: | ||
594 | case VIA_RES_720X576: | ||
595 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_8X6; | ||
596 | lcd_patch_reg = K400_LCD_RES_7X4_8X6; | ||
597 | break; | ||
598 | } | ||
599 | break; | ||
600 | |||
601 | /* LCD 1024x768 */ | ||
602 | case LCD_PANEL_ID2_1024X768: | ||
603 | switch (vmode_index) { | ||
604 | case VIA_RES_640X400: | ||
605 | case VIA_RES_640X480: | ||
606 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_10X7; | ||
607 | lcd_patch_reg = K400_LCD_RES_6X4_10X7; | ||
608 | break; | ||
609 | case VIA_RES_720X480: | ||
610 | case VIA_RES_720X576: | ||
611 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_10X7; | ||
612 | lcd_patch_reg = K400_LCD_RES_7X4_10X7; | ||
613 | break; | ||
614 | case VIA_RES_800X600: | ||
615 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_10X7; | ||
616 | lcd_patch_reg = K400_LCD_RES_8X6_10X7; | ||
617 | break; | ||
618 | } | ||
619 | break; | ||
620 | |||
621 | /* LCD 1280x1024 */ | ||
622 | case LCD_PANEL_ID4_1280X1024: | ||
623 | switch (vmode_index) { | ||
624 | case VIA_RES_640X400: | ||
625 | case VIA_RES_640X480: | ||
626 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_12X10; | ||
627 | lcd_patch_reg = K400_LCD_RES_6X4_12X10; | ||
628 | break; | ||
629 | case VIA_RES_720X480: | ||
630 | case VIA_RES_720X576: | ||
631 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_12X10; | ||
632 | lcd_patch_reg = K400_LCD_RES_7X4_12X10; | ||
633 | break; | ||
634 | case VIA_RES_800X600: | ||
635 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_12X10; | ||
636 | lcd_patch_reg = K400_LCD_RES_8X6_12X10; | ||
637 | break; | ||
638 | case VIA_RES_1024X768: | ||
639 | reg_num = NUM_TOTAL_K400_LCD_RES_10X7_12X10; | ||
640 | lcd_patch_reg = K400_LCD_RES_10X7_12X10; | ||
641 | break; | ||
642 | |||
643 | } | ||
644 | break; | ||
645 | |||
646 | /* LCD 1400x1050 */ | ||
647 | case LCD_PANEL_ID5_1400X1050: | ||
648 | switch (vmode_index) { | ||
649 | case VIA_RES_640X480: | ||
650 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_14X10; | ||
651 | lcd_patch_reg = K400_LCD_RES_6X4_14X10; | ||
652 | break; | ||
653 | case VIA_RES_800X600: | ||
654 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_14X10; | ||
655 | lcd_patch_reg = K400_LCD_RES_8X6_14X10; | ||
656 | break; | ||
657 | case VIA_RES_1024X768: | ||
658 | reg_num = NUM_TOTAL_K400_LCD_RES_10X7_14X10; | ||
659 | lcd_patch_reg = K400_LCD_RES_10X7_14X10; | ||
660 | break; | ||
661 | case VIA_RES_1280X768: | ||
662 | case VIA_RES_1280X800: | ||
663 | case VIA_RES_1280X960: | ||
664 | case VIA_RES_1280X1024: | ||
665 | reg_num = NUM_TOTAL_K400_LCD_RES_12X10_14X10; | ||
666 | lcd_patch_reg = K400_LCD_RES_12X10_14X10; | ||
667 | break; | ||
668 | } | ||
669 | break; | ||
670 | |||
671 | /* LCD 1600x1200 */ | ||
672 | case LCD_PANEL_ID6_1600X1200: | ||
673 | switch (vmode_index) { | ||
674 | case VIA_RES_640X400: | ||
675 | case VIA_RES_640X480: | ||
676 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_16X12; | ||
677 | lcd_patch_reg = K400_LCD_RES_6X4_16X12; | ||
678 | break; | ||
679 | case VIA_RES_720X480: | ||
680 | case VIA_RES_720X576: | ||
681 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_16X12; | ||
682 | lcd_patch_reg = K400_LCD_RES_7X4_16X12; | ||
683 | break; | ||
684 | case VIA_RES_800X600: | ||
685 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_16X12; | ||
686 | lcd_patch_reg = K400_LCD_RES_8X6_16X12; | ||
687 | break; | ||
688 | case VIA_RES_1024X768: | ||
689 | reg_num = NUM_TOTAL_K400_LCD_RES_10X7_16X12; | ||
690 | lcd_patch_reg = K400_LCD_RES_10X7_16X12; | ||
691 | break; | ||
692 | case VIA_RES_1280X768: | ||
693 | case VIA_RES_1280X800: | ||
694 | case VIA_RES_1280X960: | ||
695 | case VIA_RES_1280X1024: | ||
696 | reg_num = NUM_TOTAL_K400_LCD_RES_12X10_16X12; | ||
697 | lcd_patch_reg = K400_LCD_RES_12X10_16X12; | ||
698 | break; | ||
699 | } | ||
700 | break; | ||
701 | |||
702 | /* LCD 1366x768 */ | ||
703 | case LCD_PANEL_ID7_1366X768: | ||
704 | switch (vmode_index) { | ||
705 | case VIA_RES_640X480: | ||
706 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_1366X7; | ||
707 | lcd_patch_reg = K400_LCD_RES_6X4_1366X7; | ||
708 | break; | ||
709 | case VIA_RES_720X480: | ||
710 | case VIA_RES_720X576: | ||
711 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_1366X7; | ||
712 | lcd_patch_reg = K400_LCD_RES_7X4_1366X7; | ||
713 | break; | ||
714 | case VIA_RES_800X600: | ||
715 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_1366X7; | ||
716 | lcd_patch_reg = K400_LCD_RES_8X6_1366X7; | ||
717 | break; | ||
718 | case VIA_RES_1024X768: | ||
719 | reg_num = NUM_TOTAL_K400_LCD_RES_10X7_1366X7; | ||
720 | lcd_patch_reg = K400_LCD_RES_10X7_1366X7; | ||
721 | break; | ||
722 | case VIA_RES_1280X768: | ||
723 | case VIA_RES_1280X800: | ||
724 | case VIA_RES_1280X960: | ||
725 | case VIA_RES_1280X1024: | ||
726 | reg_num = NUM_TOTAL_K400_LCD_RES_12X10_1366X7; | ||
727 | lcd_patch_reg = K400_LCD_RES_12X10_1366X7; | ||
728 | break; | ||
729 | } | ||
730 | break; | ||
731 | |||
732 | /* LCD 1360x768 */ | ||
733 | case LCD_PANEL_IDB_1360X768: | ||
734 | break; | ||
735 | } | ||
736 | if (reg_num != 0) { | ||
737 | /* H.W. Reset : ON */ | ||
738 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); | ||
739 | |||
740 | viafb_write_regx(lcd_patch_reg, reg_num); | ||
741 | |||
742 | /* H.W. Reset : OFF */ | ||
743 | viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); | ||
744 | |||
745 | /* Reset PLL */ | ||
746 | viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); | ||
747 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); | ||
748 | |||
749 | /* Fire! */ | ||
750 | outb(inb(VIARMisc) | (BIT2 + BIT3), VIAWMisc); | ||
751 | } | ||
752 | } | ||
753 | |||
754 | static void load_lcd_p880_patch_tbl(int set_hres, int set_vres, | ||
755 | int panel_id) | ||
756 | { | ||
757 | int vmode_index; | ||
758 | int reg_num = 0; | ||
759 | struct io_reg *lcd_patch_reg = NULL; | ||
760 | |||
761 | vmode_index = viafb_get_mode_index(set_hres, set_vres); | ||
762 | |||
763 | switch (panel_id) { | ||
764 | case LCD_PANEL_ID5_1400X1050: | ||
765 | switch (vmode_index) { | ||
766 | case VIA_RES_640X480: | ||
767 | reg_num = NUM_TOTAL_P880_LCD_RES_6X4_14X10; | ||
768 | lcd_patch_reg = P880_LCD_RES_6X4_14X10; | ||
769 | break; | ||
770 | case VIA_RES_800X600: | ||
771 | reg_num = NUM_TOTAL_P880_LCD_RES_8X6_14X10; | ||
772 | lcd_patch_reg = P880_LCD_RES_8X6_14X10; | ||
773 | break; | ||
774 | } | ||
775 | break; | ||
776 | case LCD_PANEL_ID6_1600X1200: | ||
777 | switch (vmode_index) { | ||
778 | case VIA_RES_640X400: | ||
779 | case VIA_RES_640X480: | ||
780 | reg_num = NUM_TOTAL_P880_LCD_RES_6X4_16X12; | ||
781 | lcd_patch_reg = P880_LCD_RES_6X4_16X12; | ||
782 | break; | ||
783 | case VIA_RES_720X480: | ||
784 | case VIA_RES_720X576: | ||
785 | reg_num = NUM_TOTAL_P880_LCD_RES_7X4_16X12; | ||
786 | lcd_patch_reg = P880_LCD_RES_7X4_16X12; | ||
787 | break; | ||
788 | case VIA_RES_800X600: | ||
789 | reg_num = NUM_TOTAL_P880_LCD_RES_8X6_16X12; | ||
790 | lcd_patch_reg = P880_LCD_RES_8X6_16X12; | ||
791 | break; | ||
792 | case VIA_RES_1024X768: | ||
793 | reg_num = NUM_TOTAL_P880_LCD_RES_10X7_16X12; | ||
794 | lcd_patch_reg = P880_LCD_RES_10X7_16X12; | ||
795 | break; | ||
796 | case VIA_RES_1280X768: | ||
797 | case VIA_RES_1280X960: | ||
798 | case VIA_RES_1280X1024: | ||
799 | reg_num = NUM_TOTAL_P880_LCD_RES_12X10_16X12; | ||
800 | lcd_patch_reg = P880_LCD_RES_12X10_16X12; | ||
801 | break; | ||
802 | } | ||
803 | break; | ||
804 | |||
805 | } | ||
806 | if (reg_num != 0) { | ||
807 | /* H.W. Reset : ON */ | ||
808 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); | ||
809 | |||
810 | viafb_write_regx(lcd_patch_reg, reg_num); | ||
811 | |||
812 | /* H.W. Reset : OFF */ | ||
813 | viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); | ||
814 | |||
815 | /* Reset PLL */ | ||
816 | viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); | ||
817 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); | ||
818 | |||
819 | /* Fire! */ | ||
820 | outb(inb(VIARMisc) | (BIT2 + BIT3), VIAWMisc); | ||
821 | } | ||
822 | } | ||
823 | |||
824 | static void load_lcd_patch_regs(int set_hres, int set_vres, | ||
825 | int panel_id, int set_iga) | ||
826 | { | ||
827 | int vmode_index; | ||
828 | |||
829 | vmode_index = viafb_get_mode_index(set_hres, set_vres); | ||
830 | |||
831 | viafb_unlock_crt(); | ||
832 | |||
833 | /* Patch for simultaneous & Expansion */ | ||
834 | if ((set_iga == IGA1_IGA2) && | ||
835 | (viaparinfo->lvds_setting_info->display_method == | ||
836 | LCD_EXPANDSION)) { | ||
837 | switch (viaparinfo->chip_info->gfx_chip_name) { | ||
838 | case UNICHROME_CLE266: | ||
839 | case UNICHROME_K400: | ||
840 | load_lcd_k400_patch_tbl(set_hres, set_vres, panel_id); | ||
841 | break; | ||
842 | case UNICHROME_K800: | ||
843 | break; | ||
844 | case UNICHROME_PM800: | ||
845 | case UNICHROME_CN700: | ||
846 | case UNICHROME_CX700: | ||
847 | load_lcd_p880_patch_tbl(set_hres, set_vres, panel_id); | ||
848 | } | ||
849 | } | ||
850 | |||
851 | viafb_lock_crt(); | ||
852 | } | ||
853 | |||
854 | static void via_pitch_alignment_patch_lcd( | 518 | static void via_pitch_alignment_patch_lcd( |
855 | struct lvds_setting_information *plvds_setting_info, | 519 | struct lvds_setting_information *plvds_setting_info, |
856 | struct lvds_chip_information | 520 | struct lvds_chip_information |
@@ -949,29 +613,25 @@ void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table, | |||
949 | struct lvds_setting_information *plvds_setting_info, | 613 | struct lvds_setting_information *plvds_setting_info, |
950 | struct lvds_chip_information *plvds_chip_info) | 614 | struct lvds_chip_information *plvds_chip_info) |
951 | { | 615 | { |
952 | int video_index = plvds_setting_info->lcd_panel_size; | ||
953 | int set_iga = plvds_setting_info->iga_path; | 616 | int set_iga = plvds_setting_info->iga_path; |
954 | int mode_bpp = plvds_setting_info->bpp; | 617 | int mode_bpp = plvds_setting_info->bpp; |
955 | int set_hres, set_vres; | 618 | int set_hres = plvds_setting_info->h_active; |
956 | int panel_hres, panel_vres; | 619 | int set_vres = plvds_setting_info->v_active; |
620 | int panel_hres = plvds_setting_info->lcd_panel_hres; | ||
621 | int panel_vres = plvds_setting_info->lcd_panel_vres; | ||
957 | u32 pll_D_N; | 622 | u32 pll_D_N; |
958 | int offset; | ||
959 | struct display_timing mode_crt_reg, panel_crt_reg; | 623 | struct display_timing mode_crt_reg, panel_crt_reg; |
960 | struct crt_mode_table *panel_crt_table = NULL; | 624 | struct crt_mode_table *panel_crt_table = NULL; |
961 | struct VideoModeTable *vmode_tbl = NULL; | 625 | struct VideoModeTable *vmode_tbl = viafb_get_mode(panel_hres, |
626 | panel_vres); | ||
962 | 627 | ||
963 | DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n"); | 628 | DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n"); |
964 | /* Get mode table */ | 629 | /* Get mode table */ |
965 | mode_crt_reg = mode_crt_table->crtc; | 630 | mode_crt_reg = mode_crt_table->crtc; |
966 | /* Get panel table Pointer */ | 631 | /* Get panel table Pointer */ |
967 | vmode_tbl = viafb_get_modetbl_pointer(video_index); | ||
968 | panel_crt_table = vmode_tbl->crtc; | 632 | panel_crt_table = vmode_tbl->crtc; |
969 | panel_crt_reg = panel_crt_table->crtc; | 633 | panel_crt_reg = panel_crt_table->crtc; |
970 | DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n"); | 634 | DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n"); |
971 | set_hres = plvds_setting_info->h_active; | ||
972 | set_vres = plvds_setting_info->v_active; | ||
973 | panel_hres = plvds_setting_info->lcd_panel_hres; | ||
974 | panel_vres = plvds_setting_info->lcd_panel_vres; | ||
975 | if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) | 635 | if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) |
976 | viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info); | 636 | viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info); |
977 | plvds_setting_info->vclk = panel_crt_table->clk; | 637 | plvds_setting_info->vclk = panel_crt_table->clk; |
@@ -1001,54 +661,12 @@ void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table, | |||
1001 | } | 661 | } |
1002 | } | 662 | } |
1003 | 663 | ||
1004 | if (set_iga == IGA1_IGA2) { | 664 | /* Fetch count for IGA2 only */ |
1005 | load_crtc_shadow_timing(mode_crt_reg, panel_crt_reg); | 665 | viafb_load_fetch_count_reg(set_hres, mode_bpp / 8, set_iga); |
1006 | /* Fill shadow registers */ | ||
1007 | |||
1008 | switch (plvds_setting_info->lcd_panel_id) { | ||
1009 | case LCD_PANEL_ID0_640X480: | ||
1010 | offset = 80; | ||
1011 | break; | ||
1012 | case LCD_PANEL_ID1_800X600: | ||
1013 | case LCD_PANEL_IDA_800X480: | ||
1014 | offset = 110; | ||
1015 | break; | ||
1016 | case LCD_PANEL_ID2_1024X768: | ||
1017 | offset = 150; | ||
1018 | break; | ||
1019 | case LCD_PANEL_ID3_1280X768: | ||
1020 | case LCD_PANEL_ID4_1280X1024: | ||
1021 | case LCD_PANEL_ID5_1400X1050: | ||
1022 | case LCD_PANEL_ID9_1280X800: | ||
1023 | offset = 190; | ||
1024 | break; | ||
1025 | case LCD_PANEL_ID6_1600X1200: | ||
1026 | offset = 250; | ||
1027 | break; | ||
1028 | case LCD_PANEL_ID7_1366X768: | ||
1029 | case LCD_PANEL_IDB_1360X768: | ||
1030 | offset = 212; | ||
1031 | break; | ||
1032 | default: | ||
1033 | offset = 140; | ||
1034 | break; | ||
1035 | } | ||
1036 | |||
1037 | /* Offset for simultaneous */ | ||
1038 | viafb_set_secondary_pitch(offset << 3); | ||
1039 | DEBUG_MSG(KERN_INFO "viafb_load_reg!!\n"); | ||
1040 | viafb_load_fetch_count_reg(set_hres, 4, IGA2); | ||
1041 | /* Fetch count for simultaneous */ | ||
1042 | } else { /* SAMM */ | ||
1043 | /* Fetch count for IGA2 only */ | ||
1044 | viafb_load_fetch_count_reg(set_hres, mode_bpp / 8, set_iga); | ||
1045 | |||
1046 | if ((viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) | ||
1047 | && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)) | ||
1048 | viafb_load_FIFO_reg(set_iga, set_hres, set_vres); | ||
1049 | 666 | ||
1050 | viafb_set_color_depth(mode_bpp / 8, set_iga); | 667 | if ((viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) |
1051 | } | 668 | && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)) |
669 | viafb_load_FIFO_reg(set_iga, set_hres, set_vres); | ||
1052 | 670 | ||
1053 | fill_lcd_format(); | 671 | fill_lcd_format(); |
1054 | 672 | ||
@@ -1065,11 +683,6 @@ void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table, | |||
1065 | || (UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name)) | 683 | || (UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name)) |
1066 | viafb_write_reg_mask(CR6A, VIACR, 0x01, BIT0); | 684 | viafb_write_reg_mask(CR6A, VIACR, 0x01, BIT0); |
1067 | 685 | ||
1068 | load_lcd_patch_regs(set_hres, set_vres, | ||
1069 | plvds_setting_info->lcd_panel_id, set_iga); | ||
1070 | |||
1071 | DEBUG_MSG(KERN_INFO "load_lcd_patch_regs!!\n"); | ||
1072 | |||
1073 | /* Patch for non 32bit alignment mode */ | 686 | /* Patch for non 32bit alignment mode */ |
1074 | via_pitch_alignment_patch_lcd(plvds_setting_info, plvds_chip_info); | 687 | via_pitch_alignment_patch_lcd(plvds_setting_info, plvds_chip_info); |
1075 | } | 688 | } |
@@ -1283,8 +896,7 @@ void viafb_lcd_enable(void) | |||
1283 | viafb_write_reg_mask(CR6A, VIACR, 0x48, 0x48); | 896 | viafb_write_reg_mask(CR6A, VIACR, 0x48, 0x48); |
1284 | } | 897 | } |
1285 | 898 | ||
1286 | if ((viaparinfo->lvds_setting_info->iga_path == IGA1) | 899 | if (viaparinfo->lvds_setting_info->iga_path == IGA1) { |
1287 | || (viaparinfo->lvds_setting_info->iga_path == IGA1_IGA2)) { | ||
1288 | /* CRT path set to IGA2 */ | 900 | /* CRT path set to IGA2 */ |
1289 | viafb_write_reg_mask(SR16, VIASR, 0x40, 0x40); | 901 | viafb_write_reg_mask(SR16, VIASR, 0x40, 0x40); |
1290 | /* IGA2 path disabled */ | 902 | /* IGA2 path disabled */ |
@@ -1476,210 +1088,6 @@ static struct display_timing lcd_centering_timging(struct display_timing | |||
1476 | return crt_reg; | 1088 | return crt_reg; |
1477 | } | 1089 | } |
1478 | 1090 | ||
1479 | static void load_crtc_shadow_timing(struct display_timing mode_timing, | ||
1480 | struct display_timing panel_timing) | ||
1481 | { | ||
1482 | struct io_register *reg = NULL; | ||
1483 | int i; | ||
1484 | int viafb_load_reg_Num = 0; | ||
1485 | int reg_value = 0; | ||
1486 | |||
1487 | if (viaparinfo->lvds_setting_info->display_method == LCD_EXPANDSION) { | ||
1488 | /* Expansion */ | ||
1489 | for (i = 12; i < 20; i++) { | ||
1490 | switch (i) { | ||
1491 | case H_TOTAL_SHADOW_INDEX: | ||
1492 | reg_value = | ||
1493 | IGA2_HOR_TOTAL_SHADOW_FORMULA | ||
1494 | (panel_timing.hor_total); | ||
1495 | viafb_load_reg_Num = | ||
1496 | iga2_shadow_crtc_reg.hor_total_shadow. | ||
1497 | reg_num; | ||
1498 | reg = iga2_shadow_crtc_reg.hor_total_shadow.reg; | ||
1499 | break; | ||
1500 | case H_BLANK_END_SHADOW_INDEX: | ||
1501 | reg_value = | ||
1502 | IGA2_HOR_BLANK_END_SHADOW_FORMULA | ||
1503 | (panel_timing.hor_blank_start, | ||
1504 | panel_timing.hor_blank_end); | ||
1505 | viafb_load_reg_Num = | ||
1506 | iga2_shadow_crtc_reg. | ||
1507 | hor_blank_end_shadow.reg_num; | ||
1508 | reg = | ||
1509 | iga2_shadow_crtc_reg. | ||
1510 | hor_blank_end_shadow.reg; | ||
1511 | break; | ||
1512 | case V_TOTAL_SHADOW_INDEX: | ||
1513 | reg_value = | ||
1514 | IGA2_VER_TOTAL_SHADOW_FORMULA | ||
1515 | (panel_timing.ver_total); | ||
1516 | viafb_load_reg_Num = | ||
1517 | iga2_shadow_crtc_reg.ver_total_shadow. | ||
1518 | reg_num; | ||
1519 | reg = iga2_shadow_crtc_reg.ver_total_shadow.reg; | ||
1520 | break; | ||
1521 | case V_ADDR_SHADOW_INDEX: | ||
1522 | reg_value = | ||
1523 | IGA2_VER_ADDR_SHADOW_FORMULA | ||
1524 | (panel_timing.ver_addr); | ||
1525 | viafb_load_reg_Num = | ||
1526 | iga2_shadow_crtc_reg.ver_addr_shadow. | ||
1527 | reg_num; | ||
1528 | reg = iga2_shadow_crtc_reg.ver_addr_shadow.reg; | ||
1529 | break; | ||
1530 | case V_BLANK_SATRT_SHADOW_INDEX: | ||
1531 | reg_value = | ||
1532 | IGA2_VER_BLANK_START_SHADOW_FORMULA | ||
1533 | (panel_timing.ver_blank_start); | ||
1534 | viafb_load_reg_Num = | ||
1535 | iga2_shadow_crtc_reg. | ||
1536 | ver_blank_start_shadow.reg_num; | ||
1537 | reg = | ||
1538 | iga2_shadow_crtc_reg. | ||
1539 | ver_blank_start_shadow.reg; | ||
1540 | break; | ||
1541 | case V_BLANK_END_SHADOW_INDEX: | ||
1542 | reg_value = | ||
1543 | IGA2_VER_BLANK_END_SHADOW_FORMULA | ||
1544 | (panel_timing.ver_blank_start, | ||
1545 | panel_timing.ver_blank_end); | ||
1546 | viafb_load_reg_Num = | ||
1547 | iga2_shadow_crtc_reg. | ||
1548 | ver_blank_end_shadow.reg_num; | ||
1549 | reg = | ||
1550 | iga2_shadow_crtc_reg. | ||
1551 | ver_blank_end_shadow.reg; | ||
1552 | break; | ||
1553 | case V_SYNC_SATRT_SHADOW_INDEX: | ||
1554 | reg_value = | ||
1555 | IGA2_VER_SYNC_START_SHADOW_FORMULA | ||
1556 | (panel_timing.ver_sync_start); | ||
1557 | viafb_load_reg_Num = | ||
1558 | iga2_shadow_crtc_reg. | ||
1559 | ver_sync_start_shadow.reg_num; | ||
1560 | reg = | ||
1561 | iga2_shadow_crtc_reg. | ||
1562 | ver_sync_start_shadow.reg; | ||
1563 | break; | ||
1564 | case V_SYNC_END_SHADOW_INDEX: | ||
1565 | reg_value = | ||
1566 | IGA2_VER_SYNC_END_SHADOW_FORMULA | ||
1567 | (panel_timing.ver_sync_start, | ||
1568 | panel_timing.ver_sync_end); | ||
1569 | viafb_load_reg_Num = | ||
1570 | iga2_shadow_crtc_reg. | ||
1571 | ver_sync_end_shadow.reg_num; | ||
1572 | reg = | ||
1573 | iga2_shadow_crtc_reg. | ||
1574 | ver_sync_end_shadow.reg; | ||
1575 | break; | ||
1576 | } | ||
1577 | viafb_load_reg(reg_value, | ||
1578 | viafb_load_reg_Num, reg, VIACR); | ||
1579 | } | ||
1580 | } else { /* Centering */ | ||
1581 | for (i = 12; i < 20; i++) { | ||
1582 | switch (i) { | ||
1583 | case H_TOTAL_SHADOW_INDEX: | ||
1584 | reg_value = | ||
1585 | IGA2_HOR_TOTAL_SHADOW_FORMULA | ||
1586 | (panel_timing.hor_total); | ||
1587 | viafb_load_reg_Num = | ||
1588 | iga2_shadow_crtc_reg.hor_total_shadow. | ||
1589 | reg_num; | ||
1590 | reg = iga2_shadow_crtc_reg.hor_total_shadow.reg; | ||
1591 | break; | ||
1592 | case H_BLANK_END_SHADOW_INDEX: | ||
1593 | reg_value = | ||
1594 | IGA2_HOR_BLANK_END_SHADOW_FORMULA | ||
1595 | (panel_timing.hor_blank_start, | ||
1596 | panel_timing.hor_blank_end); | ||
1597 | viafb_load_reg_Num = | ||
1598 | iga2_shadow_crtc_reg. | ||
1599 | hor_blank_end_shadow.reg_num; | ||
1600 | reg = | ||
1601 | iga2_shadow_crtc_reg. | ||
1602 | hor_blank_end_shadow.reg; | ||
1603 | break; | ||
1604 | case V_TOTAL_SHADOW_INDEX: | ||
1605 | reg_value = | ||
1606 | IGA2_VER_TOTAL_SHADOW_FORMULA | ||
1607 | (panel_timing.ver_total); | ||
1608 | viafb_load_reg_Num = | ||
1609 | iga2_shadow_crtc_reg.ver_total_shadow. | ||
1610 | reg_num; | ||
1611 | reg = iga2_shadow_crtc_reg.ver_total_shadow.reg; | ||
1612 | break; | ||
1613 | case V_ADDR_SHADOW_INDEX: | ||
1614 | reg_value = | ||
1615 | IGA2_VER_ADDR_SHADOW_FORMULA | ||
1616 | (mode_timing.ver_addr); | ||
1617 | viafb_load_reg_Num = | ||
1618 | iga2_shadow_crtc_reg.ver_addr_shadow. | ||
1619 | reg_num; | ||
1620 | reg = iga2_shadow_crtc_reg.ver_addr_shadow.reg; | ||
1621 | break; | ||
1622 | case V_BLANK_SATRT_SHADOW_INDEX: | ||
1623 | reg_value = | ||
1624 | IGA2_VER_BLANK_START_SHADOW_FORMULA | ||
1625 | (mode_timing.ver_blank_start); | ||
1626 | viafb_load_reg_Num = | ||
1627 | iga2_shadow_crtc_reg. | ||
1628 | ver_blank_start_shadow.reg_num; | ||
1629 | reg = | ||
1630 | iga2_shadow_crtc_reg. | ||
1631 | ver_blank_start_shadow.reg; | ||
1632 | break; | ||
1633 | case V_BLANK_END_SHADOW_INDEX: | ||
1634 | reg_value = | ||
1635 | IGA2_VER_BLANK_END_SHADOW_FORMULA | ||
1636 | (panel_timing.ver_blank_start, | ||
1637 | panel_timing.ver_blank_end); | ||
1638 | viafb_load_reg_Num = | ||
1639 | iga2_shadow_crtc_reg. | ||
1640 | ver_blank_end_shadow.reg_num; | ||
1641 | reg = | ||
1642 | iga2_shadow_crtc_reg. | ||
1643 | ver_blank_end_shadow.reg; | ||
1644 | break; | ||
1645 | case V_SYNC_SATRT_SHADOW_INDEX: | ||
1646 | reg_value = | ||
1647 | IGA2_VER_SYNC_START_SHADOW_FORMULA( | ||
1648 | (panel_timing.ver_sync_start - | ||
1649 | panel_timing.ver_blank_start) + | ||
1650 | (panel_timing.ver_addr - | ||
1651 | mode_timing.ver_addr) / 2 + | ||
1652 | mode_timing.ver_addr); | ||
1653 | viafb_load_reg_Num = | ||
1654 | iga2_shadow_crtc_reg.ver_sync_start_shadow. | ||
1655 | reg_num; | ||
1656 | reg = | ||
1657 | iga2_shadow_crtc_reg.ver_sync_start_shadow. | ||
1658 | reg; | ||
1659 | break; | ||
1660 | case V_SYNC_END_SHADOW_INDEX: | ||
1661 | reg_value = | ||
1662 | IGA2_VER_SYNC_END_SHADOW_FORMULA( | ||
1663 | (panel_timing.ver_sync_start - | ||
1664 | panel_timing.ver_blank_start) + | ||
1665 | (panel_timing.ver_addr - | ||
1666 | mode_timing.ver_addr) / 2 + | ||
1667 | mode_timing.ver_addr, | ||
1668 | panel_timing.ver_sync_end); | ||
1669 | viafb_load_reg_Num = | ||
1670 | iga2_shadow_crtc_reg.ver_sync_end_shadow. | ||
1671 | reg_num; | ||
1672 | reg = | ||
1673 | iga2_shadow_crtc_reg.ver_sync_end_shadow. | ||
1674 | reg; | ||
1675 | break; | ||
1676 | } | ||
1677 | viafb_load_reg(reg_value, | ||
1678 | viafb_load_reg_Num, reg, VIACR); | ||
1679 | } | ||
1680 | } | ||
1681 | } | ||
1682 | |||
1683 | bool viafb_lcd_get_mobile_state(bool *mobile) | 1091 | bool viafb_lcd_get_mobile_state(bool *mobile) |
1684 | { | 1092 | { |
1685 | unsigned char *romptr, *tableptr; | 1093 | unsigned char *romptr, *tableptr; |
diff --git a/drivers/video/via/share.h b/drivers/video/via/share.h index 7cd03e2a1275..d55aaa7b912c 100644 --- a/drivers/video/via/share.h +++ b/drivers/video/via/share.h | |||
@@ -43,61 +43,6 @@ | |||
43 | /* Video Memory Size */ | 43 | /* Video Memory Size */ |
44 | #define VIDEO_MEMORY_SIZE_16M 0x1000000 | 44 | #define VIDEO_MEMORY_SIZE_16M 0x1000000 |
45 | 45 | ||
46 | /* Definition Mode Index | ||
47 | */ | ||
48 | #define VIA_RES_640X480 0 | ||
49 | #define VIA_RES_800X600 1 | ||
50 | #define VIA_RES_1024X768 2 | ||
51 | #define VIA_RES_1152X864 3 | ||
52 | #define VIA_RES_1280X1024 4 | ||
53 | #define VIA_RES_1600X1200 5 | ||
54 | #define VIA_RES_1440X1050 6 | ||
55 | #define VIA_RES_1280X768 7 | ||
56 | #define VIA_RES_1280X960 8 | ||
57 | #define VIA_RES_1920X1440 9 | ||
58 | #define VIA_RES_848X480 10 | ||
59 | #define VIA_RES_1400X1050 11 | ||
60 | #define VIA_RES_720X480 12 | ||
61 | #define VIA_RES_720X576 13 | ||
62 | #define VIA_RES_1024X512 14 | ||
63 | #define VIA_RES_856X480 15 | ||
64 | #define VIA_RES_1024X576 16 | ||
65 | #define VIA_RES_640X400 17 | ||
66 | #define VIA_RES_1280X720 18 | ||
67 | #define VIA_RES_1920X1080 19 | ||
68 | #define VIA_RES_800X480 20 | ||
69 | #define VIA_RES_1368X768 21 | ||
70 | #define VIA_RES_1024X600 22 | ||
71 | #define VIA_RES_1280X800 23 | ||
72 | #define VIA_RES_1680X1050 24 | ||
73 | #define VIA_RES_960X600 25 | ||
74 | #define VIA_RES_1000X600 26 | ||
75 | #define VIA_RES_1088X612 27 | ||
76 | #define VIA_RES_1152X720 28 | ||
77 | #define VIA_RES_1200X720 29 | ||
78 | #define VIA_RES_1280X600 30 | ||
79 | #define VIA_RES_1360X768 31 | ||
80 | #define VIA_RES_1366X768 32 | ||
81 | #define VIA_RES_1440X900 33 | ||
82 | #define VIA_RES_1600X900 34 | ||
83 | #define VIA_RES_1600X1024 35 | ||
84 | #define VIA_RES_1792X1344 36 | ||
85 | #define VIA_RES_1856X1392 37 | ||
86 | #define VIA_RES_1920X1200 38 | ||
87 | #define VIA_RES_2048X1536 39 | ||
88 | #define VIA_RES_480X640 40 | ||
89 | |||
90 | /*Reduce Blanking*/ | ||
91 | #define VIA_RES_1360X768_RB 131 | ||
92 | #define VIA_RES_1440X900_RB 133 | ||
93 | #define VIA_RES_1400X1050_RB 111 | ||
94 | #define VIA_RES_1600X900_RB 134 | ||
95 | #define VIA_RES_1680X1050_RB 124 | ||
96 | #define VIA_RES_1920X1080_RB 119 | ||
97 | #define VIA_RES_1920X1200_RB 138 | ||
98 | |||
99 | #define VIA_RES_INVALID 255 | ||
100 | |||
101 | /* standard VGA IO port | 46 | /* standard VGA IO port |
102 | */ | 47 | */ |
103 | #define VIARMisc 0x3CC | 48 | #define VIARMisc 0x3CC |
@@ -118,7 +63,6 @@ | |||
118 | /* Display path */ | 63 | /* Display path */ |
119 | #define IGA1 1 | 64 | #define IGA1 1 |
120 | #define IGA2 2 | 65 | #define IGA2 2 |
121 | #define IGA1_IGA2 3 | ||
122 | 66 | ||
123 | /* Define Color Depth */ | 67 | /* Define Color Depth */ |
124 | #define MODE_8BPP 1 | 68 | #define MODE_8BPP 1 |
diff --git a/drivers/video/via/via_utility.c b/drivers/video/via/via_utility.c index d53c3d54ed8e..aefdeeec89b1 100644 --- a/drivers/video/via/via_utility.c +++ b/drivers/video/via/via_utility.c | |||
@@ -239,15 +239,3 @@ void viafb_get_gamma_support_state(int bpp, unsigned int *support_state) | |||
239 | else | 239 | else |
240 | *support_state = CRT_Device | DVI_Device | LCD_Device; | 240 | *support_state = CRT_Device | DVI_Device | LCD_Device; |
241 | } | 241 | } |
242 | |||
243 | int viafb_input_parameter_converter(int parameter_value) | ||
244 | { | ||
245 | int result; | ||
246 | |||
247 | if (parameter_value >= 1 && parameter_value <= 9) | ||
248 | result = 1 << (parameter_value - 1); | ||
249 | else | ||
250 | result = 1; | ||
251 | |||
252 | return result; | ||
253 | } | ||
diff --git a/drivers/video/via/via_utility.h b/drivers/video/via/via_utility.h index 2fd455202ebd..1670ba82143f 100644 --- a/drivers/video/via/via_utility.h +++ b/drivers/video/via/via_utility.h | |||
@@ -30,6 +30,5 @@ bool viafb_lcd_get_support_expand_state(u32 xres, u32 yres); | |||
30 | void viafb_set_gamma_table(int bpp, unsigned int *gamma_table); | 30 | void viafb_set_gamma_table(int bpp, unsigned int *gamma_table); |
31 | void viafb_get_gamma_table(unsigned int *gamma_table); | 31 | void viafb_get_gamma_table(unsigned int *gamma_table); |
32 | void viafb_get_gamma_support_state(int bpp, unsigned int *support_state); | 32 | void viafb_get_gamma_support_state(int bpp, unsigned int *support_state); |
33 | int viafb_input_parameter_converter(int parameter_value); | ||
34 | 33 | ||
35 | #endif /* __VIAUTILITY_H__ */ | 34 | #endif /* __VIAUTILITY_H__ */ |
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c index 3028e7ddc3b5..ce7783b63f6a 100644 --- a/drivers/video/via/viafbdev.c +++ b/drivers/video/via/viafbdev.c | |||
@@ -26,18 +26,22 @@ | |||
26 | 26 | ||
27 | #include "global.h" | 27 | #include "global.h" |
28 | 28 | ||
29 | static struct fb_var_screeninfo default_var; | ||
30 | static char *viafb_name = "Via"; | 29 | static char *viafb_name = "Via"; |
31 | static u32 pseudo_pal[17]; | 30 | static u32 pseudo_pal[17]; |
32 | 31 | ||
33 | /* video mode */ | 32 | /* video mode */ |
34 | static char *viafb_mode = "640x480"; | 33 | static char *viafb_mode; |
35 | static char *viafb_mode1 = "640x480"; | 34 | static char *viafb_mode1; |
35 | static int viafb_bpp = 32; | ||
36 | static int viafb_bpp1 = 32; | ||
37 | |||
38 | static unsigned int viafb_second_offset; | ||
39 | static int viafb_second_size; | ||
36 | 40 | ||
37 | static int viafb_accel = 1; | 41 | static int viafb_accel = 1; |
38 | 42 | ||
39 | /* Added for specifying active devices.*/ | 43 | /* Added for specifying active devices.*/ |
40 | char *viafb_active_dev = ""; | 44 | char *viafb_active_dev; |
41 | 45 | ||
42 | /*Added for specify lcd output port*/ | 46 | /*Added for specify lcd output port*/ |
43 | char *viafb_lcd_port = ""; | 47 | char *viafb_lcd_port = ""; |
@@ -50,18 +54,78 @@ static void apply_second_mode_setting(struct fb_var_screeninfo | |||
50 | *sec_var); | 54 | *sec_var); |
51 | static void retrieve_device_setting(struct viafb_ioctl_setting | 55 | static void retrieve_device_setting(struct viafb_ioctl_setting |
52 | *setting_info); | 56 | *setting_info); |
57 | static int viafb_pan_display(struct fb_var_screeninfo *var, | ||
58 | struct fb_info *info); | ||
53 | 59 | ||
54 | static struct fb_ops viafb_ops; | 60 | static struct fb_ops viafb_ops; |
55 | 61 | ||
56 | 62 | ||
63 | static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth) | ||
64 | { | ||
65 | var->grayscale = 0; | ||
66 | var->red.msb_right = 0; | ||
67 | var->green.msb_right = 0; | ||
68 | var->blue.msb_right = 0; | ||
69 | var->transp.offset = 0; | ||
70 | var->transp.length = 0; | ||
71 | var->transp.msb_right = 0; | ||
72 | var->nonstd = 0; | ||
73 | switch (depth) { | ||
74 | case 8: | ||
75 | var->bits_per_pixel = 8; | ||
76 | var->red.offset = 0; | ||
77 | var->green.offset = 0; | ||
78 | var->blue.offset = 0; | ||
79 | var->red.length = 8; | ||
80 | var->green.length = 8; | ||
81 | var->blue.length = 8; | ||
82 | break; | ||
83 | case 15: | ||
84 | var->bits_per_pixel = 16; | ||
85 | var->red.offset = 10; | ||
86 | var->green.offset = 5; | ||
87 | var->blue.offset = 0; | ||
88 | var->red.length = 5; | ||
89 | var->green.length = 5; | ||
90 | var->blue.length = 5; | ||
91 | break; | ||
92 | case 16: | ||
93 | var->bits_per_pixel = 16; | ||
94 | var->red.offset = 11; | ||
95 | var->green.offset = 5; | ||
96 | var->blue.offset = 0; | ||
97 | var->red.length = 5; | ||
98 | var->green.length = 6; | ||
99 | var->blue.length = 5; | ||
100 | break; | ||
101 | case 24: | ||
102 | var->bits_per_pixel = 32; | ||
103 | var->red.offset = 16; | ||
104 | var->green.offset = 8; | ||
105 | var->blue.offset = 0; | ||
106 | var->red.length = 8; | ||
107 | var->green.length = 8; | ||
108 | var->blue.length = 8; | ||
109 | break; | ||
110 | case 30: | ||
111 | var->bits_per_pixel = 32; | ||
112 | var->red.offset = 20; | ||
113 | var->green.offset = 10; | ||
114 | var->blue.offset = 0; | ||
115 | var->red.length = 10; | ||
116 | var->green.length = 10; | ||
117 | var->blue.length = 10; | ||
118 | break; | ||
119 | } | ||
120 | } | ||
121 | |||
57 | static void viafb_update_fix(struct fb_info *info) | 122 | static void viafb_update_fix(struct fb_info *info) |
58 | { | 123 | { |
59 | u32 bpp = info->var.bits_per_pixel; | 124 | u32 bpp = info->var.bits_per_pixel; |
60 | 125 | ||
61 | info->fix.visual = | 126 | info->fix.visual = |
62 | bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; | 127 | bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
63 | info->fix.line_length = | 128 | info->fix.line_length = (info->var.xres_virtual * bpp / 8 + 7) & ~7; |
64 | ((info->var.xres_virtual + 7) & ~7) * bpp / 8; | ||
65 | } | 129 | } |
66 | 130 | ||
67 | static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix, | 131 | static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix, |
@@ -75,6 +139,7 @@ static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix, | |||
75 | 139 | ||
76 | fix->type = FB_TYPE_PACKED_PIXELS; | 140 | fix->type = FB_TYPE_PACKED_PIXELS; |
77 | fix->type_aux = 0; | 141 | fix->type_aux = 0; |
142 | fix->visual = FB_VISUAL_TRUECOLOR; | ||
78 | 143 | ||
79 | fix->xpanstep = fix->ywrapstep = 0; | 144 | fix->xpanstep = fix->ywrapstep = 0; |
80 | fix->ypanstep = 1; | 145 | fix->ypanstep = 1; |
@@ -97,9 +162,10 @@ static int viafb_release(struct fb_info *info, int user) | |||
97 | static int viafb_check_var(struct fb_var_screeninfo *var, | 162 | static int viafb_check_var(struct fb_var_screeninfo *var, |
98 | struct fb_info *info) | 163 | struct fb_info *info) |
99 | { | 164 | { |
100 | int vmode_index, htotal, vtotal; | 165 | int htotal, vtotal, depth; |
166 | struct VideoModeTable *vmode_entry; | ||
101 | struct viafb_par *ppar = info->par; | 167 | struct viafb_par *ppar = info->par; |
102 | u32 long_refresh; | 168 | u32 long_refresh, line; |
103 | 169 | ||
104 | DEBUG_MSG(KERN_INFO "viafb_check_var!\n"); | 170 | DEBUG_MSG(KERN_INFO "viafb_check_var!\n"); |
105 | /* Sanity check */ | 171 | /* Sanity check */ |
@@ -107,26 +173,36 @@ static int viafb_check_var(struct fb_var_screeninfo *var, | |||
107 | if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE) | 173 | if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE) |
108 | return -EINVAL; | 174 | return -EINVAL; |
109 | 175 | ||
110 | vmode_index = viafb_get_mode_index(var->xres, var->yres); | 176 | vmode_entry = viafb_get_mode(var->xres, var->yres); |
111 | if (vmode_index == VIA_RES_INVALID) { | 177 | if (!vmode_entry) { |
112 | DEBUG_MSG(KERN_INFO | 178 | DEBUG_MSG(KERN_INFO |
113 | "viafb: Mode %dx%dx%d not supported!!\n", | 179 | "viafb: Mode %dx%dx%d not supported!!\n", |
114 | var->xres, var->yres, var->bits_per_pixel); | 180 | var->xres, var->yres, var->bits_per_pixel); |
115 | return -EINVAL; | 181 | return -EINVAL; |
116 | } | 182 | } |
117 | 183 | ||
118 | if (24 == var->bits_per_pixel) | 184 | depth = fb_get_color_depth(var, &info->fix); |
119 | var->bits_per_pixel = 32; | 185 | if (!depth) |
186 | depth = var->bits_per_pixel; | ||
120 | 187 | ||
121 | if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 && | 188 | if (depth < 0 || depth > 32) |
122 | var->bits_per_pixel != 32) | ||
123 | return -EINVAL; | 189 | return -EINVAL; |
190 | else if (!depth) | ||
191 | depth = 24; | ||
192 | else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1) | ||
193 | depth = 15; | ||
194 | else if (depth == 30) | ||
195 | depth = 30; | ||
196 | else if (depth <= 8) | ||
197 | depth = 8; | ||
198 | else if (depth <= 16) | ||
199 | depth = 16; | ||
200 | else | ||
201 | depth = 24; | ||
124 | 202 | ||
125 | if ((var->xres_virtual * (var->bits_per_pixel >> 3)) & 0x1F) | 203 | viafb_fill_var_color_info(var, depth); |
126 | /*32 pixel alignment */ | 204 | line = (var->xres_virtual * var->bits_per_pixel / 8 + 7) & ~7; |
127 | var->xres_virtual = (var->xres_virtual + 31) & ~31; | 205 | if (line * var->yres_virtual > ppar->memsize) |
128 | if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 > | ||
129 | ppar->memsize) | ||
130 | return -EINVAL; | 206 | return -EINVAL; |
131 | 207 | ||
132 | /* Based on var passed in to calculate the refresh, | 208 | /* Based on var passed in to calculate the refresh, |
@@ -142,7 +218,7 @@ static int viafb_check_var(struct fb_var_screeninfo *var, | |||
142 | viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh); | 218 | viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh); |
143 | 219 | ||
144 | /* Adjust var according to our driver's own table */ | 220 | /* Adjust var according to our driver's own table */ |
145 | viafb_fill_var_timing_info(var, viafb_refresh, vmode_index); | 221 | viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry); |
146 | if (info->var.accel_flags & FB_ACCELF_TEXT && | 222 | if (info->var.accel_flags & FB_ACCELF_TEXT && |
147 | !ppar->shared->engine_mmio) | 223 | !ppar->shared->engine_mmio) |
148 | info->var.accel_flags = 0; | 224 | info->var.accel_flags = 0; |
@@ -153,39 +229,45 @@ static int viafb_check_var(struct fb_var_screeninfo *var, | |||
153 | static int viafb_set_par(struct fb_info *info) | 229 | static int viafb_set_par(struct fb_info *info) |
154 | { | 230 | { |
155 | struct viafb_par *viapar = info->par; | 231 | struct viafb_par *viapar = info->par; |
156 | int vmode_index; | 232 | struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL; |
157 | int vmode_index1 = 0; | ||
158 | DEBUG_MSG(KERN_INFO "viafb_set_par!\n"); | 233 | DEBUG_MSG(KERN_INFO "viafb_set_par!\n"); |
159 | 234 | ||
160 | viapar->depth = fb_get_color_depth(&info->var, &info->fix); | 235 | viapar->depth = fb_get_color_depth(&info->var, &info->fix); |
161 | viafb_update_device_setting(info->var.xres, info->var.yres, | 236 | viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres, |
162 | info->var.bits_per_pixel, viafb_refresh, 0); | 237 | viafbinfo->var.bits_per_pixel, viafb_refresh, 0); |
163 | 238 | ||
164 | vmode_index = viafb_get_mode_index(info->var.xres, info->var.yres); | 239 | vmode_entry = viafb_get_mode(viafbinfo->var.xres, viafbinfo->var.yres); |
165 | 240 | if (viafb_dual_fb) { | |
166 | if (viafb_SAMM_ON == 1) { | 241 | vmode_entry1 = viafb_get_mode(viafbinfo1->var.xres, |
242 | viafbinfo1->var.yres); | ||
243 | viafb_update_device_setting(viafbinfo1->var.xres, | ||
244 | viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel, | ||
245 | viafb_refresh1, 1); | ||
246 | } else if (viafb_SAMM_ON == 1) { | ||
167 | DEBUG_MSG(KERN_INFO | 247 | DEBUG_MSG(KERN_INFO |
168 | "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n", | 248 | "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n", |
169 | viafb_second_xres, viafb_second_yres, viafb_bpp1); | 249 | viafb_second_xres, viafb_second_yres, viafb_bpp1); |
170 | vmode_index1 = viafb_get_mode_index(viafb_second_xres, | 250 | vmode_entry1 = viafb_get_mode(viafb_second_xres, |
171 | viafb_second_yres); | 251 | viafb_second_yres); |
172 | DEBUG_MSG(KERN_INFO "->viafb_SAMM_ON: index=%d\n", | ||
173 | vmode_index1); | ||
174 | 252 | ||
175 | viafb_update_device_setting(viafb_second_xres, | 253 | viafb_update_device_setting(viafb_second_xres, |
176 | viafb_second_yres, viafb_bpp1, viafb_refresh1, 1); | 254 | viafb_second_yres, viafb_bpp1, viafb_refresh1, 1); |
177 | } | 255 | } |
178 | 256 | ||
179 | if (vmode_index != VIA_RES_INVALID) { | 257 | if (vmode_entry) { |
180 | viafb_update_fix(info); | 258 | viafb_update_fix(info); |
181 | viafb_bpp = info->var.bits_per_pixel; | 259 | if (viafb_dual_fb && viapar->iga_path == IGA2) |
260 | viafb_bpp1 = info->var.bits_per_pixel; | ||
261 | else | ||
262 | viafb_bpp = info->var.bits_per_pixel; | ||
263 | |||
182 | if (info->var.accel_flags & FB_ACCELF_TEXT) | 264 | if (info->var.accel_flags & FB_ACCELF_TEXT) |
183 | info->flags &= ~FBINFO_HWACCEL_DISABLED; | 265 | info->flags &= ~FBINFO_HWACCEL_DISABLED; |
184 | else | 266 | else |
185 | info->flags |= FBINFO_HWACCEL_DISABLED; | 267 | info->flags |= FBINFO_HWACCEL_DISABLED; |
186 | viafb_setmode(vmode_index, info->var.xres, info->var.yres, | 268 | viafb_setmode(vmode_entry, info->var.bits_per_pixel, |
187 | info->var.bits_per_pixel, vmode_index1, | 269 | vmode_entry1, viafb_bpp1); |
188 | viafb_second_xres, viafb_second_yres, viafb_bpp1); | 270 | viafb_pan_display(&info->var, info); |
189 | } | 271 | } |
190 | 272 | ||
191 | return 0; | 273 | return 0; |
@@ -195,234 +277,52 @@ static int viafb_set_par(struct fb_info *info) | |||
195 | static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green, | 277 | static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green, |
196 | unsigned blue, unsigned transp, struct fb_info *info) | 278 | unsigned blue, unsigned transp, struct fb_info *info) |
197 | { | 279 | { |
198 | u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10; | 280 | struct viafb_par *viapar = info->par; |
199 | unsigned cmap_entries = (info->var.bits_per_pixel == 8) ? 256 : 16; | 281 | u32 r, g, b; |
200 | DEBUG_MSG(KERN_INFO "viafb_setcolreg!\n"); | ||
201 | if (regno >= cmap_entries) | ||
202 | return 1; | ||
203 | if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) { | ||
204 | /* | ||
205 | * Read PCI bus 0,dev 0,function 0,index 0xF6 to get chip rev. | ||
206 | */ | ||
207 | outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8); | ||
208 | rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff; | ||
209 | } | ||
210 | switch (info->var.bits_per_pixel) { | ||
211 | case 8: | ||
212 | outb(0x1A, 0x3C4); | ||
213 | sr1a = inb(0x3C5); | ||
214 | outb(0x1B, 0x3C4); | ||
215 | sr1b = inb(0x3C5); | ||
216 | outb(0x67, 0x3D4); | ||
217 | cr67 = inb(0x3D5); | ||
218 | outb(0x6A, 0x3D4); | ||
219 | cr6a = inb(0x3D5); | ||
220 | |||
221 | /* Map the 3C6/7/8/9 to the IGA2 */ | ||
222 | outb(0x1A, 0x3C4); | ||
223 | outb(sr1a | 0x01, 0x3C5); | ||
224 | /* Second Display Engine colck always on */ | ||
225 | outb(0x1B, 0x3C4); | ||
226 | outb(sr1b | 0x80, 0x3C5); | ||
227 | /* Second Display Color Depth 8 */ | ||
228 | outb(0x67, 0x3D4); | ||
229 | outb(cr67 & 0x3F, 0x3D5); | ||
230 | outb(0x6A, 0x3D4); | ||
231 | /* Second Display Channel Reset CR6A[6]) */ | ||
232 | outb(cr6a & 0xBF, 0x3D5); | ||
233 | /* Second Display Channel Enable CR6A[7] */ | ||
234 | outb(cr6a | 0x80, 0x3D5); | ||
235 | /* Second Display Channel stop reset) */ | ||
236 | outb(cr6a | 0x40, 0x3D5); | ||
237 | |||
238 | /* Bit mask of palette */ | ||
239 | outb(0xFF, 0x3c6); | ||
240 | /* Write one register of IGA2 */ | ||
241 | outb(regno, 0x3C8); | ||
242 | if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name && | ||
243 | rev >= 15) { | ||
244 | shift = 8; | ||
245 | viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5); | ||
246 | viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7); | ||
247 | } else { | ||
248 | shift = 10; | ||
249 | viafb_write_reg_mask(CR6A, VIACR, 0, BIT5); | ||
250 | viafb_write_reg_mask(SR15, VIASR, 0, BIT7); | ||
251 | } | ||
252 | outb(red >> shift, 0x3C9); | ||
253 | outb(green >> shift, 0x3C9); | ||
254 | outb(blue >> shift, 0x3C9); | ||
255 | |||
256 | /* Map the 3C6/7/8/9 to the IGA1 */ | ||
257 | outb(0x1A, 0x3C4); | ||
258 | outb(sr1a & 0xFE, 0x3C5); | ||
259 | /* Bit mask of palette */ | ||
260 | outb(0xFF, 0x3c6); | ||
261 | /* Write one register of IGA1 */ | ||
262 | outb(regno, 0x3C8); | ||
263 | outb(red >> shift, 0x3C9); | ||
264 | outb(green >> shift, 0x3C9); | ||
265 | outb(blue >> shift, 0x3C9); | ||
266 | |||
267 | outb(0x1A, 0x3C4); | ||
268 | outb(sr1a, 0x3C5); | ||
269 | outb(0x1B, 0x3C4); | ||
270 | outb(sr1b, 0x3C5); | ||
271 | outb(0x67, 0x3D4); | ||
272 | outb(cr67, 0x3D5); | ||
273 | outb(0x6A, 0x3D4); | ||
274 | outb(cr6a, 0x3D5); | ||
275 | break; | ||
276 | case 16: | ||
277 | ((u32 *) info->pseudo_palette)[regno] = (red & 0xF800) | | ||
278 | ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11); | ||
279 | break; | ||
280 | case 32: | ||
281 | ((u32 *) info->pseudo_palette)[regno] = | ||
282 | ((transp & 0xFF00) << 16) | | ||
283 | ((red & 0xFF00) << 8) | | ||
284 | ((green & 0xFF00)) | ((blue & 0xFF00) >> 8); | ||
285 | break; | ||
286 | } | ||
287 | |||
288 | return 0; | ||
289 | 282 | ||
290 | } | 283 | if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) { |
284 | if (regno > 255) | ||
285 | return -EINVAL; | ||
291 | 286 | ||
292 | /*CALLED BY: fb_set_cmap */ | 287 | if (!viafb_dual_fb || viapar->iga_path == IGA1) |
293 | /* fb_set_var, pass 256 colors */ | 288 | viafb_set_primary_color_register(regno, red >> 8, |
294 | /*CALLED BY: fb_set_cmap */ | 289 | green >> 8, blue >> 8); |
295 | /* fbcon_set_palette, pass 16 colors */ | ||
296 | static int viafb_setcmap(struct fb_cmap *cmap, struct fb_info *info) | ||
297 | { | ||
298 | u32 len = cmap->len; | ||
299 | u32 i; | ||
300 | u16 *pred = cmap->red; | ||
301 | u16 *pgreen = cmap->green; | ||
302 | u16 *pblue = cmap->blue; | ||
303 | u16 *ptransp = cmap->transp; | ||
304 | u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10; | ||
305 | if (len > 256) | ||
306 | return 1; | ||
307 | if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) { | ||
308 | /* | ||
309 | * Read PCI bus 0, dev 0, function 0, index 0xF6 to get chip | ||
310 | * rev. | ||
311 | */ | ||
312 | outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8); | ||
313 | rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff; | ||
314 | } | ||
315 | switch (info->var.bits_per_pixel) { | ||
316 | case 8: | ||
317 | outb(0x1A, 0x3C4); | ||
318 | sr1a = inb(0x3C5); | ||
319 | outb(0x1B, 0x3C4); | ||
320 | sr1b = inb(0x3C5); | ||
321 | outb(0x67, 0x3D4); | ||
322 | cr67 = inb(0x3D5); | ||
323 | outb(0x6A, 0x3D4); | ||
324 | cr6a = inb(0x3D5); | ||
325 | /* Map the 3C6/7/8/9 to the IGA2 */ | ||
326 | outb(0x1A, 0x3C4); | ||
327 | outb(sr1a | 0x01, 0x3C5); | ||
328 | outb(0x1B, 0x3C4); | ||
329 | /* Second Display Engine colck always on */ | ||
330 | outb(sr1b | 0x80, 0x3C5); | ||
331 | outb(0x67, 0x3D4); | ||
332 | /* Second Display Color Depth 8 */ | ||
333 | outb(cr67 & 0x3F, 0x3D5); | ||
334 | outb(0x6A, 0x3D4); | ||
335 | /* Second Display Channel Reset CR6A[6]) */ | ||
336 | outb(cr6a & 0xBF, 0x3D5); | ||
337 | /* Second Display Channel Enable CR6A[7] */ | ||
338 | outb(cr6a | 0x80, 0x3D5); | ||
339 | /* Second Display Channel stop reset) */ | ||
340 | outb(cr6a | 0xC0, 0x3D5); | ||
341 | |||
342 | /* Bit mask of palette */ | ||
343 | outb(0xFF, 0x3c6); | ||
344 | outb(0x00, 0x3C8); | ||
345 | if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name && | ||
346 | rev >= 15) { | ||
347 | shift = 8; | ||
348 | viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5); | ||
349 | viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7); | ||
350 | } else { | ||
351 | shift = 10; | ||
352 | viafb_write_reg_mask(CR6A, VIACR, 0, BIT5); | ||
353 | viafb_write_reg_mask(SR15, VIASR, 0, BIT7); | ||
354 | } | ||
355 | for (i = 0; i < len; i++) { | ||
356 | outb((*(pred + i)) >> shift, 0x3C9); | ||
357 | outb((*(pgreen + i)) >> shift, 0x3C9); | ||
358 | outb((*(pblue + i)) >> shift, 0x3C9); | ||
359 | } | ||
360 | 290 | ||
361 | outb(0x1A, 0x3C4); | 291 | if (!viafb_dual_fb || viapar->iga_path == IGA2) |
362 | /* Map the 3C6/7/8/9 to the IGA1 */ | 292 | viafb_set_secondary_color_register(regno, red >> 8, |
363 | outb(sr1a & 0xFE, 0x3C5); | 293 | green >> 8, blue >> 8); |
364 | /* Bit mask of palette */ | 294 | } else { |
365 | outb(0xFF, 0x3c6); | 295 | if (regno > 15) |
366 | outb(0x00, 0x3C8); | 296 | return -EINVAL; |
367 | for (i = 0; i < len; i++) { | ||
368 | outb((*(pred + i)) >> shift, 0x3C9); | ||
369 | outb((*(pgreen + i)) >> shift, 0x3C9); | ||
370 | outb((*(pblue + i)) >> shift, 0x3C9); | ||
371 | } | ||
372 | 297 | ||
373 | outb(0x1A, 0x3C4); | 298 | r = (red >> (16 - info->var.red.length)) |
374 | outb(sr1a, 0x3C5); | 299 | << info->var.red.offset; |
375 | outb(0x1B, 0x3C4); | 300 | b = (blue >> (16 - info->var.blue.length)) |
376 | outb(sr1b, 0x3C5); | 301 | << info->var.blue.offset; |
377 | outb(0x67, 0x3D4); | 302 | g = (green >> (16 - info->var.green.length)) |
378 | outb(cr67, 0x3D5); | 303 | << info->var.green.offset; |
379 | outb(0x6A, 0x3D4); | 304 | ((u32 *) info->pseudo_palette)[regno] = r | g | b; |
380 | outb(cr6a, 0x3D5); | ||
381 | break; | ||
382 | case 16: | ||
383 | if (len > 17) | ||
384 | return 0; /* Because static u32 pseudo_pal[17]; */ | ||
385 | for (i = 0; i < len; i++) | ||
386 | ((u32 *) info->pseudo_palette)[i] = | ||
387 | (*(pred + i) & 0xF800) | | ||
388 | ((*(pgreen + i) & 0xFC00) >> 5) | | ||
389 | ((*(pblue + i) & 0xF800) >> 11); | ||
390 | break; | ||
391 | case 32: | ||
392 | if (len > 17) | ||
393 | return 0; | ||
394 | if (ptransp) { | ||
395 | for (i = 0; i < len; i++) | ||
396 | ((u32 *) info->pseudo_palette)[i] = | ||
397 | ((*(ptransp + i) & 0xFF00) << 16) | | ||
398 | ((*(pred + i) & 0xFF00) << 8) | | ||
399 | ((*(pgreen + i) & 0xFF00)) | | ||
400 | ((*(pblue + i) & 0xFF00) >> 8); | ||
401 | } else { | ||
402 | for (i = 0; i < len; i++) | ||
403 | ((u32 *) info->pseudo_palette)[i] = | ||
404 | 0x00000000 | | ||
405 | ((*(pred + i) & 0xFF00) << 8) | | ||
406 | ((*(pgreen + i) & 0xFF00)) | | ||
407 | ((*(pblue + i) & 0xFF00) >> 8); | ||
408 | } | ||
409 | break; | ||
410 | } | 305 | } |
306 | |||
411 | return 0; | 307 | return 0; |
412 | } | 308 | } |
413 | 309 | ||
414 | static int viafb_pan_display(struct fb_var_screeninfo *var, | 310 | static int viafb_pan_display(struct fb_var_screeninfo *var, |
415 | struct fb_info *info) | 311 | struct fb_info *info) |
416 | { | 312 | { |
417 | unsigned int offset; | 313 | struct viafb_par *viapar = info->par; |
418 | 314 | u32 vram_addr = (var->yoffset * var->xres_virtual + var->xoffset) | |
419 | DEBUG_MSG(KERN_INFO "viafb_pan_display!\n"); | 315 | * (var->bits_per_pixel / 8) + viapar->vram_addr; |
420 | 316 | ||
421 | offset = (var->xoffset + (var->yoffset * var->xres_virtual)) * | 317 | DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr); |
422 | var->bits_per_pixel / 16; | 318 | if (!viafb_dual_fb) { |
319 | viafb_set_primary_address(vram_addr); | ||
320 | viafb_set_secondary_address(vram_addr); | ||
321 | } else if (viapar->iga_path == IGA1) | ||
322 | viafb_set_primary_address(vram_addr); | ||
323 | else | ||
324 | viafb_set_secondary_address(vram_addr); | ||
423 | 325 | ||
424 | DEBUG_MSG(KERN_INFO "\nviafb_pan_display,offset =%d ", offset); | ||
425 | viafb_set_primary_address(offset); | ||
426 | return 0; | 326 | return 0; |
427 | } | 327 | } |
428 | 328 | ||
@@ -476,6 +376,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) | |||
476 | u32 gpu32; | 376 | u32 gpu32; |
477 | 377 | ||
478 | DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd); | 378 | DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd); |
379 | printk(KERN_WARNING "viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n"); | ||
479 | memset(&u, 0, sizeof(u)); | 380 | memset(&u, 0, sizeof(u)); |
480 | 381 | ||
481 | switch (cmd) { | 382 | switch (cmd) { |
@@ -1015,23 +916,6 @@ static int viafb_sync(struct fb_info *info) | |||
1015 | return 0; | 916 | return 0; |
1016 | } | 917 | } |
1017 | 918 | ||
1018 | int viafb_get_mode_index(int hres, int vres) | ||
1019 | { | ||
1020 | u32 i; | ||
1021 | DEBUG_MSG(KERN_INFO "viafb_get_mode_index!\n"); | ||
1022 | |||
1023 | for (i = 0; i < NUM_TOTAL_MODETABLE; i++) | ||
1024 | if (CLE266Modes[i].mode_array && | ||
1025 | CLE266Modes[i].crtc[0].crtc.hor_addr == hres && | ||
1026 | CLE266Modes[i].crtc[0].crtc.ver_addr == vres) | ||
1027 | break; | ||
1028 | |||
1029 | if (i == NUM_TOTAL_MODETABLE) | ||
1030 | return VIA_RES_INVALID; | ||
1031 | |||
1032 | return CLE266Modes[i].ModeIndex; | ||
1033 | } | ||
1034 | |||
1035 | static void check_available_device_to_enable(int device_id) | 919 | static void check_available_device_to_enable(int device_id) |
1036 | { | 920 | { |
1037 | int device_num = 0; | 921 | int device_num = 0; |
@@ -1330,7 +1214,7 @@ static void retrieve_device_setting(struct viafb_ioctl_setting | |||
1330 | setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode; | 1214 | setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode; |
1331 | } | 1215 | } |
1332 | 1216 | ||
1333 | static void parse_active_dev(void) | 1217 | static int parse_active_dev(void) |
1334 | { | 1218 | { |
1335 | viafb_CRT_ON = STATE_OFF; | 1219 | viafb_CRT_ON = STATE_OFF; |
1336 | viafb_DVI_ON = STATE_OFF; | 1220 | viafb_DVI_ON = STATE_OFF; |
@@ -1341,60 +1225,63 @@ static void parse_active_dev(void) | |||
1341 | IGA path to devices in SAMM case. */ | 1225 | IGA path to devices in SAMM case. */ |
1342 | /* Note: The previous of active_dev is primary device, | 1226 | /* Note: The previous of active_dev is primary device, |
1343 | and the following is secondary device. */ | 1227 | and the following is secondary device. */ |
1344 | if (!strncmp(viafb_active_dev, "CRT+DVI", 7)) { | 1228 | if (!viafb_active_dev) { |
1229 | viafb_CRT_ON = STATE_ON; | ||
1230 | viafb_SAMM_ON = STATE_OFF; | ||
1231 | } else if (!strcmp(viafb_active_dev, "CRT+DVI")) { | ||
1345 | /* CRT+DVI */ | 1232 | /* CRT+DVI */ |
1346 | viafb_CRT_ON = STATE_ON; | 1233 | viafb_CRT_ON = STATE_ON; |
1347 | viafb_DVI_ON = STATE_ON; | 1234 | viafb_DVI_ON = STATE_ON; |
1348 | viafb_primary_dev = CRT_Device; | 1235 | viafb_primary_dev = CRT_Device; |
1349 | } else if (!strncmp(viafb_active_dev, "DVI+CRT", 7)) { | 1236 | } else if (!strcmp(viafb_active_dev, "DVI+CRT")) { |
1350 | /* DVI+CRT */ | 1237 | /* DVI+CRT */ |
1351 | viafb_CRT_ON = STATE_ON; | 1238 | viafb_CRT_ON = STATE_ON; |
1352 | viafb_DVI_ON = STATE_ON; | 1239 | viafb_DVI_ON = STATE_ON; |
1353 | viafb_primary_dev = DVI_Device; | 1240 | viafb_primary_dev = DVI_Device; |
1354 | } else if (!strncmp(viafb_active_dev, "CRT+LCD", 7)) { | 1241 | } else if (!strcmp(viafb_active_dev, "CRT+LCD")) { |
1355 | /* CRT+LCD */ | 1242 | /* CRT+LCD */ |
1356 | viafb_CRT_ON = STATE_ON; | 1243 | viafb_CRT_ON = STATE_ON; |
1357 | viafb_LCD_ON = STATE_ON; | 1244 | viafb_LCD_ON = STATE_ON; |
1358 | viafb_primary_dev = CRT_Device; | 1245 | viafb_primary_dev = CRT_Device; |
1359 | } else if (!strncmp(viafb_active_dev, "LCD+CRT", 7)) { | 1246 | } else if (!strcmp(viafb_active_dev, "LCD+CRT")) { |
1360 | /* LCD+CRT */ | 1247 | /* LCD+CRT */ |
1361 | viafb_CRT_ON = STATE_ON; | 1248 | viafb_CRT_ON = STATE_ON; |
1362 | viafb_LCD_ON = STATE_ON; | 1249 | viafb_LCD_ON = STATE_ON; |
1363 | viafb_primary_dev = LCD_Device; | 1250 | viafb_primary_dev = LCD_Device; |
1364 | } else if (!strncmp(viafb_active_dev, "DVI+LCD", 7)) { | 1251 | } else if (!strcmp(viafb_active_dev, "DVI+LCD")) { |
1365 | /* DVI+LCD */ | 1252 | /* DVI+LCD */ |
1366 | viafb_DVI_ON = STATE_ON; | 1253 | viafb_DVI_ON = STATE_ON; |
1367 | viafb_LCD_ON = STATE_ON; | 1254 | viafb_LCD_ON = STATE_ON; |
1368 | viafb_primary_dev = DVI_Device; | 1255 | viafb_primary_dev = DVI_Device; |
1369 | } else if (!strncmp(viafb_active_dev, "LCD+DVI", 7)) { | 1256 | } else if (!strcmp(viafb_active_dev, "LCD+DVI")) { |
1370 | /* LCD+DVI */ | 1257 | /* LCD+DVI */ |
1371 | viafb_DVI_ON = STATE_ON; | 1258 | viafb_DVI_ON = STATE_ON; |
1372 | viafb_LCD_ON = STATE_ON; | 1259 | viafb_LCD_ON = STATE_ON; |
1373 | viafb_primary_dev = LCD_Device; | 1260 | viafb_primary_dev = LCD_Device; |
1374 | } else if (!strncmp(viafb_active_dev, "LCD+LCD2", 8)) { | 1261 | } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) { |
1375 | viafb_LCD_ON = STATE_ON; | 1262 | viafb_LCD_ON = STATE_ON; |
1376 | viafb_LCD2_ON = STATE_ON; | 1263 | viafb_LCD2_ON = STATE_ON; |
1377 | viafb_primary_dev = LCD_Device; | 1264 | viafb_primary_dev = LCD_Device; |
1378 | } else if (!strncmp(viafb_active_dev, "LCD2+LCD", 8)) { | 1265 | } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) { |
1379 | viafb_LCD_ON = STATE_ON; | 1266 | viafb_LCD_ON = STATE_ON; |
1380 | viafb_LCD2_ON = STATE_ON; | 1267 | viafb_LCD2_ON = STATE_ON; |
1381 | viafb_primary_dev = LCD2_Device; | 1268 | viafb_primary_dev = LCD2_Device; |
1382 | } else if (!strncmp(viafb_active_dev, "CRT", 3)) { | 1269 | } else if (!strcmp(viafb_active_dev, "CRT")) { |
1383 | /* CRT only */ | 1270 | /* CRT only */ |
1384 | viafb_CRT_ON = STATE_ON; | 1271 | viafb_CRT_ON = STATE_ON; |
1385 | viafb_SAMM_ON = STATE_OFF; | 1272 | viafb_SAMM_ON = STATE_OFF; |
1386 | } else if (!strncmp(viafb_active_dev, "DVI", 3)) { | 1273 | } else if (!strcmp(viafb_active_dev, "DVI")) { |
1387 | /* DVI only */ | 1274 | /* DVI only */ |
1388 | viafb_DVI_ON = STATE_ON; | 1275 | viafb_DVI_ON = STATE_ON; |
1389 | viafb_SAMM_ON = STATE_OFF; | 1276 | viafb_SAMM_ON = STATE_OFF; |
1390 | } else if (!strncmp(viafb_active_dev, "LCD", 3)) { | 1277 | } else if (!strcmp(viafb_active_dev, "LCD")) { |
1391 | /* LCD only */ | 1278 | /* LCD only */ |
1392 | viafb_LCD_ON = STATE_ON; | 1279 | viafb_LCD_ON = STATE_ON; |
1393 | viafb_SAMM_ON = STATE_OFF; | 1280 | viafb_SAMM_ON = STATE_OFF; |
1394 | } else { | 1281 | } else |
1395 | viafb_CRT_ON = STATE_ON; | 1282 | return -EINVAL; |
1396 | viafb_SAMM_ON = STATE_OFF; | 1283 | |
1397 | } | 1284 | return 0; |
1398 | } | 1285 | } |
1399 | 1286 | ||
1400 | static int parse_port(char *opt_str, int *output_interface) | 1287 | static int parse_port(char *opt_str, int *output_interface) |
@@ -1823,35 +1710,37 @@ static void viafb_remove_proc(struct proc_dir_entry *viafb_entry) | |||
1823 | remove_proc_entry("viafb", NULL); | 1710 | remove_proc_entry("viafb", NULL); |
1824 | } | 1711 | } |
1825 | 1712 | ||
1826 | static void parse_mode(const char *str, u32 *xres, u32 *yres) | 1713 | static int parse_mode(const char *str, u32 *xres, u32 *yres) |
1827 | { | 1714 | { |
1828 | char *ptr; | 1715 | char *ptr; |
1829 | 1716 | ||
1717 | if (!str) { | ||
1718 | *xres = 640; | ||
1719 | *yres = 480; | ||
1720 | return 0; | ||
1721 | } | ||
1722 | |||
1830 | *xres = simple_strtoul(str, &ptr, 10); | 1723 | *xres = simple_strtoul(str, &ptr, 10); |
1831 | if (ptr[0] != 'x') | 1724 | if (ptr[0] != 'x') |
1832 | goto out_default; | 1725 | return -EINVAL; |
1833 | 1726 | ||
1834 | *yres = simple_strtoul(&ptr[1], &ptr, 10); | 1727 | *yres = simple_strtoul(&ptr[1], &ptr, 10); |
1835 | if (ptr[0]) | 1728 | if (ptr[0]) |
1836 | goto out_default; | 1729 | return -EINVAL; |
1837 | |||
1838 | return; | ||
1839 | 1730 | ||
1840 | out_default: | 1731 | return 0; |
1841 | printk(KERN_WARNING "viafb received invalid mode string: %s\n", str); | ||
1842 | *xres = 640; | ||
1843 | *yres = 480; | ||
1844 | } | 1732 | } |
1845 | 1733 | ||
1846 | static int __devinit via_pci_probe(struct pci_dev *pdev, | 1734 | static int __devinit via_pci_probe(struct pci_dev *pdev, |
1847 | const struct pci_device_id *ent) | 1735 | const struct pci_device_id *ent) |
1848 | { | 1736 | { |
1849 | u32 default_xres, default_yres; | 1737 | u32 default_xres, default_yres; |
1850 | int vmode_index; | 1738 | struct VideoModeTable *vmode_entry; |
1739 | struct fb_var_screeninfo default_var; | ||
1851 | u32 viafb_par_length; | 1740 | u32 viafb_par_length; |
1852 | 1741 | ||
1853 | DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n"); | 1742 | DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n"); |
1854 | 1743 | memset(&default_var, 0, sizeof(default_var)); | |
1855 | viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8); | 1744 | viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8); |
1856 | 1745 | ||
1857 | /* Allocate fb_info and ***_par here, also including some other needed | 1746 | /* Allocate fb_info and ***_par here, also including some other needed |
@@ -1877,7 +1766,6 @@ static int __devinit via_pci_probe(struct pci_dev *pdev, | |||
1877 | 1766 | ||
1878 | if (viafb_dual_fb) | 1767 | if (viafb_dual_fb) |
1879 | viafb_SAMM_ON = 1; | 1768 | viafb_SAMM_ON = 1; |
1880 | parse_active_dev(); | ||
1881 | parse_lcd_port(); | 1769 | parse_lcd_port(); |
1882 | parse_dvi_port(); | 1770 | parse_dvi_port(); |
1883 | 1771 | ||
@@ -1926,9 +1814,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev, | |||
1926 | } | 1814 | } |
1927 | 1815 | ||
1928 | parse_mode(viafb_mode, &default_xres, &default_yres); | 1816 | parse_mode(viafb_mode, &default_xres, &default_yres); |
1929 | vmode_index = viafb_get_mode_index(default_xres, default_yres); | 1817 | vmode_entry = viafb_get_mode(default_xres, default_yres); |
1930 | DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index); | ||
1931 | |||
1932 | if (viafb_SAMM_ON == 1) { | 1818 | if (viafb_SAMM_ON == 1) { |
1933 | parse_mode(viafb_mode1, &viafb_second_xres, | 1819 | parse_mode(viafb_mode1, &viafb_second_xres, |
1934 | &viafb_second_yres); | 1820 | &viafb_second_yres); |
@@ -1947,19 +1833,6 @@ static int __devinit via_pci_probe(struct pci_dev *pdev, | |||
1947 | viafb_second_virtual_yres = viafb_second_yres; | 1833 | viafb_second_virtual_yres = viafb_second_yres; |
1948 | } | 1834 | } |
1949 | 1835 | ||
1950 | switch (viafb_bpp) { | ||
1951 | case 0 ... 8: | ||
1952 | viafb_bpp = 8; | ||
1953 | break; | ||
1954 | case 9 ... 16: | ||
1955 | viafb_bpp = 16; | ||
1956 | break; | ||
1957 | case 17 ... 32: | ||
1958 | viafb_bpp = 32; | ||
1959 | break; | ||
1960 | default: | ||
1961 | viafb_bpp = 8; | ||
1962 | } | ||
1963 | default_var.xres = default_xres; | 1836 | default_var.xres = default_xres; |
1964 | default_var.yres = default_yres; | 1837 | default_var.yres = default_yres; |
1965 | switch (default_xres) { | 1838 | switch (default_xres) { |
@@ -1972,8 +1845,6 @@ static int __devinit via_pci_probe(struct pci_dev *pdev, | |||
1972 | } | 1845 | } |
1973 | default_var.yres_virtual = default_yres; | 1846 | default_var.yres_virtual = default_yres; |
1974 | default_var.bits_per_pixel = viafb_bpp; | 1847 | default_var.bits_per_pixel = viafb_bpp; |
1975 | if (default_var.bits_per_pixel == 15) | ||
1976 | default_var.bits_per_pixel = 16; | ||
1977 | default_var.pixclock = | 1848 | default_var.pixclock = |
1978 | viafb_get_pixclock(default_xres, default_yres, viafb_refresh); | 1849 | viafb_get_pixclock(default_xres, default_yres, viafb_refresh); |
1979 | default_var.left_margin = (default_xres >> 3) & 0xf8; | 1850 | default_var.left_margin = (default_xres >> 3) & 0xf8; |
@@ -1982,6 +1853,8 @@ static int __devinit via_pci_probe(struct pci_dev *pdev, | |||
1982 | default_var.lower_margin = 4; | 1853 | default_var.lower_margin = 4; |
1983 | default_var.hsync_len = default_var.left_margin; | 1854 | default_var.hsync_len = default_var.left_margin; |
1984 | default_var.vsync_len = 4; | 1855 | default_var.vsync_len = 4; |
1856 | viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo); | ||
1857 | viafbinfo->var = default_var; | ||
1985 | 1858 | ||
1986 | if (viafb_dual_fb) { | 1859 | if (viafb_dual_fb) { |
1987 | viafbinfo1 = framebuffer_alloc(viafb_par_length, &pdev->dev); | 1860 | viafbinfo1 = framebuffer_alloc(viafb_par_length, &pdev->dev); |
@@ -2016,8 +1889,6 @@ static int __devinit via_pci_probe(struct pci_dev *pdev, | |||
2016 | default_var.yres = viafb_second_yres; | 1889 | default_var.yres = viafb_second_yres; |
2017 | default_var.xres_virtual = viafb_second_virtual_xres; | 1890 | default_var.xres_virtual = viafb_second_virtual_xres; |
2018 | default_var.yres_virtual = viafb_second_virtual_yres; | 1891 | default_var.yres_virtual = viafb_second_virtual_yres; |
2019 | if (viafb_bpp1 != viafb_bpp) | ||
2020 | viafb_bpp1 = viafb_bpp; | ||
2021 | default_var.bits_per_pixel = viafb_bpp1; | 1892 | default_var.bits_per_pixel = viafb_bpp1; |
2022 | default_var.pixclock = | 1893 | default_var.pixclock = |
2023 | viafb_get_pixclock(viafb_second_xres, viafb_second_yres, | 1894 | viafb_get_pixclock(viafb_second_xres, viafb_second_yres, |
@@ -2037,9 +1908,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev, | |||
2037 | &viafbinfo1->fix); | 1908 | &viafbinfo1->fix); |
2038 | } | 1909 | } |
2039 | 1910 | ||
2040 | viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo); | 1911 | viafb_check_var(&viafbinfo->var, viafbinfo); |
2041 | viafb_check_var(&default_var, viafbinfo); | ||
2042 | viafbinfo->var = default_var; | ||
2043 | viafb_update_fix(viafbinfo); | 1912 | viafb_update_fix(viafbinfo); |
2044 | viaparinfo->depth = fb_get_color_depth(&viafbinfo->var, | 1913 | viaparinfo->depth = fb_get_color_depth(&viafbinfo->var, |
2045 | &viafbinfo->fix); | 1914 | &viafbinfo->fix); |
@@ -2197,12 +2066,20 @@ static struct pci_driver viafb_driver = { | |||
2197 | 2066 | ||
2198 | static int __init viafb_init(void) | 2067 | static int __init viafb_init(void) |
2199 | { | 2068 | { |
2069 | u32 dummy; | ||
2200 | #ifndef MODULE | 2070 | #ifndef MODULE |
2201 | char *option = NULL; | 2071 | char *option = NULL; |
2202 | if (fb_get_options("viafb", &option)) | 2072 | if (fb_get_options("viafb", &option)) |
2203 | return -ENODEV; | 2073 | return -ENODEV; |
2204 | viafb_setup(option); | 2074 | viafb_setup(option); |
2205 | #endif | 2075 | #endif |
2076 | if (parse_mode(viafb_mode, &dummy, &dummy) | ||
2077 | || parse_mode(viafb_mode1, &dummy, &dummy) | ||
2078 | || viafb_bpp < 0 || viafb_bpp > 32 | ||
2079 | || viafb_bpp1 < 0 || viafb_bpp1 > 32 | ||
2080 | || parse_active_dev()) | ||
2081 | return -EINVAL; | ||
2082 | |||
2206 | printk(KERN_INFO | 2083 | printk(KERN_INFO |
2207 | "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n", | 2084 | "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n", |
2208 | VERSION_MAJOR, VERSION_MINOR); | 2085 | VERSION_MAJOR, VERSION_MINOR); |
@@ -2230,15 +2107,12 @@ static struct fb_ops viafb_ops = { | |||
2230 | .fb_cursor = viafb_cursor, | 2107 | .fb_cursor = viafb_cursor, |
2231 | .fb_ioctl = viafb_ioctl, | 2108 | .fb_ioctl = viafb_ioctl, |
2232 | .fb_sync = viafb_sync, | 2109 | .fb_sync = viafb_sync, |
2233 | .fb_setcmap = viafb_setcmap, | ||
2234 | }; | 2110 | }; |
2235 | 2111 | ||
2236 | module_init(viafb_init); | 2112 | module_init(viafb_init); |
2237 | module_exit(viafb_exit); | 2113 | module_exit(viafb_exit); |
2238 | 2114 | ||
2239 | #ifdef MODULE | 2115 | #ifdef MODULE |
2240 | module_param(viafb_memsize, int, S_IRUSR); | ||
2241 | |||
2242 | module_param(viafb_mode, charp, S_IRUSR); | 2116 | module_param(viafb_mode, charp, S_IRUSR); |
2243 | MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)"); | 2117 | MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)"); |
2244 | 2118 | ||
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h index 0c94d2441922..61b5953cd159 100644 --- a/drivers/video/via/viafbdev.h +++ b/drivers/video/via/viafbdev.h | |||
@@ -83,22 +83,16 @@ struct viafb_par { | |||
83 | 83 | ||
84 | extern unsigned int viafb_second_virtual_yres; | 84 | extern unsigned int viafb_second_virtual_yres; |
85 | extern unsigned int viafb_second_virtual_xres; | 85 | extern unsigned int viafb_second_virtual_xres; |
86 | extern unsigned int viafb_second_offset; | ||
87 | extern int viafb_second_size; | ||
88 | extern int viafb_SAMM_ON; | 86 | extern int viafb_SAMM_ON; |
89 | extern int viafb_dual_fb; | 87 | extern int viafb_dual_fb; |
90 | extern int viafb_LCD2_ON; | 88 | extern int viafb_LCD2_ON; |
91 | extern int viafb_LCD_ON; | 89 | extern int viafb_LCD_ON; |
92 | extern int viafb_DVI_ON; | 90 | extern int viafb_DVI_ON; |
93 | extern int viafb_hotplug; | 91 | extern int viafb_hotplug; |
94 | extern int viafb_memsize; | ||
95 | 92 | ||
96 | extern int strict_strtoul(const char *cp, unsigned int base, | 93 | extern int strict_strtoul(const char *cp, unsigned int base, |
97 | unsigned long *res); | 94 | unsigned long *res); |
98 | 95 | ||
99 | void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, | ||
100 | int mode_index); | ||
101 | int viafb_get_mode_index(int hres, int vres); | ||
102 | u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information | 96 | u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information |
103 | *plvds_setting_info, struct lvds_chip_information | 97 | *plvds_setting_info, struct lvds_chip_information |
104 | *plvds_chip_info, u8 index); | 98 | *plvds_chip_info, u8 index); |
diff --git a/drivers/video/via/viamode.c b/drivers/video/via/viamode.c index b74f8a67923c..af50e244016c 100644 --- a/drivers/video/via/viamode.c +++ b/drivers/video/via/viamode.c | |||
@@ -412,7 +412,7 @@ struct io_reg PM1024x768[] = { {VIASR, 0x16, 0xBF, 0x0C}, | |||
412 | }; | 412 | }; |
413 | 413 | ||
414 | struct patch_table res_patch_table[] = { | 414 | struct patch_table res_patch_table[] = { |
415 | {VIA_RES_1024X768, ARRAY_SIZE(PM1024x768), PM1024x768} | 415 | {ARRAY_SIZE(PM1024x768), PM1024x768} |
416 | }; | 416 | }; |
417 | 417 | ||
418 | /* struct VPITTable { | 418 | /* struct VPITTable { |
@@ -879,169 +879,151 @@ struct crt_mode_table CRTM2048x1536[] = { | |||
879 | {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} } | 879 | {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} } |
880 | }; | 880 | }; |
881 | 881 | ||
882 | /* Video Mode Table */ | 882 | struct VideoModeTable viafb_modes[] = { |
883 | /* struct VideoModeTable {*/ | ||
884 | /* int ModeIndex;*/ | ||
885 | /* struct crt_mode_table *crtc;*/ | ||
886 | /* int mode_array;*/ | ||
887 | /* };*/ | ||
888 | struct VideoModeTable CLE266Modes[] = { | ||
889 | /* Display : 480x640 (GTF) */ | 883 | /* Display : 480x640 (GTF) */ |
890 | {VIA_RES_480X640, CRTM480x640, ARRAY_SIZE(CRTM480x640)}, | 884 | {CRTM480x640, ARRAY_SIZE(CRTM480x640)}, |
891 | 885 | ||
892 | /* Display : 640x480 */ | 886 | /* Display : 640x480 */ |
893 | {VIA_RES_640X480, CRTM640x480, ARRAY_SIZE(CRTM640x480)}, | 887 | {CRTM640x480, ARRAY_SIZE(CRTM640x480)}, |
894 | 888 | ||
895 | /* Display : 720x480 (GTF) */ | 889 | /* Display : 720x480 (GTF) */ |
896 | {VIA_RES_720X480, CRTM720x480, ARRAY_SIZE(CRTM720x480)}, | 890 | {CRTM720x480, ARRAY_SIZE(CRTM720x480)}, |
897 | 891 | ||
898 | /* Display : 720x576 (GTF) */ | 892 | /* Display : 720x576 (GTF) */ |
899 | {VIA_RES_720X576, CRTM720x576, ARRAY_SIZE(CRTM720x576)}, | 893 | {CRTM720x576, ARRAY_SIZE(CRTM720x576)}, |
900 | 894 | ||
901 | /* Display : 800x600 */ | 895 | /* Display : 800x600 */ |
902 | {VIA_RES_800X600, CRTM800x600, ARRAY_SIZE(CRTM800x600)}, | 896 | {CRTM800x600, ARRAY_SIZE(CRTM800x600)}, |
903 | 897 | ||
904 | /* Display : 800x480 (CVT) */ | 898 | /* Display : 800x480 (CVT) */ |
905 | {VIA_RES_800X480, CRTM800x480, ARRAY_SIZE(CRTM800x480)}, | 899 | {CRTM800x480, ARRAY_SIZE(CRTM800x480)}, |
906 | 900 | ||
907 | /* Display : 848x480 (CVT) */ | 901 | /* Display : 848x480 (CVT) */ |
908 | {VIA_RES_848X480, CRTM848x480, ARRAY_SIZE(CRTM848x480)}, | 902 | {CRTM848x480, ARRAY_SIZE(CRTM848x480)}, |
909 | 903 | ||
910 | /* Display : 852x480 (GTF) */ | 904 | /* Display : 852x480 (GTF) */ |
911 | {VIA_RES_856X480, CRTM852x480, ARRAY_SIZE(CRTM852x480)}, | 905 | {CRTM852x480, ARRAY_SIZE(CRTM852x480)}, |
912 | 906 | ||
913 | /* Display : 1024x512 (GTF) */ | 907 | /* Display : 1024x512 (GTF) */ |
914 | {VIA_RES_1024X512, CRTM1024x512, ARRAY_SIZE(CRTM1024x512)}, | 908 | {CRTM1024x512, ARRAY_SIZE(CRTM1024x512)}, |
915 | 909 | ||
916 | /* Display : 1024x600 */ | 910 | /* Display : 1024x600 */ |
917 | {VIA_RES_1024X600, CRTM1024x600, ARRAY_SIZE(CRTM1024x600)}, | 911 | {CRTM1024x600, ARRAY_SIZE(CRTM1024x600)}, |
918 | |||
919 | /* Display : 1024x576 (GTF) */ | ||
920 | /*{ VIA_RES_1024X576, CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, */ | ||
921 | 912 | ||
922 | /* Display : 1024x768 */ | 913 | /* Display : 1024x768 */ |
923 | {VIA_RES_1024X768, CRTM1024x768, ARRAY_SIZE(CRTM1024x768)}, | 914 | {CRTM1024x768, ARRAY_SIZE(CRTM1024x768)}, |
924 | 915 | ||
925 | /* Display : 1152x864 */ | 916 | /* Display : 1152x864 */ |
926 | {VIA_RES_1152X864, CRTM1152x864, ARRAY_SIZE(CRTM1152x864)}, | 917 | {CRTM1152x864, ARRAY_SIZE(CRTM1152x864)}, |
927 | 918 | ||
928 | /* Display : 1280x768 (GTF) */ | 919 | /* Display : 1280x768 (GTF) */ |
929 | {VIA_RES_1280X768, CRTM1280x768, ARRAY_SIZE(CRTM1280x768)}, | 920 | {CRTM1280x768, ARRAY_SIZE(CRTM1280x768)}, |
930 | 921 | ||
931 | /* Display : 960x600 (CVT) */ | 922 | /* Display : 960x600 (CVT) */ |
932 | {VIA_RES_960X600, CRTM960x600, ARRAY_SIZE(CRTM960x600)}, | 923 | {CRTM960x600, ARRAY_SIZE(CRTM960x600)}, |
933 | 924 | ||
934 | /* Display : 1000x600 (GTF) */ | 925 | /* Display : 1000x600 (GTF) */ |
935 | {VIA_RES_1000X600, CRTM1000x600, ARRAY_SIZE(CRTM1000x600)}, | 926 | {CRTM1000x600, ARRAY_SIZE(CRTM1000x600)}, |
936 | 927 | ||
937 | /* Display : 1024x576 (GTF) */ | 928 | /* Display : 1024x576 (GTF) */ |
938 | {VIA_RES_1024X576, CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, | 929 | {CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, |
939 | 930 | ||
940 | /* Display : 1088x612 (GTF) */ | 931 | /* Display : 1088x612 (GTF) */ |
941 | {VIA_RES_1088X612, CRTM1088x612, ARRAY_SIZE(CRTM1088x612)}, | 932 | {CRTM1088x612, ARRAY_SIZE(CRTM1088x612)}, |
942 | 933 | ||
943 | /* Display : 1152x720 (CVT) */ | 934 | /* Display : 1152x720 (CVT) */ |
944 | {VIA_RES_1152X720, CRTM1152x720, ARRAY_SIZE(CRTM1152x720)}, | 935 | {CRTM1152x720, ARRAY_SIZE(CRTM1152x720)}, |
945 | 936 | ||
946 | /* Display : 1200x720 (GTF) */ | 937 | /* Display : 1200x720 (GTF) */ |
947 | {VIA_RES_1200X720, CRTM1200x720, ARRAY_SIZE(CRTM1200x720)}, | 938 | {CRTM1200x720, ARRAY_SIZE(CRTM1200x720)}, |
948 | 939 | ||
949 | /* Display : 1280x600 (GTF) */ | 940 | /* Display : 1280x600 (GTF) */ |
950 | {VIA_RES_1280X600, CRTM1280x600, ARRAY_SIZE(CRTM1280x600)}, | 941 | {CRTM1280x600, ARRAY_SIZE(CRTM1280x600)}, |
951 | 942 | ||
952 | /* Display : 1280x800 (CVT) */ | 943 | /* Display : 1280x800 (CVT) */ |
953 | {VIA_RES_1280X800, CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, | 944 | {CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, |
954 | |||
955 | /* Display : 1280x800 (GTF) */ | ||
956 | /*{ M1280x800, CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, */ | ||
957 | 945 | ||
958 | /* Display : 1280x960 */ | 946 | /* Display : 1280x960 */ |
959 | {VIA_RES_1280X960, CRTM1280x960, ARRAY_SIZE(CRTM1280x960)}, | 947 | {CRTM1280x960, ARRAY_SIZE(CRTM1280x960)}, |
960 | 948 | ||
961 | /* Display : 1280x1024 */ | 949 | /* Display : 1280x1024 */ |
962 | {VIA_RES_1280X1024, CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)}, | 950 | {CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)}, |
963 | 951 | ||
964 | /* Display : 1360x768 (CVT) */ | 952 | /* Display : 1360x768 (CVT) */ |
965 | {VIA_RES_1360X768, CRTM1360x768, ARRAY_SIZE(CRTM1360x768)}, | 953 | {CRTM1360x768, ARRAY_SIZE(CRTM1360x768)}, |
966 | |||
967 | /* Display : 1360x768 (CVT Reduce Blanking) */ | ||
968 | {VIA_RES_1360X768_RB, CRTM1360x768_RB, | ||
969 | ARRAY_SIZE(CRTM1360x768_RB)}, | ||
970 | 954 | ||
971 | /* Display : 1366x768 */ | 955 | /* Display : 1366x768 */ |
972 | {VIA_RES_1366X768, CRTM1366x768, ARRAY_SIZE(CRTM1366x768)}, | 956 | {CRTM1366x768, ARRAY_SIZE(CRTM1366x768)}, |
973 | 957 | ||
974 | /* Display : 1368x768 (GTF) */ | 958 | /* Display : 1368x768 (GTF) */ |
975 | /*{ M1368x768,CRTM1368x768,ARRAY_SIZE(CRTM1368x768)}, */ | 959 | {CRTM1368x768, ARRAY_SIZE(CRTM1368x768)}, |
976 | /* Display : 1368x768 (GTF) */ | ||
977 | {VIA_RES_1368X768, CRTM1368x768, ARRAY_SIZE(CRTM1368x768)}, | ||
978 | 960 | ||
979 | /* Display : 1440x900 (CVT) */ | 961 | /* Display : 1440x900 (CVT) */ |
980 | {VIA_RES_1440X900, CRTM1440x900, ARRAY_SIZE(CRTM1440x900)}, | 962 | {CRTM1440x900, ARRAY_SIZE(CRTM1440x900)}, |
981 | |||
982 | /* Display : 1440x900 (CVT Reduce Blanking) */ | ||
983 | {VIA_RES_1440X900_RB, CRTM1440x900_RB, | ||
984 | ARRAY_SIZE(CRTM1440x900_RB)}, | ||
985 | 963 | ||
986 | /* Display : 1440x1050 (GTF) */ | 964 | /* Display : 1440x1050 (GTF) */ |
987 | {VIA_RES_1440X1050, CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)}, | 965 | {CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)}, |
988 | |||
989 | /* Display : 1400x1050 (CVT Reduce Blanking) */ | ||
990 | {VIA_RES_1400X1050_RB, CRTM1400x1050_RB, | ||
991 | ARRAY_SIZE(CRTM1400x1050_RB)}, | ||
992 | 966 | ||
993 | /* Display : 1600x900 (CVT) */ | 967 | /* Display : 1600x900 (CVT) */ |
994 | {VIA_RES_1600X900, CRTM1600x900, ARRAY_SIZE(CRTM1600x900)}, | 968 | {CRTM1600x900, ARRAY_SIZE(CRTM1600x900)}, |
995 | |||
996 | /* Display : 1600x900 (CVT Reduce Blanking) */ | ||
997 | {VIA_RES_1600X900_RB, CRTM1600x900_RB, | ||
998 | ARRAY_SIZE(CRTM1600x900_RB)}, | ||
999 | 969 | ||
1000 | /* Display : 1600x1024 (GTF) */ | 970 | /* Display : 1600x1024 (GTF) */ |
1001 | {VIA_RES_1600X1024, CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)}, | 971 | {CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)}, |
1002 | 972 | ||
1003 | /* Display : 1600x1200 */ | 973 | /* Display : 1600x1200 */ |
1004 | {VIA_RES_1600X1200, CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)}, | 974 | {CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)}, |
1005 | 975 | ||
1006 | /* Display : 1680x1050 (CVT) */ | 976 | /* Display : 1680x1050 (CVT) */ |
1007 | {VIA_RES_1680X1050, CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)}, | 977 | {CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)}, |
1008 | |||
1009 | /* Display : 1680x1050 (CVT Reduce Blanking) */ | ||
1010 | {VIA_RES_1680X1050_RB, CRTM1680x1050_RB, | ||
1011 | ARRAY_SIZE(CRTM1680x1050_RB)}, | ||
1012 | 978 | ||
1013 | /* Display : 1792x1344 (DMT) */ | 979 | /* Display : 1792x1344 (DMT) */ |
1014 | {VIA_RES_1792X1344, CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)}, | 980 | {CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)}, |
1015 | 981 | ||
1016 | /* Display : 1856x1392 (DMT) */ | 982 | /* Display : 1856x1392 (DMT) */ |
1017 | {VIA_RES_1856X1392, CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)}, | 983 | {CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)}, |
1018 | 984 | ||
1019 | /* Display : 1920x1440 */ | 985 | /* Display : 1920x1440 */ |
1020 | {VIA_RES_1920X1440, CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)}, | 986 | {CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)}, |
1021 | 987 | ||
1022 | /* Display : 2048x1536 */ | 988 | /* Display : 2048x1536 */ |
1023 | {VIA_RES_2048X1536, CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)}, | 989 | {CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)}, |
1024 | 990 | ||
1025 | /* Display : 1280x720 */ | 991 | /* Display : 1280x720 */ |
1026 | {VIA_RES_1280X720, CRTM1280x720, ARRAY_SIZE(CRTM1280x720)}, | 992 | {CRTM1280x720, ARRAY_SIZE(CRTM1280x720)}, |
1027 | 993 | ||
1028 | /* Display : 1920x1080 (CVT) */ | 994 | /* Display : 1920x1080 (CVT) */ |
1029 | {VIA_RES_1920X1080, CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)}, | 995 | {CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)}, |
1030 | |||
1031 | /* Display : 1920x1080 (CVT Reduce Blanking) */ | ||
1032 | {VIA_RES_1920X1080_RB, CRTM1920x1080_RB, | ||
1033 | ARRAY_SIZE(CRTM1920x1080_RB)}, | ||
1034 | 996 | ||
1035 | /* Display : 1920x1200 (CVT) */ | 997 | /* Display : 1920x1200 (CVT) */ |
1036 | {VIA_RES_1920X1200, CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)}, | 998 | {CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)}, |
1037 | |||
1038 | /* Display : 1920x1200 (CVT Reduce Blanking) */ | ||
1039 | {VIA_RES_1920X1200_RB, CRTM1920x1200_RB, | ||
1040 | ARRAY_SIZE(CRTM1920x1200_RB)}, | ||
1041 | 999 | ||
1042 | /* Display : 1400x1050 (CVT) */ | 1000 | /* Display : 1400x1050 (CVT) */ |
1043 | {VIA_RES_1400X1050, CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)} | 1001 | {CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)} |
1044 | }; | 1002 | }; |
1003 | |||
1004 | struct VideoModeTable viafb_rb_modes[] = { | ||
1005 | /* Display : 1360x768 (CVT Reduce Blanking) */ | ||
1006 | {CRTM1360x768_RB, ARRAY_SIZE(CRTM1360x768_RB)}, | ||
1007 | |||
1008 | /* Display : 1440x900 (CVT Reduce Blanking) */ | ||
1009 | {CRTM1440x900_RB, ARRAY_SIZE(CRTM1440x900_RB)}, | ||
1010 | |||
1011 | /* Display : 1400x1050 (CVT Reduce Blanking) */ | ||
1012 | {CRTM1400x1050_RB, ARRAY_SIZE(CRTM1400x1050_RB)}, | ||
1013 | |||
1014 | /* Display : 1600x900 (CVT Reduce Blanking) */ | ||
1015 | {CRTM1600x900_RB, ARRAY_SIZE(CRTM1600x900_RB)}, | ||
1016 | |||
1017 | /* Display : 1680x1050 (CVT Reduce Blanking) */ | ||
1018 | {CRTM1680x1050_RB, ARRAY_SIZE(CRTM1680x1050_RB)}, | ||
1019 | |||
1020 | /* Display : 1920x1080 (CVT Reduce Blanking) */ | ||
1021 | {CRTM1920x1080_RB, ARRAY_SIZE(CRTM1920x1080_RB)}, | ||
1022 | |||
1023 | /* Display : 1920x1200 (CVT Reduce Blanking) */ | ||
1024 | {CRTM1920x1200_RB, ARRAY_SIZE(CRTM1920x1200_RB)} | ||
1025 | }; | ||
1026 | |||
1045 | struct crt_mode_table CEAM1280x720[] = { | 1027 | struct crt_mode_table CEAM1280x720[] = { |
1046 | {REFRESH_60, CLK_74_270M, M1280X720_CEA_R60_HSP, | 1028 | {REFRESH_60, CLK_74_270M, M1280X720_CEA_R60_HSP, |
1047 | M1280X720_CEA_R60_VSP, | 1029 | M1280X720_CEA_R60_VSP, |
@@ -1056,8 +1038,8 @@ struct crt_mode_table CEAM1920x1080[] = { | |||
1056 | }; | 1038 | }; |
1057 | struct VideoModeTable CEA_HDMI_Modes[] = { | 1039 | struct VideoModeTable CEA_HDMI_Modes[] = { |
1058 | /* Display : 1280x720 */ | 1040 | /* Display : 1280x720 */ |
1059 | {VIA_RES_1280X720, CEAM1280x720, ARRAY_SIZE(CEAM1280x720)}, | 1041 | {CEAM1280x720, ARRAY_SIZE(CEAM1280x720)}, |
1060 | {VIA_RES_1920X1080, CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)} | 1042 | {CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)} |
1061 | }; | 1043 | }; |
1062 | 1044 | ||
1063 | int NUM_TOTAL_RES_MAP_REFRESH = ARRAY_SIZE(res_map_refresh_tbl); | 1045 | int NUM_TOTAL_RES_MAP_REFRESH = ARRAY_SIZE(res_map_refresh_tbl); |
@@ -1069,4 +1051,28 @@ int NUM_TOTAL_CX700_ModeXregs = ARRAY_SIZE(CX700_ModeXregs); | |||
1069 | int NUM_TOTAL_VX855_ModeXregs = ARRAY_SIZE(VX855_ModeXregs); | 1051 | int NUM_TOTAL_VX855_ModeXregs = ARRAY_SIZE(VX855_ModeXregs); |
1070 | int NUM_TOTAL_CLE266_ModeXregs = ARRAY_SIZE(CLE266_ModeXregs); | 1052 | int NUM_TOTAL_CLE266_ModeXregs = ARRAY_SIZE(CLE266_ModeXregs); |
1071 | int NUM_TOTAL_PATCH_MODE = ARRAY_SIZE(res_patch_table); | 1053 | int NUM_TOTAL_PATCH_MODE = ARRAY_SIZE(res_patch_table); |
1072 | int NUM_TOTAL_MODETABLE = ARRAY_SIZE(CLE266Modes); | 1054 | |
1055 | |||
1056 | struct VideoModeTable *viafb_get_mode(int hres, int vres) | ||
1057 | { | ||
1058 | u32 i; | ||
1059 | for (i = 0; i < ARRAY_SIZE(viafb_modes); i++) | ||
1060 | if (viafb_modes[i].mode_array && | ||
1061 | viafb_modes[i].crtc[0].crtc.hor_addr == hres && | ||
1062 | viafb_modes[i].crtc[0].crtc.ver_addr == vres) | ||
1063 | return &viafb_modes[i]; | ||
1064 | |||
1065 | return NULL; | ||
1066 | } | ||
1067 | |||
1068 | struct VideoModeTable *viafb_get_rb_mode(int hres, int vres) | ||
1069 | { | ||
1070 | u32 i; | ||
1071 | for (i = 0; i < ARRAY_SIZE(viafb_rb_modes); i++) | ||
1072 | if (viafb_rb_modes[i].mode_array && | ||
1073 | viafb_rb_modes[i].crtc[0].crtc.hor_addr == hres && | ||
1074 | viafb_rb_modes[i].crtc[0].crtc.ver_addr == vres) | ||
1075 | return &viafb_rb_modes[i]; | ||
1076 | |||
1077 | return NULL; | ||
1078 | } | ||
diff --git a/drivers/video/via/viamode.h b/drivers/video/via/viamode.h index a9d6554fabdf..5b1ced86514b 100644 --- a/drivers/video/via/viamode.h +++ b/drivers/video/via/viamode.h | |||
@@ -32,13 +32,11 @@ struct VPITTable { | |||
32 | }; | 32 | }; |
33 | 33 | ||
34 | struct VideoModeTable { | 34 | struct VideoModeTable { |
35 | int ModeIndex; | ||
36 | struct crt_mode_table *crtc; | 35 | struct crt_mode_table *crtc; |
37 | int mode_array; | 36 | int mode_array; |
38 | }; | 37 | }; |
39 | 38 | ||
40 | struct patch_table { | 39 | struct patch_table { |
41 | int mode_index; | ||
42 | int table_length; | 40 | int table_length; |
43 | struct io_reg *io_reg_table; | 41 | struct io_reg *io_reg_table; |
44 | }; | 42 | }; |
@@ -59,13 +57,11 @@ extern int NUM_TOTAL_CX700_ModeXregs; | |||
59 | extern int NUM_TOTAL_VX855_ModeXregs; | 57 | extern int NUM_TOTAL_VX855_ModeXregs; |
60 | extern int NUM_TOTAL_CLE266_ModeXregs; | 58 | extern int NUM_TOTAL_CLE266_ModeXregs; |
61 | extern int NUM_TOTAL_PATCH_MODE; | 59 | extern int NUM_TOTAL_PATCH_MODE; |
62 | extern int NUM_TOTAL_MODETABLE; | ||
63 | 60 | ||
64 | /********************/ | 61 | /********************/ |
65 | /* Mode Table */ | 62 | /* Mode Table */ |
66 | /********************/ | 63 | /********************/ |
67 | 64 | ||
68 | extern struct VideoModeTable CLE266Modes[]; | ||
69 | extern struct crt_mode_table CEAM1280x720[]; | 65 | extern struct crt_mode_table CEAM1280x720[]; |
70 | extern struct crt_mode_table CEAM1920x1080[]; | 66 | extern struct crt_mode_table CEAM1920x1080[]; |
71 | extern struct VideoModeTable CEA_HDMI_Modes[]; | 67 | extern struct VideoModeTable CEA_HDMI_Modes[]; |
@@ -81,4 +77,8 @@ extern struct io_reg CLE266_ModeXregs[]; | |||
81 | extern struct io_reg PM1024x768[]; | 77 | extern struct io_reg PM1024x768[]; |
82 | extern struct patch_table res_patch_table[]; | 78 | extern struct patch_table res_patch_table[]; |
83 | extern struct VPITTable VPIT; | 79 | extern struct VPITTable VPIT; |
80 | |||
81 | struct VideoModeTable *viafb_get_mode(int hres, int vres); | ||
82 | struct VideoModeTable *viafb_get_rb_mode(int hres, int vres); | ||
83 | |||
84 | #endif /* __VIAMODE_H__ */ | 84 | #endif /* __VIAMODE_H__ */ |
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c index 2376f688ec8b..5d223959778a 100644 --- a/drivers/video/w100fb.c +++ b/drivers/video/w100fb.c | |||
@@ -628,7 +628,7 @@ static int w100fb_resume(struct platform_device *dev) | |||
628 | #endif | 628 | #endif |
629 | 629 | ||
630 | 630 | ||
631 | int __init w100fb_probe(struct platform_device *pdev) | 631 | int __devinit w100fb_probe(struct platform_device *pdev) |
632 | { | 632 | { |
633 | int err = -EIO; | 633 | int err = -EIO; |
634 | struct w100fb_mach_info *inf; | 634 | struct w100fb_mach_info *inf; |
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c index 406caa6a71cb..e5f74416d4b7 100644 --- a/drivers/w1/masters/ds2482.c +++ b/drivers/w1/masters/ds2482.c | |||
@@ -214,7 +214,7 @@ static int ds2482_wait_1wire_idle(struct ds2482_data *pdev) | |||
214 | (++retries < DS2482_WAIT_IDLE_TIMEOUT)); | 214 | (++retries < DS2482_WAIT_IDLE_TIMEOUT)); |
215 | } | 215 | } |
216 | 216 | ||
217 | if (retries > DS2482_WAIT_IDLE_TIMEOUT) | 217 | if (retries >= DS2482_WAIT_IDLE_TIMEOUT) |
218 | printk(KERN_ERR "%s: timeout on channel %d\n", | 218 | printk(KERN_ERR "%s: timeout on channel %d\n", |
219 | __func__, pdev->channel); | 219 | __func__, pdev->channel); |
220 | 220 | ||
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c index 65244c02551b..492670358cbf 100644 --- a/drivers/w1/masters/mxc_w1.c +++ b/drivers/w1/masters/mxc_w1.c | |||
@@ -102,7 +102,7 @@ static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit) | |||
102 | return ((__raw_readb(ctrl_addr)) >> 3) & 0x1; | 102 | return ((__raw_readb(ctrl_addr)) >> 3) & 0x1; |
103 | } | 103 | } |
104 | 104 | ||
105 | static int __init mxc_w1_probe(struct platform_device *pdev) | 105 | static int __devinit mxc_w1_probe(struct platform_device *pdev) |
106 | { | 106 | { |
107 | struct mxc_w1_device *mdev; | 107 | struct mxc_w1_device *mdev; |
108 | struct resource *res; | 108 | struct resource *res; |
@@ -166,7 +166,7 @@ failed_clk: | |||
166 | /* | 166 | /* |
167 | * disassociate the w1 device from the driver | 167 | * disassociate the w1 device from the driver |
168 | */ | 168 | */ |
169 | static int mxc_w1_remove(struct platform_device *pdev) | 169 | static int __devexit mxc_w1_remove(struct platform_device *pdev) |
170 | { | 170 | { |
171 | struct mxc_w1_device *mdev = platform_get_drvdata(pdev); | 171 | struct mxc_w1_device *mdev = platform_get_drvdata(pdev); |
172 | struct resource *res; | 172 | struct resource *res; |
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 0d92969404c3..22977d30f89e 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c | |||
@@ -72,7 +72,7 @@ struct hdq_data { | |||
72 | int init_trans; | 72 | int init_trans; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | static int __init omap_hdq_probe(struct platform_device *pdev); | 75 | static int __devinit omap_hdq_probe(struct platform_device *pdev); |
76 | static int omap_hdq_remove(struct platform_device *pdev); | 76 | static int omap_hdq_remove(struct platform_device *pdev); |
77 | 77 | ||
78 | static struct platform_driver omap_hdq_driver = { | 78 | static struct platform_driver omap_hdq_driver = { |
@@ -558,7 +558,7 @@ static void omap_w1_write_byte(void *_hdq, u8 byte) | |||
558 | return; | 558 | return; |
559 | } | 559 | } |
560 | 560 | ||
561 | static int __init omap_hdq_probe(struct platform_device *pdev) | 561 | static int __devinit omap_hdq_probe(struct platform_device *pdev) |
562 | { | 562 | { |
563 | struct hdq_data *hdq_data; | 563 | struct hdq_data *hdq_data; |
564 | struct resource *res; | 564 | struct resource *res; |
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 3da3f48720a7..bdcdbd53da89 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -55,6 +55,11 @@ config SOFT_WATCHDOG | |||
55 | To compile this driver as a module, choose M here: the | 55 | To compile this driver as a module, choose M here: the |
56 | module will be called softdog. | 56 | module will be called softdog. |
57 | 57 | ||
58 | config MAX63XX_WATCHDOG | ||
59 | tristate "Max63xx watchdog" | ||
60 | help | ||
61 | Support for memory mapped max63{69,70,71,72,73,74} watchdog timer. | ||
62 | |||
58 | config WM831X_WATCHDOG | 63 | config WM831X_WATCHDOG |
59 | tristate "WM831x watchdog" | 64 | tristate "WM831x watchdog" |
60 | depends on MFD_WM831X | 65 | depends on MFD_WM831X |
@@ -289,6 +294,17 @@ config ADX_WATCHDOG | |||
289 | Say Y here if you want support for the watchdog timer on Avionic | 294 | Say Y here if you want support for the watchdog timer on Avionic |
290 | Design Xanthos boards. | 295 | Design Xanthos boards. |
291 | 296 | ||
297 | config TS72XX_WATCHDOG | ||
298 | tristate "TS-72XX SBC Watchdog" | ||
299 | depends on MACH_TS72XX | ||
300 | help | ||
301 | Technologic Systems TS-7200, TS-7250 and TS-7260 boards have | ||
302 | watchdog timer implemented in a external CPLD chip. Say Y here | ||
303 | if you want to support for the watchdog timer on TS-72XX boards. | ||
304 | |||
305 | To compile this driver as a module, choose M here: the | ||
306 | module will be called ts72xx_wdt. | ||
307 | |||
292 | # AVR32 Architecture | 308 | # AVR32 Architecture |
293 | 309 | ||
294 | config AT32AP700X_WDT | 310 | config AT32AP700X_WDT |
@@ -845,10 +861,10 @@ config TXX9_WDT | |||
845 | # POWERPC Architecture | 861 | # POWERPC Architecture |
846 | 862 | ||
847 | config GEF_WDT | 863 | config GEF_WDT |
848 | tristate "GE Fanuc Watchdog Timer" | 864 | tristate "GE Watchdog Timer" |
849 | depends on GEF_SBC610 || GEF_SBC310 || GEF_PPC9A | 865 | depends on GEF_SBC610 || GEF_SBC310 || GEF_PPC9A |
850 | ---help--- | 866 | ---help--- |
851 | Watchdog timer found in a number of GE Fanuc single board computers. | 867 | Watchdog timer found in a number of GE single board computers. |
852 | 868 | ||
853 | config MPC5200_WDT | 869 | config MPC5200_WDT |
854 | bool "MPC52xx Watchdog Timer" | 870 | bool "MPC52xx Watchdog Timer" |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 475c61100069..5e3cb95bb0e9 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
@@ -46,6 +46,7 @@ obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o | |||
46 | obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o | 46 | obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o |
47 | obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o | 47 | obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o |
48 | obj-$(CONFIG_ADX_WATCHDOG) += adx_wdt.o | 48 | obj-$(CONFIG_ADX_WATCHDOG) += adx_wdt.o |
49 | obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o | ||
49 | 50 | ||
50 | # AVR32 Architecture | 51 | # AVR32 Architecture |
51 | obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o | 52 | obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o |
@@ -142,4 +143,5 @@ obj-$(CONFIG_WATCHDOG_CP1XXX) += cpwd.o | |||
142 | # Architecture Independant | 143 | # Architecture Independant |
143 | obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o | 144 | obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o |
144 | obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o | 145 | obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o |
146 | obj-$(CONFIG_MAX63XX_WATCHDOG) += max63xx_wdt.o | ||
145 | obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o | 147 | obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o |
diff --git a/drivers/watchdog/acquirewdt.c b/drivers/watchdog/acquirewdt.c index 4d18c874d963..2ffce4d75443 100644 --- a/drivers/watchdog/acquirewdt.c +++ b/drivers/watchdog/acquirewdt.c | |||
@@ -150,7 +150,7 @@ static long acq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
150 | int options, retval = -EINVAL; | 150 | int options, retval = -EINVAL; |
151 | void __user *argp = (void __user *)arg; | 151 | void __user *argp = (void __user *)arg; |
152 | int __user *p = argp; | 152 | int __user *p = argp; |
153 | static struct watchdog_info ident = { | 153 | static const struct watchdog_info ident = { |
154 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | 154 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, |
155 | .firmware_version = 1, | 155 | .firmware_version = 1, |
156 | .identity = WATCHDOG_NAME, | 156 | .identity = WATCHDOG_NAME, |
diff --git a/drivers/watchdog/advantechwdt.c b/drivers/watchdog/advantechwdt.c index 824d076a5cd6..4d40965d2c9f 100644 --- a/drivers/watchdog/advantechwdt.c +++ b/drivers/watchdog/advantechwdt.c | |||
@@ -137,7 +137,7 @@ static long advwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
137 | int new_timeout; | 137 | int new_timeout; |
138 | void __user *argp = (void __user *)arg; | 138 | void __user *argp = (void __user *)arg; |
139 | int __user *p = argp; | 139 | int __user *p = argp; |
140 | static struct watchdog_info ident = { | 140 | static const struct watchdog_info ident = { |
141 | .options = WDIOF_KEEPALIVEPING | | 141 | .options = WDIOF_KEEPALIVEPING | |
142 | WDIOF_SETTIMEOUT | | 142 | WDIOF_SETTIMEOUT | |
143 | WDIOF_MAGICCLOSE, | 143 | WDIOF_MAGICCLOSE, |
diff --git a/drivers/watchdog/adx_wdt.c b/drivers/watchdog/adx_wdt.c index 9d7d155364f8..a5ca7a6ee133 100644 --- a/drivers/watchdog/adx_wdt.c +++ b/drivers/watchdog/adx_wdt.c | |||
@@ -37,7 +37,7 @@ struct adx_wdt { | |||
37 | spinlock_t lock; | 37 | spinlock_t lock; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static struct watchdog_info adx_wdt_info = { | 40 | static const struct watchdog_info adx_wdt_info = { |
41 | .identity = "Avionic Design Xanthos Watchdog", | 41 | .identity = "Avionic Design Xanthos Watchdog", |
42 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | 42 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, |
43 | }; | 43 | }; |
diff --git a/drivers/watchdog/alim1535_wdt.c b/drivers/watchdog/alim1535_wdt.c index 937a80fb61e1..1e9caea8ff8a 100644 --- a/drivers/watchdog/alim1535_wdt.c +++ b/drivers/watchdog/alim1535_wdt.c | |||
@@ -180,7 +180,7 @@ static long ali_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
180 | { | 180 | { |
181 | void __user *argp = (void __user *)arg; | 181 | void __user *argp = (void __user *)arg; |
182 | int __user *p = argp; | 182 | int __user *p = argp; |
183 | static struct watchdog_info ident = { | 183 | static const struct watchdog_info ident = { |
184 | .options = WDIOF_KEEPALIVEPING | | 184 | .options = WDIOF_KEEPALIVEPING | |
185 | WDIOF_SETTIMEOUT | | 185 | WDIOF_SETTIMEOUT | |
186 | WDIOF_MAGICCLOSE, | 186 | WDIOF_MAGICCLOSE, |
diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c index f90afdb1b255..d8d4da9a483d 100644 --- a/drivers/watchdog/alim7101_wdt.c +++ b/drivers/watchdog/alim7101_wdt.c | |||
@@ -238,7 +238,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
238 | { | 238 | { |
239 | void __user *argp = (void __user *)arg; | 239 | void __user *argp = (void __user *)arg; |
240 | int __user *p = argp; | 240 | int __user *p = argp; |
241 | static struct watchdog_info ident = { | 241 | static const struct watchdog_info ident = { |
242 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | 242 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
243 | | WDIOF_MAGICCLOSE, | 243 | | WDIOF_MAGICCLOSE, |
244 | .firmware_version = 1, | 244 | .firmware_version = 1, |
diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c index 2bb95cd308c1..c764c52412e4 100644 --- a/drivers/watchdog/ar7_wdt.c +++ b/drivers/watchdog/ar7_wdt.c | |||
@@ -219,7 +219,7 @@ static ssize_t ar7_wdt_write(struct file *file, const char *data, | |||
219 | static long ar7_wdt_ioctl(struct file *file, | 219 | static long ar7_wdt_ioctl(struct file *file, |
220 | unsigned int cmd, unsigned long arg) | 220 | unsigned int cmd, unsigned long arg) |
221 | { | 221 | { |
222 | static struct watchdog_info ident = { | 222 | static const struct watchdog_info ident = { |
223 | .identity = LONGNAME, | 223 | .identity = LONGNAME, |
224 | .firmware_version = 1, | 224 | .firmware_version = 1, |
225 | .options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | | 225 | .options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | |
diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c index 037847923dcb..6873376f986c 100644 --- a/drivers/watchdog/at32ap700x_wdt.c +++ b/drivers/watchdog/at32ap700x_wdt.c | |||
@@ -202,7 +202,7 @@ static int at32_wdt_get_status(void) | |||
202 | return status; | 202 | return status; |
203 | } | 203 | } |
204 | 204 | ||
205 | static struct watchdog_info at32_wdt_info = { | 205 | static const struct watchdog_info at32_wdt_info = { |
206 | .identity = "at32ap700x watchdog", | 206 | .identity = "at32ap700x watchdog", |
207 | .options = WDIOF_SETTIMEOUT | | 207 | .options = WDIOF_SETTIMEOUT | |
208 | WDIOF_KEEPALIVEPING | | 208 | WDIOF_KEEPALIVEPING | |
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c index b185dafe1494..b3046dc4b56c 100644 --- a/drivers/watchdog/at91rm9200_wdt.c +++ b/drivers/watchdog/at91rm9200_wdt.c | |||
@@ -121,7 +121,7 @@ static int at91_wdt_settimeout(int new_time) | |||
121 | return 0; | 121 | return 0; |
122 | } | 122 | } |
123 | 123 | ||
124 | static struct watchdog_info at91_wdt_info = { | 124 | static const struct watchdog_info at91_wdt_info = { |
125 | .identity = "at91 watchdog", | 125 | .identity = "at91 watchdog", |
126 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | 126 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, |
127 | }; | 127 | }; |
diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c index 751c003864ad..5f245522397b 100644 --- a/drivers/watchdog/bcm47xx_wdt.c +++ b/drivers/watchdog/bcm47xx_wdt.c | |||
@@ -149,7 +149,7 @@ static ssize_t bcm47xx_wdt_write(struct file *file, const char __user *data, | |||
149 | return len; | 149 | return len; |
150 | } | 150 | } |
151 | 151 | ||
152 | static struct watchdog_info bcm47xx_wdt_info = { | 152 | static const struct watchdog_info bcm47xx_wdt_info = { |
153 | .identity = DRV_NAME, | 153 | .identity = DRV_NAME, |
154 | .options = WDIOF_SETTIMEOUT | | 154 | .options = WDIOF_SETTIMEOUT | |
155 | WDIOF_KEEPALIVEPING | | 155 | WDIOF_KEEPALIVEPING | |
diff --git a/drivers/watchdog/bfin_wdt.c b/drivers/watchdog/bfin_wdt.c index 2159e668751c..9c7ccd1e9088 100644 --- a/drivers/watchdog/bfin_wdt.c +++ b/drivers/watchdog/bfin_wdt.c | |||
@@ -19,8 +19,6 @@ | |||
19 | #include <linux/miscdevice.h> | 19 | #include <linux/miscdevice.h> |
20 | #include <linux/watchdog.h> | 20 | #include <linux/watchdog.h> |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/notifier.h> | ||
23 | #include <linux/reboot.h> | ||
24 | #include <linux/init.h> | 22 | #include <linux/init.h> |
25 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
26 | #include <linux/uaccess.h> | 24 | #include <linux/uaccess.h> |
@@ -74,7 +72,7 @@ | |||
74 | 72 | ||
75 | static unsigned int timeout = WATCHDOG_TIMEOUT; | 73 | static unsigned int timeout = WATCHDOG_TIMEOUT; |
76 | static int nowayout = WATCHDOG_NOWAYOUT; | 74 | static int nowayout = WATCHDOG_NOWAYOUT; |
77 | static struct watchdog_info bfin_wdt_info; | 75 | static const struct watchdog_info bfin_wdt_info; |
78 | static unsigned long open_check; | 76 | static unsigned long open_check; |
79 | static char expect_close; | 77 | static char expect_close; |
80 | static DEFINE_SPINLOCK(bfin_wdt_spinlock); | 78 | static DEFINE_SPINLOCK(bfin_wdt_spinlock); |
@@ -309,26 +307,6 @@ static long bfin_wdt_ioctl(struct file *file, | |||
309 | } | 307 | } |
310 | } | 308 | } |
311 | 309 | ||
312 | /** | ||
313 | * bfin_wdt_notify_sys - Notifier Handler | ||
314 | * @this: notifier block | ||
315 | * @code: notifier event | ||
316 | * @unused: unused | ||
317 | * | ||
318 | * Handles specific events, such as turning off the watchdog during a | ||
319 | * shutdown event. | ||
320 | */ | ||
321 | static int bfin_wdt_notify_sys(struct notifier_block *this, | ||
322 | unsigned long code, void *unused) | ||
323 | { | ||
324 | stampit(); | ||
325 | |||
326 | if (code == SYS_DOWN || code == SYS_HALT) | ||
327 | bfin_wdt_stop(); | ||
328 | |||
329 | return NOTIFY_DONE; | ||
330 | } | ||
331 | |||
332 | #ifdef CONFIG_PM | 310 | #ifdef CONFIG_PM |
333 | static int state_before_suspend; | 311 | static int state_before_suspend; |
334 | 312 | ||
@@ -388,40 +366,28 @@ static struct miscdevice bfin_wdt_miscdev = { | |||
388 | .fops = &bfin_wdt_fops, | 366 | .fops = &bfin_wdt_fops, |
389 | }; | 367 | }; |
390 | 368 | ||
391 | static struct watchdog_info bfin_wdt_info = { | 369 | static const struct watchdog_info bfin_wdt_info = { |
392 | .identity = "Blackfin Watchdog", | 370 | .identity = "Blackfin Watchdog", |
393 | .options = WDIOF_SETTIMEOUT | | 371 | .options = WDIOF_SETTIMEOUT | |
394 | WDIOF_KEEPALIVEPING | | 372 | WDIOF_KEEPALIVEPING | |
395 | WDIOF_MAGICCLOSE, | 373 | WDIOF_MAGICCLOSE, |
396 | }; | 374 | }; |
397 | 375 | ||
398 | static struct notifier_block bfin_wdt_notifier = { | ||
399 | .notifier_call = bfin_wdt_notify_sys, | ||
400 | }; | ||
401 | |||
402 | /** | 376 | /** |
403 | * bfin_wdt_probe - Initialize module | 377 | * bfin_wdt_probe - Initialize module |
404 | * | 378 | * |
405 | * Registers the misc device and notifier handler. Actual device | 379 | * Registers the misc device. Actual device |
406 | * initialization is handled by bfin_wdt_open(). | 380 | * initialization is handled by bfin_wdt_open(). |
407 | */ | 381 | */ |
408 | static int __devinit bfin_wdt_probe(struct platform_device *pdev) | 382 | static int __devinit bfin_wdt_probe(struct platform_device *pdev) |
409 | { | 383 | { |
410 | int ret; | 384 | int ret; |
411 | 385 | ||
412 | ret = register_reboot_notifier(&bfin_wdt_notifier); | ||
413 | if (ret) { | ||
414 | pr_devinit(KERN_ERR PFX | ||
415 | "cannot register reboot notifier (err=%d)\n", ret); | ||
416 | return ret; | ||
417 | } | ||
418 | |||
419 | ret = misc_register(&bfin_wdt_miscdev); | 386 | ret = misc_register(&bfin_wdt_miscdev); |
420 | if (ret) { | 387 | if (ret) { |
421 | pr_devinit(KERN_ERR PFX | 388 | pr_devinit(KERN_ERR PFX |
422 | "cannot register miscdev on minor=%d (err=%d)\n", | 389 | "cannot register miscdev on minor=%d (err=%d)\n", |
423 | WATCHDOG_MINOR, ret); | 390 | WATCHDOG_MINOR, ret); |
424 | unregister_reboot_notifier(&bfin_wdt_notifier); | ||
425 | return ret; | 391 | return ret; |
426 | } | 392 | } |
427 | 393 | ||
@@ -434,21 +400,33 @@ static int __devinit bfin_wdt_probe(struct platform_device *pdev) | |||
434 | /** | 400 | /** |
435 | * bfin_wdt_remove - Initialize module | 401 | * bfin_wdt_remove - Initialize module |
436 | * | 402 | * |
437 | * Unregisters the misc device and notifier handler. Actual device | 403 | * Unregisters the misc device. Actual device |
438 | * deinitialization is handled by bfin_wdt_close(). | 404 | * deinitialization is handled by bfin_wdt_close(). |
439 | */ | 405 | */ |
440 | static int __devexit bfin_wdt_remove(struct platform_device *pdev) | 406 | static int __devexit bfin_wdt_remove(struct platform_device *pdev) |
441 | { | 407 | { |
442 | misc_deregister(&bfin_wdt_miscdev); | 408 | misc_deregister(&bfin_wdt_miscdev); |
443 | unregister_reboot_notifier(&bfin_wdt_notifier); | ||
444 | return 0; | 409 | return 0; |
445 | } | 410 | } |
446 | 411 | ||
412 | /** | ||
413 | * bfin_wdt_shutdown - Soft Shutdown Handler | ||
414 | * | ||
415 | * Handles the soft shutdown event. | ||
416 | */ | ||
417 | static void bfin_wdt_shutdown(struct platform_device *pdev) | ||
418 | { | ||
419 | stampit(); | ||
420 | |||
421 | bfin_wdt_stop(); | ||
422 | } | ||
423 | |||
447 | static struct platform_device *bfin_wdt_device; | 424 | static struct platform_device *bfin_wdt_device; |
448 | 425 | ||
449 | static struct platform_driver bfin_wdt_driver = { | 426 | static struct platform_driver bfin_wdt_driver = { |
450 | .probe = bfin_wdt_probe, | 427 | .probe = bfin_wdt_probe, |
451 | .remove = __devexit_p(bfin_wdt_remove), | 428 | .remove = __devexit_p(bfin_wdt_remove), |
429 | .shutdown = bfin_wdt_shutdown, | ||
452 | .suspend = bfin_wdt_suspend, | 430 | .suspend = bfin_wdt_suspend, |
453 | .resume = bfin_wdt_resume, | 431 | .resume = bfin_wdt_resume, |
454 | .driver = { | 432 | .driver = { |
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c index e8380ef65c1c..8b724aad6825 100644 --- a/drivers/watchdog/booke_wdt.c +++ b/drivers/watchdog/booke_wdt.c | |||
@@ -121,7 +121,7 @@ static ssize_t booke_wdt_write(struct file *file, const char __user *buf, | |||
121 | return count; | 121 | return count; |
122 | } | 122 | } |
123 | 123 | ||
124 | static struct watchdog_info ident = { | 124 | static const struct watchdog_info ident = { |
125 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | 125 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, |
126 | .identity = "PowerPC Book-E Watchdog", | 126 | .identity = "PowerPC Book-E Watchdog", |
127 | }; | 127 | }; |
diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c index 923cc68dba26..9291506b8b23 100644 --- a/drivers/watchdog/coh901327_wdt.c +++ b/drivers/watchdog/coh901327_wdt.c | |||
@@ -257,7 +257,7 @@ static long coh901327_ioctl(struct file *file, unsigned int cmd, | |||
257 | struct watchdog_info __user *ident; | 257 | struct watchdog_info __user *ident; |
258 | int __user *i; | 258 | int __user *i; |
259 | } uarg; | 259 | } uarg; |
260 | static struct watchdog_info ident = { | 260 | static const struct watchdog_info ident = { |
261 | .options = WDIOF_CARDRESET | | 261 | .options = WDIOF_CARDRESET | |
262 | WDIOF_SETTIMEOUT | | 262 | WDIOF_SETTIMEOUT | |
263 | WDIOF_KEEPALIVEPING, | 263 | WDIOF_KEEPALIVEPING, |
diff --git a/drivers/watchdog/cpu5wdt.c b/drivers/watchdog/cpu5wdt.c index 71f6d7eec9a8..edd3475f41db 100644 --- a/drivers/watchdog/cpu5wdt.c +++ b/drivers/watchdog/cpu5wdt.c | |||
@@ -154,7 +154,7 @@ static long cpu5wdt_ioctl(struct file *file, unsigned int cmd, | |||
154 | void __user *argp = (void __user *)arg; | 154 | void __user *argp = (void __user *)arg; |
155 | int __user *p = argp; | 155 | int __user *p = argp; |
156 | unsigned int value; | 156 | unsigned int value; |
157 | static struct watchdog_info ident = { | 157 | static const struct watchdog_info ident = { |
158 | .options = WDIOF_CARDRESET, | 158 | .options = WDIOF_CARDRESET, |
159 | .identity = "CPU5 WDT", | 159 | .identity = "CPU5 WDT", |
160 | }; | 160 | }; |
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c index 081f2955419e..37ea052d4dee 100644 --- a/drivers/watchdog/cpwd.c +++ b/drivers/watchdog/cpwd.c | |||
@@ -403,7 +403,7 @@ static int cpwd_release(struct inode *inode, struct file *file) | |||
403 | 403 | ||
404 | static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 404 | static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
405 | { | 405 | { |
406 | static struct watchdog_info info = { | 406 | static const struct watchdog_info info = { |
407 | .options = WDIOF_SETTIMEOUT, | 407 | .options = WDIOF_SETTIMEOUT, |
408 | .firmware_version = 1, | 408 | .firmware_version = 1, |
409 | .identity = DRIVER_NAME, | 409 | .identity = DRIVER_NAME, |
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c index 887136de1857..56162c87f5d8 100644 --- a/drivers/watchdog/davinci_wdt.c +++ b/drivers/watchdog/davinci_wdt.c | |||
@@ -142,7 +142,7 @@ davinci_wdt_write(struct file *file, const char *data, size_t len, | |||
142 | return len; | 142 | return len; |
143 | } | 143 | } |
144 | 144 | ||
145 | static struct watchdog_info ident = { | 145 | static const struct watchdog_info ident = { |
146 | .options = WDIOF_KEEPALIVEPING, | 146 | .options = WDIOF_KEEPALIVEPING, |
147 | .identity = "DaVinci Watchdog", | 147 | .identity = "DaVinci Watchdog", |
148 | }; | 148 | }; |
diff --git a/drivers/watchdog/ep93xx_wdt.c b/drivers/watchdog/ep93xx_wdt.c index cdd55e0d09f8..88ed54e50f74 100644 --- a/drivers/watchdog/ep93xx_wdt.c +++ b/drivers/watchdog/ep93xx_wdt.c | |||
@@ -131,7 +131,7 @@ ep93xx_wdt_write(struct file *file, const char __user *data, size_t len, | |||
131 | return len; | 131 | return len; |
132 | } | 132 | } |
133 | 133 | ||
134 | static struct watchdog_info ident = { | 134 | static const struct watchdog_info ident = { |
135 | .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE, | 135 | .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE, |
136 | .identity = "EP93xx Watchdog", | 136 | .identity = "EP93xx Watchdog", |
137 | }; | 137 | }; |
diff --git a/drivers/watchdog/eurotechwdt.c b/drivers/watchdog/eurotechwdt.c index 9add3541fb42..d1c4e55b1db0 100644 --- a/drivers/watchdog/eurotechwdt.c +++ b/drivers/watchdog/eurotechwdt.c | |||
@@ -238,7 +238,7 @@ static long eurwdt_ioctl(struct file *file, | |||
238 | { | 238 | { |
239 | void __user *argp = (void __user *)arg; | 239 | void __user *argp = (void __user *)arg; |
240 | int __user *p = argp; | 240 | int __user *p = argp; |
241 | static struct watchdog_info ident = { | 241 | static const struct watchdog_info ident = { |
242 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | 242 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
243 | | WDIOF_MAGICCLOSE, | 243 | | WDIOF_MAGICCLOSE, |
244 | .firmware_version = 1, | 244 | .firmware_version = 1, |
diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c index 734d9806a872..abdbad034a6c 100644 --- a/drivers/watchdog/gef_wdt.c +++ b/drivers/watchdog/gef_wdt.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * GE Fanuc watchdog userspace interface | 2 | * GE watchdog userspace interface |
3 | * | 3 | * |
4 | * Author: Martyn Welch <martyn.welch@gefanuc.com> | 4 | * Author: Martyn Welch <martyn.welch@ge.com> |
5 | * | 5 | * |
6 | * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc. | 6 | * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |
@@ -161,11 +161,11 @@ static long gef_wdt_ioctl(struct file *file, unsigned int cmd, | |||
161 | int timeout; | 161 | int timeout; |
162 | int options; | 162 | int options; |
163 | void __user *argp = (void __user *)arg; | 163 | void __user *argp = (void __user *)arg; |
164 | static struct watchdog_info info = { | 164 | static const struct watchdog_info info = { |
165 | .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | | 165 | .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | |
166 | WDIOF_KEEPALIVEPING, | 166 | WDIOF_KEEPALIVEPING, |
167 | .firmware_version = 0, | 167 | .firmware_version = 0, |
168 | .identity = "GE Fanuc watchdog", | 168 | .identity = "GE watchdog", |
169 | }; | 169 | }; |
170 | 170 | ||
171 | switch (cmd) { | 171 | switch (cmd) { |
@@ -311,7 +311,7 @@ static struct of_platform_driver gef_wdt_driver = { | |||
311 | 311 | ||
312 | static int __init gef_wdt_init(void) | 312 | static int __init gef_wdt_init(void) |
313 | { | 313 | { |
314 | printk(KERN_INFO "GE Fanuc watchdog driver\n"); | 314 | printk(KERN_INFO "GE watchdog driver\n"); |
315 | return of_register_platform_driver(&gef_wdt_driver); | 315 | return of_register_platform_driver(&gef_wdt_driver); |
316 | } | 316 | } |
317 | 317 | ||
@@ -323,8 +323,8 @@ static void __exit gef_wdt_exit(void) | |||
323 | module_init(gef_wdt_init); | 323 | module_init(gef_wdt_init); |
324 | module_exit(gef_wdt_exit); | 324 | module_exit(gef_wdt_exit); |
325 | 325 | ||
326 | MODULE_AUTHOR("Martyn Welch <martyn.welch@gefanuc.com>"); | 326 | MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com>"); |
327 | MODULE_DESCRIPTION("GE Fanuc watchdog driver"); | 327 | MODULE_DESCRIPTION("GE watchdog driver"); |
328 | MODULE_LICENSE("GPL"); | 328 | MODULE_LICENSE("GPL"); |
329 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | 329 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
330 | MODULE_ALIAS("platform: gef_wdt"); | 330 | MODULE_ALIAS("platform: gef_wdt"); |
diff --git a/drivers/watchdog/geodewdt.c b/drivers/watchdog/geodewdt.c index 38252ff828ca..9b49b125ad5a 100644 --- a/drivers/watchdog/geodewdt.c +++ b/drivers/watchdog/geodewdt.c | |||
@@ -142,7 +142,7 @@ static long geodewdt_ioctl(struct file *file, unsigned int cmd, | |||
142 | int __user *p = argp; | 142 | int __user *p = argp; |
143 | int interval; | 143 | int interval; |
144 | 144 | ||
145 | static struct watchdog_info ident = { | 145 | static const struct watchdog_info ident = { |
146 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | 146 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
147 | | WDIOF_MAGICCLOSE, | 147 | | WDIOF_MAGICCLOSE, |
148 | .firmware_version = 1, | 148 | .firmware_version = 1, |
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index a6c5674c78e6..70c2c24660d0 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c | |||
@@ -554,7 +554,7 @@ static ssize_t hpwdt_write(struct file *file, const char __user *data, | |||
554 | return len; | 554 | return len; |
555 | } | 555 | } |
556 | 556 | ||
557 | static struct watchdog_info ident = { | 557 | static const struct watchdog_info ident = { |
558 | .options = WDIOF_SETTIMEOUT | | 558 | .options = WDIOF_SETTIMEOUT | |
559 | WDIOF_KEEPALIVEPING | | 559 | WDIOF_KEEPALIVEPING | |
560 | WDIOF_MAGICCLOSE, | 560 | WDIOF_MAGICCLOSE, |
diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c index 7ba0b11ec525..bb9750a03942 100644 --- a/drivers/watchdog/i6300esb.c +++ b/drivers/watchdog/i6300esb.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/mm.h> | 34 | #include <linux/mm.h> |
35 | #include <linux/miscdevice.h> | 35 | #include <linux/miscdevice.h> |
36 | #include <linux/watchdog.h> | 36 | #include <linux/watchdog.h> |
37 | #include <linux/platform_device.h> | ||
38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
39 | #include <linux/pci.h> | 38 | #include <linux/pci.h> |
40 | #include <linux/ioport.h> | 39 | #include <linux/ioport.h> |
@@ -42,7 +41,7 @@ | |||
42 | #include <linux/io.h> | 41 | #include <linux/io.h> |
43 | 42 | ||
44 | /* Module and version information */ | 43 | /* Module and version information */ |
45 | #define ESB_VERSION "0.04" | 44 | #define ESB_VERSION "0.05" |
46 | #define ESB_MODULE_NAME "i6300ESB timer" | 45 | #define ESB_MODULE_NAME "i6300ESB timer" |
47 | #define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION | 46 | #define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION |
48 | #define PFX ESB_MODULE_NAME ": " | 47 | #define PFX ESB_MODULE_NAME ": " |
@@ -65,7 +64,7 @@ | |||
65 | /* Config register bits */ | 64 | /* Config register bits */ |
66 | #define ESB_WDT_REBOOT (0x01 << 5) /* Enable reboot on timeout */ | 65 | #define ESB_WDT_REBOOT (0x01 << 5) /* Enable reboot on timeout */ |
67 | #define ESB_WDT_FREQ (0x01 << 2) /* Decrement frequency */ | 66 | #define ESB_WDT_FREQ (0x01 << 2) /* Decrement frequency */ |
68 | #define ESB_WDT_INTTYPE (0x11 << 0) /* Interrupt type on timer1 timeout */ | 67 | #define ESB_WDT_INTTYPE (0x03 << 0) /* Interrupt type on timer1 timeout */ |
69 | 68 | ||
70 | /* Reload register bits */ | 69 | /* Reload register bits */ |
71 | #define ESB_WDT_TIMEOUT (0x01 << 9) /* Watchdog timed out */ | 70 | #define ESB_WDT_TIMEOUT (0x01 << 9) /* Watchdog timed out */ |
@@ -82,7 +81,9 @@ static unsigned long timer_alive; | |||
82 | static struct pci_dev *esb_pci; | 81 | static struct pci_dev *esb_pci; |
83 | static unsigned short triggered; /* The status of the watchdog upon boot */ | 82 | static unsigned short triggered; /* The status of the watchdog upon boot */ |
84 | static char esb_expect_close; | 83 | static char esb_expect_close; |
85 | static struct platform_device *esb_platform_device; | 84 | |
85 | /* We can only use 1 card due to the /dev/watchdog restriction */ | ||
86 | static int cards_found; | ||
86 | 87 | ||
87 | /* module parameters */ | 88 | /* module parameters */ |
88 | /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */ | 89 | /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */ |
@@ -111,8 +112,8 @@ MODULE_PARM_DESC(nowayout, | |||
111 | */ | 112 | */ |
112 | static inline void esb_unlock_registers(void) | 113 | static inline void esb_unlock_registers(void) |
113 | { | 114 | { |
114 | writeb(ESB_UNLOCK1, ESB_RELOAD_REG); | 115 | writew(ESB_UNLOCK1, ESB_RELOAD_REG); |
115 | writeb(ESB_UNLOCK2, ESB_RELOAD_REG); | 116 | writew(ESB_UNLOCK2, ESB_RELOAD_REG); |
116 | } | 117 | } |
117 | 118 | ||
118 | static int esb_timer_start(void) | 119 | static int esb_timer_start(void) |
@@ -256,7 +257,7 @@ static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
256 | int new_heartbeat; | 257 | int new_heartbeat; |
257 | void __user *argp = (void __user *)arg; | 258 | void __user *argp = (void __user *)arg; |
258 | int __user *p = argp; | 259 | int __user *p = argp; |
259 | static struct watchdog_info ident = { | 260 | static const struct watchdog_info ident = { |
260 | .options = WDIOF_SETTIMEOUT | | 261 | .options = WDIOF_SETTIMEOUT | |
261 | WDIOF_KEEPALIVEPING | | 262 | WDIOF_KEEPALIVEPING | |
262 | WDIOF_MAGICCLOSE, | 263 | WDIOF_MAGICCLOSE, |
@@ -332,11 +333,6 @@ static struct miscdevice esb_miscdev = { | |||
332 | 333 | ||
333 | /* | 334 | /* |
334 | * Data for PCI driver interface | 335 | * Data for PCI driver interface |
335 | * | ||
336 | * This data only exists for exporting the supported | ||
337 | * PCI ids via MODULE_DEVICE_TABLE. We do not actually | ||
338 | * register a pci_driver, because someone else might one day | ||
339 | * want to register another driver on the same PCI id. | ||
340 | */ | 336 | */ |
341 | static struct pci_device_id esb_pci_tbl[] = { | 337 | static struct pci_device_id esb_pci_tbl[] = { |
342 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9), }, | 338 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9), }, |
@@ -348,29 +344,19 @@ MODULE_DEVICE_TABLE(pci, esb_pci_tbl); | |||
348 | * Init & exit routines | 344 | * Init & exit routines |
349 | */ | 345 | */ |
350 | 346 | ||
351 | static unsigned char __devinit esb_getdevice(void) | 347 | static unsigned char __devinit esb_getdevice(struct pci_dev *pdev) |
352 | { | 348 | { |
353 | /* | 349 | if (pci_enable_device(pdev)) { |
354 | * Find the PCI device | ||
355 | */ | ||
356 | |||
357 | esb_pci = pci_get_device(PCI_VENDOR_ID_INTEL, | ||
358 | PCI_DEVICE_ID_INTEL_ESB_9, NULL); | ||
359 | |||
360 | if (!esb_pci) | ||
361 | return 0; | ||
362 | |||
363 | if (pci_enable_device(esb_pci)) { | ||
364 | printk(KERN_ERR PFX "failed to enable device\n"); | 350 | printk(KERN_ERR PFX "failed to enable device\n"); |
365 | goto err_devput; | 351 | goto err_devput; |
366 | } | 352 | } |
367 | 353 | ||
368 | if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) { | 354 | if (pci_request_region(pdev, 0, ESB_MODULE_NAME)) { |
369 | printk(KERN_ERR PFX "failed to request region\n"); | 355 | printk(KERN_ERR PFX "failed to request region\n"); |
370 | goto err_disable; | 356 | goto err_disable; |
371 | } | 357 | } |
372 | 358 | ||
373 | BASEADDR = pci_ioremap_bar(esb_pci, 0); | 359 | BASEADDR = pci_ioremap_bar(pdev, 0); |
374 | if (BASEADDR == NULL) { | 360 | if (BASEADDR == NULL) { |
375 | /* Something's wrong here, BASEADDR has to be set */ | 361 | /* Something's wrong here, BASEADDR has to be set */ |
376 | printk(KERN_ERR PFX "failed to get BASEADDR\n"); | 362 | printk(KERN_ERR PFX "failed to get BASEADDR\n"); |
@@ -378,14 +364,14 @@ static unsigned char __devinit esb_getdevice(void) | |||
378 | } | 364 | } |
379 | 365 | ||
380 | /* Done */ | 366 | /* Done */ |
367 | esb_pci = pdev; | ||
381 | return 1; | 368 | return 1; |
382 | 369 | ||
383 | err_release: | 370 | err_release: |
384 | pci_release_region(esb_pci, 0); | 371 | pci_release_region(pdev, 0); |
385 | err_disable: | 372 | err_disable: |
386 | pci_disable_device(esb_pci); | 373 | pci_disable_device(pdev); |
387 | err_devput: | 374 | err_devput: |
388 | pci_dev_put(esb_pci); | ||
389 | return 0; | 375 | return 0; |
390 | } | 376 | } |
391 | 377 | ||
@@ -430,12 +416,23 @@ static void __devinit esb_initdevice(void) | |||
430 | esb_timer_set_heartbeat(heartbeat); | 416 | esb_timer_set_heartbeat(heartbeat); |
431 | } | 417 | } |
432 | 418 | ||
433 | static int __devinit esb_probe(struct platform_device *dev) | 419 | static int __devinit esb_probe(struct pci_dev *pdev, |
420 | const struct pci_device_id *ent) | ||
434 | { | 421 | { |
435 | int ret; | 422 | int ret; |
436 | 423 | ||
424 | cards_found++; | ||
425 | if (cards_found == 1) | ||
426 | printk(KERN_INFO PFX "Intel 6300ESB WatchDog Timer Driver v%s\n", | ||
427 | ESB_VERSION); | ||
428 | |||
429 | if (cards_found > 1) { | ||
430 | printk(KERN_ERR PFX "This driver only supports 1 device\n"); | ||
431 | return -ENODEV; | ||
432 | } | ||
433 | |||
437 | /* Check whether or not the hardware watchdog is there */ | 434 | /* Check whether or not the hardware watchdog is there */ |
438 | if (!esb_getdevice() || esb_pci == NULL) | 435 | if (!esb_getdevice(pdev) || esb_pci == NULL) |
439 | return -ENODEV; | 436 | return -ENODEV; |
440 | 437 | ||
441 | /* Check that the heartbeat value is within it's range; | 438 | /* Check that the heartbeat value is within it's range; |
@@ -467,11 +464,11 @@ err_unmap: | |||
467 | iounmap(BASEADDR); | 464 | iounmap(BASEADDR); |
468 | pci_release_region(esb_pci, 0); | 465 | pci_release_region(esb_pci, 0); |
469 | pci_disable_device(esb_pci); | 466 | pci_disable_device(esb_pci); |
470 | pci_dev_put(esb_pci); | 467 | esb_pci = NULL; |
471 | return ret; | 468 | return ret; |
472 | } | 469 | } |
473 | 470 | ||
474 | static int __devexit esb_remove(struct platform_device *dev) | 471 | static void __devexit esb_remove(struct pci_dev *pdev) |
475 | { | 472 | { |
476 | /* Stop the timer before we leave */ | 473 | /* Stop the timer before we leave */ |
477 | if (!nowayout) | 474 | if (!nowayout) |
@@ -482,54 +479,30 @@ static int __devexit esb_remove(struct platform_device *dev) | |||
482 | iounmap(BASEADDR); | 479 | iounmap(BASEADDR); |
483 | pci_release_region(esb_pci, 0); | 480 | pci_release_region(esb_pci, 0); |
484 | pci_disable_device(esb_pci); | 481 | pci_disable_device(esb_pci); |
485 | pci_dev_put(esb_pci); | 482 | esb_pci = NULL; |
486 | return 0; | ||
487 | } | 483 | } |
488 | 484 | ||
489 | static void esb_shutdown(struct platform_device *dev) | 485 | static void esb_shutdown(struct pci_dev *pdev) |
490 | { | 486 | { |
491 | esb_timer_stop(); | 487 | esb_timer_stop(); |
492 | } | 488 | } |
493 | 489 | ||
494 | static struct platform_driver esb_platform_driver = { | 490 | static struct pci_driver esb_driver = { |
491 | .name = ESB_MODULE_NAME, | ||
492 | .id_table = esb_pci_tbl, | ||
495 | .probe = esb_probe, | 493 | .probe = esb_probe, |
496 | .remove = __devexit_p(esb_remove), | 494 | .remove = __devexit_p(esb_remove), |
497 | .shutdown = esb_shutdown, | 495 | .shutdown = esb_shutdown, |
498 | .driver = { | ||
499 | .owner = THIS_MODULE, | ||
500 | .name = ESB_MODULE_NAME, | ||
501 | }, | ||
502 | }; | 496 | }; |
503 | 497 | ||
504 | static int __init watchdog_init(void) | 498 | static int __init watchdog_init(void) |
505 | { | 499 | { |
506 | int err; | 500 | return pci_register_driver(&esb_driver); |
507 | |||
508 | printk(KERN_INFO PFX "Intel 6300ESB WatchDog Timer Driver v%s\n", | ||
509 | ESB_VERSION); | ||
510 | |||
511 | err = platform_driver_register(&esb_platform_driver); | ||
512 | if (err) | ||
513 | return err; | ||
514 | |||
515 | esb_platform_device = platform_device_register_simple(ESB_MODULE_NAME, | ||
516 | -1, NULL, 0); | ||
517 | if (IS_ERR(esb_platform_device)) { | ||
518 | err = PTR_ERR(esb_platform_device); | ||
519 | goto unreg_platform_driver; | ||
520 | } | ||
521 | |||
522 | return 0; | ||
523 | |||
524 | unreg_platform_driver: | ||
525 | platform_driver_unregister(&esb_platform_driver); | ||
526 | return err; | ||
527 | } | 501 | } |
528 | 502 | ||
529 | static void __exit watchdog_cleanup(void) | 503 | static void __exit watchdog_cleanup(void) |
530 | { | 504 | { |
531 | platform_device_unregister(esb_platform_device); | 505 | pci_unregister_driver(&esb_driver); |
532 | platform_driver_unregister(&esb_platform_driver); | ||
533 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | 506 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); |
534 | } | 507 | } |
535 | 508 | ||
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index 4bdb7f1a9077..44bc6aa46edf 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c | |||
@@ -584,7 +584,7 @@ static long iTCO_wdt_ioctl(struct file *file, unsigned int cmd, | |||
584 | int new_heartbeat; | 584 | int new_heartbeat; |
585 | void __user *argp = (void __user *)arg; | 585 | void __user *argp = (void __user *)arg; |
586 | int __user *p = argp; | 586 | int __user *p = argp; |
587 | static struct watchdog_info ident = { | 587 | static const struct watchdog_info ident = { |
588 | .options = WDIOF_SETTIMEOUT | | 588 | .options = WDIOF_SETTIMEOUT | |
589 | WDIOF_KEEPALIVEPING | | 589 | WDIOF_KEEPALIVEPING | |
590 | WDIOF_MAGICCLOSE, | 590 | WDIOF_MAGICCLOSE, |
@@ -698,7 +698,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, | |||
698 | if (iTCO_wdt_private.iTCO_version == 2) { | 698 | if (iTCO_wdt_private.iTCO_version == 2) { |
699 | pci_read_config_dword(pdev, 0xf0, &base_address); | 699 | pci_read_config_dword(pdev, 0xf0, &base_address); |
700 | if ((base_address & 1) == 0) { | 700 | if ((base_address & 1) == 0) { |
701 | printk(KERN_ERR PFX "RCBA is disabled by harddware\n"); | 701 | printk(KERN_ERR PFX "RCBA is disabled by hardware\n"); |
702 | ret = -ENODEV; | 702 | ret = -ENODEV; |
703 | goto out; | 703 | goto out; |
704 | } | 704 | } |
@@ -708,8 +708,8 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, | |||
708 | 708 | ||
709 | /* Check chipset's NO_REBOOT bit */ | 709 | /* Check chipset's NO_REBOOT bit */ |
710 | if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) { | 710 | if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) { |
711 | printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, " | 711 | printk(KERN_INFO PFX "unable to reset NO_REBOOT flag, " |
712 | "reboot disabled by hardware\n"); | 712 | "platform may have disabled it\n"); |
713 | ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ | 713 | ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ |
714 | goto out_unmap; | 714 | goto out_unmap; |
715 | } | 715 | } |
@@ -805,6 +805,7 @@ static void __devexit iTCO_wdt_cleanup(void) | |||
805 | 805 | ||
806 | static int __devinit iTCO_wdt_probe(struct platform_device *dev) | 806 | static int __devinit iTCO_wdt_probe(struct platform_device *dev) |
807 | { | 807 | { |
808 | int ret = -ENODEV; | ||
808 | int found = 0; | 809 | int found = 0; |
809 | struct pci_dev *pdev = NULL; | 810 | struct pci_dev *pdev = NULL; |
810 | const struct pci_device_id *ent; | 811 | const struct pci_device_id *ent; |
@@ -814,19 +815,17 @@ static int __devinit iTCO_wdt_probe(struct platform_device *dev) | |||
814 | for_each_pci_dev(pdev) { | 815 | for_each_pci_dev(pdev) { |
815 | ent = pci_match_id(iTCO_wdt_pci_tbl, pdev); | 816 | ent = pci_match_id(iTCO_wdt_pci_tbl, pdev); |
816 | if (ent) { | 817 | if (ent) { |
817 | if (!(iTCO_wdt_init(pdev, ent, dev))) { | 818 | found++; |
818 | found++; | 819 | ret = iTCO_wdt_init(pdev, ent, dev); |
820 | if (!ret) | ||
819 | break; | 821 | break; |
820 | } | ||
821 | } | 822 | } |
822 | } | 823 | } |
823 | 824 | ||
824 | if (!found) { | 825 | if (!found) |
825 | printk(KERN_INFO PFX "No card detected\n"); | 826 | printk(KERN_INFO PFX "No card detected\n"); |
826 | return -ENODEV; | ||
827 | } | ||
828 | 827 | ||
829 | return 0; | 828 | return ret; |
830 | } | 829 | } |
831 | 830 | ||
832 | static int __devexit iTCO_wdt_remove(struct platform_device *dev) | 831 | static int __devexit iTCO_wdt_remove(struct platform_device *dev) |
diff --git a/drivers/watchdog/ib700wdt.c b/drivers/watchdog/ib700wdt.c index 4bef3ddff4a5..0149d8dfc81d 100644 --- a/drivers/watchdog/ib700wdt.c +++ b/drivers/watchdog/ib700wdt.c | |||
@@ -174,7 +174,7 @@ static long ibwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
174 | void __user *argp = (void __user *)arg; | 174 | void __user *argp = (void __user *)arg; |
175 | int __user *p = argp; | 175 | int __user *p = argp; |
176 | 176 | ||
177 | static struct watchdog_info ident = { | 177 | static const struct watchdog_info ident = { |
178 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | 178 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
179 | | WDIOF_MAGICCLOSE, | 179 | | WDIOF_MAGICCLOSE, |
180 | .firmware_version = 1, | 180 | .firmware_version = 1, |
diff --git a/drivers/watchdog/indydog.c b/drivers/watchdog/indydog.c index bea8a124a559..1cc5609666d1 100644 --- a/drivers/watchdog/indydog.c +++ b/drivers/watchdog/indydog.c | |||
@@ -111,7 +111,7 @@ static long indydog_ioctl(struct file *file, unsigned int cmd, | |||
111 | unsigned long arg) | 111 | unsigned long arg) |
112 | { | 112 | { |
113 | int options, retval = -EINVAL; | 113 | int options, retval = -EINVAL; |
114 | static struct watchdog_info ident = { | 114 | static const struct watchdog_info ident = { |
115 | .options = WDIOF_KEEPALIVEPING, | 115 | .options = WDIOF_KEEPALIVEPING, |
116 | .firmware_version = 0, | 116 | .firmware_version = 0, |
117 | .identity = "Hardware Watchdog for SGI IP22", | 117 | .identity = "Hardware Watchdog for SGI IP22", |
diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c index daed48ded7fe..f52c162b1bea 100644 --- a/drivers/watchdog/it8712f_wdt.c +++ b/drivers/watchdog/it8712f_wdt.c | |||
@@ -236,7 +236,7 @@ static long it8712f_wdt_ioctl(struct file *file, unsigned int cmd, | |||
236 | { | 236 | { |
237 | void __user *argp = (void __user *)arg; | 237 | void __user *argp = (void __user *)arg; |
238 | int __user *p = argp; | 238 | int __user *p = argp; |
239 | static struct watchdog_info ident = { | 239 | static const struct watchdog_info ident = { |
240 | .identity = "IT8712F Watchdog", | 240 | .identity = "IT8712F Watchdog", |
241 | .firmware_version = 1, | 241 | .firmware_version = 1, |
242 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | | 242 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | |
diff --git a/drivers/watchdog/it87_wdt.c b/drivers/watchdog/it87_wdt.c index cc133c531d08..b709b3b2d1ef 100644 --- a/drivers/watchdog/it87_wdt.c +++ b/drivers/watchdog/it87_wdt.c | |||
@@ -421,7 +421,7 @@ static ssize_t wdt_write(struct file *file, const char __user *buf, | |||
421 | return count; | 421 | return count; |
422 | } | 422 | } |
423 | 423 | ||
424 | static struct watchdog_info ident = { | 424 | static const struct watchdog_info ident = { |
425 | .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, | 425 | .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, |
426 | .firmware_version = 1, | 426 | .firmware_version = 1, |
427 | .identity = WATCHDOG_NAME, | 427 | .identity = WATCHDOG_NAME, |
diff --git a/drivers/watchdog/ixp2000_wdt.c b/drivers/watchdog/ixp2000_wdt.c index 3c79dc587958..e86952a7168c 100644 --- a/drivers/watchdog/ixp2000_wdt.c +++ b/drivers/watchdog/ixp2000_wdt.c | |||
@@ -100,7 +100,7 @@ static ssize_t ixp2000_wdt_write(struct file *file, const char *data, | |||
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | static struct watchdog_info ident = { | 103 | static const struct watchdog_info ident = { |
104 | .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | | 104 | .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | |
105 | WDIOF_KEEPALIVEPING, | 105 | WDIOF_KEEPALIVEPING, |
106 | .identity = "IXP2000 Watchdog", | 106 | .identity = "IXP2000 Watchdog", |
diff --git a/drivers/watchdog/ixp4xx_wdt.c b/drivers/watchdog/ixp4xx_wdt.c index 147b4d5c63b3..e02c0ecda26b 100644 --- a/drivers/watchdog/ixp4xx_wdt.c +++ b/drivers/watchdog/ixp4xx_wdt.c | |||
@@ -89,7 +89,7 @@ ixp4xx_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos) | |||
89 | return len; | 89 | return len; |
90 | } | 90 | } |
91 | 91 | ||
92 | static struct watchdog_info ident = { | 92 | static const struct watchdog_info ident = { |
93 | .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE | | 93 | .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE | |
94 | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | 94 | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, |
95 | .identity = "IXP4xx Watchdog", | 95 | .identity = "IXP4xx Watchdog", |
diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c index e1c82769b08e..2852bb2e3fd9 100644 --- a/drivers/watchdog/ks8695_wdt.c +++ b/drivers/watchdog/ks8695_wdt.c | |||
@@ -145,7 +145,7 @@ static int ks8695_wdt_close(struct inode *inode, struct file *file) | |||
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
147 | 147 | ||
148 | static struct watchdog_info ks8695_wdt_info = { | 148 | static const struct watchdog_info ks8695_wdt_info = { |
149 | .identity = "ks8695 watchdog", | 149 | .identity = "ks8695 watchdog", |
150 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | 150 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, |
151 | }; | 151 | }; |
diff --git a/drivers/watchdog/machzwd.c b/drivers/watchdog/machzwd.c index 47d719717a3b..2d118cf022fc 100644 --- a/drivers/watchdog/machzwd.c +++ b/drivers/watchdog/machzwd.c | |||
@@ -101,7 +101,7 @@ MODULE_PARM_DESC(nowayout, | |||
101 | 101 | ||
102 | #define PFX "machzwd" | 102 | #define PFX "machzwd" |
103 | 103 | ||
104 | static struct watchdog_info zf_info = { | 104 | static const struct watchdog_info zf_info = { |
105 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | 105 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, |
106 | .firmware_version = 1, | 106 | .firmware_version = 1, |
107 | .identity = "ZF-Logic watchdog", | 107 | .identity = "ZF-Logic watchdog", |
diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c new file mode 100644 index 000000000000..6eb91d757604 --- /dev/null +++ b/drivers/watchdog/max63xx_wdt.c | |||
@@ -0,0 +1,397 @@ | |||
1 | /* | ||
2 | * drivers/char/watchdog/max63xx_wdt.c | ||
3 | * | ||
4 | * Driver for max63{69,70,71,72,73,74} watchdog timers | ||
5 | * | ||
6 | * Copyright (C) 2009 Marc Zyngier <maz@misterjones.org> | ||
7 | * | ||
8 | * This file is licensed under the terms of the GNU General Public | ||
9 | * License version 2. This program is licensed "as is" without any | ||
10 | * warranty of any kind, whether express or implied. | ||
11 | * | ||
12 | * This driver assumes the watchdog pins are memory mapped (as it is | ||
13 | * the case for the Arcom Zeus). Should it be connected over GPIOs or | ||
14 | * another interface, some abstraction will have to be introduced. | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/moduleparam.h> | ||
19 | #include <linux/types.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/fs.h> | ||
22 | #include <linux/miscdevice.h> | ||
23 | #include <linux/watchdog.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/bitops.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/uaccess.h> | ||
29 | #include <linux/io.h> | ||
30 | #include <linux/device.h> | ||
31 | |||
32 | #define DEFAULT_HEARTBEAT 60 | ||
33 | #define MAX_HEARTBEAT 60 | ||
34 | |||
35 | static int heartbeat = DEFAULT_HEARTBEAT; | ||
36 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
37 | |||
38 | /* | ||
39 | * Memory mapping: a single byte, 3 first lower bits to select bit 3 | ||
40 | * to ping the watchdog. | ||
41 | */ | ||
42 | #define MAX6369_WDSET (7 << 0) | ||
43 | #define MAX6369_WDI (1 << 3) | ||
44 | |||
45 | static DEFINE_SPINLOCK(io_lock); | ||
46 | |||
47 | static unsigned long wdt_status; | ||
48 | #define WDT_IN_USE 0 | ||
49 | #define WDT_RUNNING 1 | ||
50 | #define WDT_OK_TO_CLOSE 2 | ||
51 | |||
52 | static int nodelay; | ||
53 | static struct resource *wdt_mem; | ||
54 | static void __iomem *wdt_base; | ||
55 | static struct platform_device *max63xx_pdev; | ||
56 | |||
57 | /* | ||
58 | * The timeout values used are actually the absolute minimum the chip | ||
59 | * offers. Typical values on my board are slightly over twice as long | ||
60 | * (10s setting ends up with a 25s timeout), and can be up to 3 times | ||
61 | * the nominal setting (according to the datasheet). So please take | ||
62 | * these values with a grain of salt. Same goes for the initial delay | ||
63 | * "feature". Only max6373/74 have a few settings without this initial | ||
64 | * delay (selected with the "nodelay" parameter). | ||
65 | * | ||
66 | * I also decided to remove from the tables any timeout smaller than a | ||
67 | * second, as it looked completly overkill... | ||
68 | */ | ||
69 | |||
70 | /* Timeouts in second */ | ||
71 | struct max63xx_timeout { | ||
72 | u8 wdset; | ||
73 | u8 tdelay; | ||
74 | u8 twd; | ||
75 | }; | ||
76 | |||
77 | static struct max63xx_timeout max6369_table[] = { | ||
78 | { 5, 1, 1 }, | ||
79 | { 6, 10, 10 }, | ||
80 | { 7, 60, 60 }, | ||
81 | { }, | ||
82 | }; | ||
83 | |||
84 | static struct max63xx_timeout max6371_table[] = { | ||
85 | { 6, 60, 3 }, | ||
86 | { 7, 60, 60 }, | ||
87 | { }, | ||
88 | }; | ||
89 | |||
90 | static struct max63xx_timeout max6373_table[] = { | ||
91 | { 2, 60, 1 }, | ||
92 | { 5, 0, 1 }, | ||
93 | { 1, 3, 3 }, | ||
94 | { 7, 60, 10 }, | ||
95 | { 6, 0, 10 }, | ||
96 | { }, | ||
97 | }; | ||
98 | |||
99 | static struct max63xx_timeout *current_timeout; | ||
100 | |||
101 | static struct max63xx_timeout * | ||
102 | max63xx_select_timeout(struct max63xx_timeout *table, int value) | ||
103 | { | ||
104 | while (table->twd) { | ||
105 | if (value <= table->twd) { | ||
106 | if (nodelay && table->tdelay == 0) | ||
107 | return table; | ||
108 | |||
109 | if (!nodelay) | ||
110 | return table; | ||
111 | } | ||
112 | |||
113 | table++; | ||
114 | } | ||
115 | |||
116 | return NULL; | ||
117 | } | ||
118 | |||
119 | static void max63xx_wdt_ping(void) | ||
120 | { | ||
121 | u8 val; | ||
122 | |||
123 | spin_lock(&io_lock); | ||
124 | |||
125 | val = __raw_readb(wdt_base); | ||
126 | |||
127 | __raw_writeb(val | MAX6369_WDI, wdt_base); | ||
128 | __raw_writeb(val & ~MAX6369_WDI, wdt_base); | ||
129 | |||
130 | spin_unlock(&io_lock); | ||
131 | } | ||
132 | |||
133 | static void max63xx_wdt_enable(struct max63xx_timeout *entry) | ||
134 | { | ||
135 | u8 val; | ||
136 | |||
137 | if (test_and_set_bit(WDT_RUNNING, &wdt_status)) | ||
138 | return; | ||
139 | |||
140 | spin_lock(&io_lock); | ||
141 | |||
142 | val = __raw_readb(wdt_base); | ||
143 | val &= ~MAX6369_WDSET; | ||
144 | val |= entry->wdset; | ||
145 | __raw_writeb(val, wdt_base); | ||
146 | |||
147 | spin_unlock(&io_lock); | ||
148 | |||
149 | /* check for a edge triggered startup */ | ||
150 | if (entry->tdelay == 0) | ||
151 | max63xx_wdt_ping(); | ||
152 | } | ||
153 | |||
154 | static void max63xx_wdt_disable(void) | ||
155 | { | ||
156 | spin_lock(&io_lock); | ||
157 | |||
158 | __raw_writeb(3, wdt_base); | ||
159 | |||
160 | spin_unlock(&io_lock); | ||
161 | |||
162 | clear_bit(WDT_RUNNING, &wdt_status); | ||
163 | } | ||
164 | |||
165 | static int max63xx_wdt_open(struct inode *inode, struct file *file) | ||
166 | { | ||
167 | if (test_and_set_bit(WDT_IN_USE, &wdt_status)) | ||
168 | return -EBUSY; | ||
169 | |||
170 | max63xx_wdt_enable(current_timeout); | ||
171 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); | ||
172 | |||
173 | return nonseekable_open(inode, file); | ||
174 | } | ||
175 | |||
176 | static ssize_t max63xx_wdt_write(struct file *file, const char *data, | ||
177 | size_t len, loff_t *ppos) | ||
178 | { | ||
179 | if (len) { | ||
180 | if (!nowayout) { | ||
181 | size_t i; | ||
182 | |||
183 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); | ||
184 | for (i = 0; i != len; i++) { | ||
185 | char c; | ||
186 | |||
187 | if (get_user(c, data + i)) | ||
188 | return -EFAULT; | ||
189 | |||
190 | if (c == 'V') | ||
191 | set_bit(WDT_OK_TO_CLOSE, &wdt_status); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | max63xx_wdt_ping(); | ||
196 | } | ||
197 | |||
198 | return len; | ||
199 | } | ||
200 | |||
201 | static const struct watchdog_info ident = { | ||
202 | .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, | ||
203 | .identity = "max63xx Watchdog", | ||
204 | }; | ||
205 | |||
206 | static long max63xx_wdt_ioctl(struct file *file, unsigned int cmd, | ||
207 | unsigned long arg) | ||
208 | { | ||
209 | int ret = -ENOTTY; | ||
210 | |||
211 | switch (cmd) { | ||
212 | case WDIOC_GETSUPPORT: | ||
213 | ret = copy_to_user((struct watchdog_info *)arg, &ident, | ||
214 | sizeof(ident)) ? -EFAULT : 0; | ||
215 | break; | ||
216 | |||
217 | case WDIOC_GETSTATUS: | ||
218 | case WDIOC_GETBOOTSTATUS: | ||
219 | ret = put_user(0, (int *)arg); | ||
220 | break; | ||
221 | |||
222 | case WDIOC_KEEPALIVE: | ||
223 | max63xx_wdt_ping(); | ||
224 | ret = 0; | ||
225 | break; | ||
226 | |||
227 | case WDIOC_GETTIMEOUT: | ||
228 | ret = put_user(heartbeat, (int *)arg); | ||
229 | break; | ||
230 | } | ||
231 | return ret; | ||
232 | } | ||
233 | |||
234 | static int max63xx_wdt_release(struct inode *inode, struct file *file) | ||
235 | { | ||
236 | if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) | ||
237 | max63xx_wdt_disable(); | ||
238 | else | ||
239 | dev_crit(&max63xx_pdev->dev, | ||
240 | "device closed unexpectedly - timer will not stop\n"); | ||
241 | |||
242 | clear_bit(WDT_IN_USE, &wdt_status); | ||
243 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static const struct file_operations max63xx_wdt_fops = { | ||
249 | .owner = THIS_MODULE, | ||
250 | .llseek = no_llseek, | ||
251 | .write = max63xx_wdt_write, | ||
252 | .unlocked_ioctl = max63xx_wdt_ioctl, | ||
253 | .open = max63xx_wdt_open, | ||
254 | .release = max63xx_wdt_release, | ||
255 | }; | ||
256 | |||
257 | static struct miscdevice max63xx_wdt_miscdev = { | ||
258 | .minor = WATCHDOG_MINOR, | ||
259 | .name = "watchdog", | ||
260 | .fops = &max63xx_wdt_fops, | ||
261 | }; | ||
262 | |||
263 | static int __devinit max63xx_wdt_probe(struct platform_device *pdev) | ||
264 | { | ||
265 | int ret = 0; | ||
266 | int size; | ||
267 | struct resource *res; | ||
268 | struct device *dev = &pdev->dev; | ||
269 | struct max63xx_timeout *table; | ||
270 | |||
271 | table = (struct max63xx_timeout *)pdev->id_entry->driver_data; | ||
272 | |||
273 | if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) | ||
274 | heartbeat = DEFAULT_HEARTBEAT; | ||
275 | |||
276 | dev_info(dev, "requesting %ds heartbeat\n", heartbeat); | ||
277 | current_timeout = max63xx_select_timeout(table, heartbeat); | ||
278 | |||
279 | if (!current_timeout) { | ||
280 | dev_err(dev, "unable to satisfy heartbeat request\n"); | ||
281 | return -EINVAL; | ||
282 | } | ||
283 | |||
284 | dev_info(dev, "using %ds heartbeat with %ds initial delay\n", | ||
285 | current_timeout->twd, current_timeout->tdelay); | ||
286 | |||
287 | heartbeat = current_timeout->twd; | ||
288 | |||
289 | max63xx_pdev = pdev; | ||
290 | |||
291 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
292 | if (res == NULL) { | ||
293 | dev_err(dev, "failed to get memory region resource\n"); | ||
294 | return -ENOENT; | ||
295 | } | ||
296 | |||
297 | size = resource_size(res); | ||
298 | wdt_mem = request_mem_region(res->start, size, pdev->name); | ||
299 | |||
300 | if (wdt_mem == NULL) { | ||
301 | dev_err(dev, "failed to get memory region\n"); | ||
302 | return -ENOENT; | ||
303 | } | ||
304 | |||
305 | wdt_base = ioremap(res->start, size); | ||
306 | if (!wdt_base) { | ||
307 | dev_err(dev, "failed to map memory region\n"); | ||
308 | ret = -ENOMEM; | ||
309 | goto out_request; | ||
310 | } | ||
311 | |||
312 | ret = misc_register(&max63xx_wdt_miscdev); | ||
313 | if (ret < 0) { | ||
314 | dev_err(dev, "cannot register misc device\n"); | ||
315 | goto out_unmap; | ||
316 | } | ||
317 | |||
318 | return 0; | ||
319 | |||
320 | out_unmap: | ||
321 | iounmap(wdt_base); | ||
322 | out_request: | ||
323 | release_resource(wdt_mem); | ||
324 | kfree(wdt_mem); | ||
325 | |||
326 | return ret; | ||
327 | } | ||
328 | |||
329 | static int __devexit max63xx_wdt_remove(struct platform_device *pdev) | ||
330 | { | ||
331 | misc_deregister(&max63xx_wdt_miscdev); | ||
332 | if (wdt_mem) { | ||
333 | release_resource(wdt_mem); | ||
334 | kfree(wdt_mem); | ||
335 | wdt_mem = NULL; | ||
336 | } | ||
337 | |||
338 | if (wdt_base) | ||
339 | iounmap(wdt_base); | ||
340 | |||
341 | return 0; | ||
342 | } | ||
343 | |||
344 | static struct platform_device_id max63xx_id_table[] = { | ||
345 | { "max6369_wdt", (kernel_ulong_t)max6369_table, }, | ||
346 | { "max6370_wdt", (kernel_ulong_t)max6369_table, }, | ||
347 | { "max6371_wdt", (kernel_ulong_t)max6371_table, }, | ||
348 | { "max6372_wdt", (kernel_ulong_t)max6371_table, }, | ||
349 | { "max6373_wdt", (kernel_ulong_t)max6373_table, }, | ||
350 | { "max6374_wdt", (kernel_ulong_t)max6373_table, }, | ||
351 | { }, | ||
352 | }; | ||
353 | MODULE_DEVICE_TABLE(platform, max63xx_id_table); | ||
354 | |||
355 | static struct platform_driver max63xx_wdt_driver = { | ||
356 | .probe = max63xx_wdt_probe, | ||
357 | .remove = __devexit_p(max63xx_wdt_remove), | ||
358 | .id_table = max63xx_id_table, | ||
359 | .driver = { | ||
360 | .name = "max63xx_wdt", | ||
361 | .owner = THIS_MODULE, | ||
362 | }, | ||
363 | }; | ||
364 | |||
365 | static int __init max63xx_wdt_init(void) | ||
366 | { | ||
367 | return platform_driver_register(&max63xx_wdt_driver); | ||
368 | } | ||
369 | |||
370 | static void __exit max63xx_wdt_exit(void) | ||
371 | { | ||
372 | platform_driver_unregister(&max63xx_wdt_driver); | ||
373 | } | ||
374 | |||
375 | module_init(max63xx_wdt_init); | ||
376 | module_exit(max63xx_wdt_exit); | ||
377 | |||
378 | MODULE_AUTHOR("Marc Zyngier <maz@misterjones.org>"); | ||
379 | MODULE_DESCRIPTION("max63xx Watchdog Driver"); | ||
380 | |||
381 | module_param(heartbeat, int, 0); | ||
382 | MODULE_PARM_DESC(heartbeat, | ||
383 | "Watchdog heartbeat period in seconds from 1 to " | ||
384 | __MODULE_STRING(MAX_HEARTBEAT) ", default " | ||
385 | __MODULE_STRING(DEFAULT_HEARTBEAT)); | ||
386 | |||
387 | module_param(nowayout, int, 0); | ||
388 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | ||
389 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
390 | |||
391 | module_param(nodelay, int, 0); | ||
392 | MODULE_PARM_DESC(nodelay, | ||
393 | "Force selection of a timeout setting without initial delay " | ||
394 | "(max6373/74 only, default=0)"); | ||
395 | |||
396 | MODULE_LICENSE("GPL"); | ||
397 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/mixcomwd.c b/drivers/watchdog/mixcomwd.c index 407b025cb104..bc820d16699a 100644 --- a/drivers/watchdog/mixcomwd.c +++ b/drivers/watchdog/mixcomwd.c | |||
@@ -201,7 +201,7 @@ static long mixcomwd_ioctl(struct file *file, | |||
201 | void __user *argp = (void __user *)arg; | 201 | void __user *argp = (void __user *)arg; |
202 | int __user *p = argp; | 202 | int __user *p = argp; |
203 | int status; | 203 | int status; |
204 | static struct watchdog_info ident = { | 204 | static const struct watchdog_info ident = { |
205 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | 205 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, |
206 | .firmware_version = 1, | 206 | .firmware_version = 1, |
207 | .identity = "MixCOM watchdog", | 207 | .identity = "MixCOM watchdog", |
diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c index 38c588ee694f..4e3941c5e293 100644 --- a/drivers/watchdog/mpc8xxx_wdt.c +++ b/drivers/watchdog/mpc8xxx_wdt.c | |||
@@ -148,7 +148,7 @@ static long mpc8xxx_wdt_ioctl(struct file *file, unsigned int cmd, | |||
148 | { | 148 | { |
149 | void __user *argp = (void __user *)arg; | 149 | void __user *argp = (void __user *)arg; |
150 | int __user *p = argp; | 150 | int __user *p = argp; |
151 | static struct watchdog_info ident = { | 151 | static const struct watchdog_info ident = { |
152 | .options = WDIOF_KEEPALIVEPING, | 152 | .options = WDIOF_KEEPALIVEPING, |
153 | .firmware_version = 1, | 153 | .firmware_version = 1, |
154 | .identity = "MPC8xxx", | 154 | .identity = "MPC8xxx", |
diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c index a2dc07c2ed49..b0646dac924e 100644 --- a/drivers/watchdog/mpcore_wdt.c +++ b/drivers/watchdog/mpcore_wdt.c | |||
@@ -213,7 +213,7 @@ static ssize_t mpcore_wdt_write(struct file *file, const char *data, | |||
213 | return len; | 213 | return len; |
214 | } | 214 | } |
215 | 215 | ||
216 | static struct watchdog_info ident = { | 216 | static const struct watchdog_info ident = { |
217 | .options = WDIOF_SETTIMEOUT | | 217 | .options = WDIOF_SETTIMEOUT | |
218 | WDIOF_KEEPALIVEPING | | 218 | WDIOF_KEEPALIVEPING | |
219 | WDIOF_MAGICCLOSE, | 219 | WDIOF_MAGICCLOSE, |
diff --git a/drivers/watchdog/mv64x60_wdt.c b/drivers/watchdog/mv64x60_wdt.c index a51dbe4c43da..97f8a48d8b78 100644 --- a/drivers/watchdog/mv64x60_wdt.c +++ b/drivers/watchdog/mv64x60_wdt.c | |||
@@ -179,7 +179,7 @@ static long mv64x60_wdt_ioctl(struct file *file, | |||
179 | int timeout; | 179 | int timeout; |
180 | int options; | 180 | int options; |
181 | void __user *argp = (void __user *)arg; | 181 | void __user *argp = (void __user *)arg; |
182 | static struct watchdog_info info = { | 182 | static const struct watchdog_info info = { |
183 | .options = WDIOF_SETTIMEOUT | | 183 | .options = WDIOF_SETTIMEOUT | |
184 | WDIOF_MAGICCLOSE | | 184 | WDIOF_MAGICCLOSE | |
185 | WDIOF_KEEPALIVEPING, | 185 | WDIOF_KEEPALIVEPING, |
diff --git a/drivers/watchdog/pc87413_wdt.c b/drivers/watchdog/pc87413_wdt.c index 1a2b916e3f8d..d3aa2f1fe61d 100644 --- a/drivers/watchdog/pc87413_wdt.c +++ b/drivers/watchdog/pc87413_wdt.c | |||
@@ -407,7 +407,7 @@ static long pc87413_ioctl(struct file *file, unsigned int cmd, | |||
407 | int __user *i; | 407 | int __user *i; |
408 | } uarg; | 408 | } uarg; |
409 | 409 | ||
410 | static struct watchdog_info ident = { | 410 | static const struct watchdog_info ident = { |
411 | .options = WDIOF_KEEPALIVEPING | | 411 | .options = WDIOF_KEEPALIVEPING | |
412 | WDIOF_SETTIMEOUT | | 412 | WDIOF_SETTIMEOUT | |
413 | WDIOF_MAGICCLOSE, | 413 | WDIOF_MAGICCLOSE, |
diff --git a/drivers/watchdog/pcwd.c b/drivers/watchdog/pcwd.c index aa9512321f3a..06f7922606c0 100644 --- a/drivers/watchdog/pcwd.c +++ b/drivers/watchdog/pcwd.c | |||
@@ -606,7 +606,7 @@ static long pcwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
606 | int temperature; | 606 | int temperature; |
607 | int new_heartbeat; | 607 | int new_heartbeat; |
608 | int __user *argp = (int __user *)arg; | 608 | int __user *argp = (int __user *)arg; |
609 | static struct watchdog_info ident = { | 609 | static const struct watchdog_info ident = { |
610 | .options = WDIOF_OVERHEAT | | 610 | .options = WDIOF_OVERHEAT | |
611 | WDIOF_CARDRESET | | 611 | WDIOF_CARDRESET | |
612 | WDIOF_KEEPALIVEPING | | 612 | WDIOF_KEEPALIVEPING | |
diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c index 698f51bff1bc..64374d636f09 100644 --- a/drivers/watchdog/pcwd_pci.c +++ b/drivers/watchdog/pcwd_pci.c | |||
@@ -481,7 +481,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd, | |||
481 | { | 481 | { |
482 | void __user *argp = (void __user *)arg; | 482 | void __user *argp = (void __user *)arg; |
483 | int __user *p = argp; | 483 | int __user *p = argp; |
484 | static struct watchdog_info ident = { | 484 | static const struct watchdog_info ident = { |
485 | .options = WDIOF_OVERHEAT | | 485 | .options = WDIOF_OVERHEAT | |
486 | WDIOF_CARDRESET | | 486 | WDIOF_CARDRESET | |
487 | WDIOF_KEEPALIVEPING | | 487 | WDIOF_KEEPALIVEPING | |
diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c index 052fe451851f..8e4eacc5bb52 100644 --- a/drivers/watchdog/pcwd_usb.c +++ b/drivers/watchdog/pcwd_usb.c | |||
@@ -404,7 +404,7 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd, | |||
404 | { | 404 | { |
405 | void __user *argp = (void __user *)arg; | 405 | void __user *argp = (void __user *)arg; |
406 | int __user *p = argp; | 406 | int __user *p = argp; |
407 | static struct watchdog_info ident = { | 407 | static const struct watchdog_info ident = { |
408 | .options = WDIOF_KEEPALIVEPING | | 408 | .options = WDIOF_KEEPALIVEPING | |
409 | WDIOF_SETTIMEOUT | | 409 | WDIOF_SETTIMEOUT | |
410 | WDIOF_MAGICCLOSE, | 410 | WDIOF_MAGICCLOSE, |
diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c index 2d22e996e996..435ec2aed4fe 100644 --- a/drivers/watchdog/pika_wdt.c +++ b/drivers/watchdog/pika_wdt.c | |||
@@ -52,7 +52,7 @@ static struct { | |||
52 | struct timer_list timer; /* The timer that pings the watchdog */ | 52 | struct timer_list timer; /* The timer that pings the watchdog */ |
53 | } pikawdt_private; | 53 | } pikawdt_private; |
54 | 54 | ||
55 | static struct watchdog_info ident = { | 55 | static const struct watchdog_info ident = { |
56 | .identity = DRV_NAME, | 56 | .identity = DRV_NAME, |
57 | .options = WDIOF_CARDRESET | | 57 | .options = WDIOF_CARDRESET | |
58 | WDIOF_SETTIMEOUT | | 58 | WDIOF_SETTIMEOUT | |
diff --git a/drivers/watchdog/pnx833x_wdt.c b/drivers/watchdog/pnx833x_wdt.c index 538ec2c05197..09102f09e681 100644 --- a/drivers/watchdog/pnx833x_wdt.c +++ b/drivers/watchdog/pnx833x_wdt.c | |||
@@ -141,7 +141,7 @@ static long pnx833x_wdt_ioctl(struct file *file, unsigned int cmd, | |||
141 | int options, new_timeout = 0; | 141 | int options, new_timeout = 0; |
142 | uint32_t timeout, timeout_left = 0; | 142 | uint32_t timeout, timeout_left = 0; |
143 | 143 | ||
144 | static struct watchdog_info ident = { | 144 | static const struct watchdog_info ident = { |
145 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, | 145 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, |
146 | .firmware_version = 0, | 146 | .firmware_version = 0, |
147 | .identity = "Hardware Watchdog for PNX833x", | 147 | .identity = "Hardware Watchdog for PNX833x", |
diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c index bf12d06b5877..d4c29b5311a4 100644 --- a/drivers/watchdog/rc32434_wdt.c +++ b/drivers/watchdog/rc32434_wdt.c | |||
@@ -198,7 +198,7 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd, | |||
198 | void __user *argp = (void __user *)arg; | 198 | void __user *argp = (void __user *)arg; |
199 | int new_timeout; | 199 | int new_timeout; |
200 | unsigned int value; | 200 | unsigned int value; |
201 | static struct watchdog_info ident = { | 201 | static const struct watchdog_info ident = { |
202 | .options = WDIOF_SETTIMEOUT | | 202 | .options = WDIOF_SETTIMEOUT | |
203 | WDIOF_KEEPALIVEPING | | 203 | WDIOF_KEEPALIVEPING | |
204 | WDIOF_MAGICCLOSE, | 204 | WDIOF_MAGICCLOSE, |
diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c index 4976bfd1fce6..69c6adbd8205 100644 --- a/drivers/watchdog/rdc321x_wdt.c +++ b/drivers/watchdog/rdc321x_wdt.c | |||
@@ -149,7 +149,7 @@ static long rdc321x_wdt_ioctl(struct file *file, unsigned int cmd, | |||
149 | { | 149 | { |
150 | void __user *argp = (void __user *)arg; | 150 | void __user *argp = (void __user *)arg; |
151 | unsigned int value; | 151 | unsigned int value; |
152 | static struct watchdog_info ident = { | 152 | static const struct watchdog_info ident = { |
153 | .options = WDIOF_CARDRESET, | 153 | .options = WDIOF_CARDRESET, |
154 | .identity = "RDC321x WDT", | 154 | .identity = "RDC321x WDT", |
155 | }; | 155 | }; |
diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c index c14ae8676903..ae57bf9e1b03 100644 --- a/drivers/watchdog/riowd.c +++ b/drivers/watchdog/riowd.c | |||
@@ -85,7 +85,7 @@ static int riowd_release(struct inode *inode, struct file *filp) | |||
85 | 85 | ||
86 | static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 86 | static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
87 | { | 87 | { |
88 | static struct watchdog_info info = { | 88 | static const struct watchdog_info info = { |
89 | .options = WDIOF_SETTIMEOUT, | 89 | .options = WDIOF_SETTIMEOUT, |
90 | .firmware_version = 1, | 90 | .firmware_version = 1, |
91 | .identity = DRIVER_NAME, | 91 | .identity = DRIVER_NAME, |
diff --git a/drivers/watchdog/sbc_fitpc2_wdt.c b/drivers/watchdog/sbc_fitpc2_wdt.c index e6763d2a567b..8d44c9b6fb5b 100644 --- a/drivers/watchdog/sbc_fitpc2_wdt.c +++ b/drivers/watchdog/sbc_fitpc2_wdt.c | |||
@@ -111,7 +111,7 @@ out: | |||
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | static struct watchdog_info ident = { | 114 | static const struct watchdog_info ident = { |
115 | .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | | 115 | .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | |
116 | WDIOF_KEEPALIVEPING, | 116 | WDIOF_KEEPALIVEPING, |
117 | .identity = WATCHDOG_NAME, | 117 | .identity = WATCHDOG_NAME, |
diff --git a/drivers/watchdog/sch311x_wdt.c b/drivers/watchdog/sch311x_wdt.c index 569eb295a7a8..9c40f48804f5 100644 --- a/drivers/watchdog/sch311x_wdt.c +++ b/drivers/watchdog/sch311x_wdt.c | |||
@@ -250,7 +250,7 @@ static long sch311x_wdt_ioctl(struct file *file, unsigned int cmd, | |||
250 | int new_timeout; | 250 | int new_timeout; |
251 | void __user *argp = (void __user *)arg; | 251 | void __user *argp = (void __user *)arg; |
252 | int __user *p = argp; | 252 | int __user *p = argp; |
253 | static struct watchdog_info ident = { | 253 | static const struct watchdog_info ident = { |
254 | .options = WDIOF_KEEPALIVEPING | | 254 | .options = WDIOF_KEEPALIVEPING | |
255 | WDIOF_SETTIMEOUT | | 255 | WDIOF_SETTIMEOUT | |
256 | WDIOF_MAGICCLOSE, | 256 | WDIOF_MAGICCLOSE, |
diff --git a/drivers/watchdog/stmp3xxx_wdt.c b/drivers/watchdog/stmp3xxx_wdt.c index 5dd952681f32..b3421fd2cda8 100644 --- a/drivers/watchdog/stmp3xxx_wdt.c +++ b/drivers/watchdog/stmp3xxx_wdt.c | |||
@@ -94,7 +94,7 @@ static ssize_t stmp3xxx_wdt_write(struct file *file, const char __user *data, | |||
94 | return len; | 94 | return len; |
95 | } | 95 | } |
96 | 96 | ||
97 | static struct watchdog_info ident = { | 97 | static const struct watchdog_info ident = { |
98 | .options = WDIOF_CARDRESET | | 98 | .options = WDIOF_CARDRESET | |
99 | WDIOF_MAGICCLOSE | | 99 | WDIOF_MAGICCLOSE | |
100 | WDIOF_SETTIMEOUT | | 100 | WDIOF_SETTIMEOUT | |
diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c new file mode 100644 index 000000000000..565a2c3321e5 --- /dev/null +++ b/drivers/watchdog/ts72xx_wdt.c | |||
@@ -0,0 +1,520 @@ | |||
1 | /* | ||
2 | * Watchdog driver for Technologic Systems TS-72xx based SBCs | ||
3 | * (TS-7200, TS-7250 and TS-7260). These boards have external | ||
4 | * glue logic CPLD chip, which includes programmable watchdog | ||
5 | * timer. | ||
6 | * | ||
7 | * Copyright (c) 2009 Mika Westerberg <mika.westerberg@iki.fi> | ||
8 | * | ||
9 | * This driver is based on ep93xx_wdt and wm831x_wdt drivers. | ||
10 | * | ||
11 | * This file is licensed under the terms of the GNU General Public | ||
12 | * License version 2. This program is licensed "as is" without any | ||
13 | * warranty of any kind, whether express or implied. | ||
14 | */ | ||
15 | |||
16 | #include <linux/fs.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/moduleparam.h> | ||
20 | #include <linux/miscdevice.h> | ||
21 | #include <linux/mutex.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/watchdog.h> | ||
24 | #include <linux/uaccess.h> | ||
25 | |||
26 | #define TS72XX_WDT_FEED_VAL 0x05 | ||
27 | #define TS72XX_WDT_DEFAULT_TIMEOUT 8 | ||
28 | |||
29 | static int timeout = TS72XX_WDT_DEFAULT_TIMEOUT; | ||
30 | module_param(timeout, int, 0); | ||
31 | MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. " | ||
32 | "(1 <= timeout <= 8, default=" | ||
33 | __MODULE_STRING(TS72XX_WDT_DEFAULT_TIMEOUT) | ||
34 | ")"); | ||
35 | |||
36 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
37 | module_param(nowayout, int, 0); | ||
38 | MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); | ||
39 | |||
40 | /** | ||
41 | * struct ts72xx_wdt - watchdog control structure | ||
42 | * @lock: lock that protects this structure | ||
43 | * @regval: watchdog timeout value suitable for control register | ||
44 | * @flags: flags controlling watchdog device state | ||
45 | * @control_reg: watchdog control register | ||
46 | * @feed_reg: watchdog feed register | ||
47 | * @pdev: back pointer to platform dev | ||
48 | */ | ||
49 | struct ts72xx_wdt { | ||
50 | struct mutex lock; | ||
51 | int regval; | ||
52 | |||
53 | #define TS72XX_WDT_BUSY_FLAG 1 | ||
54 | #define TS72XX_WDT_EXPECT_CLOSE_FLAG 2 | ||
55 | int flags; | ||
56 | |||
57 | void __iomem *control_reg; | ||
58 | void __iomem *feed_reg; | ||
59 | |||
60 | struct platform_device *pdev; | ||
61 | }; | ||
62 | |||
63 | struct platform_device *ts72xx_wdt_pdev; | ||
64 | |||
65 | /* | ||
66 | * TS-72xx Watchdog supports following timeouts (value written | ||
67 | * to control register): | ||
68 | * value description | ||
69 | * ------------------------- | ||
70 | * 0x00 watchdog disabled | ||
71 | * 0x01 250ms | ||
72 | * 0x02 500ms | ||
73 | * 0x03 1s | ||
74 | * 0x04 reserved | ||
75 | * 0x05 2s | ||
76 | * 0x06 4s | ||
77 | * 0x07 8s | ||
78 | * | ||
79 | * Timeouts below 1s are not very usable so we don't | ||
80 | * allow them at all. | ||
81 | * | ||
82 | * We provide two functions that convert between these: | ||
83 | * timeout_to_regval() and regval_to_timeout(). | ||
84 | */ | ||
85 | static const struct { | ||
86 | int timeout; | ||
87 | int regval; | ||
88 | } ts72xx_wdt_map[] = { | ||
89 | { 1, 3 }, | ||
90 | { 2, 5 }, | ||
91 | { 4, 6 }, | ||
92 | { 8, 7 }, | ||
93 | }; | ||
94 | |||
95 | /** | ||
96 | * timeout_to_regval() - converts given timeout to control register value | ||
97 | * @new_timeout: timeout in seconds to be converted | ||
98 | * | ||
99 | * Function converts given @new_timeout into valid value that can | ||
100 | * be programmed into watchdog control register. When conversion is | ||
101 | * not possible, function returns %-EINVAL. | ||
102 | */ | ||
103 | static int timeout_to_regval(int new_timeout) | ||
104 | { | ||
105 | int i; | ||
106 | |||
107 | /* first limit it to 1 - 8 seconds */ | ||
108 | new_timeout = clamp_val(new_timeout, 1, 8); | ||
109 | |||
110 | for (i = 0; i < ARRAY_SIZE(ts72xx_wdt_map); i++) { | ||
111 | if (ts72xx_wdt_map[i].timeout >= new_timeout) | ||
112 | return ts72xx_wdt_map[i].regval; | ||
113 | } | ||
114 | |||
115 | return -EINVAL; | ||
116 | } | ||
117 | |||
118 | /** | ||
119 | * regval_to_timeout() - converts control register value to timeout | ||
120 | * @regval: control register value to be converted | ||
121 | * | ||
122 | * Function converts given @regval to timeout in seconds (1, 2, 4 or 8). | ||
123 | * If @regval cannot be converted, function returns %-EINVAL. | ||
124 | */ | ||
125 | static int regval_to_timeout(int regval) | ||
126 | { | ||
127 | int i; | ||
128 | |||
129 | for (i = 0; i < ARRAY_SIZE(ts72xx_wdt_map); i++) { | ||
130 | if (ts72xx_wdt_map[i].regval == regval) | ||
131 | return ts72xx_wdt_map[i].timeout; | ||
132 | } | ||
133 | |||
134 | return -EINVAL; | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * ts72xx_wdt_kick() - kick the watchdog | ||
139 | * @wdt: watchdog to be kicked | ||
140 | * | ||
141 | * Called with @wdt->lock held. | ||
142 | */ | ||
143 | static inline void ts72xx_wdt_kick(struct ts72xx_wdt *wdt) | ||
144 | { | ||
145 | __raw_writeb(TS72XX_WDT_FEED_VAL, wdt->feed_reg); | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * ts72xx_wdt_start() - starts the watchdog timer | ||
150 | * @wdt: watchdog to be started | ||
151 | * | ||
152 | * This function programs timeout to watchdog timer | ||
153 | * and starts it. | ||
154 | * | ||
155 | * Called with @wdt->lock held. | ||
156 | */ | ||
157 | static void ts72xx_wdt_start(struct ts72xx_wdt *wdt) | ||
158 | { | ||
159 | /* | ||
160 | * To program the wdt, it first must be "fed" and | ||
161 | * only after that (within 30 usecs) the configuration | ||
162 | * can be changed. | ||
163 | */ | ||
164 | ts72xx_wdt_kick(wdt); | ||
165 | __raw_writeb((u8)wdt->regval, wdt->control_reg); | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * ts72xx_wdt_stop() - stops the watchdog timer | ||
170 | * @wdt: watchdog to be stopped | ||
171 | * | ||
172 | * Called with @wdt->lock held. | ||
173 | */ | ||
174 | static void ts72xx_wdt_stop(struct ts72xx_wdt *wdt) | ||
175 | { | ||
176 | ts72xx_wdt_kick(wdt); | ||
177 | __raw_writeb(0, wdt->control_reg); | ||
178 | } | ||
179 | |||
180 | static int ts72xx_wdt_open(struct inode *inode, struct file *file) | ||
181 | { | ||
182 | struct ts72xx_wdt *wdt = platform_get_drvdata(ts72xx_wdt_pdev); | ||
183 | int regval; | ||
184 | |||
185 | /* | ||
186 | * Try to convert default timeout to valid register | ||
187 | * value first. | ||
188 | */ | ||
189 | regval = timeout_to_regval(timeout); | ||
190 | if (regval < 0) { | ||
191 | dev_err(&wdt->pdev->dev, | ||
192 | "failed to convert timeout (%d) to register value\n", | ||
193 | timeout); | ||
194 | return -EINVAL; | ||
195 | } | ||
196 | |||
197 | if (mutex_lock_interruptible(&wdt->lock)) | ||
198 | return -ERESTARTSYS; | ||
199 | |||
200 | if ((wdt->flags & TS72XX_WDT_BUSY_FLAG) != 0) { | ||
201 | mutex_unlock(&wdt->lock); | ||
202 | return -EBUSY; | ||
203 | } | ||
204 | |||
205 | wdt->flags = TS72XX_WDT_BUSY_FLAG; | ||
206 | wdt->regval = regval; | ||
207 | file->private_data = wdt; | ||
208 | |||
209 | ts72xx_wdt_start(wdt); | ||
210 | |||
211 | mutex_unlock(&wdt->lock); | ||
212 | return nonseekable_open(inode, file); | ||
213 | } | ||
214 | |||
215 | static int ts72xx_wdt_release(struct inode *inode, struct file *file) | ||
216 | { | ||
217 | struct ts72xx_wdt *wdt = file->private_data; | ||
218 | |||
219 | if (mutex_lock_interruptible(&wdt->lock)) | ||
220 | return -ERESTARTSYS; | ||
221 | |||
222 | if ((wdt->flags & TS72XX_WDT_EXPECT_CLOSE_FLAG) != 0) { | ||
223 | ts72xx_wdt_stop(wdt); | ||
224 | } else { | ||
225 | dev_warn(&wdt->pdev->dev, | ||
226 | "TS-72XX WDT device closed unexpectly. " | ||
227 | "Watchdog timer will not stop!\n"); | ||
228 | /* | ||
229 | * Kick it one more time, to give userland some time | ||
230 | * to recover (for example, respawning the kicker | ||
231 | * daemon). | ||
232 | */ | ||
233 | ts72xx_wdt_kick(wdt); | ||
234 | } | ||
235 | |||
236 | wdt->flags = 0; | ||
237 | |||
238 | mutex_unlock(&wdt->lock); | ||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static ssize_t ts72xx_wdt_write(struct file *file, | ||
243 | const char __user *data, | ||
244 | size_t len, | ||
245 | loff_t *ppos) | ||
246 | { | ||
247 | struct ts72xx_wdt *wdt = file->private_data; | ||
248 | |||
249 | if (!len) | ||
250 | return 0; | ||
251 | |||
252 | if (mutex_lock_interruptible(&wdt->lock)) | ||
253 | return -ERESTARTSYS; | ||
254 | |||
255 | ts72xx_wdt_kick(wdt); | ||
256 | |||
257 | /* | ||
258 | * Support for magic character closing. User process | ||
259 | * writes 'V' into the device, just before it is closed. | ||
260 | * This means that we know that the wdt timer can be | ||
261 | * stopped after user closes the device. | ||
262 | */ | ||
263 | if (!nowayout) { | ||
264 | int i; | ||
265 | |||
266 | for (i = 0; i < len; i++) { | ||
267 | char c; | ||
268 | |||
269 | /* In case it was set long ago */ | ||
270 | wdt->flags &= ~TS72XX_WDT_EXPECT_CLOSE_FLAG; | ||
271 | |||
272 | if (get_user(c, data + i)) { | ||
273 | mutex_unlock(&wdt->lock); | ||
274 | return -EFAULT; | ||
275 | } | ||
276 | if (c == 'V') { | ||
277 | wdt->flags |= TS72XX_WDT_EXPECT_CLOSE_FLAG; | ||
278 | break; | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | |||
283 | mutex_unlock(&wdt->lock); | ||
284 | return len; | ||
285 | } | ||
286 | |||
287 | static const struct watchdog_info winfo = { | ||
288 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | | ||
289 | WDIOF_MAGICCLOSE, | ||
290 | .firmware_version = 1, | ||
291 | .identity = "TS-72XX WDT", | ||
292 | }; | ||
293 | |||
294 | static long ts72xx_wdt_ioctl(struct file *file, unsigned int cmd, | ||
295 | unsigned long arg) | ||
296 | { | ||
297 | struct ts72xx_wdt *wdt = file->private_data; | ||
298 | void __user *argp = (void __user *)arg; | ||
299 | int __user *p = (int __user *)argp; | ||
300 | int error = 0; | ||
301 | |||
302 | if (mutex_lock_interruptible(&wdt->lock)) | ||
303 | return -ERESTARTSYS; | ||
304 | |||
305 | switch (cmd) { | ||
306 | case WDIOC_GETSUPPORT: | ||
307 | error = copy_to_user(argp, &winfo, sizeof(winfo)); | ||
308 | break; | ||
309 | |||
310 | case WDIOC_GETSTATUS: | ||
311 | case WDIOC_GETBOOTSTATUS: | ||
312 | return put_user(0, p); | ||
313 | |||
314 | case WDIOC_KEEPALIVE: | ||
315 | ts72xx_wdt_kick(wdt); | ||
316 | break; | ||
317 | |||
318 | case WDIOC_SETOPTIONS: { | ||
319 | int options; | ||
320 | |||
321 | if (get_user(options, p)) { | ||
322 | error = -EFAULT; | ||
323 | break; | ||
324 | } | ||
325 | |||
326 | error = -EINVAL; | ||
327 | |||
328 | if ((options & WDIOS_DISABLECARD) != 0) { | ||
329 | ts72xx_wdt_stop(wdt); | ||
330 | error = 0; | ||
331 | } | ||
332 | if ((options & WDIOS_ENABLECARD) != 0) { | ||
333 | ts72xx_wdt_start(wdt); | ||
334 | error = 0; | ||
335 | } | ||
336 | |||
337 | break; | ||
338 | } | ||
339 | |||
340 | case WDIOC_SETTIMEOUT: { | ||
341 | int new_timeout; | ||
342 | |||
343 | if (get_user(new_timeout, p)) { | ||
344 | error = -EFAULT; | ||
345 | } else { | ||
346 | int regval; | ||
347 | |||
348 | regval = timeout_to_regval(new_timeout); | ||
349 | if (regval < 0) { | ||
350 | error = -EINVAL; | ||
351 | } else { | ||
352 | ts72xx_wdt_stop(wdt); | ||
353 | wdt->regval = regval; | ||
354 | ts72xx_wdt_start(wdt); | ||
355 | } | ||
356 | } | ||
357 | if (error) | ||
358 | break; | ||
359 | |||
360 | /*FALLTHROUGH*/ | ||
361 | } | ||
362 | |||
363 | case WDIOC_GETTIMEOUT: | ||
364 | if (put_user(regval_to_timeout(wdt->regval), p)) | ||
365 | error = -EFAULT; | ||
366 | break; | ||
367 | |||
368 | default: | ||
369 | error = -ENOTTY; | ||
370 | break; | ||
371 | } | ||
372 | |||
373 | mutex_unlock(&wdt->lock); | ||
374 | return error; | ||
375 | } | ||
376 | |||
377 | static const struct file_operations ts72xx_wdt_fops = { | ||
378 | .owner = THIS_MODULE, | ||
379 | .llseek = no_llseek, | ||
380 | .open = ts72xx_wdt_open, | ||
381 | .release = ts72xx_wdt_release, | ||
382 | .write = ts72xx_wdt_write, | ||
383 | .unlocked_ioctl = ts72xx_wdt_ioctl, | ||
384 | }; | ||
385 | |||
386 | static struct miscdevice ts72xx_wdt_miscdev = { | ||
387 | .minor = WATCHDOG_MINOR, | ||
388 | .name = "watchdog", | ||
389 | .fops = &ts72xx_wdt_fops, | ||
390 | }; | ||
391 | |||
392 | static __devinit int ts72xx_wdt_probe(struct platform_device *pdev) | ||
393 | { | ||
394 | struct ts72xx_wdt *wdt; | ||
395 | struct resource *r1, *r2; | ||
396 | int error = 0; | ||
397 | |||
398 | wdt = kzalloc(sizeof(struct ts72xx_wdt), GFP_KERNEL); | ||
399 | if (!wdt) { | ||
400 | dev_err(&pdev->dev, "failed to allocate memory\n"); | ||
401 | return -ENOMEM; | ||
402 | } | ||
403 | |||
404 | r1 = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
405 | if (!r1) { | ||
406 | dev_err(&pdev->dev, "failed to get memory resource\n"); | ||
407 | error = -ENODEV; | ||
408 | goto fail; | ||
409 | } | ||
410 | |||
411 | r1 = request_mem_region(r1->start, resource_size(r1), pdev->name); | ||
412 | if (!r1) { | ||
413 | dev_err(&pdev->dev, "cannot request memory region\n"); | ||
414 | error = -EBUSY; | ||
415 | goto fail; | ||
416 | } | ||
417 | |||
418 | wdt->control_reg = ioremap(r1->start, resource_size(r1)); | ||
419 | if (!wdt->control_reg) { | ||
420 | dev_err(&pdev->dev, "failed to map memory\n"); | ||
421 | error = -ENODEV; | ||
422 | goto fail_free_control; | ||
423 | } | ||
424 | |||
425 | r2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
426 | if (!r2) { | ||
427 | dev_err(&pdev->dev, "failed to get memory resource\n"); | ||
428 | error = -ENODEV; | ||
429 | goto fail_unmap_control; | ||
430 | } | ||
431 | |||
432 | r2 = request_mem_region(r2->start, resource_size(r2), pdev->name); | ||
433 | if (!r2) { | ||
434 | dev_err(&pdev->dev, "cannot request memory region\n"); | ||
435 | error = -EBUSY; | ||
436 | goto fail_unmap_control; | ||
437 | } | ||
438 | |||
439 | wdt->feed_reg = ioremap(r2->start, resource_size(r2)); | ||
440 | if (!wdt->feed_reg) { | ||
441 | dev_err(&pdev->dev, "failed to map memory\n"); | ||
442 | error = -ENODEV; | ||
443 | goto fail_free_feed; | ||
444 | } | ||
445 | |||
446 | platform_set_drvdata(pdev, wdt); | ||
447 | ts72xx_wdt_pdev = pdev; | ||
448 | wdt->pdev = pdev; | ||
449 | mutex_init(&wdt->lock); | ||
450 | |||
451 | error = misc_register(&ts72xx_wdt_miscdev); | ||
452 | if (error) { | ||
453 | dev_err(&pdev->dev, "failed to register miscdev\n"); | ||
454 | goto fail_unmap_feed; | ||
455 | } | ||
456 | |||
457 | dev_info(&pdev->dev, "TS-72xx Watchdog driver\n"); | ||
458 | |||
459 | return 0; | ||
460 | |||
461 | fail_unmap_feed: | ||
462 | platform_set_drvdata(pdev, NULL); | ||
463 | iounmap(wdt->feed_reg); | ||
464 | fail_free_feed: | ||
465 | release_mem_region(r2->start, resource_size(r2)); | ||
466 | fail_unmap_control: | ||
467 | iounmap(wdt->control_reg); | ||
468 | fail_free_control: | ||
469 | release_mem_region(r1->start, resource_size(r1)); | ||
470 | fail: | ||
471 | kfree(wdt); | ||
472 | return error; | ||
473 | } | ||
474 | |||
475 | static __devexit int ts72xx_wdt_remove(struct platform_device *pdev) | ||
476 | { | ||
477 | struct ts72xx_wdt *wdt = platform_get_drvdata(pdev); | ||
478 | struct resource *res; | ||
479 | int error; | ||
480 | |||
481 | error = misc_deregister(&ts72xx_wdt_miscdev); | ||
482 | platform_set_drvdata(pdev, NULL); | ||
483 | |||
484 | iounmap(wdt->feed_reg); | ||
485 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
486 | release_mem_region(res->start, resource_size(res)); | ||
487 | |||
488 | iounmap(wdt->control_reg); | ||
489 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
490 | release_mem_region(res->start, resource_size(res)); | ||
491 | |||
492 | kfree(wdt); | ||
493 | return error; | ||
494 | } | ||
495 | |||
496 | static struct platform_driver ts72xx_wdt_driver = { | ||
497 | .probe = ts72xx_wdt_probe, | ||
498 | .remove = __devexit_p(ts72xx_wdt_remove), | ||
499 | .driver = { | ||
500 | .name = "ts72xx-wdt", | ||
501 | .owner = THIS_MODULE, | ||
502 | }, | ||
503 | }; | ||
504 | |||
505 | static __init int ts72xx_wdt_init(void) | ||
506 | { | ||
507 | return platform_driver_register(&ts72xx_wdt_driver); | ||
508 | } | ||
509 | module_init(ts72xx_wdt_init); | ||
510 | |||
511 | static __exit void ts72xx_wdt_exit(void) | ||
512 | { | ||
513 | platform_driver_unregister(&ts72xx_wdt_driver); | ||
514 | } | ||
515 | module_exit(ts72xx_wdt_exit); | ||
516 | |||
517 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>"); | ||
518 | MODULE_DESCRIPTION("TS-72xx SBC Watchdog"); | ||
519 | MODULE_LICENSE("GPL"); | ||
520 | MODULE_ALIAS("platform:ts72xx-wdt"); | ||
diff --git a/drivers/watchdog/txx9wdt.c b/drivers/watchdog/txx9wdt.c index d635566e9307..9e9ed7bfabcb 100644 --- a/drivers/watchdog/txx9wdt.c +++ b/drivers/watchdog/txx9wdt.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/miscdevice.h> | 13 | #include <linux/miscdevice.h> |
14 | #include <linux/watchdog.h> | 14 | #include <linux/watchdog.h> |
15 | #include <linux/fs.h> | 15 | #include <linux/fs.h> |
16 | #include <linux/reboot.h> | ||
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
18 | #include <linux/uaccess.h> | 17 | #include <linux/uaccess.h> |
19 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
@@ -166,14 +165,6 @@ static long txx9wdt_ioctl(struct file *file, unsigned int cmd, | |||
166 | } | 165 | } |
167 | } | 166 | } |
168 | 167 | ||
169 | static int txx9wdt_notify_sys(struct notifier_block *this, unsigned long code, | ||
170 | void *unused) | ||
171 | { | ||
172 | if (code == SYS_DOWN || code == SYS_HALT) | ||
173 | txx9wdt_stop(); | ||
174 | return NOTIFY_DONE; | ||
175 | } | ||
176 | |||
177 | static const struct file_operations txx9wdt_fops = { | 168 | static const struct file_operations txx9wdt_fops = { |
178 | .owner = THIS_MODULE, | 169 | .owner = THIS_MODULE, |
179 | .llseek = no_llseek, | 170 | .llseek = no_llseek, |
@@ -189,10 +180,6 @@ static struct miscdevice txx9wdt_miscdev = { | |||
189 | .fops = &txx9wdt_fops, | 180 | .fops = &txx9wdt_fops, |
190 | }; | 181 | }; |
191 | 182 | ||
192 | static struct notifier_block txx9wdt_notifier = { | ||
193 | .notifier_call = txx9wdt_notify_sys, | ||
194 | }; | ||
195 | |||
196 | static int __init txx9wdt_probe(struct platform_device *dev) | 183 | static int __init txx9wdt_probe(struct platform_device *dev) |
197 | { | 184 | { |
198 | struct resource *res; | 185 | struct resource *res; |
@@ -221,13 +208,8 @@ static int __init txx9wdt_probe(struct platform_device *dev) | |||
221 | if (!txx9wdt_reg) | 208 | if (!txx9wdt_reg) |
222 | goto exit_busy; | 209 | goto exit_busy; |
223 | 210 | ||
224 | ret = register_reboot_notifier(&txx9wdt_notifier); | ||
225 | if (ret) | ||
226 | goto exit; | ||
227 | |||
228 | ret = misc_register(&txx9wdt_miscdev); | 211 | ret = misc_register(&txx9wdt_miscdev); |
229 | if (ret) { | 212 | if (ret) { |
230 | unregister_reboot_notifier(&txx9wdt_notifier); | ||
231 | goto exit; | 213 | goto exit; |
232 | } | 214 | } |
233 | 215 | ||
@@ -249,14 +231,19 @@ exit: | |||
249 | static int __exit txx9wdt_remove(struct platform_device *dev) | 231 | static int __exit txx9wdt_remove(struct platform_device *dev) |
250 | { | 232 | { |
251 | misc_deregister(&txx9wdt_miscdev); | 233 | misc_deregister(&txx9wdt_miscdev); |
252 | unregister_reboot_notifier(&txx9wdt_notifier); | ||
253 | clk_disable(txx9_imclk); | 234 | clk_disable(txx9_imclk); |
254 | clk_put(txx9_imclk); | 235 | clk_put(txx9_imclk); |
255 | return 0; | 236 | return 0; |
256 | } | 237 | } |
257 | 238 | ||
239 | static void txx9wdt_shutdown(struct platform_device *dev) | ||
240 | { | ||
241 | txx9wdt_stop(); | ||
242 | } | ||
243 | |||
258 | static struct platform_driver txx9wdt_driver = { | 244 | static struct platform_driver txx9wdt_driver = { |
259 | .remove = __exit_p(txx9wdt_remove), | 245 | .remove = __exit_p(txx9wdt_remove), |
246 | .shutdown = txx9wdt_shutdown, | ||
260 | .driver = { | 247 | .driver = { |
261 | .name = "txx9wdt", | 248 | .name = "txx9wdt", |
262 | .owner = THIS_MODULE, | 249 | .owner = THIS_MODULE, |
diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c index f201accc4e3d..0f5288df0091 100644 --- a/drivers/watchdog/w83627hf_wdt.c +++ b/drivers/watchdog/w83627hf_wdt.c | |||
@@ -201,7 +201,7 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
201 | void __user *argp = (void __user *)arg; | 201 | void __user *argp = (void __user *)arg; |
202 | int __user *p = argp; | 202 | int __user *p = argp; |
203 | int new_timeout; | 203 | int new_timeout; |
204 | static struct watchdog_info ident = { | 204 | static const struct watchdog_info ident = { |
205 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | | 205 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | |
206 | WDIOF_MAGICCLOSE, | 206 | WDIOF_MAGICCLOSE, |
207 | .firmware_version = 1, | 207 | .firmware_version = 1, |
diff --git a/drivers/watchdog/w83977f_wdt.c b/drivers/watchdog/w83977f_wdt.c index 0560182a1d09..6e6743d1066f 100644 --- a/drivers/watchdog/w83977f_wdt.c +++ b/drivers/watchdog/w83977f_wdt.c | |||
@@ -371,7 +371,7 @@ static ssize_t wdt_write(struct file *file, const char __user *buf, | |||
371 | * according to their available features. | 371 | * according to their available features. |
372 | */ | 372 | */ |
373 | 373 | ||
374 | static struct watchdog_info ident = { | 374 | static const struct watchdog_info ident = { |
375 | .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, | 375 | .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, |
376 | .firmware_version = 1, | 376 | .firmware_version = 1, |
377 | .identity = WATCHDOG_NAME, | 377 | .identity = WATCHDOG_NAME, |
diff --git a/drivers/watchdog/wdrtas.c b/drivers/watchdog/wdrtas.c index 5bfb1f2c5319..94ec22b9e66b 100644 --- a/drivers/watchdog/wdrtas.c +++ b/drivers/watchdog/wdrtas.c | |||
@@ -312,7 +312,7 @@ static long wdrtas_ioctl(struct file *file, unsigned int cmd, | |||
312 | { | 312 | { |
313 | int __user *argp = (void __user *)arg; | 313 | int __user *argp = (void __user *)arg; |
314 | int i; | 314 | int i; |
315 | static struct watchdog_info wdinfo = { | 315 | static const struct watchdog_info wdinfo = { |
316 | .options = WDRTAS_SUPPORTED_MASK, | 316 | .options = WDRTAS_SUPPORTED_MASK, |
317 | .firmware_version = 0, | 317 | .firmware_version = 0, |
318 | .identity = "wdrtas", | 318 | .identity = "wdrtas", |
diff --git a/drivers/watchdog/wdt.c b/drivers/watchdog/wdt.c index 3bbefe9a2634..bfda2e99dd89 100644 --- a/drivers/watchdog/wdt.c +++ b/drivers/watchdog/wdt.c | |||
@@ -358,7 +358,7 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
358 | int new_heartbeat; | 358 | int new_heartbeat; |
359 | int status; | 359 | int status; |
360 | 360 | ||
361 | static struct watchdog_info ident = { | 361 | struct watchdog_info ident = { |
362 | .options = WDIOF_SETTIMEOUT| | 362 | .options = WDIOF_SETTIMEOUT| |
363 | WDIOF_MAGICCLOSE| | 363 | WDIOF_MAGICCLOSE| |
364 | WDIOF_KEEPALIVEPING, | 364 | WDIOF_KEEPALIVEPING, |
diff --git a/drivers/watchdog/wdt_pci.c b/drivers/watchdog/wdt_pci.c index f368dd87083a..7b22e3cdbc81 100644 --- a/drivers/watchdog/wdt_pci.c +++ b/drivers/watchdog/wdt_pci.c | |||
@@ -412,7 +412,7 @@ static long wdtpci_ioctl(struct file *file, unsigned int cmd, | |||
412 | int new_heartbeat; | 412 | int new_heartbeat; |
413 | int status; | 413 | int status; |
414 | 414 | ||
415 | static struct watchdog_info ident = { | 415 | struct watchdog_info ident = { |
416 | .options = WDIOF_SETTIMEOUT| | 416 | .options = WDIOF_SETTIMEOUT| |
417 | WDIOF_MAGICCLOSE| | 417 | WDIOF_MAGICCLOSE| |
418 | WDIOF_KEEPALIVEPING, | 418 | WDIOF_KEEPALIVEPING, |
diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c index 775bcd807f31..8c4b2d5bb7da 100644 --- a/drivers/watchdog/wm831x_wdt.c +++ b/drivers/watchdog/wm831x_wdt.c | |||
@@ -213,7 +213,7 @@ static ssize_t wm831x_wdt_write(struct file *file, | |||
213 | return count; | 213 | return count; |
214 | } | 214 | } |
215 | 215 | ||
216 | static struct watchdog_info ident = { | 216 | static const struct watchdog_info ident = { |
217 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | 217 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, |
218 | .identity = "WM831x Watchdog", | 218 | .identity = "WM831x Watchdog", |
219 | }; | 219 | }; |
diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c index a2d2e8eb2282..89dd7b035295 100644 --- a/drivers/watchdog/wm8350_wdt.c +++ b/drivers/watchdog/wm8350_wdt.c | |||
@@ -177,7 +177,7 @@ static ssize_t wm8350_wdt_write(struct file *file, | |||
177 | return count; | 177 | return count; |
178 | } | 178 | } |
179 | 179 | ||
180 | static struct watchdog_info ident = { | 180 | static const struct watchdog_info ident = { |
181 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | 181 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, |
182 | .identity = "WM8350 Watchdog", | 182 | .identity = "WM8350 Watchdog", |
183 | }; | 183 | }; |
diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c index ae5cb05a1a1c..bb71ab2336c8 100644 --- a/drivers/xen/sys-hypervisor.c +++ b/drivers/xen/sys-hypervisor.c | |||
@@ -426,7 +426,7 @@ static ssize_t hyp_sysfs_store(struct kobject *kobj, | |||
426 | return 0; | 426 | return 0; |
427 | } | 427 | } |
428 | 428 | ||
429 | static struct sysfs_ops hyp_sysfs_ops = { | 429 | static const struct sysfs_ops hyp_sysfs_ops = { |
430 | .show = hyp_sysfs_show, | 430 | .show = hyp_sysfs_show, |
431 | .store = hyp_sysfs_store, | 431 | .store = hyp_sysfs_store, |
432 | }; | 432 | }; |