diff options
Diffstat (limited to 'drivers')
317 files changed, 6683 insertions, 4473 deletions
diff --git a/drivers/Makefile b/drivers/Makefile index d2dc01cc73e7..cfe38ffff28a 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -76,6 +76,7 @@ obj-$(CONFIG_MCA) += mca/ | |||
76 | obj-$(CONFIG_EISA) += eisa/ | 76 | obj-$(CONFIG_EISA) += eisa/ |
77 | obj-$(CONFIG_LGUEST_GUEST) += lguest/ | 77 | obj-$(CONFIG_LGUEST_GUEST) += lguest/ |
78 | obj-$(CONFIG_CPU_FREQ) += cpufreq/ | 78 | obj-$(CONFIG_CPU_FREQ) += cpufreq/ |
79 | obj-$(CONFIG_CPU_IDLE) += cpuidle/ | ||
79 | obj-$(CONFIG_MMC) += mmc/ | 80 | obj-$(CONFIG_MMC) += mmc/ |
80 | obj-$(CONFIG_NEW_LEDS) += leds/ | 81 | obj-$(CONFIG_NEW_LEDS) += leds/ |
81 | obj-$(CONFIG_INFINIBAND) += infiniband/ | 82 | obj-$(CONFIG_INFINIBAND) += infiniband/ |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 4875f0149eb4..b83389145f28 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -88,7 +88,7 @@ config ACPI_PROC_EVENT | |||
88 | 88 | ||
89 | config ACPI_AC | 89 | config ACPI_AC |
90 | tristate "AC Adapter" | 90 | tristate "AC Adapter" |
91 | depends on X86 | 91 | depends on X86 && POWER_SUPPLY |
92 | default y | 92 | default y |
93 | help | 93 | help |
94 | This driver adds support for the AC Adapter object, which indicates | 94 | This driver adds support for the AC Adapter object, which indicates |
@@ -97,7 +97,7 @@ config ACPI_AC | |||
97 | 97 | ||
98 | config ACPI_BATTERY | 98 | config ACPI_BATTERY |
99 | tristate "Battery" | 99 | tristate "Battery" |
100 | depends on X86 | 100 | depends on X86 && POWER_SUPPLY |
101 | default y | 101 | default y |
102 | help | 102 | help |
103 | This driver adds support for battery information through | 103 | This driver adds support for battery information through |
@@ -117,6 +117,7 @@ config ACPI_BUTTON | |||
117 | config ACPI_VIDEO | 117 | config ACPI_VIDEO |
118 | tristate "Video" | 118 | tristate "Video" |
119 | depends on X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL | 119 | depends on X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL |
120 | depends on INPUT | ||
120 | help | 121 | help |
121 | This driver implement the ACPI Extensions For Display Adapters | 122 | This driver implement the ACPI Extensions For Display Adapters |
122 | for integrated graphics devices on motherboard, as specified in | 123 | for integrated graphics devices on motherboard, as specified in |
@@ -349,12 +350,11 @@ config ACPI_HOTPLUG_MEMORY | |||
349 | $>modprobe acpi_memhotplug | 350 | $>modprobe acpi_memhotplug |
350 | 351 | ||
351 | config ACPI_SBS | 352 | config ACPI_SBS |
352 | tristate "Smart Battery System (EXPERIMENTAL)" | 353 | tristate "Smart Battery System" |
353 | depends on X86 | 354 | depends on X86 |
354 | depends on EXPERIMENTAL | 355 | depends on POWER_SUPPLY |
355 | help | 356 | help |
356 | This driver adds support for the Smart Battery System. | 357 | This driver adds support for the Smart Battery System, another |
357 | A "Smart Battery" is quite old and quite rare compared | 358 | type of access to battery information, found on some laptops. |
358 | to today's ACPI "Control Method" battery. | ||
359 | 359 | ||
360 | endif # ACPI | 360 | endif # ACPI |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index d4336f1730e9..54e3ab0e5fc0 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -60,3 +60,4 @@ obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o | |||
60 | obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o | 60 | obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o |
61 | obj-y += cm_sbs.o | 61 | obj-y += cm_sbs.o |
62 | obj-$(CONFIG_ACPI_SBS) += sbs.o | 62 | obj-$(CONFIG_ACPI_SBS) += sbs.o |
63 | obj-$(CONFIG_ACPI_SBS) += sbshc.o | ||
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 26d70702b313..e03de37a750d 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
31 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
32 | #include <linux/power_supply.h> | ||
32 | #include <acpi/acpi_bus.h> | 33 | #include <acpi/acpi_bus.h> |
33 | #include <acpi/acpi_drivers.h> | 34 | #include <acpi/acpi_drivers.h> |
34 | 35 | ||
@@ -72,16 +73,37 @@ static struct acpi_driver acpi_ac_driver = { | |||
72 | }; | 73 | }; |
73 | 74 | ||
74 | struct acpi_ac { | 75 | struct acpi_ac { |
76 | struct power_supply charger; | ||
75 | struct acpi_device * device; | 77 | struct acpi_device * device; |
76 | unsigned long state; | 78 | unsigned long state; |
77 | }; | 79 | }; |
78 | 80 | ||
81 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); | ||
82 | |||
79 | static const struct file_operations acpi_ac_fops = { | 83 | static const struct file_operations acpi_ac_fops = { |
80 | .open = acpi_ac_open_fs, | 84 | .open = acpi_ac_open_fs, |
81 | .read = seq_read, | 85 | .read = seq_read, |
82 | .llseek = seq_lseek, | 86 | .llseek = seq_lseek, |
83 | .release = single_release, | 87 | .release = single_release, |
84 | }; | 88 | }; |
89 | static int get_ac_property(struct power_supply *psy, | ||
90 | enum power_supply_property psp, | ||
91 | union power_supply_propval *val) | ||
92 | { | ||
93 | struct acpi_ac *ac = to_acpi_ac(psy); | ||
94 | switch (psp) { | ||
95 | case POWER_SUPPLY_PROP_ONLINE: | ||
96 | val->intval = ac->state; | ||
97 | break; | ||
98 | default: | ||
99 | return -EINVAL; | ||
100 | } | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static enum power_supply_property ac_props[] = { | ||
105 | POWER_SUPPLY_PROP_ONLINE, | ||
106 | }; | ||
85 | 107 | ||
86 | /* -------------------------------------------------------------------------- | 108 | /* -------------------------------------------------------------------------- |
87 | AC Adapter Management | 109 | AC Adapter Management |
@@ -208,6 +230,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) | |||
208 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 230 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
209 | device->dev.bus_id, event, | 231 | device->dev.bus_id, event, |
210 | (u32) ac->state); | 232 | (u32) ac->state); |
233 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); | ||
211 | break; | 234 | break; |
212 | default: | 235 | default: |
213 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 236 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
@@ -244,7 +267,12 @@ static int acpi_ac_add(struct acpi_device *device) | |||
244 | result = acpi_ac_add_fs(device); | 267 | result = acpi_ac_add_fs(device); |
245 | if (result) | 268 | if (result) |
246 | goto end; | 269 | goto end; |
247 | 270 | ac->charger.name = acpi_device_bid(device); | |
271 | ac->charger.type = POWER_SUPPLY_TYPE_MAINS; | ||
272 | ac->charger.properties = ac_props; | ||
273 | ac->charger.num_properties = ARRAY_SIZE(ac_props); | ||
274 | ac->charger.get_property = get_ac_property; | ||
275 | power_supply_register(&ac->device->dev, &ac->charger); | ||
248 | status = acpi_install_notify_handler(device->handle, | 276 | status = acpi_install_notify_handler(device->handle, |
249 | ACPI_ALL_NOTIFY, acpi_ac_notify, | 277 | ACPI_ALL_NOTIFY, acpi_ac_notify, |
250 | ac); | 278 | ac); |
@@ -279,7 +307,8 @@ static int acpi_ac_remove(struct acpi_device *device, int type) | |||
279 | 307 | ||
280 | status = acpi_remove_notify_handler(device->handle, | 308 | status = acpi_remove_notify_handler(device->handle, |
281 | ACPI_ALL_NOTIFY, acpi_ac_notify); | 309 | ACPI_ALL_NOTIFY, acpi_ac_notify); |
282 | 310 | if (ac->charger.dev) | |
311 | power_supply_unregister(&ac->charger); | ||
283 | acpi_ac_remove_fs(device); | 312 | acpi_ac_remove_fs(device); |
284 | 313 | ||
285 | kfree(ac); | 314 | kfree(ac); |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9b2c0f74f869..681e26b56b11 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -1,6 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * acpi_battery.c - ACPI Battery Driver ($Revision: 37 $) | 2 | * battery.c - ACPI Battery Driver (Revision: 2.0) |
3 | * | 3 | * |
4 | * Copyright (C) 2007 Alexey Starikovskiy <astarikovskiy@suse.de> | ||
5 | * Copyright (C) 2004-2007 Vladimir Lebedev <vladimir.p.lebedev@intel.com> | ||
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | 6 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | 7 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
6 | * | 8 | * |
@@ -27,244 +29,288 @@ | |||
27 | #include <linux/module.h> | 29 | #include <linux/module.h> |
28 | #include <linux/init.h> | 30 | #include <linux/init.h> |
29 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/jiffies.h> | ||
33 | |||
34 | #ifdef CONFIG_ACPI_PROCFS | ||
30 | #include <linux/proc_fs.h> | 35 | #include <linux/proc_fs.h> |
31 | #include <linux/seq_file.h> | 36 | #include <linux/seq_file.h> |
32 | #include <asm/uaccess.h> | 37 | #include <asm/uaccess.h> |
38 | #endif | ||
33 | 39 | ||
34 | #include <acpi/acpi_bus.h> | 40 | #include <acpi/acpi_bus.h> |
35 | #include <acpi/acpi_drivers.h> | 41 | #include <acpi/acpi_drivers.h> |
36 | 42 | ||
37 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF | 43 | #include <linux/power_supply.h> |
38 | 44 | ||
39 | #define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS" | 45 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF |
40 | #define ACPI_BATTERY_FORMAT_BST "NNNN" | ||
41 | 46 | ||
42 | #define ACPI_BATTERY_COMPONENT 0x00040000 | 47 | #define ACPI_BATTERY_COMPONENT 0x00040000 |
43 | #define ACPI_BATTERY_CLASS "battery" | 48 | #define ACPI_BATTERY_CLASS "battery" |
44 | #define ACPI_BATTERY_DEVICE_NAME "Battery" | 49 | #define ACPI_BATTERY_DEVICE_NAME "Battery" |
45 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 | 50 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 |
46 | #define ACPI_BATTERY_NOTIFY_INFO 0x81 | 51 | #define ACPI_BATTERY_NOTIFY_INFO 0x81 |
47 | #define ACPI_BATTERY_UNITS_WATTS "mW" | ||
48 | #define ACPI_BATTERY_UNITS_AMPS "mA" | ||
49 | 52 | ||
50 | #define _COMPONENT ACPI_BATTERY_COMPONENT | 53 | #define _COMPONENT ACPI_BATTERY_COMPONENT |
51 | 54 | ||
52 | #define ACPI_BATTERY_UPDATE_TIME 0 | ||
53 | |||
54 | #define ACPI_BATTERY_NONE_UPDATE 0 | ||
55 | #define ACPI_BATTERY_EASY_UPDATE 1 | ||
56 | #define ACPI_BATTERY_INIT_UPDATE 2 | ||
57 | |||
58 | ACPI_MODULE_NAME("battery"); | 55 | ACPI_MODULE_NAME("battery"); |
59 | 56 | ||
60 | MODULE_AUTHOR("Paul Diefenbaugh"); | 57 | MODULE_AUTHOR("Paul Diefenbaugh"); |
58 | MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>"); | ||
61 | MODULE_DESCRIPTION("ACPI Battery Driver"); | 59 | MODULE_DESCRIPTION("ACPI Battery Driver"); |
62 | MODULE_LICENSE("GPL"); | 60 | MODULE_LICENSE("GPL"); |
63 | 61 | ||
64 | static unsigned int update_time = ACPI_BATTERY_UPDATE_TIME; | 62 | static unsigned int cache_time = 1000; |
65 | 63 | module_param(cache_time, uint, 0644); | |
66 | /* 0 - every time, > 0 - by update_time */ | 64 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); |
67 | module_param(update_time, uint, 0644); | ||
68 | 65 | ||
66 | #ifdef CONFIG_ACPI_PROCFS | ||
69 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); | 67 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); |
70 | extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); | 68 | extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); |
71 | 69 | ||
72 | static int acpi_battery_add(struct acpi_device *device); | 70 | enum acpi_battery_files { |
73 | static int acpi_battery_remove(struct acpi_device *device, int type); | 71 | info_tag = 0, |
74 | static int acpi_battery_resume(struct acpi_device *device); | 72 | state_tag, |
73 | alarm_tag, | ||
74 | ACPI_BATTERY_NUMFILES, | ||
75 | }; | ||
76 | |||
77 | #endif | ||
75 | 78 | ||
76 | static const struct acpi_device_id battery_device_ids[] = { | 79 | static const struct acpi_device_id battery_device_ids[] = { |
77 | {"PNP0C0A", 0}, | 80 | {"PNP0C0A", 0}, |
78 | {"", 0}, | 81 | {"", 0}, |
79 | }; | 82 | }; |
80 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); | ||
81 | |||
82 | static struct acpi_driver acpi_battery_driver = { | ||
83 | .name = "battery", | ||
84 | .class = ACPI_BATTERY_CLASS, | ||
85 | .ids = battery_device_ids, | ||
86 | .ops = { | ||
87 | .add = acpi_battery_add, | ||
88 | .resume = acpi_battery_resume, | ||
89 | .remove = acpi_battery_remove, | ||
90 | }, | ||
91 | }; | ||
92 | 83 | ||
93 | struct acpi_battery_state { | 84 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); |
94 | acpi_integer state; | ||
95 | acpi_integer present_rate; | ||
96 | acpi_integer remaining_capacity; | ||
97 | acpi_integer present_voltage; | ||
98 | }; | ||
99 | |||
100 | struct acpi_battery_info { | ||
101 | acpi_integer power_unit; | ||
102 | acpi_integer design_capacity; | ||
103 | acpi_integer last_full_capacity; | ||
104 | acpi_integer battery_technology; | ||
105 | acpi_integer design_voltage; | ||
106 | acpi_integer design_capacity_warning; | ||
107 | acpi_integer design_capacity_low; | ||
108 | acpi_integer battery_capacity_granularity_1; | ||
109 | acpi_integer battery_capacity_granularity_2; | ||
110 | acpi_string model_number; | ||
111 | acpi_string serial_number; | ||
112 | acpi_string battery_type; | ||
113 | acpi_string oem_info; | ||
114 | }; | ||
115 | |||
116 | enum acpi_battery_files{ | ||
117 | ACPI_BATTERY_INFO = 0, | ||
118 | ACPI_BATTERY_STATE, | ||
119 | ACPI_BATTERY_ALARM, | ||
120 | ACPI_BATTERY_NUMFILES, | ||
121 | }; | ||
122 | 85 | ||
123 | struct acpi_battery_flags { | ||
124 | u8 battery_present_prev; | ||
125 | u8 alarm_present; | ||
126 | u8 init_update; | ||
127 | u8 update[ACPI_BATTERY_NUMFILES]; | ||
128 | u8 power_unit; | ||
129 | }; | ||
130 | 86 | ||
131 | struct acpi_battery { | 87 | struct acpi_battery { |
132 | struct mutex mutex; | 88 | struct mutex lock; |
89 | struct power_supply bat; | ||
133 | struct acpi_device *device; | 90 | struct acpi_device *device; |
134 | struct acpi_battery_flags flags; | 91 | unsigned long update_time; |
135 | struct acpi_buffer bif_data; | 92 | int current_now; |
136 | struct acpi_buffer bst_data; | 93 | int capacity_now; |
137 | unsigned long alarm; | 94 | int voltage_now; |
138 | unsigned long update_time[ACPI_BATTERY_NUMFILES]; | 95 | int design_capacity; |
96 | int full_charge_capacity; | ||
97 | int technology; | ||
98 | int design_voltage; | ||
99 | int design_capacity_warning; | ||
100 | int design_capacity_low; | ||
101 | int capacity_granularity_1; | ||
102 | int capacity_granularity_2; | ||
103 | int alarm; | ||
104 | char model_number[32]; | ||
105 | char serial_number[32]; | ||
106 | char type[32]; | ||
107 | char oem_info[32]; | ||
108 | int state; | ||
109 | int power_unit; | ||
110 | u8 alarm_present; | ||
139 | }; | 111 | }; |
140 | 112 | ||
113 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | ||
114 | |||
141 | inline int acpi_battery_present(struct acpi_battery *battery) | 115 | inline int acpi_battery_present(struct acpi_battery *battery) |
142 | { | 116 | { |
143 | return battery->device->status.battery_present; | 117 | return battery->device->status.battery_present; |
144 | } | 118 | } |
145 | inline char *acpi_battery_power_units(struct acpi_battery *battery) | ||
146 | { | ||
147 | if (battery->flags.power_unit) | ||
148 | return ACPI_BATTERY_UNITS_AMPS; | ||
149 | else | ||
150 | return ACPI_BATTERY_UNITS_WATTS; | ||
151 | } | ||
152 | 119 | ||
153 | inline acpi_handle acpi_battery_handle(struct acpi_battery *battery) | 120 | static int acpi_battery_technology(struct acpi_battery *battery) |
154 | { | 121 | { |
155 | return battery->device->handle; | 122 | if (!strcasecmp("NiCd", battery->type)) |
123 | return POWER_SUPPLY_TECHNOLOGY_NiCd; | ||
124 | if (!strcasecmp("NiMH", battery->type)) | ||
125 | return POWER_SUPPLY_TECHNOLOGY_NiMH; | ||
126 | if (!strcasecmp("LION", battery->type)) | ||
127 | return POWER_SUPPLY_TECHNOLOGY_LION; | ||
128 | if (!strcasecmp("LiP", battery->type)) | ||
129 | return POWER_SUPPLY_TECHNOLOGY_LIPO; | ||
130 | return POWER_SUPPLY_TECHNOLOGY_UNKNOWN; | ||
156 | } | 131 | } |
157 | 132 | ||
158 | /* -------------------------------------------------------------------------- | 133 | static int acpi_battery_get_property(struct power_supply *psy, |
159 | Battery Management | 134 | enum power_supply_property psp, |
160 | -------------------------------------------------------------------------- */ | 135 | union power_supply_propval *val) |
161 | |||
162 | static void acpi_battery_check_result(struct acpi_battery *battery, int result) | ||
163 | { | 136 | { |
164 | if (!battery) | 137 | struct acpi_battery *battery = to_acpi_battery(psy); |
165 | return; | ||
166 | 138 | ||
167 | if (result) { | 139 | if ((!acpi_battery_present(battery)) && |
168 | battery->flags.init_update = 1; | 140 | psp != POWER_SUPPLY_PROP_PRESENT) |
141 | return -ENODEV; | ||
142 | switch (psp) { | ||
143 | case POWER_SUPPLY_PROP_STATUS: | ||
144 | if (battery->state & 0x01) | ||
145 | val->intval = POWER_SUPPLY_STATUS_DISCHARGING; | ||
146 | else if (battery->state & 0x02) | ||
147 | val->intval = POWER_SUPPLY_STATUS_CHARGING; | ||
148 | else if (battery->state == 0) | ||
149 | val->intval = POWER_SUPPLY_STATUS_FULL; | ||
150 | break; | ||
151 | case POWER_SUPPLY_PROP_PRESENT: | ||
152 | val->intval = acpi_battery_present(battery); | ||
153 | break; | ||
154 | case POWER_SUPPLY_PROP_TECHNOLOGY: | ||
155 | val->intval = acpi_battery_technology(battery); | ||
156 | break; | ||
157 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | ||
158 | val->intval = battery->design_voltage * 1000; | ||
159 | break; | ||
160 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: | ||
161 | val->intval = battery->voltage_now * 1000; | ||
162 | break; | ||
163 | case POWER_SUPPLY_PROP_CURRENT_NOW: | ||
164 | val->intval = battery->current_now * 1000; | ||
165 | break; | ||
166 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: | ||
167 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: | ||
168 | val->intval = battery->design_capacity * 1000; | ||
169 | break; | ||
170 | case POWER_SUPPLY_PROP_CHARGE_FULL: | ||
171 | case POWER_SUPPLY_PROP_ENERGY_FULL: | ||
172 | val->intval = battery->full_charge_capacity * 1000; | ||
173 | break; | ||
174 | case POWER_SUPPLY_PROP_CHARGE_NOW: | ||
175 | case POWER_SUPPLY_PROP_ENERGY_NOW: | ||
176 | val->intval = battery->capacity_now * 1000; | ||
177 | break; | ||
178 | case POWER_SUPPLY_PROP_MODEL_NAME: | ||
179 | val->strval = battery->model_number; | ||
180 | break; | ||
181 | case POWER_SUPPLY_PROP_MANUFACTURER: | ||
182 | val->strval = battery->oem_info; | ||
183 | break; | ||
184 | default: | ||
185 | return -EINVAL; | ||
169 | } | 186 | } |
187 | return 0; | ||
170 | } | 188 | } |
171 | 189 | ||
172 | static int acpi_battery_extract_package(struct acpi_battery *battery, | 190 | static enum power_supply_property charge_battery_props[] = { |
173 | union acpi_object *package, | 191 | POWER_SUPPLY_PROP_STATUS, |
174 | struct acpi_buffer *format, | 192 | POWER_SUPPLY_PROP_PRESENT, |
175 | struct acpi_buffer *data, | 193 | POWER_SUPPLY_PROP_TECHNOLOGY, |
176 | char *package_name) | 194 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
195 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | ||
196 | POWER_SUPPLY_PROP_CURRENT_NOW, | ||
197 | POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, | ||
198 | POWER_SUPPLY_PROP_CHARGE_FULL, | ||
199 | POWER_SUPPLY_PROP_CHARGE_NOW, | ||
200 | POWER_SUPPLY_PROP_MODEL_NAME, | ||
201 | POWER_SUPPLY_PROP_MANUFACTURER, | ||
202 | }; | ||
203 | |||
204 | static enum power_supply_property energy_battery_props[] = { | ||
205 | POWER_SUPPLY_PROP_STATUS, | ||
206 | POWER_SUPPLY_PROP_PRESENT, | ||
207 | POWER_SUPPLY_PROP_TECHNOLOGY, | ||
208 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | ||
209 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | ||
210 | POWER_SUPPLY_PROP_CURRENT_NOW, | ||
211 | POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, | ||
212 | POWER_SUPPLY_PROP_ENERGY_FULL, | ||
213 | POWER_SUPPLY_PROP_ENERGY_NOW, | ||
214 | POWER_SUPPLY_PROP_MODEL_NAME, | ||
215 | POWER_SUPPLY_PROP_MANUFACTURER, | ||
216 | }; | ||
217 | |||
218 | #ifdef CONFIG_ACPI_PROCFS | ||
219 | inline char *acpi_battery_units(struct acpi_battery *battery) | ||
177 | { | 220 | { |
178 | acpi_status status = AE_OK; | 221 | return (battery->power_unit)?"mA":"mW"; |
179 | struct acpi_buffer data_null = { 0, NULL }; | 222 | } |
223 | #endif | ||
180 | 224 | ||
181 | status = acpi_extract_package(package, format, &data_null); | 225 | /* -------------------------------------------------------------------------- |
182 | if (status != AE_BUFFER_OVERFLOW) { | 226 | Battery Management |
183 | ACPI_EXCEPTION((AE_INFO, status, "Extracting size %s", | 227 | -------------------------------------------------------------------------- */ |
184 | package_name)); | 228 | struct acpi_offsets { |
185 | return -ENODEV; | 229 | size_t offset; /* offset inside struct acpi_sbs_battery */ |
186 | } | 230 | u8 mode; /* int or string? */ |
231 | }; | ||
187 | 232 | ||
188 | if (data_null.length != data->length) { | 233 | static struct acpi_offsets state_offsets[] = { |
189 | kfree(data->pointer); | 234 | {offsetof(struct acpi_battery, state), 0}, |
190 | data->pointer = kzalloc(data_null.length, GFP_KERNEL); | 235 | {offsetof(struct acpi_battery, current_now), 0}, |
191 | if (!data->pointer) { | 236 | {offsetof(struct acpi_battery, capacity_now), 0}, |
192 | ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, "kzalloc()")); | 237 | {offsetof(struct acpi_battery, voltage_now), 0}, |
193 | return -ENOMEM; | 238 | }; |
194 | } | ||
195 | data->length = data_null.length; | ||
196 | } | ||
197 | 239 | ||
198 | status = acpi_extract_package(package, format, data); | 240 | static struct acpi_offsets info_offsets[] = { |
199 | if (ACPI_FAILURE(status)) { | 241 | {offsetof(struct acpi_battery, power_unit), 0}, |
200 | ACPI_EXCEPTION((AE_INFO, status, "Extracting %s", | 242 | {offsetof(struct acpi_battery, design_capacity), 0}, |
201 | package_name)); | 243 | {offsetof(struct acpi_battery, full_charge_capacity), 0}, |
202 | return -ENODEV; | 244 | {offsetof(struct acpi_battery, technology), 0}, |
203 | } | 245 | {offsetof(struct acpi_battery, design_voltage), 0}, |
246 | {offsetof(struct acpi_battery, design_capacity_warning), 0}, | ||
247 | {offsetof(struct acpi_battery, design_capacity_low), 0}, | ||
248 | {offsetof(struct acpi_battery, capacity_granularity_1), 0}, | ||
249 | {offsetof(struct acpi_battery, capacity_granularity_2), 0}, | ||
250 | {offsetof(struct acpi_battery, model_number), 1}, | ||
251 | {offsetof(struct acpi_battery, serial_number), 1}, | ||
252 | {offsetof(struct acpi_battery, type), 1}, | ||
253 | {offsetof(struct acpi_battery, oem_info), 1}, | ||
254 | }; | ||
204 | 255 | ||
256 | static int extract_package(struct acpi_battery *battery, | ||
257 | union acpi_object *package, | ||
258 | struct acpi_offsets *offsets, int num) | ||
259 | { | ||
260 | int i, *x; | ||
261 | union acpi_object *element; | ||
262 | if (package->type != ACPI_TYPE_PACKAGE) | ||
263 | return -EFAULT; | ||
264 | for (i = 0; i < num; ++i) { | ||
265 | if (package->package.count <= i) | ||
266 | return -EFAULT; | ||
267 | element = &package->package.elements[i]; | ||
268 | if (offsets[i].mode) { | ||
269 | if (element->type != ACPI_TYPE_STRING && | ||
270 | element->type != ACPI_TYPE_BUFFER) | ||
271 | return -EFAULT; | ||
272 | strncpy((u8 *)battery + offsets[i].offset, | ||
273 | element->string.pointer, 32); | ||
274 | } else { | ||
275 | if (element->type != ACPI_TYPE_INTEGER) | ||
276 | return -EFAULT; | ||
277 | x = (int *)((u8 *)battery + offsets[i].offset); | ||
278 | *x = element->integer.value; | ||
279 | } | ||
280 | } | ||
205 | return 0; | 281 | return 0; |
206 | } | 282 | } |
207 | 283 | ||
208 | static int acpi_battery_get_status(struct acpi_battery *battery) | 284 | static int acpi_battery_get_status(struct acpi_battery *battery) |
209 | { | 285 | { |
210 | int result = 0; | 286 | if (acpi_bus_get_status(battery->device)) { |
211 | |||
212 | result = acpi_bus_get_status(battery->device); | ||
213 | if (result) { | ||
214 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Evaluating _STA")); | 287 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Evaluating _STA")); |
215 | return -ENODEV; | 288 | return -ENODEV; |
216 | } | 289 | } |
217 | return result; | 290 | return 0; |
218 | } | 291 | } |
219 | 292 | ||
220 | static int acpi_battery_get_info(struct acpi_battery *battery) | 293 | static int acpi_battery_get_info(struct acpi_battery *battery) |
221 | { | 294 | { |
222 | int result = 0; | 295 | int result = -EFAULT; |
223 | acpi_status status = 0; | 296 | acpi_status status = 0; |
224 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 297 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
225 | struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF), | ||
226 | ACPI_BATTERY_FORMAT_BIF | ||
227 | }; | ||
228 | union acpi_object *package = NULL; | ||
229 | struct acpi_buffer *data = NULL; | ||
230 | struct acpi_battery_info *bif = NULL; | ||
231 | |||
232 | battery->update_time[ACPI_BATTERY_INFO] = get_seconds(); | ||
233 | 298 | ||
234 | if (!acpi_battery_present(battery)) | 299 | if (!acpi_battery_present(battery)) |
235 | return 0; | 300 | return 0; |
301 | mutex_lock(&battery->lock); | ||
302 | status = acpi_evaluate_object(battery->device->handle, "_BIF", | ||
303 | NULL, &buffer); | ||
304 | mutex_unlock(&battery->lock); | ||
236 | 305 | ||
237 | /* Evaluate _BIF */ | ||
238 | |||
239 | status = | ||
240 | acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL, | ||
241 | &buffer); | ||
242 | if (ACPI_FAILURE(status)) { | 306 | if (ACPI_FAILURE(status)) { |
243 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); | 307 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); |
244 | return -ENODEV; | 308 | return -ENODEV; |
245 | } | 309 | } |
246 | 310 | ||
247 | package = buffer.pointer; | 311 | result = extract_package(battery, buffer.pointer, |
248 | 312 | info_offsets, ARRAY_SIZE(info_offsets)); | |
249 | data = &battery->bif_data; | ||
250 | |||
251 | /* Extract Package Data */ | ||
252 | |||
253 | result = | ||
254 | acpi_battery_extract_package(battery, package, &format, data, | ||
255 | "_BIF"); | ||
256 | if (result) | ||
257 | goto end; | ||
258 | |||
259 | end: | ||
260 | |||
261 | kfree(buffer.pointer); | 313 | kfree(buffer.pointer); |
262 | |||
263 | if (!result) { | ||
264 | bif = data->pointer; | ||
265 | battery->flags.power_unit = bif->power_unit; | ||
266 | } | ||
267 | |||
268 | return result; | 314 | return result; |
269 | } | 315 | } |
270 | 316 | ||
@@ -273,342 +319,203 @@ static int acpi_battery_get_state(struct acpi_battery *battery) | |||
273 | int result = 0; | 319 | int result = 0; |
274 | acpi_status status = 0; | 320 | acpi_status status = 0; |
275 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 321 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
276 | struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST), | ||
277 | ACPI_BATTERY_FORMAT_BST | ||
278 | }; | ||
279 | union acpi_object *package = NULL; | ||
280 | struct acpi_buffer *data = NULL; | ||
281 | |||
282 | battery->update_time[ACPI_BATTERY_STATE] = get_seconds(); | ||
283 | 322 | ||
284 | if (!acpi_battery_present(battery)) | 323 | if (!acpi_battery_present(battery)) |
285 | return 0; | 324 | return 0; |
286 | 325 | ||
287 | /* Evaluate _BST */ | 326 | if (battery->update_time && |
327 | time_before(jiffies, battery->update_time + | ||
328 | msecs_to_jiffies(cache_time))) | ||
329 | return 0; | ||
330 | |||
331 | mutex_lock(&battery->lock); | ||
332 | status = acpi_evaluate_object(battery->device->handle, "_BST", | ||
333 | NULL, &buffer); | ||
334 | mutex_unlock(&battery->lock); | ||
288 | 335 | ||
289 | status = | ||
290 | acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL, | ||
291 | &buffer); | ||
292 | if (ACPI_FAILURE(status)) { | 336 | if (ACPI_FAILURE(status)) { |
293 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); | 337 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); |
294 | return -ENODEV; | 338 | return -ENODEV; |
295 | } | 339 | } |
296 | 340 | ||
297 | package = buffer.pointer; | 341 | result = extract_package(battery, buffer.pointer, |
298 | 342 | state_offsets, ARRAY_SIZE(state_offsets)); | |
299 | data = &battery->bst_data; | 343 | battery->update_time = jiffies; |
300 | |||
301 | /* Extract Package Data */ | ||
302 | |||
303 | result = | ||
304 | acpi_battery_extract_package(battery, package, &format, data, | ||
305 | "_BST"); | ||
306 | if (result) | ||
307 | goto end; | ||
308 | |||
309 | end: | ||
310 | kfree(buffer.pointer); | 344 | kfree(buffer.pointer); |
311 | |||
312 | return result; | 345 | return result; |
313 | } | 346 | } |
314 | 347 | ||
315 | static int acpi_battery_get_alarm(struct acpi_battery *battery) | 348 | static int acpi_battery_set_alarm(struct acpi_battery *battery) |
316 | { | ||
317 | battery->update_time[ACPI_BATTERY_ALARM] = get_seconds(); | ||
318 | |||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | static int acpi_battery_set_alarm(struct acpi_battery *battery, | ||
323 | unsigned long alarm) | ||
324 | { | 349 | { |
325 | acpi_status status = 0; | 350 | acpi_status status = 0; |
326 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | 351 | union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; |
327 | struct acpi_object_list arg_list = { 1, &arg0 }; | 352 | struct acpi_object_list arg_list = { 1, &arg0 }; |
328 | 353 | ||
329 | battery->update_time[ACPI_BATTERY_ALARM] = get_seconds(); | 354 | if (!acpi_battery_present(battery)|| !battery->alarm_present) |
330 | |||
331 | if (!acpi_battery_present(battery)) | ||
332 | return -ENODEV; | 355 | return -ENODEV; |
333 | 356 | ||
334 | if (!battery->flags.alarm_present) | 357 | arg0.integer.value = battery->alarm; |
335 | return -ENODEV; | ||
336 | |||
337 | arg0.integer.value = alarm; | ||
338 | 358 | ||
339 | status = | 359 | mutex_lock(&battery->lock); |
340 | acpi_evaluate_object(acpi_battery_handle(battery), "_BTP", | 360 | status = acpi_evaluate_object(battery->device->handle, "_BTP", |
341 | &arg_list, NULL); | 361 | &arg_list, NULL); |
362 | mutex_unlock(&battery->lock); | ||
363 | |||
342 | if (ACPI_FAILURE(status)) | 364 | if (ACPI_FAILURE(status)) |
343 | return -ENODEV; | 365 | return -ENODEV; |
344 | 366 | ||
345 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm)); | 367 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", battery->alarm)); |
346 | |||
347 | battery->alarm = alarm; | ||
348 | |||
349 | return 0; | 368 | return 0; |
350 | } | 369 | } |
351 | 370 | ||
352 | static int acpi_battery_init_alarm(struct acpi_battery *battery) | 371 | static int acpi_battery_init_alarm(struct acpi_battery *battery) |
353 | { | 372 | { |
354 | int result = 0; | ||
355 | acpi_status status = AE_OK; | 373 | acpi_status status = AE_OK; |
356 | acpi_handle handle = NULL; | 374 | acpi_handle handle = NULL; |
357 | struct acpi_battery_info *bif = battery->bif_data.pointer; | ||
358 | unsigned long alarm = battery->alarm; | ||
359 | 375 | ||
360 | /* See if alarms are supported, and if so, set default */ | 376 | /* See if alarms are supported, and if so, set default */ |
361 | 377 | status = acpi_get_handle(battery->device->handle, "_BTP", &handle); | |
362 | status = acpi_get_handle(acpi_battery_handle(battery), "_BTP", &handle); | 378 | if (ACPI_FAILURE(status)) { |
363 | if (ACPI_SUCCESS(status)) { | 379 | battery->alarm_present = 0; |
364 | battery->flags.alarm_present = 1; | 380 | return 0; |
365 | if (!alarm && bif) { | ||
366 | alarm = bif->design_capacity_warning; | ||
367 | } | ||
368 | result = acpi_battery_set_alarm(battery, alarm); | ||
369 | if (result) | ||
370 | goto end; | ||
371 | } else { | ||
372 | battery->flags.alarm_present = 0; | ||
373 | } | 381 | } |
374 | 382 | battery->alarm_present = 1; | |
375 | end: | 383 | if (!battery->alarm) |
376 | 384 | battery->alarm = battery->design_capacity_warning; | |
377 | return result; | 385 | return acpi_battery_set_alarm(battery); |
378 | } | 386 | } |
379 | 387 | ||
380 | static int acpi_battery_init_update(struct acpi_battery *battery) | 388 | static int acpi_battery_update(struct acpi_battery *battery) |
381 | { | 389 | { |
382 | int result = 0; | 390 | int saved_present = acpi_battery_present(battery); |
383 | 391 | int result = acpi_battery_get_status(battery); | |
384 | result = acpi_battery_get_status(battery); | 392 | if (result || !acpi_battery_present(battery)) |
385 | if (result) | ||
386 | return result; | 393 | return result; |
387 | 394 | if (saved_present != acpi_battery_present(battery) || | |
388 | battery->flags.battery_present_prev = acpi_battery_present(battery); | 395 | !battery->update_time) { |
389 | 396 | battery->update_time = 0; | |
390 | if (acpi_battery_present(battery)) { | ||
391 | result = acpi_battery_get_info(battery); | 397 | result = acpi_battery_get_info(battery); |
392 | if (result) | 398 | if (result) |
393 | return result; | 399 | return result; |
394 | result = acpi_battery_get_state(battery); | 400 | if (battery->power_unit) { |
395 | if (result) | 401 | battery->bat.properties = charge_battery_props; |
396 | return result; | 402 | battery->bat.num_properties = |
397 | 403 | ARRAY_SIZE(charge_battery_props); | |
398 | acpi_battery_init_alarm(battery); | ||
399 | } | ||
400 | |||
401 | return result; | ||
402 | } | ||
403 | |||
404 | static int acpi_battery_update(struct acpi_battery *battery, | ||
405 | int update, int *update_result_ptr) | ||
406 | { | ||
407 | int result = 0; | ||
408 | int update_result = ACPI_BATTERY_NONE_UPDATE; | ||
409 | |||
410 | if (!acpi_battery_present(battery)) { | ||
411 | update = 1; | ||
412 | } | ||
413 | |||
414 | if (battery->flags.init_update) { | ||
415 | result = acpi_battery_init_update(battery); | ||
416 | if (result) | ||
417 | goto end; | ||
418 | update_result = ACPI_BATTERY_INIT_UPDATE; | ||
419 | } else if (update) { | ||
420 | result = acpi_battery_get_status(battery); | ||
421 | if (result) | ||
422 | goto end; | ||
423 | if ((!battery->flags.battery_present_prev & acpi_battery_present(battery)) | ||
424 | || (battery->flags.battery_present_prev & !acpi_battery_present(battery))) { | ||
425 | result = acpi_battery_init_update(battery); | ||
426 | if (result) | ||
427 | goto end; | ||
428 | update_result = ACPI_BATTERY_INIT_UPDATE; | ||
429 | } else { | 404 | } else { |
430 | update_result = ACPI_BATTERY_EASY_UPDATE; | 405 | battery->bat.properties = energy_battery_props; |
406 | battery->bat.num_properties = | ||
407 | ARRAY_SIZE(energy_battery_props); | ||
431 | } | 408 | } |
409 | acpi_battery_init_alarm(battery); | ||
432 | } | 410 | } |
433 | 411 | return acpi_battery_get_state(battery); | |
434 | end: | ||
435 | |||
436 | battery->flags.init_update = (result != 0); | ||
437 | |||
438 | *update_result_ptr = update_result; | ||
439 | |||
440 | return result; | ||
441 | } | ||
442 | |||
443 | static void acpi_battery_notify_update(struct acpi_battery *battery) | ||
444 | { | ||
445 | acpi_battery_get_status(battery); | ||
446 | |||
447 | if (battery->flags.init_update) { | ||
448 | return; | ||
449 | } | ||
450 | |||
451 | if ((!battery->flags.battery_present_prev & | ||
452 | acpi_battery_present(battery)) || | ||
453 | (battery->flags.battery_present_prev & | ||
454 | !acpi_battery_present(battery))) { | ||
455 | battery->flags.init_update = 1; | ||
456 | } else { | ||
457 | battery->flags.update[ACPI_BATTERY_INFO] = 1; | ||
458 | battery->flags.update[ACPI_BATTERY_STATE] = 1; | ||
459 | battery->flags.update[ACPI_BATTERY_ALARM] = 1; | ||
460 | } | ||
461 | } | 412 | } |
462 | 413 | ||
463 | /* -------------------------------------------------------------------------- | 414 | /* -------------------------------------------------------------------------- |
464 | FS Interface (/proc) | 415 | FS Interface (/proc) |
465 | -------------------------------------------------------------------------- */ | 416 | -------------------------------------------------------------------------- */ |
466 | 417 | ||
418 | #ifdef CONFIG_ACPI_PROCFS | ||
467 | static struct proc_dir_entry *acpi_battery_dir; | 419 | static struct proc_dir_entry *acpi_battery_dir; |
468 | 420 | ||
469 | static int acpi_battery_print_info(struct seq_file *seq, int result) | 421 | static int acpi_battery_print_info(struct seq_file *seq, int result) |
470 | { | 422 | { |
471 | struct acpi_battery *battery = seq->private; | 423 | struct acpi_battery *battery = seq->private; |
472 | struct acpi_battery_info *bif = NULL; | ||
473 | char *units = "?"; | ||
474 | 424 | ||
475 | if (result) | 425 | if (result) |
476 | goto end; | 426 | goto end; |
477 | 427 | ||
478 | if (acpi_battery_present(battery)) | 428 | seq_printf(seq, "present: %s\n", |
479 | seq_printf(seq, "present: yes\n"); | 429 | acpi_battery_present(battery)?"yes":"no"); |
480 | else { | 430 | if (!acpi_battery_present(battery)) |
481 | seq_printf(seq, "present: no\n"); | ||
482 | goto end; | ||
483 | } | ||
484 | |||
485 | bif = battery->bif_data.pointer; | ||
486 | if (!bif) { | ||
487 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BIF buffer is NULL")); | ||
488 | result = -ENODEV; | ||
489 | goto end; | 431 | goto end; |
490 | } | 432 | if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) |
491 | |||
492 | /* Battery Units */ | ||
493 | |||
494 | units = acpi_battery_power_units(battery); | ||
495 | |||
496 | if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) | ||
497 | seq_printf(seq, "design capacity: unknown\n"); | 433 | seq_printf(seq, "design capacity: unknown\n"); |
498 | else | 434 | else |
499 | seq_printf(seq, "design capacity: %d %sh\n", | 435 | seq_printf(seq, "design capacity: %d %sh\n", |
500 | (u32) bif->design_capacity, units); | 436 | battery->design_capacity, |
437 | acpi_battery_units(battery)); | ||
501 | 438 | ||
502 | if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN) | 439 | if (battery->full_charge_capacity == ACPI_BATTERY_VALUE_UNKNOWN) |
503 | seq_printf(seq, "last full capacity: unknown\n"); | 440 | seq_printf(seq, "last full capacity: unknown\n"); |
504 | else | 441 | else |
505 | seq_printf(seq, "last full capacity: %d %sh\n", | 442 | seq_printf(seq, "last full capacity: %d %sh\n", |
506 | (u32) bif->last_full_capacity, units); | 443 | battery->full_charge_capacity, |
444 | acpi_battery_units(battery)); | ||
507 | 445 | ||
508 | switch ((u32) bif->battery_technology) { | 446 | seq_printf(seq, "battery technology: %srechargeable\n", |
509 | case 0: | 447 | (!battery->technology)?"non-":""); |
510 | seq_printf(seq, "battery technology: non-rechargeable\n"); | ||
511 | break; | ||
512 | case 1: | ||
513 | seq_printf(seq, "battery technology: rechargeable\n"); | ||
514 | break; | ||
515 | default: | ||
516 | seq_printf(seq, "battery technology: unknown\n"); | ||
517 | break; | ||
518 | } | ||
519 | 448 | ||
520 | if (bif->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN) | 449 | if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN) |
521 | seq_printf(seq, "design voltage: unknown\n"); | 450 | seq_printf(seq, "design voltage: unknown\n"); |
522 | else | 451 | else |
523 | seq_printf(seq, "design voltage: %d mV\n", | 452 | seq_printf(seq, "design voltage: %d mV\n", |
524 | (u32) bif->design_voltage); | 453 | battery->design_voltage); |
525 | seq_printf(seq, "design capacity warning: %d %sh\n", | 454 | seq_printf(seq, "design capacity warning: %d %sh\n", |
526 | (u32) bif->design_capacity_warning, units); | 455 | battery->design_capacity_warning, |
456 | acpi_battery_units(battery)); | ||
527 | seq_printf(seq, "design capacity low: %d %sh\n", | 457 | seq_printf(seq, "design capacity low: %d %sh\n", |
528 | (u32) bif->design_capacity_low, units); | 458 | battery->design_capacity_low, |
459 | acpi_battery_units(battery)); | ||
529 | seq_printf(seq, "capacity granularity 1: %d %sh\n", | 460 | seq_printf(seq, "capacity granularity 1: %d %sh\n", |
530 | (u32) bif->battery_capacity_granularity_1, units); | 461 | battery->capacity_granularity_1, |
462 | acpi_battery_units(battery)); | ||
531 | seq_printf(seq, "capacity granularity 2: %d %sh\n", | 463 | seq_printf(seq, "capacity granularity 2: %d %sh\n", |
532 | (u32) bif->battery_capacity_granularity_2, units); | 464 | battery->capacity_granularity_2, |
533 | seq_printf(seq, "model number: %s\n", bif->model_number); | 465 | acpi_battery_units(battery)); |
534 | seq_printf(seq, "serial number: %s\n", bif->serial_number); | 466 | seq_printf(seq, "model number: %s\n", battery->model_number); |
535 | seq_printf(seq, "battery type: %s\n", bif->battery_type); | 467 | seq_printf(seq, "serial number: %s\n", battery->serial_number); |
536 | seq_printf(seq, "OEM info: %s\n", bif->oem_info); | 468 | seq_printf(seq, "battery type: %s\n", battery->type); |
537 | 469 | seq_printf(seq, "OEM info: %s\n", battery->oem_info); | |
538 | end: | 470 | end: |
539 | |||
540 | if (result) | 471 | if (result) |
541 | seq_printf(seq, "ERROR: Unable to read battery info\n"); | 472 | seq_printf(seq, "ERROR: Unable to read battery info\n"); |
542 | |||
543 | return result; | 473 | return result; |
544 | } | 474 | } |
545 | 475 | ||
546 | static int acpi_battery_print_state(struct seq_file *seq, int result) | 476 | static int acpi_battery_print_state(struct seq_file *seq, int result) |
547 | { | 477 | { |
548 | struct acpi_battery *battery = seq->private; | 478 | struct acpi_battery *battery = seq->private; |
549 | struct acpi_battery_state *bst = NULL; | ||
550 | char *units = "?"; | ||
551 | 479 | ||
552 | if (result) | 480 | if (result) |
553 | goto end; | 481 | goto end; |
554 | 482 | ||
555 | if (acpi_battery_present(battery)) | 483 | seq_printf(seq, "present: %s\n", |
556 | seq_printf(seq, "present: yes\n"); | 484 | acpi_battery_present(battery)?"yes":"no"); |
557 | else { | 485 | if (!acpi_battery_present(battery)) |
558 | seq_printf(seq, "present: no\n"); | ||
559 | goto end; | ||
560 | } | ||
561 | |||
562 | bst = battery->bst_data.pointer; | ||
563 | if (!bst) { | ||
564 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BST buffer is NULL")); | ||
565 | result = -ENODEV; | ||
566 | goto end; | 486 | goto end; |
567 | } | ||
568 | |||
569 | /* Battery Units */ | ||
570 | |||
571 | units = acpi_battery_power_units(battery); | ||
572 | |||
573 | if (!(bst->state & 0x04)) | ||
574 | seq_printf(seq, "capacity state: ok\n"); | ||
575 | else | ||
576 | seq_printf(seq, "capacity state: critical\n"); | ||
577 | 487 | ||
578 | if ((bst->state & 0x01) && (bst->state & 0x02)) { | 488 | seq_printf(seq, "capacity state: %s\n", |
489 | (battery->state & 0x04)?"critical":"ok"); | ||
490 | if ((battery->state & 0x01) && (battery->state & 0x02)) | ||
579 | seq_printf(seq, | 491 | seq_printf(seq, |
580 | "charging state: charging/discharging\n"); | 492 | "charging state: charging/discharging\n"); |
581 | } else if (bst->state & 0x01) | 493 | else if (battery->state & 0x01) |
582 | seq_printf(seq, "charging state: discharging\n"); | 494 | seq_printf(seq, "charging state: discharging\n"); |
583 | else if (bst->state & 0x02) | 495 | else if (battery->state & 0x02) |
584 | seq_printf(seq, "charging state: charging\n"); | 496 | seq_printf(seq, "charging state: charging\n"); |
585 | else { | 497 | else |
586 | seq_printf(seq, "charging state: charged\n"); | 498 | seq_printf(seq, "charging state: charged\n"); |
587 | } | ||
588 | 499 | ||
589 | if (bst->present_rate == ACPI_BATTERY_VALUE_UNKNOWN) | 500 | if (battery->current_now == ACPI_BATTERY_VALUE_UNKNOWN) |
590 | seq_printf(seq, "present rate: unknown\n"); | 501 | seq_printf(seq, "present rate: unknown\n"); |
591 | else | 502 | else |
592 | seq_printf(seq, "present rate: %d %s\n", | 503 | seq_printf(seq, "present rate: %d %s\n", |
593 | (u32) bst->present_rate, units); | 504 | battery->current_now, acpi_battery_units(battery)); |
594 | 505 | ||
595 | if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN) | 506 | if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN) |
596 | seq_printf(seq, "remaining capacity: unknown\n"); | 507 | seq_printf(seq, "remaining capacity: unknown\n"); |
597 | else | 508 | else |
598 | seq_printf(seq, "remaining capacity: %d %sh\n", | 509 | seq_printf(seq, "remaining capacity: %d %sh\n", |
599 | (u32) bst->remaining_capacity, units); | 510 | battery->capacity_now, acpi_battery_units(battery)); |
600 | 511 | if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN) | |
601 | if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN) | ||
602 | seq_printf(seq, "present voltage: unknown\n"); | 512 | seq_printf(seq, "present voltage: unknown\n"); |
603 | else | 513 | else |
604 | seq_printf(seq, "present voltage: %d mV\n", | 514 | seq_printf(seq, "present voltage: %d mV\n", |
605 | (u32) bst->present_voltage); | 515 | battery->voltage_now); |
606 | |||
607 | end: | 516 | end: |
608 | 517 | if (result) | |
609 | if (result) { | ||
610 | seq_printf(seq, "ERROR: Unable to read battery state\n"); | 518 | seq_printf(seq, "ERROR: Unable to read battery state\n"); |
611 | } | ||
612 | 519 | ||
613 | return result; | 520 | return result; |
614 | } | 521 | } |
@@ -616,7 +523,6 @@ static int acpi_battery_print_state(struct seq_file *seq, int result) | |||
616 | static int acpi_battery_print_alarm(struct seq_file *seq, int result) | 523 | static int acpi_battery_print_alarm(struct seq_file *seq, int result) |
617 | { | 524 | { |
618 | struct acpi_battery *battery = seq->private; | 525 | struct acpi_battery *battery = seq->private; |
619 | char *units = "?"; | ||
620 | 526 | ||
621 | if (result) | 527 | if (result) |
622 | goto end; | 528 | goto end; |
@@ -625,189 +531,121 @@ static int acpi_battery_print_alarm(struct seq_file *seq, int result) | |||
625 | seq_printf(seq, "present: no\n"); | 531 | seq_printf(seq, "present: no\n"); |
626 | goto end; | 532 | goto end; |
627 | } | 533 | } |
628 | |||
629 | /* Battery Units */ | ||
630 | |||
631 | units = acpi_battery_power_units(battery); | ||
632 | |||
633 | seq_printf(seq, "alarm: "); | 534 | seq_printf(seq, "alarm: "); |
634 | if (!battery->alarm) | 535 | if (!battery->alarm) |
635 | seq_printf(seq, "unsupported\n"); | 536 | seq_printf(seq, "unsupported\n"); |
636 | else | 537 | else |
637 | seq_printf(seq, "%lu %sh\n", battery->alarm, units); | 538 | seq_printf(seq, "%u %sh\n", battery->alarm, |
638 | 539 | acpi_battery_units(battery)); | |
639 | end: | 540 | end: |
640 | |||
641 | if (result) | 541 | if (result) |
642 | seq_printf(seq, "ERROR: Unable to read battery alarm\n"); | 542 | seq_printf(seq, "ERROR: Unable to read battery alarm\n"); |
643 | |||
644 | return result; | 543 | return result; |
645 | } | 544 | } |
646 | 545 | ||
647 | static ssize_t | 546 | static ssize_t acpi_battery_write_alarm(struct file *file, |
648 | acpi_battery_write_alarm(struct file *file, | 547 | const char __user * buffer, |
649 | const char __user * buffer, | 548 | size_t count, loff_t * ppos) |
650 | size_t count, loff_t * ppos) | ||
651 | { | 549 | { |
652 | int result = 0; | 550 | int result = 0; |
653 | char alarm_string[12] = { '\0' }; | 551 | char alarm_string[12] = { '\0' }; |
654 | struct seq_file *m = file->private_data; | 552 | struct seq_file *m = file->private_data; |
655 | struct acpi_battery *battery = m->private; | 553 | struct acpi_battery *battery = m->private; |
656 | int update_result = ACPI_BATTERY_NONE_UPDATE; | ||
657 | 554 | ||
658 | if (!battery || (count > sizeof(alarm_string) - 1)) | 555 | if (!battery || (count > sizeof(alarm_string) - 1)) |
659 | return -EINVAL; | 556 | return -EINVAL; |
660 | |||
661 | mutex_lock(&battery->mutex); | ||
662 | |||
663 | result = acpi_battery_update(battery, 1, &update_result); | ||
664 | if (result) { | 557 | if (result) { |
665 | result = -ENODEV; | 558 | result = -ENODEV; |
666 | goto end; | 559 | goto end; |
667 | } | 560 | } |
668 | |||
669 | if (!acpi_battery_present(battery)) { | 561 | if (!acpi_battery_present(battery)) { |
670 | result = -ENODEV; | 562 | result = -ENODEV; |
671 | goto end; | 563 | goto end; |
672 | } | 564 | } |
673 | |||
674 | if (copy_from_user(alarm_string, buffer, count)) { | 565 | if (copy_from_user(alarm_string, buffer, count)) { |
675 | result = -EFAULT; | 566 | result = -EFAULT; |
676 | goto end; | 567 | goto end; |
677 | } | 568 | } |
678 | |||
679 | alarm_string[count] = '\0'; | 569 | alarm_string[count] = '\0'; |
680 | 570 | battery->alarm = simple_strtol(alarm_string, NULL, 0); | |
681 | result = acpi_battery_set_alarm(battery, | 571 | result = acpi_battery_set_alarm(battery); |
682 | simple_strtoul(alarm_string, NULL, 0)); | ||
683 | if (result) | ||
684 | goto end; | ||
685 | |||
686 | end: | 572 | end: |
687 | |||
688 | acpi_battery_check_result(battery, result); | ||
689 | |||
690 | if (!result) | 573 | if (!result) |
691 | result = count; | 574 | return count; |
692 | |||
693 | mutex_unlock(&battery->mutex); | ||
694 | |||
695 | return result; | 575 | return result; |
696 | } | 576 | } |
697 | 577 | ||
698 | typedef int(*print_func)(struct seq_file *seq, int result); | 578 | typedef int(*print_func)(struct seq_file *seq, int result); |
699 | typedef int(*get_func)(struct acpi_battery *battery); | 579 | |
700 | 580 | static print_func acpi_print_funcs[ACPI_BATTERY_NUMFILES] = { | |
701 | static struct acpi_read_mux { | 581 | acpi_battery_print_info, |
702 | print_func print; | 582 | acpi_battery_print_state, |
703 | get_func get; | 583 | acpi_battery_print_alarm, |
704 | } acpi_read_funcs[ACPI_BATTERY_NUMFILES] = { | ||
705 | {.get = acpi_battery_get_info, .print = acpi_battery_print_info}, | ||
706 | {.get = acpi_battery_get_state, .print = acpi_battery_print_state}, | ||
707 | {.get = acpi_battery_get_alarm, .print = acpi_battery_print_alarm}, | ||
708 | }; | 584 | }; |
709 | 585 | ||
710 | static int acpi_battery_read(int fid, struct seq_file *seq) | 586 | static int acpi_battery_read(int fid, struct seq_file *seq) |
711 | { | 587 | { |
712 | struct acpi_battery *battery = seq->private; | 588 | struct acpi_battery *battery = seq->private; |
713 | int result = 0; | 589 | int result = acpi_battery_update(battery); |
714 | int update_result = ACPI_BATTERY_NONE_UPDATE; | 590 | return acpi_print_funcs[fid](seq, result); |
715 | int update = 0; | 591 | } |
716 | 592 | ||
717 | mutex_lock(&battery->mutex); | 593 | #define DECLARE_FILE_FUNCTIONS(_name) \ |
718 | 594 | static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \ | |
719 | update = (get_seconds() - battery->update_time[fid] >= update_time); | 595 | { \ |
720 | update = (update | battery->flags.update[fid]); | 596 | return acpi_battery_read(_name##_tag, seq); \ |
721 | 597 | } \ | |
722 | result = acpi_battery_update(battery, update, &update_result); | 598 | static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \ |
723 | if (result) | 599 | { \ |
724 | goto end; | 600 | return single_open(file, acpi_battery_read_##_name, PDE(inode)->data); \ |
725 | 601 | } | |
726 | if (update_result == ACPI_BATTERY_EASY_UPDATE) { | 602 | |
727 | result = acpi_read_funcs[fid].get(battery); | 603 | DECLARE_FILE_FUNCTIONS(info); |
728 | if (result) | 604 | DECLARE_FILE_FUNCTIONS(state); |
729 | goto end; | 605 | DECLARE_FILE_FUNCTIONS(alarm); |
606 | |||
607 | #undef DECLARE_FILE_FUNCTIONS | ||
608 | |||
609 | #define FILE_DESCRIPTION_RO(_name) \ | ||
610 | { \ | ||
611 | .name = __stringify(_name), \ | ||
612 | .mode = S_IRUGO, \ | ||
613 | .ops = { \ | ||
614 | .open = acpi_battery_##_name##_open_fs, \ | ||
615 | .read = seq_read, \ | ||
616 | .llseek = seq_lseek, \ | ||
617 | .release = single_release, \ | ||
618 | .owner = THIS_MODULE, \ | ||
619 | }, \ | ||
620 | } | ||
621 | |||
622 | #define FILE_DESCRIPTION_RW(_name) \ | ||
623 | { \ | ||
624 | .name = __stringify(_name), \ | ||
625 | .mode = S_IFREG | S_IRUGO | S_IWUSR, \ | ||
626 | .ops = { \ | ||
627 | .open = acpi_battery_##_name##_open_fs, \ | ||
628 | .read = seq_read, \ | ||
629 | .llseek = seq_lseek, \ | ||
630 | .write = acpi_battery_write_##_name, \ | ||
631 | .release = single_release, \ | ||
632 | .owner = THIS_MODULE, \ | ||
633 | }, \ | ||
730 | } | 634 | } |
731 | 635 | ||
732 | end: | ||
733 | result = acpi_read_funcs[fid].print(seq, result); | ||
734 | acpi_battery_check_result(battery, result); | ||
735 | battery->flags.update[fid] = result; | ||
736 | mutex_unlock(&battery->mutex); | ||
737 | return result; | ||
738 | } | ||
739 | |||
740 | static int acpi_battery_read_info(struct seq_file *seq, void *offset) | ||
741 | { | ||
742 | return acpi_battery_read(ACPI_BATTERY_INFO, seq); | ||
743 | } | ||
744 | |||
745 | static int acpi_battery_read_state(struct seq_file *seq, void *offset) | ||
746 | { | ||
747 | return acpi_battery_read(ACPI_BATTERY_STATE, seq); | ||
748 | } | ||
749 | |||
750 | static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) | ||
751 | { | ||
752 | return acpi_battery_read(ACPI_BATTERY_ALARM, seq); | ||
753 | } | ||
754 | |||
755 | static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) | ||
756 | { | ||
757 | return single_open(file, acpi_battery_read_info, PDE(inode)->data); | ||
758 | } | ||
759 | |||
760 | static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) | ||
761 | { | ||
762 | return single_open(file, acpi_battery_read_state, PDE(inode)->data); | ||
763 | } | ||
764 | |||
765 | static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) | ||
766 | { | ||
767 | return single_open(file, acpi_battery_read_alarm, PDE(inode)->data); | ||
768 | } | ||
769 | |||
770 | static struct battery_file { | 636 | static struct battery_file { |
771 | struct file_operations ops; | 637 | struct file_operations ops; |
772 | mode_t mode; | 638 | mode_t mode; |
773 | char *name; | 639 | char *name; |
774 | } acpi_battery_file[] = { | 640 | } acpi_battery_file[] = { |
775 | { | 641 | FILE_DESCRIPTION_RO(info), |
776 | .name = "info", | 642 | FILE_DESCRIPTION_RO(state), |
777 | .mode = S_IRUGO, | 643 | FILE_DESCRIPTION_RW(alarm), |
778 | .ops = { | ||
779 | .open = acpi_battery_info_open_fs, | ||
780 | .read = seq_read, | ||
781 | .llseek = seq_lseek, | ||
782 | .release = single_release, | ||
783 | .owner = THIS_MODULE, | ||
784 | }, | ||
785 | }, | ||
786 | { | ||
787 | .name = "state", | ||
788 | .mode = S_IRUGO, | ||
789 | .ops = { | ||
790 | .open = acpi_battery_state_open_fs, | ||
791 | .read = seq_read, | ||
792 | .llseek = seq_lseek, | ||
793 | .release = single_release, | ||
794 | .owner = THIS_MODULE, | ||
795 | }, | ||
796 | }, | ||
797 | { | ||
798 | .name = "alarm", | ||
799 | .mode = S_IFREG | S_IRUGO | S_IWUSR, | ||
800 | .ops = { | ||
801 | .open = acpi_battery_alarm_open_fs, | ||
802 | .read = seq_read, | ||
803 | .write = acpi_battery_write_alarm, | ||
804 | .llseek = seq_lseek, | ||
805 | .release = single_release, | ||
806 | .owner = THIS_MODULE, | ||
807 | }, | ||
808 | }, | ||
809 | }; | 644 | }; |
810 | 645 | ||
646 | #undef FILE_DESCRIPTION_RO | ||
647 | #undef FILE_DESCRIPTION_RW | ||
648 | |||
811 | static int acpi_battery_add_fs(struct acpi_device *device) | 649 | static int acpi_battery_add_fs(struct acpi_device *device) |
812 | { | 650 | { |
813 | struct proc_dir_entry *entry = NULL; | 651 | struct proc_dir_entry *entry = NULL; |
@@ -832,25 +670,51 @@ static int acpi_battery_add_fs(struct acpi_device *device) | |||
832 | entry->owner = THIS_MODULE; | 670 | entry->owner = THIS_MODULE; |
833 | } | 671 | } |
834 | } | 672 | } |
835 | |||
836 | return 0; | 673 | return 0; |
837 | } | 674 | } |
838 | 675 | ||
839 | static int acpi_battery_remove_fs(struct acpi_device *device) | 676 | static void acpi_battery_remove_fs(struct acpi_device *device) |
840 | { | 677 | { |
841 | int i; | 678 | int i; |
842 | if (acpi_device_dir(device)) { | 679 | if (!acpi_device_dir(device)) |
843 | for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) { | 680 | return; |
844 | remove_proc_entry(acpi_battery_file[i].name, | 681 | for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) |
682 | remove_proc_entry(acpi_battery_file[i].name, | ||
845 | acpi_device_dir(device)); | 683 | acpi_device_dir(device)); |
846 | } | ||
847 | remove_proc_entry(acpi_device_bid(device), acpi_battery_dir); | ||
848 | acpi_device_dir(device) = NULL; | ||
849 | } | ||
850 | 684 | ||
851 | return 0; | 685 | remove_proc_entry(acpi_device_bid(device), acpi_battery_dir); |
686 | acpi_device_dir(device) = NULL; | ||
687 | } | ||
688 | |||
689 | #endif | ||
690 | |||
691 | static ssize_t acpi_battery_alarm_show(struct device *dev, | ||
692 | struct device_attribute *attr, | ||
693 | char *buf) | ||
694 | { | ||
695 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
696 | return sprintf(buf, "%d\n", battery->alarm * 1000); | ||
697 | } | ||
698 | |||
699 | static ssize_t acpi_battery_alarm_store(struct device *dev, | ||
700 | struct device_attribute *attr, | ||
701 | const char *buf, size_t count) | ||
702 | { | ||
703 | unsigned long x; | ||
704 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
705 | if (sscanf(buf, "%ld\n", &x) == 1) | ||
706 | battery->alarm = x/1000; | ||
707 | if (acpi_battery_present(battery)) | ||
708 | acpi_battery_set_alarm(battery); | ||
709 | return count; | ||
852 | } | 710 | } |
853 | 711 | ||
712 | static struct device_attribute alarm_attr = { | ||
713 | .attr = {.name = "alarm", .mode = 0644, .owner = THIS_MODULE}, | ||
714 | .show = acpi_battery_alarm_show, | ||
715 | .store = acpi_battery_alarm_store, | ||
716 | }; | ||
717 | |||
854 | /* -------------------------------------------------------------------------- | 718 | /* -------------------------------------------------------------------------- |
855 | Driver Interface | 719 | Driver Interface |
856 | -------------------------------------------------------------------------- */ | 720 | -------------------------------------------------------------------------- */ |
@@ -858,33 +722,17 @@ static int acpi_battery_remove_fs(struct acpi_device *device) | |||
858 | static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) | 722 | static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) |
859 | { | 723 | { |
860 | struct acpi_battery *battery = data; | 724 | struct acpi_battery *battery = data; |
861 | struct acpi_device *device = NULL; | 725 | struct acpi_device *device; |
862 | |||
863 | if (!battery) | 726 | if (!battery) |
864 | return; | 727 | return; |
865 | |||
866 | device = battery->device; | 728 | device = battery->device; |
867 | 729 | acpi_battery_update(battery); | |
868 | switch (event) { | 730 | acpi_bus_generate_proc_event(device, event, |
869 | case ACPI_BATTERY_NOTIFY_STATUS: | 731 | acpi_battery_present(battery)); |
870 | case ACPI_BATTERY_NOTIFY_INFO: | 732 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
871 | case ACPI_NOTIFY_BUS_CHECK: | 733 | device->dev.bus_id, event, |
872 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
873 | device = battery->device; | ||
874 | acpi_battery_notify_update(battery); | ||
875 | acpi_bus_generate_proc_event(device, event, | ||
876 | acpi_battery_present(battery)); | 734 | acpi_battery_present(battery)); |
877 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 735 | kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); |
878 | device->dev.bus_id, event, | ||
879 | acpi_battery_present(battery)); | ||
880 | break; | ||
881 | default: | ||
882 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
883 | "Unsupported event [0x%x]\n", event)); | ||
884 | break; | ||
885 | } | ||
886 | |||
887 | return; | ||
888 | } | 736 | } |
889 | 737 | ||
890 | static int acpi_battery_add(struct acpi_device *device) | 738 | static int acpi_battery_add(struct acpi_device *device) |
@@ -892,33 +740,27 @@ static int acpi_battery_add(struct acpi_device *device) | |||
892 | int result = 0; | 740 | int result = 0; |
893 | acpi_status status = 0; | 741 | acpi_status status = 0; |
894 | struct acpi_battery *battery = NULL; | 742 | struct acpi_battery *battery = NULL; |
895 | |||
896 | if (!device) | 743 | if (!device) |
897 | return -EINVAL; | 744 | return -EINVAL; |
898 | |||
899 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); | 745 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); |
900 | if (!battery) | 746 | if (!battery) |
901 | return -ENOMEM; | 747 | return -ENOMEM; |
902 | |||
903 | mutex_init(&battery->mutex); | ||
904 | |||
905 | mutex_lock(&battery->mutex); | ||
906 | |||
907 | battery->device = device; | 748 | battery->device = device; |
908 | strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); | 749 | strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); |
909 | strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); | 750 | strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); |
910 | acpi_driver_data(device) = battery; | 751 | acpi_driver_data(device) = battery; |
911 | 752 | mutex_init(&battery->lock); | |
912 | result = acpi_battery_get_status(battery); | 753 | acpi_battery_update(battery); |
913 | if (result) | 754 | #ifdef CONFIG_ACPI_PROCFS |
914 | goto end; | ||
915 | |||
916 | battery->flags.init_update = 1; | ||
917 | |||
918 | result = acpi_battery_add_fs(device); | 755 | result = acpi_battery_add_fs(device); |
919 | if (result) | 756 | if (result) |
920 | goto end; | 757 | goto end; |
921 | 758 | #endif | |
759 | battery->bat.name = acpi_device_bid(device); | ||
760 | battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; | ||
761 | battery->bat.get_property = acpi_battery_get_property; | ||
762 | result = power_supply_register(&battery->device->dev, &battery->bat); | ||
763 | result = device_create_file(battery->bat.dev, &alarm_attr); | ||
922 | status = acpi_install_notify_handler(device->handle, | 764 | status = acpi_install_notify_handler(device->handle, |
923 | ACPI_ALL_NOTIFY, | 765 | ACPI_ALL_NOTIFY, |
924 | acpi_battery_notify, battery); | 766 | acpi_battery_notify, battery); |
@@ -927,20 +769,16 @@ static int acpi_battery_add(struct acpi_device *device) | |||
927 | result = -ENODEV; | 769 | result = -ENODEV; |
928 | goto end; | 770 | goto end; |
929 | } | 771 | } |
930 | |||
931 | printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", | 772 | printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", |
932 | ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), | 773 | ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), |
933 | device->status.battery_present ? "present" : "absent"); | 774 | device->status.battery_present ? "present" : "absent"); |
934 | |||
935 | end: | 775 | end: |
936 | |||
937 | if (result) { | 776 | if (result) { |
777 | #ifdef CONFIG_ACPI_PROCFS | ||
938 | acpi_battery_remove_fs(device); | 778 | acpi_battery_remove_fs(device); |
779 | #endif | ||
939 | kfree(battery); | 780 | kfree(battery); |
940 | } | 781 | } |
941 | |||
942 | mutex_unlock(&battery->mutex); | ||
943 | |||
944 | return result; | 782 | return result; |
945 | } | 783 | } |
946 | 784 | ||
@@ -951,27 +789,19 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
951 | 789 | ||
952 | if (!device || !acpi_driver_data(device)) | 790 | if (!device || !acpi_driver_data(device)) |
953 | return -EINVAL; | 791 | return -EINVAL; |
954 | |||
955 | battery = acpi_driver_data(device); | 792 | battery = acpi_driver_data(device); |
956 | |||
957 | mutex_lock(&battery->mutex); | ||
958 | |||
959 | status = acpi_remove_notify_handler(device->handle, | 793 | status = acpi_remove_notify_handler(device->handle, |
960 | ACPI_ALL_NOTIFY, | 794 | ACPI_ALL_NOTIFY, |
961 | acpi_battery_notify); | 795 | acpi_battery_notify); |
962 | 796 | #ifdef CONFIG_ACPI_PROCFS | |
963 | acpi_battery_remove_fs(device); | 797 | acpi_battery_remove_fs(device); |
964 | 798 | #endif | |
965 | kfree(battery->bif_data.pointer); | 799 | if (battery->bat.dev) { |
966 | 800 | device_remove_file(battery->bat.dev, &alarm_attr); | |
967 | kfree(battery->bst_data.pointer); | 801 | power_supply_unregister(&battery->bat); |
968 | 802 | } | |
969 | mutex_unlock(&battery->mutex); | 803 | mutex_destroy(&battery->lock); |
970 | |||
971 | mutex_destroy(&battery->mutex); | ||
972 | |||
973 | kfree(battery); | 804 | kfree(battery); |
974 | |||
975 | return 0; | 805 | return 0; |
976 | } | 806 | } |
977 | 807 | ||
@@ -979,44 +809,48 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
979 | static int acpi_battery_resume(struct acpi_device *device) | 809 | static int acpi_battery_resume(struct acpi_device *device) |
980 | { | 810 | { |
981 | struct acpi_battery *battery; | 811 | struct acpi_battery *battery; |
982 | |||
983 | if (!device) | 812 | if (!device) |
984 | return -EINVAL; | 813 | return -EINVAL; |
985 | 814 | battery = acpi_driver_data(device); | |
986 | battery = device->driver_data; | 815 | battery->update_time = 0; |
987 | |||
988 | battery->flags.init_update = 1; | ||
989 | |||
990 | return 0; | 816 | return 0; |
991 | } | 817 | } |
992 | 818 | ||
819 | static struct acpi_driver acpi_battery_driver = { | ||
820 | .name = "battery", | ||
821 | .class = ACPI_BATTERY_CLASS, | ||
822 | .ids = battery_device_ids, | ||
823 | .ops = { | ||
824 | .add = acpi_battery_add, | ||
825 | .resume = acpi_battery_resume, | ||
826 | .remove = acpi_battery_remove, | ||
827 | }, | ||
828 | }; | ||
829 | |||
993 | static int __init acpi_battery_init(void) | 830 | static int __init acpi_battery_init(void) |
994 | { | 831 | { |
995 | int result; | ||
996 | |||
997 | if (acpi_disabled) | 832 | if (acpi_disabled) |
998 | return -ENODEV; | 833 | return -ENODEV; |
999 | 834 | #ifdef CONFIG_ACPI_PROCFS | |
1000 | acpi_battery_dir = acpi_lock_battery_dir(); | 835 | acpi_battery_dir = acpi_lock_battery_dir(); |
1001 | if (!acpi_battery_dir) | 836 | if (!acpi_battery_dir) |
1002 | return -ENODEV; | 837 | return -ENODEV; |
1003 | 838 | #endif | |
1004 | result = acpi_bus_register_driver(&acpi_battery_driver); | 839 | if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { |
1005 | if (result < 0) { | 840 | #ifdef CONFIG_ACPI_PROCFS |
1006 | acpi_unlock_battery_dir(acpi_battery_dir); | 841 | acpi_unlock_battery_dir(acpi_battery_dir); |
842 | #endif | ||
1007 | return -ENODEV; | 843 | return -ENODEV; |
1008 | } | 844 | } |
1009 | |||
1010 | return 0; | 845 | return 0; |
1011 | } | 846 | } |
1012 | 847 | ||
1013 | static void __exit acpi_battery_exit(void) | 848 | static void __exit acpi_battery_exit(void) |
1014 | { | 849 | { |
1015 | acpi_bus_unregister_driver(&acpi_battery_driver); | 850 | acpi_bus_unregister_driver(&acpi_battery_driver); |
1016 | 851 | #ifdef CONFIG_ACPI_PROCFS | |
1017 | acpi_unlock_battery_dir(acpi_battery_dir); | 852 | acpi_unlock_battery_dir(acpi_battery_dir); |
1018 | 853 | #endif | |
1019 | return; | ||
1020 | } | 854 | } |
1021 | 855 | ||
1022 | module_init(acpi_battery_init); | 856 | module_init(acpi_battery_init); |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index cbfc81579c9a..fb2cff9a2d24 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -286,15 +286,11 @@ DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue); | |||
286 | 286 | ||
287 | extern int event_is_open; | 287 | extern int event_is_open; |
288 | 288 | ||
289 | int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data) | 289 | int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id, u8 type, int data) |
290 | { | 290 | { |
291 | struct acpi_bus_event *event = NULL; | 291 | struct acpi_bus_event *event; |
292 | unsigned long flags = 0; | 292 | unsigned long flags = 0; |
293 | 293 | ||
294 | |||
295 | if (!device) | ||
296 | return -EINVAL; | ||
297 | |||
298 | /* drop event on the floor if no one's listening */ | 294 | /* drop event on the floor if no one's listening */ |
299 | if (!event_is_open) | 295 | if (!event_is_open) |
300 | return 0; | 296 | return 0; |
@@ -303,8 +299,8 @@ int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data) | |||
303 | if (!event) | 299 | if (!event) |
304 | return -ENOMEM; | 300 | return -ENOMEM; |
305 | 301 | ||
306 | strcpy(event->device_class, device->pnp.device_class); | 302 | strcpy(event->device_class, device_class); |
307 | strcpy(event->bus_id, device->pnp.bus_id); | 303 | strcpy(event->bus_id, bus_id); |
308 | event->type = type; | 304 | event->type = type; |
309 | event->data = data; | 305 | event->data = data; |
310 | 306 | ||
@@ -315,6 +311,17 @@ int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data) | |||
315 | wake_up_interruptible(&acpi_bus_event_queue); | 311 | wake_up_interruptible(&acpi_bus_event_queue); |
316 | 312 | ||
317 | return 0; | 313 | return 0; |
314 | |||
315 | } | ||
316 | |||
317 | EXPORT_SYMBOL_GPL(acpi_bus_generate_proc_event4); | ||
318 | |||
319 | int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data) | ||
320 | { | ||
321 | if (!device) | ||
322 | return -EINVAL; | ||
323 | return acpi_bus_generate_proc_event4(device->pnp.device_class, | ||
324 | device->pnp.bus_id, type, data); | ||
318 | } | 325 | } |
319 | 326 | ||
320 | EXPORT_SYMBOL(acpi_bus_generate_proc_event); | 327 | EXPORT_SYMBOL(acpi_bus_generate_proc_event); |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 2e79a3395ecf..301e832e6961 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -434,18 +434,18 @@ static int acpi_button_add(struct acpi_device *device) | |||
434 | switch (button->type) { | 434 | switch (button->type) { |
435 | case ACPI_BUTTON_TYPE_POWER: | 435 | case ACPI_BUTTON_TYPE_POWER: |
436 | case ACPI_BUTTON_TYPE_POWERF: | 436 | case ACPI_BUTTON_TYPE_POWERF: |
437 | input->evbit[0] = BIT(EV_KEY); | 437 | input->evbit[0] = BIT_MASK(EV_KEY); |
438 | set_bit(KEY_POWER, input->keybit); | 438 | set_bit(KEY_POWER, input->keybit); |
439 | break; | 439 | break; |
440 | 440 | ||
441 | case ACPI_BUTTON_TYPE_SLEEP: | 441 | case ACPI_BUTTON_TYPE_SLEEP: |
442 | case ACPI_BUTTON_TYPE_SLEEPF: | 442 | case ACPI_BUTTON_TYPE_SLEEPF: |
443 | input->evbit[0] = BIT(EV_KEY); | 443 | input->evbit[0] = BIT_MASK(EV_KEY); |
444 | set_bit(KEY_SLEEP, input->keybit); | 444 | set_bit(KEY_SLEEP, input->keybit); |
445 | break; | 445 | break; |
446 | 446 | ||
447 | case ACPI_BUTTON_TYPE_LID: | 447 | case ACPI_BUTTON_TYPE_LID: |
448 | input->evbit[0] = BIT(EV_SW); | 448 | input->evbit[0] = BIT_MASK(EV_SW); |
449 | set_bit(SW_LID, input->swbit); | 449 | set_bit(SW_LID, input->swbit); |
450 | break; | 450 | break; |
451 | } | 451 | } |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 3f7935ab0cf5..7b4178393e34 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -121,6 +121,7 @@ static struct acpi_ec { | |||
121 | atomic_t event_count; | 121 | atomic_t event_count; |
122 | wait_queue_head_t wait; | 122 | wait_queue_head_t wait; |
123 | struct list_head list; | 123 | struct list_head list; |
124 | u8 handlers_installed; | ||
124 | } *boot_ec, *first_ec; | 125 | } *boot_ec, *first_ec; |
125 | 126 | ||
126 | /* -------------------------------------------------------------------------- | 127 | /* -------------------------------------------------------------------------- |
@@ -425,7 +426,7 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, | |||
425 | handler->func = func; | 426 | handler->func = func; |
426 | handler->data = data; | 427 | handler->data = data; |
427 | mutex_lock(&ec->lock); | 428 | mutex_lock(&ec->lock); |
428 | list_add_tail(&handler->node, &ec->list); | 429 | list_add(&handler->node, &ec->list); |
429 | mutex_unlock(&ec->lock); | 430 | mutex_unlock(&ec->lock); |
430 | return 0; | 431 | return 0; |
431 | } | 432 | } |
@@ -440,7 +441,6 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) | |||
440 | if (query_bit == handler->query_bit) { | 441 | if (query_bit == handler->query_bit) { |
441 | list_del(&handler->node); | 442 | list_del(&handler->node); |
442 | kfree(handler); | 443 | kfree(handler); |
443 | break; | ||
444 | } | 444 | } |
445 | } | 445 | } |
446 | mutex_unlock(&ec->lock); | 446 | mutex_unlock(&ec->lock); |
@@ -680,32 +680,50 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) | |||
680 | status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe); | 680 | status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe); |
681 | if (ACPI_FAILURE(status)) | 681 | if (ACPI_FAILURE(status)) |
682 | return status; | 682 | return status; |
683 | |||
684 | /* Find and register all query methods */ | 683 | /* Find and register all query methods */ |
685 | acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1, | 684 | acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1, |
686 | acpi_ec_register_query_methods, ec, NULL); | 685 | acpi_ec_register_query_methods, ec, NULL); |
687 | |||
688 | /* Use the global lock for all EC transactions? */ | 686 | /* Use the global lock for all EC transactions? */ |
689 | acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock); | 687 | acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock); |
690 | |||
691 | ec->handle = handle; | 688 | ec->handle = handle; |
692 | |||
693 | printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", | ||
694 | ec->gpe, ec->command_addr, ec->data_addr); | ||
695 | |||
696 | return AE_CTRL_TERMINATE; | 689 | return AE_CTRL_TERMINATE; |
697 | } | 690 | } |
698 | 691 | ||
692 | static void ec_remove_handlers(struct acpi_ec *ec) | ||
693 | { | ||
694 | if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, | ||
695 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) | ||
696 | printk(KERN_ERR PREFIX "failed to remove space handler\n"); | ||
697 | if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, | ||
698 | &acpi_ec_gpe_handler))) | ||
699 | printk(KERN_ERR PREFIX "failed to remove gpe handler\n"); | ||
700 | ec->handlers_installed = 0; | ||
701 | } | ||
702 | |||
699 | static int acpi_ec_add(struct acpi_device *device) | 703 | static int acpi_ec_add(struct acpi_device *device) |
700 | { | 704 | { |
701 | struct acpi_ec *ec = NULL; | 705 | struct acpi_ec *ec = NULL; |
702 | 706 | ||
703 | if (!device) | 707 | if (!device) |
704 | return -EINVAL; | 708 | return -EINVAL; |
705 | |||
706 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); | 709 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); |
707 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); | 710 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); |
708 | 711 | ||
712 | /* Check for boot EC */ | ||
713 | if (boot_ec) { | ||
714 | if (boot_ec->handle == device->handle) { | ||
715 | /* Pre-loaded EC from DSDT, just move pointer */ | ||
716 | ec = boot_ec; | ||
717 | boot_ec = NULL; | ||
718 | goto end; | ||
719 | } else if (boot_ec->handle == ACPI_ROOT_OBJECT) { | ||
720 | /* ECDT-based EC, time to shut it down */ | ||
721 | ec_remove_handlers(boot_ec); | ||
722 | kfree(boot_ec); | ||
723 | first_ec = boot_ec = NULL; | ||
724 | } | ||
725 | } | ||
726 | |||
709 | ec = make_acpi_ec(); | 727 | ec = make_acpi_ec(); |
710 | if (!ec) | 728 | if (!ec) |
711 | return -ENOMEM; | 729 | return -ENOMEM; |
@@ -715,25 +733,14 @@ static int acpi_ec_add(struct acpi_device *device) | |||
715 | kfree(ec); | 733 | kfree(ec); |
716 | return -EINVAL; | 734 | return -EINVAL; |
717 | } | 735 | } |
718 | |||
719 | /* Check if we found the boot EC */ | ||
720 | if (boot_ec) { | ||
721 | if (boot_ec->gpe == ec->gpe) { | ||
722 | /* We might have incorrect info for GL at boot time */ | ||
723 | mutex_lock(&boot_ec->lock); | ||
724 | boot_ec->global_lock = ec->global_lock; | ||
725 | /* Copy handlers from new ec into boot ec */ | ||
726 | list_splice(&ec->list, &boot_ec->list); | ||
727 | mutex_unlock(&boot_ec->lock); | ||
728 | kfree(ec); | ||
729 | ec = boot_ec; | ||
730 | } | ||
731 | } else | ||
732 | first_ec = ec; | ||
733 | ec->handle = device->handle; | 736 | ec->handle = device->handle; |
737 | end: | ||
738 | if (!first_ec) | ||
739 | first_ec = ec; | ||
734 | acpi_driver_data(device) = ec; | 740 | acpi_driver_data(device) = ec; |
735 | |||
736 | acpi_ec_add_fs(device); | 741 | acpi_ec_add_fs(device); |
742 | printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", | ||
743 | ec->gpe, ec->command_addr, ec->data_addr); | ||
737 | return 0; | 744 | return 0; |
738 | } | 745 | } |
739 | 746 | ||
@@ -756,10 +763,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type) | |||
756 | acpi_driver_data(device) = NULL; | 763 | acpi_driver_data(device) = NULL; |
757 | if (ec == first_ec) | 764 | if (ec == first_ec) |
758 | first_ec = NULL; | 765 | first_ec = NULL; |
759 | 766 | kfree(ec); | |
760 | /* Don't touch boot EC */ | ||
761 | if (boot_ec != ec) | ||
762 | kfree(ec); | ||
763 | return 0; | 767 | return 0; |
764 | } | 768 | } |
765 | 769 | ||
@@ -789,6 +793,8 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context) | |||
789 | static int ec_install_handlers(struct acpi_ec *ec) | 793 | static int ec_install_handlers(struct acpi_ec *ec) |
790 | { | 794 | { |
791 | acpi_status status; | 795 | acpi_status status; |
796 | if (ec->handlers_installed) | ||
797 | return 0; | ||
792 | status = acpi_install_gpe_handler(NULL, ec->gpe, | 798 | status = acpi_install_gpe_handler(NULL, ec->gpe, |
793 | ACPI_GPE_EDGE_TRIGGERED, | 799 | ACPI_GPE_EDGE_TRIGGERED, |
794 | &acpi_ec_gpe_handler, ec); | 800 | &acpi_ec_gpe_handler, ec); |
@@ -807,6 +813,7 @@ static int ec_install_handlers(struct acpi_ec *ec) | |||
807 | return -ENODEV; | 813 | return -ENODEV; |
808 | } | 814 | } |
809 | 815 | ||
816 | ec->handlers_installed = 1; | ||
810 | return 0; | 817 | return 0; |
811 | } | 818 | } |
812 | 819 | ||
@@ -823,41 +830,22 @@ static int acpi_ec_start(struct acpi_device *device) | |||
823 | if (!ec) | 830 | if (!ec) |
824 | return -EINVAL; | 831 | return -EINVAL; |
825 | 832 | ||
826 | /* Boot EC is already working */ | 833 | ret = ec_install_handlers(ec); |
827 | if (ec != boot_ec) | ||
828 | ret = ec_install_handlers(ec); | ||
829 | 834 | ||
830 | /* EC is fully operational, allow queries */ | 835 | /* EC is fully operational, allow queries */ |
831 | atomic_set(&ec->query_pending, 0); | 836 | atomic_set(&ec->query_pending, 0); |
832 | |||
833 | return ret; | 837 | return ret; |
834 | } | 838 | } |
835 | 839 | ||
836 | static int acpi_ec_stop(struct acpi_device *device, int type) | 840 | static int acpi_ec_stop(struct acpi_device *device, int type) |
837 | { | 841 | { |
838 | acpi_status status; | ||
839 | struct acpi_ec *ec; | 842 | struct acpi_ec *ec; |
840 | |||
841 | if (!device) | 843 | if (!device) |
842 | return -EINVAL; | 844 | return -EINVAL; |
843 | |||
844 | ec = acpi_driver_data(device); | 845 | ec = acpi_driver_data(device); |
845 | if (!ec) | 846 | if (!ec) |
846 | return -EINVAL; | 847 | return -EINVAL; |
847 | 848 | ec_remove_handlers(ec); | |
848 | /* Don't touch boot EC */ | ||
849 | if (ec == boot_ec) | ||
850 | return 0; | ||
851 | |||
852 | status = acpi_remove_address_space_handler(ec->handle, | ||
853 | ACPI_ADR_SPACE_EC, | ||
854 | &acpi_ec_space_handler); | ||
855 | if (ACPI_FAILURE(status)) | ||
856 | return -ENODEV; | ||
857 | |||
858 | status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler); | ||
859 | if (ACPI_FAILURE(status)) | ||
860 | return -ENODEV; | ||
861 | 849 | ||
862 | return 0; | 850 | return 0; |
863 | } | 851 | } |
@@ -877,7 +865,7 @@ int __init acpi_ec_ecdt_probe(void) | |||
877 | status = acpi_get_table(ACPI_SIG_ECDT, 1, | 865 | status = acpi_get_table(ACPI_SIG_ECDT, 1, |
878 | (struct acpi_table_header **)&ecdt_ptr); | 866 | (struct acpi_table_header **)&ecdt_ptr); |
879 | if (ACPI_SUCCESS(status)) { | 867 | if (ACPI_SUCCESS(status)) { |
880 | printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n\n"); | 868 | printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n"); |
881 | boot_ec->command_addr = ecdt_ptr->control.address; | 869 | boot_ec->command_addr = ecdt_ptr->control.address; |
882 | boot_ec->data_addr = ecdt_ptr->data.address; | 870 | boot_ec->data_addr = ecdt_ptr->data.address; |
883 | boot_ec->gpe = ecdt_ptr->gpe; | 871 | boot_ec->gpe = ecdt_ptr->gpe; |
@@ -899,7 +887,6 @@ int __init acpi_ec_ecdt_probe(void) | |||
899 | error: | 887 | error: |
900 | kfree(boot_ec); | 888 | kfree(boot_ec); |
901 | boot_ec = NULL; | 889 | boot_ec = NULL; |
902 | |||
903 | return -ENODEV; | 890 | return -ENODEV; |
904 | } | 891 | } |
905 | 892 | ||
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c index a1f87b5def2a..e41287815ea1 100644 --- a/drivers/acpi/events/evevent.c +++ b/drivers/acpi/events/evevent.c | |||
@@ -239,10 +239,8 @@ u32 acpi_ev_fixed_event_detect(void) | |||
239 | * Read the fixed feature status and enable registers, as all the cases | 239 | * Read the fixed feature status and enable registers, as all the cases |
240 | * depend on their values. Ignore errors here. | 240 | * depend on their values. Ignore errors here. |
241 | */ | 241 | */ |
242 | (void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, | 242 | (void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); |
243 | ACPI_REGISTER_PM1_STATUS, &fixed_status); | 243 | (void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); |
244 | (void)acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, | ||
245 | ACPI_REGISTER_PM1_ENABLE, &fixed_enable); | ||
246 | 244 | ||
247 | ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, | 245 | ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, |
248 | "Fixed Event Block: Enable %08X Status %08X\n", | 246 | "Fixed Event Block: Enable %08X Status %08X\n", |
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index 1d371fa663f2..73f9c5fb1ba7 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c | |||
@@ -75,8 +75,7 @@ acpi_status acpi_hw_clear_acpi_status(void) | |||
75 | 75 | ||
76 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | 76 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); |
77 | 77 | ||
78 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 78 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, |
79 | ACPI_REGISTER_PM1_STATUS, | ||
80 | ACPI_BITMASK_ALL_FIXED_STATUS); | 79 | ACPI_BITMASK_ALL_FIXED_STATUS); |
81 | if (ACPI_FAILURE(status)) { | 80 | if (ACPI_FAILURE(status)) { |
82 | goto unlock_and_exit; | 81 | goto unlock_and_exit; |
@@ -259,7 +258,7 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) | |||
259 | * | 258 | * |
260 | ******************************************************************************/ | 259 | ******************************************************************************/ |
261 | 260 | ||
262 | acpi_status acpi_get_register(u32 register_id, u32 * return_value) | 261 | acpi_status acpi_get_register_unlocked(u32 register_id, u32 * return_value) |
263 | { | 262 | { |
264 | u32 register_value = 0; | 263 | u32 register_value = 0; |
265 | struct acpi_bit_register_info *bit_reg_info; | 264 | struct acpi_bit_register_info *bit_reg_info; |
@@ -276,8 +275,7 @@ acpi_status acpi_get_register(u32 register_id, u32 * return_value) | |||
276 | 275 | ||
277 | /* Read from the register */ | 276 | /* Read from the register */ |
278 | 277 | ||
279 | status = acpi_hw_register_read(ACPI_MTX_LOCK, | 278 | status = acpi_hw_register_read(bit_reg_info->parent_register, |
280 | bit_reg_info->parent_register, | ||
281 | ®ister_value); | 279 | ®ister_value); |
282 | 280 | ||
283 | if (ACPI_SUCCESS(status)) { | 281 | if (ACPI_SUCCESS(status)) { |
@@ -298,6 +296,16 @@ acpi_status acpi_get_register(u32 register_id, u32 * return_value) | |||
298 | return_ACPI_STATUS(status); | 296 | return_ACPI_STATUS(status); |
299 | } | 297 | } |
300 | 298 | ||
299 | acpi_status acpi_get_register(u32 register_id, u32 * return_value) | ||
300 | { | ||
301 | acpi_status status; | ||
302 | acpi_cpu_flags flags; | ||
303 | flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
304 | status = acpi_get_register_unlocked(register_id, return_value); | ||
305 | acpi_os_release_lock(acpi_gbl_hardware_lock, flags); | ||
306 | return status; | ||
307 | } | ||
308 | |||
301 | ACPI_EXPORT_SYMBOL(acpi_get_register) | 309 | ACPI_EXPORT_SYMBOL(acpi_get_register) |
302 | 310 | ||
303 | /******************************************************************************* | 311 | /******************************************************************************* |
@@ -335,8 +343,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value) | |||
335 | 343 | ||
336 | /* Always do a register read first so we can insert the new bits */ | 344 | /* Always do a register read first so we can insert the new bits */ |
337 | 345 | ||
338 | status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, | 346 | status = acpi_hw_register_read(bit_reg_info->parent_register, |
339 | bit_reg_info->parent_register, | ||
340 | ®ister_value); | 347 | ®ister_value); |
341 | if (ACPI_FAILURE(status)) { | 348 | if (ACPI_FAILURE(status)) { |
342 | goto unlock_and_exit; | 349 | goto unlock_and_exit; |
@@ -363,8 +370,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value) | |||
363 | bit_reg_info-> | 370 | bit_reg_info-> |
364 | access_bit_mask); | 371 | access_bit_mask); |
365 | if (value) { | 372 | if (value) { |
366 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 373 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, |
367 | ACPI_REGISTER_PM1_STATUS, | ||
368 | (u16) value); | 374 | (u16) value); |
369 | register_value = 0; | 375 | register_value = 0; |
370 | } | 376 | } |
@@ -377,8 +383,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value) | |||
377 | bit_reg_info->access_bit_mask, | 383 | bit_reg_info->access_bit_mask, |
378 | value); | 384 | value); |
379 | 385 | ||
380 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 386 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_ENABLE, |
381 | ACPI_REGISTER_PM1_ENABLE, | ||
382 | (u16) register_value); | 387 | (u16) register_value); |
383 | break; | 388 | break; |
384 | 389 | ||
@@ -397,15 +402,13 @@ acpi_status acpi_set_register(u32 register_id, u32 value) | |||
397 | bit_reg_info->access_bit_mask, | 402 | bit_reg_info->access_bit_mask, |
398 | value); | 403 | value); |
399 | 404 | ||
400 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 405 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, |
401 | ACPI_REGISTER_PM1_CONTROL, | ||
402 | (u16) register_value); | 406 | (u16) register_value); |
403 | break; | 407 | break; |
404 | 408 | ||
405 | case ACPI_REGISTER_PM2_CONTROL: | 409 | case ACPI_REGISTER_PM2_CONTROL: |
406 | 410 | ||
407 | status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, | 411 | status = acpi_hw_register_read(ACPI_REGISTER_PM2_CONTROL, |
408 | ACPI_REGISTER_PM2_CONTROL, | ||
409 | ®ister_value); | 412 | ®ister_value); |
410 | if (ACPI_FAILURE(status)) { | 413 | if (ACPI_FAILURE(status)) { |
411 | goto unlock_and_exit; | 414 | goto unlock_and_exit; |
@@ -430,8 +433,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value) | |||
430 | xpm2_control_block. | 433 | xpm2_control_block. |
431 | address))); | 434 | address))); |
432 | 435 | ||
433 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 436 | status = acpi_hw_register_write(ACPI_REGISTER_PM2_CONTROL, |
434 | ACPI_REGISTER_PM2_CONTROL, | ||
435 | (u8) (register_value)); | 437 | (u8) (register_value)); |
436 | break; | 438 | break; |
437 | 439 | ||
@@ -461,8 +463,7 @@ ACPI_EXPORT_SYMBOL(acpi_set_register) | |||
461 | * | 463 | * |
462 | * FUNCTION: acpi_hw_register_read | 464 | * FUNCTION: acpi_hw_register_read |
463 | * | 465 | * |
464 | * PARAMETERS: use_lock - Lock hardware? True/False | 466 | * PARAMETERS: register_id - ACPI Register ID |
465 | * register_id - ACPI Register ID | ||
466 | * return_value - Where the register value is returned | 467 | * return_value - Where the register value is returned |
467 | * | 468 | * |
468 | * RETURN: Status and the value read. | 469 | * RETURN: Status and the value read. |
@@ -471,19 +472,14 @@ ACPI_EXPORT_SYMBOL(acpi_set_register) | |||
471 | * | 472 | * |
472 | ******************************************************************************/ | 473 | ******************************************************************************/ |
473 | acpi_status | 474 | acpi_status |
474 | acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) | 475 | acpi_hw_register_read(u32 register_id, u32 * return_value) |
475 | { | 476 | { |
476 | u32 value1 = 0; | 477 | u32 value1 = 0; |
477 | u32 value2 = 0; | 478 | u32 value2 = 0; |
478 | acpi_status status; | 479 | acpi_status status; |
479 | acpi_cpu_flags lock_flags = 0; | ||
480 | 480 | ||
481 | ACPI_FUNCTION_TRACE(hw_register_read); | 481 | ACPI_FUNCTION_TRACE(hw_register_read); |
482 | 482 | ||
483 | if (ACPI_MTX_LOCK == use_lock) { | ||
484 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
485 | } | ||
486 | |||
487 | switch (register_id) { | 483 | switch (register_id) { |
488 | case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ | 484 | case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ |
489 | 485 | ||
@@ -491,7 +487,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) | |||
491 | acpi_hw_low_level_read(16, &value1, | 487 | acpi_hw_low_level_read(16, &value1, |
492 | &acpi_gbl_FADT.xpm1a_event_block); | 488 | &acpi_gbl_FADT.xpm1a_event_block); |
493 | if (ACPI_FAILURE(status)) { | 489 | if (ACPI_FAILURE(status)) { |
494 | goto unlock_and_exit; | 490 | goto exit; |
495 | } | 491 | } |
496 | 492 | ||
497 | /* PM1B is optional */ | 493 | /* PM1B is optional */ |
@@ -507,7 +503,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) | |||
507 | status = | 503 | status = |
508 | acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable); | 504 | acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable); |
509 | if (ACPI_FAILURE(status)) { | 505 | if (ACPI_FAILURE(status)) { |
510 | goto unlock_and_exit; | 506 | goto exit; |
511 | } | 507 | } |
512 | 508 | ||
513 | /* PM1B is optional */ | 509 | /* PM1B is optional */ |
@@ -523,7 +519,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) | |||
523 | acpi_hw_low_level_read(16, &value1, | 519 | acpi_hw_low_level_read(16, &value1, |
524 | &acpi_gbl_FADT.xpm1a_control_block); | 520 | &acpi_gbl_FADT.xpm1a_control_block); |
525 | if (ACPI_FAILURE(status)) { | 521 | if (ACPI_FAILURE(status)) { |
526 | goto unlock_and_exit; | 522 | goto exit; |
527 | } | 523 | } |
528 | 524 | ||
529 | status = | 525 | status = |
@@ -558,10 +554,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) | |||
558 | break; | 554 | break; |
559 | } | 555 | } |
560 | 556 | ||
561 | unlock_and_exit: | 557 | exit: |
562 | if (ACPI_MTX_LOCK == use_lock) { | ||
563 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); | ||
564 | } | ||
565 | 558 | ||
566 | if (ACPI_SUCCESS(status)) { | 559 | if (ACPI_SUCCESS(status)) { |
567 | *return_value = value1; | 560 | *return_value = value1; |
@@ -574,8 +567,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) | |||
574 | * | 567 | * |
575 | * FUNCTION: acpi_hw_register_write | 568 | * FUNCTION: acpi_hw_register_write |
576 | * | 569 | * |
577 | * PARAMETERS: use_lock - Lock hardware? True/False | 570 | * PARAMETERS: register_id - ACPI Register ID |
578 | * register_id - ACPI Register ID | ||
579 | * Value - The value to write | 571 | * Value - The value to write |
580 | * | 572 | * |
581 | * RETURN: Status | 573 | * RETURN: Status |
@@ -597,28 +589,22 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) | |||
597 | * | 589 | * |
598 | ******************************************************************************/ | 590 | ******************************************************************************/ |
599 | 591 | ||
600 | acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) | 592 | acpi_status acpi_hw_register_write(u32 register_id, u32 value) |
601 | { | 593 | { |
602 | acpi_status status; | 594 | acpi_status status; |
603 | acpi_cpu_flags lock_flags = 0; | ||
604 | u32 read_value; | 595 | u32 read_value; |
605 | 596 | ||
606 | ACPI_FUNCTION_TRACE(hw_register_write); | 597 | ACPI_FUNCTION_TRACE(hw_register_write); |
607 | 598 | ||
608 | if (ACPI_MTX_LOCK == use_lock) { | ||
609 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
610 | } | ||
611 | |||
612 | switch (register_id) { | 599 | switch (register_id) { |
613 | case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ | 600 | case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ |
614 | 601 | ||
615 | /* Perform a read first to preserve certain bits (per ACPI spec) */ | 602 | /* Perform a read first to preserve certain bits (per ACPI spec) */ |
616 | 603 | ||
617 | status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, | 604 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, |
618 | ACPI_REGISTER_PM1_STATUS, | ||
619 | &read_value); | 605 | &read_value); |
620 | if (ACPI_FAILURE(status)) { | 606 | if (ACPI_FAILURE(status)) { |
621 | goto unlock_and_exit; | 607 | goto exit; |
622 | } | 608 | } |
623 | 609 | ||
624 | /* Insert the bits to be preserved */ | 610 | /* Insert the bits to be preserved */ |
@@ -632,7 +618,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) | |||
632 | acpi_hw_low_level_write(16, value, | 618 | acpi_hw_low_level_write(16, value, |
633 | &acpi_gbl_FADT.xpm1a_event_block); | 619 | &acpi_gbl_FADT.xpm1a_event_block); |
634 | if (ACPI_FAILURE(status)) { | 620 | if (ACPI_FAILURE(status)) { |
635 | goto unlock_and_exit; | 621 | goto exit; |
636 | } | 622 | } |
637 | 623 | ||
638 | /* PM1B is optional */ | 624 | /* PM1B is optional */ |
@@ -647,7 +633,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) | |||
647 | status = | 633 | status = |
648 | acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable); | 634 | acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable); |
649 | if (ACPI_FAILURE(status)) { | 635 | if (ACPI_FAILURE(status)) { |
650 | goto unlock_and_exit; | 636 | goto exit; |
651 | } | 637 | } |
652 | 638 | ||
653 | /* PM1B is optional */ | 639 | /* PM1B is optional */ |
@@ -661,11 +647,10 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) | |||
661 | /* | 647 | /* |
662 | * Perform a read first to preserve certain bits (per ACPI spec) | 648 | * Perform a read first to preserve certain bits (per ACPI spec) |
663 | */ | 649 | */ |
664 | status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, | 650 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, |
665 | ACPI_REGISTER_PM1_CONTROL, | ||
666 | &read_value); | 651 | &read_value); |
667 | if (ACPI_FAILURE(status)) { | 652 | if (ACPI_FAILURE(status)) { |
668 | goto unlock_and_exit; | 653 | goto exit; |
669 | } | 654 | } |
670 | 655 | ||
671 | /* Insert the bits to be preserved */ | 656 | /* Insert the bits to be preserved */ |
@@ -679,7 +664,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) | |||
679 | acpi_hw_low_level_write(16, value, | 664 | acpi_hw_low_level_write(16, value, |
680 | &acpi_gbl_FADT.xpm1a_control_block); | 665 | &acpi_gbl_FADT.xpm1a_control_block); |
681 | if (ACPI_FAILURE(status)) { | 666 | if (ACPI_FAILURE(status)) { |
682 | goto unlock_and_exit; | 667 | goto exit; |
683 | } | 668 | } |
684 | 669 | ||
685 | status = | 670 | status = |
@@ -728,11 +713,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) | |||
728 | break; | 713 | break; |
729 | } | 714 | } |
730 | 715 | ||
731 | unlock_and_exit: | 716 | exit: |
732 | if (ACPI_MTX_LOCK == use_lock) { | ||
733 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); | ||
734 | } | ||
735 | |||
736 | return_ACPI_STATUS(status); | 717 | return_ACPI_STATUS(status); |
737 | } | 718 | } |
738 | 719 | ||
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index cf69c0040a39..81b248429703 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c | |||
@@ -234,15 +234,11 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) | |||
234 | "While executing method _SST")); | 234 | "While executing method _SST")); |
235 | } | 235 | } |
236 | 236 | ||
237 | /* | 237 | /* Disable/Clear all GPEs */ |
238 | * 1) Disable/Clear all GPEs | 238 | |
239 | */ | ||
240 | status = acpi_hw_disable_all_gpes(); | 239 | status = acpi_hw_disable_all_gpes(); |
241 | if (ACPI_FAILURE(status)) { | ||
242 | return_ACPI_STATUS(status); | ||
243 | } | ||
244 | 240 | ||
245 | return_ACPI_STATUS(AE_OK); | 241 | return_ACPI_STATUS(status); |
246 | } | 242 | } |
247 | 243 | ||
248 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) | 244 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) |
@@ -313,8 +309,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) | |||
313 | 309 | ||
314 | /* Get current value of PM1A control */ | 310 | /* Get current value of PM1A control */ |
315 | 311 | ||
316 | status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, | 312 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); |
317 | ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); | ||
318 | if (ACPI_FAILURE(status)) { | 313 | if (ACPI_FAILURE(status)) { |
319 | return_ACPI_STATUS(status); | 314 | return_ACPI_STATUS(status); |
320 | } | 315 | } |
@@ -341,15 +336,13 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) | |||
341 | 336 | ||
342 | /* Write #1: fill in SLP_TYP data */ | 337 | /* Write #1: fill in SLP_TYP data */ |
343 | 338 | ||
344 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 339 | status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, |
345 | ACPI_REGISTER_PM1A_CONTROL, | ||
346 | PM1Acontrol); | 340 | PM1Acontrol); |
347 | if (ACPI_FAILURE(status)) { | 341 | if (ACPI_FAILURE(status)) { |
348 | return_ACPI_STATUS(status); | 342 | return_ACPI_STATUS(status); |
349 | } | 343 | } |
350 | 344 | ||
351 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 345 | status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, |
352 | ACPI_REGISTER_PM1B_CONTROL, | ||
353 | PM1Bcontrol); | 346 | PM1Bcontrol); |
354 | if (ACPI_FAILURE(status)) { | 347 | if (ACPI_FAILURE(status)) { |
355 | return_ACPI_STATUS(status); | 348 | return_ACPI_STATUS(status); |
@@ -364,15 +357,13 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) | |||
364 | 357 | ||
365 | ACPI_FLUSH_CPU_CACHE(); | 358 | ACPI_FLUSH_CPU_CACHE(); |
366 | 359 | ||
367 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 360 | status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, |
368 | ACPI_REGISTER_PM1A_CONTROL, | ||
369 | PM1Acontrol); | 361 | PM1Acontrol); |
370 | if (ACPI_FAILURE(status)) { | 362 | if (ACPI_FAILURE(status)) { |
371 | return_ACPI_STATUS(status); | 363 | return_ACPI_STATUS(status); |
372 | } | 364 | } |
373 | 365 | ||
374 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 366 | status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, |
375 | ACPI_REGISTER_PM1B_CONTROL, | ||
376 | PM1Bcontrol); | 367 | PM1Bcontrol); |
377 | if (ACPI_FAILURE(status)) { | 368 | if (ACPI_FAILURE(status)) { |
378 | return_ACPI_STATUS(status); | 369 | return_ACPI_STATUS(status); |
@@ -392,8 +383,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) | |||
392 | */ | 383 | */ |
393 | acpi_os_stall(10000000); | 384 | acpi_os_stall(10000000); |
394 | 385 | ||
395 | status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 386 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, |
396 | ACPI_REGISTER_PM1_CONTROL, | ||
397 | sleep_enable_reg_info-> | 387 | sleep_enable_reg_info-> |
398 | access_bit_mask); | 388 | access_bit_mask); |
399 | if (ACPI_FAILURE(status)) { | 389 | if (ACPI_FAILURE(status)) { |
@@ -404,7 +394,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) | |||
404 | /* Wait until we enter sleep state */ | 394 | /* Wait until we enter sleep state */ |
405 | 395 | ||
406 | do { | 396 | do { |
407 | status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value); | 397 | status = acpi_get_register_unlocked(ACPI_BITREG_WAKE_STATUS, |
398 | &in_value); | ||
408 | if (ACPI_FAILURE(status)) { | 399 | if (ACPI_FAILURE(status)) { |
409 | return_ACPI_STATUS(status); | 400 | return_ACPI_STATUS(status); |
410 | } | 401 | } |
@@ -520,8 +511,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state) | |||
520 | 511 | ||
521 | /* Get current value of PM1A control */ | 512 | /* Get current value of PM1A control */ |
522 | 513 | ||
523 | status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, | 514 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, |
524 | ACPI_REGISTER_PM1_CONTROL, | ||
525 | &PM1Acontrol); | 515 | &PM1Acontrol); |
526 | if (ACPI_SUCCESS(status)) { | 516 | if (ACPI_SUCCESS(status)) { |
527 | 517 | ||
@@ -543,11 +533,9 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state) | |||
543 | 533 | ||
544 | /* Just ignore any errors */ | 534 | /* Just ignore any errors */ |
545 | 535 | ||
546 | (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 536 | (void)acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, |
547 | ACPI_REGISTER_PM1A_CONTROL, | ||
548 | PM1Acontrol); | 537 | PM1Acontrol); |
549 | (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, | 538 | (void)acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, |
550 | ACPI_REGISTER_PM1B_CONTROL, | ||
551 | PM1Bcontrol); | 539 | PM1Bcontrol); |
552 | } | 540 | } |
553 | } | 541 | } |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 352cf81af581..aabc6ca4a81c 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -1043,14 +1043,6 @@ static int __init acpi_wake_gpes_always_on_setup(char *str) | |||
1043 | __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); | 1043 | __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); |
1044 | 1044 | ||
1045 | /* | 1045 | /* |
1046 | * max_cstate is defined in the base kernel so modules can | ||
1047 | * change it w/o depending on the state of the processor module. | ||
1048 | */ | ||
1049 | unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; | ||
1050 | |||
1051 | EXPORT_SYMBOL(max_cstate); | ||
1052 | |||
1053 | /* | ||
1054 | * Acquire a spinlock. | 1046 | * Acquire a spinlock. |
1055 | * | 1047 | * |
1056 | * handle is a pointer to the spinlock_t. | 1048 | * handle is a pointer to the spinlock_t. |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 9f11dc296cdd..235a51e328c3 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/seq_file.h> | 44 | #include <linux/seq_file.h> |
45 | #include <linux/dmi.h> | 45 | #include <linux/dmi.h> |
46 | #include <linux/moduleparam.h> | 46 | #include <linux/moduleparam.h> |
47 | #include <linux/cpuidle.h> | ||
47 | 48 | ||
48 | #include <asm/io.h> | 49 | #include <asm/io.h> |
49 | #include <asm/system.h> | 50 | #include <asm/system.h> |
@@ -421,12 +422,6 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, | |||
421 | return 0; | 422 | return 0; |
422 | } | 423 | } |
423 | 424 | ||
424 | #ifdef CONFIG_IA64 | ||
425 | #define arch_cpu_to_apicid ia64_cpu_to_sapicid | ||
426 | #else | ||
427 | #define arch_cpu_to_apicid x86_cpu_to_apicid | ||
428 | #endif | ||
429 | |||
430 | static int map_madt_entry(u32 acpi_id) | 425 | static int map_madt_entry(u32 acpi_id) |
431 | { | 426 | { |
432 | unsigned long madt_end, entry; | 427 | unsigned long madt_end, entry; |
@@ -500,7 +495,7 @@ static int get_cpu_id(acpi_handle handle, u32 acpi_id) | |||
500 | return apic_id; | 495 | return apic_id; |
501 | 496 | ||
502 | for (i = 0; i < NR_CPUS; ++i) { | 497 | for (i = 0; i < NR_CPUS; ++i) { |
503 | if (arch_cpu_to_apicid[i] == apic_id) | 498 | if (cpu_physical_id(i) == apic_id) |
504 | return i; | 499 | return i; |
505 | } | 500 | } |
506 | return -1; | 501 | return -1; |
@@ -1049,11 +1044,13 @@ static int __init acpi_processor_init(void) | |||
1049 | return -ENOMEM; | 1044 | return -ENOMEM; |
1050 | acpi_processor_dir->owner = THIS_MODULE; | 1045 | acpi_processor_dir->owner = THIS_MODULE; |
1051 | 1046 | ||
1047 | result = cpuidle_register_driver(&acpi_idle_driver); | ||
1048 | if (result < 0) | ||
1049 | goto out_proc; | ||
1050 | |||
1052 | result = acpi_bus_register_driver(&acpi_processor_driver); | 1051 | result = acpi_bus_register_driver(&acpi_processor_driver); |
1053 | if (result < 0) { | 1052 | if (result < 0) |
1054 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | 1053 | goto out_cpuidle; |
1055 | return result; | ||
1056 | } | ||
1057 | 1054 | ||
1058 | acpi_processor_install_hotplug_notify(); | 1055 | acpi_processor_install_hotplug_notify(); |
1059 | 1056 | ||
@@ -1062,11 +1059,18 @@ static int __init acpi_processor_init(void) | |||
1062 | acpi_processor_ppc_init(); | 1059 | acpi_processor_ppc_init(); |
1063 | 1060 | ||
1064 | return 0; | 1061 | return 0; |
1062 | |||
1063 | out_cpuidle: | ||
1064 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
1065 | |||
1066 | out_proc: | ||
1067 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
1068 | |||
1069 | return result; | ||
1065 | } | 1070 | } |
1066 | 1071 | ||
1067 | static void __exit acpi_processor_exit(void) | 1072 | static void __exit acpi_processor_exit(void) |
1068 | { | 1073 | { |
1069 | |||
1070 | acpi_processor_ppc_exit(); | 1074 | acpi_processor_ppc_exit(); |
1071 | 1075 | ||
1072 | acpi_thermal_cpufreq_exit(); | 1076 | acpi_thermal_cpufreq_exit(); |
@@ -1075,6 +1079,8 @@ static void __exit acpi_processor_exit(void) | |||
1075 | 1079 | ||
1076 | acpi_bus_unregister_driver(&acpi_processor_driver); | 1080 | acpi_bus_unregister_driver(&acpi_processor_driver); |
1077 | 1081 | ||
1082 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
1083 | |||
1078 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | 1084 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); |
1079 | 1085 | ||
1080 | return; | 1086 | return; |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 1f6fb38de017..f996d0e37689 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/sched.h> /* need_resched() */ | 40 | #include <linux/sched.h> /* need_resched() */ |
41 | #include <linux/latency.h> | 41 | #include <linux/latency.h> |
42 | #include <linux/clockchips.h> | 42 | #include <linux/clockchips.h> |
43 | #include <linux/cpuidle.h> | ||
43 | 44 | ||
44 | /* | 45 | /* |
45 | * Include the apic definitions for x86 to have the APIC timer related defines | 46 | * Include the apic definitions for x86 to have the APIC timer related defines |
@@ -64,14 +65,22 @@ ACPI_MODULE_NAME("processor_idle"); | |||
64 | #define ACPI_PROCESSOR_FILE_POWER "power" | 65 | #define ACPI_PROCESSOR_FILE_POWER "power" |
65 | #define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) | 66 | #define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) |
66 | #define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) | 67 | #define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) |
68 | #ifndef CONFIG_CPU_IDLE | ||
67 | #define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ | 69 | #define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ |
68 | #define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */ | 70 | #define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */ |
69 | static void (*pm_idle_save) (void) __read_mostly; | 71 | static void (*pm_idle_save) (void) __read_mostly; |
70 | module_param(max_cstate, uint, 0644); | 72 | #else |
73 | #define C2_OVERHEAD 1 /* 1us */ | ||
74 | #define C3_OVERHEAD 1 /* 1us */ | ||
75 | #endif | ||
76 | #define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000)) | ||
71 | 77 | ||
78 | static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; | ||
79 | module_param(max_cstate, uint, 0000); | ||
72 | static unsigned int nocst __read_mostly; | 80 | static unsigned int nocst __read_mostly; |
73 | module_param(nocst, uint, 0000); | 81 | module_param(nocst, uint, 0000); |
74 | 82 | ||
83 | #ifndef CONFIG_CPU_IDLE | ||
75 | /* | 84 | /* |
76 | * bm_history -- bit-mask with a bit per jiffy of bus-master activity | 85 | * bm_history -- bit-mask with a bit per jiffy of bus-master activity |
77 | * 1000 HZ: 0xFFFFFFFF: 32 jiffies = 32ms | 86 | * 1000 HZ: 0xFFFFFFFF: 32 jiffies = 32ms |
@@ -82,9 +91,10 @@ module_param(nocst, uint, 0000); | |||
82 | static unsigned int bm_history __read_mostly = | 91 | static unsigned int bm_history __read_mostly = |
83 | (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1)); | 92 | (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1)); |
84 | module_param(bm_history, uint, 0644); | 93 | module_param(bm_history, uint, 0644); |
85 | /* -------------------------------------------------------------------------- | 94 | |
86 | Power Management | 95 | static int acpi_processor_set_power_policy(struct acpi_processor *pr); |
87 | -------------------------------------------------------------------------- */ | 96 | |
97 | #endif | ||
88 | 98 | ||
89 | /* | 99 | /* |
90 | * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. | 100 | * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. |
@@ -177,6 +187,18 @@ static inline u32 ticks_elapsed(u32 t1, u32 t2) | |||
177 | return ((0xFFFFFFFF - t1) + t2); | 187 | return ((0xFFFFFFFF - t1) + t2); |
178 | } | 188 | } |
179 | 189 | ||
190 | static inline u32 ticks_elapsed_in_us(u32 t1, u32 t2) | ||
191 | { | ||
192 | if (t2 >= t1) | ||
193 | return PM_TIMER_TICKS_TO_US(t2 - t1); | ||
194 | else if (!(acpi_gbl_FADT.flags & ACPI_FADT_32BIT_TIMER)) | ||
195 | return PM_TIMER_TICKS_TO_US(((0x00FFFFFF - t1) + t2) & 0x00FFFFFF); | ||
196 | else | ||
197 | return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2); | ||
198 | } | ||
199 | |||
200 | #ifndef CONFIG_CPU_IDLE | ||
201 | |||
180 | static void | 202 | static void |
181 | acpi_processor_power_activate(struct acpi_processor *pr, | 203 | acpi_processor_power_activate(struct acpi_processor *pr, |
182 | struct acpi_processor_cx *new) | 204 | struct acpi_processor_cx *new) |
@@ -248,6 +270,7 @@ static void acpi_cstate_enter(struct acpi_processor_cx *cstate) | |||
248 | unused = inl(acpi_gbl_FADT.xpm_timer_block.address); | 270 | unused = inl(acpi_gbl_FADT.xpm_timer_block.address); |
249 | } | 271 | } |
250 | } | 272 | } |
273 | #endif /* !CONFIG_CPU_IDLE */ | ||
251 | 274 | ||
252 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | 275 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 |
253 | 276 | ||
@@ -330,6 +353,7 @@ int acpi_processor_resume(struct acpi_device * device) | |||
330 | return 0; | 353 | return 0; |
331 | } | 354 | } |
332 | 355 | ||
356 | #ifndef CONFIG_CPU_IDLE | ||
333 | static void acpi_processor_idle(void) | 357 | static void acpi_processor_idle(void) |
334 | { | 358 | { |
335 | struct acpi_processor *pr = NULL; | 359 | struct acpi_processor *pr = NULL; |
@@ -427,7 +451,7 @@ static void acpi_processor_idle(void) | |||
427 | * an SMP system. We do it here instead of doing it at _CST/P_LVL | 451 | * an SMP system. We do it here instead of doing it at _CST/P_LVL |
428 | * detection phase, to work cleanly with logical CPU hotplug. | 452 | * detection phase, to work cleanly with logical CPU hotplug. |
429 | */ | 453 | */ |
430 | if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) && | 454 | if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) && |
431 | !pr->flags.has_cst && !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) | 455 | !pr->flags.has_cst && !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) |
432 | cx = &pr->power.states[ACPI_STATE_C1]; | 456 | cx = &pr->power.states[ACPI_STATE_C1]; |
433 | #endif | 457 | #endif |
@@ -727,6 +751,7 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr) | |||
727 | 751 | ||
728 | return 0; | 752 | return 0; |
729 | } | 753 | } |
754 | #endif /* !CONFIG_CPU_IDLE */ | ||
730 | 755 | ||
731 | static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) | 756 | static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) |
732 | { | 757 | { |
@@ -744,7 +769,7 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) | |||
744 | #ifndef CONFIG_HOTPLUG_CPU | 769 | #ifndef CONFIG_HOTPLUG_CPU |
745 | /* | 770 | /* |
746 | * Check for P_LVL2_UP flag before entering C2 and above on | 771 | * Check for P_LVL2_UP flag before entering C2 and above on |
747 | * an SMP system. | 772 | * an SMP system. |
748 | */ | 773 | */ |
749 | if ((num_online_cpus() > 1) && | 774 | if ((num_online_cpus() > 1) && |
750 | !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) | 775 | !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) |
@@ -945,7 +970,12 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) | |||
945 | * Normalize the C2 latency to expidite policy | 970 | * Normalize the C2 latency to expidite policy |
946 | */ | 971 | */ |
947 | cx->valid = 1; | 972 | cx->valid = 1; |
973 | |||
974 | #ifndef CONFIG_CPU_IDLE | ||
948 | cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); | 975 | cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); |
976 | #else | ||
977 | cx->latency_ticks = cx->latency; | ||
978 | #endif | ||
949 | 979 | ||
950 | return; | 980 | return; |
951 | } | 981 | } |
@@ -1025,7 +1055,12 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, | |||
1025 | * use this in our C3 policy | 1055 | * use this in our C3 policy |
1026 | */ | 1056 | */ |
1027 | cx->valid = 1; | 1057 | cx->valid = 1; |
1058 | |||
1059 | #ifndef CONFIG_CPU_IDLE | ||
1028 | cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); | 1060 | cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); |
1061 | #else | ||
1062 | cx->latency_ticks = cx->latency; | ||
1063 | #endif | ||
1029 | 1064 | ||
1030 | return; | 1065 | return; |
1031 | } | 1066 | } |
@@ -1090,6 +1125,7 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr) | |||
1090 | 1125 | ||
1091 | pr->power.count = acpi_processor_power_verify(pr); | 1126 | pr->power.count = acpi_processor_power_verify(pr); |
1092 | 1127 | ||
1128 | #ifndef CONFIG_CPU_IDLE | ||
1093 | /* | 1129 | /* |
1094 | * Set Default Policy | 1130 | * Set Default Policy |
1095 | * ------------------ | 1131 | * ------------------ |
@@ -1101,6 +1137,7 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr) | |||
1101 | result = acpi_processor_set_power_policy(pr); | 1137 | result = acpi_processor_set_power_policy(pr); |
1102 | if (result) | 1138 | if (result) |
1103 | return result; | 1139 | return result; |
1140 | #endif | ||
1104 | 1141 | ||
1105 | /* | 1142 | /* |
1106 | * if one state of type C2 or C3 is available, mark this | 1143 | * if one state of type C2 or C3 is available, mark this |
@@ -1117,35 +1154,6 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr) | |||
1117 | return 0; | 1154 | return 0; |
1118 | } | 1155 | } |
1119 | 1156 | ||
1120 | int acpi_processor_cst_has_changed(struct acpi_processor *pr) | ||
1121 | { | ||
1122 | int result = 0; | ||
1123 | |||
1124 | |||
1125 | if (!pr) | ||
1126 | return -EINVAL; | ||
1127 | |||
1128 | if (nocst) { | ||
1129 | return -ENODEV; | ||
1130 | } | ||
1131 | |||
1132 | if (!pr->flags.power_setup_done) | ||
1133 | return -ENODEV; | ||
1134 | |||
1135 | /* Fall back to the default idle loop */ | ||
1136 | pm_idle = pm_idle_save; | ||
1137 | synchronize_sched(); /* Relies on interrupts forcing exit from idle. */ | ||
1138 | |||
1139 | pr->flags.power = 0; | ||
1140 | result = acpi_processor_get_power_info(pr); | ||
1141 | if ((pr->flags.power == 1) && (pr->flags.power_setup_done)) | ||
1142 | pm_idle = acpi_processor_idle; | ||
1143 | |||
1144 | return result; | ||
1145 | } | ||
1146 | |||
1147 | /* proc interface */ | ||
1148 | |||
1149 | static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) | 1157 | static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) |
1150 | { | 1158 | { |
1151 | struct acpi_processor *pr = seq->private; | 1159 | struct acpi_processor *pr = seq->private; |
@@ -1227,6 +1235,35 @@ static const struct file_operations acpi_processor_power_fops = { | |||
1227 | .release = single_release, | 1235 | .release = single_release, |
1228 | }; | 1236 | }; |
1229 | 1237 | ||
1238 | #ifndef CONFIG_CPU_IDLE | ||
1239 | |||
1240 | int acpi_processor_cst_has_changed(struct acpi_processor *pr) | ||
1241 | { | ||
1242 | int result = 0; | ||
1243 | |||
1244 | |||
1245 | if (!pr) | ||
1246 | return -EINVAL; | ||
1247 | |||
1248 | if (nocst) { | ||
1249 | return -ENODEV; | ||
1250 | } | ||
1251 | |||
1252 | if (!pr->flags.power_setup_done) | ||
1253 | return -ENODEV; | ||
1254 | |||
1255 | /* Fall back to the default idle loop */ | ||
1256 | pm_idle = pm_idle_save; | ||
1257 | synchronize_sched(); /* Relies on interrupts forcing exit from idle. */ | ||
1258 | |||
1259 | pr->flags.power = 0; | ||
1260 | result = acpi_processor_get_power_info(pr); | ||
1261 | if ((pr->flags.power == 1) && (pr->flags.power_setup_done)) | ||
1262 | pm_idle = acpi_processor_idle; | ||
1263 | |||
1264 | return result; | ||
1265 | } | ||
1266 | |||
1230 | #ifdef CONFIG_SMP | 1267 | #ifdef CONFIG_SMP |
1231 | static void smp_callback(void *v) | 1268 | static void smp_callback(void *v) |
1232 | { | 1269 | { |
@@ -1249,7 +1286,366 @@ static int acpi_processor_latency_notify(struct notifier_block *b, | |||
1249 | static struct notifier_block acpi_processor_latency_notifier = { | 1286 | static struct notifier_block acpi_processor_latency_notifier = { |
1250 | .notifier_call = acpi_processor_latency_notify, | 1287 | .notifier_call = acpi_processor_latency_notify, |
1251 | }; | 1288 | }; |
1289 | |||
1290 | #endif | ||
1291 | |||
1292 | #else /* CONFIG_CPU_IDLE */ | ||
1293 | |||
1294 | /** | ||
1295 | * acpi_idle_bm_check - checks if bus master activity was detected | ||
1296 | */ | ||
1297 | static int acpi_idle_bm_check(void) | ||
1298 | { | ||
1299 | u32 bm_status = 0; | ||
1300 | |||
1301 | acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status); | ||
1302 | if (bm_status) | ||
1303 | acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1); | ||
1304 | /* | ||
1305 | * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect | ||
1306 | * the true state of bus mastering activity; forcing us to | ||
1307 | * manually check the BMIDEA bit of each IDE channel. | ||
1308 | */ | ||
1309 | else if (errata.piix4.bmisx) { | ||
1310 | if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) | ||
1311 | || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) | ||
1312 | bm_status = 1; | ||
1313 | } | ||
1314 | return bm_status; | ||
1315 | } | ||
1316 | |||
1317 | /** | ||
1318 | * acpi_idle_update_bm_rld - updates the BM_RLD bit depending on target state | ||
1319 | * @pr: the processor | ||
1320 | * @target: the new target state | ||
1321 | */ | ||
1322 | static inline void acpi_idle_update_bm_rld(struct acpi_processor *pr, | ||
1323 | struct acpi_processor_cx *target) | ||
1324 | { | ||
1325 | if (pr->flags.bm_rld_set && target->type != ACPI_STATE_C3) { | ||
1326 | acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0); | ||
1327 | pr->flags.bm_rld_set = 0; | ||
1328 | } | ||
1329 | |||
1330 | if (!pr->flags.bm_rld_set && target->type == ACPI_STATE_C3) { | ||
1331 | acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1); | ||
1332 | pr->flags.bm_rld_set = 1; | ||
1333 | } | ||
1334 | } | ||
1335 | |||
1336 | /** | ||
1337 | * acpi_idle_do_entry - a helper function that does C2 and C3 type entry | ||
1338 | * @cx: cstate data | ||
1339 | */ | ||
1340 | static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx) | ||
1341 | { | ||
1342 | if (cx->space_id == ACPI_CSTATE_FFH) { | ||
1343 | /* Call into architectural FFH based C-state */ | ||
1344 | acpi_processor_ffh_cstate_enter(cx); | ||
1345 | } else { | ||
1346 | int unused; | ||
1347 | /* IO port based C-state */ | ||
1348 | inb(cx->address); | ||
1349 | /* Dummy wait op - must do something useless after P_LVL2 read | ||
1350 | because chipsets cannot guarantee that STPCLK# signal | ||
1351 | gets asserted in time to freeze execution properly. */ | ||
1352 | unused = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1353 | } | ||
1354 | } | ||
1355 | |||
1356 | /** | ||
1357 | * acpi_idle_enter_c1 - enters an ACPI C1 state-type | ||
1358 | * @dev: the target CPU | ||
1359 | * @state: the state data | ||
1360 | * | ||
1361 | * This is equivalent to the HALT instruction. | ||
1362 | */ | ||
1363 | static int acpi_idle_enter_c1(struct cpuidle_device *dev, | ||
1364 | struct cpuidle_state *state) | ||
1365 | { | ||
1366 | struct acpi_processor *pr; | ||
1367 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); | ||
1368 | pr = processors[smp_processor_id()]; | ||
1369 | |||
1370 | if (unlikely(!pr)) | ||
1371 | return 0; | ||
1372 | |||
1373 | if (pr->flags.bm_check) | ||
1374 | acpi_idle_update_bm_rld(pr, cx); | ||
1375 | |||
1376 | current_thread_info()->status &= ~TS_POLLING; | ||
1377 | /* | ||
1378 | * TS_POLLING-cleared state must be visible before we test | ||
1379 | * NEED_RESCHED: | ||
1380 | */ | ||
1381 | smp_mb(); | ||
1382 | if (!need_resched()) | ||
1383 | safe_halt(); | ||
1384 | current_thread_info()->status |= TS_POLLING; | ||
1385 | |||
1386 | cx->usage++; | ||
1387 | |||
1388 | return 0; | ||
1389 | } | ||
1390 | |||
1391 | /** | ||
1392 | * acpi_idle_enter_simple - enters an ACPI state without BM handling | ||
1393 | * @dev: the target CPU | ||
1394 | * @state: the state data | ||
1395 | */ | ||
1396 | static int acpi_idle_enter_simple(struct cpuidle_device *dev, | ||
1397 | struct cpuidle_state *state) | ||
1398 | { | ||
1399 | struct acpi_processor *pr; | ||
1400 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); | ||
1401 | u32 t1, t2; | ||
1402 | pr = processors[smp_processor_id()]; | ||
1403 | |||
1404 | if (unlikely(!pr)) | ||
1405 | return 0; | ||
1406 | |||
1407 | if (acpi_idle_suspend) | ||
1408 | return(acpi_idle_enter_c1(dev, state)); | ||
1409 | |||
1410 | if (pr->flags.bm_check) | ||
1411 | acpi_idle_update_bm_rld(pr, cx); | ||
1412 | |||
1413 | local_irq_disable(); | ||
1414 | current_thread_info()->status &= ~TS_POLLING; | ||
1415 | /* | ||
1416 | * TS_POLLING-cleared state must be visible before we test | ||
1417 | * NEED_RESCHED: | ||
1418 | */ | ||
1419 | smp_mb(); | ||
1420 | |||
1421 | if (unlikely(need_resched())) { | ||
1422 | current_thread_info()->status |= TS_POLLING; | ||
1423 | local_irq_enable(); | ||
1424 | return 0; | ||
1425 | } | ||
1426 | |||
1427 | if (cx->type == ACPI_STATE_C3) | ||
1428 | ACPI_FLUSH_CPU_CACHE(); | ||
1429 | |||
1430 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1431 | acpi_state_timer_broadcast(pr, cx, 1); | ||
1432 | acpi_idle_do_entry(cx); | ||
1433 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1434 | |||
1435 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) | ||
1436 | /* TSC could halt in idle, so notify users */ | ||
1437 | mark_tsc_unstable("TSC halts in idle");; | ||
1438 | #endif | ||
1439 | |||
1440 | local_irq_enable(); | ||
1441 | current_thread_info()->status |= TS_POLLING; | ||
1442 | |||
1443 | cx->usage++; | ||
1444 | |||
1445 | acpi_state_timer_broadcast(pr, cx, 0); | ||
1446 | cx->time += ticks_elapsed(t1, t2); | ||
1447 | return ticks_elapsed_in_us(t1, t2); | ||
1448 | } | ||
1449 | |||
1450 | static int c3_cpu_count; | ||
1451 | static DEFINE_SPINLOCK(c3_lock); | ||
1452 | |||
1453 | /** | ||
1454 | * acpi_idle_enter_bm - enters C3 with proper BM handling | ||
1455 | * @dev: the target CPU | ||
1456 | * @state: the state data | ||
1457 | * | ||
1458 | * If BM is detected, the deepest non-C3 idle state is entered instead. | ||
1459 | */ | ||
1460 | static int acpi_idle_enter_bm(struct cpuidle_device *dev, | ||
1461 | struct cpuidle_state *state) | ||
1462 | { | ||
1463 | struct acpi_processor *pr; | ||
1464 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); | ||
1465 | u32 t1, t2; | ||
1466 | pr = processors[smp_processor_id()]; | ||
1467 | |||
1468 | if (unlikely(!pr)) | ||
1469 | return 0; | ||
1470 | |||
1471 | if (acpi_idle_suspend) | ||
1472 | return(acpi_idle_enter_c1(dev, state)); | ||
1473 | |||
1474 | local_irq_disable(); | ||
1475 | current_thread_info()->status &= ~TS_POLLING; | ||
1476 | /* | ||
1477 | * TS_POLLING-cleared state must be visible before we test | ||
1478 | * NEED_RESCHED: | ||
1479 | */ | ||
1480 | smp_mb(); | ||
1481 | |||
1482 | if (unlikely(need_resched())) { | ||
1483 | current_thread_info()->status |= TS_POLLING; | ||
1484 | local_irq_enable(); | ||
1485 | return 0; | ||
1486 | } | ||
1487 | |||
1488 | /* | ||
1489 | * Must be done before busmaster disable as we might need to | ||
1490 | * access HPET ! | ||
1491 | */ | ||
1492 | acpi_state_timer_broadcast(pr, cx, 1); | ||
1493 | |||
1494 | if (acpi_idle_bm_check()) { | ||
1495 | cx = pr->power.bm_state; | ||
1496 | |||
1497 | acpi_idle_update_bm_rld(pr, cx); | ||
1498 | |||
1499 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1500 | acpi_idle_do_entry(cx); | ||
1501 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1502 | } else { | ||
1503 | acpi_idle_update_bm_rld(pr, cx); | ||
1504 | |||
1505 | spin_lock(&c3_lock); | ||
1506 | c3_cpu_count++; | ||
1507 | /* Disable bus master arbitration when all CPUs are in C3 */ | ||
1508 | if (c3_cpu_count == num_online_cpus()) | ||
1509 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); | ||
1510 | spin_unlock(&c3_lock); | ||
1511 | |||
1512 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1513 | acpi_idle_do_entry(cx); | ||
1514 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1515 | |||
1516 | spin_lock(&c3_lock); | ||
1517 | /* Re-enable bus master arbitration */ | ||
1518 | if (c3_cpu_count == num_online_cpus()) | ||
1519 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); | ||
1520 | c3_cpu_count--; | ||
1521 | spin_unlock(&c3_lock); | ||
1522 | } | ||
1523 | |||
1524 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) | ||
1525 | /* TSC could halt in idle, so notify users */ | ||
1526 | mark_tsc_unstable("TSC halts in idle"); | ||
1527 | #endif | ||
1528 | |||
1529 | local_irq_enable(); | ||
1530 | current_thread_info()->status |= TS_POLLING; | ||
1531 | |||
1532 | cx->usage++; | ||
1533 | |||
1534 | acpi_state_timer_broadcast(pr, cx, 0); | ||
1535 | cx->time += ticks_elapsed(t1, t2); | ||
1536 | return ticks_elapsed_in_us(t1, t2); | ||
1537 | } | ||
1538 | |||
1539 | struct cpuidle_driver acpi_idle_driver = { | ||
1540 | .name = "acpi_idle", | ||
1541 | .owner = THIS_MODULE, | ||
1542 | }; | ||
1543 | |||
1544 | /** | ||
1545 | * acpi_processor_setup_cpuidle - prepares and configures CPUIDLE | ||
1546 | * @pr: the ACPI processor | ||
1547 | */ | ||
1548 | static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | ||
1549 | { | ||
1550 | int i, count = 0; | ||
1551 | struct acpi_processor_cx *cx; | ||
1552 | struct cpuidle_state *state; | ||
1553 | struct cpuidle_device *dev = &pr->power.dev; | ||
1554 | |||
1555 | if (!pr->flags.power_setup_done) | ||
1556 | return -EINVAL; | ||
1557 | |||
1558 | if (pr->flags.power == 0) { | ||
1559 | return -EINVAL; | ||
1560 | } | ||
1561 | |||
1562 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { | ||
1563 | cx = &pr->power.states[i]; | ||
1564 | state = &dev->states[count]; | ||
1565 | |||
1566 | if (!cx->valid) | ||
1567 | continue; | ||
1568 | |||
1569 | #ifdef CONFIG_HOTPLUG_CPU | ||
1570 | if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) && | ||
1571 | !pr->flags.has_cst && | ||
1572 | !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) | ||
1573 | continue; | ||
1252 | #endif | 1574 | #endif |
1575 | cpuidle_set_statedata(state, cx); | ||
1576 | |||
1577 | snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); | ||
1578 | state->exit_latency = cx->latency; | ||
1579 | state->target_residency = cx->latency * 6; | ||
1580 | state->power_usage = cx->power; | ||
1581 | |||
1582 | state->flags = 0; | ||
1583 | switch (cx->type) { | ||
1584 | case ACPI_STATE_C1: | ||
1585 | state->flags |= CPUIDLE_FLAG_SHALLOW; | ||
1586 | state->enter = acpi_idle_enter_c1; | ||
1587 | break; | ||
1588 | |||
1589 | case ACPI_STATE_C2: | ||
1590 | state->flags |= CPUIDLE_FLAG_BALANCED; | ||
1591 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | ||
1592 | state->enter = acpi_idle_enter_simple; | ||
1593 | break; | ||
1594 | |||
1595 | case ACPI_STATE_C3: | ||
1596 | state->flags |= CPUIDLE_FLAG_DEEP; | ||
1597 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | ||
1598 | state->flags |= CPUIDLE_FLAG_CHECK_BM; | ||
1599 | state->enter = pr->flags.bm_check ? | ||
1600 | acpi_idle_enter_bm : | ||
1601 | acpi_idle_enter_simple; | ||
1602 | break; | ||
1603 | } | ||
1604 | |||
1605 | count++; | ||
1606 | } | ||
1607 | |||
1608 | dev->state_count = count; | ||
1609 | |||
1610 | if (!count) | ||
1611 | return -EINVAL; | ||
1612 | |||
1613 | /* find the deepest state that can handle active BM */ | ||
1614 | if (pr->flags.bm_check) { | ||
1615 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) | ||
1616 | if (pr->power.states[i].type == ACPI_STATE_C3) | ||
1617 | break; | ||
1618 | pr->power.bm_state = &pr->power.states[i-1]; | ||
1619 | } | ||
1620 | |||
1621 | return 0; | ||
1622 | } | ||
1623 | |||
1624 | int acpi_processor_cst_has_changed(struct acpi_processor *pr) | ||
1625 | { | ||
1626 | int ret; | ||
1627 | |||
1628 | if (!pr) | ||
1629 | return -EINVAL; | ||
1630 | |||
1631 | if (nocst) { | ||
1632 | return -ENODEV; | ||
1633 | } | ||
1634 | |||
1635 | if (!pr->flags.power_setup_done) | ||
1636 | return -ENODEV; | ||
1637 | |||
1638 | cpuidle_pause_and_lock(); | ||
1639 | cpuidle_disable_device(&pr->power.dev); | ||
1640 | acpi_processor_get_power_info(pr); | ||
1641 | acpi_processor_setup_cpuidle(pr); | ||
1642 | ret = cpuidle_enable_device(&pr->power.dev); | ||
1643 | cpuidle_resume_and_unlock(); | ||
1644 | |||
1645 | return ret; | ||
1646 | } | ||
1647 | |||
1648 | #endif /* CONFIG_CPU_IDLE */ | ||
1253 | 1649 | ||
1254 | int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | 1650 | int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, |
1255 | struct acpi_device *device) | 1651 | struct acpi_device *device) |
@@ -1267,7 +1663,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
1267 | "ACPI: processor limited to max C-state %d\n", | 1663 | "ACPI: processor limited to max C-state %d\n", |
1268 | max_cstate); | 1664 | max_cstate); |
1269 | first_run++; | 1665 | first_run++; |
1270 | #ifdef CONFIG_SMP | 1666 | #if !defined (CONFIG_CPU_IDLE) && defined (CONFIG_SMP) |
1271 | register_latency_notifier(&acpi_processor_latency_notifier); | 1667 | register_latency_notifier(&acpi_processor_latency_notifier); |
1272 | #endif | 1668 | #endif |
1273 | } | 1669 | } |
@@ -1285,6 +1681,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
1285 | } | 1681 | } |
1286 | 1682 | ||
1287 | acpi_processor_get_power_info(pr); | 1683 | acpi_processor_get_power_info(pr); |
1684 | pr->flags.power_setup_done = 1; | ||
1288 | 1685 | ||
1289 | /* | 1686 | /* |
1290 | * Install the idle handler if processor power management is supported. | 1687 | * Install the idle handler if processor power management is supported. |
@@ -1292,6 +1689,13 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
1292 | * platforms that only support C1. | 1689 | * platforms that only support C1. |
1293 | */ | 1690 | */ |
1294 | if ((pr->flags.power) && (!boot_option_idle_override)) { | 1691 | if ((pr->flags.power) && (!boot_option_idle_override)) { |
1692 | #ifdef CONFIG_CPU_IDLE | ||
1693 | acpi_processor_setup_cpuidle(pr); | ||
1694 | pr->power.dev.cpu = pr->id; | ||
1695 | if (cpuidle_register_device(&pr->power.dev)) | ||
1696 | return -EIO; | ||
1697 | #endif | ||
1698 | |||
1295 | printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id); | 1699 | printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id); |
1296 | for (i = 1; i <= pr->power.count; i++) | 1700 | for (i = 1; i <= pr->power.count; i++) |
1297 | if (pr->power.states[i].valid) | 1701 | if (pr->power.states[i].valid) |
@@ -1299,10 +1703,12 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
1299 | pr->power.states[i].type); | 1703 | pr->power.states[i].type); |
1300 | printk(")\n"); | 1704 | printk(")\n"); |
1301 | 1705 | ||
1706 | #ifndef CONFIG_CPU_IDLE | ||
1302 | if (pr->id == 0) { | 1707 | if (pr->id == 0) { |
1303 | pm_idle_save = pm_idle; | 1708 | pm_idle_save = pm_idle; |
1304 | pm_idle = acpi_processor_idle; | 1709 | pm_idle = acpi_processor_idle; |
1305 | } | 1710 | } |
1711 | #endif | ||
1306 | } | 1712 | } |
1307 | 1713 | ||
1308 | /* 'power' [R] */ | 1714 | /* 'power' [R] */ |
@@ -1316,21 +1722,24 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
1316 | entry->owner = THIS_MODULE; | 1722 | entry->owner = THIS_MODULE; |
1317 | } | 1723 | } |
1318 | 1724 | ||
1319 | pr->flags.power_setup_done = 1; | ||
1320 | |||
1321 | return 0; | 1725 | return 0; |
1322 | } | 1726 | } |
1323 | 1727 | ||
1324 | int acpi_processor_power_exit(struct acpi_processor *pr, | 1728 | int acpi_processor_power_exit(struct acpi_processor *pr, |
1325 | struct acpi_device *device) | 1729 | struct acpi_device *device) |
1326 | { | 1730 | { |
1327 | 1731 | #ifdef CONFIG_CPU_IDLE | |
1732 | if ((pr->flags.power) && (!boot_option_idle_override)) | ||
1733 | cpuidle_unregister_device(&pr->power.dev); | ||
1734 | #endif | ||
1328 | pr->flags.power_setup_done = 0; | 1735 | pr->flags.power_setup_done = 0; |
1329 | 1736 | ||
1330 | if (acpi_device_dir(device)) | 1737 | if (acpi_device_dir(device)) |
1331 | remove_proc_entry(ACPI_PROCESSOR_FILE_POWER, | 1738 | remove_proc_entry(ACPI_PROCESSOR_FILE_POWER, |
1332 | acpi_device_dir(device)); | 1739 | acpi_device_dir(device)); |
1333 | 1740 | ||
1741 | #ifndef CONFIG_CPU_IDLE | ||
1742 | |||
1334 | /* Unregister the idle handler when processor #0 is removed. */ | 1743 | /* Unregister the idle handler when processor #0 is removed. */ |
1335 | if (pr->id == 0) { | 1744 | if (pr->id == 0) { |
1336 | pm_idle = pm_idle_save; | 1745 | pm_idle = pm_idle_save; |
@@ -1345,6 +1754,7 @@ int acpi_processor_power_exit(struct acpi_processor *pr, | |||
1345 | unregister_latency_notifier(&acpi_processor_latency_notifier); | 1754 | unregister_latency_notifier(&acpi_processor_latency_notifier); |
1346 | #endif | 1755 | #endif |
1347 | } | 1756 | } |
1757 | #endif | ||
1348 | 1758 | ||
1349 | return 0; | 1759 | return 0; |
1350 | } | 1760 | } |
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index a578986e3214..90fd09c65f95 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -1,6 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * acpi_sbs.c - ACPI Smart Battery System Driver ($Revision: 1.16 $) | 2 | * sbs.c - ACPI Smart Battery System Driver ($Revision: 2.0 $) |
3 | * | 3 | * |
4 | * Copyright (c) 2007 Alexey Starikovskiy <astarikovskiy@suse.de> | ||
5 | * Copyright (c) 2005-2007 Vladimir Lebedev <vladimir.p.lebedev@intel.com> | ||
4 | * Copyright (c) 2005 Rich Townsend <rhdt@bartol.udel.edu> | 6 | * Copyright (c) 2005 Rich Townsend <rhdt@bartol.udel.edu> |
5 | * | 7 | * |
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 8 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
@@ -26,15 +28,22 @@ | |||
26 | #include <linux/module.h> | 28 | #include <linux/module.h> |
27 | #include <linux/moduleparam.h> | 29 | #include <linux/moduleparam.h> |
28 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
31 | |||
32 | #ifdef CONFIG_ACPI_PROCFS | ||
29 | #include <linux/proc_fs.h> | 33 | #include <linux/proc_fs.h> |
30 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
31 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
36 | #endif | ||
37 | |||
32 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
33 | #include <linux/timer.h> | 39 | #include <linux/timer.h> |
34 | #include <linux/jiffies.h> | 40 | #include <linux/jiffies.h> |
35 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
36 | 42 | ||
37 | #define ACPI_SBS_COMPONENT 0x00080000 | 43 | #include <linux/power_supply.h> |
44 | |||
45 | #include "sbshc.h" | ||
46 | |||
38 | #define ACPI_SBS_CLASS "sbs" | 47 | #define ACPI_SBS_CLASS "sbs" |
39 | #define ACPI_AC_CLASS "ac_adapter" | 48 | #define ACPI_AC_CLASS "ac_adapter" |
40 | #define ACPI_BATTERY_CLASS "battery" | 49 | #define ACPI_BATTERY_CLASS "battery" |
@@ -44,836 +53,436 @@ | |||
44 | #define ACPI_SBS_FILE_ALARM "alarm" | 53 | #define ACPI_SBS_FILE_ALARM "alarm" |
45 | #define ACPI_BATTERY_DIR_NAME "BAT%i" | 54 | #define ACPI_BATTERY_DIR_NAME "BAT%i" |
46 | #define ACPI_AC_DIR_NAME "AC0" | 55 | #define ACPI_AC_DIR_NAME "AC0" |
47 | #define ACPI_SBC_SMBUS_ADDR 0x9 | ||
48 | #define ACPI_SBSM_SMBUS_ADDR 0xa | ||
49 | #define ACPI_SB_SMBUS_ADDR 0xb | ||
50 | #define ACPI_SBS_AC_NOTIFY_STATUS 0x80 | ||
51 | #define ACPI_SBS_BATTERY_NOTIFY_STATUS 0x80 | ||
52 | #define ACPI_SBS_BATTERY_NOTIFY_INFO 0x81 | ||
53 | 56 | ||
54 | #define _COMPONENT ACPI_SBS_COMPONENT | 57 | enum acpi_sbs_device_addr { |
58 | ACPI_SBS_CHARGER = 0x9, | ||
59 | ACPI_SBS_MANAGER = 0xa, | ||
60 | ACPI_SBS_BATTERY = 0xb, | ||
61 | }; | ||
55 | 62 | ||
56 | ACPI_MODULE_NAME("sbs"); | 63 | #define ACPI_SBS_NOTIFY_STATUS 0x80 |
64 | #define ACPI_SBS_NOTIFY_INFO 0x81 | ||
57 | 65 | ||
58 | MODULE_AUTHOR("Rich Townsend"); | 66 | MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>"); |
59 | MODULE_DESCRIPTION("Smart Battery System ACPI interface driver"); | 67 | MODULE_DESCRIPTION("Smart Battery System ACPI interface driver"); |
60 | MODULE_LICENSE("GPL"); | 68 | MODULE_LICENSE("GPL"); |
61 | 69 | ||
62 | #define xmsleep(t) msleep(t) | 70 | static unsigned int cache_time = 1000; |
63 | 71 | module_param(cache_time, uint, 0644); | |
64 | #define ACPI_EC_SMB_PRTCL 0x00 /* protocol, PEC */ | 72 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); |
65 | |||
66 | #define ACPI_EC_SMB_STS 0x01 /* status */ | ||
67 | #define ACPI_EC_SMB_ADDR 0x02 /* address */ | ||
68 | #define ACPI_EC_SMB_CMD 0x03 /* command */ | ||
69 | #define ACPI_EC_SMB_DATA 0x04 /* 32 data registers */ | ||
70 | #define ACPI_EC_SMB_BCNT 0x24 /* number of data bytes */ | ||
71 | |||
72 | #define ACPI_EC_SMB_STS_DONE 0x80 | ||
73 | #define ACPI_EC_SMB_STS_STATUS 0x1f | ||
74 | |||
75 | #define ACPI_EC_SMB_PRTCL_WRITE 0x00 | ||
76 | #define ACPI_EC_SMB_PRTCL_READ 0x01 | ||
77 | #define ACPI_EC_SMB_PRTCL_WORD_DATA 0x08 | ||
78 | #define ACPI_EC_SMB_PRTCL_BLOCK_DATA 0x0a | ||
79 | |||
80 | #define ACPI_EC_SMB_TRANSACTION_SLEEP 1 | ||
81 | #define ACPI_EC_SMB_ACCESS_SLEEP1 1 | ||
82 | #define ACPI_EC_SMB_ACCESS_SLEEP2 10 | ||
83 | |||
84 | #define DEF_CAPACITY_UNIT 3 | ||
85 | #define MAH_CAPACITY_UNIT 1 | ||
86 | #define MWH_CAPACITY_UNIT 2 | ||
87 | #define CAPACITY_UNIT DEF_CAPACITY_UNIT | ||
88 | |||
89 | #define REQUEST_UPDATE_MODE 1 | ||
90 | #define QUEUE_UPDATE_MODE 2 | ||
91 | |||
92 | #define DATA_TYPE_COMMON 0 | ||
93 | #define DATA_TYPE_INFO 1 | ||
94 | #define DATA_TYPE_STATE 2 | ||
95 | #define DATA_TYPE_ALARM 3 | ||
96 | #define DATA_TYPE_AC_STATE 4 | ||
97 | 73 | ||
98 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); | 74 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); |
99 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); | 75 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); |
100 | extern void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); | 76 | extern void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); |
101 | extern void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); | 77 | extern void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); |
102 | 78 | ||
103 | #define MAX_SBS_BAT 4 | 79 | #define MAX_SBS_BAT 4 |
104 | #define ACPI_SBS_BLOCK_MAX 32 | 80 | #define ACPI_SBS_BLOCK_MAX 32 |
105 | 81 | ||
106 | #define ACPI_SBS_SMBUS_READ 1 | ||
107 | #define ACPI_SBS_SMBUS_WRITE 2 | ||
108 | |||
109 | #define ACPI_SBS_WORD_DATA 1 | ||
110 | #define ACPI_SBS_BLOCK_DATA 2 | ||
111 | |||
112 | #define UPDATE_DELAY 10 | ||
113 | |||
114 | /* 0 - every time, > 0 - by update_time */ | ||
115 | static unsigned int update_time = 120; | ||
116 | |||
117 | static unsigned int capacity_mode = CAPACITY_UNIT; | ||
118 | |||
119 | module_param(update_time, uint, 0644); | ||
120 | module_param(capacity_mode, uint, 0444); | ||
121 | |||
122 | static int acpi_sbs_add(struct acpi_device *device); | ||
123 | static int acpi_sbs_remove(struct acpi_device *device, int type); | ||
124 | static int acpi_sbs_resume(struct acpi_device *device); | ||
125 | |||
126 | static const struct acpi_device_id sbs_device_ids[] = { | 82 | static const struct acpi_device_id sbs_device_ids[] = { |
127 | {"ACPI0001", 0}, | 83 | {"ACPI0002", 0}, |
128 | {"ACPI0005", 0}, | ||
129 | {"", 0}, | 84 | {"", 0}, |
130 | }; | 85 | }; |
131 | MODULE_DEVICE_TABLE(acpi, sbs_device_ids); | 86 | MODULE_DEVICE_TABLE(acpi, sbs_device_ids); |
132 | 87 | ||
133 | static struct acpi_driver acpi_sbs_driver = { | ||
134 | .name = "sbs", | ||
135 | .class = ACPI_SBS_CLASS, | ||
136 | .ids = sbs_device_ids, | ||
137 | .ops = { | ||
138 | .add = acpi_sbs_add, | ||
139 | .remove = acpi_sbs_remove, | ||
140 | .resume = acpi_sbs_resume, | ||
141 | }, | ||
142 | }; | ||
143 | |||
144 | struct acpi_ac { | ||
145 | int ac_present; | ||
146 | }; | ||
147 | |||
148 | struct acpi_battery_info { | ||
149 | int capacity_mode; | ||
150 | s16 full_charge_capacity; | ||
151 | s16 design_capacity; | ||
152 | s16 design_voltage; | ||
153 | int vscale; | ||
154 | int ipscale; | ||
155 | s16 serial_number; | ||
156 | char manufacturer_name[ACPI_SBS_BLOCK_MAX + 3]; | ||
157 | char device_name[ACPI_SBS_BLOCK_MAX + 3]; | ||
158 | char device_chemistry[ACPI_SBS_BLOCK_MAX + 3]; | ||
159 | }; | ||
160 | |||
161 | struct acpi_battery_state { | ||
162 | s16 voltage; | ||
163 | s16 amperage; | ||
164 | s16 remaining_capacity; | ||
165 | s16 battery_state; | ||
166 | }; | ||
167 | |||
168 | struct acpi_battery_alarm { | ||
169 | s16 remaining_capacity; | ||
170 | }; | ||
171 | |||
172 | struct acpi_battery { | 88 | struct acpi_battery { |
173 | int alive; | 89 | struct power_supply bat; |
174 | int id; | ||
175 | int init_state; | ||
176 | int battery_present; | ||
177 | struct acpi_sbs *sbs; | 90 | struct acpi_sbs *sbs; |
178 | struct acpi_battery_info info; | 91 | #ifdef CONFIG_ACPI_PROCFS |
179 | struct acpi_battery_state state; | 92 | struct proc_dir_entry *proc_entry; |
180 | struct acpi_battery_alarm alarm; | 93 | #endif |
181 | struct proc_dir_entry *battery_entry; | 94 | unsigned long update_time; |
95 | char name[8]; | ||
96 | char manufacturer_name[ACPI_SBS_BLOCK_MAX]; | ||
97 | char device_name[ACPI_SBS_BLOCK_MAX]; | ||
98 | char device_chemistry[ACPI_SBS_BLOCK_MAX]; | ||
99 | u16 alarm_capacity; | ||
100 | u16 full_charge_capacity; | ||
101 | u16 design_capacity; | ||
102 | u16 design_voltage; | ||
103 | u16 serial_number; | ||
104 | u16 cycle_count; | ||
105 | u16 temp_now; | ||
106 | u16 voltage_now; | ||
107 | s16 current_now; | ||
108 | s16 current_avg; | ||
109 | u16 capacity_now; | ||
110 | u16 state_of_charge; | ||
111 | u16 state; | ||
112 | u16 mode; | ||
113 | u16 spec; | ||
114 | u8 id; | ||
115 | u8 present:1; | ||
182 | }; | 116 | }; |
183 | 117 | ||
118 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | ||
119 | |||
184 | struct acpi_sbs { | 120 | struct acpi_sbs { |
185 | int base; | 121 | struct power_supply charger; |
186 | struct acpi_device *device; | 122 | struct acpi_device *device; |
187 | struct mutex mutex; | 123 | struct acpi_smb_hc *hc; |
188 | int sbsm_present; | 124 | struct mutex lock; |
189 | int sbsm_batteries_supported; | 125 | #ifdef CONFIG_ACPI_PROCFS |
190 | struct proc_dir_entry *ac_entry; | 126 | struct proc_dir_entry *charger_entry; |
191 | struct acpi_ac ac; | 127 | #endif |
192 | struct acpi_battery battery[MAX_SBS_BAT]; | 128 | struct acpi_battery battery[MAX_SBS_BAT]; |
193 | int zombie; | 129 | u8 batteries_supported:4; |
194 | struct timer_list update_timer; | 130 | u8 manager_present:1; |
195 | int run_cnt; | 131 | u8 charger_present:1; |
196 | int update_proc_flg; | ||
197 | }; | 132 | }; |
198 | 133 | ||
199 | static int acpi_sbs_update_run(struct acpi_sbs *sbs, int id, int data_type); | 134 | #define to_acpi_sbs(x) container_of(x, struct acpi_sbs, charger) |
200 | static void acpi_sbs_update_time(void *data); | ||
201 | 135 | ||
202 | union sbs_rw_data { | 136 | static inline int battery_scale(int log) |
203 | u16 word; | ||
204 | u8 block[ACPI_SBS_BLOCK_MAX + 2]; | ||
205 | }; | ||
206 | |||
207 | static int acpi_ec_sbs_access(struct acpi_sbs *sbs, u16 addr, | ||
208 | char read_write, u8 command, int size, | ||
209 | union sbs_rw_data *data); | ||
210 | |||
211 | /* -------------------------------------------------------------------------- | ||
212 | SMBus Communication | ||
213 | -------------------------------------------------------------------------- */ | ||
214 | |||
215 | static int acpi_ec_sbs_read(struct acpi_sbs *sbs, u8 address, u8 * data) | ||
216 | { | 137 | { |
217 | u8 val; | 138 | int scale = 1; |
218 | int err; | 139 | while (log--) |
219 | 140 | scale *= 10; | |
220 | err = ec_read(sbs->base + address, &val); | 141 | return scale; |
221 | if (!err) { | ||
222 | *data = val; | ||
223 | } | ||
224 | xmsleep(ACPI_EC_SMB_TRANSACTION_SLEEP); | ||
225 | return (err); | ||
226 | } | ||
227 | |||
228 | static int acpi_ec_sbs_write(struct acpi_sbs *sbs, u8 address, u8 data) | ||
229 | { | ||
230 | int err; | ||
231 | |||
232 | err = ec_write(sbs->base + address, data); | ||
233 | return (err); | ||
234 | } | ||
235 | |||
236 | static int | ||
237 | acpi_ec_sbs_access(struct acpi_sbs *sbs, u16 addr, | ||
238 | char read_write, u8 command, int size, | ||
239 | union sbs_rw_data *data) | ||
240 | { | ||
241 | unsigned char protocol, len = 0, temp[2] = { 0, 0 }; | ||
242 | int i; | ||
243 | |||
244 | if (read_write == ACPI_SBS_SMBUS_READ) { | ||
245 | protocol = ACPI_EC_SMB_PRTCL_READ; | ||
246 | } else { | ||
247 | protocol = ACPI_EC_SMB_PRTCL_WRITE; | ||
248 | } | ||
249 | |||
250 | switch (size) { | ||
251 | |||
252 | case ACPI_SBS_WORD_DATA: | ||
253 | acpi_ec_sbs_write(sbs, ACPI_EC_SMB_CMD, command); | ||
254 | if (read_write == ACPI_SBS_SMBUS_WRITE) { | ||
255 | acpi_ec_sbs_write(sbs, ACPI_EC_SMB_DATA, data->word); | ||
256 | acpi_ec_sbs_write(sbs, ACPI_EC_SMB_DATA + 1, | ||
257 | data->word >> 8); | ||
258 | } | ||
259 | protocol |= ACPI_EC_SMB_PRTCL_WORD_DATA; | ||
260 | break; | ||
261 | case ACPI_SBS_BLOCK_DATA: | ||
262 | acpi_ec_sbs_write(sbs, ACPI_EC_SMB_CMD, command); | ||
263 | if (read_write == ACPI_SBS_SMBUS_WRITE) { | ||
264 | len = min_t(u8, data->block[0], 32); | ||
265 | acpi_ec_sbs_write(sbs, ACPI_EC_SMB_BCNT, len); | ||
266 | for (i = 0; i < len; i++) | ||
267 | acpi_ec_sbs_write(sbs, ACPI_EC_SMB_DATA + i, | ||
268 | data->block[i + 1]); | ||
269 | } | ||
270 | protocol |= ACPI_EC_SMB_PRTCL_BLOCK_DATA; | ||
271 | break; | ||
272 | default: | ||
273 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
274 | "unsupported transaction %d", size)); | ||
275 | return (-1); | ||
276 | } | ||
277 | |||
278 | acpi_ec_sbs_write(sbs, ACPI_EC_SMB_ADDR, addr << 1); | ||
279 | acpi_ec_sbs_write(sbs, ACPI_EC_SMB_PRTCL, protocol); | ||
280 | |||
281 | acpi_ec_sbs_read(sbs, ACPI_EC_SMB_STS, temp); | ||
282 | |||
283 | if (~temp[0] & ACPI_EC_SMB_STS_DONE) { | ||
284 | xmsleep(ACPI_EC_SMB_ACCESS_SLEEP1); | ||
285 | acpi_ec_sbs_read(sbs, ACPI_EC_SMB_STS, temp); | ||
286 | } | ||
287 | if (~temp[0] & ACPI_EC_SMB_STS_DONE) { | ||
288 | xmsleep(ACPI_EC_SMB_ACCESS_SLEEP2); | ||
289 | acpi_ec_sbs_read(sbs, ACPI_EC_SMB_STS, temp); | ||
290 | } | ||
291 | if ((~temp[0] & ACPI_EC_SMB_STS_DONE) | ||
292 | || (temp[0] & ACPI_EC_SMB_STS_STATUS)) { | ||
293 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
294 | "transaction %d error", size)); | ||
295 | return (-1); | ||
296 | } | ||
297 | |||
298 | if (read_write == ACPI_SBS_SMBUS_WRITE) { | ||
299 | return (0); | ||
300 | } | ||
301 | |||
302 | switch (size) { | ||
303 | |||
304 | case ACPI_SBS_WORD_DATA: | ||
305 | acpi_ec_sbs_read(sbs, ACPI_EC_SMB_DATA, temp); | ||
306 | acpi_ec_sbs_read(sbs, ACPI_EC_SMB_DATA + 1, temp + 1); | ||
307 | data->word = (temp[1] << 8) | temp[0]; | ||
308 | break; | ||
309 | |||
310 | case ACPI_SBS_BLOCK_DATA: | ||
311 | len = 0; | ||
312 | acpi_ec_sbs_read(sbs, ACPI_EC_SMB_BCNT, &len); | ||
313 | len = min_t(u8, len, 32); | ||
314 | for (i = 0; i < len; i++) | ||
315 | acpi_ec_sbs_read(sbs, ACPI_EC_SMB_DATA + i, | ||
316 | data->block + i + 1); | ||
317 | data->block[0] = len; | ||
318 | break; | ||
319 | default: | ||
320 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
321 | "unsupported transaction %d", size)); | ||
322 | return (-1); | ||
323 | } | ||
324 | |||
325 | return (0); | ||
326 | } | 142 | } |
327 | 143 | ||
328 | static int | 144 | static inline int acpi_battery_vscale(struct acpi_battery *battery) |
329 | acpi_sbs_read_word(struct acpi_sbs *sbs, int addr, int func, u16 * word) | ||
330 | { | 145 | { |
331 | union sbs_rw_data data; | 146 | return battery_scale((battery->spec & 0x0f00) >> 8); |
332 | int result = 0; | ||
333 | |||
334 | result = acpi_ec_sbs_access(sbs, addr, | ||
335 | ACPI_SBS_SMBUS_READ, func, | ||
336 | ACPI_SBS_WORD_DATA, &data); | ||
337 | if (result) { | ||
338 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
339 | "acpi_ec_sbs_access() failed")); | ||
340 | } else { | ||
341 | *word = data.word; | ||
342 | } | ||
343 | |||
344 | return result; | ||
345 | } | 147 | } |
346 | 148 | ||
347 | static int | 149 | static inline int acpi_battery_ipscale(struct acpi_battery *battery) |
348 | acpi_sbs_read_str(struct acpi_sbs *sbs, int addr, int func, char *str) | ||
349 | { | 150 | { |
350 | union sbs_rw_data data; | 151 | return battery_scale((battery->spec & 0xf000) >> 12); |
351 | int result = 0; | ||
352 | |||
353 | result = acpi_ec_sbs_access(sbs, addr, | ||
354 | ACPI_SBS_SMBUS_READ, func, | ||
355 | ACPI_SBS_BLOCK_DATA, &data); | ||
356 | if (result) { | ||
357 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
358 | "acpi_ec_sbs_access() failed")); | ||
359 | } else { | ||
360 | strncpy(str, (const char *)data.block + 1, data.block[0]); | ||
361 | str[data.block[0]] = 0; | ||
362 | } | ||
363 | |||
364 | return result; | ||
365 | } | 152 | } |
366 | 153 | ||
367 | static int | 154 | static inline int acpi_battery_mode(struct acpi_battery *battery) |
368 | acpi_sbs_write_word(struct acpi_sbs *sbs, int addr, int func, int word) | ||
369 | { | 155 | { |
370 | union sbs_rw_data data; | 156 | return (battery->mode & 0x8000); |
371 | int result = 0; | ||
372 | |||
373 | data.word = word; | ||
374 | |||
375 | result = acpi_ec_sbs_access(sbs, addr, | ||
376 | ACPI_SBS_SMBUS_WRITE, func, | ||
377 | ACPI_SBS_WORD_DATA, &data); | ||
378 | if (result) { | ||
379 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
380 | "acpi_ec_sbs_access() failed")); | ||
381 | } | ||
382 | |||
383 | return result; | ||
384 | } | 157 | } |
385 | 158 | ||
386 | static int sbs_zombie(struct acpi_sbs *sbs) | 159 | static inline int acpi_battery_scale(struct acpi_battery *battery) |
387 | { | 160 | { |
388 | return (sbs->zombie); | 161 | return (acpi_battery_mode(battery) ? 10 : 1) * |
162 | acpi_battery_ipscale(battery); | ||
389 | } | 163 | } |
390 | 164 | ||
391 | static int sbs_mutex_lock(struct acpi_sbs *sbs) | 165 | static int sbs_get_ac_property(struct power_supply *psy, |
166 | enum power_supply_property psp, | ||
167 | union power_supply_propval *val) | ||
392 | { | 168 | { |
393 | if (sbs_zombie(sbs)) { | 169 | struct acpi_sbs *sbs = to_acpi_sbs(psy); |
394 | return -ENODEV; | 170 | switch (psp) { |
171 | case POWER_SUPPLY_PROP_ONLINE: | ||
172 | val->intval = sbs->charger_present; | ||
173 | break; | ||
174 | default: | ||
175 | return -EINVAL; | ||
395 | } | 176 | } |
396 | mutex_lock(&sbs->mutex); | ||
397 | return 0; | 177 | return 0; |
398 | } | 178 | } |
399 | 179 | ||
400 | static void sbs_mutex_unlock(struct acpi_sbs *sbs) | 180 | static int acpi_battery_technology(struct acpi_battery *battery) |
401 | { | 181 | { |
402 | mutex_unlock(&sbs->mutex); | 182 | if (!strcasecmp("NiCd", battery->device_chemistry)) |
183 | return POWER_SUPPLY_TECHNOLOGY_NiCd; | ||
184 | if (!strcasecmp("NiMH", battery->device_chemistry)) | ||
185 | return POWER_SUPPLY_TECHNOLOGY_NiMH; | ||
186 | if (!strcasecmp("LION", battery->device_chemistry)) | ||
187 | return POWER_SUPPLY_TECHNOLOGY_LION; | ||
188 | if (!strcasecmp("LiP", battery->device_chemistry)) | ||
189 | return POWER_SUPPLY_TECHNOLOGY_LIPO; | ||
190 | return POWER_SUPPLY_TECHNOLOGY_UNKNOWN; | ||
403 | } | 191 | } |
404 | 192 | ||
405 | /* -------------------------------------------------------------------------- | 193 | static int acpi_sbs_battery_get_property(struct power_supply *psy, |
406 | Smart Battery System Management | 194 | enum power_supply_property psp, |
407 | -------------------------------------------------------------------------- */ | 195 | union power_supply_propval *val) |
408 | |||
409 | static int acpi_check_update_proc(struct acpi_sbs *sbs) | ||
410 | { | 196 | { |
411 | acpi_status status = AE_OK; | 197 | struct acpi_battery *battery = to_acpi_battery(psy); |
412 | 198 | ||
413 | if (update_time == 0) { | 199 | if ((!battery->present) && psp != POWER_SUPPLY_PROP_PRESENT) |
414 | sbs->update_proc_flg = 0; | 200 | return -ENODEV; |
415 | return 0; | 201 | switch (psp) { |
416 | } | 202 | case POWER_SUPPLY_PROP_STATUS: |
417 | if (sbs->update_proc_flg == 0) { | 203 | if (battery->current_now < 0) |
418 | status = acpi_os_execute(OSL_GPE_HANDLER, | 204 | val->intval = POWER_SUPPLY_STATUS_DISCHARGING; |
419 | acpi_sbs_update_time, sbs); | 205 | else if (battery->current_now > 0) |
420 | if (status != AE_OK) { | 206 | val->intval = POWER_SUPPLY_STATUS_CHARGING; |
421 | ACPI_EXCEPTION((AE_INFO, status, | 207 | else |
422 | "acpi_os_execute() failed")); | 208 | val->intval = POWER_SUPPLY_STATUS_FULL; |
423 | return 1; | 209 | break; |
424 | } | 210 | case POWER_SUPPLY_PROP_PRESENT: |
425 | sbs->update_proc_flg = 1; | 211 | val->intval = battery->present; |
212 | break; | ||
213 | case POWER_SUPPLY_PROP_TECHNOLOGY: | ||
214 | val->intval = acpi_battery_technology(battery); | ||
215 | break; | ||
216 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | ||
217 | val->intval = battery->design_voltage * | ||
218 | acpi_battery_vscale(battery) * 1000; | ||
219 | break; | ||
220 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: | ||
221 | val->intval = battery->voltage_now * | ||
222 | acpi_battery_vscale(battery) * 1000; | ||
223 | break; | ||
224 | case POWER_SUPPLY_PROP_CURRENT_NOW: | ||
225 | val->intval = abs(battery->current_now) * | ||
226 | acpi_battery_ipscale(battery) * 1000; | ||
227 | break; | ||
228 | case POWER_SUPPLY_PROP_CURRENT_AVG: | ||
229 | val->intval = abs(battery->current_avg) * | ||
230 | acpi_battery_ipscale(battery) * 1000; | ||
231 | break; | ||
232 | case POWER_SUPPLY_PROP_CAPACITY: | ||
233 | val->intval = battery->state_of_charge; | ||
234 | break; | ||
235 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: | ||
236 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: | ||
237 | val->intval = battery->design_capacity * | ||
238 | acpi_battery_scale(battery) * 1000; | ||
239 | break; | ||
240 | case POWER_SUPPLY_PROP_CHARGE_FULL: | ||
241 | case POWER_SUPPLY_PROP_ENERGY_FULL: | ||
242 | val->intval = battery->full_charge_capacity * | ||
243 | acpi_battery_scale(battery) * 1000; | ||
244 | break; | ||
245 | case POWER_SUPPLY_PROP_CHARGE_NOW: | ||
246 | case POWER_SUPPLY_PROP_ENERGY_NOW: | ||
247 | val->intval = battery->capacity_now * | ||
248 | acpi_battery_scale(battery) * 1000; | ||
249 | break; | ||
250 | case POWER_SUPPLY_PROP_TEMP: | ||
251 | val->intval = battery->temp_now - 2730; // dK -> dC | ||
252 | break; | ||
253 | case POWER_SUPPLY_PROP_MODEL_NAME: | ||
254 | val->strval = battery->device_name; | ||
255 | break; | ||
256 | case POWER_SUPPLY_PROP_MANUFACTURER: | ||
257 | val->strval = battery->manufacturer_name; | ||
258 | break; | ||
259 | default: | ||
260 | return -EINVAL; | ||
426 | } | 261 | } |
427 | return 0; | 262 | return 0; |
428 | } | 263 | } |
429 | 264 | ||
430 | static int acpi_sbs_generate_event(struct acpi_device *device, | 265 | static enum power_supply_property sbs_ac_props[] = { |
431 | int event, int state, char *bid, char *class) | 266 | POWER_SUPPLY_PROP_ONLINE, |
432 | { | 267 | }; |
433 | char bid_saved[5]; | ||
434 | char class_saved[20]; | ||
435 | int result = 0; | ||
436 | |||
437 | strcpy(bid_saved, acpi_device_bid(device)); | ||
438 | strcpy(class_saved, acpi_device_class(device)); | ||
439 | |||
440 | strcpy(acpi_device_bid(device), bid); | ||
441 | strcpy(acpi_device_class(device), class); | ||
442 | |||
443 | result = acpi_bus_generate_proc_event(device, event, state); | ||
444 | |||
445 | strcpy(acpi_device_bid(device), bid_saved); | ||
446 | strcpy(acpi_device_class(device), class_saved); | ||
447 | |||
448 | acpi_bus_generate_netlink_event(class, bid, event, state); | ||
449 | return result; | ||
450 | } | ||
451 | |||
452 | static int acpi_battery_get_present(struct acpi_battery *battery) | ||
453 | { | ||
454 | s16 state; | ||
455 | int result = 0; | ||
456 | int is_present = 0; | ||
457 | |||
458 | result = acpi_sbs_read_word(battery->sbs, | ||
459 | ACPI_SBSM_SMBUS_ADDR, 0x01, &state); | ||
460 | if (result) { | ||
461 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
462 | "acpi_sbs_read_word() failed")); | ||
463 | } | ||
464 | if (!result) { | ||
465 | is_present = (state & 0x000f) & (1 << battery->id); | ||
466 | } | ||
467 | battery->battery_present = is_present; | ||
468 | |||
469 | return result; | ||
470 | } | ||
471 | 268 | ||
472 | static int acpi_battery_select(struct acpi_battery *battery) | 269 | static enum power_supply_property sbs_charge_battery_props[] = { |
473 | { | 270 | POWER_SUPPLY_PROP_STATUS, |
474 | struct acpi_sbs *sbs = battery->sbs; | 271 | POWER_SUPPLY_PROP_PRESENT, |
475 | int result = 0; | 272 | POWER_SUPPLY_PROP_TECHNOLOGY, |
476 | s16 state; | 273 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
477 | int foo; | 274 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
275 | POWER_SUPPLY_PROP_CURRENT_NOW, | ||
276 | POWER_SUPPLY_PROP_CURRENT_AVG, | ||
277 | POWER_SUPPLY_PROP_CAPACITY, | ||
278 | POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, | ||
279 | POWER_SUPPLY_PROP_CHARGE_FULL, | ||
280 | POWER_SUPPLY_PROP_CHARGE_NOW, | ||
281 | POWER_SUPPLY_PROP_TEMP, | ||
282 | POWER_SUPPLY_PROP_MODEL_NAME, | ||
283 | POWER_SUPPLY_PROP_MANUFACTURER, | ||
284 | }; | ||
478 | 285 | ||
479 | if (sbs->sbsm_present) { | 286 | static enum power_supply_property sbs_energy_battery_props[] = { |
287 | POWER_SUPPLY_PROP_STATUS, | ||
288 | POWER_SUPPLY_PROP_PRESENT, | ||
289 | POWER_SUPPLY_PROP_TECHNOLOGY, | ||
290 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | ||
291 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | ||
292 | POWER_SUPPLY_PROP_CURRENT_NOW, | ||
293 | POWER_SUPPLY_PROP_CURRENT_AVG, | ||
294 | POWER_SUPPLY_PROP_CAPACITY, | ||
295 | POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, | ||
296 | POWER_SUPPLY_PROP_ENERGY_FULL, | ||
297 | POWER_SUPPLY_PROP_ENERGY_NOW, | ||
298 | POWER_SUPPLY_PROP_TEMP, | ||
299 | POWER_SUPPLY_PROP_MODEL_NAME, | ||
300 | POWER_SUPPLY_PROP_MANUFACTURER, | ||
301 | }; | ||
480 | 302 | ||
481 | /* Take special care not to knobble other nibbles of | 303 | /* -------------------------------------------------------------------------- |
482 | * state (aka selector_state), since | 304 | Smart Battery System Management |
483 | * it causes charging to halt on SBSELs */ | 305 | -------------------------------------------------------------------------- */ |
484 | 306 | ||
485 | result = | 307 | struct acpi_battery_reader { |
486 | acpi_sbs_read_word(sbs, ACPI_SBSM_SMBUS_ADDR, 0x01, &state); | 308 | u8 command; /* command for battery */ |
487 | if (result) { | 309 | u8 mode; /* word or block? */ |
488 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 310 | size_t offset; /* offset inside struct acpi_sbs_battery */ |
489 | "acpi_sbs_read_word() failed")); | 311 | }; |
490 | goto end; | ||
491 | } | ||
492 | 312 | ||
493 | foo = (state & 0x0fff) | (1 << (battery->id + 12)); | 313 | static struct acpi_battery_reader info_readers[] = { |
494 | result = | 314 | {0x01, SMBUS_READ_WORD, offsetof(struct acpi_battery, alarm_capacity)}, |
495 | acpi_sbs_write_word(sbs, ACPI_SBSM_SMBUS_ADDR, 0x01, foo); | 315 | {0x03, SMBUS_READ_WORD, offsetof(struct acpi_battery, mode)}, |
496 | if (result) { | 316 | {0x10, SMBUS_READ_WORD, offsetof(struct acpi_battery, full_charge_capacity)}, |
497 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 317 | {0x17, SMBUS_READ_WORD, offsetof(struct acpi_battery, cycle_count)}, |
498 | "acpi_sbs_write_word() failed")); | 318 | {0x18, SMBUS_READ_WORD, offsetof(struct acpi_battery, design_capacity)}, |
499 | goto end; | 319 | {0x19, SMBUS_READ_WORD, offsetof(struct acpi_battery, design_voltage)}, |
500 | } | 320 | {0x1a, SMBUS_READ_WORD, offsetof(struct acpi_battery, spec)}, |
501 | } | 321 | {0x1c, SMBUS_READ_WORD, offsetof(struct acpi_battery, serial_number)}, |
322 | {0x20, SMBUS_READ_BLOCK, offsetof(struct acpi_battery, manufacturer_name)}, | ||
323 | {0x21, SMBUS_READ_BLOCK, offsetof(struct acpi_battery, device_name)}, | ||
324 | {0x22, SMBUS_READ_BLOCK, offsetof(struct acpi_battery, device_chemistry)}, | ||
325 | }; | ||
502 | 326 | ||
503 | end: | 327 | static struct acpi_battery_reader state_readers[] = { |
504 | return result; | 328 | {0x08, SMBUS_READ_WORD, offsetof(struct acpi_battery, temp_now)}, |
505 | } | 329 | {0x09, SMBUS_READ_WORD, offsetof(struct acpi_battery, voltage_now)}, |
330 | {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_now)}, | ||
331 | {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_avg)}, | ||
332 | {0x0f, SMBUS_READ_WORD, offsetof(struct acpi_battery, capacity_now)}, | ||
333 | {0x0e, SMBUS_READ_WORD, offsetof(struct acpi_battery, state_of_charge)}, | ||
334 | {0x16, SMBUS_READ_WORD, offsetof(struct acpi_battery, state)}, | ||
335 | }; | ||
506 | 336 | ||
507 | static int acpi_sbsm_get_info(struct acpi_sbs *sbs) | 337 | static int acpi_manager_get_info(struct acpi_sbs *sbs) |
508 | { | 338 | { |
509 | int result = 0; | 339 | int result = 0; |
510 | s16 battery_system_info; | 340 | u16 battery_system_info; |
511 | |||
512 | result = acpi_sbs_read_word(sbs, ACPI_SBSM_SMBUS_ADDR, 0x04, | ||
513 | &battery_system_info); | ||
514 | if (result) { | ||
515 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
516 | "acpi_sbs_read_word() failed")); | ||
517 | goto end; | ||
518 | } | ||
519 | sbs->sbsm_present = 1; | ||
520 | sbs->sbsm_batteries_supported = battery_system_info & 0x000f; | ||
521 | |||
522 | end: | ||
523 | 341 | ||
342 | result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_MANAGER, | ||
343 | 0x04, (u8 *)&battery_system_info); | ||
344 | if (!result) | ||
345 | sbs->batteries_supported = battery_system_info & 0x000f; | ||
524 | return result; | 346 | return result; |
525 | } | 347 | } |
526 | 348 | ||
527 | static int acpi_battery_get_info(struct acpi_battery *battery) | 349 | static int acpi_battery_get_info(struct acpi_battery *battery) |
528 | { | 350 | { |
529 | struct acpi_sbs *sbs = battery->sbs; | 351 | int i, result = 0; |
530 | int result = 0; | 352 | |
531 | s16 battery_mode; | 353 | for (i = 0; i < ARRAY_SIZE(info_readers); ++i) { |
532 | s16 specification_info; | 354 | result = acpi_smbus_read(battery->sbs->hc, |
533 | 355 | info_readers[i].mode, | |
534 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x03, | 356 | ACPI_SBS_BATTERY, |
535 | &battery_mode); | 357 | info_readers[i].command, |
536 | if (result) { | 358 | (u8 *) battery + |
537 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 359 | info_readers[i].offset); |
538 | "acpi_sbs_read_word() failed")); | 360 | if (result) |
539 | goto end; | 361 | break; |
540 | } | ||
541 | battery->info.capacity_mode = (battery_mode & 0x8000) >> 15; | ||
542 | |||
543 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x10, | ||
544 | &battery->info.full_charge_capacity); | ||
545 | if (result) { | ||
546 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
547 | "acpi_sbs_read_word() failed")); | ||
548 | goto end; | ||
549 | } | ||
550 | |||
551 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x18, | ||
552 | &battery->info.design_capacity); | ||
553 | |||
554 | if (result) { | ||
555 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
556 | "acpi_sbs_read_word() failed")); | ||
557 | goto end; | ||
558 | } | ||
559 | |||
560 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x19, | ||
561 | &battery->info.design_voltage); | ||
562 | if (result) { | ||
563 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
564 | "acpi_sbs_read_word() failed")); | ||
565 | goto end; | ||
566 | } | 362 | } |
567 | |||
568 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x1a, | ||
569 | &specification_info); | ||
570 | if (result) { | ||
571 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
572 | "acpi_sbs_read_word() failed")); | ||
573 | goto end; | ||
574 | } | ||
575 | |||
576 | switch ((specification_info & 0x0f00) >> 8) { | ||
577 | case 1: | ||
578 | battery->info.vscale = 10; | ||
579 | break; | ||
580 | case 2: | ||
581 | battery->info.vscale = 100; | ||
582 | break; | ||
583 | case 3: | ||
584 | battery->info.vscale = 1000; | ||
585 | break; | ||
586 | default: | ||
587 | battery->info.vscale = 1; | ||
588 | } | ||
589 | |||
590 | switch ((specification_info & 0xf000) >> 12) { | ||
591 | case 1: | ||
592 | battery->info.ipscale = 10; | ||
593 | break; | ||
594 | case 2: | ||
595 | battery->info.ipscale = 100; | ||
596 | break; | ||
597 | case 3: | ||
598 | battery->info.ipscale = 1000; | ||
599 | break; | ||
600 | default: | ||
601 | battery->info.ipscale = 1; | ||
602 | } | ||
603 | |||
604 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x1c, | ||
605 | &battery->info.serial_number); | ||
606 | if (result) { | ||
607 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
608 | "acpi_sbs_read_word() failed")); | ||
609 | goto end; | ||
610 | } | ||
611 | |||
612 | result = acpi_sbs_read_str(sbs, ACPI_SB_SMBUS_ADDR, 0x20, | ||
613 | battery->info.manufacturer_name); | ||
614 | if (result) { | ||
615 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
616 | "acpi_sbs_read_str() failed")); | ||
617 | goto end; | ||
618 | } | ||
619 | |||
620 | result = acpi_sbs_read_str(sbs, ACPI_SB_SMBUS_ADDR, 0x21, | ||
621 | battery->info.device_name); | ||
622 | if (result) { | ||
623 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
624 | "acpi_sbs_read_str() failed")); | ||
625 | goto end; | ||
626 | } | ||
627 | |||
628 | result = acpi_sbs_read_str(sbs, ACPI_SB_SMBUS_ADDR, 0x22, | ||
629 | battery->info.device_chemistry); | ||
630 | if (result) { | ||
631 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
632 | "acpi_sbs_read_str() failed")); | ||
633 | goto end; | ||
634 | } | ||
635 | |||
636 | end: | ||
637 | return result; | 363 | return result; |
638 | } | 364 | } |
639 | 365 | ||
640 | static int acpi_battery_get_state(struct acpi_battery *battery) | 366 | static int acpi_battery_get_state(struct acpi_battery *battery) |
641 | { | 367 | { |
642 | struct acpi_sbs *sbs = battery->sbs; | 368 | int i, result = 0; |
643 | int result = 0; | ||
644 | 369 | ||
645 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x09, | 370 | if (battery->update_time && |
646 | &battery->state.voltage); | 371 | time_before(jiffies, battery->update_time + |
647 | if (result) { | 372 | msecs_to_jiffies(cache_time))) |
648 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 373 | return 0; |
649 | "acpi_sbs_read_word() failed")); | 374 | for (i = 0; i < ARRAY_SIZE(state_readers); ++i) { |
650 | goto end; | 375 | result = acpi_smbus_read(battery->sbs->hc, |
651 | } | 376 | state_readers[i].mode, |
652 | 377 | ACPI_SBS_BATTERY, | |
653 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x0a, | 378 | state_readers[i].command, |
654 | &battery->state.amperage); | 379 | (u8 *)battery + |
655 | if (result) { | 380 | state_readers[i].offset); |
656 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 381 | if (result) |
657 | "acpi_sbs_read_word() failed")); | 382 | goto end; |
658 | goto end; | ||
659 | } | ||
660 | |||
661 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x0f, | ||
662 | &battery->state.remaining_capacity); | ||
663 | if (result) { | ||
664 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
665 | "acpi_sbs_read_word() failed")); | ||
666 | goto end; | ||
667 | } | ||
668 | |||
669 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x16, | ||
670 | &battery->state.battery_state); | ||
671 | if (result) { | ||
672 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
673 | "acpi_sbs_read_word() failed")); | ||
674 | goto end; | ||
675 | } | 383 | } |
676 | |||
677 | end: | 384 | end: |
385 | battery->update_time = jiffies; | ||
678 | return result; | 386 | return result; |
679 | } | 387 | } |
680 | 388 | ||
681 | static int acpi_battery_get_alarm(struct acpi_battery *battery) | 389 | static int acpi_battery_get_alarm(struct acpi_battery *battery) |
682 | { | 390 | { |
683 | struct acpi_sbs *sbs = battery->sbs; | 391 | return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, |
684 | int result = 0; | 392 | ACPI_SBS_BATTERY, 0x01, |
685 | 393 | (u8 *)&battery->alarm_capacity); | |
686 | result = acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x01, | ||
687 | &battery->alarm.remaining_capacity); | ||
688 | if (result) { | ||
689 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
690 | "acpi_sbs_read_word() failed")); | ||
691 | goto end; | ||
692 | } | ||
693 | |||
694 | end: | ||
695 | |||
696 | return result; | ||
697 | } | 394 | } |
698 | 395 | ||
699 | static int acpi_battery_set_alarm(struct acpi_battery *battery, | 396 | static int acpi_battery_set_alarm(struct acpi_battery *battery) |
700 | unsigned long alarm) | ||
701 | { | 397 | { |
702 | struct acpi_sbs *sbs = battery->sbs; | 398 | struct acpi_sbs *sbs = battery->sbs; |
703 | int result = 0; | 399 | u16 value, sel = 1 << (battery->id + 12); |
704 | s16 battery_mode; | ||
705 | int foo; | ||
706 | 400 | ||
707 | result = acpi_battery_select(battery); | 401 | int ret; |
708 | if (result) { | ||
709 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
710 | "acpi_battery_select() failed")); | ||
711 | goto end; | ||
712 | } | ||
713 | 402 | ||
714 | /* If necessary, enable the alarm */ | ||
715 | 403 | ||
716 | if (alarm > 0) { | 404 | if (sbs->manager_present) { |
717 | result = | 405 | ret = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_MANAGER, |
718 | acpi_sbs_read_word(sbs, ACPI_SB_SMBUS_ADDR, 0x03, | 406 | 0x01, (u8 *)&value); |
719 | &battery_mode); | 407 | if (ret) |
720 | if (result) { | ||
721 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
722 | "acpi_sbs_read_word() failed")); | ||
723 | goto end; | 408 | goto end; |
724 | } | 409 | if ((value & 0xf000) != sel) { |
725 | 410 | value &= 0x0fff; | |
726 | result = | 411 | value |= sel; |
727 | acpi_sbs_write_word(sbs, ACPI_SB_SMBUS_ADDR, 0x01, | 412 | ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, |
728 | battery_mode & 0xbfff); | 413 | ACPI_SBS_MANAGER, |
729 | if (result) { | 414 | 0x01, (u8 *)&value, 2); |
730 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 415 | if (ret) |
731 | "acpi_sbs_write_word() failed")); | ||
732 | goto end; | 416 | goto end; |
733 | } | 417 | } |
734 | } | 418 | } |
735 | 419 | ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, ACPI_SBS_BATTERY, | |
736 | foo = alarm / (battery->info.capacity_mode ? 10 : 1); | 420 | 0x01, (u8 *)&battery->alarm_capacity, 2); |
737 | result = acpi_sbs_write_word(sbs, ACPI_SB_SMBUS_ADDR, 0x01, foo); | ||
738 | if (result) { | ||
739 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
740 | "acpi_sbs_write_word() failed")); | ||
741 | goto end; | ||
742 | } | ||
743 | |||
744 | end: | 421 | end: |
745 | 422 | return ret; | |
746 | return result; | ||
747 | } | 423 | } |
748 | 424 | ||
749 | static int acpi_battery_set_mode(struct acpi_battery *battery) | 425 | static int acpi_ac_get_present(struct acpi_sbs *sbs) |
750 | { | 426 | { |
751 | struct acpi_sbs *sbs = battery->sbs; | 427 | int result; |
752 | int result = 0; | 428 | u16 status; |
753 | s16 battery_mode; | ||
754 | |||
755 | if (capacity_mode == DEF_CAPACITY_UNIT) { | ||
756 | goto end; | ||
757 | } | ||
758 | |||
759 | result = acpi_sbs_read_word(sbs, | ||
760 | ACPI_SB_SMBUS_ADDR, 0x03, &battery_mode); | ||
761 | if (result) { | ||
762 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
763 | "acpi_sbs_read_word() failed")); | ||
764 | goto end; | ||
765 | } | ||
766 | |||
767 | if (capacity_mode == MAH_CAPACITY_UNIT) { | ||
768 | battery_mode &= 0x7fff; | ||
769 | } else { | ||
770 | battery_mode |= 0x8000; | ||
771 | } | ||
772 | result = acpi_sbs_write_word(sbs, | ||
773 | ACPI_SB_SMBUS_ADDR, 0x03, battery_mode); | ||
774 | if (result) { | ||
775 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
776 | "acpi_sbs_write_word() failed")); | ||
777 | goto end; | ||
778 | } | ||
779 | |||
780 | result = acpi_sbs_read_word(sbs, | ||
781 | ACPI_SB_SMBUS_ADDR, 0x03, &battery_mode); | ||
782 | if (result) { | ||
783 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
784 | "acpi_sbs_read_word() failed")); | ||
785 | goto end; | ||
786 | } | ||
787 | 429 | ||
788 | end: | 430 | result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_CHARGER, |
431 | 0x13, (u8 *) & status); | ||
432 | if (!result) | ||
433 | sbs->charger_present = (status >> 15) & 0x1; | ||
789 | return result; | 434 | return result; |
790 | } | 435 | } |
791 | 436 | ||
792 | static int acpi_battery_init(struct acpi_battery *battery) | 437 | static ssize_t acpi_battery_alarm_show(struct device *dev, |
438 | struct device_attribute *attr, | ||
439 | char *buf) | ||
793 | { | 440 | { |
794 | int result = 0; | 441 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); |
795 | 442 | acpi_battery_get_alarm(battery); | |
796 | result = acpi_battery_select(battery); | 443 | return sprintf(buf, "%d\n", battery->alarm_capacity * |
797 | if (result) { | 444 | acpi_battery_scale(battery) * 1000); |
798 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
799 | "acpi_battery_select() failed")); | ||
800 | goto end; | ||
801 | } | ||
802 | |||
803 | result = acpi_battery_set_mode(battery); | ||
804 | if (result) { | ||
805 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
806 | "acpi_battery_set_mode() failed")); | ||
807 | goto end; | ||
808 | } | ||
809 | |||
810 | result = acpi_battery_get_info(battery); | ||
811 | if (result) { | ||
812 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
813 | "acpi_battery_get_info() failed")); | ||
814 | goto end; | ||
815 | } | ||
816 | |||
817 | result = acpi_battery_get_state(battery); | ||
818 | if (result) { | ||
819 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
820 | "acpi_battery_get_state() failed")); | ||
821 | goto end; | ||
822 | } | ||
823 | |||
824 | result = acpi_battery_get_alarm(battery); | ||
825 | if (result) { | ||
826 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
827 | "acpi_battery_get_alarm() failed")); | ||
828 | goto end; | ||
829 | } | ||
830 | |||
831 | end: | ||
832 | return result; | ||
833 | } | 445 | } |
834 | 446 | ||
835 | static int acpi_ac_get_present(struct acpi_sbs *sbs) | 447 | static ssize_t acpi_battery_alarm_store(struct device *dev, |
448 | struct device_attribute *attr, | ||
449 | const char *buf, size_t count) | ||
836 | { | 450 | { |
837 | int result = 0; | 451 | unsigned long x; |
838 | s16 charger_status; | 452 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); |
839 | 453 | if (sscanf(buf, "%ld\n", &x) == 1) | |
840 | result = acpi_sbs_read_word(sbs, ACPI_SBC_SMBUS_ADDR, 0x13, | 454 | battery->alarm_capacity = x / |
841 | &charger_status); | 455 | (1000 * acpi_battery_scale(battery)); |
842 | 456 | if (battery->present) | |
843 | if (result) { | 457 | acpi_battery_set_alarm(battery); |
844 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 458 | return count; |
845 | "acpi_sbs_read_word() failed")); | ||
846 | goto end; | ||
847 | } | ||
848 | |||
849 | sbs->ac.ac_present = (charger_status & 0x8000) >> 15; | ||
850 | |||
851 | end: | ||
852 | |||
853 | return result; | ||
854 | } | 459 | } |
855 | 460 | ||
461 | static struct device_attribute alarm_attr = { | ||
462 | .attr = {.name = "alarm", .mode = 0644, .owner = THIS_MODULE}, | ||
463 | .show = acpi_battery_alarm_show, | ||
464 | .store = acpi_battery_alarm_store, | ||
465 | }; | ||
466 | |||
856 | /* -------------------------------------------------------------------------- | 467 | /* -------------------------------------------------------------------------- |
857 | FS Interface (/proc/acpi) | 468 | FS Interface (/proc/acpi) |
858 | -------------------------------------------------------------------------- */ | 469 | -------------------------------------------------------------------------- */ |
859 | 470 | ||
471 | #ifdef CONFIG_ACPI_PROCFS | ||
860 | /* Generic Routines */ | 472 | /* Generic Routines */ |
861 | |||
862 | static int | 473 | static int |
863 | acpi_sbs_generic_add_fs(struct proc_dir_entry **dir, | 474 | acpi_sbs_add_fs(struct proc_dir_entry **dir, |
864 | struct proc_dir_entry *parent_dir, | 475 | struct proc_dir_entry *parent_dir, |
865 | char *dir_name, | 476 | char *dir_name, |
866 | struct file_operations *info_fops, | 477 | struct file_operations *info_fops, |
867 | struct file_operations *state_fops, | 478 | struct file_operations *state_fops, |
868 | struct file_operations *alarm_fops, void *data) | 479 | struct file_operations *alarm_fops, void *data) |
869 | { | 480 | { |
870 | struct proc_dir_entry *entry = NULL; | 481 | struct proc_dir_entry *entry = NULL; |
871 | 482 | ||
872 | if (!*dir) { | 483 | if (!*dir) { |
873 | *dir = proc_mkdir(dir_name, parent_dir); | 484 | *dir = proc_mkdir(dir_name, parent_dir); |
874 | if (!*dir) { | 485 | if (!*dir) { |
875 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
876 | "proc_mkdir() failed")); | ||
877 | return -ENODEV; | 486 | return -ENODEV; |
878 | } | 487 | } |
879 | (*dir)->owner = THIS_MODULE; | 488 | (*dir)->owner = THIS_MODULE; |
@@ -882,10 +491,7 @@ acpi_sbs_generic_add_fs(struct proc_dir_entry **dir, | |||
882 | /* 'info' [R] */ | 491 | /* 'info' [R] */ |
883 | if (info_fops) { | 492 | if (info_fops) { |
884 | entry = create_proc_entry(ACPI_SBS_FILE_INFO, S_IRUGO, *dir); | 493 | entry = create_proc_entry(ACPI_SBS_FILE_INFO, S_IRUGO, *dir); |
885 | if (!entry) { | 494 | if (entry) { |
886 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
887 | "create_proc_entry() failed")); | ||
888 | } else { | ||
889 | entry->proc_fops = info_fops; | 495 | entry->proc_fops = info_fops; |
890 | entry->data = data; | 496 | entry->data = data; |
891 | entry->owner = THIS_MODULE; | 497 | entry->owner = THIS_MODULE; |
@@ -895,10 +501,7 @@ acpi_sbs_generic_add_fs(struct proc_dir_entry **dir, | |||
895 | /* 'state' [R] */ | 501 | /* 'state' [R] */ |
896 | if (state_fops) { | 502 | if (state_fops) { |
897 | entry = create_proc_entry(ACPI_SBS_FILE_STATE, S_IRUGO, *dir); | 503 | entry = create_proc_entry(ACPI_SBS_FILE_STATE, S_IRUGO, *dir); |
898 | if (!entry) { | 504 | if (entry) { |
899 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
900 | "create_proc_entry() failed")); | ||
901 | } else { | ||
902 | entry->proc_fops = state_fops; | 505 | entry->proc_fops = state_fops; |
903 | entry->data = data; | 506 | entry->data = data; |
904 | entry->owner = THIS_MODULE; | 507 | entry->owner = THIS_MODULE; |
@@ -908,24 +511,19 @@ acpi_sbs_generic_add_fs(struct proc_dir_entry **dir, | |||
908 | /* 'alarm' [R/W] */ | 511 | /* 'alarm' [R/W] */ |
909 | if (alarm_fops) { | 512 | if (alarm_fops) { |
910 | entry = create_proc_entry(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir); | 513 | entry = create_proc_entry(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir); |
911 | if (!entry) { | 514 | if (entry) { |
912 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
913 | "create_proc_entry() failed")); | ||
914 | } else { | ||
915 | entry->proc_fops = alarm_fops; | 515 | entry->proc_fops = alarm_fops; |
916 | entry->data = data; | 516 | entry->data = data; |
917 | entry->owner = THIS_MODULE; | 517 | entry->owner = THIS_MODULE; |
918 | } | 518 | } |
919 | } | 519 | } |
920 | |||
921 | return 0; | 520 | return 0; |
922 | } | 521 | } |
923 | 522 | ||
924 | static void | 523 | static void |
925 | acpi_sbs_generic_remove_fs(struct proc_dir_entry **dir, | 524 | acpi_sbs_remove_fs(struct proc_dir_entry **dir, |
926 | struct proc_dir_entry *parent_dir) | 525 | struct proc_dir_entry *parent_dir) |
927 | { | 526 | { |
928 | |||
929 | if (*dir) { | 527 | if (*dir) { |
930 | remove_proc_entry(ACPI_SBS_FILE_INFO, *dir); | 528 | remove_proc_entry(ACPI_SBS_FILE_INFO, *dir); |
931 | remove_proc_entry(ACPI_SBS_FILE_STATE, *dir); | 529 | remove_proc_entry(ACPI_SBS_FILE_STATE, *dir); |
@@ -933,82 +531,52 @@ acpi_sbs_generic_remove_fs(struct proc_dir_entry **dir, | |||
933 | remove_proc_entry((*dir)->name, parent_dir); | 531 | remove_proc_entry((*dir)->name, parent_dir); |
934 | *dir = NULL; | 532 | *dir = NULL; |
935 | } | 533 | } |
936 | |||
937 | } | 534 | } |
938 | 535 | ||
939 | /* Smart Battery Interface */ | 536 | /* Smart Battery Interface */ |
940 | |||
941 | static struct proc_dir_entry *acpi_battery_dir = NULL; | 537 | static struct proc_dir_entry *acpi_battery_dir = NULL; |
942 | 538 | ||
539 | static inline char *acpi_battery_units(struct acpi_battery *battery) | ||
540 | { | ||
541 | return acpi_battery_mode(battery) ? " mWh" : " mAh"; | ||
542 | } | ||
543 | |||
544 | |||
943 | static int acpi_battery_read_info(struct seq_file *seq, void *offset) | 545 | static int acpi_battery_read_info(struct seq_file *seq, void *offset) |
944 | { | 546 | { |
945 | struct acpi_battery *battery = seq->private; | 547 | struct acpi_battery *battery = seq->private; |
946 | struct acpi_sbs *sbs = battery->sbs; | 548 | struct acpi_sbs *sbs = battery->sbs; |
947 | int cscale; | ||
948 | int result = 0; | 549 | int result = 0; |
949 | 550 | ||
950 | if (sbs_mutex_lock(sbs)) { | 551 | mutex_lock(&sbs->lock); |
951 | return -ENODEV; | ||
952 | } | ||
953 | |||
954 | result = acpi_check_update_proc(sbs); | ||
955 | if (result) | ||
956 | goto end; | ||
957 | |||
958 | if (update_time == 0) { | ||
959 | result = acpi_sbs_update_run(sbs, battery->id, DATA_TYPE_INFO); | ||
960 | if (result) { | ||
961 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
962 | "acpi_sbs_update_run() failed")); | ||
963 | } | ||
964 | } | ||
965 | 552 | ||
966 | if (battery->battery_present) { | 553 | seq_printf(seq, "present: %s\n", |
967 | seq_printf(seq, "present: yes\n"); | 554 | (battery->present) ? "yes" : "no"); |
968 | } else { | 555 | if (!battery->present) |
969 | seq_printf(seq, "present: no\n"); | ||
970 | goto end; | 556 | goto end; |
971 | } | ||
972 | 557 | ||
973 | if (battery->info.capacity_mode) { | ||
974 | cscale = battery->info.vscale * battery->info.ipscale; | ||
975 | } else { | ||
976 | cscale = battery->info.ipscale; | ||
977 | } | ||
978 | seq_printf(seq, "design capacity: %i%s\n", | 558 | seq_printf(seq, "design capacity: %i%s\n", |
979 | battery->info.design_capacity * cscale, | 559 | battery->design_capacity * acpi_battery_scale(battery), |
980 | battery->info.capacity_mode ? "0 mWh" : " mAh"); | 560 | acpi_battery_units(battery)); |
981 | |||
982 | seq_printf(seq, "last full capacity: %i%s\n", | 561 | seq_printf(seq, "last full capacity: %i%s\n", |
983 | battery->info.full_charge_capacity * cscale, | 562 | battery->full_charge_capacity * acpi_battery_scale(battery), |
984 | battery->info.capacity_mode ? "0 mWh" : " mAh"); | 563 | acpi_battery_units(battery)); |
985 | |||
986 | seq_printf(seq, "battery technology: rechargeable\n"); | 564 | seq_printf(seq, "battery technology: rechargeable\n"); |
987 | |||
988 | seq_printf(seq, "design voltage: %i mV\n", | 565 | seq_printf(seq, "design voltage: %i mV\n", |
989 | battery->info.design_voltage * battery->info.vscale); | 566 | battery->design_voltage * acpi_battery_vscale(battery)); |
990 | |||
991 | seq_printf(seq, "design capacity warning: unknown\n"); | 567 | seq_printf(seq, "design capacity warning: unknown\n"); |
992 | seq_printf(seq, "design capacity low: unknown\n"); | 568 | seq_printf(seq, "design capacity low: unknown\n"); |
993 | seq_printf(seq, "capacity granularity 1: unknown\n"); | 569 | seq_printf(seq, "capacity granularity 1: unknown\n"); |
994 | seq_printf(seq, "capacity granularity 2: unknown\n"); | 570 | seq_printf(seq, "capacity granularity 2: unknown\n"); |
995 | 571 | seq_printf(seq, "model number: %s\n", battery->device_name); | |
996 | seq_printf(seq, "model number: %s\n", | ||
997 | battery->info.device_name); | ||
998 | |||
999 | seq_printf(seq, "serial number: %i\n", | 572 | seq_printf(seq, "serial number: %i\n", |
1000 | battery->info.serial_number); | 573 | battery->serial_number); |
1001 | |||
1002 | seq_printf(seq, "battery type: %s\n", | 574 | seq_printf(seq, "battery type: %s\n", |
1003 | battery->info.device_chemistry); | 575 | battery->device_chemistry); |
1004 | |||
1005 | seq_printf(seq, "OEM info: %s\n", | 576 | seq_printf(seq, "OEM info: %s\n", |
1006 | battery->info.manufacturer_name); | 577 | battery->manufacturer_name); |
1007 | |||
1008 | end: | 578 | end: |
1009 | 579 | mutex_unlock(&sbs->lock); | |
1010 | sbs_mutex_unlock(sbs); | ||
1011 | |||
1012 | return result; | 580 | return result; |
1013 | } | 581 | } |
1014 | 582 | ||
@@ -1022,73 +590,29 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) | |||
1022 | struct acpi_battery *battery = seq->private; | 590 | struct acpi_battery *battery = seq->private; |
1023 | struct acpi_sbs *sbs = battery->sbs; | 591 | struct acpi_sbs *sbs = battery->sbs; |
1024 | int result = 0; | 592 | int result = 0; |
1025 | int cscale; | ||
1026 | int foo; | ||
1027 | |||
1028 | if (sbs_mutex_lock(sbs)) { | ||
1029 | return -ENODEV; | ||
1030 | } | ||
1031 | 593 | ||
1032 | result = acpi_check_update_proc(sbs); | 594 | mutex_lock(&sbs->lock); |
1033 | if (result) | 595 | seq_printf(seq, "present: %s\n", |
596 | (battery->present) ? "yes" : "no"); | ||
597 | if (!battery->present) | ||
1034 | goto end; | 598 | goto end; |
1035 | 599 | ||
1036 | if (update_time == 0) { | 600 | acpi_battery_get_state(battery); |
1037 | result = acpi_sbs_update_run(sbs, battery->id, DATA_TYPE_STATE); | 601 | seq_printf(seq, "capacity state: %s\n", |
1038 | if (result) { | 602 | (battery->state & 0x0010) ? "critical" : "ok"); |
1039 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 603 | seq_printf(seq, "charging state: %s\n", |
1040 | "acpi_sbs_update_run() failed")); | 604 | (battery->current_now < 0) ? "discharging" : |
1041 | } | 605 | ((battery->current_now > 0) ? "charging" : "charged")); |
1042 | } | 606 | seq_printf(seq, "present rate: %d mA\n", |
1043 | 607 | abs(battery->current_now) * acpi_battery_ipscale(battery)); | |
1044 | if (battery->battery_present) { | ||
1045 | seq_printf(seq, "present: yes\n"); | ||
1046 | } else { | ||
1047 | seq_printf(seq, "present: no\n"); | ||
1048 | goto end; | ||
1049 | } | ||
1050 | |||
1051 | if (battery->info.capacity_mode) { | ||
1052 | cscale = battery->info.vscale * battery->info.ipscale; | ||
1053 | } else { | ||
1054 | cscale = battery->info.ipscale; | ||
1055 | } | ||
1056 | |||
1057 | if (battery->state.battery_state & 0x0010) { | ||
1058 | seq_printf(seq, "capacity state: critical\n"); | ||
1059 | } else { | ||
1060 | seq_printf(seq, "capacity state: ok\n"); | ||
1061 | } | ||
1062 | |||
1063 | foo = (s16) battery->state.amperage * battery->info.ipscale; | ||
1064 | if (battery->info.capacity_mode) { | ||
1065 | foo = foo * battery->info.design_voltage / 1000; | ||
1066 | } | ||
1067 | if (battery->state.amperage < 0) { | ||
1068 | seq_printf(seq, "charging state: discharging\n"); | ||
1069 | seq_printf(seq, "present rate: %d %s\n", | ||
1070 | -foo, battery->info.capacity_mode ? "mW" : "mA"); | ||
1071 | } else if (battery->state.amperage > 0) { | ||
1072 | seq_printf(seq, "charging state: charging\n"); | ||
1073 | seq_printf(seq, "present rate: %d %s\n", | ||
1074 | foo, battery->info.capacity_mode ? "mW" : "mA"); | ||
1075 | } else { | ||
1076 | seq_printf(seq, "charging state: charged\n"); | ||
1077 | seq_printf(seq, "present rate: 0 %s\n", | ||
1078 | battery->info.capacity_mode ? "mW" : "mA"); | ||
1079 | } | ||
1080 | |||
1081 | seq_printf(seq, "remaining capacity: %i%s\n", | 608 | seq_printf(seq, "remaining capacity: %i%s\n", |
1082 | battery->state.remaining_capacity * cscale, | 609 | battery->capacity_now * acpi_battery_scale(battery), |
1083 | battery->info.capacity_mode ? "0 mWh" : " mAh"); | 610 | acpi_battery_units(battery)); |
1084 | |||
1085 | seq_printf(seq, "present voltage: %i mV\n", | 611 | seq_printf(seq, "present voltage: %i mV\n", |
1086 | battery->state.voltage * battery->info.vscale); | 612 | battery->voltage_now * acpi_battery_vscale(battery)); |
1087 | 613 | ||
1088 | end: | 614 | end: |
1089 | 615 | mutex_unlock(&sbs->lock); | |
1090 | sbs_mutex_unlock(sbs); | ||
1091 | |||
1092 | return result; | 616 | return result; |
1093 | } | 617 | } |
1094 | 618 | ||
@@ -1102,48 +626,25 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) | |||
1102 | struct acpi_battery *battery = seq->private; | 626 | struct acpi_battery *battery = seq->private; |
1103 | struct acpi_sbs *sbs = battery->sbs; | 627 | struct acpi_sbs *sbs = battery->sbs; |
1104 | int result = 0; | 628 | int result = 0; |
1105 | int cscale; | ||
1106 | |||
1107 | if (sbs_mutex_lock(sbs)) { | ||
1108 | return -ENODEV; | ||
1109 | } | ||
1110 | |||
1111 | result = acpi_check_update_proc(sbs); | ||
1112 | if (result) | ||
1113 | goto end; | ||
1114 | 629 | ||
1115 | if (update_time == 0) { | 630 | mutex_lock(&sbs->lock); |
1116 | result = acpi_sbs_update_run(sbs, battery->id, DATA_TYPE_ALARM); | ||
1117 | if (result) { | ||
1118 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1119 | "acpi_sbs_update_run() failed")); | ||
1120 | } | ||
1121 | } | ||
1122 | 631 | ||
1123 | if (!battery->battery_present) { | 632 | if (!battery->present) { |
1124 | seq_printf(seq, "present: no\n"); | 633 | seq_printf(seq, "present: no\n"); |
1125 | goto end; | 634 | goto end; |
1126 | } | 635 | } |
1127 | 636 | ||
1128 | if (battery->info.capacity_mode) { | 637 | acpi_battery_get_alarm(battery); |
1129 | cscale = battery->info.vscale * battery->info.ipscale; | ||
1130 | } else { | ||
1131 | cscale = battery->info.ipscale; | ||
1132 | } | ||
1133 | |||
1134 | seq_printf(seq, "alarm: "); | 638 | seq_printf(seq, "alarm: "); |
1135 | if (battery->alarm.remaining_capacity) { | 639 | if (battery->alarm_capacity) |
1136 | seq_printf(seq, "%i%s\n", | 640 | seq_printf(seq, "%i%s\n", |
1137 | battery->alarm.remaining_capacity * cscale, | 641 | battery->alarm_capacity * |
1138 | battery->info.capacity_mode ? "0 mWh" : " mAh"); | 642 | acpi_battery_scale(battery), |
1139 | } else { | 643 | acpi_battery_units(battery)); |
644 | else | ||
1140 | seq_printf(seq, "disabled\n"); | 645 | seq_printf(seq, "disabled\n"); |
1141 | } | ||
1142 | |||
1143 | end: | 646 | end: |
1144 | 647 | mutex_unlock(&sbs->lock); | |
1145 | sbs_mutex_unlock(sbs); | ||
1146 | |||
1147 | return result; | 648 | return result; |
1148 | } | 649 | } |
1149 | 650 | ||
@@ -1155,59 +656,29 @@ acpi_battery_write_alarm(struct file *file, const char __user * buffer, | |||
1155 | struct acpi_battery *battery = seq->private; | 656 | struct acpi_battery *battery = seq->private; |
1156 | struct acpi_sbs *sbs = battery->sbs; | 657 | struct acpi_sbs *sbs = battery->sbs; |
1157 | char alarm_string[12] = { '\0' }; | 658 | char alarm_string[12] = { '\0' }; |
1158 | int result, old_alarm, new_alarm; | 659 | int result = 0; |
1159 | 660 | mutex_lock(&sbs->lock); | |
1160 | if (sbs_mutex_lock(sbs)) { | 661 | if (!battery->present) { |
1161 | return -ENODEV; | ||
1162 | } | ||
1163 | |||
1164 | result = acpi_check_update_proc(sbs); | ||
1165 | if (result) | ||
1166 | goto end; | ||
1167 | |||
1168 | if (!battery->battery_present) { | ||
1169 | result = -ENODEV; | 662 | result = -ENODEV; |
1170 | goto end; | 663 | goto end; |
1171 | } | 664 | } |
1172 | |||
1173 | if (count > sizeof(alarm_string) - 1) { | 665 | if (count > sizeof(alarm_string) - 1) { |
1174 | result = -EINVAL; | 666 | result = -EINVAL; |
1175 | goto end; | 667 | goto end; |
1176 | } | 668 | } |
1177 | |||
1178 | if (copy_from_user(alarm_string, buffer, count)) { | 669 | if (copy_from_user(alarm_string, buffer, count)) { |
1179 | result = -EFAULT; | 670 | result = -EFAULT; |
1180 | goto end; | 671 | goto end; |
1181 | } | 672 | } |
1182 | |||
1183 | alarm_string[count] = 0; | 673 | alarm_string[count] = 0; |
1184 | 674 | battery->alarm_capacity = simple_strtoul(alarm_string, NULL, 0) / | |
1185 | old_alarm = battery->alarm.remaining_capacity; | 675 | acpi_battery_scale(battery); |
1186 | new_alarm = simple_strtoul(alarm_string, NULL, 0); | 676 | acpi_battery_set_alarm(battery); |
1187 | |||
1188 | result = acpi_battery_set_alarm(battery, new_alarm); | ||
1189 | if (result) { | ||
1190 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1191 | "acpi_battery_set_alarm() failed")); | ||
1192 | acpi_battery_set_alarm(battery, old_alarm); | ||
1193 | goto end; | ||
1194 | } | ||
1195 | result = acpi_battery_get_alarm(battery); | ||
1196 | if (result) { | ||
1197 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1198 | "acpi_battery_get_alarm() failed")); | ||
1199 | acpi_battery_set_alarm(battery, old_alarm); | ||
1200 | goto end; | ||
1201 | } | ||
1202 | |||
1203 | end: | 677 | end: |
1204 | sbs_mutex_unlock(sbs); | 678 | mutex_unlock(&sbs->lock); |
1205 | 679 | if (result) | |
1206 | if (result) { | ||
1207 | return result; | 680 | return result; |
1208 | } else { | 681 | return count; |
1209 | return count; | ||
1210 | } | ||
1211 | } | 682 | } |
1212 | 683 | ||
1213 | static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) | 684 | static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) |
@@ -1246,26 +717,15 @@ static struct proc_dir_entry *acpi_ac_dir = NULL; | |||
1246 | 717 | ||
1247 | static int acpi_ac_read_state(struct seq_file *seq, void *offset) | 718 | static int acpi_ac_read_state(struct seq_file *seq, void *offset) |
1248 | { | 719 | { |
1249 | struct acpi_sbs *sbs = seq->private; | ||
1250 | int result; | ||
1251 | 720 | ||
1252 | if (sbs_mutex_lock(sbs)) { | 721 | struct acpi_sbs *sbs = seq->private; |
1253 | return -ENODEV; | ||
1254 | } | ||
1255 | 722 | ||
1256 | if (update_time == 0) { | 723 | mutex_lock(&sbs->lock); |
1257 | result = acpi_sbs_update_run(sbs, -1, DATA_TYPE_AC_STATE); | ||
1258 | if (result) { | ||
1259 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1260 | "acpi_sbs_update_run() failed")); | ||
1261 | } | ||
1262 | } | ||
1263 | 724 | ||
1264 | seq_printf(seq, "state: %s\n", | 725 | seq_printf(seq, "state: %s\n", |
1265 | sbs->ac.ac_present ? "on-line" : "off-line"); | 726 | sbs->charger_present ? "on-line" : "off-line"); |
1266 | |||
1267 | sbs_mutex_unlock(sbs); | ||
1268 | 727 | ||
728 | mutex_unlock(&sbs->lock); | ||
1269 | return 0; | 729 | return 0; |
1270 | } | 730 | } |
1271 | 731 | ||
@@ -1282,429 +742,203 @@ static struct file_operations acpi_ac_state_fops = { | |||
1282 | .owner = THIS_MODULE, | 742 | .owner = THIS_MODULE, |
1283 | }; | 743 | }; |
1284 | 744 | ||
745 | #endif | ||
746 | |||
1285 | /* -------------------------------------------------------------------------- | 747 | /* -------------------------------------------------------------------------- |
1286 | Driver Interface | 748 | Driver Interface |
1287 | -------------------------------------------------------------------------- */ | 749 | -------------------------------------------------------------------------- */ |
750 | static int acpi_battery_read(struct acpi_battery *battery) | ||
751 | { | ||
752 | int result = 0, saved_present = battery->present; | ||
753 | u16 state; | ||
754 | |||
755 | if (battery->sbs->manager_present) { | ||
756 | result = acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, | ||
757 | ACPI_SBS_MANAGER, 0x01, (u8 *)&state); | ||
758 | if (!result) | ||
759 | battery->present = state & (1 << battery->id); | ||
760 | state &= 0x0fff; | ||
761 | state |= 1 << (battery->id + 12); | ||
762 | acpi_smbus_write(battery->sbs->hc, SMBUS_WRITE_WORD, | ||
763 | ACPI_SBS_MANAGER, 0x01, (u8 *)&state, 2); | ||
764 | } else if (battery->id == 0) | ||
765 | battery->present = 1; | ||
766 | if (result || !battery->present) | ||
767 | return result; | ||
1288 | 768 | ||
1289 | /* Smart Battery */ | 769 | if (saved_present != battery->present) { |
770 | battery->update_time = 0; | ||
771 | result = acpi_battery_get_info(battery); | ||
772 | if (result) | ||
773 | return result; | ||
774 | } | ||
775 | result = acpi_battery_get_state(battery); | ||
776 | return result; | ||
777 | } | ||
1290 | 778 | ||
779 | /* Smart Battery */ | ||
1291 | static int acpi_battery_add(struct acpi_sbs *sbs, int id) | 780 | static int acpi_battery_add(struct acpi_sbs *sbs, int id) |
1292 | { | 781 | { |
1293 | int is_present; | 782 | struct acpi_battery *battery = &sbs->battery[id]; |
1294 | int result; | 783 | int result; |
1295 | char dir_name[32]; | ||
1296 | struct acpi_battery *battery; | ||
1297 | |||
1298 | battery = &sbs->battery[id]; | ||
1299 | |||
1300 | battery->alive = 0; | ||
1301 | 784 | ||
1302 | battery->init_state = 0; | ||
1303 | battery->id = id; | 785 | battery->id = id; |
1304 | battery->sbs = sbs; | 786 | battery->sbs = sbs; |
787 | result = acpi_battery_read(battery); | ||
788 | if (result) | ||
789 | return result; | ||
1305 | 790 | ||
1306 | result = acpi_battery_select(battery); | 791 | sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); |
1307 | if (result) { | 792 | #ifdef CONFIG_ACPI_PROCFS |
1308 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 793 | acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir, |
1309 | "acpi_battery_select() failed")); | 794 | battery->name, &acpi_battery_info_fops, |
1310 | goto end; | 795 | &acpi_battery_state_fops, &acpi_battery_alarm_fops, |
1311 | } | 796 | battery); |
1312 | 797 | #endif | |
1313 | result = acpi_battery_get_present(battery); | 798 | battery->bat.name = battery->name; |
1314 | if (result) { | 799 | battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; |
1315 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | 800 | if (!acpi_battery_mode(battery)) { |
1316 | "acpi_battery_get_present() failed")); | 801 | battery->bat.properties = sbs_charge_battery_props; |
1317 | goto end; | 802 | battery->bat.num_properties = |
1318 | } | 803 | ARRAY_SIZE(sbs_charge_battery_props); |
1319 | 804 | } else { | |
1320 | is_present = battery->battery_present; | 805 | battery->bat.properties = sbs_energy_battery_props; |
1321 | 806 | battery->bat.num_properties = | |
1322 | if (is_present) { | 807 | ARRAY_SIZE(sbs_energy_battery_props); |
1323 | result = acpi_battery_init(battery); | ||
1324 | if (result) { | ||
1325 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1326 | "acpi_battery_init() failed")); | ||
1327 | goto end; | ||
1328 | } | ||
1329 | battery->init_state = 1; | ||
1330 | } | ||
1331 | |||
1332 | sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); | ||
1333 | |||
1334 | result = acpi_sbs_generic_add_fs(&battery->battery_entry, | ||
1335 | acpi_battery_dir, | ||
1336 | dir_name, | ||
1337 | &acpi_battery_info_fops, | ||
1338 | &acpi_battery_state_fops, | ||
1339 | &acpi_battery_alarm_fops, battery); | ||
1340 | if (result) { | ||
1341 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1342 | "acpi_sbs_generic_add_fs() failed")); | ||
1343 | goto end; | ||
1344 | } | 808 | } |
1345 | battery->alive = 1; | 809 | battery->bat.get_property = acpi_sbs_battery_get_property; |
1346 | 810 | result = power_supply_register(&sbs->device->dev, &battery->bat); | |
811 | device_create_file(battery->bat.dev, &alarm_attr); | ||
1347 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", | 812 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", |
1348 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), dir_name, | 813 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), |
1349 | sbs->battery->battery_present ? "present" : "absent"); | 814 | battery->name, sbs->battery->present ? "present" : "absent"); |
1350 | |||
1351 | end: | ||
1352 | return result; | 815 | return result; |
1353 | } | 816 | } |
1354 | 817 | ||
1355 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) | 818 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) |
1356 | { | 819 | { |
1357 | 820 | if (sbs->battery[id].bat.dev) | |
1358 | if (sbs->battery[id].battery_entry) { | 821 | device_remove_file(sbs->battery[id].bat.dev, &alarm_attr); |
1359 | acpi_sbs_generic_remove_fs(&(sbs->battery[id].battery_entry), | 822 | power_supply_unregister(&sbs->battery[id].bat); |
1360 | acpi_battery_dir); | 823 | #ifdef CONFIG_ACPI_PROCFS |
1361 | } | 824 | if (sbs->battery[id].proc_entry) { |
825 | acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry), | ||
826 | acpi_battery_dir); | ||
827 | } | ||
828 | #endif | ||
1362 | } | 829 | } |
1363 | 830 | ||
1364 | static int acpi_ac_add(struct acpi_sbs *sbs) | 831 | static int acpi_charger_add(struct acpi_sbs *sbs) |
1365 | { | 832 | { |
1366 | int result; | 833 | int result; |
1367 | 834 | ||
1368 | result = acpi_ac_get_present(sbs); | 835 | result = acpi_ac_get_present(sbs); |
1369 | if (result) { | 836 | if (result) |
1370 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1371 | "acpi_ac_get_present() failed")); | ||
1372 | goto end; | 837 | goto end; |
1373 | } | 838 | #ifdef CONFIG_ACPI_PROCFS |
1374 | 839 | result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir, | |
1375 | result = acpi_sbs_generic_add_fs(&sbs->ac_entry, | 840 | ACPI_AC_DIR_NAME, NULL, |
1376 | acpi_ac_dir, | 841 | &acpi_ac_state_fops, NULL, sbs); |
1377 | ACPI_AC_DIR_NAME, | 842 | if (result) |
1378 | NULL, &acpi_ac_state_fops, NULL, sbs); | ||
1379 | if (result) { | ||
1380 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1381 | "acpi_sbs_generic_add_fs() failed")); | ||
1382 | goto end; | 843 | goto end; |
1383 | } | 844 | #endif |
1384 | 845 | sbs->charger.name = "sbs-charger"; | |
846 | sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; | ||
847 | sbs->charger.properties = sbs_ac_props; | ||
848 | sbs->charger.num_properties = ARRAY_SIZE(sbs_ac_props); | ||
849 | sbs->charger.get_property = sbs_get_ac_property; | ||
850 | power_supply_register(&sbs->device->dev, &sbs->charger); | ||
1385 | printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n", | 851 | printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n", |
1386 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), | 852 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), |
1387 | ACPI_AC_DIR_NAME, sbs->ac.ac_present ? "on-line" : "off-line"); | 853 | ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line"); |
1388 | |||
1389 | end: | 854 | end: |
1390 | |||
1391 | return result; | 855 | return result; |
1392 | } | 856 | } |
1393 | 857 | ||
1394 | static void acpi_ac_remove(struct acpi_sbs *sbs) | 858 | static void acpi_charger_remove(struct acpi_sbs *sbs) |
1395 | { | 859 | { |
1396 | 860 | if (sbs->charger.dev) | |
1397 | if (sbs->ac_entry) { | 861 | power_supply_unregister(&sbs->charger); |
1398 | acpi_sbs_generic_remove_fs(&sbs->ac_entry, acpi_ac_dir); | 862 | #ifdef CONFIG_ACPI_PROCFS |
1399 | } | 863 | if (sbs->charger_entry) |
864 | acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); | ||
865 | #endif | ||
1400 | } | 866 | } |
1401 | 867 | ||
1402 | static void acpi_sbs_update_time_run(unsigned long data) | 868 | void acpi_sbs_callback(void *context) |
1403 | { | 869 | { |
1404 | acpi_os_execute(OSL_GPE_HANDLER, acpi_sbs_update_time, (void *)data); | 870 | int id; |
1405 | } | 871 | struct acpi_sbs *sbs = context; |
1406 | 872 | struct acpi_battery *bat; | |
1407 | static int acpi_sbs_update_run(struct acpi_sbs *sbs, int id, int data_type) | 873 | u8 saved_charger_state = sbs->charger_present; |
1408 | { | 874 | u8 saved_battery_state; |
1409 | struct acpi_battery *battery; | 875 | acpi_ac_get_present(sbs); |
1410 | int result = 0, cnt; | 876 | if (sbs->charger_present != saved_charger_state) { |
1411 | int old_ac_present = -1; | 877 | #ifdef CONFIG_ACPI_PROC_EVENT |
1412 | int old_battery_present = -1; | 878 | acpi_bus_generate_proc_event4(ACPI_AC_CLASS, ACPI_AC_DIR_NAME, |
1413 | int new_ac_present = -1; | 879 | ACPI_SBS_NOTIFY_STATUS, |
1414 | int new_battery_present = -1; | 880 | sbs->charger_present); |
1415 | int id_min = 0, id_max = MAX_SBS_BAT - 1; | 881 | #endif |
1416 | char dir_name[32]; | 882 | kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE); |
1417 | int do_battery_init = 0, do_ac_init = 0; | 883 | } |
1418 | int old_remaining_capacity = 0; | 884 | if (sbs->manager_present) { |
1419 | int update_battery = 1; | 885 | for (id = 0; id < MAX_SBS_BAT; ++id) { |
1420 | int up_tm = update_time; | 886 | if (!(sbs->batteries_supported & (1 << id))) |
1421 | 887 | continue; | |
1422 | if (sbs_zombie(sbs)) { | 888 | bat = &sbs->battery[id]; |
1423 | goto end; | 889 | saved_battery_state = bat->present; |
1424 | } | 890 | acpi_battery_read(bat); |
1425 | 891 | if (saved_battery_state == bat->present) | |
1426 | if (id >= 0) { | 892 | continue; |
1427 | id_min = id_max = id; | 893 | #ifdef CONFIG_ACPI_PROC_EVENT |
1428 | } | 894 | acpi_bus_generate_proc_event4(ACPI_BATTERY_CLASS, |
1429 | 895 | bat->name, | |
1430 | if (data_type == DATA_TYPE_COMMON && up_tm > 0) { | 896 | ACPI_SBS_NOTIFY_STATUS, |
1431 | cnt = up_tm / (up_tm > UPDATE_DELAY ? UPDATE_DELAY : up_tm); | 897 | bat->present); |
1432 | if (sbs->run_cnt % cnt != 0) { | 898 | #endif |
1433 | update_battery = 0; | 899 | kobject_uevent(&bat->bat.dev->kobj, KOBJ_CHANGE); |
1434 | } | ||
1435 | } | ||
1436 | |||
1437 | sbs->run_cnt++; | ||
1438 | |||
1439 | old_ac_present = sbs->ac.ac_present; | ||
1440 | |||
1441 | result = acpi_ac_get_present(sbs); | ||
1442 | if (result) { | ||
1443 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1444 | "acpi_ac_get_present() failed")); | ||
1445 | } | ||
1446 | |||
1447 | new_ac_present = sbs->ac.ac_present; | ||
1448 | |||
1449 | do_ac_init = (old_ac_present != new_ac_present); | ||
1450 | if (sbs->run_cnt == 1 && data_type == DATA_TYPE_COMMON) { | ||
1451 | do_ac_init = 1; | ||
1452 | } | ||
1453 | |||
1454 | if (do_ac_init) { | ||
1455 | result = acpi_sbs_generate_event(sbs->device, | ||
1456 | ACPI_SBS_AC_NOTIFY_STATUS, | ||
1457 | new_ac_present, | ||
1458 | ACPI_AC_DIR_NAME, | ||
1459 | ACPI_AC_CLASS); | ||
1460 | if (result) { | ||
1461 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1462 | "acpi_sbs_generate_event() failed")); | ||
1463 | } | ||
1464 | } | ||
1465 | |||
1466 | if (data_type == DATA_TYPE_COMMON) { | ||
1467 | if (!do_ac_init && !update_battery) { | ||
1468 | goto end; | ||
1469 | } | ||
1470 | } | ||
1471 | |||
1472 | if (data_type == DATA_TYPE_AC_STATE && !do_ac_init) { | ||
1473 | goto end; | ||
1474 | } | ||
1475 | |||
1476 | for (id = id_min; id <= id_max; id++) { | ||
1477 | battery = &sbs->battery[id]; | ||
1478 | if (battery->alive == 0) { | ||
1479 | continue; | ||
1480 | } | ||
1481 | |||
1482 | old_remaining_capacity = battery->state.remaining_capacity; | ||
1483 | |||
1484 | old_battery_present = battery->battery_present; | ||
1485 | |||
1486 | result = acpi_battery_select(battery); | ||
1487 | if (result) { | ||
1488 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1489 | "acpi_battery_select() failed")); | ||
1490 | } | ||
1491 | |||
1492 | result = acpi_battery_get_present(battery); | ||
1493 | if (result) { | ||
1494 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1495 | "acpi_battery_get_present() failed")); | ||
1496 | } | ||
1497 | |||
1498 | new_battery_present = battery->battery_present; | ||
1499 | |||
1500 | do_battery_init = ((old_battery_present != new_battery_present) | ||
1501 | && new_battery_present); | ||
1502 | if (!new_battery_present) | ||
1503 | goto event; | ||
1504 | if (do_ac_init || do_battery_init) { | ||
1505 | result = acpi_battery_init(battery); | ||
1506 | if (result) { | ||
1507 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1508 | "acpi_battery_init() " | ||
1509 | "failed")); | ||
1510 | } | ||
1511 | } | ||
1512 | if (sbs_zombie(sbs)) { | ||
1513 | goto end; | ||
1514 | } | ||
1515 | |||
1516 | if ((data_type == DATA_TYPE_COMMON | ||
1517 | || data_type == DATA_TYPE_INFO) | ||
1518 | && new_battery_present) { | ||
1519 | result = acpi_battery_get_info(battery); | ||
1520 | if (result) { | ||
1521 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1522 | "acpi_battery_get_info() failed")); | ||
1523 | } | ||
1524 | } | ||
1525 | if (data_type == DATA_TYPE_INFO) { | ||
1526 | continue; | ||
1527 | } | ||
1528 | if (sbs_zombie(sbs)) { | ||
1529 | goto end; | ||
1530 | } | ||
1531 | |||
1532 | if ((data_type == DATA_TYPE_COMMON | ||
1533 | || data_type == DATA_TYPE_STATE) | ||
1534 | && new_battery_present) { | ||
1535 | result = acpi_battery_get_state(battery); | ||
1536 | if (result) { | ||
1537 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1538 | "acpi_battery_get_state() failed")); | ||
1539 | } | ||
1540 | } | ||
1541 | if (data_type == DATA_TYPE_STATE) { | ||
1542 | goto event; | ||
1543 | } | ||
1544 | if (sbs_zombie(sbs)) { | ||
1545 | goto end; | ||
1546 | } | ||
1547 | |||
1548 | if ((data_type == DATA_TYPE_COMMON | ||
1549 | || data_type == DATA_TYPE_ALARM) | ||
1550 | && new_battery_present) { | ||
1551 | result = acpi_battery_get_alarm(battery); | ||
1552 | if (result) { | ||
1553 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1554 | "acpi_battery_get_alarm() " | ||
1555 | "failed")); | ||
1556 | } | ||
1557 | } | ||
1558 | if (data_type == DATA_TYPE_ALARM) { | ||
1559 | continue; | ||
1560 | } | ||
1561 | if (sbs_zombie(sbs)) { | ||
1562 | goto end; | ||
1563 | } | ||
1564 | |||
1565 | event: | ||
1566 | |||
1567 | if (old_battery_present != new_battery_present || do_ac_init || | ||
1568 | old_remaining_capacity != | ||
1569 | battery->state.remaining_capacity) { | ||
1570 | sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); | ||
1571 | result = acpi_sbs_generate_event(sbs->device, | ||
1572 | ACPI_SBS_BATTERY_NOTIFY_STATUS, | ||
1573 | new_battery_present, | ||
1574 | dir_name, | ||
1575 | ACPI_BATTERY_CLASS); | ||
1576 | if (result) { | ||
1577 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1578 | "acpi_sbs_generate_event() " | ||
1579 | "failed")); | ||
1580 | } | ||
1581 | } | 900 | } |
1582 | } | 901 | } |
1583 | |||
1584 | end: | ||
1585 | |||
1586 | return result; | ||
1587 | } | 902 | } |
1588 | 903 | ||
1589 | static void acpi_sbs_update_time(void *data) | 904 | static int acpi_sbs_remove(struct acpi_device *device, int type); |
1590 | { | ||
1591 | struct acpi_sbs *sbs = data; | ||
1592 | unsigned long delay = -1; | ||
1593 | int result; | ||
1594 | unsigned int up_tm = update_time; | ||
1595 | |||
1596 | if (sbs_mutex_lock(sbs)) | ||
1597 | return; | ||
1598 | |||
1599 | result = acpi_sbs_update_run(sbs, -1, DATA_TYPE_COMMON); | ||
1600 | if (result) { | ||
1601 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1602 | "acpi_sbs_update_run() failed")); | ||
1603 | } | ||
1604 | |||
1605 | if (sbs_zombie(sbs)) { | ||
1606 | goto end; | ||
1607 | } | ||
1608 | |||
1609 | if (!up_tm) { | ||
1610 | if (timer_pending(&sbs->update_timer)) | ||
1611 | del_timer(&sbs->update_timer); | ||
1612 | } else { | ||
1613 | delay = (up_tm > UPDATE_DELAY ? UPDATE_DELAY : up_tm); | ||
1614 | delay = jiffies + HZ * delay; | ||
1615 | if (timer_pending(&sbs->update_timer)) { | ||
1616 | mod_timer(&sbs->update_timer, delay); | ||
1617 | } else { | ||
1618 | sbs->update_timer.data = (unsigned long)data; | ||
1619 | sbs->update_timer.function = acpi_sbs_update_time_run; | ||
1620 | sbs->update_timer.expires = delay; | ||
1621 | add_timer(&sbs->update_timer); | ||
1622 | } | ||
1623 | } | ||
1624 | |||
1625 | end: | ||
1626 | |||
1627 | sbs_mutex_unlock(sbs); | ||
1628 | } | ||
1629 | 905 | ||
1630 | static int acpi_sbs_add(struct acpi_device *device) | 906 | static int acpi_sbs_add(struct acpi_device *device) |
1631 | { | 907 | { |
1632 | struct acpi_sbs *sbs = NULL; | 908 | struct acpi_sbs *sbs; |
1633 | int result = 0, remove_result = 0; | 909 | int result = 0; |
1634 | int id; | 910 | int id; |
1635 | acpi_status status = AE_OK; | ||
1636 | unsigned long val; | ||
1637 | |||
1638 | status = | ||
1639 | acpi_evaluate_integer(device->handle, "_EC", NULL, &val); | ||
1640 | if (ACPI_FAILURE(status)) { | ||
1641 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Error obtaining _EC")); | ||
1642 | return -EIO; | ||
1643 | } | ||
1644 | 911 | ||
1645 | sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL); | 912 | sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL); |
1646 | if (!sbs) { | 913 | if (!sbs) { |
1647 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, "kzalloc() failed")); | ||
1648 | result = -ENOMEM; | 914 | result = -ENOMEM; |
1649 | goto end; | 915 | goto end; |
1650 | } | 916 | } |
1651 | 917 | ||
1652 | mutex_init(&sbs->mutex); | 918 | mutex_init(&sbs->lock); |
1653 | |||
1654 | sbs_mutex_lock(sbs); | ||
1655 | 919 | ||
1656 | sbs->base = 0xff & (val >> 8); | 920 | sbs->hc = acpi_driver_data(device->parent); |
1657 | sbs->device = device; | 921 | sbs->device = device; |
1658 | |||
1659 | strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME); | 922 | strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME); |
1660 | strcpy(acpi_device_class(device), ACPI_SBS_CLASS); | 923 | strcpy(acpi_device_class(device), ACPI_SBS_CLASS); |
1661 | acpi_driver_data(device) = sbs; | 924 | acpi_driver_data(device) = sbs; |
1662 | 925 | ||
1663 | result = acpi_ac_add(sbs); | 926 | result = acpi_charger_add(sbs); |
1664 | if (result) { | ||
1665 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, "acpi_ac_add() failed")); | ||
1666 | goto end; | ||
1667 | } | ||
1668 | |||
1669 | acpi_sbsm_get_info(sbs); | ||
1670 | |||
1671 | if (!sbs->sbsm_present) { | ||
1672 | result = acpi_battery_add(sbs, 0); | ||
1673 | if (result) { | ||
1674 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1675 | "acpi_battery_add() failed")); | ||
1676 | goto end; | ||
1677 | } | ||
1678 | } else { | ||
1679 | for (id = 0; id < MAX_SBS_BAT; id++) { | ||
1680 | if ((sbs->sbsm_batteries_supported & (1 << id))) { | ||
1681 | result = acpi_battery_add(sbs, id); | ||
1682 | if (result) { | ||
1683 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1684 | "acpi_battery_add() failed")); | ||
1685 | goto end; | ||
1686 | } | ||
1687 | } | ||
1688 | } | ||
1689 | } | ||
1690 | |||
1691 | init_timer(&sbs->update_timer); | ||
1692 | result = acpi_check_update_proc(sbs); | ||
1693 | if (result) | 927 | if (result) |
1694 | goto end; | 928 | goto end; |
1695 | 929 | ||
930 | result = acpi_manager_get_info(sbs); | ||
931 | if (!result) { | ||
932 | sbs->manager_present = 1; | ||
933 | for (id = 0; id < MAX_SBS_BAT; ++id) | ||
934 | if ((sbs->batteries_supported & (1 << id))) | ||
935 | acpi_battery_add(sbs, id); | ||
936 | } else | ||
937 | acpi_battery_add(sbs, 0); | ||
938 | acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs); | ||
1696 | end: | 939 | end: |
1697 | 940 | if (result) | |
1698 | sbs_mutex_unlock(sbs); | 941 | acpi_sbs_remove(device, 0); |
1699 | |||
1700 | if (result) { | ||
1701 | remove_result = acpi_sbs_remove(device, 0); | ||
1702 | if (remove_result) { | ||
1703 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1704 | "acpi_sbs_remove() failed")); | ||
1705 | } | ||
1706 | } | ||
1707 | |||
1708 | return result; | 942 | return result; |
1709 | } | 943 | } |
1710 | 944 | ||
@@ -1713,39 +947,25 @@ static int acpi_sbs_remove(struct acpi_device *device, int type) | |||
1713 | struct acpi_sbs *sbs; | 947 | struct acpi_sbs *sbs; |
1714 | int id; | 948 | int id; |
1715 | 949 | ||
1716 | if (!device) { | 950 | if (!device) |
1717 | return -EINVAL; | 951 | return -EINVAL; |
1718 | } | ||
1719 | |||
1720 | sbs = acpi_driver_data(device); | 952 | sbs = acpi_driver_data(device); |
1721 | if (!sbs) { | 953 | if (!sbs) |
1722 | return -EINVAL; | 954 | return -EINVAL; |
1723 | } | 955 | mutex_lock(&sbs->lock); |
1724 | 956 | acpi_smbus_unregister_callback(sbs->hc); | |
1725 | sbs_mutex_lock(sbs); | 957 | for (id = 0; id < MAX_SBS_BAT; ++id) |
1726 | |||
1727 | sbs->zombie = 1; | ||
1728 | del_timer_sync(&sbs->update_timer); | ||
1729 | acpi_os_wait_events_complete(NULL); | ||
1730 | del_timer_sync(&sbs->update_timer); | ||
1731 | |||
1732 | for (id = 0; id < MAX_SBS_BAT; id++) { | ||
1733 | acpi_battery_remove(sbs, id); | 958 | acpi_battery_remove(sbs, id); |
1734 | } | 959 | acpi_charger_remove(sbs); |
1735 | 960 | mutex_unlock(&sbs->lock); | |
1736 | acpi_ac_remove(sbs); | 961 | mutex_destroy(&sbs->lock); |
1737 | |||
1738 | sbs_mutex_unlock(sbs); | ||
1739 | |||
1740 | mutex_destroy(&sbs->mutex); | ||
1741 | |||
1742 | kfree(sbs); | 962 | kfree(sbs); |
1743 | |||
1744 | return 0; | 963 | return 0; |
1745 | } | 964 | } |
1746 | 965 | ||
1747 | static void acpi_sbs_rmdirs(void) | 966 | static void acpi_sbs_rmdirs(void) |
1748 | { | 967 | { |
968 | #ifdef CONFIG_ACPI_PROCFS | ||
1749 | if (acpi_ac_dir) { | 969 | if (acpi_ac_dir) { |
1750 | acpi_unlock_ac_dir(acpi_ac_dir); | 970 | acpi_unlock_ac_dir(acpi_ac_dir); |
1751 | acpi_ac_dir = NULL; | 971 | acpi_ac_dir = NULL; |
@@ -1754,69 +974,58 @@ static void acpi_sbs_rmdirs(void) | |||
1754 | acpi_unlock_battery_dir(acpi_battery_dir); | 974 | acpi_unlock_battery_dir(acpi_battery_dir); |
1755 | acpi_battery_dir = NULL; | 975 | acpi_battery_dir = NULL; |
1756 | } | 976 | } |
977 | #endif | ||
1757 | } | 978 | } |
1758 | 979 | ||
1759 | static int acpi_sbs_resume(struct acpi_device *device) | 980 | static int acpi_sbs_resume(struct acpi_device *device) |
1760 | { | 981 | { |
1761 | struct acpi_sbs *sbs; | 982 | struct acpi_sbs *sbs; |
1762 | |||
1763 | if (!device) | 983 | if (!device) |
1764 | return -EINVAL; | 984 | return -EINVAL; |
1765 | |||
1766 | sbs = device->driver_data; | 985 | sbs = device->driver_data; |
1767 | 986 | acpi_sbs_callback(sbs); | |
1768 | sbs->run_cnt = 0; | ||
1769 | |||
1770 | return 0; | 987 | return 0; |
1771 | } | 988 | } |
1772 | 989 | ||
990 | static struct acpi_driver acpi_sbs_driver = { | ||
991 | .name = "sbs", | ||
992 | .class = ACPI_SBS_CLASS, | ||
993 | .ids = sbs_device_ids, | ||
994 | .ops = { | ||
995 | .add = acpi_sbs_add, | ||
996 | .remove = acpi_sbs_remove, | ||
997 | .resume = acpi_sbs_resume, | ||
998 | }, | ||
999 | }; | ||
1000 | |||
1773 | static int __init acpi_sbs_init(void) | 1001 | static int __init acpi_sbs_init(void) |
1774 | { | 1002 | { |
1775 | int result = 0; | 1003 | int result = 0; |
1776 | 1004 | ||
1777 | if (acpi_disabled) | 1005 | if (acpi_disabled) |
1778 | return -ENODEV; | 1006 | return -ENODEV; |
1779 | 1007 | #ifdef CONFIG_ACPI_PROCFS | |
1780 | if (capacity_mode != DEF_CAPACITY_UNIT | ||
1781 | && capacity_mode != MAH_CAPACITY_UNIT | ||
1782 | && capacity_mode != MWH_CAPACITY_UNIT) { | ||
1783 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1784 | "invalid capacity_mode = %d", capacity_mode)); | ||
1785 | return -EINVAL; | ||
1786 | } | ||
1787 | |||
1788 | acpi_ac_dir = acpi_lock_ac_dir(); | 1008 | acpi_ac_dir = acpi_lock_ac_dir(); |
1789 | if (!acpi_ac_dir) { | 1009 | if (!acpi_ac_dir) |
1790 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1791 | "acpi_lock_ac_dir() failed")); | ||
1792 | return -ENODEV; | 1010 | return -ENODEV; |
1793 | } | ||
1794 | |||
1795 | acpi_battery_dir = acpi_lock_battery_dir(); | 1011 | acpi_battery_dir = acpi_lock_battery_dir(); |
1796 | if (!acpi_battery_dir) { | 1012 | if (!acpi_battery_dir) { |
1797 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1798 | "acpi_lock_battery_dir() failed")); | ||
1799 | acpi_sbs_rmdirs(); | 1013 | acpi_sbs_rmdirs(); |
1800 | return -ENODEV; | 1014 | return -ENODEV; |
1801 | } | 1015 | } |
1802 | 1016 | #endif | |
1803 | result = acpi_bus_register_driver(&acpi_sbs_driver); | 1017 | result = acpi_bus_register_driver(&acpi_sbs_driver); |
1804 | if (result < 0) { | 1018 | if (result < 0) { |
1805 | ACPI_EXCEPTION((AE_INFO, AE_ERROR, | ||
1806 | "acpi_bus_register_driver() failed")); | ||
1807 | acpi_sbs_rmdirs(); | 1019 | acpi_sbs_rmdirs(); |
1808 | return -ENODEV; | 1020 | return -ENODEV; |
1809 | } | 1021 | } |
1810 | |||
1811 | return 0; | 1022 | return 0; |
1812 | } | 1023 | } |
1813 | 1024 | ||
1814 | static void __exit acpi_sbs_exit(void) | 1025 | static void __exit acpi_sbs_exit(void) |
1815 | { | 1026 | { |
1816 | acpi_bus_unregister_driver(&acpi_sbs_driver); | 1027 | acpi_bus_unregister_driver(&acpi_sbs_driver); |
1817 | |||
1818 | acpi_sbs_rmdirs(); | 1028 | acpi_sbs_rmdirs(); |
1819 | |||
1820 | return; | 1029 | return; |
1821 | } | 1030 | } |
1822 | 1031 | ||
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c new file mode 100644 index 000000000000..046d7c3ed356 --- /dev/null +++ b/drivers/acpi/sbshc.c | |||
@@ -0,0 +1,309 @@ | |||
1 | /* | ||
2 | * SMBus driver for ACPI Embedded Controller (v0.1) | ||
3 | * | ||
4 | * Copyright (c) 2007 Alexey Starikovskiy | ||
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 version 2. | ||
9 | */ | ||
10 | |||
11 | #include <acpi/acpi_bus.h> | ||
12 | #include <acpi/acpi_drivers.h> | ||
13 | #include <acpi/actypes.h> | ||
14 | #include <linux/wait.h> | ||
15 | #include <linux/delay.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include "sbshc.h" | ||
18 | |||
19 | #define ACPI_SMB_HC_CLASS "smbus_host_controller" | ||
20 | #define ACPI_SMB_HC_DEVICE_NAME "ACPI SMBus HC" | ||
21 | |||
22 | struct acpi_smb_hc { | ||
23 | struct acpi_ec *ec; | ||
24 | struct mutex lock; | ||
25 | wait_queue_head_t wait; | ||
26 | u8 offset; | ||
27 | u8 query_bit; | ||
28 | smbus_alarm_callback callback; | ||
29 | void *context; | ||
30 | }; | ||
31 | |||
32 | static int acpi_smbus_hc_add(struct acpi_device *device); | ||
33 | static int acpi_smbus_hc_remove(struct acpi_device *device, int type); | ||
34 | |||
35 | static const struct acpi_device_id sbs_device_ids[] = { | ||
36 | {"ACPI0001", 0}, | ||
37 | {"ACPI0005", 0}, | ||
38 | {"", 0}, | ||
39 | }; | ||
40 | |||
41 | MODULE_DEVICE_TABLE(acpi, sbs_device_ids); | ||
42 | |||
43 | static struct acpi_driver acpi_smb_hc_driver = { | ||
44 | .name = "smbus_hc", | ||
45 | .class = ACPI_SMB_HC_CLASS, | ||
46 | .ids = sbs_device_ids, | ||
47 | .ops = { | ||
48 | .add = acpi_smbus_hc_add, | ||
49 | .remove = acpi_smbus_hc_remove, | ||
50 | }, | ||
51 | }; | ||
52 | |||
53 | union acpi_smb_status { | ||
54 | u8 raw; | ||
55 | struct { | ||
56 | u8 status:5; | ||
57 | u8 reserved:1; | ||
58 | u8 alarm:1; | ||
59 | u8 done:1; | ||
60 | } fields; | ||
61 | }; | ||
62 | |||
63 | enum acpi_smb_status_codes { | ||
64 | SMBUS_OK = 0, | ||
65 | SMBUS_UNKNOWN_FAILURE = 0x07, | ||
66 | SMBUS_DEVICE_ADDRESS_NACK = 0x10, | ||
67 | SMBUS_DEVICE_ERROR = 0x11, | ||
68 | SMBUS_DEVICE_COMMAND_ACCESS_DENIED = 0x12, | ||
69 | SMBUS_UNKNOWN_ERROR = 0x13, | ||
70 | SMBUS_DEVICE_ACCESS_DENIED = 0x17, | ||
71 | SMBUS_TIMEOUT = 0x18, | ||
72 | SMBUS_HOST_UNSUPPORTED_PROTOCOL = 0x19, | ||
73 | SMBUS_BUSY = 0x1a, | ||
74 | SMBUS_PEC_ERROR = 0x1f, | ||
75 | }; | ||
76 | |||
77 | enum acpi_smb_offset { | ||
78 | ACPI_SMB_PROTOCOL = 0, /* protocol, PEC */ | ||
79 | ACPI_SMB_STATUS = 1, /* status */ | ||
80 | ACPI_SMB_ADDRESS = 2, /* address */ | ||
81 | ACPI_SMB_COMMAND = 3, /* command */ | ||
82 | ACPI_SMB_DATA = 4, /* 32 data registers */ | ||
83 | ACPI_SMB_BLOCK_COUNT = 0x24, /* number of data bytes */ | ||
84 | ACPI_SMB_ALARM_ADDRESS = 0x25, /* alarm address */ | ||
85 | ACPI_SMB_ALARM_DATA = 0x26, /* 2 bytes alarm data */ | ||
86 | }; | ||
87 | |||
88 | static inline int smb_hc_read(struct acpi_smb_hc *hc, u8 address, u8 *data) | ||
89 | { | ||
90 | return ec_read(hc->offset + address, data); | ||
91 | } | ||
92 | |||
93 | static inline int smb_hc_write(struct acpi_smb_hc *hc, u8 address, u8 data) | ||
94 | { | ||
95 | return ec_write(hc->offset + address, data); | ||
96 | } | ||
97 | |||
98 | static inline int smb_check_done(struct acpi_smb_hc *hc) | ||
99 | { | ||
100 | union acpi_smb_status status = {.raw = 0}; | ||
101 | smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw); | ||
102 | return status.fields.done && (status.fields.status == SMBUS_OK); | ||
103 | } | ||
104 | |||
105 | static int wait_transaction_complete(struct acpi_smb_hc *hc, int timeout) | ||
106 | { | ||
107 | if (wait_event_timeout(hc->wait, smb_check_done(hc), | ||
108 | msecs_to_jiffies(timeout))) | ||
109 | return 0; | ||
110 | else | ||
111 | return -ETIME; | ||
112 | } | ||
113 | |||
114 | int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol, u8 address, | ||
115 | u8 command, u8 *data, u8 length) | ||
116 | { | ||
117 | int ret = -EFAULT, i; | ||
118 | u8 temp, sz = 0; | ||
119 | |||
120 | mutex_lock(&hc->lock); | ||
121 | if (smb_hc_read(hc, ACPI_SMB_PROTOCOL, &temp)) | ||
122 | goto end; | ||
123 | if (temp) { | ||
124 | ret = -EBUSY; | ||
125 | goto end; | ||
126 | } | ||
127 | smb_hc_write(hc, ACPI_SMB_COMMAND, command); | ||
128 | smb_hc_write(hc, ACPI_SMB_COMMAND, command); | ||
129 | if (!(protocol & 0x01)) { | ||
130 | smb_hc_write(hc, ACPI_SMB_BLOCK_COUNT, length); | ||
131 | for (i = 0; i < length; ++i) | ||
132 | smb_hc_write(hc, ACPI_SMB_DATA + i, data[i]); | ||
133 | } | ||
134 | smb_hc_write(hc, ACPI_SMB_ADDRESS, address << 1); | ||
135 | smb_hc_write(hc, ACPI_SMB_PROTOCOL, protocol); | ||
136 | /* | ||
137 | * Wait for completion. Save the status code, data size, | ||
138 | * and data into the return package (if required by the protocol). | ||
139 | */ | ||
140 | ret = wait_transaction_complete(hc, 1000); | ||
141 | if (ret || !(protocol & 0x01)) | ||
142 | goto end; | ||
143 | switch (protocol) { | ||
144 | case SMBUS_RECEIVE_BYTE: | ||
145 | case SMBUS_READ_BYTE: | ||
146 | sz = 1; | ||
147 | break; | ||
148 | case SMBUS_READ_WORD: | ||
149 | sz = 2; | ||
150 | break; | ||
151 | case SMBUS_READ_BLOCK: | ||
152 | if (smb_hc_read(hc, ACPI_SMB_BLOCK_COUNT, &sz)) { | ||
153 | ret = -EFAULT; | ||
154 | goto end; | ||
155 | } | ||
156 | sz &= 0x1f; | ||
157 | break; | ||
158 | } | ||
159 | for (i = 0; i < sz; ++i) | ||
160 | smb_hc_read(hc, ACPI_SMB_DATA + i, &data[i]); | ||
161 | end: | ||
162 | mutex_unlock(&hc->lock); | ||
163 | return ret; | ||
164 | } | ||
165 | |||
166 | int acpi_smbus_read(struct acpi_smb_hc *hc, u8 protocol, u8 address, | ||
167 | u8 command, u8 *data) | ||
168 | { | ||
169 | return acpi_smbus_transaction(hc, protocol, address, command, data, 0); | ||
170 | } | ||
171 | |||
172 | EXPORT_SYMBOL_GPL(acpi_smbus_read); | ||
173 | |||
174 | int acpi_smbus_write(struct acpi_smb_hc *hc, u8 protocol, u8 address, | ||
175 | u8 command, u8 *data, u8 length) | ||
176 | { | ||
177 | return acpi_smbus_transaction(hc, protocol, address, command, data, length); | ||
178 | } | ||
179 | |||
180 | EXPORT_SYMBOL_GPL(acpi_smbus_write); | ||
181 | |||
182 | int acpi_smbus_register_callback(struct acpi_smb_hc *hc, | ||
183 | smbus_alarm_callback callback, void *context) | ||
184 | { | ||
185 | mutex_lock(&hc->lock); | ||
186 | hc->callback = callback; | ||
187 | hc->context = context; | ||
188 | mutex_unlock(&hc->lock); | ||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | EXPORT_SYMBOL_GPL(acpi_smbus_register_callback); | ||
193 | |||
194 | int acpi_smbus_unregister_callback(struct acpi_smb_hc *hc) | ||
195 | { | ||
196 | mutex_lock(&hc->lock); | ||
197 | hc->callback = NULL; | ||
198 | hc->context = NULL; | ||
199 | mutex_unlock(&hc->lock); | ||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | EXPORT_SYMBOL_GPL(acpi_smbus_unregister_callback); | ||
204 | |||
205 | static void acpi_smbus_callback(void *context) | ||
206 | { | ||
207 | struct acpi_smb_hc *hc = context; | ||
208 | |||
209 | if (hc->callback) | ||
210 | hc->callback(hc->context); | ||
211 | } | ||
212 | |||
213 | static int smbus_alarm(void *context) | ||
214 | { | ||
215 | struct acpi_smb_hc *hc = context; | ||
216 | union acpi_smb_status status; | ||
217 | if (smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw)) | ||
218 | return 0; | ||
219 | /* Check if it is only a completion notify */ | ||
220 | if (status.fields.done) | ||
221 | wake_up(&hc->wait); | ||
222 | if (!status.fields.alarm) | ||
223 | return 0; | ||
224 | mutex_lock(&hc->lock); | ||
225 | smb_hc_write(hc, ACPI_SMB_STATUS, status.raw); | ||
226 | if (hc->callback) | ||
227 | acpi_os_execute(OSL_GPE_HANDLER, acpi_smbus_callback, hc); | ||
228 | mutex_unlock(&hc->lock); | ||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | typedef int (*acpi_ec_query_func) (void *data); | ||
233 | |||
234 | extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, | ||
235 | acpi_handle handle, acpi_ec_query_func func, | ||
236 | void *data); | ||
237 | |||
238 | static int acpi_smbus_hc_add(struct acpi_device *device) | ||
239 | { | ||
240 | int status; | ||
241 | unsigned long val; | ||
242 | struct acpi_smb_hc *hc; | ||
243 | |||
244 | if (!device) | ||
245 | return -EINVAL; | ||
246 | |||
247 | status = acpi_evaluate_integer(device->handle, "_EC", NULL, &val); | ||
248 | if (ACPI_FAILURE(status)) { | ||
249 | printk(KERN_ERR PREFIX "error obtaining _EC.\n"); | ||
250 | return -EIO; | ||
251 | } | ||
252 | |||
253 | strcpy(acpi_device_name(device), ACPI_SMB_HC_DEVICE_NAME); | ||
254 | strcpy(acpi_device_class(device), ACPI_SMB_HC_CLASS); | ||
255 | |||
256 | hc = kzalloc(sizeof(struct acpi_smb_hc), GFP_KERNEL); | ||
257 | if (!hc) | ||
258 | return -ENOMEM; | ||
259 | mutex_init(&hc->lock); | ||
260 | init_waitqueue_head(&hc->wait); | ||
261 | |||
262 | hc->ec = acpi_driver_data(device->parent); | ||
263 | hc->offset = (val >> 8) & 0xff; | ||
264 | hc->query_bit = val & 0xff; | ||
265 | acpi_driver_data(device) = hc; | ||
266 | |||
267 | acpi_ec_add_query_handler(hc->ec, hc->query_bit, NULL, smbus_alarm, hc); | ||
268 | printk(KERN_INFO PREFIX "SBS HC: EC = 0x%p, offset = 0x%0x, query_bit = 0x%0x\n", | ||
269 | hc->ec, hc->offset, hc->query_bit); | ||
270 | |||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit); | ||
275 | |||
276 | static int acpi_smbus_hc_remove(struct acpi_device *device, int type) | ||
277 | { | ||
278 | struct acpi_smb_hc *hc; | ||
279 | |||
280 | if (!device) | ||
281 | return -EINVAL; | ||
282 | |||
283 | hc = acpi_driver_data(device); | ||
284 | acpi_ec_remove_query_handler(hc->ec, hc->query_bit); | ||
285 | kfree(hc); | ||
286 | return 0; | ||
287 | } | ||
288 | |||
289 | static int __init acpi_smb_hc_init(void) | ||
290 | { | ||
291 | int result; | ||
292 | |||
293 | result = acpi_bus_register_driver(&acpi_smb_hc_driver); | ||
294 | if (result < 0) | ||
295 | return -ENODEV; | ||
296 | return 0; | ||
297 | } | ||
298 | |||
299 | static void __exit acpi_smb_hc_exit(void) | ||
300 | { | ||
301 | acpi_bus_unregister_driver(&acpi_smb_hc_driver); | ||
302 | } | ||
303 | |||
304 | module_init(acpi_smb_hc_init); | ||
305 | module_exit(acpi_smb_hc_exit); | ||
306 | |||
307 | MODULE_LICENSE("GPL"); | ||
308 | MODULE_AUTHOR("Alexey Starikovskiy"); | ||
309 | MODULE_DESCRIPTION("ACPI SMBus HC driver"); | ||
diff --git a/drivers/acpi/sbshc.h b/drivers/acpi/sbshc.h new file mode 100644 index 000000000000..3bda3491a97b --- /dev/null +++ b/drivers/acpi/sbshc.h | |||
@@ -0,0 +1,27 @@ | |||
1 | struct acpi_smb_hc; | ||
2 | enum acpi_smb_protocol { | ||
3 | SMBUS_WRITE_QUICK = 2, | ||
4 | SMBUS_READ_QUICK = 3, | ||
5 | SMBUS_SEND_BYTE = 4, | ||
6 | SMBUS_RECEIVE_BYTE = 5, | ||
7 | SMBUS_WRITE_BYTE = 6, | ||
8 | SMBUS_READ_BYTE = 7, | ||
9 | SMBUS_WRITE_WORD = 8, | ||
10 | SMBUS_READ_WORD = 9, | ||
11 | SMBUS_WRITE_BLOCK = 0xa, | ||
12 | SMBUS_READ_BLOCK = 0xb, | ||
13 | SMBUS_PROCESS_CALL = 0xc, | ||
14 | SMBUS_BLOCK_PROCESS_CALL = 0xd, | ||
15 | }; | ||
16 | |||
17 | static const u8 SMBUS_PEC = 0x80; | ||
18 | |||
19 | typedef void (*smbus_alarm_callback)(void *context); | ||
20 | |||
21 | extern int acpi_smbus_read(struct acpi_smb_hc *hc, u8 protocol, u8 address, | ||
22 | u8 command, u8 * data); | ||
23 | extern int acpi_smbus_write(struct acpi_smb_hc *hc, u8 protocol, u8 slave_address, | ||
24 | u8 command, u8 * data, u8 length); | ||
25 | extern int acpi_smbus_register_callback(struct acpi_smb_hc *hc, | ||
26 | smbus_alarm_callback callback, void *context); | ||
27 | extern int acpi_smbus_unregister_callback(struct acpi_smb_hc *hc); | ||
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index 048295ec3707..f3d3867303ec 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -44,7 +44,6 @@ int acpi_sleep_prepare(u32 acpi_state) | |||
44 | ACPI_FLUSH_CPU_CACHE(); | 44 | ACPI_FLUSH_CPU_CACHE(); |
45 | acpi_enable_wakeup_device_prep(acpi_state); | 45 | acpi_enable_wakeup_device_prep(acpi_state); |
46 | #endif | 46 | #endif |
47 | acpi_gpe_sleep_prepare(acpi_state); | ||
48 | acpi_enter_sleep_state_prep(acpi_state); | 47 | acpi_enter_sleep_state_prep(acpi_state); |
49 | return 0; | 48 | return 0; |
50 | } | 49 | } |
@@ -268,6 +267,11 @@ static void acpi_hibernation_leave(void) | |||
268 | 267 | ||
269 | static void acpi_hibernation_finish(void) | 268 | static void acpi_hibernation_finish(void) |
270 | { | 269 | { |
270 | /* | ||
271 | * If ACPI is not enabled by the BIOS and the boot kernel, we need to | ||
272 | * enable it here. | ||
273 | */ | ||
274 | acpi_enable(); | ||
271 | acpi_leave_sleep_state(ACPI_STATE_S4); | 275 | acpi_leave_sleep_state(ACPI_STATE_S4); |
272 | acpi_disable_wakeup_device(ACPI_STATE_S4); | 276 | acpi_disable_wakeup_device(ACPI_STATE_S4); |
273 | 277 | ||
diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep/sleep.h index ff1f8504f497..a2ea125ae2d0 100644 --- a/drivers/acpi/sleep/sleep.h +++ b/drivers/acpi/sleep/sleep.h | |||
@@ -5,6 +5,5 @@ extern int acpi_suspend (u32 state); | |||
5 | extern void acpi_enable_wakeup_device_prep(u8 sleep_state); | 5 | extern void acpi_enable_wakeup_device_prep(u8 sleep_state); |
6 | extern void acpi_enable_wakeup_device(u8 sleep_state); | 6 | extern void acpi_enable_wakeup_device(u8 sleep_state); |
7 | extern void acpi_disable_wakeup_device(u8 sleep_state); | 7 | extern void acpi_disable_wakeup_device(u8 sleep_state); |
8 | extern void acpi_gpe_sleep_prepare(u32 sleep_state); | ||
9 | 8 | ||
10 | extern int acpi_sleep_prepare(u32 acpi_state); | 9 | extern int acpi_sleep_prepare(u32 acpi_state); |
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c index 97c27ddb144d..ed8e41becf0c 100644 --- a/drivers/acpi/sleep/wakeup.c +++ b/drivers/acpi/sleep/wakeup.c | |||
@@ -64,36 +64,29 @@ void acpi_enable_wakeup_device(u8 sleep_state) | |||
64 | ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device"); | 64 | ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device"); |
65 | spin_lock(&acpi_device_lock); | 65 | spin_lock(&acpi_device_lock); |
66 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | 66 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { |
67 | struct acpi_device *dev = container_of(node, | 67 | struct acpi_device *dev = |
68 | struct acpi_device, | 68 | container_of(node, struct acpi_device, wakeup_list); |
69 | wakeup_list); | 69 | if (!dev->wakeup.flags.valid) |
70 | 70 | continue; | |
71 | /* If users want to disable run-wake GPE, | 71 | /* If users want to disable run-wake GPE, |
72 | * we only disable it for wake and leave it for runtime | 72 | * we only disable it for wake and leave it for runtime |
73 | */ | 73 | */ |
74 | if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { | 74 | if (!dev->wakeup.state.enabled || |
75 | spin_unlock(&acpi_device_lock); | 75 | sleep_state > (u32) dev->wakeup.sleep_state) { |
76 | acpi_set_gpe_type(dev->wakeup.gpe_device, | 76 | if (dev->wakeup.flags.run_wake) { |
77 | dev->wakeup.gpe_number, | 77 | spin_unlock(&acpi_device_lock); |
78 | ACPI_GPE_TYPE_RUNTIME); | 78 | /* set_gpe_type will disable GPE, leave it like that */ |
79 | /* Re-enable it, since set_gpe_type will disable it */ | 79 | acpi_set_gpe_type(dev->wakeup.gpe_device, |
80 | acpi_enable_gpe(dev->wakeup.gpe_device, | 80 | dev->wakeup.gpe_number, |
81 | dev->wakeup.gpe_number, ACPI_ISR); | 81 | ACPI_GPE_TYPE_RUNTIME); |
82 | spin_lock(&acpi_device_lock); | 82 | spin_lock(&acpi_device_lock); |
83 | } | ||
83 | continue; | 84 | continue; |
84 | } | 85 | } |
85 | |||
86 | if (!dev->wakeup.flags.valid || | ||
87 | !dev->wakeup.state.enabled || | ||
88 | (sleep_state > (u32) dev->wakeup.sleep_state)) | ||
89 | continue; | ||
90 | |||
91 | spin_unlock(&acpi_device_lock); | 86 | spin_unlock(&acpi_device_lock); |
92 | /* run-wake GPE has been enabled */ | ||
93 | if (!dev->wakeup.flags.run_wake) | 87 | if (!dev->wakeup.flags.run_wake) |
94 | acpi_enable_gpe(dev->wakeup.gpe_device, | 88 | acpi_enable_gpe(dev->wakeup.gpe_device, |
95 | dev->wakeup.gpe_number, ACPI_ISR); | 89 | dev->wakeup.gpe_number, ACPI_ISR); |
96 | dev->wakeup.state.active = 1; | ||
97 | spin_lock(&acpi_device_lock); | 90 | spin_lock(&acpi_device_lock); |
98 | } | 91 | } |
99 | spin_unlock(&acpi_device_lock); | 92 | spin_unlock(&acpi_device_lock); |
@@ -112,26 +105,25 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
112 | 105 | ||
113 | spin_lock(&acpi_device_lock); | 106 | spin_lock(&acpi_device_lock); |
114 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | 107 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { |
115 | struct acpi_device *dev = container_of(node, | 108 | struct acpi_device *dev = |
116 | struct acpi_device, | 109 | container_of(node, struct acpi_device, wakeup_list); |
117 | wakeup_list); | ||
118 | 110 | ||
119 | if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { | 111 | if (!dev->wakeup.flags.valid) |
120 | spin_unlock(&acpi_device_lock); | ||
121 | acpi_set_gpe_type(dev->wakeup.gpe_device, | ||
122 | dev->wakeup.gpe_number, | ||
123 | ACPI_GPE_TYPE_WAKE_RUN); | ||
124 | /* Re-enable it, since set_gpe_type will disable it */ | ||
125 | acpi_enable_gpe(dev->wakeup.gpe_device, | ||
126 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | ||
127 | spin_lock(&acpi_device_lock); | ||
128 | continue; | 112 | continue; |
129 | } | 113 | if (!dev->wakeup.state.enabled || |
130 | 114 | sleep_state > (u32) dev->wakeup.sleep_state) { | |
131 | if (!dev->wakeup.flags.valid || | 115 | if (dev->wakeup.flags.run_wake) { |
132 | !dev->wakeup.state.active || | 116 | spin_unlock(&acpi_device_lock); |
133 | (sleep_state > (u32) dev->wakeup.sleep_state)) | 117 | acpi_set_gpe_type(dev->wakeup.gpe_device, |
118 | dev->wakeup.gpe_number, | ||
119 | ACPI_GPE_TYPE_WAKE_RUN); | ||
120 | /* Re-enable it, since set_gpe_type will disable it */ | ||
121 | acpi_enable_gpe(dev->wakeup.gpe_device, | ||
122 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | ||
123 | spin_lock(&acpi_device_lock); | ||
124 | } | ||
134 | continue; | 125 | continue; |
126 | } | ||
135 | 127 | ||
136 | spin_unlock(&acpi_device_lock); | 128 | spin_unlock(&acpi_device_lock); |
137 | acpi_disable_wakeup_device_power(dev); | 129 | acpi_disable_wakeup_device_power(dev); |
@@ -142,7 +134,6 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
142 | acpi_clear_gpe(dev->wakeup.gpe_device, | 134 | acpi_clear_gpe(dev->wakeup.gpe_device, |
143 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 135 | dev->wakeup.gpe_number, ACPI_NOT_ISR); |
144 | } | 136 | } |
145 | dev->wakeup.state.active = 0; | ||
146 | spin_lock(&acpi_device_lock); | 137 | spin_lock(&acpi_device_lock); |
147 | } | 138 | } |
148 | spin_unlock(&acpi_device_lock); | 139 | spin_unlock(&acpi_device_lock); |
@@ -160,48 +151,20 @@ static int __init acpi_wakeup_device_init(void) | |||
160 | struct acpi_device *dev = container_of(node, | 151 | struct acpi_device *dev = container_of(node, |
161 | struct acpi_device, | 152 | struct acpi_device, |
162 | wakeup_list); | 153 | wakeup_list); |
163 | |||
164 | /* In case user doesn't load button driver */ | 154 | /* In case user doesn't load button driver */ |
165 | if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { | 155 | if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled) |
166 | spin_unlock(&acpi_device_lock); | 156 | continue; |
167 | acpi_set_gpe_type(dev->wakeup.gpe_device, | 157 | spin_unlock(&acpi_device_lock); |
168 | dev->wakeup.gpe_number, | 158 | acpi_set_gpe_type(dev->wakeup.gpe_device, |
169 | ACPI_GPE_TYPE_WAKE_RUN); | 159 | dev->wakeup.gpe_number, |
170 | acpi_enable_gpe(dev->wakeup.gpe_device, | 160 | ACPI_GPE_TYPE_WAKE_RUN); |
171 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 161 | acpi_enable_gpe(dev->wakeup.gpe_device, |
172 | dev->wakeup.state.enabled = 1; | 162 | dev->wakeup.gpe_number, ACPI_NOT_ISR); |
173 | spin_lock(&acpi_device_lock); | 163 | dev->wakeup.state.enabled = 1; |
174 | } | 164 | spin_lock(&acpi_device_lock); |
175 | } | 165 | } |
176 | spin_unlock(&acpi_device_lock); | 166 | spin_unlock(&acpi_device_lock); |
177 | |||
178 | return 0; | 167 | return 0; |
179 | } | 168 | } |
180 | 169 | ||
181 | late_initcall(acpi_wakeup_device_init); | 170 | late_initcall(acpi_wakeup_device_init); |
182 | |||
183 | /* | ||
184 | * Disable all wakeup GPEs before entering requested sleep state. | ||
185 | * @sleep_state: ACPI state | ||
186 | * Since acpi_enter_sleep_state() will disable all | ||
187 | * RUNTIME GPEs, we simply mark all GPES that | ||
188 | * are not enabled for wakeup from requested state as RUNTIME. | ||
189 | */ | ||
190 | void acpi_gpe_sleep_prepare(u32 sleep_state) | ||
191 | { | ||
192 | struct list_head *node, *next; | ||
193 | |||
194 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | ||
195 | struct acpi_device *dev = container_of(node, | ||
196 | struct acpi_device, | ||
197 | wakeup_list); | ||
198 | |||
199 | /* The GPE can wakeup system from this state, don't touch it */ | ||
200 | if ((u32) dev->wakeup.sleep_state >= sleep_state) | ||
201 | continue; | ||
202 | /* acpi_set_gpe_type will automatically disable GPE */ | ||
203 | acpi_set_gpe_type(dev->wakeup.gpe_device, | ||
204 | dev->wakeup.gpe_number, | ||
205 | ACPI_GPE_TYPE_RUNTIME); | ||
206 | } | ||
207 | } | ||
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 8cc9492ffbf2..5f1d85f2ffe4 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c | |||
@@ -400,7 +400,7 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) | |||
400 | u32 table_count; | 400 | u32 table_count; |
401 | struct acpi_table_header *table; | 401 | struct acpi_table_header *table; |
402 | acpi_physical_address address; | 402 | acpi_physical_address address; |
403 | acpi_physical_address rsdt_address; | 403 | acpi_physical_address uninitialized_var(rsdt_address); |
404 | u32 length; | 404 | u32 length; |
405 | u8 *table_entry; | 405 | u8 *table_entry; |
406 | acpi_status status; | 406 | acpi_status status; |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index ad898e10c1a9..5f79b4451212 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -195,6 +195,7 @@ struct acpi_thermal { | |||
195 | struct acpi_thermal_trips trips; | 195 | struct acpi_thermal_trips trips; |
196 | struct acpi_handle_list devices; | 196 | struct acpi_handle_list devices; |
197 | struct timer_list timer; | 197 | struct timer_list timer; |
198 | struct mutex lock; | ||
198 | }; | 199 | }; |
199 | 200 | ||
200 | static const struct file_operations acpi_thermal_state_fops = { | 201 | static const struct file_operations acpi_thermal_state_fops = { |
@@ -711,6 +712,7 @@ static void acpi_thermal_check(void *data) | |||
711 | int result = 0; | 712 | int result = 0; |
712 | struct acpi_thermal *tz = data; | 713 | struct acpi_thermal *tz = data; |
713 | unsigned long sleep_time = 0; | 714 | unsigned long sleep_time = 0; |
715 | unsigned long timeout_jiffies = 0; | ||
714 | int i = 0; | 716 | int i = 0; |
715 | struct acpi_thermal_state state; | 717 | struct acpi_thermal_state state; |
716 | 718 | ||
@@ -720,11 +722,15 @@ static void acpi_thermal_check(void *data) | |||
720 | return; | 722 | return; |
721 | } | 723 | } |
722 | 724 | ||
725 | /* Check if someone else is already running */ | ||
726 | if (!mutex_trylock(&tz->lock)) | ||
727 | return; | ||
728 | |||
723 | state = tz->state; | 729 | state = tz->state; |
724 | 730 | ||
725 | result = acpi_thermal_get_temperature(tz); | 731 | result = acpi_thermal_get_temperature(tz); |
726 | if (result) | 732 | if (result) |
727 | return; | 733 | goto unlock; |
728 | 734 | ||
729 | memset(&tz->state, 0, sizeof(tz->state)); | 735 | memset(&tz->state, 0, sizeof(tz->state)); |
730 | 736 | ||
@@ -787,10 +793,13 @@ static void acpi_thermal_check(void *data) | |||
787 | * a thermal event occurs). Note that _TSP and _TZD values are | 793 | * a thermal event occurs). Note that _TSP and _TZD values are |
788 | * given in 1/10th seconds (we must covert to milliseconds). | 794 | * given in 1/10th seconds (we must covert to milliseconds). |
789 | */ | 795 | */ |
790 | if (tz->state.passive) | 796 | if (tz->state.passive) { |
791 | sleep_time = tz->trips.passive.tsp * 100; | 797 | sleep_time = tz->trips.passive.tsp * 100; |
792 | else if (tz->polling_frequency > 0) | 798 | timeout_jiffies = jiffies + (HZ * sleep_time) / 1000; |
799 | } else if (tz->polling_frequency > 0) { | ||
793 | sleep_time = tz->polling_frequency * 100; | 800 | sleep_time = tz->polling_frequency * 100; |
801 | timeout_jiffies = round_jiffies(jiffies + (HZ * sleep_time) / 1000); | ||
802 | } | ||
794 | 803 | ||
795 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n", | 804 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n", |
796 | tz->name, tz->temperature, sleep_time)); | 805 | tz->name, tz->temperature, sleep_time)); |
@@ -804,17 +813,16 @@ static void acpi_thermal_check(void *data) | |||
804 | del_timer(&(tz->timer)); | 813 | del_timer(&(tz->timer)); |
805 | } else { | 814 | } else { |
806 | if (timer_pending(&(tz->timer))) | 815 | if (timer_pending(&(tz->timer))) |
807 | mod_timer(&(tz->timer), | 816 | mod_timer(&(tz->timer), timeout_jiffies); |
808 | jiffies + (HZ * sleep_time) / 1000); | ||
809 | else { | 817 | else { |
810 | tz->timer.data = (unsigned long)tz; | 818 | tz->timer.data = (unsigned long)tz; |
811 | tz->timer.function = acpi_thermal_run; | 819 | tz->timer.function = acpi_thermal_run; |
812 | tz->timer.expires = jiffies + (HZ * sleep_time) / 1000; | 820 | tz->timer.expires = timeout_jiffies; |
813 | add_timer(&(tz->timer)); | 821 | add_timer(&(tz->timer)); |
814 | } | 822 | } |
815 | } | 823 | } |
816 | 824 | unlock: | |
817 | return; | 825 | mutex_unlock(&tz->lock); |
818 | } | 826 | } |
819 | 827 | ||
820 | /* -------------------------------------------------------------------------- | 828 | /* -------------------------------------------------------------------------- |
@@ -1251,7 +1259,7 @@ static int acpi_thermal_add(struct acpi_device *device) | |||
1251 | strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); | 1259 | strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); |
1252 | strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); | 1260 | strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); |
1253 | acpi_driver_data(device) = tz; | 1261 | acpi_driver_data(device) = tz; |
1254 | 1262 | mutex_init(&tz->lock); | |
1255 | result = acpi_thermal_get_info(tz); | 1263 | result = acpi_thermal_get_info(tz); |
1256 | if (result) | 1264 | if (result) |
1257 | goto end; | 1265 | goto end; |
@@ -1321,7 +1329,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) | |||
1321 | } | 1329 | } |
1322 | 1330 | ||
1323 | acpi_thermal_remove_fs(device); | 1331 | acpi_thermal_remove_fs(device); |
1324 | 1332 | mutex_destroy(&tz->lock); | |
1325 | kfree(tz); | 1333 | kfree(tz); |
1326 | return 0; | 1334 | return 0; |
1327 | } | 1335 | } |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index b8a2095cb5ee..bac956b30c57 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -409,14 +409,17 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, | |||
409 | static int | 409 | static int |
410 | acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) | 410 | acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) |
411 | { | 411 | { |
412 | int status; | 412 | int status = AE_OK; |
413 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | 413 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; |
414 | struct acpi_object_list args = { 1, &arg0 }; | 414 | struct acpi_object_list args = { 1, &arg0 }; |
415 | 415 | ||
416 | 416 | ||
417 | arg0.integer.value = level; | 417 | arg0.integer.value = level; |
418 | status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL); | ||
419 | 418 | ||
419 | if (device->cap._BCM) | ||
420 | status = acpi_evaluate_object(device->dev->handle, "_BCM", | ||
421 | &args, NULL); | ||
422 | device->brightness->curr = level; | ||
420 | return status; | 423 | return status; |
421 | } | 424 | } |
422 | 425 | ||
@@ -424,11 +427,11 @@ static int | |||
424 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | 427 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, |
425 | unsigned long *level) | 428 | unsigned long *level) |
426 | { | 429 | { |
427 | int status; | 430 | if (device->cap._BQC) |
428 | 431 | return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, | |
429 | status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level); | 432 | level); |
430 | 433 | *level = device->brightness->curr; | |
431 | return status; | 434 | return AE_OK; |
432 | } | 435 | } |
433 | 436 | ||
434 | static int | 437 | static int |
@@ -1633,9 +1636,20 @@ static int | |||
1633 | acpi_video_get_next_level(struct acpi_video_device *device, | 1636 | acpi_video_get_next_level(struct acpi_video_device *device, |
1634 | u32 level_current, u32 event) | 1637 | u32 level_current, u32 event) |
1635 | { | 1638 | { |
1636 | int min, max, min_above, max_below, i, l; | 1639 | int min, max, min_above, max_below, i, l, delta = 255; |
1637 | max = max_below = 0; | 1640 | max = max_below = 0; |
1638 | min = min_above = 255; | 1641 | min = min_above = 255; |
1642 | /* Find closest level to level_current */ | ||
1643 | for (i = 0; i < device->brightness->count; i++) { | ||
1644 | l = device->brightness->levels[i]; | ||
1645 | if (abs(l - level_current) < abs(delta)) { | ||
1646 | delta = l - level_current; | ||
1647 | if (!delta) | ||
1648 | break; | ||
1649 | } | ||
1650 | } | ||
1651 | /* Ajust level_current to closest available level */ | ||
1652 | level_current += delta; | ||
1639 | for (i = 0; i < device->brightness->count; i++) { | 1653 | for (i = 0; i < device->brightness->count; i++) { |
1640 | l = device->brightness->levels[i]; | 1654 | l = device->brightness->levels[i]; |
1641 | if (l < min) | 1655 | if (l < min) |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index bbaa545ea999..629eadbd0ec0 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1392,7 +1392,7 @@ static void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
1392 | * @tf: Taskfile registers for the command and the result | 1392 | * @tf: Taskfile registers for the command and the result |
1393 | * @cdb: CDB for packet command | 1393 | * @cdb: CDB for packet command |
1394 | * @dma_dir: Data tranfer direction of the command | 1394 | * @dma_dir: Data tranfer direction of the command |
1395 | * @sg: sg list for the data buffer of the command | 1395 | * @sgl: sg list for the data buffer of the command |
1396 | * @n_elem: Number of sg entries | 1396 | * @n_elem: Number of sg entries |
1397 | * @timeout: Timeout in msecs (0 for default) | 1397 | * @timeout: Timeout in msecs (0 for default) |
1398 | * | 1398 | * |
diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c index 53070f6b1fc4..d753e568588e 100644 --- a/drivers/ata/pata_cs5536.c +++ b/drivers/ata/pata_cs5536.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <asm/msr.h> | 40 | #include <asm/msr.h> |
41 | 41 | ||
42 | #define DRV_NAME "pata_cs5536" | 42 | #define DRV_NAME "pata_cs5536" |
43 | #define DRV_VERSION "0.0.5" | 43 | #define DRV_VERSION "0.0.6" |
44 | 44 | ||
45 | enum { | 45 | enum { |
46 | CFG = 0, | 46 | CFG = 0, |
@@ -214,7 +214,7 @@ static void cs5536_set_dmamode(struct ata_port *ap, struct ata_device *adev) | |||
214 | cs5536_read(pdev, DTC, &dtc); | 214 | cs5536_read(pdev, DTC, &dtc); |
215 | 215 | ||
216 | dtc &= ~(IDE_DRV_MASK << dshift); | 216 | dtc &= ~(IDE_DRV_MASK << dshift); |
217 | dtc |= mwdma_timings[mode] << dshift; | 217 | dtc |= mwdma_timings[mode - XFER_MW_DMA_0] << dshift; |
218 | 218 | ||
219 | cs5536_write(pdev, DTC, dtc); | 219 | cs5536_write(pdev, DTC, dtc); |
220 | } | 220 | } |
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index 8d98a9fb0a42..f147dc7bf464 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c | |||
@@ -92,7 +92,7 @@ static struct scsi_host_template sis_sht = { | |||
92 | .queuecommand = ata_scsi_queuecmd, | 92 | .queuecommand = ata_scsi_queuecmd, |
93 | .can_queue = ATA_DEF_QUEUE, | 93 | .can_queue = ATA_DEF_QUEUE, |
94 | .this_id = ATA_SHT_THIS_ID, | 94 | .this_id = ATA_SHT_THIS_ID, |
95 | .sg_tablesize = ATA_MAX_PRD, | 95 | .sg_tablesize = LIBATA_MAX_PRD, |
96 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | 96 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
97 | .emulated = ATA_SHT_EMULATED, | 97 | .emulated = ATA_SHT_EMULATED, |
98 | .use_clustering = ATA_SHT_USE_CLUSTERING, | 98 | .use_clustering = ATA_SHT_USE_CLUSTERING, |
@@ -166,11 +166,11 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) | |||
166 | return addr; | 166 | return addr; |
167 | } | 167 | } |
168 | 168 | ||
169 | static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) | 169 | static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg, u32 *val) |
170 | { | 170 | { |
171 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 171 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
172 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); | 172 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); |
173 | u32 val, val2 = 0; | 173 | u32 val2 = 0; |
174 | u8 pmr; | 174 | u8 pmr; |
175 | 175 | ||
176 | if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ | 176 | if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ |
@@ -178,13 +178,16 @@ static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) | |||
178 | 178 | ||
179 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 179 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
180 | 180 | ||
181 | pci_read_config_dword(pdev, cfg_addr, &val); | 181 | pci_read_config_dword(pdev, cfg_addr, val); |
182 | 182 | ||
183 | if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || | 183 | if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || |
184 | (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED)) | 184 | (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED)) |
185 | pci_read_config_dword(pdev, cfg_addr+0x10, &val2); | 185 | pci_read_config_dword(pdev, cfg_addr+0x10, &val2); |
186 | 186 | ||
187 | return (val|val2) & 0xfffffffb; /* avoid problems with powerdowned ports */ | 187 | *val |= val2; |
188 | *val &= 0xfffffffb; /* avoid problems with powerdowned ports */ | ||
189 | |||
190 | return 0; | ||
188 | } | 191 | } |
189 | 192 | ||
190 | static void sis_scr_cfg_write (struct ata_port *ap, unsigned int sc_reg, u32 val) | 193 | static void sis_scr_cfg_write (struct ata_port *ap, unsigned int sc_reg, u32 val) |
@@ -214,7 +217,7 @@ static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
214 | return -EINVAL; | 217 | return -EINVAL; |
215 | 218 | ||
216 | if (ap->flags & SIS_FLAG_CFGSCR) | 219 | if (ap->flags & SIS_FLAG_CFGSCR) |
217 | return sis_scr_cfg_read(ap, sc_reg); | 220 | return sis_scr_cfg_read(ap, sc_reg, val); |
218 | 221 | ||
219 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 222 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
220 | 223 | ||
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index cb136a919f2a..ac4a0cb217ab 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -188,7 +188,7 @@ static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size, | |||
188 | if (signal_pending(current)) { | 188 | if (signal_pending(current)) { |
189 | siginfo_t info; | 189 | siginfo_t info; |
190 | printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n", | 190 | printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n", |
191 | current->pid, current->comm, | 191 | task_pid_nr(current), current->comm, |
192 | dequeue_signal_lock(current, ¤t->blocked, &info)); | 192 | dequeue_signal_lock(current, ¤t->blocked, &info)); |
193 | result = -EINTR; | 193 | result = -EINTR; |
194 | sock_shutdown(lo, !send); | 194 | sock_shutdown(lo, !send); |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index d70745c84250..af0561053167 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -1107,7 +1107,7 @@ int open_for_data(struct cdrom_device_info * cdi) | |||
1107 | is the default case! */ | 1107 | is the default case! */ |
1108 | cdinfo(CD_OPEN, "bummer. wrong media type.\n"); | 1108 | cdinfo(CD_OPEN, "bummer. wrong media type.\n"); |
1109 | cdinfo(CD_WARNING, "pid %d must open device O_NONBLOCK!\n", | 1109 | cdinfo(CD_WARNING, "pid %d must open device O_NONBLOCK!\n", |
1110 | (unsigned int)current->pid); | 1110 | (unsigned int)task_pid_nr(current)); |
1111 | ret=-EMEDIUMTYPE; | 1111 | ret=-EMEDIUMTYPE; |
1112 | goto clean_up_and_return; | 1112 | goto clean_up_and_return; |
1113 | } | 1113 | } |
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c index 856774fbe025..d24a6c2c2c24 100644 --- a/drivers/char/drm/drm_bufs.c +++ b/drivers/char/drm/drm_bufs.c | |||
@@ -1456,7 +1456,7 @@ int drm_freebufs(struct drm_device *dev, void *data, | |||
1456 | buf = dma->buflist[idx]; | 1456 | buf = dma->buflist[idx]; |
1457 | if (buf->file_priv != file_priv) { | 1457 | if (buf->file_priv != file_priv) { |
1458 | DRM_ERROR("Process %d freeing buffer not owned\n", | 1458 | DRM_ERROR("Process %d freeing buffer not owned\n", |
1459 | current->pid); | 1459 | task_pid_nr(current)); |
1460 | return -EINVAL; | 1460 | return -EINVAL; |
1461 | } | 1461 | } |
1462 | drm_free_buffer(dev, buf); | 1462 | drm_free_buffer(dev, buf); |
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index 72668b15e5ce..44a46268b02b 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c | |||
@@ -463,7 +463,7 @@ int drm_ioctl(struct inode *inode, struct file *filp, | |||
463 | ++file_priv->ioctl_count; | 463 | ++file_priv->ioctl_count; |
464 | 464 | ||
465 | DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n", | 465 | DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n", |
466 | current->pid, cmd, nr, | 466 | task_pid_nr(current), cmd, nr, |
467 | (long)old_encode_dev(file_priv->head->device), | 467 | (long)old_encode_dev(file_priv->head->device), |
468 | file_priv->authenticated); | 468 | file_priv->authenticated); |
469 | 469 | ||
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c index f383fc37190c..3992f73299cc 100644 --- a/drivers/char/drm/drm_fops.c +++ b/drivers/char/drm/drm_fops.c | |||
@@ -234,7 +234,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
234 | if (!drm_cpu_valid()) | 234 | if (!drm_cpu_valid()) |
235 | return -EINVAL; | 235 | return -EINVAL; |
236 | 236 | ||
237 | DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor); | 237 | DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor); |
238 | 238 | ||
239 | priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); | 239 | priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); |
240 | if (!priv) | 240 | if (!priv) |
@@ -244,7 +244,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
244 | filp->private_data = priv; | 244 | filp->private_data = priv; |
245 | priv->filp = filp; | 245 | priv->filp = filp; |
246 | priv->uid = current->euid; | 246 | priv->uid = current->euid; |
247 | priv->pid = current->pid; | 247 | priv->pid = task_pid_nr(current); |
248 | priv->minor = minor; | 248 | priv->minor = minor; |
249 | priv->head = drm_heads[minor]; | 249 | priv->head = drm_heads[minor]; |
250 | priv->ioctl_count = 0; | 250 | priv->ioctl_count = 0; |
@@ -339,7 +339,8 @@ int drm_release(struct inode *inode, struct file *filp) | |||
339 | */ | 339 | */ |
340 | 340 | ||
341 | DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", | 341 | DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", |
342 | current->pid, (long)old_encode_dev(file_priv->head->device), | 342 | task_pid_nr(current), |
343 | (long)old_encode_dev(file_priv->head->device), | ||
343 | dev->open_count); | 344 | dev->open_count); |
344 | 345 | ||
345 | if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) { | 346 | if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) { |
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c index c6b73e744d67..bea2a7d5b2b2 100644 --- a/drivers/char/drm/drm_lock.c +++ b/drivers/char/drm/drm_lock.c | |||
@@ -58,12 +58,12 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
58 | 58 | ||
59 | if (lock->context == DRM_KERNEL_CONTEXT) { | 59 | if (lock->context == DRM_KERNEL_CONTEXT) { |
60 | DRM_ERROR("Process %d using kernel context %d\n", | 60 | DRM_ERROR("Process %d using kernel context %d\n", |
61 | current->pid, lock->context); | 61 | task_pid_nr(current), lock->context); |
62 | return -EINVAL; | 62 | return -EINVAL; |
63 | } | 63 | } |
64 | 64 | ||
65 | DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", | 65 | DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", |
66 | lock->context, current->pid, | 66 | lock->context, task_pid_nr(current), |
67 | dev->lock.hw_lock->lock, lock->flags); | 67 | dev->lock.hw_lock->lock, lock->flags); |
68 | 68 | ||
69 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)) | 69 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)) |
@@ -153,7 +153,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
153 | 153 | ||
154 | if (lock->context == DRM_KERNEL_CONTEXT) { | 154 | if (lock->context == DRM_KERNEL_CONTEXT) { |
155 | DRM_ERROR("Process %d using kernel context %d\n", | 155 | DRM_ERROR("Process %d using kernel context %d\n", |
156 | current->pid, lock->context); | 156 | task_pid_nr(current), lock->context); |
157 | return -EINVAL; | 157 | return -EINVAL; |
158 | } | 158 | } |
159 | 159 | ||
diff --git a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h index 114e54e0f61b..76e44ac94fb5 100644 --- a/drivers/char/drm/drm_os_linux.h +++ b/drivers/char/drm/drm_os_linux.h | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <linux/delay.h> | 7 | #include <linux/delay.h> |
8 | 8 | ||
9 | /** Current process ID */ | 9 | /** Current process ID */ |
10 | #define DRM_CURRENTPID current->pid | 10 | #define DRM_CURRENTPID task_pid_nr(current) |
11 | #define DRM_SUSER(p) capable(CAP_SYS_ADMIN) | 11 | #define DRM_SUSER(p) capable(CAP_SYS_ADMIN) |
12 | #define DRM_UDELAY(d) udelay(d) | 12 | #define DRM_UDELAY(d) udelay(d) |
13 | /** Read a byte from a MMIO region */ | 13 | /** Read a byte from a MMIO region */ |
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c index 8e841bdee6dc..eb381a7c5bee 100644 --- a/drivers/char/drm/i810_dma.c +++ b/drivers/char/drm/i810_dma.c | |||
@@ -1024,7 +1024,7 @@ static int i810_getbuf(struct drm_device *dev, void *data, | |||
1024 | retcode = i810_dma_get_buffer(dev, d, file_priv); | 1024 | retcode = i810_dma_get_buffer(dev, d, file_priv); |
1025 | 1025 | ||
1026 | DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", | 1026 | DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", |
1027 | current->pid, retcode, d->granted); | 1027 | task_pid_nr(current), retcode, d->granted); |
1028 | 1028 | ||
1029 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1029 | sarea_priv->last_dispatch = (int)hw_status[5]; |
1030 | 1030 | ||
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index 43a1f78712d6..69a363edb0d2 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c | |||
@@ -1409,7 +1409,7 @@ static int i830_getbuf(struct drm_device *dev, void *data, | |||
1409 | retcode = i830_dma_get_buffer(dev, d, file_priv); | 1409 | retcode = i830_dma_get_buffer(dev, d, file_priv); |
1410 | 1410 | ||
1411 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", | 1411 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", |
1412 | current->pid, retcode, d->granted); | 1412 | task_pid_nr(current), retcode, d->granted); |
1413 | 1413 | ||
1414 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1414 | sarea_priv->last_dispatch = (int)hw_status[5]; |
1415 | 1415 | ||
diff --git a/drivers/char/esp.c b/drivers/char/esp.c index 2e7ae42a5503..0f8fb135da53 100644 --- a/drivers/char/esp.c +++ b/drivers/char/esp.c | |||
@@ -58,10 +58,10 @@ | |||
58 | #include <linux/mm.h> | 58 | #include <linux/mm.h> |
59 | #include <linux/init.h> | 59 | #include <linux/init.h> |
60 | #include <linux/delay.h> | 60 | #include <linux/delay.h> |
61 | #include <linux/bitops.h> | ||
61 | 62 | ||
62 | #include <asm/system.h> | 63 | #include <asm/system.h> |
63 | #include <asm/io.h> | 64 | #include <asm/io.h> |
64 | #include <asm/bitops.h> | ||
65 | 65 | ||
66 | #include <asm/dma.h> | 66 | #include <asm/dma.h> |
67 | #include <linux/slab.h> | 67 | #include <linux/slab.h> |
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 212276affa1f..fc54d234507a 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/sysrq.h> | 42 | #include <linux/sysrq.h> |
43 | #include <linux/input.h> | 43 | #include <linux/input.h> |
44 | #include <linux/reboot.h> | 44 | #include <linux/reboot.h> |
45 | #include <linux/notifier.h> | ||
45 | 46 | ||
46 | extern void ctrl_alt_del(void); | 47 | extern void ctrl_alt_del(void); |
47 | 48 | ||
@@ -81,7 +82,8 @@ void compute_shiftstate(void); | |||
81 | typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, | 82 | typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, |
82 | char up_flag); | 83 | char up_flag); |
83 | static k_handler_fn K_HANDLERS; | 84 | static k_handler_fn K_HANDLERS; |
84 | static k_handler_fn *k_handler[16] = { K_HANDLERS }; | 85 | k_handler_fn *k_handler[16] = { K_HANDLERS }; |
86 | EXPORT_SYMBOL_GPL(k_handler); | ||
85 | 87 | ||
86 | #define FN_HANDLERS\ | 88 | #define FN_HANDLERS\ |
87 | fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\ | 89 | fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\ |
@@ -127,7 +129,7 @@ int shift_state = 0; | |||
127 | */ | 129 | */ |
128 | 130 | ||
129 | static struct input_handler kbd_handler; | 131 | static struct input_handler kbd_handler; |
130 | static unsigned long key_down[NBITS(KEY_MAX)]; /* keyboard key bitmap */ | 132 | static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */ |
131 | static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ | 133 | static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ |
132 | static int dead_key_next; | 134 | static int dead_key_next; |
133 | static int npadch = -1; /* -1 or number assembled on pad */ | 135 | static int npadch = -1; /* -1 or number assembled on pad */ |
@@ -160,6 +162,23 @@ static int sysrq_alt_use; | |||
160 | static int sysrq_alt; | 162 | static int sysrq_alt; |
161 | 163 | ||
162 | /* | 164 | /* |
165 | * Notifier list for console keyboard events | ||
166 | */ | ||
167 | static ATOMIC_NOTIFIER_HEAD(keyboard_notifier_list); | ||
168 | |||
169 | int register_keyboard_notifier(struct notifier_block *nb) | ||
170 | { | ||
171 | return atomic_notifier_chain_register(&keyboard_notifier_list, nb); | ||
172 | } | ||
173 | EXPORT_SYMBOL_GPL(register_keyboard_notifier); | ||
174 | |||
175 | int unregister_keyboard_notifier(struct notifier_block *nb) | ||
176 | { | ||
177 | return atomic_notifier_chain_unregister(&keyboard_notifier_list, nb); | ||
178 | } | ||
179 | EXPORT_SYMBOL_GPL(unregister_keyboard_notifier); | ||
180 | |||
181 | /* | ||
163 | * Translation of scancodes to keycodes. We set them on only the first | 182 | * Translation of scancodes to keycodes. We set them on only the first |
164 | * keyboard in the list that accepts the scancode and keycode. | 183 | * keyboard in the list that accepts the scancode and keycode. |
165 | * Explanation for not choosing the first attached keyboard anymore: | 184 | * Explanation for not choosing the first attached keyboard anymore: |
@@ -1130,6 +1149,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) | |||
1130 | unsigned char type, raw_mode; | 1149 | unsigned char type, raw_mode; |
1131 | struct tty_struct *tty; | 1150 | struct tty_struct *tty; |
1132 | int shift_final; | 1151 | int shift_final; |
1152 | struct keyboard_notifier_param param = { .vc = vc, .value = keycode, .down = down }; | ||
1133 | 1153 | ||
1134 | tty = vc->vc_tty; | 1154 | tty = vc->vc_tty; |
1135 | 1155 | ||
@@ -1217,10 +1237,11 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) | |||
1217 | return; | 1237 | return; |
1218 | } | 1238 | } |
1219 | 1239 | ||
1220 | shift_final = (shift_state | kbd->slockstate) ^ kbd->lockstate; | 1240 | param.shift = shift_final = (shift_state | kbd->slockstate) ^ kbd->lockstate; |
1221 | key_map = key_maps[shift_final]; | 1241 | key_map = key_maps[shift_final]; |
1222 | 1242 | ||
1223 | if (!key_map) { | 1243 | if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_KEYCODE, ¶m) == NOTIFY_STOP || !key_map) { |
1244 | atomic_notifier_call_chain(&keyboard_notifier_list, KBD_UNBOUND_KEYCODE, ¶m); | ||
1224 | compute_shiftstate(); | 1245 | compute_shiftstate(); |
1225 | kbd->slockstate = 0; | 1246 | kbd->slockstate = 0; |
1226 | return; | 1247 | return; |
@@ -1237,6 +1258,9 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) | |||
1237 | type = KTYP(keysym); | 1258 | type = KTYP(keysym); |
1238 | 1259 | ||
1239 | if (type < 0xf0) { | 1260 | if (type < 0xf0) { |
1261 | param.value = keysym; | ||
1262 | if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_UNICODE, ¶m) == NOTIFY_STOP) | ||
1263 | return; | ||
1240 | if (down && !raw_mode) | 1264 | if (down && !raw_mode) |
1241 | to_utf8(vc, keysym); | 1265 | to_utf8(vc, keysym); |
1242 | return; | 1266 | return; |
@@ -1244,9 +1268,6 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) | |||
1244 | 1268 | ||
1245 | type -= 0xf0; | 1269 | type -= 0xf0; |
1246 | 1270 | ||
1247 | if (raw_mode && type != KT_SPEC && type != KT_SHIFT) | ||
1248 | return; | ||
1249 | |||
1250 | if (type == KT_LETTER) { | 1271 | if (type == KT_LETTER) { |
1251 | type = KT_LATIN; | 1272 | type = KT_LATIN; |
1252 | if (vc_kbd_led(kbd, VC_CAPSLOCK)) { | 1273 | if (vc_kbd_led(kbd, VC_CAPSLOCK)) { |
@@ -1255,9 +1276,18 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) | |||
1255 | keysym = key_map[keycode]; | 1276 | keysym = key_map[keycode]; |
1256 | } | 1277 | } |
1257 | } | 1278 | } |
1279 | param.value = keysym; | ||
1280 | |||
1281 | if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_KEYSYM, ¶m) == NOTIFY_STOP) | ||
1282 | return; | ||
1283 | |||
1284 | if (raw_mode && type != KT_SPEC && type != KT_SHIFT) | ||
1285 | return; | ||
1258 | 1286 | ||
1259 | (*k_handler[type])(vc, keysym & 0xff, !down); | 1287 | (*k_handler[type])(vc, keysym & 0xff, !down); |
1260 | 1288 | ||
1289 | atomic_notifier_call_chain(&keyboard_notifier_list, KBD_POST_KEYSYM, ¶m); | ||
1290 | |||
1261 | if (type != KT_SLOCK) | 1291 | if (type != KT_SLOCK) |
1262 | kbd->slockstate = 0; | 1292 | kbd->slockstate = 0; |
1263 | } | 1293 | } |
@@ -1347,12 +1377,12 @@ static void kbd_start(struct input_handle *handle) | |||
1347 | static const struct input_device_id kbd_ids[] = { | 1377 | static const struct input_device_id kbd_ids[] = { |
1348 | { | 1378 | { |
1349 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT, | 1379 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT, |
1350 | .evbit = { BIT(EV_KEY) }, | 1380 | .evbit = { BIT_MASK(EV_KEY) }, |
1351 | }, | 1381 | }, |
1352 | 1382 | ||
1353 | { | 1383 | { |
1354 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT, | 1384 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT, |
1355 | .evbit = { BIT(EV_SND) }, | 1385 | .evbit = { BIT_MASK(EV_SND) }, |
1356 | }, | 1386 | }, |
1357 | 1387 | ||
1358 | { }, /* Terminating entry */ | 1388 | { }, /* Terminating entry */ |
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 661aca0e155d..fd0abef7ee08 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -56,11 +56,11 @@ | |||
56 | #include <linux/mm.h> | 56 | #include <linux/mm.h> |
57 | #include <linux/delay.h> | 57 | #include <linux/delay.h> |
58 | #include <linux/pci.h> | 58 | #include <linux/pci.h> |
59 | #include <linux/bitops.h> | ||
59 | 60 | ||
60 | #include <asm/system.h> | 61 | #include <asm/system.h> |
61 | #include <asm/io.h> | 62 | #include <asm/io.h> |
62 | #include <asm/irq.h> | 63 | #include <asm/irq.h> |
63 | #include <asm/bitops.h> | ||
64 | #include <asm/uaccess.h> | 64 | #include <asm/uaccess.h> |
65 | 65 | ||
66 | #include "mxser.h" | 66 | #include "mxser.h" |
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c index 854dbf59eb68..081c84c7b548 100644 --- a/drivers/char/mxser_new.c +++ b/drivers/char/mxser_new.c | |||
@@ -39,11 +39,11 @@ | |||
39 | #include <linux/mm.h> | 39 | #include <linux/mm.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
42 | #include <linux/bitops.h> | ||
42 | 43 | ||
43 | #include <asm/system.h> | 44 | #include <asm/system.h> |
44 | #include <asm/io.h> | 45 | #include <asm/io.h> |
45 | #include <asm/irq.h> | 46 | #include <asm/irq.h> |
46 | #include <asm/bitops.h> | ||
47 | #include <asm/uaccess.h> | 47 | #include <asm/uaccess.h> |
48 | 48 | ||
49 | #include "mxser_new.h" | 49 | #include "mxser_new.h" |
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 859858561ab6..9782cb4d30dc 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -1178,9 +1178,9 @@ static int __devinit sonypi_create_input_devices(void) | |||
1178 | jog_dev->id.bustype = BUS_ISA; | 1178 | jog_dev->id.bustype = BUS_ISA; |
1179 | jog_dev->id.vendor = PCI_VENDOR_ID_SONY; | 1179 | jog_dev->id.vendor = PCI_VENDOR_ID_SONY; |
1180 | 1180 | ||
1181 | jog_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 1181 | jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
1182 | jog_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE); | 1182 | jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE); |
1183 | jog_dev->relbit[0] = BIT(REL_WHEEL); | 1183 | jog_dev->relbit[0] = BIT_MASK(REL_WHEEL); |
1184 | 1184 | ||
1185 | sonypi_device.input_key_dev = key_dev = input_allocate_device(); | 1185 | sonypi_device.input_key_dev = key_dev = input_allocate_device(); |
1186 | if (!key_dev) { | 1186 | if (!key_dev) { |
@@ -1193,7 +1193,7 @@ static int __devinit sonypi_create_input_devices(void) | |||
1193 | key_dev->id.vendor = PCI_VENDOR_ID_SONY; | 1193 | key_dev->id.vendor = PCI_VENDOR_ID_SONY; |
1194 | 1194 | ||
1195 | /* Initialize the Input Drivers: special keys */ | 1195 | /* Initialize the Input Drivers: special keys */ |
1196 | key_dev->evbit[0] = BIT(EV_KEY); | 1196 | key_dev->evbit[0] = BIT_MASK(EV_KEY); |
1197 | for (i = 0; sonypi_inputkeys[i].sonypiev; i++) | 1197 | for (i = 0; sonypi_inputkeys[i].sonypiev; i++) |
1198 | if (sonypi_inputkeys[i].inputev) | 1198 | if (sonypi_inputkeys[i].inputev) |
1199 | set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit); | 1199 | set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit); |
diff --git a/drivers/char/sx.c b/drivers/char/sx.c index 85a23283dff5..a6e1c9ba1217 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c | |||
@@ -1467,7 +1467,7 @@ static int sx_open(struct tty_struct *tty, struct file *filp) | |||
1467 | 1467 | ||
1468 | line = tty->index; | 1468 | line = tty->index; |
1469 | sx_dprintk(SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, " | 1469 | sx_dprintk(SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, " |
1470 | "np=%d)\n", current->pid, line, tty, | 1470 | "np=%d)\n", task_pid_nr(current), line, tty, |
1471 | current->signal->tty, sx_nports); | 1471 | current->signal->tty, sx_nports); |
1472 | 1472 | ||
1473 | if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports)) | 1473 | if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports)) |
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index 78d14935f2b8..de60e1ea4fb3 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c | |||
@@ -251,7 +251,7 @@ static void send_sig_all(int sig) | |||
251 | struct task_struct *p; | 251 | struct task_struct *p; |
252 | 252 | ||
253 | for_each_process(p) { | 253 | for_each_process(p) { |
254 | if (p->mm && !is_init(p)) | 254 | if (p->mm && !is_global_init(p)) |
255 | /* Not swapper, init nor kernel thread */ | 255 | /* Not swapper, init nor kernel thread */ |
256 | force_sig(sig, p); | 256 | force_sig(sig, p); |
257 | } | 257 | } |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 9c867cf6de64..13a53575a016 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -103,6 +103,7 @@ | |||
103 | #include <linux/selection.h> | 103 | #include <linux/selection.h> |
104 | 104 | ||
105 | #include <linux/kmod.h> | 105 | #include <linux/kmod.h> |
106 | #include <linux/nsproxy.h> | ||
106 | 107 | ||
107 | #undef TTY_DEBUG_HANGUP | 108 | #undef TTY_DEBUG_HANGUP |
108 | 109 | ||
@@ -3107,7 +3108,7 @@ static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t | |||
3107 | */ | 3108 | */ |
3108 | if (tty == real_tty && current->signal->tty != real_tty) | 3109 | if (tty == real_tty && current->signal->tty != real_tty) |
3109 | return -ENOTTY; | 3110 | return -ENOTTY; |
3110 | return put_user(pid_nr(real_tty->pgrp), p); | 3111 | return put_user(pid_vnr(real_tty->pgrp), p); |
3111 | } | 3112 | } |
3112 | 3113 | ||
3113 | /** | 3114 | /** |
@@ -3141,7 +3142,7 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t | |||
3141 | if (pgrp_nr < 0) | 3142 | if (pgrp_nr < 0) |
3142 | return -EINVAL; | 3143 | return -EINVAL; |
3143 | rcu_read_lock(); | 3144 | rcu_read_lock(); |
3144 | pgrp = find_pid(pgrp_nr); | 3145 | pgrp = find_vpid(pgrp_nr); |
3145 | retval = -ESRCH; | 3146 | retval = -ESRCH; |
3146 | if (!pgrp) | 3147 | if (!pgrp) |
3147 | goto out_unlock; | 3148 | goto out_unlock; |
@@ -3178,7 +3179,7 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _ | |||
3178 | return -ENOTTY; | 3179 | return -ENOTTY; |
3179 | if (!real_tty->session) | 3180 | if (!real_tty->session) |
3180 | return -ENOTTY; | 3181 | return -ENOTTY; |
3181 | return put_user(pid_nr(real_tty->session), p); | 3182 | return put_user(pid_vnr(real_tty->session), p); |
3182 | } | 3183 | } |
3183 | 3184 | ||
3184 | /** | 3185 | /** |
@@ -3528,8 +3529,8 @@ void __do_SAK(struct tty_struct *tty) | |||
3528 | /* Kill the entire session */ | 3529 | /* Kill the entire session */ |
3529 | do_each_pid_task(session, PIDTYPE_SID, p) { | 3530 | do_each_pid_task(session, PIDTYPE_SID, p) { |
3530 | printk(KERN_NOTICE "SAK: killed process %d" | 3531 | printk(KERN_NOTICE "SAK: killed process %d" |
3531 | " (%s): process_session(p)==tty->session\n", | 3532 | " (%s): task_session_nr(p)==tty->session\n", |
3532 | p->pid, p->comm); | 3533 | task_pid_nr(p), p->comm); |
3533 | send_sig(SIGKILL, p, 1); | 3534 | send_sig(SIGKILL, p, 1); |
3534 | } while_each_pid_task(session, PIDTYPE_SID, p); | 3535 | } while_each_pid_task(session, PIDTYPE_SID, p); |
3535 | /* Now kill any processes that happen to have the | 3536 | /* Now kill any processes that happen to have the |
@@ -3538,8 +3539,8 @@ void __do_SAK(struct tty_struct *tty) | |||
3538 | do_each_thread(g, p) { | 3539 | do_each_thread(g, p) { |
3539 | if (p->signal->tty == tty) { | 3540 | if (p->signal->tty == tty) { |
3540 | printk(KERN_NOTICE "SAK: killed process %d" | 3541 | printk(KERN_NOTICE "SAK: killed process %d" |
3541 | " (%s): process_session(p)==tty->session\n", | 3542 | " (%s): task_session_nr(p)==tty->session\n", |
3542 | p->pid, p->comm); | 3543 | task_pid_nr(p), p->comm); |
3543 | send_sig(SIGKILL, p, 1); | 3544 | send_sig(SIGKILL, p, 1); |
3544 | continue; | 3545 | continue; |
3545 | } | 3546 | } |
@@ -3559,7 +3560,7 @@ void __do_SAK(struct tty_struct *tty) | |||
3559 | filp->private_data == tty) { | 3560 | filp->private_data == tty) { |
3560 | printk(KERN_NOTICE "SAK: killed process %d" | 3561 | printk(KERN_NOTICE "SAK: killed process %d" |
3561 | " (%s): fd#%d opened to the tty\n", | 3562 | " (%s): fd#%d opened to the tty\n", |
3562 | p->pid, p->comm, i); | 3563 | task_pid_nr(p), p->comm, i); |
3563 | force_sig(SIGKILL, p); | 3564 | force_sig(SIGKILL, p); |
3564 | break; | 3565 | break; |
3565 | } | 3566 | } |
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 1764c67b585f..7a5badfb7d84 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -99,6 +99,7 @@ | |||
99 | #include <linux/pm.h> | 99 | #include <linux/pm.h> |
100 | #include <linux/font.h> | 100 | #include <linux/font.h> |
101 | #include <linux/bitops.h> | 101 | #include <linux/bitops.h> |
102 | #include <linux/notifier.h> | ||
102 | 103 | ||
103 | #include <asm/io.h> | 104 | #include <asm/io.h> |
104 | #include <asm/system.h> | 105 | #include <asm/system.h> |
@@ -223,6 +224,35 @@ enum { | |||
223 | }; | 224 | }; |
224 | 225 | ||
225 | /* | 226 | /* |
227 | * Notifier list for console events. | ||
228 | */ | ||
229 | static ATOMIC_NOTIFIER_HEAD(vt_notifier_list); | ||
230 | |||
231 | int register_vt_notifier(struct notifier_block *nb) | ||
232 | { | ||
233 | return atomic_notifier_chain_register(&vt_notifier_list, nb); | ||
234 | } | ||
235 | EXPORT_SYMBOL_GPL(register_vt_notifier); | ||
236 | |||
237 | int unregister_vt_notifier(struct notifier_block *nb) | ||
238 | { | ||
239 | return atomic_notifier_chain_unregister(&vt_notifier_list, nb); | ||
240 | } | ||
241 | EXPORT_SYMBOL_GPL(unregister_vt_notifier); | ||
242 | |||
243 | static void notify_write(struct vc_data *vc, unsigned int unicode) | ||
244 | { | ||
245 | struct vt_notifier_param param = { .vc = vc, unicode = unicode }; | ||
246 | atomic_notifier_call_chain(&vt_notifier_list, VT_WRITE, ¶m); | ||
247 | } | ||
248 | |||
249 | static void notify_update(struct vc_data *vc) | ||
250 | { | ||
251 | struct vt_notifier_param param = { .vc = vc }; | ||
252 | atomic_notifier_call_chain(&vt_notifier_list, VT_UPDATE, ¶m); | ||
253 | } | ||
254 | |||
255 | /* | ||
226 | * Low-Level Functions | 256 | * Low-Level Functions |
227 | */ | 257 | */ |
228 | 258 | ||
@@ -718,6 +748,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ | |||
718 | return -ENXIO; | 748 | return -ENXIO; |
719 | if (!vc_cons[currcons].d) { | 749 | if (!vc_cons[currcons].d) { |
720 | struct vc_data *vc; | 750 | struct vc_data *vc; |
751 | struct vt_notifier_param param; | ||
721 | 752 | ||
722 | /* prevent users from taking too much memory */ | 753 | /* prevent users from taking too much memory */ |
723 | if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE)) | 754 | if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE)) |
@@ -729,7 +760,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ | |||
729 | /* although the numbers above are not valid since long ago, the | 760 | /* although the numbers above are not valid since long ago, the |
730 | point is still up-to-date and the comment still has its value | 761 | point is still up-to-date and the comment still has its value |
731 | even if only as a historical artifact. --mj, July 1998 */ | 762 | even if only as a historical artifact. --mj, July 1998 */ |
732 | vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL); | 763 | param.vc = vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL); |
733 | if (!vc) | 764 | if (!vc) |
734 | return -ENOMEM; | 765 | return -ENOMEM; |
735 | vc_cons[currcons].d = vc; | 766 | vc_cons[currcons].d = vc; |
@@ -746,6 +777,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ | |||
746 | } | 777 | } |
747 | vc->vc_kmalloced = 1; | 778 | vc->vc_kmalloced = 1; |
748 | vc_init(vc, vc->vc_rows, vc->vc_cols, 1); | 779 | vc_init(vc, vc->vc_rows, vc->vc_cols, 1); |
780 | atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, ¶m); | ||
749 | } | 781 | } |
750 | return 0; | 782 | return 0; |
751 | } | 783 | } |
@@ -907,6 +939,8 @@ void vc_deallocate(unsigned int currcons) | |||
907 | 939 | ||
908 | if (vc_cons_allocated(currcons)) { | 940 | if (vc_cons_allocated(currcons)) { |
909 | struct vc_data *vc = vc_cons[currcons].d; | 941 | struct vc_data *vc = vc_cons[currcons].d; |
942 | struct vt_notifier_param param = { .vc = vc }; | ||
943 | atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, ¶m); | ||
910 | vc->vc_sw->con_deinit(vc); | 944 | vc->vc_sw->con_deinit(vc); |
911 | put_pid(vc->vt_pid); | 945 | put_pid(vc->vt_pid); |
912 | module_put(vc->vc_sw->owner); | 946 | module_put(vc->vc_sw->owner); |
@@ -1019,6 +1053,7 @@ static void lf(struct vc_data *vc) | |||
1019 | vc->vc_pos += vc->vc_size_row; | 1053 | vc->vc_pos += vc->vc_size_row; |
1020 | } | 1054 | } |
1021 | vc->vc_need_wrap = 0; | 1055 | vc->vc_need_wrap = 0; |
1056 | notify_write(vc, '\n'); | ||
1022 | } | 1057 | } |
1023 | 1058 | ||
1024 | static void ri(struct vc_data *vc) | 1059 | static void ri(struct vc_data *vc) |
@@ -1039,6 +1074,7 @@ static inline void cr(struct vc_data *vc) | |||
1039 | { | 1074 | { |
1040 | vc->vc_pos -= vc->vc_x << 1; | 1075 | vc->vc_pos -= vc->vc_x << 1; |
1041 | vc->vc_need_wrap = vc->vc_x = 0; | 1076 | vc->vc_need_wrap = vc->vc_x = 0; |
1077 | notify_write(vc, '\r'); | ||
1042 | } | 1078 | } |
1043 | 1079 | ||
1044 | static inline void bs(struct vc_data *vc) | 1080 | static inline void bs(struct vc_data *vc) |
@@ -1047,6 +1083,7 @@ static inline void bs(struct vc_data *vc) | |||
1047 | vc->vc_pos -= 2; | 1083 | vc->vc_pos -= 2; |
1048 | vc->vc_x--; | 1084 | vc->vc_x--; |
1049 | vc->vc_need_wrap = 0; | 1085 | vc->vc_need_wrap = 0; |
1086 | notify_write(vc, '\b'); | ||
1050 | } | 1087 | } |
1051 | } | 1088 | } |
1052 | 1089 | ||
@@ -1593,6 +1630,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) | |||
1593 | break; | 1630 | break; |
1594 | } | 1631 | } |
1595 | vc->vc_pos += (vc->vc_x << 1); | 1632 | vc->vc_pos += (vc->vc_x << 1); |
1633 | notify_write(vc, '\t'); | ||
1596 | return; | 1634 | return; |
1597 | case 10: case 11: case 12: | 1635 | case 10: case 11: case 12: |
1598 | lf(vc); | 1636 | lf(vc); |
@@ -2252,6 +2290,7 @@ rescan_last_byte: | |||
2252 | tc = conv_uni_to_pc(vc, ' '); /* A space is printed in the second column */ | 2290 | tc = conv_uni_to_pc(vc, ' '); /* A space is printed in the second column */ |
2253 | if (tc < 0) tc = ' '; | 2291 | if (tc < 0) tc = ' '; |
2254 | } | 2292 | } |
2293 | notify_write(vc, c); | ||
2255 | 2294 | ||
2256 | if (inverse) { | 2295 | if (inverse) { |
2257 | FLUSH | 2296 | FLUSH |
@@ -2274,6 +2313,7 @@ rescan_last_byte: | |||
2274 | release_console_sem(); | 2313 | release_console_sem(); |
2275 | 2314 | ||
2276 | out: | 2315 | out: |
2316 | notify_update(vc); | ||
2277 | return n; | 2317 | return n; |
2278 | #undef FLUSH | 2318 | #undef FLUSH |
2279 | } | 2319 | } |
@@ -2317,6 +2357,7 @@ static void console_callback(struct work_struct *ignored) | |||
2317 | do_blank_screen(0); | 2357 | do_blank_screen(0); |
2318 | blank_timer_expired = 0; | 2358 | blank_timer_expired = 0; |
2319 | } | 2359 | } |
2360 | notify_update(vc_cons[fg_console].d); | ||
2320 | 2361 | ||
2321 | release_console_sem(); | 2362 | release_console_sem(); |
2322 | } | 2363 | } |
@@ -2418,6 +2459,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) | |||
2418 | continue; | 2459 | continue; |
2419 | } | 2460 | } |
2420 | scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); | 2461 | scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); |
2462 | notify_write(vc, c); | ||
2421 | cnt++; | 2463 | cnt++; |
2422 | if (myx == vc->vc_cols - 1) { | 2464 | if (myx == vc->vc_cols - 1) { |
2423 | vc->vc_need_wrap = 1; | 2465 | vc->vc_need_wrap = 1; |
@@ -2436,6 +2478,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) | |||
2436 | } | 2478 | } |
2437 | } | 2479 | } |
2438 | set_cursor(vc); | 2480 | set_cursor(vc); |
2481 | notify_update(vc); | ||
2439 | 2482 | ||
2440 | quit: | 2483 | quit: |
2441 | clear_bit(0, &printing); | 2484 | clear_bit(0, &printing); |
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig new file mode 100644 index 000000000000..3bed4127d4ad --- /dev/null +++ b/drivers/cpuidle/Kconfig | |||
@@ -0,0 +1,20 @@ | |||
1 | |||
2 | config CPU_IDLE | ||
3 | bool "CPU idle PM support" | ||
4 | help | ||
5 | CPU idle is a generic framework for supporting software-controlled | ||
6 | idle processor power management. It includes modular cross-platform | ||
7 | governors that can be swapped during runtime. | ||
8 | |||
9 | If you're using a mobile platform that supports CPU idle PM (e.g. | ||
10 | an ACPI-capable notebook), you should say Y here. | ||
11 | |||
12 | config CPU_IDLE_GOV_LADDER | ||
13 | bool | ||
14 | depends on CPU_IDLE | ||
15 | default y | ||
16 | |||
17 | config CPU_IDLE_GOV_MENU | ||
18 | bool | ||
19 | depends on CPU_IDLE && NO_HZ | ||
20 | default y | ||
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile new file mode 100644 index 000000000000..5634f88379df --- /dev/null +++ b/drivers/cpuidle/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # | ||
2 | # Makefile for cpuidle. | ||
3 | # | ||
4 | |||
5 | obj-y += cpuidle.o driver.o governor.o sysfs.o governors/ | ||
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c new file mode 100644 index 000000000000..fdf4106b817b --- /dev/null +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -0,0 +1,295 @@ | |||
1 | /* | ||
2 | * cpuidle.c - core cpuidle infrastructure | ||
3 | * | ||
4 | * (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | ||
5 | * Shaohua Li <shaohua.li@intel.com> | ||
6 | * Adam Belay <abelay@novell.com> | ||
7 | * | ||
8 | * This code is licenced under the GPL. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/mutex.h> | ||
13 | #include <linux/sched.h> | ||
14 | #include <linux/notifier.h> | ||
15 | #include <linux/latency.h> | ||
16 | #include <linux/cpu.h> | ||
17 | #include <linux/cpuidle.h> | ||
18 | |||
19 | #include "cpuidle.h" | ||
20 | |||
21 | DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); | ||
22 | EXPORT_PER_CPU_SYMBOL_GPL(cpuidle_devices); | ||
23 | |||
24 | DEFINE_MUTEX(cpuidle_lock); | ||
25 | LIST_HEAD(cpuidle_detected_devices); | ||
26 | static void (*pm_idle_old)(void); | ||
27 | |||
28 | static int enabled_devices; | ||
29 | |||
30 | /** | ||
31 | * cpuidle_idle_call - the main idle loop | ||
32 | * | ||
33 | * NOTE: no locks or semaphores should be used here | ||
34 | */ | ||
35 | static void cpuidle_idle_call(void) | ||
36 | { | ||
37 | struct cpuidle_device *dev = __get_cpu_var(cpuidle_devices); | ||
38 | struct cpuidle_state *target_state; | ||
39 | int next_state; | ||
40 | |||
41 | /* check if the device is ready */ | ||
42 | if (!dev || !dev->enabled) { | ||
43 | if (pm_idle_old) | ||
44 | pm_idle_old(); | ||
45 | else | ||
46 | local_irq_enable(); | ||
47 | return; | ||
48 | } | ||
49 | |||
50 | /* ask the governor for the next state */ | ||
51 | next_state = cpuidle_curr_governor->select(dev); | ||
52 | if (need_resched()) | ||
53 | return; | ||
54 | target_state = &dev->states[next_state]; | ||
55 | |||
56 | /* enter the state and update stats */ | ||
57 | dev->last_residency = target_state->enter(dev, target_state); | ||
58 | dev->last_state = target_state; | ||
59 | target_state->time += dev->last_residency; | ||
60 | target_state->usage++; | ||
61 | |||
62 | /* give the governor an opportunity to reflect on the outcome */ | ||
63 | if (cpuidle_curr_governor->reflect) | ||
64 | cpuidle_curr_governor->reflect(dev); | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * cpuidle_install_idle_handler - installs the cpuidle idle loop handler | ||
69 | */ | ||
70 | void cpuidle_install_idle_handler(void) | ||
71 | { | ||
72 | if (enabled_devices && (pm_idle != cpuidle_idle_call)) { | ||
73 | /* Make sure all changes finished before we switch to new idle */ | ||
74 | smp_wmb(); | ||
75 | pm_idle = cpuidle_idle_call; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * cpuidle_uninstall_idle_handler - uninstalls the cpuidle idle loop handler | ||
81 | */ | ||
82 | void cpuidle_uninstall_idle_handler(void) | ||
83 | { | ||
84 | if (enabled_devices && (pm_idle != pm_idle_old)) { | ||
85 | pm_idle = pm_idle_old; | ||
86 | cpu_idle_wait(); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * cpuidle_pause_and_lock - temporarily disables CPUIDLE | ||
92 | */ | ||
93 | void cpuidle_pause_and_lock(void) | ||
94 | { | ||
95 | mutex_lock(&cpuidle_lock); | ||
96 | cpuidle_uninstall_idle_handler(); | ||
97 | } | ||
98 | |||
99 | EXPORT_SYMBOL_GPL(cpuidle_pause_and_lock); | ||
100 | |||
101 | /** | ||
102 | * cpuidle_resume_and_unlock - resumes CPUIDLE operation | ||
103 | */ | ||
104 | void cpuidle_resume_and_unlock(void) | ||
105 | { | ||
106 | cpuidle_install_idle_handler(); | ||
107 | mutex_unlock(&cpuidle_lock); | ||
108 | } | ||
109 | |||
110 | EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock); | ||
111 | |||
112 | /** | ||
113 | * cpuidle_enable_device - enables idle PM for a CPU | ||
114 | * @dev: the CPU | ||
115 | * | ||
116 | * This function must be called between cpuidle_pause_and_lock and | ||
117 | * cpuidle_resume_and_unlock when used externally. | ||
118 | */ | ||
119 | int cpuidle_enable_device(struct cpuidle_device *dev) | ||
120 | { | ||
121 | int ret, i; | ||
122 | |||
123 | if (dev->enabled) | ||
124 | return 0; | ||
125 | if (!cpuidle_curr_driver || !cpuidle_curr_governor) | ||
126 | return -EIO; | ||
127 | if (!dev->state_count) | ||
128 | return -EINVAL; | ||
129 | |||
130 | if ((ret = cpuidle_add_state_sysfs(dev))) | ||
131 | return ret; | ||
132 | |||
133 | if (cpuidle_curr_governor->enable && | ||
134 | (ret = cpuidle_curr_governor->enable(dev))) | ||
135 | goto fail_sysfs; | ||
136 | |||
137 | for (i = 0; i < dev->state_count; i++) { | ||
138 | dev->states[i].usage = 0; | ||
139 | dev->states[i].time = 0; | ||
140 | } | ||
141 | dev->last_residency = 0; | ||
142 | dev->last_state = NULL; | ||
143 | |||
144 | smp_wmb(); | ||
145 | |||
146 | dev->enabled = 1; | ||
147 | |||
148 | enabled_devices++; | ||
149 | return 0; | ||
150 | |||
151 | fail_sysfs: | ||
152 | cpuidle_remove_state_sysfs(dev); | ||
153 | |||
154 | return ret; | ||
155 | } | ||
156 | |||
157 | EXPORT_SYMBOL_GPL(cpuidle_enable_device); | ||
158 | |||
159 | /** | ||
160 | * cpuidle_disable_device - disables idle PM for a CPU | ||
161 | * @dev: the CPU | ||
162 | * | ||
163 | * This function must be called between cpuidle_pause_and_lock and | ||
164 | * cpuidle_resume_and_unlock when used externally. | ||
165 | */ | ||
166 | void cpuidle_disable_device(struct cpuidle_device *dev) | ||
167 | { | ||
168 | if (!dev->enabled) | ||
169 | return; | ||
170 | if (!cpuidle_curr_driver || !cpuidle_curr_governor) | ||
171 | return; | ||
172 | |||
173 | dev->enabled = 0; | ||
174 | |||
175 | if (cpuidle_curr_governor->disable) | ||
176 | cpuidle_curr_governor->disable(dev); | ||
177 | |||
178 | cpuidle_remove_state_sysfs(dev); | ||
179 | enabled_devices--; | ||
180 | } | ||
181 | |||
182 | EXPORT_SYMBOL_GPL(cpuidle_disable_device); | ||
183 | |||
184 | /** | ||
185 | * cpuidle_register_device - registers a CPU's idle PM feature | ||
186 | * @dev: the cpu | ||
187 | */ | ||
188 | int cpuidle_register_device(struct cpuidle_device *dev) | ||
189 | { | ||
190 | int ret; | ||
191 | struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu); | ||
192 | |||
193 | if (!sys_dev) | ||
194 | return -EINVAL; | ||
195 | if (!try_module_get(cpuidle_curr_driver->owner)) | ||
196 | return -EINVAL; | ||
197 | |||
198 | init_completion(&dev->kobj_unregister); | ||
199 | |||
200 | mutex_lock(&cpuidle_lock); | ||
201 | |||
202 | per_cpu(cpuidle_devices, dev->cpu) = dev; | ||
203 | list_add(&dev->device_list, &cpuidle_detected_devices); | ||
204 | if ((ret = cpuidle_add_sysfs(sys_dev))) { | ||
205 | mutex_unlock(&cpuidle_lock); | ||
206 | module_put(cpuidle_curr_driver->owner); | ||
207 | return ret; | ||
208 | } | ||
209 | |||
210 | cpuidle_enable_device(dev); | ||
211 | cpuidle_install_idle_handler(); | ||
212 | |||
213 | mutex_unlock(&cpuidle_lock); | ||
214 | |||
215 | return 0; | ||
216 | |||
217 | } | ||
218 | |||
219 | EXPORT_SYMBOL_GPL(cpuidle_register_device); | ||
220 | |||
221 | /** | ||
222 | * cpuidle_unregister_device - unregisters a CPU's idle PM feature | ||
223 | * @dev: the cpu | ||
224 | */ | ||
225 | void cpuidle_unregister_device(struct cpuidle_device *dev) | ||
226 | { | ||
227 | struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu); | ||
228 | |||
229 | cpuidle_pause_and_lock(); | ||
230 | |||
231 | cpuidle_disable_device(dev); | ||
232 | |||
233 | cpuidle_remove_sysfs(sys_dev); | ||
234 | list_del(&dev->device_list); | ||
235 | wait_for_completion(&dev->kobj_unregister); | ||
236 | per_cpu(cpuidle_devices, dev->cpu) = NULL; | ||
237 | |||
238 | cpuidle_resume_and_unlock(); | ||
239 | |||
240 | module_put(cpuidle_curr_driver->owner); | ||
241 | } | ||
242 | |||
243 | EXPORT_SYMBOL_GPL(cpuidle_unregister_device); | ||
244 | |||
245 | #ifdef CONFIG_SMP | ||
246 | |||
247 | static void smp_callback(void *v) | ||
248 | { | ||
249 | /* we already woke the CPU up, nothing more to do */ | ||
250 | } | ||
251 | |||
252 | /* | ||
253 | * This function gets called when a part of the kernel has a new latency | ||
254 | * requirement. This means we need to get all processors out of their C-state, | ||
255 | * and then recalculate a new suitable C-state. Just do a cross-cpu IPI; that | ||
256 | * wakes them all right up. | ||
257 | */ | ||
258 | static int cpuidle_latency_notify(struct notifier_block *b, | ||
259 | unsigned long l, void *v) | ||
260 | { | ||
261 | smp_call_function(smp_callback, NULL, 0, 1); | ||
262 | return NOTIFY_OK; | ||
263 | } | ||
264 | |||
265 | static struct notifier_block cpuidle_latency_notifier = { | ||
266 | .notifier_call = cpuidle_latency_notify, | ||
267 | }; | ||
268 | |||
269 | #define latency_notifier_init(x) do { register_latency_notifier(x); } while (0) | ||
270 | |||
271 | #else /* CONFIG_SMP */ | ||
272 | |||
273 | #define latency_notifier_init(x) do { } while (0) | ||
274 | |||
275 | #endif /* CONFIG_SMP */ | ||
276 | |||
277 | /** | ||
278 | * cpuidle_init - core initializer | ||
279 | */ | ||
280 | static int __init cpuidle_init(void) | ||
281 | { | ||
282 | int ret; | ||
283 | |||
284 | pm_idle_old = pm_idle; | ||
285 | |||
286 | ret = cpuidle_add_class_sysfs(&cpu_sysdev_class); | ||
287 | if (ret) | ||
288 | return ret; | ||
289 | |||
290 | latency_notifier_init(&cpuidle_latency_notifier); | ||
291 | |||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | core_initcall(cpuidle_init); | ||
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h new file mode 100644 index 000000000000..9476ba33ee2c --- /dev/null +++ b/drivers/cpuidle/cpuidle.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * cpuidle.h - The internal header file | ||
3 | */ | ||
4 | |||
5 | #ifndef __DRIVER_CPUIDLE_H | ||
6 | #define __DRIVER_CPUIDLE_H | ||
7 | |||
8 | #include <linux/sysdev.h> | ||
9 | |||
10 | /* For internal use only */ | ||
11 | extern struct cpuidle_governor *cpuidle_curr_governor; | ||
12 | extern struct cpuidle_driver *cpuidle_curr_driver; | ||
13 | extern struct list_head cpuidle_governors; | ||
14 | extern struct list_head cpuidle_detected_devices; | ||
15 | extern struct mutex cpuidle_lock; | ||
16 | extern spinlock_t cpuidle_driver_lock; | ||
17 | |||
18 | /* idle loop */ | ||
19 | extern void cpuidle_install_idle_handler(void); | ||
20 | extern void cpuidle_uninstall_idle_handler(void); | ||
21 | |||
22 | /* governors */ | ||
23 | extern int cpuidle_switch_governor(struct cpuidle_governor *gov); | ||
24 | |||
25 | /* sysfs */ | ||
26 | extern int cpuidle_add_class_sysfs(struct sysdev_class *cls); | ||
27 | extern void cpuidle_remove_class_sysfs(struct sysdev_class *cls); | ||
28 | extern int cpuidle_add_state_sysfs(struct cpuidle_device *device); | ||
29 | extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device); | ||
30 | extern int cpuidle_add_sysfs(struct sys_device *sysdev); | ||
31 | extern void cpuidle_remove_sysfs(struct sys_device *sysdev); | ||
32 | |||
33 | #endif /* __DRIVER_CPUIDLE_H */ | ||
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c new file mode 100644 index 000000000000..2257004fe33d --- /dev/null +++ b/drivers/cpuidle/driver.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * driver.c - driver support | ||
3 | * | ||
4 | * (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | ||
5 | * Shaohua Li <shaohua.li@intel.com> | ||
6 | * Adam Belay <abelay@novell.com> | ||
7 | * | ||
8 | * This code is licenced under the GPL. | ||
9 | */ | ||
10 | |||
11 | #include <linux/mutex.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/cpuidle.h> | ||
14 | |||
15 | #include "cpuidle.h" | ||
16 | |||
17 | struct cpuidle_driver *cpuidle_curr_driver; | ||
18 | DEFINE_SPINLOCK(cpuidle_driver_lock); | ||
19 | |||
20 | /** | ||
21 | * cpuidle_register_driver - registers a driver | ||
22 | * @drv: the driver | ||
23 | */ | ||
24 | int cpuidle_register_driver(struct cpuidle_driver *drv) | ||
25 | { | ||
26 | if (!drv) | ||
27 | return -EINVAL; | ||
28 | |||
29 | spin_lock(&cpuidle_driver_lock); | ||
30 | if (cpuidle_curr_driver) { | ||
31 | spin_unlock(&cpuidle_driver_lock); | ||
32 | return -EBUSY; | ||
33 | } | ||
34 | cpuidle_curr_driver = drv; | ||
35 | spin_unlock(&cpuidle_driver_lock); | ||
36 | |||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | EXPORT_SYMBOL_GPL(cpuidle_register_driver); | ||
41 | |||
42 | /** | ||
43 | * cpuidle_unregister_driver - unregisters a driver | ||
44 | * @drv: the driver | ||
45 | */ | ||
46 | void cpuidle_unregister_driver(struct cpuidle_driver *drv) | ||
47 | { | ||
48 | if (!drv) | ||
49 | return; | ||
50 | |||
51 | spin_lock(&cpuidle_driver_lock); | ||
52 | cpuidle_curr_driver = NULL; | ||
53 | spin_unlock(&cpuidle_driver_lock); | ||
54 | } | ||
55 | |||
56 | EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); | ||
diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c new file mode 100644 index 000000000000..bb699cb2dc5a --- /dev/null +++ b/drivers/cpuidle/governor.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * governor.c - governor support | ||
3 | * | ||
4 | * (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | ||
5 | * Shaohua Li <shaohua.li@intel.com> | ||
6 | * Adam Belay <abelay@novell.com> | ||
7 | * | ||
8 | * This code is licenced under the GPL. | ||
9 | */ | ||
10 | |||
11 | #include <linux/mutex.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/cpuidle.h> | ||
14 | |||
15 | #include "cpuidle.h" | ||
16 | |||
17 | LIST_HEAD(cpuidle_governors); | ||
18 | struct cpuidle_governor *cpuidle_curr_governor; | ||
19 | |||
20 | /** | ||
21 | * __cpuidle_find_governor - finds a governor of the specified name | ||
22 | * @str: the name | ||
23 | * | ||
24 | * Must be called with cpuidle_lock aquired. | ||
25 | */ | ||
26 | static struct cpuidle_governor * __cpuidle_find_governor(const char *str) | ||
27 | { | ||
28 | struct cpuidle_governor *gov; | ||
29 | |||
30 | list_for_each_entry(gov, &cpuidle_governors, governor_list) | ||
31 | if (!strnicmp(str, gov->name, CPUIDLE_NAME_LEN)) | ||
32 | return gov; | ||
33 | |||
34 | return NULL; | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * cpuidle_switch_governor - changes the governor | ||
39 | * @gov: the new target governor | ||
40 | * | ||
41 | * NOTE: "gov" can be NULL to specify disabled | ||
42 | * Must be called with cpuidle_lock aquired. | ||
43 | */ | ||
44 | int cpuidle_switch_governor(struct cpuidle_governor *gov) | ||
45 | { | ||
46 | struct cpuidle_device *dev; | ||
47 | |||
48 | if (gov == cpuidle_curr_governor) | ||
49 | return 0; | ||
50 | |||
51 | cpuidle_uninstall_idle_handler(); | ||
52 | |||
53 | if (cpuidle_curr_governor) { | ||
54 | list_for_each_entry(dev, &cpuidle_detected_devices, device_list) | ||
55 | cpuidle_disable_device(dev); | ||
56 | module_put(cpuidle_curr_governor->owner); | ||
57 | } | ||
58 | |||
59 | cpuidle_curr_governor = gov; | ||
60 | |||
61 | if (gov) { | ||
62 | if (!try_module_get(cpuidle_curr_governor->owner)) | ||
63 | return -EINVAL; | ||
64 | list_for_each_entry(dev, &cpuidle_detected_devices, device_list) | ||
65 | cpuidle_enable_device(dev); | ||
66 | cpuidle_install_idle_handler(); | ||
67 | printk(KERN_INFO "cpuidle: using governor %s\n", gov->name); | ||
68 | } | ||
69 | |||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | * cpuidle_register_governor - registers a governor | ||
75 | * @gov: the governor | ||
76 | */ | ||
77 | int cpuidle_register_governor(struct cpuidle_governor *gov) | ||
78 | { | ||
79 | int ret = -EEXIST; | ||
80 | |||
81 | if (!gov || !gov->select) | ||
82 | return -EINVAL; | ||
83 | |||
84 | mutex_lock(&cpuidle_lock); | ||
85 | if (__cpuidle_find_governor(gov->name) == NULL) { | ||
86 | ret = 0; | ||
87 | list_add_tail(&gov->governor_list, &cpuidle_governors); | ||
88 | if (!cpuidle_curr_governor || | ||
89 | cpuidle_curr_governor->rating < gov->rating) | ||
90 | cpuidle_switch_governor(gov); | ||
91 | } | ||
92 | mutex_unlock(&cpuidle_lock); | ||
93 | |||
94 | return ret; | ||
95 | } | ||
96 | |||
97 | EXPORT_SYMBOL_GPL(cpuidle_register_governor); | ||
98 | |||
99 | /** | ||
100 | * cpuidle_replace_governor - find a replacement governor | ||
101 | * @exclude_rating: the rating that will be skipped while looking for | ||
102 | * new governor. | ||
103 | */ | ||
104 | static struct cpuidle_governor *cpuidle_replace_governor(int exclude_rating) | ||
105 | { | ||
106 | struct cpuidle_governor *gov; | ||
107 | struct cpuidle_governor *ret_gov = NULL; | ||
108 | unsigned int max_rating = 0; | ||
109 | |||
110 | list_for_each_entry(gov, &cpuidle_governors, governor_list) { | ||
111 | if (gov->rating == exclude_rating) | ||
112 | continue; | ||
113 | if (gov->rating > max_rating) { | ||
114 | max_rating = gov->rating; | ||
115 | ret_gov = gov; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | return ret_gov; | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * cpuidle_unregister_governor - unregisters a governor | ||
124 | * @gov: the governor | ||
125 | */ | ||
126 | void cpuidle_unregister_governor(struct cpuidle_governor *gov) | ||
127 | { | ||
128 | if (!gov) | ||
129 | return; | ||
130 | |||
131 | mutex_lock(&cpuidle_lock); | ||
132 | if (gov == cpuidle_curr_governor) { | ||
133 | struct cpuidle_governor *new_gov; | ||
134 | new_gov = cpuidle_replace_governor(gov->rating); | ||
135 | cpuidle_switch_governor(new_gov); | ||
136 | } | ||
137 | list_del(&gov->governor_list); | ||
138 | mutex_unlock(&cpuidle_lock); | ||
139 | } | ||
140 | |||
141 | EXPORT_SYMBOL_GPL(cpuidle_unregister_governor); | ||
diff --git a/drivers/cpuidle/governors/Makefile b/drivers/cpuidle/governors/Makefile new file mode 100644 index 000000000000..1b512722689f --- /dev/null +++ b/drivers/cpuidle/governors/Makefile | |||
@@ -0,0 +1,6 @@ | |||
1 | # | ||
2 | # Makefile for cpuidle governors. | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o | ||
6 | obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o | ||
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c new file mode 100644 index 000000000000..eb666ecae7c9 --- /dev/null +++ b/drivers/cpuidle/governors/ladder.c | |||
@@ -0,0 +1,166 @@ | |||
1 | /* | ||
2 | * ladder.c - the residency ladder algorithm | ||
3 | * | ||
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | ||
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | ||
6 | * Copyright (C) 2004, 2005 Dominik Brodowski <linux@brodo.de> | ||
7 | * | ||
8 | * (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | ||
9 | * Shaohua Li <shaohua.li@intel.com> | ||
10 | * Adam Belay <abelay@novell.com> | ||
11 | * | ||
12 | * This code is licenced under the GPL. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/cpuidle.h> | ||
17 | #include <linux/latency.h> | ||
18 | #include <linux/moduleparam.h> | ||
19 | #include <linux/jiffies.h> | ||
20 | |||
21 | #include <asm/io.h> | ||
22 | #include <asm/uaccess.h> | ||
23 | |||
24 | #define PROMOTION_COUNT 4 | ||
25 | #define DEMOTION_COUNT 1 | ||
26 | |||
27 | struct ladder_device_state { | ||
28 | struct { | ||
29 | u32 promotion_count; | ||
30 | u32 demotion_count; | ||
31 | u32 promotion_time; | ||
32 | u32 demotion_time; | ||
33 | } threshold; | ||
34 | struct { | ||
35 | int promotion_count; | ||
36 | int demotion_count; | ||
37 | } stats; | ||
38 | }; | ||
39 | |||
40 | struct ladder_device { | ||
41 | struct ladder_device_state states[CPUIDLE_STATE_MAX]; | ||
42 | int last_state_idx; | ||
43 | }; | ||
44 | |||
45 | static DEFINE_PER_CPU(struct ladder_device, ladder_devices); | ||
46 | |||
47 | /** | ||
48 | * ladder_do_selection - prepares private data for a state change | ||
49 | * @ldev: the ladder device | ||
50 | * @old_idx: the current state index | ||
51 | * @new_idx: the new target state index | ||
52 | */ | ||
53 | static inline void ladder_do_selection(struct ladder_device *ldev, | ||
54 | int old_idx, int new_idx) | ||
55 | { | ||
56 | ldev->states[old_idx].stats.promotion_count = 0; | ||
57 | ldev->states[old_idx].stats.demotion_count = 0; | ||
58 | ldev->last_state_idx = new_idx; | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * ladder_select_state - selects the next state to enter | ||
63 | * @dev: the CPU | ||
64 | */ | ||
65 | static int ladder_select_state(struct cpuidle_device *dev) | ||
66 | { | ||
67 | struct ladder_device *ldev = &__get_cpu_var(ladder_devices); | ||
68 | struct ladder_device_state *last_state; | ||
69 | int last_residency, last_idx = ldev->last_state_idx; | ||
70 | |||
71 | if (unlikely(!ldev)) | ||
72 | return 0; | ||
73 | |||
74 | last_state = &ldev->states[last_idx]; | ||
75 | |||
76 | if (dev->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID) | ||
77 | last_residency = cpuidle_get_last_residency(dev) - dev->states[last_idx].exit_latency; | ||
78 | else | ||
79 | last_residency = last_state->threshold.promotion_time + 1; | ||
80 | |||
81 | /* consider promotion */ | ||
82 | if (last_idx < dev->state_count - 1 && | ||
83 | last_residency > last_state->threshold.promotion_time && | ||
84 | dev->states[last_idx + 1].exit_latency <= system_latency_constraint()) { | ||
85 | last_state->stats.promotion_count++; | ||
86 | last_state->stats.demotion_count = 0; | ||
87 | if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) { | ||
88 | ladder_do_selection(ldev, last_idx, last_idx + 1); | ||
89 | return last_idx + 1; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | /* consider demotion */ | ||
94 | if (last_idx > 0 && | ||
95 | last_residency < last_state->threshold.demotion_time) { | ||
96 | last_state->stats.demotion_count++; | ||
97 | last_state->stats.promotion_count = 0; | ||
98 | if (last_state->stats.demotion_count >= last_state->threshold.demotion_count) { | ||
99 | ladder_do_selection(ldev, last_idx, last_idx - 1); | ||
100 | return last_idx - 1; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | /* otherwise remain at the current state */ | ||
105 | return last_idx; | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * ladder_enable_device - setup for the governor | ||
110 | * @dev: the CPU | ||
111 | */ | ||
112 | static int ladder_enable_device(struct cpuidle_device *dev) | ||
113 | { | ||
114 | int i; | ||
115 | struct ladder_device *ldev = &per_cpu(ladder_devices, dev->cpu); | ||
116 | struct ladder_device_state *lstate; | ||
117 | struct cpuidle_state *state; | ||
118 | |||
119 | ldev->last_state_idx = 0; | ||
120 | |||
121 | for (i = 0; i < dev->state_count; i++) { | ||
122 | state = &dev->states[i]; | ||
123 | lstate = &ldev->states[i]; | ||
124 | |||
125 | lstate->stats.promotion_count = 0; | ||
126 | lstate->stats.demotion_count = 0; | ||
127 | |||
128 | lstate->threshold.promotion_count = PROMOTION_COUNT; | ||
129 | lstate->threshold.demotion_count = DEMOTION_COUNT; | ||
130 | |||
131 | if (i < dev->state_count - 1) | ||
132 | lstate->threshold.promotion_time = state->exit_latency; | ||
133 | if (i > 0) | ||
134 | lstate->threshold.demotion_time = state->exit_latency; | ||
135 | } | ||
136 | |||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | static struct cpuidle_governor ladder_governor = { | ||
141 | .name = "ladder", | ||
142 | .rating = 10, | ||
143 | .enable = ladder_enable_device, | ||
144 | .select = ladder_select_state, | ||
145 | .owner = THIS_MODULE, | ||
146 | }; | ||
147 | |||
148 | /** | ||
149 | * init_ladder - initializes the governor | ||
150 | */ | ||
151 | static int __init init_ladder(void) | ||
152 | { | ||
153 | return cpuidle_register_governor(&ladder_governor); | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * exit_ladder - exits the governor | ||
158 | */ | ||
159 | static void __exit exit_ladder(void) | ||
160 | { | ||
161 | cpuidle_unregister_governor(&ladder_governor); | ||
162 | } | ||
163 | |||
164 | MODULE_LICENSE("GPL"); | ||
165 | module_init(init_ladder); | ||
166 | module_exit(exit_ladder); | ||
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c new file mode 100644 index 000000000000..299d45c3bdd2 --- /dev/null +++ b/drivers/cpuidle/governors/menu.c | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | * menu.c - the menu idle governor | ||
3 | * | ||
4 | * Copyright (C) 2006-2007 Adam Belay <abelay@novell.com> | ||
5 | * | ||
6 | * This code is licenced under the GPL. | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/cpuidle.h> | ||
11 | #include <linux/latency.h> | ||
12 | #include <linux/time.h> | ||
13 | #include <linux/ktime.h> | ||
14 | #include <linux/hrtimer.h> | ||
15 | #include <linux/tick.h> | ||
16 | |||
17 | #define BREAK_FUZZ 4 /* 4 us */ | ||
18 | |||
19 | struct menu_device { | ||
20 | int last_state_idx; | ||
21 | |||
22 | unsigned int expected_us; | ||
23 | unsigned int predicted_us; | ||
24 | unsigned int last_measured_us; | ||
25 | unsigned int elapsed_us; | ||
26 | }; | ||
27 | |||
28 | static DEFINE_PER_CPU(struct menu_device, menu_devices); | ||
29 | |||
30 | /** | ||
31 | * menu_select - selects the next idle state to enter | ||
32 | * @dev: the CPU | ||
33 | */ | ||
34 | static int menu_select(struct cpuidle_device *dev) | ||
35 | { | ||
36 | struct menu_device *data = &__get_cpu_var(menu_devices); | ||
37 | int i; | ||
38 | |||
39 | /* determine the expected residency time */ | ||
40 | data->expected_us = | ||
41 | (u32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000; | ||
42 | |||
43 | /* find the deepest idle state that satisfies our constraints */ | ||
44 | for (i = 1; i < dev->state_count; i++) { | ||
45 | struct cpuidle_state *s = &dev->states[i]; | ||
46 | |||
47 | if (s->target_residency > data->expected_us) | ||
48 | break; | ||
49 | if (s->target_residency > data->predicted_us) | ||
50 | break; | ||
51 | if (s->exit_latency > system_latency_constraint()) | ||
52 | break; | ||
53 | } | ||
54 | |||
55 | data->last_state_idx = i - 1; | ||
56 | return i - 1; | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * menu_reflect - attempts to guess what happened after entry | ||
61 | * @dev: the CPU | ||
62 | * | ||
63 | * NOTE: it's important to be fast here because this operation will add to | ||
64 | * the overall exit latency. | ||
65 | */ | ||
66 | static void menu_reflect(struct cpuidle_device *dev) | ||
67 | { | ||
68 | struct menu_device *data = &__get_cpu_var(menu_devices); | ||
69 | int last_idx = data->last_state_idx; | ||
70 | unsigned int measured_us = | ||
71 | cpuidle_get_last_residency(dev) + data->elapsed_us; | ||
72 | struct cpuidle_state *target = &dev->states[last_idx]; | ||
73 | |||
74 | /* | ||
75 | * Ugh, this idle state doesn't support residency measurements, so we | ||
76 | * are basically lost in the dark. As a compromise, assume we slept | ||
77 | * for one full standard timer tick. However, be aware that this | ||
78 | * could potentially result in a suboptimal state transition. | ||
79 | */ | ||
80 | if (!(target->flags & CPUIDLE_FLAG_TIME_VALID)) | ||
81 | measured_us = USEC_PER_SEC / HZ; | ||
82 | |||
83 | /* Predict time remaining until next break event */ | ||
84 | if (measured_us + BREAK_FUZZ < data->expected_us - target->exit_latency) { | ||
85 | data->predicted_us = max(measured_us, data->last_measured_us); | ||
86 | data->last_measured_us = measured_us; | ||
87 | data->elapsed_us = 0; | ||
88 | } else { | ||
89 | if (data->elapsed_us < data->elapsed_us + measured_us) | ||
90 | data->elapsed_us = measured_us; | ||
91 | else | ||
92 | data->elapsed_us = -1; | ||
93 | data->predicted_us = max(measured_us, data->last_measured_us); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | /** | ||
98 | * menu_enable_device - scans a CPU's states and does setup | ||
99 | * @dev: the CPU | ||
100 | */ | ||
101 | static int menu_enable_device(struct cpuidle_device *dev) | ||
102 | { | ||
103 | struct menu_device *data = &per_cpu(menu_devices, dev->cpu); | ||
104 | |||
105 | memset(data, 0, sizeof(struct menu_device)); | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static struct cpuidle_governor menu_governor = { | ||
111 | .name = "menu", | ||
112 | .rating = 20, | ||
113 | .enable = menu_enable_device, | ||
114 | .select = menu_select, | ||
115 | .reflect = menu_reflect, | ||
116 | .owner = THIS_MODULE, | ||
117 | }; | ||
118 | |||
119 | /** | ||
120 | * init_menu - initializes the governor | ||
121 | */ | ||
122 | static int __init init_menu(void) | ||
123 | { | ||
124 | return cpuidle_register_governor(&menu_governor); | ||
125 | } | ||
126 | |||
127 | /** | ||
128 | * exit_menu - exits the governor | ||
129 | */ | ||
130 | static void __exit exit_menu(void) | ||
131 | { | ||
132 | cpuidle_unregister_governor(&menu_governor); | ||
133 | } | ||
134 | |||
135 | MODULE_LICENSE("GPL"); | ||
136 | module_init(init_menu); | ||
137 | module_exit(exit_menu); | ||
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c new file mode 100644 index 000000000000..0f3515e77d4b --- /dev/null +++ b/drivers/cpuidle/sysfs.c | |||
@@ -0,0 +1,361 @@ | |||
1 | /* | ||
2 | * sysfs.c - sysfs support | ||
3 | * | ||
4 | * (C) 2006-2007 Shaohua Li <shaohua.li@intel.com> | ||
5 | * | ||
6 | * This code is licenced under the GPL. | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/cpuidle.h> | ||
11 | #include <linux/sysfs.h> | ||
12 | #include <linux/cpu.h> | ||
13 | |||
14 | #include "cpuidle.h" | ||
15 | |||
16 | static unsigned int sysfs_switch; | ||
17 | static int __init cpuidle_sysfs_setup(char *unused) | ||
18 | { | ||
19 | sysfs_switch = 1; | ||
20 | return 1; | ||
21 | } | ||
22 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); | ||
23 | |||
24 | static ssize_t show_available_governors(struct sys_device *dev, char *buf) | ||
25 | { | ||
26 | ssize_t i = 0; | ||
27 | struct cpuidle_governor *tmp; | ||
28 | |||
29 | mutex_lock(&cpuidle_lock); | ||
30 | list_for_each_entry(tmp, &cpuidle_governors, governor_list) { | ||
31 | if (i >= (ssize_t) ((PAGE_SIZE/sizeof(char)) - CPUIDLE_NAME_LEN - 2)) | ||
32 | goto out; | ||
33 | i += scnprintf(&buf[i], CPUIDLE_NAME_LEN, "%s ", tmp->name); | ||
34 | } | ||
35 | |||
36 | out: | ||
37 | i+= sprintf(&buf[i], "\n"); | ||
38 | mutex_unlock(&cpuidle_lock); | ||
39 | return i; | ||
40 | } | ||
41 | |||
42 | static ssize_t show_current_driver(struct sys_device *dev, char *buf) | ||
43 | { | ||
44 | ssize_t ret; | ||
45 | |||
46 | spin_lock(&cpuidle_driver_lock); | ||
47 | if (cpuidle_curr_driver) | ||
48 | ret = sprintf(buf, "%s\n", cpuidle_curr_driver->name); | ||
49 | else | ||
50 | ret = sprintf(buf, "none\n"); | ||
51 | spin_unlock(&cpuidle_driver_lock); | ||
52 | |||
53 | return ret; | ||
54 | } | ||
55 | |||
56 | static ssize_t show_current_governor(struct sys_device *dev, char *buf) | ||
57 | { | ||
58 | ssize_t ret; | ||
59 | |||
60 | mutex_lock(&cpuidle_lock); | ||
61 | if (cpuidle_curr_governor) | ||
62 | ret = sprintf(buf, "%s\n", cpuidle_curr_governor->name); | ||
63 | else | ||
64 | ret = sprintf(buf, "none\n"); | ||
65 | mutex_unlock(&cpuidle_lock); | ||
66 | |||
67 | return ret; | ||
68 | } | ||
69 | |||
70 | static ssize_t store_current_governor(struct sys_device *dev, | ||
71 | const char *buf, size_t count) | ||
72 | { | ||
73 | char gov_name[CPUIDLE_NAME_LEN]; | ||
74 | int ret = -EINVAL; | ||
75 | size_t len = count; | ||
76 | struct cpuidle_governor *gov; | ||
77 | |||
78 | if (!len || len >= sizeof(gov_name)) | ||
79 | return -EINVAL; | ||
80 | |||
81 | memcpy(gov_name, buf, len); | ||
82 | gov_name[len] = '\0'; | ||
83 | if (gov_name[len - 1] == '\n') | ||
84 | gov_name[--len] = '\0'; | ||
85 | |||
86 | mutex_lock(&cpuidle_lock); | ||
87 | |||
88 | list_for_each_entry(gov, &cpuidle_governors, governor_list) { | ||
89 | if (strlen(gov->name) == len && !strcmp(gov->name, gov_name)) { | ||
90 | ret = cpuidle_switch_governor(gov); | ||
91 | break; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | mutex_unlock(&cpuidle_lock); | ||
96 | |||
97 | if (ret) | ||
98 | return ret; | ||
99 | else | ||
100 | return count; | ||
101 | } | ||
102 | |||
103 | static SYSDEV_ATTR(current_driver, 0444, show_current_driver, NULL); | ||
104 | static SYSDEV_ATTR(current_governor_ro, 0444, show_current_governor, NULL); | ||
105 | |||
106 | static struct attribute *cpuclass_default_attrs[] = { | ||
107 | &attr_current_driver.attr, | ||
108 | &attr_current_governor_ro.attr, | ||
109 | NULL | ||
110 | }; | ||
111 | |||
112 | static SYSDEV_ATTR(available_governors, 0444, show_available_governors, NULL); | ||
113 | static SYSDEV_ATTR(current_governor, 0644, show_current_governor, | ||
114 | store_current_governor); | ||
115 | |||
116 | static struct attribute *cpuclass_switch_attrs[] = { | ||
117 | &attr_available_governors.attr, | ||
118 | &attr_current_driver.attr, | ||
119 | &attr_current_governor.attr, | ||
120 | NULL | ||
121 | }; | ||
122 | |||
123 | static struct attribute_group cpuclass_attr_group = { | ||
124 | .attrs = cpuclass_default_attrs, | ||
125 | .name = "cpuidle", | ||
126 | }; | ||
127 | |||
128 | /** | ||
129 | * cpuidle_add_class_sysfs - add CPU global sysfs attributes | ||
130 | */ | ||
131 | int cpuidle_add_class_sysfs(struct sysdev_class *cls) | ||
132 | { | ||
133 | if (sysfs_switch) | ||
134 | cpuclass_attr_group.attrs = cpuclass_switch_attrs; | ||
135 | |||
136 | return sysfs_create_group(&cls->kset.kobj, &cpuclass_attr_group); | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * cpuidle_remove_class_sysfs - remove CPU global sysfs attributes | ||
141 | */ | ||
142 | void cpuidle_remove_class_sysfs(struct sysdev_class *cls) | ||
143 | { | ||
144 | sysfs_remove_group(&cls->kset.kobj, &cpuclass_attr_group); | ||
145 | } | ||
146 | |||
147 | struct cpuidle_attr { | ||
148 | struct attribute attr; | ||
149 | ssize_t (*show)(struct cpuidle_device *, char *); | ||
150 | ssize_t (*store)(struct cpuidle_device *, const char *, size_t count); | ||
151 | }; | ||
152 | |||
153 | #define define_one_ro(_name, show) \ | ||
154 | static struct cpuidle_attr attr_##_name = __ATTR(_name, 0444, show, NULL) | ||
155 | #define define_one_rw(_name, show, store) \ | ||
156 | static struct cpuidle_attr attr_##_name = __ATTR(_name, 0644, show, store) | ||
157 | |||
158 | #define kobj_to_cpuidledev(k) container_of(k, struct cpuidle_device, kobj) | ||
159 | #define attr_to_cpuidleattr(a) container_of(a, struct cpuidle_attr, attr) | ||
160 | static ssize_t cpuidle_show(struct kobject * kobj, struct attribute * attr ,char * buf) | ||
161 | { | ||
162 | int ret = -EIO; | ||
163 | struct cpuidle_device *dev = kobj_to_cpuidledev(kobj); | ||
164 | struct cpuidle_attr * cattr = attr_to_cpuidleattr(attr); | ||
165 | |||
166 | if (cattr->show) { | ||
167 | mutex_lock(&cpuidle_lock); | ||
168 | ret = cattr->show(dev, buf); | ||
169 | mutex_unlock(&cpuidle_lock); | ||
170 | } | ||
171 | return ret; | ||
172 | } | ||
173 | |||
174 | static ssize_t cpuidle_store(struct kobject * kobj, struct attribute * attr, | ||
175 | const char * buf, size_t count) | ||
176 | { | ||
177 | int ret = -EIO; | ||
178 | struct cpuidle_device *dev = kobj_to_cpuidledev(kobj); | ||
179 | struct cpuidle_attr * cattr = attr_to_cpuidleattr(attr); | ||
180 | |||
181 | if (cattr->store) { | ||
182 | mutex_lock(&cpuidle_lock); | ||
183 | ret = cattr->store(dev, buf, count); | ||
184 | mutex_unlock(&cpuidle_lock); | ||
185 | } | ||
186 | return ret; | ||
187 | } | ||
188 | |||
189 | static struct sysfs_ops cpuidle_sysfs_ops = { | ||
190 | .show = cpuidle_show, | ||
191 | .store = cpuidle_store, | ||
192 | }; | ||
193 | |||
194 | static void cpuidle_sysfs_release(struct kobject *kobj) | ||
195 | { | ||
196 | struct cpuidle_device *dev = kobj_to_cpuidledev(kobj); | ||
197 | |||
198 | complete(&dev->kobj_unregister); | ||
199 | } | ||
200 | |||
201 | static struct kobj_type ktype_cpuidle = { | ||
202 | .sysfs_ops = &cpuidle_sysfs_ops, | ||
203 | .release = cpuidle_sysfs_release, | ||
204 | }; | ||
205 | |||
206 | struct cpuidle_state_attr { | ||
207 | struct attribute attr; | ||
208 | ssize_t (*show)(struct cpuidle_state *, char *); | ||
209 | ssize_t (*store)(struct cpuidle_state *, const char *, size_t); | ||
210 | }; | ||
211 | |||
212 | #define define_one_state_ro(_name, show) \ | ||
213 | static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) | ||
214 | |||
215 | #define define_show_state_function(_name) \ | ||
216 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | ||
217 | { \ | ||
218 | return sprintf(buf, "%u\n", state->_name);\ | ||
219 | } | ||
220 | |||
221 | static ssize_t show_state_name(struct cpuidle_state *state, char *buf) | ||
222 | { | ||
223 | return sprintf(buf, "%s\n", state->name); | ||
224 | } | ||
225 | |||
226 | define_show_state_function(exit_latency) | ||
227 | define_show_state_function(power_usage) | ||
228 | define_show_state_function(usage) | ||
229 | define_show_state_function(time) | ||
230 | define_one_state_ro(name, show_state_name); | ||
231 | define_one_state_ro(latency, show_state_exit_latency); | ||
232 | define_one_state_ro(power, show_state_power_usage); | ||
233 | define_one_state_ro(usage, show_state_usage); | ||
234 | define_one_state_ro(time, show_state_time); | ||
235 | |||
236 | static struct attribute *cpuidle_state_default_attrs[] = { | ||
237 | &attr_name.attr, | ||
238 | &attr_latency.attr, | ||
239 | &attr_power.attr, | ||
240 | &attr_usage.attr, | ||
241 | &attr_time.attr, | ||
242 | NULL | ||
243 | }; | ||
244 | |||
245 | #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) | ||
246 | #define kobj_to_state(k) (kobj_to_state_obj(k)->state) | ||
247 | #define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) | ||
248 | static ssize_t cpuidle_state_show(struct kobject * kobj, | ||
249 | struct attribute * attr ,char * buf) | ||
250 | { | ||
251 | int ret = -EIO; | ||
252 | struct cpuidle_state *state = kobj_to_state(kobj); | ||
253 | struct cpuidle_state_attr * cattr = attr_to_stateattr(attr); | ||
254 | |||
255 | if (cattr->show) | ||
256 | ret = cattr->show(state, buf); | ||
257 | |||
258 | return ret; | ||
259 | } | ||
260 | |||
261 | static struct sysfs_ops cpuidle_state_sysfs_ops = { | ||
262 | .show = cpuidle_state_show, | ||
263 | }; | ||
264 | |||
265 | static void cpuidle_state_sysfs_release(struct kobject *kobj) | ||
266 | { | ||
267 | struct cpuidle_state_kobj *state_obj = kobj_to_state_obj(kobj); | ||
268 | |||
269 | complete(&state_obj->kobj_unregister); | ||
270 | } | ||
271 | |||
272 | static struct kobj_type ktype_state_cpuidle = { | ||
273 | .sysfs_ops = &cpuidle_state_sysfs_ops, | ||
274 | .default_attrs = cpuidle_state_default_attrs, | ||
275 | .release = cpuidle_state_sysfs_release, | ||
276 | }; | ||
277 | |||
278 | static void inline cpuidle_free_state_kobj(struct cpuidle_device *device, int i) | ||
279 | { | ||
280 | kobject_unregister(&device->kobjs[i]->kobj); | ||
281 | wait_for_completion(&device->kobjs[i]->kobj_unregister); | ||
282 | kfree(device->kobjs[i]); | ||
283 | device->kobjs[i] = NULL; | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * cpuidle_add_driver_sysfs - adds driver-specific sysfs attributes | ||
288 | * @device: the target device | ||
289 | */ | ||
290 | int cpuidle_add_state_sysfs(struct cpuidle_device *device) | ||
291 | { | ||
292 | int i, ret = -ENOMEM; | ||
293 | struct cpuidle_state_kobj *kobj; | ||
294 | |||
295 | /* state statistics */ | ||
296 | for (i = 0; i < device->state_count; i++) { | ||
297 | kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); | ||
298 | if (!kobj) | ||
299 | goto error_state; | ||
300 | kobj->state = &device->states[i]; | ||
301 | init_completion(&kobj->kobj_unregister); | ||
302 | |||
303 | kobj->kobj.parent = &device->kobj; | ||
304 | kobj->kobj.ktype = &ktype_state_cpuidle; | ||
305 | kobject_set_name(&kobj->kobj, "state%d", i); | ||
306 | ret = kobject_register(&kobj->kobj); | ||
307 | if (ret) { | ||
308 | kfree(kobj); | ||
309 | goto error_state; | ||
310 | } | ||
311 | device->kobjs[i] = kobj; | ||
312 | } | ||
313 | |||
314 | return 0; | ||
315 | |||
316 | error_state: | ||
317 | for (i = i - 1; i >= 0; i--) | ||
318 | cpuidle_free_state_kobj(device, i); | ||
319 | return ret; | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * cpuidle_remove_driver_sysfs - removes driver-specific sysfs attributes | ||
324 | * @device: the target device | ||
325 | */ | ||
326 | void cpuidle_remove_state_sysfs(struct cpuidle_device *device) | ||
327 | { | ||
328 | int i; | ||
329 | |||
330 | for (i = 0; i < device->state_count; i++) | ||
331 | cpuidle_free_state_kobj(device, i); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * cpuidle_add_sysfs - creates a sysfs instance for the target device | ||
336 | * @sysdev: the target device | ||
337 | */ | ||
338 | int cpuidle_add_sysfs(struct sys_device *sysdev) | ||
339 | { | ||
340 | int cpu = sysdev->id; | ||
341 | struct cpuidle_device *dev; | ||
342 | |||
343 | dev = per_cpu(cpuidle_devices, cpu); | ||
344 | dev->kobj.parent = &sysdev->kobj; | ||
345 | dev->kobj.ktype = &ktype_cpuidle; | ||
346 | kobject_set_name(&dev->kobj, "%s", "cpuidle"); | ||
347 | return kobject_register(&dev->kobj); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * cpuidle_remove_sysfs - deletes a sysfs instance on the target device | ||
352 | * @sysdev: the target device | ||
353 | */ | ||
354 | void cpuidle_remove_sysfs(struct sys_device *sysdev) | ||
355 | { | ||
356 | int cpu = sysdev->id; | ||
357 | struct cpuidle_device *dev; | ||
358 | |||
359 | dev = per_cpu(cpuidle_devices, cpu); | ||
360 | kobject_unregister(&dev->kobj); | ||
361 | } | ||
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h index e80af67664cc..2d23e304f5ec 100644 --- a/drivers/edac/edac_core.h +++ b/drivers/edac/edac_core.h | |||
@@ -94,8 +94,6 @@ extern int edac_debug_level; | |||
94 | 94 | ||
95 | #endif /* !CONFIG_EDAC_DEBUG */ | 95 | #endif /* !CONFIG_EDAC_DEBUG */ |
96 | 96 | ||
97 | #define BIT(x) (1 << (x)) | ||
98 | |||
99 | #define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \ | 97 | #define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \ |
100 | PCI_DEVICE_ID_ ## vend ## _ ## dev | 98 | PCI_DEVICE_ID_ ## vend ## _ ## dev |
101 | 99 | ||
diff --git a/drivers/edac/pasemi_edac.c b/drivers/edac/pasemi_edac.c index e66cdd42a392..9007d0677220 100644 --- a/drivers/edac/pasemi_edac.c +++ b/drivers/edac/pasemi_edac.c | |||
@@ -270,6 +270,7 @@ static void __devexit pasemi_edac_remove(struct pci_dev *pdev) | |||
270 | 270 | ||
271 | static const struct pci_device_id pasemi_edac_pci_tbl[] = { | 271 | static const struct pci_device_id pasemi_edac_pci_tbl[] = { |
272 | { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa00a) }, | 272 | { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa00a) }, |
273 | { } | ||
273 | }; | 274 | }; |
274 | 275 | ||
275 | MODULE_DEVICE_TABLE(pci, pasemi_edac_pci_tbl); | 276 | MODULE_DEVICE_TABLE(pci, pasemi_edac_pci_tbl); |
diff --git a/drivers/firmware/dcdbas.h b/drivers/firmware/dcdbas.h index dcdba0f1b32c..87bc3417de27 100644 --- a/drivers/firmware/dcdbas.h +++ b/drivers/firmware/dcdbas.h | |||
@@ -17,7 +17,6 @@ | |||
17 | #define _DCDBAS_H_ | 17 | #define _DCDBAS_H_ |
18 | 18 | ||
19 | #include <linux/device.h> | 19 | #include <linux/device.h> |
20 | #include <linux/input.h> | ||
21 | #include <linux/sysfs.h> | 20 | #include <linux/sysfs.h> |
22 | #include <linux/types.h> | 21 | #include <linux/types.h> |
23 | 22 | ||
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index a702e2f6da7d..1ca6f4635eeb 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -113,13 +113,13 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t | |||
113 | 113 | ||
114 | if (count > HID_MIN_BUFFER_SIZE) { | 114 | if (count > HID_MIN_BUFFER_SIZE) { |
115 | printk(KERN_WARNING "hidraw: pid %d passed too large report\n", | 115 | printk(KERN_WARNING "hidraw: pid %d passed too large report\n", |
116 | current->pid); | 116 | task_pid_nr(current)); |
117 | return -EINVAL; | 117 | return -EINVAL; |
118 | } | 118 | } |
119 | 119 | ||
120 | if (count < 2) { | 120 | if (count < 2) { |
121 | printk(KERN_WARNING "hidraw: pid %d passed too short report\n", | 121 | printk(KERN_WARNING "hidraw: pid %d passed too short report\n", |
122 | current->pid); | 122 | task_pid_nr(current)); |
123 | return -EINVAL; | 123 | return -EINVAL; |
124 | } | 124 | } |
125 | 125 | ||
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index b76b02f7b52d..775a1ef28a29 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c | |||
@@ -274,8 +274,11 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
274 | 274 | ||
275 | input_set_drvdata(input_dev, kbd); | 275 | input_set_drvdata(input_dev, kbd); |
276 | 276 | ||
277 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 277 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_LED) | |
278 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | 278 | BIT_MASK(EV_REP); |
279 | input_dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) | | ||
280 | BIT_MASK(LED_SCROLLL) | BIT_MASK(LED_COMPOSE) | | ||
281 | BIT_MASK(LED_KANA); | ||
279 | 282 | ||
280 | for (i = 0; i < 255; i++) | 283 | for (i = 0; i < 255; i++) |
281 | set_bit(usb_kbd_keycode[i], input_dev->keybit); | 284 | set_bit(usb_kbd_keycode[i], input_dev->keybit); |
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c index 5345c73bcf62..f8ad6910d3d9 100644 --- a/drivers/hid/usbhid/usbmouse.c +++ b/drivers/hid/usbhid/usbmouse.c | |||
@@ -173,11 +173,13 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i | |||
173 | usb_to_input_id(dev, &input_dev->id); | 173 | usb_to_input_id(dev, &input_dev->id); |
174 | input_dev->dev.parent = &intf->dev; | 174 | input_dev->dev.parent = &intf->dev; |
175 | 175 | ||
176 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 176 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
177 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 177 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
178 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 178 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); |
179 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 179 | input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
180 | input_dev->relbit[0] |= BIT(REL_WHEEL); | 180 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_SIDE) | |
181 | BIT_MASK(BTN_EXTRA); | ||
182 | input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); | ||
181 | 183 | ||
182 | input_set_drvdata(input_dev, mouse); | 184 | input_set_drvdata(input_dev, mouse); |
183 | 185 | ||
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 4879125b4cdc..1001d2e122a2 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c | |||
@@ -1099,7 +1099,7 @@ static int applesmc_create_accelerometer(void) | |||
1099 | idev->name = "applesmc"; | 1099 | idev->name = "applesmc"; |
1100 | idev->id.bustype = BUS_HOST; | 1100 | idev->id.bustype = BUS_HOST; |
1101 | idev->dev.parent = &pdev->dev; | 1101 | idev->dev.parent = &pdev->dev; |
1102 | idev->evbit[0] = BIT(EV_ABS); | 1102 | idev->evbit[0] = BIT_MASK(EV_ABS); |
1103 | input_set_abs_params(idev, ABS_X, | 1103 | input_set_abs_params(idev, ABS_X, |
1104 | -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); | 1104 | -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); |
1105 | input_set_abs_params(idev, ABS_Y, | 1105 | input_set_abs_params(idev, ABS_Y, |
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 6f66551d9e51..5c82ec7f8bbd 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
@@ -150,7 +150,7 @@ static struct coretemp_data *coretemp_update_device(struct device *dev) | |||
150 | static int __devinit coretemp_probe(struct platform_device *pdev) | 150 | static int __devinit coretemp_probe(struct platform_device *pdev) |
151 | { | 151 | { |
152 | struct coretemp_data *data; | 152 | struct coretemp_data *data; |
153 | struct cpuinfo_x86 *c = &(cpu_data)[pdev->id]; | 153 | struct cpuinfo_x86 *c = &cpu_data(pdev->id); |
154 | int err; | 154 | int err; |
155 | u32 eax, edx; | 155 | u32 eax, edx; |
156 | 156 | ||
@@ -359,7 +359,7 @@ static int __init coretemp_init(void) | |||
359 | struct pdev_entry *p, *n; | 359 | struct pdev_entry *p, *n; |
360 | 360 | ||
361 | /* quick check if we run Intel */ | 361 | /* quick check if we run Intel */ |
362 | if (cpu_data[0].x86_vendor != X86_VENDOR_INTEL) | 362 | if (cpu_data(0).x86_vendor != X86_VENDOR_INTEL) |
363 | goto exit; | 363 | goto exit; |
364 | 364 | ||
365 | err = platform_driver_register(&coretemp_driver); | 365 | err = platform_driver_register(&coretemp_driver); |
@@ -367,7 +367,7 @@ static int __init coretemp_init(void) | |||
367 | goto exit; | 367 | goto exit; |
368 | 368 | ||
369 | for_each_online_cpu(i) { | 369 | for_each_online_cpu(i) { |
370 | struct cpuinfo_x86 *c = &(cpu_data)[i]; | 370 | struct cpuinfo_x86 *c = &cpu_data(i); |
371 | 371 | ||
372 | /* check if family 6, models e, f, 16 */ | 372 | /* check if family 6, models e, f, 16 */ |
373 | if ((c->cpuid_level < 0) || (c->x86 != 0x6) || | 373 | if ((c->cpuid_level < 0) || (c->x86 != 0x6) || |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 8a7ae03aeee4..bab5fd2e4dfd 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -574,7 +574,7 @@ static int __init hdaps_init(void) | |||
574 | idev = hdaps_idev->input; | 574 | idev = hdaps_idev->input; |
575 | idev->name = "hdaps"; | 575 | idev->name = "hdaps"; |
576 | idev->dev.parent = &pdev->dev; | 576 | idev->dev.parent = &pdev->dev; |
577 | idev->evbit[0] = BIT(EV_ABS); | 577 | idev->evbit[0] = BIT_MASK(EV_ABS); |
578 | input_set_abs_params(idev, ABS_X, | 578 | input_set_abs_params(idev, ABS_X, |
579 | -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT); | 579 | -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT); |
580 | input_set_abs_params(idev, ABS_Y, | 580 | input_set_abs_params(idev, ABS_Y, |
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index f17e771e42f8..3330667280b9 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c | |||
@@ -200,7 +200,7 @@ static u8 find_vrm(u8 eff_family, u8 eff_model, u8 eff_stepping, u8 vendor) | |||
200 | 200 | ||
201 | u8 vid_which_vrm(void) | 201 | u8 vid_which_vrm(void) |
202 | { | 202 | { |
203 | struct cpuinfo_x86 *c = cpu_data; | 203 | struct cpuinfo_x86 *c = &cpu_data(0); |
204 | u32 eax; | 204 | u32 eax; |
205 | u8 eff_family, eff_model, eff_stepping, vrm_ret; | 205 | u8 eff_family, eff_model, eff_stepping, vrm_ret; |
206 | 206 | ||
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 00fad11733ad..6426a61f8d4d 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -85,7 +85,7 @@ struct bits { | |||
85 | const char *set; | 85 | const char *set; |
86 | const char *unset; | 86 | const char *unset; |
87 | }; | 87 | }; |
88 | #define BIT(m, s, u) { .mask = m, .set = s, .unset = u } | 88 | #define PXA_BIT(m, s, u) { .mask = m, .set = s, .unset = u } |
89 | 89 | ||
90 | static inline void | 90 | static inline void |
91 | decode_bits(const char *prefix, const struct bits *bits, int num, u32 val) | 91 | decode_bits(const char *prefix, const struct bits *bits, int num, u32 val) |
@@ -100,17 +100,17 @@ decode_bits(const char *prefix, const struct bits *bits, int num, u32 val) | |||
100 | } | 100 | } |
101 | 101 | ||
102 | static const struct bits isr_bits[] = { | 102 | static const struct bits isr_bits[] = { |
103 | BIT(ISR_RWM, "RX", "TX"), | 103 | PXA_BIT(ISR_RWM, "RX", "TX"), |
104 | BIT(ISR_ACKNAK, "NAK", "ACK"), | 104 | PXA_BIT(ISR_ACKNAK, "NAK", "ACK"), |
105 | BIT(ISR_UB, "Bsy", "Rdy"), | 105 | PXA_BIT(ISR_UB, "Bsy", "Rdy"), |
106 | BIT(ISR_IBB, "BusBsy", "BusRdy"), | 106 | PXA_BIT(ISR_IBB, "BusBsy", "BusRdy"), |
107 | BIT(ISR_SSD, "SlaveStop", NULL), | 107 | PXA_BIT(ISR_SSD, "SlaveStop", NULL), |
108 | BIT(ISR_ALD, "ALD", NULL), | 108 | PXA_BIT(ISR_ALD, "ALD", NULL), |
109 | BIT(ISR_ITE, "TxEmpty", NULL), | 109 | PXA_BIT(ISR_ITE, "TxEmpty", NULL), |
110 | BIT(ISR_IRF, "RxFull", NULL), | 110 | PXA_BIT(ISR_IRF, "RxFull", NULL), |
111 | BIT(ISR_GCAD, "GenCall", NULL), | 111 | PXA_BIT(ISR_GCAD, "GenCall", NULL), |
112 | BIT(ISR_SAD, "SlaveAddr", NULL), | 112 | PXA_BIT(ISR_SAD, "SlaveAddr", NULL), |
113 | BIT(ISR_BED, "BusErr", NULL), | 113 | PXA_BIT(ISR_BED, "BusErr", NULL), |
114 | }; | 114 | }; |
115 | 115 | ||
116 | static void decode_ISR(unsigned int val) | 116 | static void decode_ISR(unsigned int val) |
@@ -120,21 +120,21 @@ static void decode_ISR(unsigned int val) | |||
120 | } | 120 | } |
121 | 121 | ||
122 | static const struct bits icr_bits[] = { | 122 | static const struct bits icr_bits[] = { |
123 | BIT(ICR_START, "START", NULL), | 123 | PXA_BIT(ICR_START, "START", NULL), |
124 | BIT(ICR_STOP, "STOP", NULL), | 124 | PXA_BIT(ICR_STOP, "STOP", NULL), |
125 | BIT(ICR_ACKNAK, "ACKNAK", NULL), | 125 | PXA_BIT(ICR_ACKNAK, "ACKNAK", NULL), |
126 | BIT(ICR_TB, "TB", NULL), | 126 | PXA_BIT(ICR_TB, "TB", NULL), |
127 | BIT(ICR_MA, "MA", NULL), | 127 | PXA_BIT(ICR_MA, "MA", NULL), |
128 | BIT(ICR_SCLE, "SCLE", "scle"), | 128 | PXA_BIT(ICR_SCLE, "SCLE", "scle"), |
129 | BIT(ICR_IUE, "IUE", "iue"), | 129 | PXA_BIT(ICR_IUE, "IUE", "iue"), |
130 | BIT(ICR_GCD, "GCD", NULL), | 130 | PXA_BIT(ICR_GCD, "GCD", NULL), |
131 | BIT(ICR_ITEIE, "ITEIE", NULL), | 131 | PXA_BIT(ICR_ITEIE, "ITEIE", NULL), |
132 | BIT(ICR_IRFIE, "IRFIE", NULL), | 132 | PXA_BIT(ICR_IRFIE, "IRFIE", NULL), |
133 | BIT(ICR_BEIE, "BEIE", NULL), | 133 | PXA_BIT(ICR_BEIE, "BEIE", NULL), |
134 | BIT(ICR_SSDIE, "SSDIE", NULL), | 134 | PXA_BIT(ICR_SSDIE, "SSDIE", NULL), |
135 | BIT(ICR_ALDIE, "ALDIE", NULL), | 135 | PXA_BIT(ICR_ALDIE, "ALDIE", NULL), |
136 | BIT(ICR_SADIE, "SADIE", NULL), | 136 | PXA_BIT(ICR_SADIE, "SADIE", NULL), |
137 | BIT(ICR_UR, "UR", "ur"), | 137 | PXA_BIT(ICR_UR, "UR", "ur"), |
138 | }; | 138 | }; |
139 | 139 | ||
140 | static void decode_ICR(unsigned int val) | 140 | static void decode_ICR(unsigned int val) |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 6d9fd92763f4..6eaece96524e 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -1056,6 +1056,9 @@ endif | |||
1056 | config BLK_DEV_IDEDMA | 1056 | config BLK_DEV_IDEDMA |
1057 | def_bool BLK_DEV_IDEDMA_PCI || BLK_DEV_IDEDMA_PMAC || BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 1057 | def_bool BLK_DEV_IDEDMA_PCI || BLK_DEV_IDEDMA_PMAC || BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
1058 | 1058 | ||
1059 | config IDE_ARCH_OBSOLETE_INIT | ||
1060 | def_bool ALPHA || (ARM && !ARCH_L7200) || BLACKFIN || X86 || IA64 || M32R || MIPS || PARISC || PPC || (SUPERH64 && BLK_DEV_IDEPCI) || SPARC | ||
1061 | |||
1059 | endif | 1062 | endif |
1060 | 1063 | ||
1061 | config BLK_DEV_HD_ONLY | 1064 | config BLK_DEV_HD_ONLY |
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c index f7449d04114a..48db6167bb90 100644 --- a/drivers/ide/arm/bast-ide.c +++ b/drivers/ide/arm/bast-ide.c | |||
@@ -45,7 +45,7 @@ bastide_register(unsigned int base, unsigned int aux, int irq, | |||
45 | hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); | 45 | hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); |
46 | hw.irq = irq; | 46 | hw.irq = irq; |
47 | 47 | ||
48 | ide_register_hw(&hw, 0, hwif); | 48 | ide_register_hw(&hw, NULL, 0, hwif); |
49 | 49 | ||
50 | return 0; | 50 | return 0; |
51 | } | 51 | } |
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 3af33fbf1f88..410a0d13e35e 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -316,27 +316,29 @@ static int icside_dma_end(ide_drive_t *drive) | |||
316 | 316 | ||
317 | drive->waiting_for_dma = 0; | 317 | drive->waiting_for_dma = 0; |
318 | 318 | ||
319 | disable_dma(hwif->hw.dma); | 319 | disable_dma(state->dev->dma); |
320 | 320 | ||
321 | /* Teardown mappings after DMA has completed. */ | 321 | /* Teardown mappings after DMA has completed. */ |
322 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, | 322 | dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, |
323 | hwif->sg_dma_direction); | 323 | hwif->sg_dma_direction); |
324 | 324 | ||
325 | return get_dma_residue(hwif->hw.dma) != 0; | 325 | return get_dma_residue(state->dev->dma) != 0; |
326 | } | 326 | } |
327 | 327 | ||
328 | static void icside_dma_start(ide_drive_t *drive) | 328 | static void icside_dma_start(ide_drive_t *drive) |
329 | { | 329 | { |
330 | ide_hwif_t *hwif = HWIF(drive); | 330 | ide_hwif_t *hwif = HWIF(drive); |
331 | struct icside_state *state = hwif->hwif_data; | ||
331 | 332 | ||
332 | /* We can not enable DMA on both channels simultaneously. */ | 333 | /* We can not enable DMA on both channels simultaneously. */ |
333 | BUG_ON(dma_channel_active(hwif->hw.dma)); | 334 | BUG_ON(dma_channel_active(state->dev->dma)); |
334 | enable_dma(hwif->hw.dma); | 335 | enable_dma(state->dev->dma); |
335 | } | 336 | } |
336 | 337 | ||
337 | static int icside_dma_setup(ide_drive_t *drive) | 338 | static int icside_dma_setup(ide_drive_t *drive) |
338 | { | 339 | { |
339 | ide_hwif_t *hwif = HWIF(drive); | 340 | ide_hwif_t *hwif = HWIF(drive); |
341 | struct icside_state *state = hwif->hwif_data; | ||
340 | struct request *rq = hwif->hwgroup->rq; | 342 | struct request *rq = hwif->hwgroup->rq; |
341 | unsigned int dma_mode; | 343 | unsigned int dma_mode; |
342 | 344 | ||
@@ -348,7 +350,7 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
348 | /* | 350 | /* |
349 | * We can not enable DMA on both channels. | 351 | * We can not enable DMA on both channels. |
350 | */ | 352 | */ |
351 | BUG_ON(dma_channel_active(hwif->hw.dma)); | 353 | BUG_ON(dma_channel_active(state->dev->dma)); |
352 | 354 | ||
353 | icside_build_sglist(drive, rq); | 355 | icside_build_sglist(drive, rq); |
354 | 356 | ||
@@ -365,14 +367,14 @@ static int icside_dma_setup(ide_drive_t *drive) | |||
365 | /* | 367 | /* |
366 | * Select the correct timing for this drive. | 368 | * Select the correct timing for this drive. |
367 | */ | 369 | */ |
368 | set_dma_speed(hwif->hw.dma, drive->drive_data); | 370 | set_dma_speed(state->dev->dma, drive->drive_data); |
369 | 371 | ||
370 | /* | 372 | /* |
371 | * Tell the DMA engine about the SG table and | 373 | * Tell the DMA engine about the SG table and |
372 | * data direction. | 374 | * data direction. |
373 | */ | 375 | */ |
374 | set_dma_sg(hwif->hw.dma, hwif->sg_table, hwif->sg_nents); | 376 | set_dma_sg(state->dev->dma, hwif->sg_table, hwif->sg_nents); |
375 | set_dma_mode(hwif->hw.dma, dma_mode); | 377 | set_dma_mode(state->dev->dma, dma_mode); |
376 | 378 | ||
377 | drive->waiting_for_dma = 1; | 379 | drive->waiting_for_dma = 1; |
378 | 380 | ||
@@ -438,40 +440,16 @@ static void icside_dma_init(ide_hwif_t *hwif) | |||
438 | #define icside_dma_init(hwif) (0) | 440 | #define icside_dma_init(hwif) (0) |
439 | #endif | 441 | #endif |
440 | 442 | ||
441 | static ide_hwif_t *icside_find_hwif(unsigned long dataport) | ||
442 | { | ||
443 | ide_hwif_t *hwif; | ||
444 | int index; | ||
445 | |||
446 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
447 | hwif = &ide_hwifs[index]; | ||
448 | if (hwif->io_ports[IDE_DATA_OFFSET] == dataport) | ||
449 | goto found; | ||
450 | } | ||
451 | |||
452 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
453 | hwif = &ide_hwifs[index]; | ||
454 | if (!hwif->io_ports[IDE_DATA_OFFSET]) | ||
455 | goto found; | ||
456 | } | ||
457 | |||
458 | hwif = NULL; | ||
459 | found: | ||
460 | return hwif; | ||
461 | } | ||
462 | |||
463 | static ide_hwif_t * | 443 | static ide_hwif_t * |
464 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) | 444 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) |
465 | { | 445 | { |
466 | unsigned long port = (unsigned long)base + info->dataoffset; | 446 | unsigned long port = (unsigned long)base + info->dataoffset; |
467 | ide_hwif_t *hwif; | 447 | ide_hwif_t *hwif; |
468 | 448 | ||
469 | hwif = icside_find_hwif(port); | 449 | hwif = ide_find_port(port); |
470 | if (hwif) { | 450 | if (hwif) { |
471 | int i; | 451 | int i; |
472 | 452 | ||
473 | memset(&hwif->hw, 0, sizeof(hw_regs_t)); | ||
474 | |||
475 | /* | 453 | /* |
476 | * Ensure we're using MMIO | 454 | * Ensure we're using MMIO |
477 | */ | 455 | */ |
@@ -479,13 +457,10 @@ icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *e | |||
479 | hwif->mmio = 1; | 457 | hwif->mmio = 1; |
480 | 458 | ||
481 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | 459 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { |
482 | hwif->hw.io_ports[i] = port; | ||
483 | hwif->io_ports[i] = port; | 460 | hwif->io_ports[i] = port; |
484 | port += 1 << info->stepping; | 461 | port += 1 << info->stepping; |
485 | } | 462 | } |
486 | hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; | ||
487 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; | 463 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; |
488 | hwif->hw.irq = ec->irq; | ||
489 | hwif->irq = ec->irq; | 464 | hwif->irq = ec->irq; |
490 | hwif->noprobe = 0; | 465 | hwif->noprobe = 0; |
491 | hwif->chipset = ide_acorn; | 466 | hwif->chipset = ide_acorn; |
@@ -500,6 +475,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
500 | { | 475 | { |
501 | ide_hwif_t *hwif; | 476 | ide_hwif_t *hwif; |
502 | void __iomem *base; | 477 | void __iomem *base; |
478 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
503 | 479 | ||
504 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); | 480 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
505 | if (!base) | 481 | if (!base) |
@@ -523,9 +499,9 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
523 | 499 | ||
524 | state->hwif[0] = hwif; | 500 | state->hwif[0] = hwif; |
525 | 501 | ||
526 | probe_hwif_init(hwif); | 502 | idx[0] = hwif->index; |
527 | 503 | ||
528 | ide_proc_register_port(hwif); | 504 | ide_device_add(idx); |
529 | 505 | ||
530 | return 0; | 506 | return 0; |
531 | } | 507 | } |
@@ -537,6 +513,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
537 | void __iomem *ioc_base, *easi_base; | 513 | void __iomem *ioc_base, *easi_base; |
538 | unsigned int sel = 0; | 514 | unsigned int sel = 0; |
539 | int ret; | 515 | int ret; |
516 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
540 | 517 | ||
541 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); | 518 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
542 | if (!ioc_base) { | 519 | if (!ioc_base) { |
@@ -592,7 +569,6 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
592 | hwif->serialized = 1; | 569 | hwif->serialized = 1; |
593 | hwif->config_data = (unsigned long)ioc_base; | 570 | hwif->config_data = (unsigned long)ioc_base; |
594 | hwif->select_data = sel; | 571 | hwif->select_data = sel; |
595 | hwif->hw.dma = ec->dma; | ||
596 | 572 | ||
597 | mate->maskproc = icside_maskproc; | 573 | mate->maskproc = icside_maskproc; |
598 | mate->channel = 1; | 574 | mate->channel = 1; |
@@ -601,18 +577,16 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
601 | mate->serialized = 1; | 577 | mate->serialized = 1; |
602 | mate->config_data = (unsigned long)ioc_base; | 578 | mate->config_data = (unsigned long)ioc_base; |
603 | mate->select_data = sel | 1; | 579 | mate->select_data = sel | 1; |
604 | mate->hw.dma = ec->dma; | ||
605 | 580 | ||
606 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { | 581 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { |
607 | icside_dma_init(hwif); | 582 | icside_dma_init(hwif); |
608 | icside_dma_init(mate); | 583 | icside_dma_init(mate); |
609 | } | 584 | } |
610 | 585 | ||
611 | probe_hwif_init(hwif); | 586 | idx[0] = hwif->index; |
612 | probe_hwif_init(mate); | 587 | idx[1] = mate->index; |
613 | 588 | ||
614 | ide_proc_register_port(hwif); | 589 | ide_device_add(idx); |
615 | ide_proc_register_port(mate); | ||
616 | 590 | ||
617 | return 0; | 591 | return 0; |
618 | 592 | ||
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c index bce2bec81413..8957cbadf5c2 100644 --- a/drivers/ide/arm/ide_arm.c +++ b/drivers/ide/arm/ide_arm.c | |||
@@ -31,5 +31,5 @@ void __init ide_arm_init(void) | |||
31 | memset(&hw, 0, sizeof(hw)); | 31 | memset(&hw, 0, sizeof(hw)); |
32 | ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); | 32 | ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); |
33 | hw.irq = IDE_ARM_IRQ; | 33 | hw.irq = IDE_ARM_IRQ; |
34 | ide_register_hw(&hw, 1, NULL); | 34 | ide_register_hw(&hw, NULL, 1, NULL); |
35 | } | 35 | } |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index 83811af11610..0775a3afef48 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -13,42 +13,25 @@ | |||
13 | 13 | ||
14 | #include <asm/ecard.h> | 14 | #include <asm/ecard.h> |
15 | 15 | ||
16 | /* | ||
17 | * Something like this really should be in generic code, but isn't. | ||
18 | */ | ||
19 | static ide_hwif_t * | 16 | static ide_hwif_t * |
20 | rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq) | 17 | rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq) |
21 | { | 18 | { |
22 | unsigned long port = (unsigned long)base; | 19 | unsigned long port = (unsigned long)base; |
23 | ide_hwif_t *hwif; | 20 | ide_hwif_t *hwif = ide_find_port(port); |
24 | int index, i; | 21 | int i; |
25 | |||
26 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
27 | hwif = ide_hwifs + index; | ||
28 | if (hwif->io_ports[IDE_DATA_OFFSET] == port) | ||
29 | goto found; | ||
30 | } | ||
31 | |||
32 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
33 | hwif = ide_hwifs + index; | ||
34 | if (hwif->io_ports[IDE_DATA_OFFSET] == 0) | ||
35 | goto found; | ||
36 | } | ||
37 | 22 | ||
38 | return NULL; | 23 | if (hwif == NULL) |
24 | goto out; | ||
39 | 25 | ||
40 | found: | ||
41 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | 26 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { |
42 | hwif->hw.io_ports[i] = port; | ||
43 | hwif->io_ports[i] = port; | 27 | hwif->io_ports[i] = port; |
44 | port += sz; | 28 | port += sz; |
45 | } | 29 | } |
46 | hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; | ||
47 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; | 30 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; |
48 | hwif->hw.irq = hwif->irq = irq; | 31 | hwif->irq = irq; |
49 | hwif->mmio = 1; | 32 | hwif->mmio = 1; |
50 | default_hwif_mmiops(hwif); | 33 | default_hwif_mmiops(hwif); |
51 | 34 | out: | |
52 | return hwif; | 35 | return hwif; |
53 | } | 36 | } |
54 | 37 | ||
@@ -58,6 +41,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
58 | ide_hwif_t *hwif; | 41 | ide_hwif_t *hwif; |
59 | void __iomem *base; | 42 | void __iomem *base; |
60 | int ret; | 43 | int ret; |
44 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
61 | 45 | ||
62 | ret = ecard_request_resources(ec); | 46 | ret = ecard_request_resources(ec); |
63 | if (ret) | 47 | if (ret) |
@@ -74,8 +58,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
74 | hwif->hwif_data = base; | 58 | hwif->hwif_data = base; |
75 | hwif->gendev.parent = &ec->dev; | 59 | hwif->gendev.parent = &ec->dev; |
76 | hwif->noprobe = 0; | 60 | hwif->noprobe = 0; |
77 | probe_hwif_init(hwif); | 61 | |
78 | ide_proc_register_port(hwif); | 62 | idx[0] = hwif->index; |
63 | |||
64 | ide_device_add(idx); | ||
65 | |||
79 | ecard_set_drvdata(ec, hwif); | 66 | ecard_set_drvdata(ec, hwif); |
80 | goto out; | 67 | goto out; |
81 | } | 68 | } |
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index 9a96a10ba9d3..ff20377b4c82 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c | |||
@@ -782,7 +782,7 @@ init_e100_ide (void) | |||
782 | ide_offsets, | 782 | ide_offsets, |
783 | 0, 0, cris_ide_ack_intr, | 783 | 0, 0, cris_ide_ack_intr, |
784 | ide_default_irq(0)); | 784 | ide_default_irq(0)); |
785 | ide_register_hw(&hw, 1, &hwif); | 785 | ide_register_hw(&hw, NULL, 1, &hwif); |
786 | hwif->mmio = 1; | 786 | hwif->mmio = 1; |
787 | hwif->chipset = ide_etrax100; | 787 | hwif->chipset = ide_etrax100; |
788 | hwif->set_pio_mode = &cris_set_pio_mode; | 788 | hwif->set_pio_mode = &cris_set_pio_mode; |
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c index 6d26ad7360d5..4a49b5c59acb 100644 --- a/drivers/ide/h8300/ide-h8300.c +++ b/drivers/ide/h8300/ide-h8300.c | |||
@@ -68,7 +68,6 @@ static inline void hw_setup(hw_regs_t *hw) | |||
68 | hw->io_ports[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i; | 68 | hw->io_ports[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i; |
69 | hw->io_ports[IDE_CONTROL_OFFSET] = CONFIG_H8300_IDE_ALT; | 69 | hw->io_ports[IDE_CONTROL_OFFSET] = CONFIG_H8300_IDE_ALT; |
70 | hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ; | 70 | hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ; |
71 | hw->dma = NO_DMA; | ||
72 | hw->chipset = ide_generic; | 71 | hw->chipset = ide_generic; |
73 | } | 72 | } |
74 | 73 | ||
@@ -101,7 +100,7 @@ void __init h8300_ide_init(void) | |||
101 | hw_setup(&hw); | 100 | hw_setup(&hw); |
102 | 101 | ||
103 | /* register if */ | 102 | /* register if */ |
104 | idx = ide_register_hw(&hw, 1, &hwif); | 103 | idx = ide_register_hw(&hw, NULL, 1, &hwif); |
105 | if (idx == -1) { | 104 | if (idx == -1) { |
106 | printk(KERN_ERR "ide-h8300: IDE I/F register failed\n"); | 105 | printk(KERN_ERR "ide-h8300: IDE I/F register failed\n"); |
107 | return; | 106 | return; |
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 1d5f6823101c..89df48fdc69d 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -350,7 +350,7 @@ static int taskfile_load_raw(ide_drive_t *drive, | |||
350 | 350 | ||
351 | memset(&args, 0, sizeof(ide_task_t)); | 351 | memset(&args, 0, sizeof(ide_task_t)); |
352 | args.command_type = IDE_DRIVE_TASK_NO_DATA; | 352 | args.command_type = IDE_DRIVE_TASK_NO_DATA; |
353 | args.data_phase = TASKFILE_IN; | 353 | args.data_phase = TASKFILE_NO_DATA; |
354 | args.handler = &task_no_data_intr; | 354 | args.handler = &task_no_data_intr; |
355 | 355 | ||
356 | /* convert gtf to IDE Taskfile */ | 356 | /* convert gtf to IDE Taskfile */ |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 2722d9165b6b..00123d99527a 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -593,28 +593,12 @@ static int smart_enable(ide_drive_t *drive) | |||
593 | return ide_raw_taskfile(drive, &args, NULL); | 593 | return ide_raw_taskfile(drive, &args, NULL); |
594 | } | 594 | } |
595 | 595 | ||
596 | static int get_smart_values(ide_drive_t *drive, u8 *buf) | 596 | static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) |
597 | { | 597 | { |
598 | ide_task_t args; | 598 | ide_task_t args; |
599 | 599 | ||
600 | memset(&args, 0, sizeof(ide_task_t)); | 600 | memset(&args, 0, sizeof(ide_task_t)); |
601 | args.tfRegister[IDE_FEATURE_OFFSET] = SMART_READ_VALUES; | 601 | args.tfRegister[IDE_FEATURE_OFFSET] = sub_cmd; |
602 | args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01; | ||
603 | args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS; | ||
604 | args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; | ||
605 | args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SMART; | ||
606 | args.command_type = IDE_DRIVE_TASK_IN; | ||
607 | args.data_phase = TASKFILE_IN; | ||
608 | args.handler = &task_in_intr; | ||
609 | (void) smart_enable(drive); | ||
610 | return ide_raw_taskfile(drive, &args, buf); | ||
611 | } | ||
612 | |||
613 | static int get_smart_thresholds(ide_drive_t *drive, u8 *buf) | ||
614 | { | ||
615 | ide_task_t args; | ||
616 | memset(&args, 0, sizeof(ide_task_t)); | ||
617 | args.tfRegister[IDE_FEATURE_OFFSET] = SMART_READ_THRESHOLDS; | ||
618 | args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01; | 602 | args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01; |
619 | args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS; | 603 | args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS; |
620 | args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; | 604 | args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; |
@@ -656,7 +640,7 @@ static int proc_idedisk_read_smart_thresholds | |||
656 | ide_drive_t *drive = (ide_drive_t *)data; | 640 | ide_drive_t *drive = (ide_drive_t *)data; |
657 | int len = 0, i = 0; | 641 | int len = 0, i = 0; |
658 | 642 | ||
659 | if (!get_smart_thresholds(drive, page)) { | 643 | if (get_smart_data(drive, page, SMART_READ_THRESHOLDS) == 0) { |
660 | unsigned short *val = (unsigned short *) page; | 644 | unsigned short *val = (unsigned short *) page; |
661 | char *out = ((char *)val) + (SECTOR_WORDS * 4); | 645 | char *out = ((char *)val) + (SECTOR_WORDS * 4); |
662 | page = out; | 646 | page = out; |
@@ -675,7 +659,7 @@ static int proc_idedisk_read_smart_values | |||
675 | ide_drive_t *drive = (ide_drive_t *)data; | 659 | ide_drive_t *drive = (ide_drive_t *)data; |
676 | int len = 0, i = 0; | 660 | int len = 0, i = 0; |
677 | 661 | ||
678 | if (!get_smart_values(drive, page)) { | 662 | if (get_smart_data(drive, page, SMART_READ_VALUES) == 0) { |
679 | unsigned short *val = (unsigned short *) page; | 663 | unsigned short *val = (unsigned short *) page; |
680 | char *out = ((char *)val) + (SECTOR_WORDS * 4); | 664 | char *out = ((char *)val) + (SECTOR_WORDS * 4); |
681 | page = out; | 665 | page = out; |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 80b4f17f3941..428f7a8a00b6 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -901,10 +901,7 @@ void ide_dma_timeout (ide_drive_t *drive) | |||
901 | 901 | ||
902 | EXPORT_SYMBOL(ide_dma_timeout); | 902 | EXPORT_SYMBOL(ide_dma_timeout); |
903 | 903 | ||
904 | /* | 904 | static void ide_release_dma_engine(ide_hwif_t *hwif) |
905 | * Needed for allowing full modular support of ide-driver | ||
906 | */ | ||
907 | static int ide_release_dma_engine(ide_hwif_t *hwif) | ||
908 | { | 905 | { |
909 | if (hwif->dmatable_cpu) { | 906 | if (hwif->dmatable_cpu) { |
910 | pci_free_consistent(hwif->pci_dev, | 907 | pci_free_consistent(hwif->pci_dev, |
@@ -913,7 +910,6 @@ static int ide_release_dma_engine(ide_hwif_t *hwif) | |||
913 | hwif->dmatable_dma); | 910 | hwif->dmatable_dma); |
914 | hwif->dmatable_cpu = NULL; | 911 | hwif->dmatable_cpu = NULL; |
915 | } | 912 | } |
916 | return 1; | ||
917 | } | 913 | } |
918 | 914 | ||
919 | static int ide_release_iomio_dma(ide_hwif_t *hwif) | 915 | static int ide_release_iomio_dma(ide_hwif_t *hwif) |
@@ -956,12 +952,6 @@ static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base, unsigned in | |||
956 | { | 952 | { |
957 | printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); | 953 | printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); |
958 | 954 | ||
959 | hwif->dma_base = base; | ||
960 | |||
961 | if(hwif->mate) | ||
962 | hwif->dma_master = (hwif->channel) ? hwif->mate->dma_base : base; | ||
963 | else | ||
964 | hwif->dma_master = base; | ||
965 | return 0; | 955 | return 0; |
966 | } | 956 | } |
967 | 957 | ||
@@ -975,8 +965,6 @@ static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int port | |||
975 | return 1; | 965 | return 1; |
976 | } | 966 | } |
977 | 967 | ||
978 | hwif->dma_base = base; | ||
979 | |||
980 | if (hwif->cds->extra) { | 968 | if (hwif->cds->extra) { |
981 | hwif->extra_base = base + (hwif->channel ? 8 : 16); | 969 | hwif->extra_base = base + (hwif->channel ? 8 : 16); |
982 | 970 | ||
@@ -991,10 +979,6 @@ static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int port | |||
991 | } | 979 | } |
992 | } | 980 | } |
993 | 981 | ||
994 | if(hwif->mate) | ||
995 | hwif->dma_master = (hwif->channel) ? hwif->mate->dma_base:base; | ||
996 | else | ||
997 | hwif->dma_master = base; | ||
998 | return 0; | 982 | return 0; |
999 | } | 983 | } |
1000 | 984 | ||
@@ -1006,12 +990,9 @@ static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base, unsigned int por | |||
1006 | return ide_iomio_dma(hwif, base, ports); | 990 | return ide_iomio_dma(hwif, base, ports); |
1007 | } | 991 | } |
1008 | 992 | ||
1009 | /* | 993 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) |
1010 | * This can be called for a dynamically installed interface. Don't __init it | ||
1011 | */ | ||
1012 | void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_ports) | ||
1013 | { | 994 | { |
1014 | if (ide_dma_iobase(hwif, dma_base, num_ports)) | 995 | if (ide_dma_iobase(hwif, base, num_ports)) |
1015 | return; | 996 | return; |
1016 | 997 | ||
1017 | if (ide_allocate_dma_engine(hwif)) { | 998 | if (ide_allocate_dma_engine(hwif)) { |
@@ -1019,6 +1000,13 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p | |||
1019 | return; | 1000 | return; |
1020 | } | 1001 | } |
1021 | 1002 | ||
1003 | hwif->dma_base = base; | ||
1004 | |||
1005 | if (hwif->mate) | ||
1006 | hwif->dma_master = hwif->channel ? hwif->mate->dma_base : base; | ||
1007 | else | ||
1008 | hwif->dma_master = base; | ||
1009 | |||
1022 | if (!(hwif->dma_command)) | 1010 | if (!(hwif->dma_command)) |
1023 | hwif->dma_command = hwif->dma_base; | 1011 | hwif->dma_command = hwif->dma_base; |
1024 | if (!(hwif->dma_vendor1)) | 1012 | if (!(hwif->dma_vendor1)) |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 5c8b008676fb..c89f0d3058e9 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -47,15 +47,15 @@ | |||
47 | #include <linux/device.h> | 47 | #include <linux/device.h> |
48 | #include <linux/kmod.h> | 48 | #include <linux/kmod.h> |
49 | #include <linux/scatterlist.h> | 49 | #include <linux/scatterlist.h> |
50 | #include <linux/bitops.h> | ||
50 | 51 | ||
51 | #include <asm/byteorder.h> | 52 | #include <asm/byteorder.h> |
52 | #include <asm/irq.h> | 53 | #include <asm/irq.h> |
53 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
54 | #include <asm/io.h> | 55 | #include <asm/io.h> |
55 | #include <asm/bitops.h> | ||
56 | 56 | ||
57 | static int __ide_end_request(ide_drive_t *drive, struct request *rq, | 57 | static int __ide_end_request(ide_drive_t *drive, struct request *rq, |
58 | int uptodate, unsigned int nr_bytes) | 58 | int uptodate, unsigned int nr_bytes, int dequeue) |
59 | { | 59 | { |
60 | int ret = 1; | 60 | int ret = 1; |
61 | 61 | ||
@@ -80,9 +80,11 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq, | |||
80 | 80 | ||
81 | if (!end_that_request_chunk(rq, uptodate, nr_bytes)) { | 81 | if (!end_that_request_chunk(rq, uptodate, nr_bytes)) { |
82 | add_disk_randomness(rq->rq_disk); | 82 | add_disk_randomness(rq->rq_disk); |
83 | if (!list_empty(&rq->queuelist)) | 83 | if (dequeue) { |
84 | blkdev_dequeue_request(rq); | 84 | if (!list_empty(&rq->queuelist)) |
85 | HWGROUP(drive)->rq = NULL; | 85 | blkdev_dequeue_request(rq); |
86 | HWGROUP(drive)->rq = NULL; | ||
87 | } | ||
86 | end_that_request_last(rq, uptodate); | 88 | end_that_request_last(rq, uptodate); |
87 | ret = 0; | 89 | ret = 0; |
88 | } | 90 | } |
@@ -122,7 +124,7 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors) | |||
122 | nr_bytes = rq->hard_cur_sectors << 9; | 124 | nr_bytes = rq->hard_cur_sectors << 9; |
123 | } | 125 | } |
124 | 126 | ||
125 | ret = __ide_end_request(drive, rq, uptodate, nr_bytes); | 127 | ret = __ide_end_request(drive, rq, uptodate, nr_bytes, 1); |
126 | 128 | ||
127 | spin_unlock_irqrestore(&ide_lock, flags); | 129 | spin_unlock_irqrestore(&ide_lock, flags); |
128 | return ret; | 130 | return ret; |
@@ -255,39 +257,13 @@ int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, | |||
255 | int uptodate, int nr_sectors) | 257 | int uptodate, int nr_sectors) |
256 | { | 258 | { |
257 | unsigned long flags; | 259 | unsigned long flags; |
258 | int ret = 1; | 260 | int ret; |
259 | 261 | ||
260 | spin_lock_irqsave(&ide_lock, flags); | 262 | spin_lock_irqsave(&ide_lock, flags); |
261 | |||
262 | BUG_ON(!blk_rq_started(rq)); | 263 | BUG_ON(!blk_rq_started(rq)); |
263 | 264 | ret = __ide_end_request(drive, rq, uptodate, nr_sectors << 9, 0); | |
264 | /* | ||
265 | * if failfast is set on a request, override number of sectors and | ||
266 | * complete the whole request right now | ||
267 | */ | ||
268 | if (blk_noretry_request(rq) && end_io_error(uptodate)) | ||
269 | nr_sectors = rq->hard_nr_sectors; | ||
270 | |||
271 | if (!blk_fs_request(rq) && end_io_error(uptodate) && !rq->errors) | ||
272 | rq->errors = -EIO; | ||
273 | |||
274 | /* | ||
275 | * decide whether to reenable DMA -- 3 is a random magic for now, | ||
276 | * if we DMA timeout more than 3 times, just stay in PIO | ||
277 | */ | ||
278 | if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) { | ||
279 | drive->state = 0; | ||
280 | HWGROUP(drive)->hwif->ide_dma_on(drive); | ||
281 | } | ||
282 | |||
283 | if (!end_that_request_first(rq, uptodate, nr_sectors)) { | ||
284 | add_disk_randomness(rq->rq_disk); | ||
285 | if (blk_rq_tagged(rq)) | ||
286 | blk_queue_end_tag(drive->queue, rq); | ||
287 | end_that_request_last(rq, uptodate); | ||
288 | ret = 0; | ||
289 | } | ||
290 | spin_unlock_irqrestore(&ide_lock, flags); | 265 | spin_unlock_irqrestore(&ide_lock, flags); |
266 | |||
291 | return ret; | 267 | return ret; |
292 | } | 268 | } |
293 | EXPORT_SYMBOL_GPL(ide_end_dequeued_request); | 269 | EXPORT_SYMBOL_GPL(ide_end_dequeued_request); |
@@ -800,7 +776,20 @@ static ide_startstop_t do_special (ide_drive_t *drive) | |||
800 | s->b.set_tune = 0; | 776 | s->b.set_tune = 0; |
801 | 777 | ||
802 | if (set_pio_mode_abuse(drive->hwif, req_pio)) { | 778 | if (set_pio_mode_abuse(drive->hwif, req_pio)) { |
803 | if (hwif->set_pio_mode) | 779 | |
780 | if (hwif->set_pio_mode == NULL) | ||
781 | return ide_stopped; | ||
782 | |||
783 | /* | ||
784 | * take ide_lock for drive->[no_]unmask/[no_]io_32bit | ||
785 | */ | ||
786 | if (req_pio == 8 || req_pio == 9) { | ||
787 | unsigned long flags; | ||
788 | |||
789 | spin_lock_irqsave(&ide_lock, flags); | ||
790 | hwif->set_pio_mode(drive, req_pio); | ||
791 | spin_unlock_irqrestore(&ide_lock, flags); | ||
792 | } else | ||
804 | hwif->set_pio_mode(drive, req_pio); | 793 | hwif->set_pio_mode(drive, req_pio); |
805 | } else { | 794 | } else { |
806 | int keep_dma = drive->using_dma; | 795 | int keep_dma = drive->using_dma; |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index d4d790f91f91..95168833d069 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -693,35 +693,16 @@ static u8 ide_auto_reduce_xfer (ide_drive_t *drive) | |||
693 | } | 693 | } |
694 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | 694 | #endif /* CONFIG_BLK_DEV_IDEDMA */ |
695 | 695 | ||
696 | /* | 696 | int ide_driveid_update(ide_drive_t *drive) |
697 | * Update the | ||
698 | */ | ||
699 | int ide_driveid_update (ide_drive_t *drive) | ||
700 | { | 697 | { |
701 | ide_hwif_t *hwif = HWIF(drive); | 698 | ide_hwif_t *hwif = drive->hwif; |
702 | struct hd_driveid *id; | 699 | struct hd_driveid *id; |
703 | #if 0 | 700 | unsigned long timeout, flags; |
704 | id = kmalloc(SECTOR_WORDS*4, GFP_ATOMIC); | ||
705 | if (!id) | ||
706 | return 0; | ||
707 | |||
708 | taskfile_lib_get_identify(drive, (char *)&id); | ||
709 | 701 | ||
710 | ide_fix_driveid(id); | ||
711 | if (id) { | ||
712 | drive->id->dma_ultra = id->dma_ultra; | ||
713 | drive->id->dma_mword = id->dma_mword; | ||
714 | drive->id->dma_1word = id->dma_1word; | ||
715 | /* anything more ? */ | ||
716 | kfree(id); | ||
717 | } | ||
718 | return 1; | ||
719 | #else | ||
720 | /* | 702 | /* |
721 | * Re-read drive->id for possible DMA mode | 703 | * Re-read drive->id for possible DMA mode |
722 | * change (copied from ide-probe.c) | 704 | * change (copied from ide-probe.c) |
723 | */ | 705 | */ |
724 | unsigned long timeout, flags; | ||
725 | 706 | ||
726 | SELECT_MASK(drive, 1); | 707 | SELECT_MASK(drive, 1); |
727 | if (IDE_CONTROL_REG) | 708 | if (IDE_CONTROL_REG) |
@@ -763,7 +744,6 @@ int ide_driveid_update (ide_drive_t *drive) | |||
763 | } | 744 | } |
764 | 745 | ||
765 | return 1; | 746 | return 1; |
766 | #endif | ||
767 | } | 747 | } |
768 | 748 | ||
769 | int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | 749 | int ide_config_drive_speed(ide_drive_t *drive, u8 speed) |
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c index 2b8009c50e91..e245521af7b5 100644 --- a/drivers/ide/ide-pnp.c +++ b/drivers/ide/ide-pnp.c | |||
@@ -40,9 +40,8 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id | |||
40 | ide_std_init_ports(&hw, pnp_port_start(dev, 0), | 40 | ide_std_init_ports(&hw, pnp_port_start(dev, 0), |
41 | pnp_port_start(dev, 1)); | 41 | pnp_port_start(dev, 1)); |
42 | hw.irq = pnp_irq(dev, 0); | 42 | hw.irq = pnp_irq(dev, 0); |
43 | hw.dma = NO_DMA; | ||
44 | 43 | ||
45 | index = ide_register_hw(&hw, 1, &hwif); | 44 | index = ide_register_hw(&hw, NULL, 1, &hwif); |
46 | 45 | ||
47 | if (index != -1) { | 46 | if (index != -1) { |
48 | printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); | 47 | printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index e294c7415c27..d5146c57e5b3 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -717,7 +717,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave); | |||
717 | * This routine only knows how to look for drive units 0 and 1 | 717 | * This routine only knows how to look for drive units 0 and 1 |
718 | * on an interface, so any setting of MAX_DRIVES > 2 won't work here. | 718 | * on an interface, so any setting of MAX_DRIVES > 2 won't work here. |
719 | */ | 719 | */ |
720 | static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) | 720 | static void probe_hwif(ide_hwif_t *hwif) |
721 | { | 721 | { |
722 | unsigned long flags; | 722 | unsigned long flags; |
723 | unsigned int irqd; | 723 | unsigned int irqd; |
@@ -819,8 +819,8 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) | |||
819 | return; | 819 | return; |
820 | } | 820 | } |
821 | 821 | ||
822 | if (fixup) | 822 | if (hwif->fixup) |
823 | fixup(hwif); | 823 | hwif->fixup(hwif); |
824 | 824 | ||
825 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 825 | for (unit = 0; unit < MAX_DRIVES; ++unit) { |
826 | ide_drive_t *drive = &hwif->drives[unit]; | 826 | ide_drive_t *drive = &hwif->drives[unit]; |
@@ -859,10 +859,11 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) | |||
859 | } | 859 | } |
860 | 860 | ||
861 | static int hwif_init(ide_hwif_t *hwif); | 861 | static int hwif_init(ide_hwif_t *hwif); |
862 | static void hwif_register_devices(ide_hwif_t *hwif); | ||
862 | 863 | ||
863 | int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) | 864 | static int probe_hwif_init(ide_hwif_t *hwif) |
864 | { | 865 | { |
865 | probe_hwif(hwif, fixup); | 866 | probe_hwif(hwif); |
866 | 867 | ||
867 | if (!hwif_init(hwif)) { | 868 | if (!hwif_init(hwif)) { |
868 | printk(KERN_INFO "%s: failed to initialize IDE interface\n", | 869 | printk(KERN_INFO "%s: failed to initialize IDE interface\n", |
@@ -870,34 +871,12 @@ int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif) | |||
870 | return -1; | 871 | return -1; |
871 | } | 872 | } |
872 | 873 | ||
873 | if (hwif->present) { | 874 | if (hwif->present) |
874 | u16 unit = 0; | 875 | hwif_register_devices(hwif); |
875 | int ret; | ||
876 | 876 | ||
877 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | ||
878 | ide_drive_t *drive = &hwif->drives[unit]; | ||
879 | /* For now don't attach absent drives, we may | ||
880 | want them on default or a new "empty" class | ||
881 | for hotplug reprobing ? */ | ||
882 | if (drive->present) { | ||
883 | ret = device_register(&drive->gendev); | ||
884 | if (ret < 0) | ||
885 | printk(KERN_WARNING "IDE: %s: " | ||
886 | "device_register error: %d\n", | ||
887 | __FUNCTION__, ret); | ||
888 | } | ||
889 | } | ||
890 | } | ||
891 | return 0; | 877 | return 0; |
892 | } | 878 | } |
893 | 879 | ||
894 | int probe_hwif_init(ide_hwif_t *hwif) | ||
895 | { | ||
896 | return probe_hwif_init_with_fixup(hwif, NULL); | ||
897 | } | ||
898 | |||
899 | EXPORT_SYMBOL(probe_hwif_init); | ||
900 | |||
901 | #if MAX_HWIFS > 1 | 880 | #if MAX_HWIFS > 1 |
902 | /* | 881 | /* |
903 | * save_match() is used to simplify logic in init_irq() below. | 882 | * save_match() is used to simplify logic in init_irq() below. |
@@ -1379,6 +1358,24 @@ out: | |||
1379 | return 0; | 1358 | return 0; |
1380 | } | 1359 | } |
1381 | 1360 | ||
1361 | static void hwif_register_devices(ide_hwif_t *hwif) | ||
1362 | { | ||
1363 | unsigned int i; | ||
1364 | |||
1365 | for (i = 0; i < MAX_DRIVES; i++) { | ||
1366 | ide_drive_t *drive = &hwif->drives[i]; | ||
1367 | |||
1368 | if (drive->present) { | ||
1369 | int ret = device_register(&drive->gendev); | ||
1370 | |||
1371 | if (ret < 0) | ||
1372 | printk(KERN_WARNING "IDE: %s: " | ||
1373 | "device_register error: %d\n", | ||
1374 | __FUNCTION__, ret); | ||
1375 | } | ||
1376 | } | ||
1377 | } | ||
1378 | |||
1382 | int ideprobe_init (void) | 1379 | int ideprobe_init (void) |
1383 | { | 1380 | { |
1384 | unsigned int index; | 1381 | unsigned int index; |
@@ -1390,27 +1387,18 @@ int ideprobe_init (void) | |||
1390 | 1387 | ||
1391 | for (index = 0; index < MAX_HWIFS; ++index) | 1388 | for (index = 0; index < MAX_HWIFS; ++index) |
1392 | if (probe[index]) | 1389 | if (probe[index]) |
1393 | probe_hwif(&ide_hwifs[index], NULL); | 1390 | probe_hwif(&ide_hwifs[index]); |
1394 | for (index = 0; index < MAX_HWIFS; ++index) | 1391 | for (index = 0; index < MAX_HWIFS; ++index) |
1395 | if (probe[index]) | 1392 | if (probe[index]) |
1396 | hwif_init(&ide_hwifs[index]); | 1393 | hwif_init(&ide_hwifs[index]); |
1397 | for (index = 0; index < MAX_HWIFS; ++index) { | 1394 | for (index = 0; index < MAX_HWIFS; ++index) { |
1398 | if (probe[index]) { | 1395 | if (probe[index]) { |
1399 | ide_hwif_t *hwif = &ide_hwifs[index]; | 1396 | ide_hwif_t *hwif = &ide_hwifs[index]; |
1400 | int unit; | ||
1401 | if (!hwif->present) | 1397 | if (!hwif->present) |
1402 | continue; | 1398 | continue; |
1403 | if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced) | 1399 | if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced) |
1404 | hwif->chipset = ide_generic; | 1400 | hwif->chipset = ide_generic; |
1405 | for (unit = 0; unit < MAX_DRIVES; ++unit) | 1401 | hwif_register_devices(hwif); |
1406 | if (hwif->drives[unit].present) { | ||
1407 | int ret = device_register( | ||
1408 | &hwif->drives[unit].gendev); | ||
1409 | if (ret < 0) | ||
1410 | printk(KERN_WARNING "IDE: %s: " | ||
1411 | "device_register error: %d\n", | ||
1412 | __FUNCTION__, ret); | ||
1413 | } | ||
1414 | } | 1402 | } |
1415 | } | 1403 | } |
1416 | for (index = 0; index < MAX_HWIFS; ++index) | 1404 | for (index = 0; index < MAX_HWIFS; ++index) |
@@ -1420,3 +1408,22 @@ int ideprobe_init (void) | |||
1420 | } | 1408 | } |
1421 | 1409 | ||
1422 | EXPORT_SYMBOL_GPL(ideprobe_init); | 1410 | EXPORT_SYMBOL_GPL(ideprobe_init); |
1411 | |||
1412 | int ide_device_add(u8 idx[4]) | ||
1413 | { | ||
1414 | int i, rc = 0; | ||
1415 | |||
1416 | for (i = 0; i < 4; i++) { | ||
1417 | if (idx[i] != 0xff) | ||
1418 | rc |= probe_hwif_init(&ide_hwifs[idx[i]]); | ||
1419 | } | ||
1420 | |||
1421 | for (i = 0; i < 4; i++) { | ||
1422 | if (idx[i] != 0xff) | ||
1423 | ide_proc_register_port(&ide_hwifs[idx[i]]); | ||
1424 | } | ||
1425 | |||
1426 | return rc; | ||
1427 | } | ||
1428 | |||
1429 | EXPORT_SYMBOL_GPL(ide_device_add); | ||
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index fc1d8ae6a803..a4007d30da52 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -804,8 +804,6 @@ void ide_proc_register_port(ide_hwif_t *hwif) | |||
804 | create_proc_ide_drives(hwif); | 804 | create_proc_ide_drives(hwif); |
805 | } | 805 | } |
806 | 806 | ||
807 | EXPORT_SYMBOL_GPL(ide_proc_register_port); | ||
808 | |||
809 | #ifdef CONFIG_BLK_DEV_IDEPCI | 807 | #ifdef CONFIG_BLK_DEV_IDEPCI |
810 | void ide_pci_create_host_proc(const char *name, get_info_t *get_info) | 808 | void ide_pci_create_host_proc(const char *name, get_info_t *get_info) |
811 | { | 809 | { |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 1fa57947bca0..e5a86a962b26 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -621,7 +621,6 @@ typedef struct os_dat_s { | |||
621 | */ | 621 | */ |
622 | #define USE_IOTRACE 0 | 622 | #define USE_IOTRACE 0 |
623 | #if USE_IOTRACE | 623 | #if USE_IOTRACE |
624 | #include <linux/io_trace.h> | ||
625 | #define IO_IDETAPE_FIFO 500 | 624 | #define IO_IDETAPE_FIFO 500 |
626 | #endif | 625 | #endif |
627 | 626 | ||
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 2a3c8d498343..73ef6bf5fbcc 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -8,23 +8,6 @@ | |||
8 | * Copyright (C) 2003-2004 Bartlomiej Zolnierkiewicz | 8 | * Copyright (C) 2003-2004 Bartlomiej Zolnierkiewicz |
9 | * | 9 | * |
10 | * The big the bad and the ugly. | 10 | * The big the bad and the ugly. |
11 | * | ||
12 | * Problems to be fixed because of BH interface or the lack therefore. | ||
13 | * | ||
14 | * Fill me in stupid !!! | ||
15 | * | ||
16 | * HOST: | ||
17 | * General refers to the Controller and Driver "pair". | ||
18 | * DATA HANDLER: | ||
19 | * Under the context of Linux it generally refers to an interrupt handler. | ||
20 | * However, it correctly describes the 'HOST' | ||
21 | * DATA BLOCK: | ||
22 | * The amount of data needed to be transfered as predefined in the | ||
23 | * setup of the device. | ||
24 | * STORAGE ATOMIC: | ||
25 | * The 'DATA BLOCK' associated to the 'DATA HANDLER', and can be as | ||
26 | * small as a single sector or as large as the entire command block | ||
27 | * request. | ||
28 | */ | 11 | */ |
29 | 12 | ||
30 | #include <linux/module.h> | 13 | #include <linux/module.h> |
@@ -695,9 +678,6 @@ int ide_wait_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, | |||
695 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 678 | return ide_do_drive_cmd(drive, &rq, ide_wait); |
696 | } | 679 | } |
697 | 680 | ||
698 | /* | ||
699 | * FIXME : this needs to map into at taskfile. <andre@linux-ide.org> | ||
700 | */ | ||
701 | int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | 681 | int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) |
702 | { | 682 | { |
703 | int err = 0; | 683 | int err = 0; |
@@ -761,9 +741,6 @@ static int ide_wait_cmd_task(ide_drive_t *drive, u8 *buf) | |||
761 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 741 | return ide_do_drive_cmd(drive, &rq, ide_wait); |
762 | } | 742 | } |
763 | 743 | ||
764 | /* | ||
765 | * FIXME : this needs to map into at taskfile. <andre@linux-ide.org> | ||
766 | */ | ||
767 | int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | 744 | int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) |
768 | { | 745 | { |
769 | void __user *p = (void __user *)arg; | 746 | void __user *p = (void __user *)arg; |
@@ -860,9 +837,14 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
860 | case TASKFILE_OUT_DMA: | 837 | case TASKFILE_OUT_DMA: |
861 | case TASKFILE_IN_DMAQ: | 838 | case TASKFILE_IN_DMAQ: |
862 | case TASKFILE_IN_DMA: | 839 | case TASKFILE_IN_DMA: |
863 | hwif->dma_setup(drive); | 840 | if (!drive->using_dma) |
864 | hwif->dma_exec_cmd(drive, taskfile->command); | 841 | break; |
865 | hwif->dma_start(drive); | 842 | |
843 | if (!hwif->dma_setup(drive)) { | ||
844 | hwif->dma_exec_cmd(drive, taskfile->command); | ||
845 | hwif->dma_start(drive); | ||
846 | return ide_started; | ||
847 | } | ||
866 | break; | 848 | break; |
867 | 849 | ||
868 | default: | 850 | default: |
@@ -876,7 +858,8 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
876 | return task->prehandler(drive, task->rq); | 858 | return task->prehandler(drive, task->rq); |
877 | } | 859 | } |
878 | ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL); | 860 | ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL); |
861 | return ide_started; | ||
879 | } | 862 | } |
880 | 863 | ||
881 | return ide_started; | 864 | return ide_stopped; |
882 | } | 865 | } |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 961e6c897286..674a65c1a130 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -168,7 +168,6 @@ static void init_hwif_default(ide_hwif_t *hwif, unsigned int index) | |||
168 | 168 | ||
169 | ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, &hwif->irq); | 169 | ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, &hwif->irq); |
170 | 170 | ||
171 | memcpy(&hwif->hw, &hw, sizeof(hw)); | ||
172 | memcpy(hwif->io_ports, hw.io_ports, sizeof(hw.io_ports)); | 171 | memcpy(hwif->io_ports, hw.io_ports, sizeof(hw.io_ports)); |
173 | 172 | ||
174 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; | 173 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; |
@@ -214,7 +213,7 @@ static void __init init_ide_data (void) | |||
214 | init_hwif_data(hwif, index); | 213 | init_hwif_data(hwif, index); |
215 | init_hwif_default(hwif, index); | 214 | init_hwif_default(hwif, index); |
216 | #if !defined(CONFIG_PPC32) || !defined(CONFIG_PCI) | 215 | #if !defined(CONFIG_PPC32) || !defined(CONFIG_PCI) |
217 | hwif->irq = hwif->hw.irq = | 216 | hwif->irq = |
218 | ide_init_default_irq(hwif->io_ports[IDE_DATA_OFFSET]); | 217 | ide_init_default_irq(hwif->io_ports[IDE_DATA_OFFSET]); |
219 | #endif | 218 | #endif |
220 | } | 219 | } |
@@ -265,6 +264,30 @@ static int ide_system_bus_speed(void) | |||
265 | return system_bus_speed; | 264 | return system_bus_speed; |
266 | } | 265 | } |
267 | 266 | ||
267 | ide_hwif_t * ide_find_port(unsigned long base) | ||
268 | { | ||
269 | ide_hwif_t *hwif; | ||
270 | int i; | ||
271 | |||
272 | for (i = 0; i < MAX_HWIFS; i++) { | ||
273 | hwif = &ide_hwifs[i]; | ||
274 | if (hwif->io_ports[IDE_DATA_OFFSET] == base) | ||
275 | goto found; | ||
276 | } | ||
277 | |||
278 | for (i = 0; i < MAX_HWIFS; i++) { | ||
279 | hwif = &ide_hwifs[i]; | ||
280 | if (hwif->io_ports[IDE_DATA_OFFSET] == 0) | ||
281 | goto found; | ||
282 | } | ||
283 | |||
284 | hwif = NULL; | ||
285 | found: | ||
286 | return hwif; | ||
287 | } | ||
288 | |||
289 | EXPORT_SYMBOL_GPL(ide_find_port); | ||
290 | |||
268 | static struct resource* hwif_request_region(ide_hwif_t *hwif, | 291 | static struct resource* hwif_request_region(ide_hwif_t *hwif, |
269 | unsigned long addr, int num) | 292 | unsigned long addr, int num) |
270 | { | 293 | { |
@@ -391,6 +414,8 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) | |||
391 | hwif->cds = tmp_hwif->cds; | 414 | hwif->cds = tmp_hwif->cds; |
392 | #endif | 415 | #endif |
393 | 416 | ||
417 | hwif->fixup = tmp_hwif->fixup; | ||
418 | |||
394 | hwif->set_pio_mode = tmp_hwif->set_pio_mode; | 419 | hwif->set_pio_mode = tmp_hwif->set_pio_mode; |
395 | hwif->set_dma_mode = tmp_hwif->set_dma_mode; | 420 | hwif->set_dma_mode = tmp_hwif->set_dma_mode; |
396 | hwif->mdma_filter = tmp_hwif->mdma_filter; | 421 | hwif->mdma_filter = tmp_hwif->mdma_filter; |
@@ -652,7 +677,6 @@ void ide_setup_ports ( hw_regs_t *hw, | |||
652 | } | 677 | } |
653 | } | 678 | } |
654 | hw->irq = irq; | 679 | hw->irq = irq; |
655 | hw->dma = NO_DMA; | ||
656 | hw->ack_intr = ack_intr; | 680 | hw->ack_intr = ack_intr; |
657 | /* | 681 | /* |
658 | * hw->iops = iops; | 682 | * hw->iops = iops; |
@@ -660,11 +684,11 @@ void ide_setup_ports ( hw_regs_t *hw, | |||
660 | } | 684 | } |
661 | 685 | ||
662 | /** | 686 | /** |
663 | * ide_register_hw_with_fixup - register IDE interface | 687 | * ide_register_hw - register IDE interface |
664 | * @hw: hardware registers | 688 | * @hw: hardware registers |
689 | * @fixup: fixup function | ||
665 | * @initializing: set while initializing built-in drivers | 690 | * @initializing: set while initializing built-in drivers |
666 | * @hwifp: pointer to returned hwif | 691 | * @hwifp: pointer to returned hwif |
667 | * @fixup: fixup function | ||
668 | * | 692 | * |
669 | * Register an IDE interface, specifying exactly the registers etc. | 693 | * Register an IDE interface, specifying exactly the registers etc. |
670 | * Set init=1 iff calling before probes have taken place. | 694 | * Set init=1 iff calling before probes have taken place. |
@@ -672,9 +696,8 @@ void ide_setup_ports ( hw_regs_t *hw, | |||
672 | * Returns -1 on error. | 696 | * Returns -1 on error. |
673 | */ | 697 | */ |
674 | 698 | ||
675 | int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing, | 699 | int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *), |
676 | ide_hwif_t **hwifp, | 700 | int initializing, ide_hwif_t **hwifp) |
677 | void(*fixup)(ide_hwif_t *hwif)) | ||
678 | { | 701 | { |
679 | int index, retry = 1; | 702 | int index, retry = 1; |
680 | ide_hwif_t *hwif; | 703 | ide_hwif_t *hwif; |
@@ -682,7 +705,7 @@ int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing, | |||
682 | do { | 705 | do { |
683 | for (index = 0; index < MAX_HWIFS; ++index) { | 706 | for (index = 0; index < MAX_HWIFS; ++index) { |
684 | hwif = &ide_hwifs[index]; | 707 | hwif = &ide_hwifs[index]; |
685 | if (hwif->hw.io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET]) | 708 | if (hwif->io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET]) |
686 | goto found; | 709 | goto found; |
687 | } | 710 | } |
688 | for (index = 0; index < MAX_HWIFS; ++index) { | 711 | for (index = 0; index < MAX_HWIFS; ++index) { |
@@ -690,7 +713,7 @@ int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing, | |||
690 | if (hwif->hold) | 713 | if (hwif->hold) |
691 | continue; | 714 | continue; |
692 | if ((!hwif->present && !hwif->mate && !initializing) || | 715 | if ((!hwif->present && !hwif->mate && !initializing) || |
693 | (!hwif->hw.io_ports[IDE_DATA_OFFSET] && initializing)) | 716 | (!hwif->io_ports[IDE_DATA_OFFSET] && initializing)) |
694 | goto found; | 717 | goto found; |
695 | } | 718 | } |
696 | for (index = 0; index < MAX_HWIFS; index++) | 719 | for (index = 0; index < MAX_HWIFS; index++) |
@@ -706,16 +729,18 @@ found: | |||
706 | } | 729 | } |
707 | if (hwif->present) | 730 | if (hwif->present) |
708 | return -1; | 731 | return -1; |
709 | memcpy(&hwif->hw, hw, sizeof(*hw)); | 732 | memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); |
710 | memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports)); | ||
711 | hwif->irq = hw->irq; | 733 | hwif->irq = hw->irq; |
712 | hwif->noprobe = 0; | 734 | hwif->noprobe = 0; |
735 | hwif->fixup = fixup; | ||
713 | hwif->chipset = hw->chipset; | 736 | hwif->chipset = hw->chipset; |
714 | hwif->gendev.parent = hw->dev; | 737 | hwif->gendev.parent = hw->dev; |
738 | hwif->ack_intr = hw->ack_intr; | ||
739 | |||
740 | if (initializing == 0) { | ||
741 | u8 idx[4] = { index, 0xff, 0xff, 0xff }; | ||
715 | 742 | ||
716 | if (!initializing) { | 743 | ide_device_add(idx); |
717 | probe_hwif_init_with_fixup(hwif, fixup); | ||
718 | ide_proc_register_port(hwif); | ||
719 | } | 744 | } |
720 | 745 | ||
721 | if (hwifp) | 746 | if (hwifp) |
@@ -724,13 +749,6 @@ found: | |||
724 | return (initializing || hwif->present) ? index : -1; | 749 | return (initializing || hwif->present) ? index : -1; |
725 | } | 750 | } |
726 | 751 | ||
727 | EXPORT_SYMBOL(ide_register_hw_with_fixup); | ||
728 | |||
729 | int ide_register_hw(hw_regs_t *hw, int initializing, ide_hwif_t **hwifp) | ||
730 | { | ||
731 | return ide_register_hw_with_fixup(hw, initializing, hwifp, NULL); | ||
732 | } | ||
733 | |||
734 | EXPORT_SYMBOL(ide_register_hw); | 752 | EXPORT_SYMBOL(ide_register_hw); |
735 | 753 | ||
736 | /* | 754 | /* |
@@ -1046,7 +1064,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device | |||
1046 | ide_init_hwif_ports(&hw, (unsigned long) args[0], | 1064 | ide_init_hwif_ports(&hw, (unsigned long) args[0], |
1047 | (unsigned long) args[1], NULL); | 1065 | (unsigned long) args[1], NULL); |
1048 | hw.irq = args[2]; | 1066 | hw.irq = args[2]; |
1049 | if (ide_register_hw(&hw, 0, NULL) == -1) | 1067 | if (ide_register_hw(&hw, NULL, 0, NULL) == -1) |
1050 | return -EIO; | 1068 | return -EIO; |
1051 | return 0; | 1069 | return 0; |
1052 | } | 1070 | } |
@@ -1397,6 +1415,9 @@ static int __init ide_setup(char *s) | |||
1397 | "reset", "minus6", "ata66", "minus8", "minus9", | 1415 | "reset", "minus6", "ata66", "minus8", "minus9", |
1398 | "minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb", | 1416 | "minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb", |
1399 | "dtc2278", "umc8672", "ali14xx", NULL }; | 1417 | "dtc2278", "umc8672", "ali14xx", NULL }; |
1418 | |||
1419 | hw_regs_t hwregs; | ||
1420 | |||
1400 | hw = s[3] - '0'; | 1421 | hw = s[3] - '0'; |
1401 | hwif = &ide_hwifs[hw]; | 1422 | hwif = &ide_hwifs[hw]; |
1402 | i = match_parm(&s[4], ide_words, vals, 3); | 1423 | i = match_parm(&s[4], ide_words, vals, 3); |
@@ -1506,9 +1527,9 @@ static int __init ide_setup(char *s) | |||
1506 | case 2: /* base,ctl */ | 1527 | case 2: /* base,ctl */ |
1507 | vals[2] = 0; /* default irq = probe for it */ | 1528 | vals[2] = 0; /* default irq = probe for it */ |
1508 | case 3: /* base,ctl,irq */ | 1529 | case 3: /* base,ctl,irq */ |
1509 | hwif->hw.irq = vals[2]; | 1530 | memset(&hwregs, 0, sizeof(hwregs)); |
1510 | ide_init_hwif_ports(&hwif->hw, (unsigned long) vals[0], (unsigned long) vals[1], &hwif->irq); | 1531 | ide_init_hwif_ports(&hwregs, vals[0], vals[1], &hwif->irq); |
1511 | memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports)); | 1532 | memcpy(hwif->io_ports, hwregs.io_ports, sizeof(hwif->io_ports)); |
1512 | hwif->irq = vals[2]; | 1533 | hwif->irq = vals[2]; |
1513 | hwif->noprobe = 0; | 1534 | hwif->noprobe = 0; |
1514 | hwif->chipset = ide_forced; | 1535 | hwif->chipset = ide_forced; |
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index 2f0ef9b44033..10311ecc674a 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
@@ -102,6 +102,8 @@ static void outReg (u8 data, u8 reg) | |||
102 | outb_p(data, dataPort); | 102 | outb_p(data, dataPort); |
103 | } | 103 | } |
104 | 104 | ||
105 | static DEFINE_SPINLOCK(ali14xx_lock); | ||
106 | |||
105 | /* | 107 | /* |
106 | * Set PIO mode for the specified drive. | 108 | * Set PIO mode for the specified drive. |
107 | * This function computes timing parameters | 109 | * This function computes timing parameters |
@@ -129,14 +131,14 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
129 | 131 | ||
130 | /* stuff timing parameters into controller registers */ | 132 | /* stuff timing parameters into controller registers */ |
131 | driveNum = (HWIF(drive)->index << 1) + drive->select.b.unit; | 133 | driveNum = (HWIF(drive)->index << 1) + drive->select.b.unit; |
132 | spin_lock_irqsave(&ide_lock, flags); | 134 | spin_lock_irqsave(&ali14xx_lock, flags); |
133 | outb_p(regOn, basePort); | 135 | outb_p(regOn, basePort); |
134 | outReg(param1, regTab[driveNum].reg1); | 136 | outReg(param1, regTab[driveNum].reg1); |
135 | outReg(param2, regTab[driveNum].reg2); | 137 | outReg(param2, regTab[driveNum].reg2); |
136 | outReg(param3, regTab[driveNum].reg3); | 138 | outReg(param3, regTab[driveNum].reg3); |
137 | outReg(param4, regTab[driveNum].reg4); | 139 | outReg(param4, regTab[driveNum].reg4); |
138 | outb_p(regOff, basePort); | 140 | outb_p(regOff, basePort); |
139 | spin_unlock_irqrestore(&ide_lock, flags); | 141 | spin_unlock_irqrestore(&ali14xx_lock, flags); |
140 | } | 142 | } |
141 | 143 | ||
142 | /* | 144 | /* |
@@ -193,6 +195,7 @@ static int __init initRegisters (void) { | |||
193 | static int __init ali14xx_probe(void) | 195 | static int __init ali14xx_probe(void) |
194 | { | 196 | { |
195 | ide_hwif_t *hwif, *mate; | 197 | ide_hwif_t *hwif, *mate; |
198 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | ||
196 | 199 | ||
197 | printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", | 200 | printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", |
198 | basePort, regOn); | 201 | basePort, regOn); |
@@ -217,11 +220,7 @@ static int __init ali14xx_probe(void) | |||
217 | mate->mate = hwif; | 220 | mate->mate = hwif; |
218 | mate->channel = 1; | 221 | mate->channel = 1; |
219 | 222 | ||
220 | probe_hwif_init(hwif); | 223 | ide_device_add(idx); |
221 | probe_hwif_init(mate); | ||
222 | |||
223 | ide_proc_register_port(hwif); | ||
224 | ide_proc_register_port(mate); | ||
225 | 224 | ||
226 | return 0; | 225 | return 0; |
227 | } | 226 | } |
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c index 101aee1711c4..4a0be251a05f 100644 --- a/drivers/ide/legacy/buddha.c +++ b/drivers/ide/legacy/buddha.c | |||
@@ -212,8 +212,8 @@ fail_base2: | |||
212 | // xsurf_iops, | 212 | // xsurf_iops, |
213 | IRQ_AMIGA_PORTS); | 213 | IRQ_AMIGA_PORTS); |
214 | } | 214 | } |
215 | 215 | ||
216 | index = ide_register_hw(&hw, 1, &hwif); | 216 | index = ide_register_hw(&hw, NULL, 1, &hwif); |
217 | if (index != -1) { | 217 | if (index != -1) { |
218 | hwif->mmio = 1; | 218 | hwif->mmio = 1; |
219 | printk("ide%d: ", index); | 219 | printk("ide%d: ", index); |
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index f16521254867..24a845d45bd2 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c | |||
@@ -67,20 +67,24 @@ static void sub22 (char b, char c) | |||
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | static DEFINE_SPINLOCK(dtc2278_lock); | ||
71 | |||
70 | static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio) | 72 | static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio) |
71 | { | 73 | { |
72 | unsigned long flags; | 74 | unsigned long flags; |
73 | 75 | ||
74 | if (pio >= 3) { | 76 | if (pio >= 3) { |
75 | spin_lock_irqsave(&ide_lock, flags); | 77 | spin_lock_irqsave(&dtc2278_lock, flags); |
76 | /* | 78 | /* |
77 | * This enables PIO mode4 (3?) on the first interface | 79 | * This enables PIO mode4 (3?) on the first interface |
78 | */ | 80 | */ |
79 | sub22(1,0xc3); | 81 | sub22(1,0xc3); |
80 | sub22(0,0xa0); | 82 | sub22(0,0xa0); |
81 | spin_unlock_irqrestore(&ide_lock, flags); | 83 | spin_unlock_irqrestore(&dtc2278_lock, flags); |
82 | } else { | 84 | } else { |
83 | /* we don't know how to set it back again.. */ | 85 | /* we don't know how to set it back again.. */ |
86 | /* Actually we do - there is a data sheet available for the | ||
87 | Winbond but does anyone actually care */ | ||
84 | } | 88 | } |
85 | 89 | ||
86 | /* | 90 | /* |
@@ -94,6 +98,7 @@ static int __init dtc2278_probe(void) | |||
94 | { | 98 | { |
95 | unsigned long flags; | 99 | unsigned long flags; |
96 | ide_hwif_t *hwif, *mate; | 100 | ide_hwif_t *hwif, *mate; |
101 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | ||
97 | 102 | ||
98 | hwif = &ide_hwifs[0]; | 103 | hwif = &ide_hwifs[0]; |
99 | mate = &ide_hwifs[1]; | 104 | mate = &ide_hwifs[1]; |
@@ -129,16 +134,13 @@ static int __init dtc2278_probe(void) | |||
129 | 134 | ||
130 | mate->serialized = 1; | 135 | mate->serialized = 1; |
131 | mate->chipset = ide_dtc2278; | 136 | mate->chipset = ide_dtc2278; |
137 | mate->pio_mask = ATA_PIO4; | ||
132 | mate->drives[0].no_unmask = 1; | 138 | mate->drives[0].no_unmask = 1; |
133 | mate->drives[1].no_unmask = 1; | 139 | mate->drives[1].no_unmask = 1; |
134 | mate->mate = hwif; | 140 | mate->mate = hwif; |
135 | mate->channel = 1; | 141 | mate->channel = 1; |
136 | 142 | ||
137 | probe_hwif_init(hwif); | 143 | ide_device_add(idx); |
138 | probe_hwif_init(mate); | ||
139 | |||
140 | ide_proc_register_port(hwif); | ||
141 | ide_proc_register_port(mate); | ||
142 | 144 | ||
143 | return 0; | 145 | return 0; |
144 | } | 146 | } |
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index f0829b83e970..7d7936f1b900 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
@@ -72,7 +72,7 @@ void __init falconide_init(void) | |||
72 | 0, 0, NULL, | 72 | 0, 0, NULL, |
73 | // falconide_iops, | 73 | // falconide_iops, |
74 | IRQ_MFP_IDE); | 74 | IRQ_MFP_IDE); |
75 | index = ide_register_hw(&hw, 1, NULL); | 75 | index = ide_register_hw(&hw, NULL, 1, NULL); |
76 | 76 | ||
77 | if (index != -1) | 77 | if (index != -1) |
78 | printk("ide%d: Falcon IDE interface\n", index); | 78 | printk("ide%d: Falcon IDE interface\n", index); |
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index 0830a021bbb6..53331ee1e957 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
@@ -165,7 +165,7 @@ found: | |||
165 | // &gayle_iops, | 165 | // &gayle_iops, |
166 | IRQ_AMIGA_PORTS); | 166 | IRQ_AMIGA_PORTS); |
167 | 167 | ||
168 | index = ide_register_hw(&hw, 1, &hwif); | 168 | index = ide_register_hw(&hw, NULL, 1, &hwif); |
169 | if (index != -1) { | 169 | if (index != -1) { |
170 | hwif->mmio = 1; | 170 | hwif->mmio = 1; |
171 | switch (i) { | 171 | switch (i) { |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 2e5a9cc5c0f7..a4245d13f11b 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -247,6 +247,8 @@ static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio) | |||
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | static DEFINE_SPINLOCK(ht6560b_lock); | ||
251 | |||
250 | /* | 252 | /* |
251 | * Enable/Disable so called prefetch mode | 253 | * Enable/Disable so called prefetch mode |
252 | */ | 254 | */ |
@@ -254,9 +256,9 @@ static void ht_set_prefetch(ide_drive_t *drive, u8 state) | |||
254 | { | 256 | { |
255 | unsigned long flags; | 257 | unsigned long flags; |
256 | int t = HT_PREFETCH_MODE << 8; | 258 | int t = HT_PREFETCH_MODE << 8; |
257 | 259 | ||
258 | spin_lock_irqsave(&ide_lock, flags); | 260 | spin_lock_irqsave(&ht6560b_lock, flags); |
259 | 261 | ||
260 | /* | 262 | /* |
261 | * Prefetch mode and unmask irq seems to conflict | 263 | * Prefetch mode and unmask irq seems to conflict |
262 | */ | 264 | */ |
@@ -268,9 +270,9 @@ static void ht_set_prefetch(ide_drive_t *drive, u8 state) | |||
268 | drive->drive_data &= ~t; /* disable prefetch mode */ | 270 | drive->drive_data &= ~t; /* disable prefetch mode */ |
269 | drive->no_unmask = 0; | 271 | drive->no_unmask = 0; |
270 | } | 272 | } |
271 | 273 | ||
272 | spin_unlock_irqrestore(&ide_lock, flags); | 274 | spin_unlock_irqrestore(&ht6560b_lock, flags); |
273 | 275 | ||
274 | #ifdef DEBUG | 276 | #ifdef DEBUG |
275 | printk("ht6560b: drive %s prefetch mode %sabled\n", drive->name, (state ? "en" : "dis")); | 277 | printk("ht6560b: drive %s prefetch mode %sabled\n", drive->name, (state ? "en" : "dis")); |
276 | #endif | 278 | #endif |
@@ -287,16 +289,14 @@ static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
287 | ht_set_prefetch(drive, pio & 1); | 289 | ht_set_prefetch(drive, pio & 1); |
288 | return; | 290 | return; |
289 | } | 291 | } |
290 | 292 | ||
291 | timing = ht_pio2timings(drive, pio); | 293 | timing = ht_pio2timings(drive, pio); |
292 | 294 | ||
293 | spin_lock_irqsave(&ide_lock, flags); | 295 | spin_lock_irqsave(&ht6560b_lock, flags); |
294 | |||
295 | drive->drive_data &= 0xff00; | 296 | drive->drive_data &= 0xff00; |
296 | drive->drive_data |= timing; | 297 | drive->drive_data |= timing; |
297 | 298 | spin_unlock_irqrestore(&ht6560b_lock, flags); | |
298 | spin_unlock_irqrestore(&ide_lock, flags); | 299 | |
299 | |||
300 | #ifdef DEBUG | 300 | #ifdef DEBUG |
301 | printk("ht6560b: drive %s tuned to pio mode %#x timing=%#x\n", drive->name, pio, timing); | 301 | printk("ht6560b: drive %s tuned to pio mode %#x timing=%#x\n", drive->name, pio, timing); |
302 | #endif | 302 | #endif |
@@ -311,6 +311,7 @@ MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); | |||
311 | int __init ht6560b_init(void) | 311 | int __init ht6560b_init(void) |
312 | { | 312 | { |
313 | ide_hwif_t *hwif, *mate; | 313 | ide_hwif_t *hwif, *mate; |
314 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | ||
314 | int t; | 315 | int t; |
315 | 316 | ||
316 | if (probe_ht6560b == 0) | 317 | if (probe_ht6560b == 0) |
@@ -359,11 +360,7 @@ int __init ht6560b_init(void) | |||
359 | mate->drives[0].drive_data = t; | 360 | mate->drives[0].drive_data = t; |
360 | mate->drives[1].drive_data = t; | 361 | mate->drives[1].drive_data = t; |
361 | 362 | ||
362 | probe_hwif_init(hwif); | 363 | ide_device_add(idx); |
363 | probe_hwif_init(mate); | ||
364 | |||
365 | ide_proc_register_port(hwif); | ||
366 | ide_proc_register_port(mate); | ||
367 | 364 | ||
368 | return 0; | 365 | return 0; |
369 | 366 | ||
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index e8e360c2619d..03715c058664 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -153,7 +153,7 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq | |||
153 | hw.irq = irq; | 153 | hw.irq = irq; |
154 | hw.chipset = ide_pci; | 154 | hw.chipset = ide_pci; |
155 | hw.dev = &handle->dev; | 155 | hw.dev = &handle->dev; |
156 | return ide_register_hw_with_fixup(&hw, 0, NULL, ide_undecoded_slave); | 156 | return ide_register_hw(&hw, &ide_undecoded_slave, 0, NULL); |
157 | } | 157 | } |
158 | 158 | ||
159 | /*====================================================================== | 159 | /*====================================================================== |
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index b992b2b91fe2..7bb79f53dac8 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c | |||
@@ -33,39 +33,24 @@ static ide_hwif_t *__devinit plat_ide_locate_hwif(void __iomem *base, | |||
33 | int mmio) | 33 | int mmio) |
34 | { | 34 | { |
35 | unsigned long port = (unsigned long)base; | 35 | unsigned long port = (unsigned long)base; |
36 | ide_hwif_t *hwif; | 36 | ide_hwif_t *hwif = ide_find_port(port); |
37 | int index, i; | 37 | int i; |
38 | |||
39 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
40 | hwif = ide_hwifs + index; | ||
41 | if (hwif->io_ports[IDE_DATA_OFFSET] == port) | ||
42 | goto found; | ||
43 | } | ||
44 | |||
45 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
46 | hwif = ide_hwifs + index; | ||
47 | if (hwif->io_ports[IDE_DATA_OFFSET] == 0) | ||
48 | goto found; | ||
49 | } | ||
50 | 38 | ||
51 | return NULL; | 39 | if (hwif == NULL) |
52 | 40 | goto out; | |
53 | found: | ||
54 | 41 | ||
55 | hwif->hw.io_ports[IDE_DATA_OFFSET] = port; | 42 | hwif->io_ports[IDE_DATA_OFFSET] = port; |
56 | 43 | ||
57 | port += (1 << pdata->ioport_shift); | 44 | port += (1 << pdata->ioport_shift); |
58 | for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; | 45 | for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; |
59 | i++, port += (1 << pdata->ioport_shift)) | 46 | i++, port += (1 << pdata->ioport_shift)) |
60 | hwif->hw.io_ports[i] = port; | 47 | hwif->io_ports[i] = port; |
61 | 48 | ||
62 | hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; | 49 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; |
63 | 50 | ||
64 | memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports)); | 51 | hwif->irq = irq; |
65 | hwif->hw.irq = hwif->irq = irq; | ||
66 | 52 | ||
67 | hwif->hw.dma = NO_DMA; | 53 | hwif->chipset = ide_generic; |
68 | hwif->chipset = hwif->hw.chipset = ide_generic; | ||
69 | 54 | ||
70 | if (mmio) { | 55 | if (mmio) { |
71 | hwif->mmio = 1; | 56 | hwif->mmio = 1; |
@@ -73,8 +58,8 @@ found: | |||
73 | } | 58 | } |
74 | 59 | ||
75 | hwif_prop.hwif = hwif; | 60 | hwif_prop.hwif = hwif; |
76 | hwif_prop.index = index; | 61 | hwif_prop.index = hwif->index; |
77 | 62 | out: | |
78 | return hwif; | 63 | return hwif; |
79 | } | 64 | } |
80 | 65 | ||
@@ -83,6 +68,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
83 | struct resource *res_base, *res_alt, *res_irq; | 68 | struct resource *res_base, *res_alt, *res_irq; |
84 | ide_hwif_t *hwif; | 69 | ide_hwif_t *hwif; |
85 | struct pata_platform_info *pdata; | 70 | struct pata_platform_info *pdata; |
71 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
86 | int ret = 0; | 72 | int ret = 0; |
87 | int mmio = 0; | 73 | int mmio = 0; |
88 | 74 | ||
@@ -130,10 +116,11 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
130 | hwif->gendev.parent = &pdev->dev; | 116 | hwif->gendev.parent = &pdev->dev; |
131 | hwif->noprobe = 0; | 117 | hwif->noprobe = 0; |
132 | 118 | ||
133 | probe_hwif_init(hwif); | 119 | idx[0] = hwif->index; |
120 | |||
121 | ide_device_add(idx); | ||
134 | 122 | ||
135 | platform_set_drvdata(pdev, hwif); | 123 | platform_set_drvdata(pdev, hwif); |
136 | ide_proc_register_port(hwif); | ||
137 | 124 | ||
138 | return 0; | 125 | return 0; |
139 | 126 | ||
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index b557c45a5a9d..e87cd2f16430 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c | |||
@@ -93,21 +93,21 @@ void macide_init(void) | |||
93 | 0, 0, macide_ack_intr, | 93 | 0, 0, macide_ack_intr, |
94 | // quadra_ide_iops, | 94 | // quadra_ide_iops, |
95 | IRQ_NUBUS_F); | 95 | IRQ_NUBUS_F); |
96 | index = ide_register_hw(&hw, 1, &hwif); | 96 | index = ide_register_hw(&hw, NULL, 1, &hwif); |
97 | break; | 97 | break; |
98 | case MAC_IDE_PB: | 98 | case MAC_IDE_PB: |
99 | ide_setup_ports(&hw, IDE_BASE, macide_offsets, | 99 | ide_setup_ports(&hw, IDE_BASE, macide_offsets, |
100 | 0, 0, macide_ack_intr, | 100 | 0, 0, macide_ack_intr, |
101 | // macide_pb_iops, | 101 | // macide_pb_iops, |
102 | IRQ_NUBUS_C); | 102 | IRQ_NUBUS_C); |
103 | index = ide_register_hw(&hw, 1, &hwif); | 103 | index = ide_register_hw(&hw, NULL, 1, &hwif); |
104 | break; | 104 | break; |
105 | case MAC_IDE_BABOON: | 105 | case MAC_IDE_BABOON: |
106 | ide_setup_ports(&hw, BABOON_BASE, macide_offsets, | 106 | ide_setup_ports(&hw, BABOON_BASE, macide_offsets, |
107 | 0, 0, NULL, | 107 | 0, 0, NULL, |
108 | // macide_baboon_iops, | 108 | // macide_baboon_iops, |
109 | IRQ_BABOON_1); | 109 | IRQ_BABOON_1); |
110 | index = ide_register_hw(&hw, 1, &hwif); | 110 | index = ide_register_hw(&hw, NULL, 1, &hwif); |
111 | if (index == -1) break; | 111 | if (index == -1) break; |
112 | if (macintosh_config->ident == MAC_MODEL_PB190) { | 112 | if (macintosh_config->ident == MAC_MODEL_PB190) { |
113 | 113 | ||
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index e628a983ce33..44cdb745a6ff 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c | |||
@@ -89,9 +89,8 @@ void q40_ide_setup_ports ( hw_regs_t *hw, | |||
89 | else | 89 | else |
90 | hw->io_ports[i] = Q40_ISA_IO_B(base + offsets[i]); | 90 | hw->io_ports[i] = Q40_ISA_IO_B(base + offsets[i]); |
91 | } | 91 | } |
92 | 92 | ||
93 | hw->irq = irq; | 93 | hw->irq = irq; |
94 | hw->dma = NO_DMA; | ||
95 | hw->ack_intr = ack_intr; | 94 | hw->ack_intr = ack_intr; |
96 | /* | 95 | /* |
97 | * hw->iops = iops; | 96 | * hw->iops = iops; |
@@ -142,7 +141,7 @@ void q40ide_init(void) | |||
142 | 0, NULL, | 141 | 0, NULL, |
143 | // m68kide_iops, | 142 | // m68kide_iops, |
144 | q40ide_default_irq(pcide_bases[i])); | 143 | q40ide_default_irq(pcide_bases[i])); |
145 | index = ide_register_hw(&hw, 1, &hwif); | 144 | index = ide_register_hw(&hw, NULL, 1, &hwif); |
146 | // **FIXME** | 145 | // **FIXME** |
147 | if (index != -1) | 146 | if (index != -1) |
148 | hwif->mmio = 1; | 147 | hwif->mmio = 1; |
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 0c81d2d0b941..912e73853faa 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -89,26 +89,6 @@ | |||
89 | 89 | ||
90 | static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ | 90 | static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ |
91 | 91 | ||
92 | static void qd_write_reg (u8 content, unsigned long reg) | ||
93 | { | ||
94 | unsigned long flags; | ||
95 | |||
96 | spin_lock_irqsave(&ide_lock, flags); | ||
97 | outb(content,reg); | ||
98 | spin_unlock_irqrestore(&ide_lock, flags); | ||
99 | } | ||
100 | |||
101 | static u8 __init qd_read_reg (unsigned long reg) | ||
102 | { | ||
103 | unsigned long flags; | ||
104 | u8 read; | ||
105 | |||
106 | spin_lock_irqsave(&ide_lock, flags); | ||
107 | read = inb(reg); | ||
108 | spin_unlock_irqrestore(&ide_lock, flags); | ||
109 | return read; | ||
110 | } | ||
111 | |||
112 | /* | 92 | /* |
113 | * qd_select: | 93 | * qd_select: |
114 | * | 94 | * |
@@ -121,7 +101,7 @@ static void qd_select (ide_drive_t *drive) | |||
121 | (QD_TIMREG(drive) & 0x02); | 101 | (QD_TIMREG(drive) & 0x02); |
122 | 102 | ||
123 | if (timings[index] != QD_TIMING(drive)) | 103 | if (timings[index] != QD_TIMING(drive)) |
124 | qd_write_reg(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); | 104 | outb(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); |
125 | } | 105 | } |
126 | 106 | ||
127 | /* | 107 | /* |
@@ -284,7 +264,7 @@ static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
284 | } | 264 | } |
285 | 265 | ||
286 | if (!HWIF(drive)->channel && drive->media != ide_disk) { | 266 | if (!HWIF(drive)->channel && drive->media != ide_disk) { |
287 | qd_write_reg(0x5f, QD_CONTROL_PORT); | 267 | outb(0x5f, QD_CONTROL_PORT); |
288 | printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO " | 268 | printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO " |
289 | "and post-write buffer on %s.\n", | 269 | "and post-write buffer on %s.\n", |
290 | drive->name, HWIF(drive)->name); | 270 | drive->name, HWIF(drive)->name); |
@@ -301,16 +281,15 @@ static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
301 | 281 | ||
302 | static int __init qd_testreg(int port) | 282 | static int __init qd_testreg(int port) |
303 | { | 283 | { |
304 | u8 savereg; | ||
305 | u8 readreg; | ||
306 | unsigned long flags; | 284 | unsigned long flags; |
285 | u8 savereg, readreg; | ||
307 | 286 | ||
308 | spin_lock_irqsave(&ide_lock, flags); | 287 | local_irq_save(flags); |
309 | savereg = inb_p(port); | 288 | savereg = inb_p(port); |
310 | outb_p(QD_TESTVAL, port); /* safe value */ | 289 | outb_p(QD_TESTVAL, port); /* safe value */ |
311 | readreg = inb_p(port); | 290 | readreg = inb_p(port); |
312 | outb(savereg, port); | 291 | outb(savereg, port); |
313 | spin_unlock_irqrestore(&ide_lock, flags); | 292 | local_irq_restore(flags); |
314 | 293 | ||
315 | if (savereg == QD_TESTVAL) { | 294 | if (savereg == QD_TESTVAL) { |
316 | printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n"); | 295 | printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n"); |
@@ -364,13 +343,13 @@ static void __exit qd_unsetup(ide_hwif_t *hwif) | |||
364 | 343 | ||
365 | if (set_pio_mode == (void *)qd6500_set_pio_mode) { | 344 | if (set_pio_mode == (void *)qd6500_set_pio_mode) { |
366 | // will do it for both | 345 | // will do it for both |
367 | qd_write_reg(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); | 346 | outb(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); |
368 | } else if (set_pio_mode == (void *)qd6580_set_pio_mode) { | 347 | } else if (set_pio_mode == (void *)qd6580_set_pio_mode) { |
369 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { | 348 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { |
370 | qd_write_reg(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); | 349 | outb(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); |
371 | qd_write_reg(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); | 350 | outb(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); |
372 | } else { | 351 | } else { |
373 | qd_write_reg(hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); | 352 | outb(hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); |
374 | } | 353 | } |
375 | } else { | 354 | } else { |
376 | printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n"); | 355 | printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n"); |
@@ -389,10 +368,11 @@ static void __exit qd_unsetup(ide_hwif_t *hwif) | |||
389 | static int __init qd_probe(int base) | 368 | static int __init qd_probe(int base) |
390 | { | 369 | { |
391 | ide_hwif_t *hwif; | 370 | ide_hwif_t *hwif; |
371 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
392 | u8 config; | 372 | u8 config; |
393 | u8 unit; | 373 | u8 unit; |
394 | 374 | ||
395 | config = qd_read_reg(QD_CONFIG_PORT); | 375 | config = inb(QD_CONFIG_PORT); |
396 | 376 | ||
397 | if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) | 377 | if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) |
398 | return 1; | 378 | return 1; |
@@ -419,9 +399,9 @@ static int __init qd_probe(int base) | |||
419 | 399 | ||
420 | hwif->set_pio_mode = &qd6500_set_pio_mode; | 400 | hwif->set_pio_mode = &qd6500_set_pio_mode; |
421 | 401 | ||
422 | probe_hwif_init(hwif); | 402 | idx[0] = unit; |
423 | 403 | ||
424 | ide_proc_register_port(hwif); | 404 | ide_device_add(idx); |
425 | 405 | ||
426 | return 1; | 406 | return 1; |
427 | } | 407 | } |
@@ -436,7 +416,7 @@ static int __init qd_probe(int base) | |||
436 | 416 | ||
437 | /* qd6580 found */ | 417 | /* qd6580 found */ |
438 | 418 | ||
439 | control = qd_read_reg(QD_CONTROL_PORT); | 419 | control = inb(QD_CONTROL_PORT); |
440 | 420 | ||
441 | printk(KERN_NOTICE "qd6580 at %#x\n", base); | 421 | printk(KERN_NOTICE "qd6580 at %#x\n", base); |
442 | printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n", | 422 | printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n", |
@@ -453,11 +433,11 @@ static int __init qd_probe(int base) | |||
453 | 433 | ||
454 | hwif->set_pio_mode = &qd6580_set_pio_mode; | 434 | hwif->set_pio_mode = &qd6580_set_pio_mode; |
455 | 435 | ||
456 | probe_hwif_init(hwif); | 436 | idx[0] = unit; |
457 | 437 | ||
458 | qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); | 438 | ide_device_add(idx); |
459 | 439 | ||
460 | ide_proc_register_port(hwif); | 440 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
461 | 441 | ||
462 | return 1; | 442 | return 1; |
463 | } else { | 443 | } else { |
@@ -474,19 +454,17 @@ static int __init qd_probe(int base) | |||
474 | 454 | ||
475 | hwif->set_pio_mode = &qd6580_set_pio_mode; | 455 | hwif->set_pio_mode = &qd6580_set_pio_mode; |
476 | 456 | ||
477 | probe_hwif_init(hwif); | ||
478 | |||
479 | qd_setup(mate, base, config | (control << 8), | 457 | qd_setup(mate, base, config | (control << 8), |
480 | QD6580_DEF_DATA2, QD6580_DEF_DATA2); | 458 | QD6580_DEF_DATA2, QD6580_DEF_DATA2); |
481 | 459 | ||
482 | mate->set_pio_mode = &qd6580_set_pio_mode; | 460 | mate->set_pio_mode = &qd6580_set_pio_mode; |
483 | 461 | ||
484 | probe_hwif_init(mate); | 462 | idx[0] = 0; |
463 | idx[1] = 1; | ||
485 | 464 | ||
486 | qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); | 465 | ide_device_add(idx); |
487 | 466 | ||
488 | ide_proc_register_port(hwif); | 467 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
489 | ide_proc_register_port(mate); | ||
490 | 468 | ||
491 | return 0; /* no other qd65xx possible */ | 469 | return 0; /* no other qd65xx possible */ |
492 | } | 470 | } |
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c index 1151c92dd531..79577b916874 100644 --- a/drivers/ide/legacy/umc8672.c +++ b/drivers/ide/legacy/umc8672.c | |||
@@ -124,8 +124,9 @@ static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
124 | 124 | ||
125 | static int __init umc8672_probe(void) | 125 | static int __init umc8672_probe(void) |
126 | { | 126 | { |
127 | unsigned long flags; | ||
128 | ide_hwif_t *hwif, *mate; | 127 | ide_hwif_t *hwif, *mate; |
128 | unsigned long flags; | ||
129 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | ||
129 | 130 | ||
130 | if (!request_region(0x108, 2, "umc8672")) { | 131 | if (!request_region(0x108, 2, "umc8672")) { |
131 | printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); | 132 | printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); |
@@ -158,11 +159,7 @@ static int __init umc8672_probe(void) | |||
158 | mate->mate = hwif; | 159 | mate->mate = hwif; |
159 | mate->channel = 1; | 160 | mate->channel = 1; |
160 | 161 | ||
161 | probe_hwif_init(hwif); | 162 | ide_device_add(idx); |
162 | probe_hwif_init(mate); | ||
163 | |||
164 | ide_proc_register_port(hwif); | ||
165 | ide_proc_register_port(mate); | ||
166 | 163 | ||
167 | return 0; | 164 | return 0; |
168 | } | 165 | } |
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index 2f322d7e881b..1de58566e5b6 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c | |||
@@ -601,8 +601,9 @@ static int au_ide_probe(struct device *dev) | |||
601 | _auide_hwif *ahwif = &auide_hwif; | 601 | _auide_hwif *ahwif = &auide_hwif; |
602 | ide_hwif_t *hwif; | 602 | ide_hwif_t *hwif; |
603 | struct resource *res; | 603 | struct resource *res; |
604 | hw_regs_t *hw; | ||
605 | int ret = 0; | 604 | int ret = 0; |
605 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
606 | hw_regs_t hw; | ||
606 | 607 | ||
607 | #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) | 608 | #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) |
608 | char *mode = "MWDMA2"; | 609 | char *mode = "MWDMA2"; |
@@ -644,12 +645,12 @@ static int au_ide_probe(struct device *dev) | |||
644 | /* FIXME: This might possibly break PCMCIA IDE devices */ | 645 | /* FIXME: This might possibly break PCMCIA IDE devices */ |
645 | 646 | ||
646 | hwif = &ide_hwifs[pdev->id]; | 647 | hwif = &ide_hwifs[pdev->id]; |
647 | hw = &hwif->hw; | 648 | hwif->irq = ahwif->irq; |
648 | hwif->irq = hw->irq = ahwif->irq; | ||
649 | hwif->chipset = ide_au1xxx; | 649 | hwif->chipset = ide_au1xxx; |
650 | 650 | ||
651 | auide_setup_ports(hw, ahwif); | 651 | memset(&hw, 0, sizeof(hw)); |
652 | memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); | 652 | auide_setup_ports(&hw, ahwif); |
653 | memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports)); | ||
653 | 654 | ||
654 | hwif->ultra_mask = 0x0; /* Disable Ultra DMA */ | 655 | hwif->ultra_mask = 0x0; /* Disable Ultra DMA */ |
655 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 656 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
@@ -706,8 +707,10 @@ static int au_ide_probe(struct device *dev) | |||
706 | hwif->config_data = 0; /* no chipset-specific code */ | 707 | hwif->config_data = 0; /* no chipset-specific code */ |
707 | 708 | ||
708 | hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */ | 709 | hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */ |
710 | hwif->drives[1].autotune = 1; | ||
709 | #endif | 711 | #endif |
710 | hwif->drives[0].no_io_32bit = 1; | 712 | hwif->drives[0].no_io_32bit = 1; |
713 | hwif->drives[1].no_io_32bit = 1; | ||
711 | 714 | ||
712 | auide_hwif.hwif = hwif; | 715 | auide_hwif.hwif = hwif; |
713 | hwif->hwif_data = &auide_hwif; | 716 | hwif->hwif_data = &auide_hwif; |
@@ -717,9 +720,9 @@ static int au_ide_probe(struct device *dev) | |||
717 | dbdma_init_done = 1; | 720 | dbdma_init_done = 1; |
718 | #endif | 721 | #endif |
719 | 722 | ||
720 | probe_hwif_init(hwif); | 723 | idx[0] = hwif->index; |
721 | 724 | ||
722 | ide_proc_register_port(hwif); | 725 | ide_device_add(idx); |
723 | 726 | ||
724 | dev_set_drvdata(dev, hwif); | 727 | dev_set_drvdata(dev, hwif); |
725 | 728 | ||
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c index c2e29571b007..521edd41b572 100644 --- a/drivers/ide/mips/swarm.c +++ b/drivers/ide/mips/swarm.c | |||
@@ -71,6 +71,7 @@ static int __devinit swarm_ide_probe(struct device *dev) | |||
71 | u8 __iomem *base; | 71 | u8 __iomem *base; |
72 | phys_t offset, size; | 72 | phys_t offset, size; |
73 | int i; | 73 | int i; |
74 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
74 | 75 | ||
75 | if (!SIBYTE_HAVE_IDE) | 76 | if (!SIBYTE_HAVE_IDE) |
76 | return -ENODEV; | 77 | return -ENODEV; |
@@ -119,18 +120,15 @@ static int __devinit swarm_ide_probe(struct device *dev) | |||
119 | hwif->noprobe = 0; | 120 | hwif->noprobe = 0; |
120 | 121 | ||
121 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) | 122 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) |
122 | hwif->hw.io_ports[i] = | 123 | hwif->io_ports[i] = |
123 | (unsigned long)(base + ((0x1f0 + i) << 5)); | 124 | (unsigned long)(base + ((0x1f0 + i) << 5)); |
124 | hwif->hw.io_ports[IDE_CONTROL_OFFSET] = | 125 | hwif->io_ports[IDE_CONTROL_OFFSET] = |
125 | (unsigned long)(base + (0x3f6 << 5)); | 126 | (unsigned long)(base + (0x3f6 << 5)); |
126 | hwif->hw.irq = K_INT_GB_IDE; | 127 | hwif->irq = K_INT_GB_IDE; |
127 | 128 | ||
128 | memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports)); | 129 | idx[0] = hwif->index; |
129 | hwif->irq = hwif->hw.irq; | ||
130 | 130 | ||
131 | probe_hwif_init(hwif); | 131 | ide_device_add(idx); |
132 | |||
133 | ide_proc_register_port(hwif); | ||
134 | 132 | ||
135 | dev_set_drvdata(dev, hwif); | 133 | dev_set_drvdata(dev, hwif); |
136 | 134 | ||
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index b3dc12a70d51..19ec421f7b9f 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/aec62xx.c Version 0.26 Sep 1, 2007 | 2 | * linux/drivers/ide/pci/aec62xx.c Version 0.27 Sep 16, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> | 5 | * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> |
@@ -141,19 +141,6 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
141 | drive->hwif->set_dma_mode(drive, pio + XFER_PIO_0); | 141 | drive->hwif->set_dma_mode(drive, pio + XFER_PIO_0); |
142 | } | 142 | } |
143 | 143 | ||
144 | static void aec62xx_dma_lost_irq (ide_drive_t *drive) | ||
145 | { | ||
146 | switch (HWIF(drive)->pci_dev->device) { | ||
147 | case PCI_DEVICE_ID_ARTOP_ATP860: | ||
148 | case PCI_DEVICE_ID_ARTOP_ATP860R: | ||
149 | case PCI_DEVICE_ID_ARTOP_ATP865: | ||
150 | case PCI_DEVICE_ID_ARTOP_ATP865R: | ||
151 | printk(" AEC62XX time out "); | ||
152 | default: | ||
153 | break; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) | 144 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) |
158 | { | 145 | { |
159 | int bus_speed = system_bus_clock(); | 146 | int bus_speed = system_bus_clock(); |
@@ -195,8 +182,6 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | |||
195 | if (hwif->dma_base == 0) | 182 | if (hwif->dma_base == 0) |
196 | return; | 183 | return; |
197 | 184 | ||
198 | hwif->dma_lost_irq = &aec62xx_dma_lost_irq; | ||
199 | |||
200 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) | 185 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) |
201 | return; | 186 | return; |
202 | 187 | ||
@@ -209,7 +194,7 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | |||
209 | } | 194 | } |
210 | } | 195 | } |
211 | 196 | ||
212 | static ide_pci_device_t aec62xx_chipsets[] __devinitdata = { | 197 | static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { |
213 | { /* 0 */ | 198 | { /* 0 */ |
214 | .name = "AEC6210", | 199 | .name = "AEC6210", |
215 | .init_chipset = init_chipset_aec62xx, | 200 | .init_chipset = init_chipset_aec62xx, |
@@ -268,12 +253,12 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = { | |||
268 | * finds a device matching our IDE device tables. | 253 | * finds a device matching our IDE device tables. |
269 | * | 254 | * |
270 | * NOTE: since we're going to modify the 'name' field for AEC-6[26]80[R] | 255 | * NOTE: since we're going to modify the 'name' field for AEC-6[26]80[R] |
271 | * chips, pass a local copy of 'struct pci_device_id' down the call chain. | 256 | * chips, pass a local copy of 'struct ide_port_info' down the call chain. |
272 | */ | 257 | */ |
273 | 258 | ||
274 | static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 259 | static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
275 | { | 260 | { |
276 | ide_pci_device_t d; | 261 | struct ide_port_info d; |
277 | u8 idx = id->driver_data; | 262 | u8 idx = id->driver_data; |
278 | 263 | ||
279 | d = aec62xx_chipsets[idx]; | 264 | d = aec62xx_chipsets[idx]; |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 8ee2b48d105d..a607dd31a64c 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/alim15x3.c Version 0.27 Aug 27 2007 | 2 | * linux/drivers/ide/pci/alim15x3.c Version 0.29 Sep 16 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1998-2000 Michel Aubry, Maintainer | 4 | * Copyright (C) 1998-2000 Michel Aubry, Maintainer |
5 | * Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer | 5 | * Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer |
@@ -492,6 +492,13 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c | |||
492 | * clear bit 7 | 492 | * clear bit 7 |
493 | */ | 493 | */ |
494 | pci_write_config_byte(dev, 0x4b, tmpbyte & 0x7F); | 494 | pci_write_config_byte(dev, 0x4b, tmpbyte & 0x7F); |
495 | /* | ||
496 | * check m1533, 0x5e, bit 1~4 == 1001 => & 00011110 = 00010010 | ||
497 | */ | ||
498 | if (m5229_revision >= 0x20 && isa_dev) { | ||
499 | pci_read_config_byte(isa_dev, 0x5e, &tmpbyte); | ||
500 | chip_is_1543c_e = ((tmpbyte & 0x1e) == 0x12) ? 1: 0; | ||
501 | } | ||
495 | goto out; | 502 | goto out; |
496 | } | 503 | } |
497 | 504 | ||
@@ -537,7 +544,30 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c | |||
537 | pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x02); | 544 | pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x02); |
538 | } | 545 | } |
539 | } | 546 | } |
547 | |||
540 | out: | 548 | out: |
549 | /* | ||
550 | * CD_ROM DMA on (m5229, 0x53, bit0) | ||
551 | * Enable this bit even if we want to use PIO. | ||
552 | * PIO FIFO off (m5229, 0x53, bit1) | ||
553 | * The hardware will use 0x54h and 0x55h to control PIO FIFO. | ||
554 | * (Not on later devices it seems) | ||
555 | * | ||
556 | * 0x53 changes meaning on later revs - we must no touch | ||
557 | * bit 1 on them. Need to check if 0x20 is the right break. | ||
558 | */ | ||
559 | if (m5229_revision >= 0x20) { | ||
560 | pci_read_config_byte(dev, 0x53, &tmpbyte); | ||
561 | |||
562 | if (m5229_revision <= 0x20) | ||
563 | tmpbyte = (tmpbyte & (~0x02)) | 0x01; | ||
564 | else if (m5229_revision == 0xc7 || m5229_revision == 0xc8) | ||
565 | tmpbyte |= 0x03; | ||
566 | else | ||
567 | tmpbyte |= 0x01; | ||
568 | |||
569 | pci_write_config_byte(dev, 0x53, tmpbyte); | ||
570 | } | ||
541 | pci_dev_put(north); | 571 | pci_dev_put(north); |
542 | pci_dev_put(isa_dev); | 572 | pci_dev_put(isa_dev); |
543 | local_irq_restore(flags); | 573 | local_irq_restore(flags); |
@@ -616,36 +646,8 @@ static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) | |||
616 | if ((tmpbyte & (1 << hwif->channel)) == 0) | 646 | if ((tmpbyte & (1 << hwif->channel)) == 0) |
617 | cbl = ATA_CBL_PATA80; | 647 | cbl = ATA_CBL_PATA80; |
618 | } | 648 | } |
619 | } else { | ||
620 | /* | ||
621 | * check m1533, 0x5e, bit 1~4 == 1001 => & 00011110 = 00010010 | ||
622 | */ | ||
623 | pci_read_config_byte(isa_dev, 0x5e, &tmpbyte); | ||
624 | chip_is_1543c_e = ((tmpbyte & 0x1e) == 0x12) ? 1: 0; | ||
625 | } | 649 | } |
626 | 650 | ||
627 | /* | ||
628 | * CD_ROM DMA on (m5229, 0x53, bit0) | ||
629 | * Enable this bit even if we want to use PIO | ||
630 | * PIO FIFO off (m5229, 0x53, bit1) | ||
631 | * The hardware will use 0x54h and 0x55h to control PIO FIFO | ||
632 | * (Not on later devices it seems) | ||
633 | * | ||
634 | * 0x53 changes meaning on later revs - we must no touch | ||
635 | * bit 1 on them. Need to check if 0x20 is the right break | ||
636 | */ | ||
637 | |||
638 | pci_read_config_byte(dev, 0x53, &tmpbyte); | ||
639 | |||
640 | if(m5229_revision <= 0x20) | ||
641 | tmpbyte = (tmpbyte & (~0x02)) | 0x01; | ||
642 | else if (m5229_revision == 0xc7 || m5229_revision == 0xc8) | ||
643 | tmpbyte |= 0x03; | ||
644 | else | ||
645 | tmpbyte |= 0x01; | ||
646 | |||
647 | pci_write_config_byte(dev, 0x53, tmpbyte); | ||
648 | |||
649 | local_irq_restore(flags); | 651 | local_irq_restore(flags); |
650 | 652 | ||
651 | return cbl; | 653 | return cbl; |
@@ -664,31 +666,9 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) | |||
664 | hwif->set_dma_mode = &ali_set_dma_mode; | 666 | hwif->set_dma_mode = &ali_set_dma_mode; |
665 | hwif->udma_filter = &ali_udma_filter; | 667 | hwif->udma_filter = &ali_udma_filter; |
666 | 668 | ||
667 | /* don't use LBA48 DMA on ALi devices before rev 0xC5 */ | ||
668 | if (m5229_revision <= 0xC4) | ||
669 | hwif->host_flags |= IDE_HFLAG_NO_LBA48_DMA; | ||
670 | |||
671 | if (hwif->dma_base == 0) | 669 | if (hwif->dma_base == 0) |
672 | return; | 670 | return; |
673 | 671 | ||
674 | /* | ||
675 | * check in ->init_dma guarantees m5229_revision >= 0x20 here | ||
676 | */ | ||
677 | |||
678 | if (m5229_revision == 0x20) | ||
679 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | ||
680 | |||
681 | if (m5229_revision <= 0x20) | ||
682 | hwif->ultra_mask = 0x00; /* no udma */ | ||
683 | else if (m5229_revision < 0xC2) | ||
684 | hwif->ultra_mask = ATA_UDMA2; | ||
685 | else if (m5229_revision == 0xC2 || m5229_revision == 0xC3) | ||
686 | hwif->ultra_mask = ATA_UDMA4; | ||
687 | else if (m5229_revision == 0xC4) | ||
688 | hwif->ultra_mask = ATA_UDMA5; | ||
689 | else | ||
690 | hwif->ultra_mask = ATA_UDMA6; | ||
691 | |||
692 | hwif->dma_setup = &ali15x3_dma_setup; | 672 | hwif->dma_setup = &ali15x3_dma_setup; |
693 | 673 | ||
694 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 674 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
@@ -766,7 +746,7 @@ static void __devinit init_dma_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase) | |||
766 | ide_setup_dma(hwif, dmabase, 8); | 746 | ide_setup_dma(hwif, dmabase, 8); |
767 | } | 747 | } |
768 | 748 | ||
769 | static ide_pci_device_t ali15x3_chipset __devinitdata = { | 749 | static const struct ide_port_info ali15x3_chipset __devinitdata = { |
770 | .name = "ALI15X3", | 750 | .name = "ALI15X3", |
771 | .init_chipset = init_chipset_ali15x3, | 751 | .init_chipset = init_chipset_ali15x3, |
772 | .init_hwif = init_hwif_ali15x3, | 752 | .init_hwif = init_hwif_ali15x3, |
@@ -792,15 +772,34 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev | |||
792 | { }, | 772 | { }, |
793 | }; | 773 | }; |
794 | 774 | ||
795 | ide_pci_device_t *d = &ali15x3_chipset; | 775 | struct ide_port_info d = ali15x3_chipset; |
776 | u8 rev = dev->revision; | ||
796 | 777 | ||
797 | if (pci_dev_present(ati_rs100)) | 778 | if (pci_dev_present(ati_rs100)) |
798 | printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n"); | 779 | printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n"); |
799 | 780 | ||
781 | /* don't use LBA48 DMA on ALi devices before rev 0xC5 */ | ||
782 | if (rev <= 0xC4) | ||
783 | d.host_flags |= IDE_HFLAG_NO_LBA48_DMA; | ||
784 | |||
785 | if (rev >= 0x20) { | ||
786 | if (rev == 0x20) | ||
787 | d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | ||
788 | |||
789 | if (rev < 0xC2) | ||
790 | d.udma_mask = ATA_UDMA2; | ||
791 | else if (rev == 0xC2 || rev == 0xC3) | ||
792 | d.udma_mask = ATA_UDMA4; | ||
793 | else if (rev == 0xC4) | ||
794 | d.udma_mask = ATA_UDMA5; | ||
795 | else | ||
796 | d.udma_mask = ATA_UDMA6; | ||
797 | } | ||
798 | |||
800 | #if defined(CONFIG_SPARC64) | 799 | #if defined(CONFIG_SPARC64) |
801 | d->init_hwif = init_hwif_common_ali15x3; | 800 | d.init_hwif = init_hwif_common_ali15x3; |
802 | #endif /* CONFIG_SPARC64 */ | 801 | #endif /* CONFIG_SPARC64 */ |
803 | return ide_setup_pci_device(dev, d); | 802 | return ide_setup_pci_device(dev, &d); |
804 | } | 803 | } |
805 | 804 | ||
806 | 805 | ||
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 7cafefbf6c1b..8d4125ec252c 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -77,7 +77,7 @@ static struct amd_ide_chip { | |||
77 | }; | 77 | }; |
78 | 78 | ||
79 | static struct amd_ide_chip *amd_config; | 79 | static struct amd_ide_chip *amd_config; |
80 | static ide_pci_device_t *amd_chipset; | 80 | static const struct ide_port_info *amd_chipset; |
81 | static unsigned int amd_80w; | 81 | static unsigned int amd_80w; |
82 | static unsigned int amd_clock; | 82 | static unsigned int amd_clock; |
83 | 83 | ||
@@ -242,19 +242,12 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const ch | |||
242 | 242 | ||
243 | static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | 243 | static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) |
244 | { | 244 | { |
245 | int i; | ||
246 | |||
247 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ | 245 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ |
248 | hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel); | 246 | hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel); |
249 | 247 | ||
250 | hwif->set_pio_mode = &amd_set_pio_mode; | 248 | hwif->set_pio_mode = &amd_set_pio_mode; |
251 | hwif->set_dma_mode = &amd_set_drive; | 249 | hwif->set_dma_mode = &amd_set_drive; |
252 | 250 | ||
253 | for (i = 0; i < 2; i++) { | ||
254 | hwif->drives[i].io_32bit = 1; | ||
255 | hwif->drives[i].unmask = 1; | ||
256 | } | ||
257 | |||
258 | if (!hwif->dma_base) | 251 | if (!hwif->dma_base) |
259 | return; | 252 | return; |
260 | 253 | ||
@@ -270,16 +263,21 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
270 | } | 263 | } |
271 | } | 264 | } |
272 | 265 | ||
266 | #define IDE_HFLAGS_AMD \ | ||
267 | (IDE_HFLAG_PIO_NO_BLACKLIST | \ | ||
268 | IDE_HFLAG_PIO_NO_DOWNGRADE | \ | ||
269 | IDE_HFLAG_POST_SET_MODE | \ | ||
270 | IDE_HFLAG_IO_32BIT | \ | ||
271 | IDE_HFLAG_UNMASK_IRQS | \ | ||
272 | IDE_HFLAG_BOOTABLE) | ||
273 | |||
273 | #define DECLARE_AMD_DEV(name_str) \ | 274 | #define DECLARE_AMD_DEV(name_str) \ |
274 | { \ | 275 | { \ |
275 | .name = name_str, \ | 276 | .name = name_str, \ |
276 | .init_chipset = init_chipset_amd74xx, \ | 277 | .init_chipset = init_chipset_amd74xx, \ |
277 | .init_hwif = init_hwif_amd74xx, \ | 278 | .init_hwif = init_hwif_amd74xx, \ |
278 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ | 279 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ |
279 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | \ | 280 | .host_flags = IDE_HFLAGS_AMD, \ |
280 | IDE_HFLAG_PIO_NO_DOWNGRADE | \ | ||
281 | IDE_HFLAG_POST_SET_MODE | \ | ||
282 | IDE_HFLAG_BOOTABLE, \ | ||
283 | .pio_mask = ATA_PIO5, \ | 281 | .pio_mask = ATA_PIO5, \ |
284 | .swdma_mask = ATA_SWDMA2, \ | 282 | .swdma_mask = ATA_SWDMA2, \ |
285 | .mwdma_mask = ATA_MWDMA2, \ | 283 | .mwdma_mask = ATA_MWDMA2, \ |
@@ -291,16 +289,13 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
291 | .init_chipset = init_chipset_amd74xx, \ | 289 | .init_chipset = init_chipset_amd74xx, \ |
292 | .init_hwif = init_hwif_amd74xx, \ | 290 | .init_hwif = init_hwif_amd74xx, \ |
293 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ | 291 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ |
294 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | \ | 292 | .host_flags = IDE_HFLAGS_AMD, \ |
295 | IDE_HFLAG_PIO_NO_DOWNGRADE | \ | ||
296 | IDE_HFLAG_POST_SET_MODE | \ | ||
297 | IDE_HFLAG_BOOTABLE, \ | ||
298 | .pio_mask = ATA_PIO5, \ | 293 | .pio_mask = ATA_PIO5, \ |
299 | .swdma_mask = ATA_SWDMA2, \ | 294 | .swdma_mask = ATA_SWDMA2, \ |
300 | .mwdma_mask = ATA_MWDMA2, \ | 295 | .mwdma_mask = ATA_MWDMA2, \ |
301 | } | 296 | } |
302 | 297 | ||
303 | static ide_pci_device_t amd74xx_chipsets[] __devinitdata = { | 298 | static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { |
304 | /* 0 */ DECLARE_AMD_DEV("AMD7401"), | 299 | /* 0 */ DECLARE_AMD_DEV("AMD7401"), |
305 | /* 1 */ DECLARE_AMD_DEV("AMD7409"), | 300 | /* 1 */ DECLARE_AMD_DEV("AMD7409"), |
306 | /* 2 */ DECLARE_AMD_DEV("AMD7411"), | 301 | /* 2 */ DECLARE_AMD_DEV("AMD7411"), |
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index 307843053078..ef8e0164ef7a 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
@@ -189,8 +189,7 @@ static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) | |||
189 | hwif->dma_host_off = &atiixp_dma_host_off; | 189 | hwif->dma_host_off = &atiixp_dma_host_off; |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { | |
193 | static ide_pci_device_t atiixp_pci_info[] __devinitdata = { | ||
194 | { /* 0 */ | 193 | { /* 0 */ |
195 | .name = "ATIIXP", | 194 | .name = "ATIIXP", |
196 | .init_hwif = init_hwif_atiixp, | 195 | .init_hwif = init_hwif_atiixp, |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index f369645e4d16..4aa48104e0c1 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -185,6 +185,8 @@ static u8 recovery_counts[4] = {16, 16, 16, 16}; /* Recovery count (encoded) */ | |||
185 | 185 | ||
186 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 186 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
187 | 187 | ||
188 | static DEFINE_SPINLOCK(cmd640_lock); | ||
189 | |||
188 | /* | 190 | /* |
189 | * These are initialized to point at the devices we control | 191 | * These are initialized to point at the devices we control |
190 | */ | 192 | */ |
@@ -258,12 +260,12 @@ static u8 get_cmd640_reg_vlb (u16 reg) | |||
258 | 260 | ||
259 | static u8 get_cmd640_reg(u16 reg) | 261 | static u8 get_cmd640_reg(u16 reg) |
260 | { | 262 | { |
261 | u8 b; | ||
262 | unsigned long flags; | 263 | unsigned long flags; |
264 | u8 b; | ||
263 | 265 | ||
264 | spin_lock_irqsave(&ide_lock, flags); | 266 | spin_lock_irqsave(&cmd640_lock, flags); |
265 | b = __get_cmd640_reg(reg); | 267 | b = __get_cmd640_reg(reg); |
266 | spin_unlock_irqrestore(&ide_lock, flags); | 268 | spin_unlock_irqrestore(&cmd640_lock, flags); |
267 | return b; | 269 | return b; |
268 | } | 270 | } |
269 | 271 | ||
@@ -271,9 +273,9 @@ static void put_cmd640_reg(u16 reg, u8 val) | |||
271 | { | 273 | { |
272 | unsigned long flags; | 274 | unsigned long flags; |
273 | 275 | ||
274 | spin_lock_irqsave(&ide_lock, flags); | 276 | spin_lock_irqsave(&cmd640_lock, flags); |
275 | __put_cmd640_reg(reg,val); | 277 | __put_cmd640_reg(reg,val); |
276 | spin_unlock_irqrestore(&ide_lock, flags); | 278 | spin_unlock_irqrestore(&cmd640_lock, flags); |
277 | } | 279 | } |
278 | 280 | ||
279 | static int __init match_pci_cmd640_device (void) | 281 | static int __init match_pci_cmd640_device (void) |
@@ -351,7 +353,7 @@ static int __init secondary_port_responding (void) | |||
351 | { | 353 | { |
352 | unsigned long flags; | 354 | unsigned long flags; |
353 | 355 | ||
354 | spin_lock_irqsave(&ide_lock, flags); | 356 | spin_lock_irqsave(&cmd640_lock, flags); |
355 | 357 | ||
356 | outb_p(0x0a, 0x170 + IDE_SELECT_OFFSET); /* select drive0 */ | 358 | outb_p(0x0a, 0x170 + IDE_SELECT_OFFSET); /* select drive0 */ |
357 | udelay(100); | 359 | udelay(100); |
@@ -359,11 +361,11 @@ static int __init secondary_port_responding (void) | |||
359 | outb_p(0x1a, 0x170 + IDE_SELECT_OFFSET); /* select drive1 */ | 361 | outb_p(0x1a, 0x170 + IDE_SELECT_OFFSET); /* select drive1 */ |
360 | udelay(100); | 362 | udelay(100); |
361 | if ((inb_p(0x170 + IDE_SELECT_OFFSET) & 0x1f) != 0x1a) { | 363 | if ((inb_p(0x170 + IDE_SELECT_OFFSET) & 0x1f) != 0x1a) { |
362 | spin_unlock_irqrestore(&ide_lock, flags); | 364 | spin_unlock_irqrestore(&cmd640_lock, flags); |
363 | return 0; /* nothing responded */ | 365 | return 0; /* nothing responded */ |
364 | } | 366 | } |
365 | } | 367 | } |
366 | spin_unlock_irqrestore(&ide_lock, flags); | 368 | spin_unlock_irqrestore(&cmd640_lock, flags); |
367 | return 1; /* success */ | 369 | return 1; /* success */ |
368 | } | 370 | } |
369 | 371 | ||
@@ -440,11 +442,11 @@ static void __init setup_device_ptrs (void) | |||
440 | static void set_prefetch_mode (unsigned int index, int mode) | 442 | static void set_prefetch_mode (unsigned int index, int mode) |
441 | { | 443 | { |
442 | ide_drive_t *drive = cmd_drives[index]; | 444 | ide_drive_t *drive = cmd_drives[index]; |
445 | unsigned long flags; | ||
443 | int reg = prefetch_regs[index]; | 446 | int reg = prefetch_regs[index]; |
444 | u8 b; | 447 | u8 b; |
445 | unsigned long flags; | ||
446 | 448 | ||
447 | spin_lock_irqsave(&ide_lock, flags); | 449 | spin_lock_irqsave(&cmd640_lock, flags); |
448 | b = __get_cmd640_reg(reg); | 450 | b = __get_cmd640_reg(reg); |
449 | if (mode) { /* want prefetch on? */ | 451 | if (mode) { /* want prefetch on? */ |
450 | #if CMD640_PREFETCH_MASKS | 452 | #if CMD640_PREFETCH_MASKS |
@@ -460,7 +462,7 @@ static void set_prefetch_mode (unsigned int index, int mode) | |||
460 | b |= prefetch_masks[index]; /* disable prefetch */ | 462 | b |= prefetch_masks[index]; /* disable prefetch */ |
461 | } | 463 | } |
462 | __put_cmd640_reg(reg, b); | 464 | __put_cmd640_reg(reg, b); |
463 | spin_unlock_irqrestore(&ide_lock, flags); | 465 | spin_unlock_irqrestore(&cmd640_lock, flags); |
464 | } | 466 | } |
465 | 467 | ||
466 | /* | 468 | /* |
@@ -561,7 +563,7 @@ static void program_drive_counts (unsigned int index) | |||
561 | /* | 563 | /* |
562 | * Now that everything is ready, program the new timings | 564 | * Now that everything is ready, program the new timings |
563 | */ | 565 | */ |
564 | spin_lock_irqsave(&ide_lock, flags); | 566 | spin_lock_irqsave(&cmd640_lock, flags); |
565 | /* | 567 | /* |
566 | * Program the address_setup clocks into ARTTIM reg, | 568 | * Program the address_setup clocks into ARTTIM reg, |
567 | * and then the active/recovery counts into the DRWTIM reg | 569 | * and then the active/recovery counts into the DRWTIM reg |
@@ -570,7 +572,7 @@ static void program_drive_counts (unsigned int index) | |||
570 | setup_count |= __get_cmd640_reg(arttim_regs[index]) & 0x3f; | 572 | setup_count |= __get_cmd640_reg(arttim_regs[index]) & 0x3f; |
571 | __put_cmd640_reg(arttim_regs[index], setup_count); | 573 | __put_cmd640_reg(arttim_regs[index], setup_count); |
572 | __put_cmd640_reg(drwtim_regs[index], pack_nibbles(active_count, recovery_count)); | 574 | __put_cmd640_reg(drwtim_regs[index], pack_nibbles(active_count, recovery_count)); |
573 | spin_unlock_irqrestore(&ide_lock, flags); | 575 | spin_unlock_irqrestore(&cmd640_lock, flags); |
574 | } | 576 | } |
575 | 577 | ||
576 | /* | 578 | /* |
@@ -670,20 +672,20 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
670 | 672 | ||
671 | static int pci_conf1(void) | 673 | static int pci_conf1(void) |
672 | { | 674 | { |
673 | u32 tmp; | ||
674 | unsigned long flags; | 675 | unsigned long flags; |
676 | u32 tmp; | ||
675 | 677 | ||
676 | spin_lock_irqsave(&ide_lock, flags); | 678 | spin_lock_irqsave(&cmd640_lock, flags); |
677 | outb(0x01, 0xCFB); | 679 | outb(0x01, 0xCFB); |
678 | tmp = inl(0xCF8); | 680 | tmp = inl(0xCF8); |
679 | outl(0x80000000, 0xCF8); | 681 | outl(0x80000000, 0xCF8); |
680 | if (inl(0xCF8) == 0x80000000) { | 682 | if (inl(0xCF8) == 0x80000000) { |
681 | outl(tmp, 0xCF8); | 683 | outl(tmp, 0xCF8); |
682 | spin_unlock_irqrestore(&ide_lock, flags); | 684 | spin_unlock_irqrestore(&cmd640_lock, flags); |
683 | return 1; | 685 | return 1; |
684 | } | 686 | } |
685 | outl(tmp, 0xCF8); | 687 | outl(tmp, 0xCF8); |
686 | spin_unlock_irqrestore(&ide_lock, flags); | 688 | spin_unlock_irqrestore(&cmd640_lock, flags); |
687 | return 0; | 689 | return 0; |
688 | } | 690 | } |
689 | 691 | ||
@@ -691,15 +693,15 @@ static int pci_conf2(void) | |||
691 | { | 693 | { |
692 | unsigned long flags; | 694 | unsigned long flags; |
693 | 695 | ||
694 | spin_lock_irqsave(&ide_lock, flags); | 696 | spin_lock_irqsave(&cmd640_lock, flags); |
695 | outb(0x00, 0xCFB); | 697 | outb(0x00, 0xCFB); |
696 | outb(0x00, 0xCF8); | 698 | outb(0x00, 0xCF8); |
697 | outb(0x00, 0xCFA); | 699 | outb(0x00, 0xCFA); |
698 | if (inb(0xCF8) == 0x00 && inb(0xCF8) == 0x00) { | 700 | if (inb(0xCF8) == 0x00 && inb(0xCF8) == 0x00) { |
699 | spin_unlock_irqrestore(&ide_lock, flags); | 701 | spin_unlock_irqrestore(&cmd640_lock, flags); |
700 | return 1; | 702 | return 1; |
701 | } | 703 | } |
702 | spin_unlock_irqrestore(&ide_lock, flags); | 704 | spin_unlock_irqrestore(&cmd640_lock, flags); |
703 | return 0; | 705 | return 0; |
704 | } | 706 | } |
705 | 707 | ||
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index adee2ef6fd71..ea0143ef5fe5 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -535,7 +535,6 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | |||
535 | hwif->ide_dma_test_irq = &cmd648_ide_dma_test_irq; | 535 | hwif->ide_dma_test_irq = &cmd648_ide_dma_test_irq; |
536 | break; | 536 | break; |
537 | case PCI_DEVICE_ID_CMD_646: | 537 | case PCI_DEVICE_ID_CMD_646: |
538 | hwif->chipset = ide_cmd646; | ||
539 | if (dev->revision == 0x01) { | 538 | if (dev->revision == 0x01) { |
540 | hwif->ide_dma_end = &cmd646_1_ide_dma_end; | 539 | hwif->ide_dma_end = &cmd646_1_ide_dma_end; |
541 | break; | 540 | break; |
@@ -549,7 +548,7 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | |||
549 | } | 548 | } |
550 | } | 549 | } |
551 | 550 | ||
552 | static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | 551 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { |
553 | { /* 0 */ | 552 | { /* 0 */ |
554 | .name = "CMD643", | 553 | .name = "CMD643", |
555 | .init_chipset = init_chipset_cmd64x, | 554 | .init_chipset = init_chipset_cmd64x, |
@@ -573,6 +572,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
573 | .init_chipset = init_chipset_cmd64x, | 572 | .init_chipset = init_chipset_cmd64x, |
574 | .init_hwif = init_hwif_cmd64x, | 573 | .init_hwif = init_hwif_cmd64x, |
575 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 574 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
575 | .chipset = ide_cmd646, | ||
576 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE, | 576 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE, |
577 | .pio_mask = ATA_PIO5, | 577 | .pio_mask = ATA_PIO5, |
578 | .mwdma_mask = ATA_MWDMA2, | 578 | .mwdma_mask = ATA_MWDMA2, |
@@ -591,7 +591,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = { | |||
591 | 591 | ||
592 | static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 592 | static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
593 | { | 593 | { |
594 | ide_pci_device_t d; | 594 | struct ide_port_info d; |
595 | u8 idx = id->driver_data; | 595 | u8 idx = id->driver_data; |
596 | 596 | ||
597 | d = cmd64x_chipsets[idx]; | 597 | d = cmd64x_chipsets[idx]; |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index aa98e817d385..0466462fd21b 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
@@ -141,7 +141,7 @@ static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) | |||
141 | .pio_mask = ATA_PIO4, \ | 141 | .pio_mask = ATA_PIO4, \ |
142 | } | 142 | } |
143 | 143 | ||
144 | static ide_pci_device_t cyrix_chipsets[] __devinitdata = { | 144 | static const struct ide_port_info cyrix_chipsets[] __devinitdata = { |
145 | /* 0 */ DECLARE_CS_DEV("Cyrix 5510"), | 145 | /* 0 */ DECLARE_CS_DEV("Cyrix 5510"), |
146 | /* 1 */ DECLARE_CS_DEV("Cyrix 5520") | 146 | /* 1 */ DECLARE_CS_DEV("Cyrix 5520") |
147 | }; | 147 | }; |
@@ -154,9 +154,8 @@ static ide_pci_device_t cyrix_chipsets[] __devinitdata = { | |||
154 | 154 | ||
155 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 155 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
156 | { | 156 | { |
157 | ide_hwif_t *hwif = NULL, *mate = NULL; | 157 | const struct ide_port_info *d = &cyrix_chipsets[id->driver_data]; |
158 | ata_index_t index; | 158 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
159 | ide_pci_device_t *d = &cyrix_chipsets[id->driver_data]; | ||
160 | 159 | ||
161 | ide_setup_pci_noise(dev, d); | 160 | ide_setup_pci_noise(dev, d); |
162 | 161 | ||
@@ -172,29 +171,14 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic | |||
172 | return -ENODEV; | 171 | return -ENODEV; |
173 | } | 172 | } |
174 | 173 | ||
175 | index.all = 0xf0f0; | ||
176 | |||
177 | /* | 174 | /* |
178 | * Now the chipset is configured we can let the core | 175 | * Now the chipset is configured we can let the core |
179 | * do all the device setup for us | 176 | * do all the device setup for us |
180 | */ | 177 | */ |
181 | 178 | ||
182 | ide_pci_setup_ports(dev, d, 14, &index); | 179 | ide_pci_setup_ports(dev, d, 14, &idx[0]); |
183 | |||
184 | if ((index.b.low & 0xf0) != 0xf0) | ||
185 | hwif = &ide_hwifs[index.b.low]; | ||
186 | if ((index.b.high & 0xf0) != 0xf0) | ||
187 | mate = &ide_hwifs[index.b.high]; | ||
188 | |||
189 | if (hwif) | ||
190 | probe_hwif_init(hwif); | ||
191 | if (mate) | ||
192 | probe_hwif_init(mate); | ||
193 | 180 | ||
194 | if (hwif) | 181 | ide_device_add(idx); |
195 | ide_proc_register_port(hwif); | ||
196 | if (mate) | ||
197 | ide_proc_register_port(mate); | ||
198 | 182 | ||
199 | return 0; | 183 | return 0; |
200 | } | 184 | } |
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index ba0c6eba024b..599408952bd4 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/cs5530.c Version 0.76 Aug 3 2007 | 2 | * linux/drivers/ide/pci/cs5530.c Version 0.77 Sep 24 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2000 Mark Lord <mlord@pobox.com> | 5 | * Copyright (C) 2000 Mark Lord <mlord@pobox.com> |
@@ -146,7 +146,6 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
146 | static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const char *name) | 146 | static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const char *name) |
147 | { | 147 | { |
148 | struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; | 148 | struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; |
149 | unsigned long flags; | ||
150 | 149 | ||
151 | if (pci_resource_start(dev, 4) == 0) | 150 | if (pci_resource_start(dev, 4) == 0) |
152 | return -EFAULT; | 151 | return -EFAULT; |
@@ -171,9 +170,6 @@ static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const ch | |||
171 | goto out; | 170 | goto out; |
172 | } | 171 | } |
173 | 172 | ||
174 | spin_lock_irqsave(&ide_lock, flags); | ||
175 | /* all CPUs (there should only be one CPU with this chipset) */ | ||
176 | |||
177 | /* | 173 | /* |
178 | * Enable BusMaster and MemoryWriteAndInvalidate for the cs5530: | 174 | * Enable BusMaster and MemoryWriteAndInvalidate for the cs5530: |
179 | * --> OR 0x14 into 16-bit PCI COMMAND reg of function 0 of the cs5530 | 175 | * --> OR 0x14 into 16-bit PCI COMMAND reg of function 0 of the cs5530 |
@@ -224,8 +220,6 @@ static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const ch | |||
224 | pci_write_config_byte(master_0, 0x42, 0x00); | 220 | pci_write_config_byte(master_0, 0x42, 0x00); |
225 | pci_write_config_byte(master_0, 0x43, 0xc1); | 221 | pci_write_config_byte(master_0, 0x43, 0xc1); |
226 | 222 | ||
227 | spin_unlock_irqrestore(&ide_lock, flags); | ||
228 | |||
229 | out: | 223 | out: |
230 | pci_dev_put(master_0); | 224 | pci_dev_put(master_0); |
231 | pci_dev_put(cs5530_0); | 225 | pci_dev_put(cs5530_0); |
@@ -261,7 +255,7 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif) | |||
261 | hwif->udma_filter = cs5530_udma_filter; | 255 | hwif->udma_filter = cs5530_udma_filter; |
262 | } | 256 | } |
263 | 257 | ||
264 | static ide_pci_device_t cs5530_chipset __devinitdata = { | 258 | static const struct ide_port_info cs5530_chipset __devinitdata = { |
265 | .name = "CS5530", | 259 | .name = "CS5530", |
266 | .init_chipset = init_chipset_cs5530, | 260 | .init_chipset = init_chipset_cs5530, |
267 | .init_hwif = init_hwif_cs5530, | 261 | .init_hwif = init_hwif_cs5530, |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index 5ac82ffa5c09..9094916e3780 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
@@ -186,7 +186,7 @@ static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) | |||
186 | hwif->cbl = cs5535_cable_detect(hwif->pci_dev); | 186 | hwif->cbl = cs5535_cable_detect(hwif->pci_dev); |
187 | } | 187 | } |
188 | 188 | ||
189 | static ide_pci_device_t cs5535_chipset __devinitdata = { | 189 | static const struct ide_port_info cs5535_chipset __devinitdata = { |
190 | .name = "CS5535", | 190 | .name = "CS5535", |
191 | .init_hwif = init_hwif_cs5535, | 191 | .init_hwif = init_hwif_cs5535, |
192 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | | 192 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | |
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index efc20bd97fd5..3ef4fc10fe2c 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -428,7 +428,6 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c | |||
428 | */ | 428 | */ |
429 | static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) | 429 | static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) |
430 | { | 430 | { |
431 | hwif->chipset = ide_cy82c693; | ||
432 | hwif->set_pio_mode = &cy82c693_set_pio_mode; | 431 | hwif->set_pio_mode = &cy82c693_set_pio_mode; |
433 | 432 | ||
434 | if (hwif->dma_base == 0) | 433 | if (hwif->dma_base == 0) |
@@ -449,11 +448,12 @@ static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | |||
449 | } | 448 | } |
450 | } | 449 | } |
451 | 450 | ||
452 | static ide_pci_device_t cy82c693_chipset __devinitdata = { | 451 | static const struct ide_port_info cy82c693_chipset __devinitdata = { |
453 | .name = "CY82C693", | 452 | .name = "CY82C693", |
454 | .init_chipset = init_chipset_cy82c693, | 453 | .init_chipset = init_chipset_cy82c693, |
455 | .init_iops = init_iops_cy82c693, | 454 | .init_iops = init_iops_cy82c693, |
456 | .init_hwif = init_hwif_cy82c693, | 455 | .init_hwif = init_hwif_cy82c693, |
456 | .chipset = ide_cy82c693, | ||
457 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 457 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
458 | IDE_HFLAG_BOOTABLE, | 458 | IDE_HFLAG_BOOTABLE, |
459 | .pio_mask = ATA_PIO4, | 459 | .pio_mask = ATA_PIO4, |
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c index 46f4a888c037..83829081640a 100644 --- a/drivers/ide/pci/delkin_cb.c +++ b/drivers/ide/pci/delkin_cb.c | |||
@@ -80,7 +80,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
80 | hw.irq = dev->irq; | 80 | hw.irq = dev->irq; |
81 | hw.chipset = ide_pci; /* this enables IRQ sharing */ | 81 | hw.chipset = ide_pci; /* this enables IRQ sharing */ |
82 | 82 | ||
83 | rc = ide_register_hw_with_fixup(&hw, 0, &hwif, ide_undecoded_slave); | 83 | rc = ide_register_hw(&hw, &ide_undecoded_slave, 0, &hwif); |
84 | if (rc < 0) { | 84 | if (rc < 0) { |
85 | printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc); | 85 | printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc); |
86 | pci_disable_device(dev); | 86 | pci_disable_device(dev); |
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index 51165832e7f2..f44d70852c3c 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c | |||
@@ -54,37 +54,24 @@ __setup("all-generic-ide", ide_generic_all_on); | |||
54 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); | 54 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); |
55 | MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); | 55 | MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); |
56 | 56 | ||
57 | static void __devinit init_hwif_generic (ide_hwif_t *hwif) | 57 | #define IDE_HFLAGS_UMC (IDE_HFLAG_NO_DMA | IDE_HFLAG_FORCE_LEGACY_IRQS) |
58 | { | ||
59 | switch(hwif->pci_dev->device) { | ||
60 | case PCI_DEVICE_ID_UMC_UM8673F: | ||
61 | case PCI_DEVICE_ID_UMC_UM8886A: | ||
62 | case PCI_DEVICE_ID_UMC_UM8886BF: | ||
63 | hwif->irq = hwif->channel ? 15 : 14; | ||
64 | break; | ||
65 | default: | ||
66 | break; | ||
67 | } | ||
68 | } | ||
69 | 58 | ||
70 | #define DECLARE_GENERIC_PCI_DEV(name_str, dma_setting) \ | 59 | #define DECLARE_GENERIC_PCI_DEV(name_str, extra_flags) \ |
71 | { \ | 60 | { \ |
72 | .name = name_str, \ | 61 | .name = name_str, \ |
73 | .init_hwif = init_hwif_generic, \ | ||
74 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \ | 62 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \ |
75 | dma_setting | \ | 63 | extra_flags | \ |
76 | IDE_HFLAG_BOOTABLE, \ | 64 | IDE_HFLAG_BOOTABLE, \ |
77 | .swdma_mask = ATA_SWDMA2, \ | 65 | .swdma_mask = ATA_SWDMA2, \ |
78 | .mwdma_mask = ATA_MWDMA2, \ | 66 | .mwdma_mask = ATA_MWDMA2, \ |
79 | .udma_mask = ATA_UDMA6, \ | 67 | .udma_mask = ATA_UDMA6, \ |
80 | } | 68 | } |
81 | 69 | ||
82 | static ide_pci_device_t generic_chipsets[] __devinitdata = { | 70 | static const struct ide_port_info generic_chipsets[] __devinitdata = { |
83 | /* 0 */ DECLARE_GENERIC_PCI_DEV("Unknown", 0), | 71 | /* 0 */ DECLARE_GENERIC_PCI_DEV("Unknown", 0), |
84 | 72 | ||
85 | { /* 1 */ | 73 | { /* 1 */ |
86 | .name = "NS87410", | 74 | .name = "NS87410", |
87 | .init_hwif = init_hwif_generic, | ||
88 | .enablebits = {{0x43,0x08,0x08}, {0x47,0x08,0x08}}, | 75 | .enablebits = {{0x43,0x08,0x08}, {0x47,0x08,0x08}}, |
89 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 76 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
90 | IDE_HFLAG_BOOTABLE, | 77 | IDE_HFLAG_BOOTABLE, |
@@ -95,16 +82,15 @@ static ide_pci_device_t generic_chipsets[] __devinitdata = { | |||
95 | 82 | ||
96 | /* 2 */ DECLARE_GENERIC_PCI_DEV("SAMURAI", 0), | 83 | /* 2 */ DECLARE_GENERIC_PCI_DEV("SAMURAI", 0), |
97 | /* 3 */ DECLARE_GENERIC_PCI_DEV("HT6565", 0), | 84 | /* 3 */ DECLARE_GENERIC_PCI_DEV("HT6565", 0), |
98 | /* 4 */ DECLARE_GENERIC_PCI_DEV("UM8673F", IDE_HFLAG_NO_DMA), | 85 | /* 4 */ DECLARE_GENERIC_PCI_DEV("UM8673F", IDE_HFLAGS_UMC), |
99 | /* 5 */ DECLARE_GENERIC_PCI_DEV("UM8886A", IDE_HFLAG_NO_DMA), | 86 | /* 5 */ DECLARE_GENERIC_PCI_DEV("UM8886A", IDE_HFLAGS_UMC), |
100 | /* 6 */ DECLARE_GENERIC_PCI_DEV("UM8886BF", IDE_HFLAG_NO_DMA), | 87 | /* 6 */ DECLARE_GENERIC_PCI_DEV("UM8886BF", IDE_HFLAGS_UMC), |
101 | /* 7 */ DECLARE_GENERIC_PCI_DEV("HINT_IDE", 0), | 88 | /* 7 */ DECLARE_GENERIC_PCI_DEV("HINT_IDE", 0), |
102 | /* 8 */ DECLARE_GENERIC_PCI_DEV("VIA_IDE", IDE_HFLAG_NO_AUTODMA), | 89 | /* 8 */ DECLARE_GENERIC_PCI_DEV("VIA_IDE", IDE_HFLAG_NO_AUTODMA), |
103 | /* 9 */ DECLARE_GENERIC_PCI_DEV("OPTI621V", IDE_HFLAG_NO_AUTODMA), | 90 | /* 9 */ DECLARE_GENERIC_PCI_DEV("OPTI621V", IDE_HFLAG_NO_AUTODMA), |
104 | 91 | ||
105 | { /* 10 */ | 92 | { /* 10 */ |
106 | .name = "VIA8237SATA", | 93 | .name = "VIA8237SATA", |
107 | .init_hwif = init_hwif_generic, | ||
108 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 94 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
109 | IDE_HFLAG_OFF_BOARD, | 95 | IDE_HFLAG_OFF_BOARD, |
110 | .swdma_mask = ATA_SWDMA2, | 96 | .swdma_mask = ATA_SWDMA2, |
@@ -118,7 +104,6 @@ static ide_pci_device_t generic_chipsets[] __devinitdata = { | |||
118 | 104 | ||
119 | { /* 14 */ | 105 | { /* 14 */ |
120 | .name = "Revolution", | 106 | .name = "Revolution", |
121 | .init_hwif = init_hwif_generic, | ||
122 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 107 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
123 | IDE_HFLAG_OFF_BOARD, | 108 | IDE_HFLAG_OFF_BOARD, |
124 | .swdma_mask = ATA_SWDMA2, | 109 | .swdma_mask = ATA_SWDMA2, |
@@ -138,7 +123,7 @@ static ide_pci_device_t generic_chipsets[] __devinitdata = { | |||
138 | 123 | ||
139 | static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 124 | static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
140 | { | 125 | { |
141 | ide_pci_device_t *d = &generic_chipsets[id->driver_data]; | 126 | const struct ide_port_info *d = &generic_chipsets[id->driver_data]; |
142 | int ret = -ENODEV; | 127 | int ret = -ENODEV; |
143 | 128 | ||
144 | /* Don't use the generic entry unless instructed to do so */ | 129 | /* Don't use the generic entry unless instructed to do so */ |
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index 67af1a7dde30..ae6307fae4f9 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
@@ -129,7 +129,7 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif) | |||
129 | hwif->set_dma_mode = &hpt34x_set_mode; | 129 | hwif->set_dma_mode = &hpt34x_set_mode; |
130 | } | 130 | } |
131 | 131 | ||
132 | static ide_pci_device_t hpt34x_chipsets[] __devinitdata = { | 132 | static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { |
133 | { /* 0 */ | 133 | { /* 0 */ |
134 | .name = "HPT343", | 134 | .name = "HPT343", |
135 | .init_chipset = init_chipset_hpt34x, | 135 | .init_chipset = init_chipset_hpt34x, |
@@ -158,7 +158,7 @@ static ide_pci_device_t hpt34x_chipsets[] __devinitdata = { | |||
158 | 158 | ||
159 | static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 159 | static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
160 | { | 160 | { |
161 | ide_pci_device_t *d; | 161 | const struct ide_port_info *d; |
162 | u16 pcicmd = 0; | 162 | u16 pcicmd = 0; |
163 | 163 | ||
164 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | 164 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 18f5b7ddaee6..612b795241bf 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -1425,7 +1425,7 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2) | |||
1425 | return 0; | 1425 | return 0; |
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | static ide_pci_device_t hpt366_chipsets[] __devinitdata = { | 1428 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { |
1429 | { /* 0 */ | 1429 | { /* 0 */ |
1430 | .name = "HPT36x", | 1430 | .name = "HPT36x", |
1431 | .init_chipset = init_chipset_hpt366, | 1431 | .init_chipset = init_chipset_hpt366, |
@@ -1510,7 +1510,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1510 | { | 1510 | { |
1511 | struct hpt_info *info = NULL; | 1511 | struct hpt_info *info = NULL; |
1512 | struct pci_dev *dev2 = NULL; | 1512 | struct pci_dev *dev2 = NULL; |
1513 | ide_pci_device_t d; | 1513 | struct ide_port_info d; |
1514 | u8 idx = id->driver_data; | 1514 | u8 idx = id->driver_data; |
1515 | u8 rev = dev->revision; | 1515 | u8 rev = dev->revision; |
1516 | 1516 | ||
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index dfbe605120cb..90b52ed37bfc 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -193,7 +193,7 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | |||
193 | .udma_mask = ATA_UDMA6, \ | 193 | .udma_mask = ATA_UDMA6, \ |
194 | } | 194 | } |
195 | 195 | ||
196 | static ide_pci_device_t it8213_chipsets[] __devinitdata = { | 196 | static const struct ide_port_info it8213_chipsets[] __devinitdata = { |
197 | /* 0 */ DECLARE_ITE_DEV("IT8213"), | 197 | /* 0 */ DECLARE_ITE_DEV("IT8213"), |
198 | }; | 198 | }; |
199 | 199 | ||
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index ec45b7247209..1a7ddd12e65c 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -638,7 +638,7 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha | |||
638 | .pio_mask = ATA_PIO4, \ | 638 | .pio_mask = ATA_PIO4, \ |
639 | } | 639 | } |
640 | 640 | ||
641 | static ide_pci_device_t it821x_chipsets[] __devinitdata = { | 641 | static const struct ide_port_info it821x_chipsets[] __devinitdata = { |
642 | /* 0 */ DECLARE_ITE_DEV("IT8212"), | 642 | /* 0 */ DECLARE_ITE_DEV("IT8212"), |
643 | }; | 643 | }; |
644 | 644 | ||
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index 2eeff670d9a6..bdf64d997708 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c | |||
@@ -118,7 +118,7 @@ static void __devinit init_hwif_jmicron(ide_hwif_t *hwif) | |||
118 | hwif->cbl = ata66_jmicron(hwif); | 118 | hwif->cbl = ata66_jmicron(hwif); |
119 | } | 119 | } |
120 | 120 | ||
121 | static ide_pci_device_t jmicron_chipset __devinitdata = { | 121 | static const struct ide_port_info jmicron_chipset __devinitdata = { |
122 | .name = "JMB", | 122 | .name = "JMB", |
123 | .init_hwif = init_hwif_jmicron, | 123 | .init_hwif = init_hwif_jmicron, |
124 | .host_flags = IDE_HFLAG_BOOTABLE, | 124 | .host_flags = IDE_HFLAG_BOOTABLE, |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index d21b58923829..d4df4642dbb5 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -260,7 +260,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
260 | hwif->ide_dma_end = &ns87415_ide_dma_end; | 260 | hwif->ide_dma_end = &ns87415_ide_dma_end; |
261 | } | 261 | } |
262 | 262 | ||
263 | static ide_pci_device_t ns87415_chipset __devinitdata = { | 263 | static const struct ide_port_info ns87415_chipset __devinitdata = { |
264 | .name = "NS87415", | 264 | .name = "NS87415", |
265 | #ifdef CONFIG_SUPERIO | 265 | #ifdef CONFIG_SUPERIO |
266 | .init_iops = init_iops_ns87415, | 266 | .init_iops = init_iops_ns87415, |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index 3573ffeaaa34..8953d9c3926f 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/opti621.c Version 0.8 Aug 27, 2007 | 2 | * linux/drivers/ide/pci/opti621.c Version 0.9 Sep 24, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 1996-1998 Linus Torvalds & authors (see below) | 4 | * Copyright (C) 1996-1998 Linus Torvalds & authors (see below) |
5 | */ | 5 | */ |
@@ -133,6 +133,8 @@ static int reg_base; | |||
133 | #define PIO_NOT_EXIST 254 | 133 | #define PIO_NOT_EXIST 254 |
134 | #define PIO_DONT_KNOW 255 | 134 | #define PIO_DONT_KNOW 255 |
135 | 135 | ||
136 | static DEFINE_SPINLOCK(opti621_lock); | ||
137 | |||
136 | /* there are stored pio numbers from other calls of opti621_set_pio_mode */ | 138 | /* there are stored pio numbers from other calls of opti621_set_pio_mode */ |
137 | static void compute_pios(ide_drive_t *drive, const u8 pio) | 139 | static void compute_pios(ide_drive_t *drive, const u8 pio) |
138 | /* Store values into drive->drive_data | 140 | /* Store values into drive->drive_data |
@@ -278,7 +280,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
278 | second.recovery_time, drdy); | 280 | second.recovery_time, drdy); |
279 | #endif | 281 | #endif |
280 | 282 | ||
281 | spin_lock_irqsave(&ide_lock, flags); | 283 | spin_lock_irqsave(&opti621_lock, flags); |
282 | 284 | ||
283 | reg_base = hwif->io_ports[IDE_DATA_OFFSET]; | 285 | reg_base = hwif->io_ports[IDE_DATA_OFFSET]; |
284 | 286 | ||
@@ -317,7 +319,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
317 | /* and read prefetch for both drives */ | 319 | /* and read prefetch for both drives */ |
318 | write_reg(misc, MISC_REG); | 320 | write_reg(misc, MISC_REG); |
319 | 321 | ||
320 | spin_unlock_irqrestore(&ide_lock, flags); | 322 | spin_unlock_irqrestore(&opti621_lock, flags); |
321 | } | 323 | } |
322 | 324 | ||
323 | /* | 325 | /* |
@@ -331,7 +333,7 @@ static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) | |||
331 | hwif->set_pio_mode = &opti621_set_pio_mode; | 333 | hwif->set_pio_mode = &opti621_set_pio_mode; |
332 | } | 334 | } |
333 | 335 | ||
334 | static ide_pci_device_t opti621_chipsets[] __devinitdata = { | 336 | static const struct ide_port_info opti621_chipsets[] __devinitdata = { |
335 | { /* 0 */ | 337 | { /* 0 */ |
336 | .name = "OPTI621", | 338 | .name = "OPTI621", |
337 | .init_hwif = init_hwif_opti621, | 339 | .init_hwif = init_hwif_opti621, |
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index d1e7823454f3..4234efeba606 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
@@ -513,7 +513,7 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | |||
513 | .udma_mask = udma, \ | 513 | .udma_mask = udma, \ |
514 | } | 514 | } |
515 | 515 | ||
516 | static ide_pci_device_t pdcnew_chipsets[] __devinitdata = { | 516 | static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { |
517 | /* 0 */ DECLARE_PDCNEW_DEV("PDC20268", ATA_UDMA5), | 517 | /* 0 */ DECLARE_PDCNEW_DEV("PDC20268", ATA_UDMA5), |
518 | /* 1 */ DECLARE_PDCNEW_DEV("PDC20269", ATA_UDMA6), | 518 | /* 1 */ DECLARE_PDCNEW_DEV("PDC20269", ATA_UDMA6), |
519 | /* 2 */ DECLARE_PDCNEW_DEV("PDC20270", ATA_UDMA5), | 519 | /* 2 */ DECLARE_PDCNEW_DEV("PDC20270", ATA_UDMA5), |
@@ -534,7 +534,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = { | |||
534 | 534 | ||
535 | static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 535 | static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
536 | { | 536 | { |
537 | ide_pci_device_t *d; | 537 | const struct ide_port_info *d; |
538 | struct pci_dev *bridge = dev->bus->self; | 538 | struct pci_dev *bridge = dev->bus->self; |
539 | u8 idx = id->driver_data; | 539 | u8 idx = id->driver_data; |
540 | 540 | ||
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index 29306121dc4a..e09742e2ba59 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
@@ -302,13 +302,6 @@ static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, | |||
302 | 302 | ||
303 | static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) | 303 | static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) |
304 | { | 304 | { |
305 | struct pci_dev *dev = hwif->pci_dev; | ||
306 | |||
307 | /* PDC20265 has problems with large LBA48 requests */ | ||
308 | if ((dev->device == PCI_DEVICE_ID_PROMISE_20267) || | ||
309 | (dev->device == PCI_DEVICE_ID_PROMISE_20265)) | ||
310 | hwif->rqsize = 256; | ||
311 | |||
312 | hwif->set_pio_mode = &pdc202xx_set_pio_mode; | 305 | hwif->set_pio_mode = &pdc202xx_set_pio_mode; |
313 | hwif->set_dma_mode = &pdc202xx_set_mode; | 306 | hwif->set_dma_mode = &pdc202xx_set_mode; |
314 | 307 | ||
@@ -382,7 +375,7 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | |||
382 | } | 375 | } |
383 | } | 376 | } |
384 | 377 | ||
385 | #define DECLARE_PDC2026X_DEV(name_str, udma) \ | 378 | #define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ |
386 | { \ | 379 | { \ |
387 | .name = name_str, \ | 380 | .name = name_str, \ |
388 | .init_chipset = init_chipset_pdc202xx, \ | 381 | .init_chipset = init_chipset_pdc202xx, \ |
@@ -390,13 +383,14 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | |||
390 | .init_dma = init_dma_pdc202xx, \ | 383 | .init_dma = init_dma_pdc202xx, \ |
391 | .extra = 48, \ | 384 | .extra = 48, \ |
392 | .host_flags = IDE_HFLAG_ERROR_STOPS_FIFO | \ | 385 | .host_flags = IDE_HFLAG_ERROR_STOPS_FIFO | \ |
386 | extra_flags | \ | ||
393 | IDE_HFLAG_OFF_BOARD, \ | 387 | IDE_HFLAG_OFF_BOARD, \ |
394 | .pio_mask = ATA_PIO4, \ | 388 | .pio_mask = ATA_PIO4, \ |
395 | .mwdma_mask = ATA_MWDMA2, \ | 389 | .mwdma_mask = ATA_MWDMA2, \ |
396 | .udma_mask = udma, \ | 390 | .udma_mask = udma, \ |
397 | } | 391 | } |
398 | 392 | ||
399 | static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = { | 393 | static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { |
400 | { /* 0 */ | 394 | { /* 0 */ |
401 | .name = "PDC20246", | 395 | .name = "PDC20246", |
402 | .init_chipset = init_chipset_pdc202xx, | 396 | .init_chipset = init_chipset_pdc202xx, |
@@ -410,10 +404,10 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = { | |||
410 | .udma_mask = ATA_UDMA2, | 404 | .udma_mask = ATA_UDMA2, |
411 | }, | 405 | }, |
412 | 406 | ||
413 | /* 1 */ DECLARE_PDC2026X_DEV("PDC20262", ATA_UDMA4), | 407 | /* 1 */ DECLARE_PDC2026X_DEV("PDC20262", ATA_UDMA4, 0), |
414 | /* 2 */ DECLARE_PDC2026X_DEV("PDC20263", ATA_UDMA4), | 408 | /* 2 */ DECLARE_PDC2026X_DEV("PDC20263", ATA_UDMA4, 0), |
415 | /* 3 */ DECLARE_PDC2026X_DEV("PDC20265", ATA_UDMA5), | 409 | /* 3 */ DECLARE_PDC2026X_DEV("PDC20265", ATA_UDMA5, IDE_HFLAG_RQSIZE_256), |
416 | /* 4 */ DECLARE_PDC2026X_DEV("PDC20267", ATA_UDMA5), | 410 | /* 4 */ DECLARE_PDC2026X_DEV("PDC20267", ATA_UDMA5, IDE_HFLAG_RQSIZE_256), |
417 | }; | 411 | }; |
418 | 412 | ||
419 | /** | 413 | /** |
@@ -427,7 +421,7 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = { | |||
427 | 421 | ||
428 | static int __devinit pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 422 | static int __devinit pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
429 | { | 423 | { |
430 | ide_pci_device_t *d; | 424 | const struct ide_port_info *d; |
431 | u8 idx = id->driver_data; | 425 | u8 idx = id->driver_data; |
432 | 426 | ||
433 | d = &pdc202xx_chipsets[idx]; | 427 | d = &pdc202xx_chipsets[idx]; |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index ec0c6e96a213..9329d4a810e5 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -396,7 +396,7 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif) | |||
396 | .udma_mask = udma, \ | 396 | .udma_mask = udma, \ |
397 | } | 397 | } |
398 | 398 | ||
399 | static ide_pci_device_t piix_pci_info[] __devinitdata = { | 399 | static const struct ide_port_info piix_pci_info[] __devinitdata = { |
400 | /* 0 */ DECLARE_PIIX_DEV("PIIXa", 0x00), /* no udma */ | 400 | /* 0 */ DECLARE_PIIX_DEV("PIIXa", 0x00), /* no udma */ |
401 | /* 1 */ DECLARE_PIIX_DEV("PIIXb", 0x00), /* no udma */ | 401 | /* 1 */ DECLARE_PIIX_DEV("PIIXb", 0x00), /* no udma */ |
402 | 402 | ||
@@ -449,9 +449,7 @@ static ide_pci_device_t piix_pci_info[] __devinitdata = { | |||
449 | 449 | ||
450 | static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 450 | static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
451 | { | 451 | { |
452 | ide_pci_device_t *d = &piix_pci_info[id->driver_data]; | 452 | return ide_setup_pci_device(dev, &piix_pci_info[id->driver_data]); |
453 | |||
454 | return ide_setup_pci_device(dev, d); | ||
455 | } | 453 | } |
456 | 454 | ||
457 | /** | 455 | /** |
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c index dd2583ef1ad7..6b10ae260fa2 100644 --- a/drivers/ide/pci/rz1000.c +++ b/drivers/ide/pci/rz1000.c | |||
@@ -35,13 +35,13 @@ static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) | |||
35 | u16 reg; | 35 | u16 reg; |
36 | struct pci_dev *dev = hwif->pci_dev; | 36 | struct pci_dev *dev = hwif->pci_dev; |
37 | 37 | ||
38 | hwif->chipset = ide_rz1000; | ||
39 | if (!pci_read_config_word (dev, 0x40, ®) && | 38 | if (!pci_read_config_word (dev, 0x40, ®) && |
40 | !pci_write_config_word(dev, 0x40, reg & 0xdfff)) { | 39 | !pci_write_config_word(dev, 0x40, reg & 0xdfff)) { |
41 | printk(KERN_INFO "%s: disabled chipset read-ahead " | 40 | printk(KERN_INFO "%s: disabled chipset read-ahead " |
42 | "(buggy RZ1000/RZ1001)\n", hwif->name); | 41 | "(buggy RZ1000/RZ1001)\n", hwif->name); |
43 | } else { | 42 | } else { |
44 | hwif->serialized = 1; | 43 | if (hwif->mate) |
44 | hwif->mate->serialized = hwif->serialized = 1; | ||
45 | hwif->drives[0].no_unmask = 1; | 45 | hwif->drives[0].no_unmask = 1; |
46 | hwif->drives[1].no_unmask = 1; | 46 | hwif->drives[1].no_unmask = 1; |
47 | printk(KERN_INFO "%s: serialized, disabled unmasking " | 47 | printk(KERN_INFO "%s: serialized, disabled unmasking " |
@@ -49,9 +49,10 @@ static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | static ide_pci_device_t rz1000_chipset __devinitdata = { | 52 | static const struct ide_port_info rz1000_chipset __devinitdata = { |
53 | .name = "RZ100x", | 53 | .name = "RZ100x", |
54 | .init_hwif = init_hwif_rz1000, | 54 | .init_hwif = init_hwif_rz1000, |
55 | .chipset = ide_rz1000, | ||
55 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_BOOTABLE, | 56 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_BOOTABLE, |
56 | }; | 57 | }; |
57 | 58 | ||
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index b2423e03bf36..d2c8b5524f28 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -372,7 +372,7 @@ static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif) | |||
372 | hwif->ide_dma_end = &sc1200_ide_dma_end; | 372 | hwif->ide_dma_end = &sc1200_ide_dma_end; |
373 | } | 373 | } |
374 | 374 | ||
375 | static ide_pci_device_t sc1200_chipset __devinitdata = { | 375 | static const struct ide_port_info sc1200_chipset __devinitdata = { |
376 | .name = "SC1200", | 376 | .name = "SC1200", |
377 | .init_hwif = init_hwif_sc1200, | 377 | .init_hwif = init_hwif_sc1200, |
378 | .host_flags = IDE_HFLAG_SERIALIZE | | 378 | .host_flags = IDE_HFLAG_SERIALIZE | |
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index ae9b50331d2a..ebb7132b9b84 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
@@ -538,12 +538,13 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name) | |||
538 | /** | 538 | /** |
539 | * init_setup_scc - set up an SCC PATA Controller | 539 | * init_setup_scc - set up an SCC PATA Controller |
540 | * @dev: PCI device | 540 | * @dev: PCI device |
541 | * @d: IDE PCI device | 541 | * @d: IDE port info |
542 | * | 542 | * |
543 | * Perform the initial set up for this device. | 543 | * Perform the initial set up for this device. |
544 | */ | 544 | */ |
545 | 545 | ||
546 | static int __devinit init_setup_scc(struct pci_dev *dev, ide_pci_device_t *d) | 546 | static int __devinit init_setup_scc(struct pci_dev *dev, |
547 | const struct ide_port_info *d) | ||
547 | { | 548 | { |
548 | unsigned long ctl_base; | 549 | unsigned long ctl_base; |
549 | unsigned long dma_base; | 550 | unsigned long dma_base; |
@@ -702,7 +703,7 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
702 | .pio_mask = ATA_PIO4, \ | 703 | .pio_mask = ATA_PIO4, \ |
703 | } | 704 | } |
704 | 705 | ||
705 | static ide_pci_device_t scc_chipsets[] __devinitdata = { | 706 | static const struct ide_port_info scc_chipsets[] __devinitdata = { |
706 | /* 0 */ DECLARE_SCC_DEV("sccIDE"), | 707 | /* 0 */ DECLARE_SCC_DEV("sccIDE"), |
707 | }; | 708 | }; |
708 | 709 | ||
@@ -717,9 +718,7 @@ static ide_pci_device_t scc_chipsets[] __devinitdata = { | |||
717 | 718 | ||
718 | static int __devinit scc_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 719 | static int __devinit scc_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
719 | { | 720 | { |
720 | ide_pci_device_t *d = &scc_chipsets[id->driver_data]; | 721 | return init_setup_scc(dev, &scc_chipsets[id->driver_data]); |
721 | |||
722 | return init_setup_scc(dev, d); | ||
723 | } | 722 | } |
724 | 723 | ||
725 | /** | 724 | /** |
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index a3d880e21d0b..a7280311357b 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
@@ -158,13 +158,6 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
158 | 158 | ||
159 | u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; | 159 | u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; |
160 | 160 | ||
161 | /* If we are about to put a disk into UDMA mode we screwed up. | ||
162 | Our code assumes we never _ever_ do this on an OSB4 */ | ||
163 | |||
164 | if(dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4 && | ||
165 | drive->media == ide_disk && speed >= XFER_UDMA_0) | ||
166 | BUG(); | ||
167 | |||
168 | pci_read_config_byte(dev, (0x56|hwif->channel), &ultra_timing); | 161 | pci_read_config_byte(dev, (0x56|hwif->channel), &ultra_timing); |
169 | pci_read_config_byte(dev, 0x54, &ultra_enable); | 162 | pci_read_config_byte(dev, 0x54, &ultra_enable); |
170 | 163 | ||
@@ -373,7 +366,7 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif) | |||
373 | } | 366 | } |
374 | } | 367 | } |
375 | 368 | ||
376 | static ide_pci_device_t serverworks_chipsets[] __devinitdata = { | 369 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { |
377 | { /* 0 */ | 370 | { /* 0 */ |
378 | .name = "SvrWks OSB4", | 371 | .name = "SvrWks OSB4", |
379 | .init_chipset = init_chipset_svwks, | 372 | .init_chipset = init_chipset_svwks, |
@@ -430,7 +423,7 @@ static ide_pci_device_t serverworks_chipsets[] __devinitdata = { | |||
430 | 423 | ||
431 | static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 424 | static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
432 | { | 425 | { |
433 | ide_pci_device_t d; | 426 | struct ide_port_info d; |
434 | u8 idx = id->driver_data; | 427 | u8 idx = id->driver_data; |
435 | 428 | ||
436 | d = serverworks_chipsets[idx]; | 429 | d = serverworks_chipsets[idx]; |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 5af74ea1d46e..de820aa58cd0 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -614,6 +614,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
614 | void __iomem *virt_base; | 614 | void __iomem *virt_base; |
615 | ide_hwif_t *hwif; | 615 | ide_hwif_t *hwif; |
616 | int h; | 616 | int h; |
617 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
617 | 618 | ||
618 | /* | 619 | /* |
619 | * Find an empty HWIF; if none available, return -ENOMEM. | 620 | * Find an empty HWIF; if none available, return -ENOMEM. |
@@ -654,10 +655,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
654 | } | 655 | } |
655 | 656 | ||
656 | if (hwif->io_ports[IDE_DATA_OFFSET] != cmd_base) { | 657 | if (hwif->io_ports[IDE_DATA_OFFSET] != cmd_base) { |
658 | hw_regs_t hw; | ||
659 | |||
657 | /* Initialize the IO registers */ | 660 | /* Initialize the IO registers */ |
658 | sgiioc4_init_hwif_ports(&hwif->hw, cmd_base, ctl, irqport); | 661 | memset(&hw, 0, sizeof(hw)); |
659 | memcpy(hwif->io_ports, hwif->hw.io_ports, | 662 | sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport); |
660 | sizeof (hwif->io_ports)); | 663 | memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports)); |
661 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; | 664 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; |
662 | } | 665 | } |
663 | 666 | ||
@@ -679,11 +682,10 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
679 | 682 | ||
680 | ide_init_sgiioc4(hwif); | 683 | ide_init_sgiioc4(hwif); |
681 | 684 | ||
682 | if (probe_hwif_init(hwif)) | 685 | idx[0] = hwif->index; |
683 | return -EIO; | ||
684 | 686 | ||
685 | /* Create /proc/ide entries */ | 687 | if (ide_device_add(idx)) |
686 | ide_proc_register_port(hwif); | 688 | return -EIO; |
687 | 689 | ||
688 | return 0; | 690 | return 0; |
689 | } | 691 | } |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 689786df1ede..dc915cb22bec 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/siimage.c Version 1.17 Oct 18 2007 | 2 | * linux/drivers/ide/pci/siimage.c Version 1.18 Oct 18 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2003 Red Hat <alan@redhat.com> | 5 | * Copyright (C) 2003 Red Hat <alan@redhat.com> |
@@ -57,8 +57,8 @@ | |||
57 | 57 | ||
58 | static int pdev_is_sata(struct pci_dev *pdev) | 58 | static int pdev_is_sata(struct pci_dev *pdev) |
59 | { | 59 | { |
60 | switch(pdev->device) | 60 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
61 | { | 61 | switch(pdev->device) { |
62 | case PCI_DEVICE_ID_SII_3112: | 62 | case PCI_DEVICE_ID_SII_3112: |
63 | case PCI_DEVICE_ID_SII_1210SA: | 63 | case PCI_DEVICE_ID_SII_1210SA: |
64 | return 1; | 64 | return 1; |
@@ -66,9 +66,10 @@ static int pdev_is_sata(struct pci_dev *pdev) | |||
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | BUG(); | 68 | BUG(); |
69 | #endif | ||
69 | return 0; | 70 | return 0; |
70 | } | 71 | } |
71 | 72 | ||
72 | /** | 73 | /** |
73 | * is_sata - check if hwif is SATA | 74 | * is_sata - check if hwif is SATA |
74 | * @hwif: interface to check | 75 | * @hwif: interface to check |
@@ -136,7 +137,7 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r) | |||
136 | * SI3112 SATA controller life is a bit simpler. | 137 | * SI3112 SATA controller life is a bit simpler. |
137 | */ | 138 | */ |
138 | 139 | ||
139 | static u8 sil_udma_filter(ide_drive_t *drive) | 140 | static u8 sil_pata_udma_filter(ide_drive_t *drive) |
140 | { | 141 | { |
141 | ide_hwif_t *hwif = drive->hwif; | 142 | ide_hwif_t *hwif = drive->hwif; |
142 | unsigned long base = (unsigned long) hwif->hwif_data; | 143 | unsigned long base = (unsigned long) hwif->hwif_data; |
@@ -147,23 +148,23 @@ static u8 sil_udma_filter(ide_drive_t *drive) | |||
147 | else | 148 | else |
148 | pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc); | 149 | pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc); |
149 | 150 | ||
150 | if (is_sata(hwif)) { | ||
151 | mask = strstr(drive->id->model, "Maxtor") ? 0x3f : 0x7f; | ||
152 | goto out; | ||
153 | } | ||
154 | |||
155 | if ((scsc & 0x30) == 0x10) /* 133 */ | 151 | if ((scsc & 0x30) == 0x10) /* 133 */ |
156 | mask = 0x7f; | 152 | mask = ATA_UDMA6; |
157 | else if ((scsc & 0x30) == 0x20) /* 2xPCI */ | 153 | else if ((scsc & 0x30) == 0x20) /* 2xPCI */ |
158 | mask = 0x7f; | 154 | mask = ATA_UDMA6; |
159 | else if ((scsc & 0x30) == 0x00) /* 100 */ | 155 | else if ((scsc & 0x30) == 0x00) /* 100 */ |
160 | mask = 0x3f; | 156 | mask = ATA_UDMA5; |
161 | else /* Disabled ? */ | 157 | else /* Disabled ? */ |
162 | BUG(); | 158 | BUG(); |
163 | out: | 159 | |
164 | return mask; | 160 | return mask; |
165 | } | 161 | } |
166 | 162 | ||
163 | static u8 sil_sata_udma_filter(ide_drive_t *drive) | ||
164 | { | ||
165 | return strstr(drive->id->model, "Maxtor") ? ATA_UDMA5 : ATA_UDMA6; | ||
166 | } | ||
167 | |||
167 | /** | 168 | /** |
168 | * sil_set_pio_mode - set host controller for PIO mode | 169 | * sil_set_pio_mode - set host controller for PIO mode |
169 | * @drive: drive | 170 | * @drive: drive |
@@ -340,10 +341,11 @@ static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) | |||
340 | static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | 341 | static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) |
341 | { | 342 | { |
342 | ide_hwif_t *hwif = HWIF(drive); | 343 | ide_hwif_t *hwif = HWIF(drive); |
343 | unsigned long base = (unsigned long)hwif->hwif_data; | ||
344 | unsigned long addr = siimage_selreg(hwif, 0x1); | 344 | unsigned long addr = siimage_selreg(hwif, 0x1); |
345 | 345 | ||
346 | if (SATA_ERROR_REG) { | 346 | if (SATA_ERROR_REG) { |
347 | unsigned long base = (unsigned long)hwif->hwif_data; | ||
348 | |||
347 | u32 ext_stat = readl((void __iomem *)(base + 0x10)); | 349 | u32 ext_stat = readl((void __iomem *)(base + 0x10)); |
348 | u8 watchdog = 0; | 350 | u8 watchdog = 0; |
349 | if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) { | 351 | if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) { |
@@ -376,7 +378,7 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | |||
376 | } | 378 | } |
377 | 379 | ||
378 | /** | 380 | /** |
379 | * siimage_busproc - bus isolation ioctl | 381 | * sil_sata_busproc - bus isolation IOCTL |
380 | * @drive: drive to isolate/restore | 382 | * @drive: drive to isolate/restore |
381 | * @state: bus state to set | 383 | * @state: bus state to set |
382 | * | 384 | * |
@@ -384,8 +386,8 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | |||
384 | * SATA controller the work required is quite limited, we | 386 | * SATA controller the work required is quite limited, we |
385 | * just have to clean up the statistics | 387 | * just have to clean up the statistics |
386 | */ | 388 | */ |
387 | 389 | ||
388 | static int siimage_busproc (ide_drive_t * drive, int state) | 390 | static int sil_sata_busproc(ide_drive_t * drive, int state) |
389 | { | 391 | { |
390 | ide_hwif_t *hwif = HWIF(drive); | 392 | ide_hwif_t *hwif = HWIF(drive); |
391 | u32 stat_config = 0; | 393 | u32 stat_config = 0; |
@@ -417,14 +419,14 @@ static int siimage_busproc (ide_drive_t * drive, int state) | |||
417 | } | 419 | } |
418 | 420 | ||
419 | /** | 421 | /** |
420 | * siimage_reset_poll - wait for sata reset | 422 | * sil_sata_reset_poll - wait for SATA reset |
421 | * @drive: drive we are resetting | 423 | * @drive: drive we are resetting |
422 | * | 424 | * |
423 | * Poll the SATA phy and see whether it has come back from the dead | 425 | * Poll the SATA phy and see whether it has come back from the dead |
424 | * yet. | 426 | * yet. |
425 | */ | 427 | */ |
426 | 428 | ||
427 | static int siimage_reset_poll (ide_drive_t *drive) | 429 | static int sil_sata_reset_poll(ide_drive_t *drive) |
428 | { | 430 | { |
429 | if (SATA_STATUS_REG) { | 431 | if (SATA_STATUS_REG) { |
430 | ide_hwif_t *hwif = HWIF(drive); | 432 | ide_hwif_t *hwif = HWIF(drive); |
@@ -436,27 +438,22 @@ static int siimage_reset_poll (ide_drive_t *drive) | |||
436 | HWGROUP(drive)->polling = 0; | 438 | HWGROUP(drive)->polling = 0; |
437 | return ide_started; | 439 | return ide_started; |
438 | } | 440 | } |
439 | return 0; | ||
440 | } else { | ||
441 | return 0; | ||
442 | } | 441 | } |
442 | |||
443 | return 0; | ||
443 | } | 444 | } |
444 | 445 | ||
445 | /** | 446 | /** |
446 | * siimage_pre_reset - reset hook | 447 | * sil_sata_pre_reset - reset hook |
447 | * @drive: IDE device being reset | 448 | * @drive: IDE device being reset |
448 | * | 449 | * |
449 | * For the SATA devices we need to handle recalibration/geometry | 450 | * For the SATA devices we need to handle recalibration/geometry |
450 | * differently | 451 | * differently |
451 | */ | 452 | */ |
452 | |||
453 | static void siimage_pre_reset (ide_drive_t *drive) | ||
454 | { | ||
455 | if (drive->media != ide_disk) | ||
456 | return; | ||
457 | 453 | ||
458 | if (is_sata(HWIF(drive))) | 454 | static void sil_sata_pre_reset(ide_drive_t *drive) |
459 | { | 455 | { |
456 | if (drive->media == ide_disk) { | ||
460 | drive->special.b.set_geometry = 0; | 457 | drive->special.b.set_geometry = 0; |
461 | drive->special.b.recalibrate = 0; | 458 | drive->special.b.recalibrate = 0; |
462 | } | 459 | } |
@@ -502,7 +499,6 @@ static void siimage_reset (ide_drive_t *drive) | |||
502 | drive->failures++; | 499 | drive->failures++; |
503 | } | 500 | } |
504 | } | 501 | } |
505 | |||
506 | } | 502 | } |
507 | 503 | ||
508 | /** | 504 | /** |
@@ -758,16 +754,11 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
758 | hwif->sata_misc[SATA_IEN_OFFSET] = base + 0x148; | 754 | hwif->sata_misc[SATA_IEN_OFFSET] = base + 0x148; |
759 | } | 755 | } |
760 | 756 | ||
761 | hw.irq = hwif->pci_dev->irq; | 757 | memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports)); |
762 | 758 | ||
763 | memcpy(&hwif->hw, &hw, sizeof(hw)); | 759 | hwif->irq = dev->irq; |
764 | memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports)); | ||
765 | 760 | ||
766 | hwif->irq = hw.irq; | 761 | hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00); |
767 | |||
768 | base = (unsigned long) addr; | ||
769 | |||
770 | hwif->dma_base = base + (ch ? 0x08 : 0x00); | ||
771 | 762 | ||
772 | hwif->mmio = 1; | 763 | hwif->mmio = 1; |
773 | } | 764 | } |
@@ -864,28 +855,31 @@ static u8 __devinit ata66_siimage(ide_hwif_t *hwif) | |||
864 | 855 | ||
865 | static void __devinit init_hwif_siimage(ide_hwif_t *hwif) | 856 | static void __devinit init_hwif_siimage(ide_hwif_t *hwif) |
866 | { | 857 | { |
858 | u8 sata = is_sata(hwif); | ||
859 | |||
867 | hwif->resetproc = &siimage_reset; | 860 | hwif->resetproc = &siimage_reset; |
868 | hwif->set_pio_mode = &sil_set_pio_mode; | 861 | hwif->set_pio_mode = &sil_set_pio_mode; |
869 | hwif->set_dma_mode = &sil_set_dma_mode; | 862 | hwif->set_dma_mode = &sil_set_dma_mode; |
870 | hwif->reset_poll = &siimage_reset_poll; | ||
871 | hwif->pre_reset = &siimage_pre_reset; | ||
872 | hwif->udma_filter = &sil_udma_filter; | ||
873 | 863 | ||
874 | if(is_sata(hwif)) { | 864 | if (sata) { |
875 | static int first = 1; | 865 | static int first = 1; |
876 | 866 | ||
877 | hwif->busproc = &siimage_busproc; | 867 | hwif->busproc = &sil_sata_busproc; |
868 | hwif->reset_poll = &sil_sata_reset_poll; | ||
869 | hwif->pre_reset = &sil_sata_pre_reset; | ||
870 | hwif->udma_filter = &sil_sata_udma_filter; | ||
878 | 871 | ||
879 | if (first) { | 872 | if (first) { |
880 | printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n"); | 873 | printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n"); |
881 | first = 0; | 874 | first = 0; |
882 | } | 875 | } |
883 | } | 876 | } else |
877 | hwif->udma_filter = &sil_pata_udma_filter; | ||
884 | 878 | ||
885 | if (hwif->dma_base == 0) | 879 | if (hwif->dma_base == 0) |
886 | return; | 880 | return; |
887 | 881 | ||
888 | if (is_sata(hwif)) | 882 | if (sata) |
889 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 883 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |
890 | 884 | ||
891 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 885 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
@@ -911,7 +905,7 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif) | |||
911 | .udma_mask = ATA_UDMA6, \ | 905 | .udma_mask = ATA_UDMA6, \ |
912 | } | 906 | } |
913 | 907 | ||
914 | static ide_pci_device_t siimage_chipsets[] __devinitdata = { | 908 | static const struct ide_port_info siimage_chipsets[] __devinitdata = { |
915 | /* 0 */ DECLARE_SII_DEV("SiI680"), | 909 | /* 0 */ DECLARE_SII_DEV("SiI680"), |
916 | /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"), | 910 | /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"), |
917 | /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA") | 911 | /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA") |
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index c1d280b06391..6b7bb53acefd 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
@@ -264,7 +264,7 @@ static void sis_ata133_program_timings(ide_drive_t *drive, const u8 mode) | |||
264 | if (mode >= XFER_MW_DMA_0) { | 264 | if (mode >= XFER_MW_DMA_0) { |
265 | t1 &= ~0x04; /* disable UDMA */ | 265 | t1 &= ~0x04; /* disable UDMA */ |
266 | idx = mode - XFER_MW_DMA_0 + 5; | 266 | idx = mode - XFER_MW_DMA_0 + 5; |
267 | } | 267 | } else |
268 | idx = mode - XFER_PIO_0; | 268 | idx = mode - XFER_PIO_0; |
269 | t1 |= ini_time_value[clk][idx] << 12; | 269 | t1 |= ini_time_value[clk][idx] << 12; |
270 | t1 |= act_time_value[clk][idx] << 16; | 270 | t1 |= act_time_value[clk][idx] << 16; |
@@ -579,7 +579,7 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif) | |||
579 | hwif->cbl = ata66_sis5513(hwif); | 579 | hwif->cbl = ata66_sis5513(hwif); |
580 | } | 580 | } |
581 | 581 | ||
582 | static ide_pci_device_t sis5513_chipset __devinitdata = { | 582 | static const struct ide_port_info sis5513_chipset __devinitdata = { |
583 | .name = "SIS5513", | 583 | .name = "SIS5513", |
584 | .init_chipset = init_chipset_sis5513, | 584 | .init_chipset = init_chipset_sis5513, |
585 | .init_hwif = init_hwif_sis5513, | 585 | .init_hwif = init_hwif_sis5513, |
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index 0dce459b1269..147d783f7529 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
@@ -361,13 +361,6 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) | |||
361 | hwif->selectproc = &sl82c105_selectproc; | 361 | hwif->selectproc = &sl82c105_selectproc; |
362 | hwif->resetproc = &sl82c105_resetproc; | 362 | hwif->resetproc = &sl82c105_resetproc; |
363 | 363 | ||
364 | /* | ||
365 | * We support 32-bit I/O on this interface, and | ||
366 | * it doesn't have problems with interrupts. | ||
367 | */ | ||
368 | hwif->drives[0].io_32bit = hwif->drives[1].io_32bit = 1; | ||
369 | hwif->drives[0].unmask = hwif->drives[1].unmask = 1; | ||
370 | |||
371 | if (!hwif->dma_base) | 364 | if (!hwif->dma_base) |
372 | return; | 365 | return; |
373 | 366 | ||
@@ -394,12 +387,15 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) | |||
394 | hwif->serialized = hwif->mate->serialized = 1; | 387 | hwif->serialized = hwif->mate->serialized = 1; |
395 | } | 388 | } |
396 | 389 | ||
397 | static ide_pci_device_t sl82c105_chipset __devinitdata = { | 390 | static const struct ide_port_info sl82c105_chipset __devinitdata = { |
398 | .name = "W82C105", | 391 | .name = "W82C105", |
399 | .init_chipset = init_chipset_sl82c105, | 392 | .init_chipset = init_chipset_sl82c105, |
400 | .init_hwif = init_hwif_sl82c105, | 393 | .init_hwif = init_hwif_sl82c105, |
401 | .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, | 394 | .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, |
402 | .host_flags = IDE_HFLAG_NO_AUTODMA | IDE_HFLAG_BOOTABLE, | 395 | .host_flags = IDE_HFLAG_IO_32BIT | |
396 | IDE_HFLAG_UNMASK_IRQS | | ||
397 | IDE_HFLAG_NO_AUTODMA | | ||
398 | IDE_HFLAG_BOOTABLE, | ||
403 | .pio_mask = ATA_PIO5, | 399 | .pio_mask = ATA_PIO5, |
404 | }; | 400 | }; |
405 | 401 | ||
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index 4f22dffdf8ef..eb4445b229ed 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/slc90e66.c Version 0.18 Aug 9, 2007 | 2 | * linux/drivers/ide/pci/slc90e66.c Version 0.19 Sep 24, 2007 |
3 | * | 3 | * |
4 | * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> | 5 | * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> |
@@ -21,6 +21,8 @@ | |||
21 | 21 | ||
22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
23 | 23 | ||
24 | static DEFINE_SPINLOCK(slc90e66_lock); | ||
25 | |||
24 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | 26 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) |
25 | { | 27 | { |
26 | ide_hwif_t *hwif = HWIF(drive); | 28 | ide_hwif_t *hwif = HWIF(drive); |
@@ -40,7 +42,7 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
40 | { 2, 1 }, | 42 | { 2, 1 }, |
41 | { 2, 3 }, }; | 43 | { 2, 3 }, }; |
42 | 44 | ||
43 | spin_lock_irqsave(&ide_lock, flags); | 45 | spin_lock_irqsave(&slc90e66_lock, flags); |
44 | pci_read_config_word(dev, master_port, &master_data); | 46 | pci_read_config_word(dev, master_port, &master_data); |
45 | 47 | ||
46 | if (pio > 1) | 48 | if (pio > 1) |
@@ -71,7 +73,7 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
71 | pci_write_config_word(dev, master_port, master_data); | 73 | pci_write_config_word(dev, master_port, master_data); |
72 | if (is_slave) | 74 | if (is_slave) |
73 | pci_write_config_byte(dev, slave_port, slave_data); | 75 | pci_write_config_byte(dev, slave_port, slave_data); |
74 | spin_unlock_irqrestore(&ide_lock, flags); | 76 | spin_unlock_irqrestore(&slc90e66_lock, flags); |
75 | } | 77 | } |
76 | 78 | ||
77 | static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) | 79 | static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) |
@@ -146,7 +148,7 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) | |||
146 | hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 148 | hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
147 | } | 149 | } |
148 | 150 | ||
149 | static ide_pci_device_t slc90e66_chipset __devinitdata = { | 151 | static const struct ide_port_info slc90e66_chipset __devinitdata = { |
150 | .name = "SLC90E66", | 152 | .name = "SLC90E66", |
151 | .init_hwif = init_hwif_slc90e66, | 153 | .init_hwif = init_hwif_slc90e66, |
152 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, | 154 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, |
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index 631506e9b5d2..a66ebd14664e 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c | |||
@@ -218,7 +218,7 @@ static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, | |||
218 | return err; | 218 | return err; |
219 | } | 219 | } |
220 | 220 | ||
221 | static ide_pci_device_t tc86c001_chipset __devinitdata = { | 221 | static const struct ide_port_info tc86c001_chipset __devinitdata = { |
222 | .name = "TC86C001", | 222 | .name = "TC86C001", |
223 | .init_chipset = init_chipset_tc86c001, | 223 | .init_chipset = init_chipset_tc86c001, |
224 | .init_hwif = init_hwif_tc86c001, | 224 | .init_hwif = init_hwif_tc86c001, |
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index 30b52f62699a..a227c41d23a3 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c | |||
@@ -102,7 +102,7 @@ static void __devinit init_hwif_triflex(ide_hwif_t *hwif) | |||
102 | hwif->set_dma_mode = &triflex_set_mode; | 102 | hwif->set_dma_mode = &triflex_set_mode; |
103 | } | 103 | } |
104 | 104 | ||
105 | static ide_pci_device_t triflex_device __devinitdata = { | 105 | static const struct ide_port_info triflex_device __devinitdata = { |
106 | .name = "TRIFLEX", | 106 | .name = "TRIFLEX", |
107 | .init_hwif = init_hwif_triflex, | 107 | .init_hwif = init_hwif_triflex, |
108 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, | 108 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, |
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index 140d486f6237..5011ba22e36c 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c | |||
@@ -250,7 +250,6 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
250 | u8 reg = 0; | 250 | u8 reg = 0; |
251 | struct pci_dev *dev = hwif->pci_dev; | 251 | struct pci_dev *dev = hwif->pci_dev; |
252 | 252 | ||
253 | hwif->chipset = ide_trm290; | ||
254 | cfgbase = pci_resource_start(dev, 4); | 253 | cfgbase = pci_resource_start(dev, 4); |
255 | if ((dev->class & 5) && cfgbase) { | 254 | if ((dev->class & 5) && cfgbase) { |
256 | hwif->config_data = cfgbase; | 255 | hwif->config_data = cfgbase; |
@@ -320,9 +319,10 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
320 | #endif | 319 | #endif |
321 | } | 320 | } |
322 | 321 | ||
323 | static ide_pci_device_t trm290_chipset __devinitdata = { | 322 | static const struct ide_port_info trm290_chipset __devinitdata = { |
324 | .name = "TRM290", | 323 | .name = "TRM290", |
325 | .init_hwif = init_hwif_trm290, | 324 | .init_hwif = init_hwif_trm290, |
325 | .chipset = ide_trm290, | ||
326 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 326 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
327 | #if 0 /* play it safe for now */ | 327 | #if 0 /* play it safe for now */ |
328 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 328 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index c8022a92a0e3..a0d3c16b68ec 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * Version 3.49 | 3 | * Version 3.50 |
4 | * | 4 | * |
5 | * VIA IDE driver for Linux. Supported southbridges: | 5 | * VIA IDE driver for Linux. Supported southbridges: |
6 | * | 6 | * |
@@ -422,65 +422,40 @@ static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) | |||
422 | 422 | ||
423 | static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) | 423 | static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) |
424 | { | 424 | { |
425 | struct via82cxxx_dev *vdev = pci_get_drvdata(hwif->pci_dev); | ||
426 | int i; | ||
427 | |||
428 | hwif->set_pio_mode = &via_set_pio_mode; | 425 | hwif->set_pio_mode = &via_set_pio_mode; |
429 | hwif->set_dma_mode = &via_set_drive; | 426 | hwif->set_dma_mode = &via_set_drive; |
430 | 427 | ||
431 | #ifdef CONFIG_PPC_CHRP | ||
432 | if(machine_is(chrp) && _chrp_type == _CHRP_Pegasos) { | ||
433 | hwif->irq = hwif->channel ? 15 : 14; | ||
434 | } | ||
435 | #endif | ||
436 | |||
437 | for (i = 0; i < 2; i++) { | ||
438 | hwif->drives[i].io_32bit = 1; | ||
439 | hwif->drives[i].unmask = (vdev->via_config->flags & VIA_NO_UNMASK) ? 0 : 1; | ||
440 | } | ||
441 | |||
442 | if (!hwif->dma_base) | 428 | if (!hwif->dma_base) |
443 | return; | 429 | return; |
444 | 430 | ||
445 | hwif->ultra_mask = vdev->via_config->udma_mask; | ||
446 | |||
447 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 431 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
448 | hwif->cbl = via82cxxx_cable_detect(hwif); | 432 | hwif->cbl = via82cxxx_cable_detect(hwif); |
449 | } | 433 | } |
450 | 434 | ||
451 | static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = { | 435 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { |
452 | { /* 0 */ | 436 | .name = "VP_IDE", |
453 | .name = "VP_IDE", | 437 | .init_chipset = init_chipset_via82cxxx, |
454 | .init_chipset = init_chipset_via82cxxx, | 438 | .init_hwif = init_hwif_via82cxxx, |
455 | .init_hwif = init_hwif_via82cxxx, | 439 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, |
456 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, | 440 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | |
457 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | | 441 | IDE_HFLAG_PIO_NO_DOWNGRADE | |
458 | IDE_HFLAG_PIO_NO_DOWNGRADE | | 442 | IDE_HFLAG_POST_SET_MODE | |
459 | IDE_HFLAG_POST_SET_MODE | | 443 | IDE_HFLAG_IO_32BIT | |
460 | IDE_HFLAG_NO_AUTODMA | | 444 | IDE_HFLAG_BOOTABLE, |
461 | IDE_HFLAG_BOOTABLE, | 445 | .pio_mask = ATA_PIO5, |
462 | .pio_mask = ATA_PIO5, | 446 | .swdma_mask = ATA_SWDMA2, |
463 | .swdma_mask = ATA_SWDMA2, | 447 | .mwdma_mask = ATA_MWDMA2, |
464 | .mwdma_mask = ATA_MWDMA2, | ||
465 | },{ /* 1 */ | ||
466 | .name = "VP_IDE", | ||
467 | .init_chipset = init_chipset_via82cxxx, | ||
468 | .init_hwif = init_hwif_via82cxxx, | ||
469 | .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, | ||
470 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | | ||
471 | IDE_HFLAG_PIO_NO_DOWNGRADE | | ||
472 | IDE_HFLAG_POST_SET_MODE | | ||
473 | IDE_HFLAG_BOOTABLE, | ||
474 | .pio_mask = ATA_PIO5, | ||
475 | .swdma_mask = ATA_SWDMA2, | ||
476 | .mwdma_mask = ATA_MWDMA2, | ||
477 | } | ||
478 | }; | 448 | }; |
479 | 449 | ||
480 | static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 450 | static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
481 | { | 451 | { |
482 | struct pci_dev *isa = NULL; | 452 | struct pci_dev *isa = NULL; |
483 | struct via_isa_bridge *via_config; | 453 | struct via_isa_bridge *via_config; |
454 | u8 idx = id->driver_data; | ||
455 | struct ide_port_info d; | ||
456 | |||
457 | d = via82cxxx_chipset; | ||
458 | |||
484 | /* | 459 | /* |
485 | * Find the ISA bridge and check we know what it is. | 460 | * Find the ISA bridge and check we know what it is. |
486 | */ | 461 | */ |
@@ -490,7 +465,23 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
490 | printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); | 465 | printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); |
491 | return -ENODEV; | 466 | return -ENODEV; |
492 | } | 467 | } |
493 | return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]); | 468 | |
469 | if (idx == 0) | ||
470 | d.host_flags |= IDE_HFLAG_NO_AUTODMA; | ||
471 | else | ||
472 | d.enablebits[1].reg = d.enablebits[0].reg = 0; | ||
473 | |||
474 | if ((via_config->flags & VIA_NO_UNMASK) == 0) | ||
475 | d.host_flags |= IDE_HFLAG_UNMASK_IRQS; | ||
476 | |||
477 | #ifdef CONFIG_PPC_CHRP | ||
478 | if (machine_is(chrp) && _chrp_type == _CHRP_Pegasos) | ||
479 | d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS; | ||
480 | #endif | ||
481 | |||
482 | d.udma_mask = via_config->udma_mask; | ||
483 | |||
484 | return ide_setup_pci_device(dev, &d); | ||
494 | } | 485 | } |
495 | 486 | ||
496 | static const struct pci_device_id via_pci_tbl[] = { | 487 | static const struct pci_device_id via_pci_tbl[] = { |
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c index df2e92034f5d..5f0da35ab5ad 100644 --- a/drivers/ide/ppc/mpc8xx.c +++ b/drivers/ide/ppc/mpc8xx.c | |||
@@ -316,8 +316,8 @@ m8xx_ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, | |||
316 | 316 | ||
317 | ide_hwifs[data_port].pio_mask = ATA_PIO4; | 317 | ide_hwifs[data_port].pio_mask = ATA_PIO4; |
318 | ide_hwifs[data_port].set_pio_mode = m8xx_ide_set_pio_mode; | 318 | ide_hwifs[data_port].set_pio_mode = m8xx_ide_set_pio_mode; |
319 | ide_hwifs[data_port].ack_intr = (ide_ack_intr_t *)ide_interrupt_ack; | ||
319 | 320 | ||
320 | hw->ack_intr = (ide_ack_intr_t *) ide_interrupt_ack; | ||
321 | /* Enable Harddisk Interrupt, | 321 | /* Enable Harddisk Interrupt, |
322 | * and make it edge sensitive | 322 | * and make it edge sensitive |
323 | */ | 323 | */ |
@@ -402,8 +402,8 @@ void m8xx_ide_init_hwif_ports (hw_regs_t *hw, | |||
402 | 402 | ||
403 | ide_hwifs[data_port].pio_mask = ATA_PIO4; | 403 | ide_hwifs[data_port].pio_mask = ATA_PIO4; |
404 | ide_hwifs[data_port].set_pio_mode = m8xx_ide_set_pio_mode; | 404 | ide_hwifs[data_port].set_pio_mode = m8xx_ide_set_pio_mode; |
405 | ide_hwifs[data_port].ack_intr = (ide_ack_intr_t *)ide_interrupt_ack; | ||
405 | 406 | ||
406 | hw->ack_intr = (ide_ack_intr_t *) ide_interrupt_ack; | ||
407 | /* Enable Harddisk Interrupt, | 407 | /* Enable Harddisk Interrupt, |
408 | * and make it edge sensitive | 408 | * and make it edge sensitive |
409 | */ | 409 | */ |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index c55479356768..816b5311dad6 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -1039,6 +1039,8 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
1039 | { | 1039 | { |
1040 | struct device_node *np = pmif->node; | 1040 | struct device_node *np = pmif->node; |
1041 | const int *bidp; | 1041 | const int *bidp; |
1042 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
1043 | hw_regs_t hw; | ||
1042 | 1044 | ||
1043 | pmif->cable_80 = 0; | 1045 | pmif->cable_80 = 0; |
1044 | pmif->broken_dma = pmif->broken_dma_warn = 0; | 1046 | pmif->broken_dma = pmif->broken_dma_warn = 0; |
@@ -1124,8 +1126,9 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
1124 | /* Tell common code _not_ to mess with resources */ | 1126 | /* Tell common code _not_ to mess with resources */ |
1125 | hwif->mmio = 1; | 1127 | hwif->mmio = 1; |
1126 | hwif->hwif_data = pmif; | 1128 | hwif->hwif_data = pmif; |
1127 | pmac_ide_init_hwif_ports(&hwif->hw, pmif->regbase, 0, &hwif->irq); | 1129 | memset(&hw, 0, sizeof(hw)); |
1128 | memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports)); | 1130 | pmac_ide_init_hwif_ports(&hw, pmif->regbase, 0, &hwif->irq); |
1131 | memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports)); | ||
1129 | hwif->chipset = ide_pmac; | 1132 | hwif->chipset = ide_pmac; |
1130 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || pmif->mediabay; | 1133 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || pmif->mediabay; |
1131 | hwif->hold = pmif->mediabay; | 1134 | hwif->hold = pmif->mediabay; |
@@ -1163,10 +1166,9 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
1163 | pmac_ide_setup_dma(pmif, hwif); | 1166 | pmac_ide_setup_dma(pmif, hwif); |
1164 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 1167 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
1165 | 1168 | ||
1166 | /* We probe the hwif now */ | 1169 | idx[0] = hwif->index; |
1167 | probe_hwif_init(hwif); | ||
1168 | 1170 | ||
1169 | ide_proc_register_port(hwif); | 1171 | ide_device_add(idx); |
1170 | 1172 | ||
1171 | return 0; | 1173 | return 0; |
1172 | } | 1174 | } |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index fff567bcedbe..02d14bf85ab2 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -147,15 +147,15 @@ static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) | |||
147 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 147 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
148 | /** | 148 | /** |
149 | * ide_get_or_set_dma_base - setup BMIBA | 149 | * ide_get_or_set_dma_base - setup BMIBA |
150 | * @d: IDE pci device data | 150 | * @d: IDE port info |
151 | * @hwif: Interface | 151 | * @hwif: IDE interface |
152 | * | 152 | * |
153 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. | 153 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. |
154 | * Where a device has a partner that is already in DMA mode we check | 154 | * Where a device has a partner that is already in DMA mode we check |
155 | * and enforce IDE simplex rules. | 155 | * and enforce IDE simplex rules. |
156 | */ | 156 | */ |
157 | 157 | ||
158 | static unsigned long ide_get_or_set_dma_base(ide_pci_device_t *d, ide_hwif_t *hwif) | 158 | static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) |
159 | { | 159 | { |
160 | unsigned long dma_base = 0; | 160 | unsigned long dma_base = 0; |
161 | struct pci_dev *dev = hwif->pci_dev; | 161 | struct pci_dev *dev = hwif->pci_dev; |
@@ -225,10 +225,11 @@ static unsigned long ide_get_or_set_dma_base(ide_pci_device_t *d, ide_hwif_t *hw | |||
225 | } | 225 | } |
226 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 226 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
227 | 227 | ||
228 | void ide_setup_pci_noise (struct pci_dev *dev, ide_pci_device_t *d) | 228 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) |
229 | { | 229 | { |
230 | printk(KERN_INFO "%s: IDE controller at PCI slot %s\n", | 230 | printk(KERN_INFO "%s: IDE controller (0x%04x:0x%04x rev 0x%02x) at " |
231 | d->name, pci_name(dev)); | 231 | " PCI slot %s\n", d->name, dev->vendor, dev->device, |
232 | dev->revision, pci_name(dev)); | ||
232 | } | 233 | } |
233 | 234 | ||
234 | EXPORT_SYMBOL_GPL(ide_setup_pci_noise); | 235 | EXPORT_SYMBOL_GPL(ide_setup_pci_noise); |
@@ -237,15 +238,15 @@ EXPORT_SYMBOL_GPL(ide_setup_pci_noise); | |||
237 | /** | 238 | /** |
238 | * ide_pci_enable - do PCI enables | 239 | * ide_pci_enable - do PCI enables |
239 | * @dev: PCI device | 240 | * @dev: PCI device |
240 | * @d: IDE pci device data | 241 | * @d: IDE port info |
241 | * | 242 | * |
242 | * Enable the IDE PCI device. We attempt to enable the device in full | 243 | * Enable the IDE PCI device. We attempt to enable the device in full |
243 | * but if that fails then we only need BAR4 so we will enable that. | 244 | * but if that fails then we only need BAR4 so we will enable that. |
244 | * | 245 | * |
245 | * Returns zero on success or an error code | 246 | * Returns zero on success or an error code |
246 | */ | 247 | */ |
247 | 248 | ||
248 | static int ide_pci_enable(struct pci_dev *dev, ide_pci_device_t *d) | 249 | static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) |
249 | { | 250 | { |
250 | int ret; | 251 | int ret; |
251 | 252 | ||
@@ -260,9 +261,9 @@ static int ide_pci_enable(struct pci_dev *dev, ide_pci_device_t *d) | |||
260 | } | 261 | } |
261 | 262 | ||
262 | /* | 263 | /* |
263 | * assume all devices can do 32-bit dma for now. we can add a | 264 | * assume all devices can do 32-bit DMA for now, we can add |
264 | * dma mask field to the ide_pci_device_t if we need it (or let | 265 | * a DMA mask field to the struct ide_port_info if we need it |
265 | * lower level driver set the dma mask) | 266 | * (or let lower level driver set the DMA mask) |
266 | */ | 267 | */ |
267 | ret = pci_set_dma_mask(dev, DMA_32BIT_MASK); | 268 | ret = pci_set_dma_mask(dev, DMA_32BIT_MASK); |
268 | if (ret < 0) { | 269 | if (ret < 0) { |
@@ -284,13 +285,13 @@ out: | |||
284 | /** | 285 | /** |
285 | * ide_pci_configure - configure an unconfigured device | 286 | * ide_pci_configure - configure an unconfigured device |
286 | * @dev: PCI device | 287 | * @dev: PCI device |
287 | * @d: IDE pci device data | 288 | * @d: IDE port info |
288 | * | 289 | * |
289 | * Enable and configure the PCI device we have been passed. | 290 | * Enable and configure the PCI device we have been passed. |
290 | * Returns zero on success or an error code. | 291 | * Returns zero on success or an error code. |
291 | */ | 292 | */ |
292 | 293 | ||
293 | static int ide_pci_configure(struct pci_dev *dev, ide_pci_device_t *d) | 294 | static int ide_pci_configure(struct pci_dev *dev, const struct ide_port_info *d) |
294 | { | 295 | { |
295 | u16 pcicmd = 0; | 296 | u16 pcicmd = 0; |
296 | /* | 297 | /* |
@@ -318,15 +319,15 @@ static int ide_pci_configure(struct pci_dev *dev, ide_pci_device_t *d) | |||
318 | 319 | ||
319 | /** | 320 | /** |
320 | * ide_pci_check_iomem - check a register is I/O | 321 | * ide_pci_check_iomem - check a register is I/O |
321 | * @dev: pci device | 322 | * @dev: PCI device |
322 | * @d: ide_pci_device | 323 | * @d: IDE port info |
323 | * @bar: bar number | 324 | * @bar: BAR number |
324 | * | 325 | * |
325 | * Checks if a BAR is configured and points to MMIO space. If so | 326 | * Checks if a BAR is configured and points to MMIO space. If so |
326 | * print an error and return an error code. Otherwise return 0 | 327 | * print an error and return an error code. Otherwise return 0 |
327 | */ | 328 | */ |
328 | 329 | ||
329 | static int ide_pci_check_iomem(struct pci_dev *dev, ide_pci_device_t *d, int bar) | 330 | static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *d, int bar) |
330 | { | 331 | { |
331 | ulong flags = pci_resource_flags(dev, bar); | 332 | ulong flags = pci_resource_flags(dev, bar); |
332 | 333 | ||
@@ -348,7 +349,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, ide_pci_device_t *d, int bar | |||
348 | /** | 349 | /** |
349 | * ide_hwif_configure - configure an IDE interface | 350 | * ide_hwif_configure - configure an IDE interface |
350 | * @dev: PCI device holding interface | 351 | * @dev: PCI device holding interface |
351 | * @d: IDE pci data | 352 | * @d: IDE port info |
352 | * @mate: Paired interface if any | 353 | * @mate: Paired interface if any |
353 | * | 354 | * |
354 | * Perform the initial set up for the hardware interface structure. This | 355 | * Perform the initial set up for the hardware interface structure. This |
@@ -357,8 +358,8 @@ static int ide_pci_check_iomem(struct pci_dev *dev, ide_pci_device_t *d, int bar | |||
357 | * | 358 | * |
358 | * Returns the new hardware interface structure, or NULL on a failure | 359 | * Returns the new hardware interface structure, or NULL on a failure |
359 | */ | 360 | */ |
360 | 361 | ||
361 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, ide_pci_device_t *d, ide_hwif_t *mate, int port, int irq) | 362 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *mate, int port, int irq) |
362 | { | 363 | { |
363 | unsigned long ctl = 0, base = 0; | 364 | unsigned long ctl = 0, base = 0; |
364 | ide_hwif_t *hwif; | 365 | ide_hwif_t *hwif; |
@@ -387,19 +388,20 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, ide_pci_device_t *d, | |||
387 | return NULL; /* no room in ide_hwifs[] */ | 388 | return NULL; /* no room in ide_hwifs[] */ |
388 | if (hwif->io_ports[IDE_DATA_OFFSET] != base || | 389 | if (hwif->io_ports[IDE_DATA_OFFSET] != base || |
389 | hwif->io_ports[IDE_CONTROL_OFFSET] != (ctl | 2)) { | 390 | hwif->io_ports[IDE_CONTROL_OFFSET] != (ctl | 2)) { |
390 | memset(&hwif->hw, 0, sizeof(hwif->hw)); | 391 | hw_regs_t hw; |
391 | #ifndef IDE_ARCH_OBSOLETE_INIT | 392 | |
392 | ide_std_init_ports(&hwif->hw, base, (ctl | 2)); | 393 | memset(&hw, 0, sizeof(hw)); |
393 | hwif->hw.io_ports[IDE_IRQ_OFFSET] = 0; | 394 | #ifndef CONFIG_IDE_ARCH_OBSOLETE_INIT |
395 | ide_std_init_ports(&hw, base, ctl | 2); | ||
394 | #else | 396 | #else |
395 | ide_init_hwif_ports(&hwif->hw, base, (ctl | 2), NULL); | 397 | ide_init_hwif_ports(&hw, base, ctl | 2, NULL); |
396 | #endif | 398 | #endif |
397 | memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports)); | 399 | memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports)); |
398 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; | 400 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; |
399 | } | 401 | } |
400 | hwif->chipset = ide_pci; | 402 | hwif->chipset = d->chipset ? d->chipset : ide_pci; |
401 | hwif->pci_dev = dev; | 403 | hwif->pci_dev = dev; |
402 | hwif->cds = (struct ide_pci_device_s *) d; | 404 | hwif->cds = d; |
403 | hwif->channel = port; | 405 | hwif->channel = port; |
404 | 406 | ||
405 | if (!hwif->irq) | 407 | if (!hwif->irq) |
@@ -414,21 +416,17 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, ide_pci_device_t *d, | |||
414 | /** | 416 | /** |
415 | * ide_hwif_setup_dma - configure DMA interface | 417 | * ide_hwif_setup_dma - configure DMA interface |
416 | * @dev: PCI device | 418 | * @dev: PCI device |
417 | * @d: IDE pci data | 419 | * @d: IDE port info |
418 | * @hwif: Hardware interface we are configuring | 420 | * @hwif: IDE interface |
419 | * | 421 | * |
420 | * Set up the DMA base for the interface. Enable the master bits as | 422 | * Set up the DMA base for the interface. Enable the master bits as |
421 | * necessary and attempt to bring the device DMA into a ready to use | 423 | * necessary and attempt to bring the device DMA into a ready to use |
422 | * state | 424 | * state |
423 | */ | 425 | */ |
424 | 426 | ||
425 | #ifndef CONFIG_BLK_DEV_IDEDMA_PCI | 427 | static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *hwif) |
426 | static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwif_t *hwif) | ||
427 | { | ||
428 | } | ||
429 | #else | ||
430 | static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwif_t *hwif) | ||
431 | { | 428 | { |
429 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
432 | u16 pcicmd; | 430 | u16 pcicmd; |
433 | 431 | ||
434 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | 432 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); |
@@ -460,13 +458,13 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwi | |||
460 | "(BIOS)\n", hwif->name, d->name); | 458 | "(BIOS)\n", hwif->name, d->name); |
461 | } | 459 | } |
462 | } | 460 | } |
463 | } | ||
464 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI*/ | 461 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI*/ |
462 | } | ||
465 | 463 | ||
466 | /** | 464 | /** |
467 | * ide_setup_pci_controller - set up IDE PCI | 465 | * ide_setup_pci_controller - set up IDE PCI |
468 | * @dev: PCI device | 466 | * @dev: PCI device |
469 | * @d: IDE PCI data | 467 | * @d: IDE port info |
470 | * @noisy: verbose flag | 468 | * @noisy: verbose flag |
471 | * @config: returned as 1 if we configured the hardware | 469 | * @config: returned as 1 if we configured the hardware |
472 | * | 470 | * |
@@ -474,8 +472,8 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwi | |||
474 | * up the PCI side of the device, checks that the device is enabled | 472 | * up the PCI side of the device, checks that the device is enabled |
475 | * and enables it if need be | 473 | * and enables it if need be |
476 | */ | 474 | */ |
477 | 475 | ||
478 | static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, int noisy, int *config) | 476 | static int ide_setup_pci_controller(struct pci_dev *dev, const struct ide_port_info *d, int noisy, int *config) |
479 | { | 477 | { |
480 | int ret; | 478 | int ret; |
481 | u16 pcicmd; | 479 | u16 pcicmd; |
@@ -500,9 +498,6 @@ static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, in | |||
500 | printk(KERN_INFO "%s: device enabled (Linux)\n", d->name); | 498 | printk(KERN_INFO "%s: device enabled (Linux)\n", d->name); |
501 | } | 499 | } |
502 | 500 | ||
503 | if (noisy) | ||
504 | printk(KERN_INFO "%s: chipset revision %d\n", | ||
505 | d->name, dev->revision); | ||
506 | out: | 501 | out: |
507 | return ret; | 502 | return ret; |
508 | } | 503 | } |
@@ -510,9 +505,9 @@ out: | |||
510 | /** | 505 | /** |
511 | * ide_pci_setup_ports - configure ports/devices on PCI IDE | 506 | * ide_pci_setup_ports - configure ports/devices on PCI IDE |
512 | * @dev: PCI device | 507 | * @dev: PCI device |
513 | * @d: IDE pci device info | 508 | * @d: IDE port info |
514 | * @pciirq: IRQ line | 509 | * @pciirq: IRQ line |
515 | * @index: ata index to update | 510 | * @idx: ATA index table to update |
516 | * | 511 | * |
517 | * Scan the interfaces attached to this device and do any | 512 | * Scan the interfaces attached to this device and do any |
518 | * necessary per port setup. Attach the devices and ask the | 513 | * necessary per port setup. Attach the devices and ask the |
@@ -522,26 +517,25 @@ out: | |||
522 | * but is also used directly as a helper function by some controllers | 517 | * but is also used directly as a helper function by some controllers |
523 | * where the chipset setup is not the default PCI IDE one. | 518 | * where the chipset setup is not the default PCI IDE one. |
524 | */ | 519 | */ |
525 | 520 | ||
526 | void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, ata_index_t *index) | 521 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) |
527 | { | 522 | { |
528 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; | 523 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; |
529 | int at_least_one_hwif_enabled = 0; | ||
530 | ide_hwif_t *hwif, *mate = NULL; | 524 | ide_hwif_t *hwif, *mate = NULL; |
531 | u8 tmp; | 525 | u8 tmp; |
532 | 526 | ||
533 | index->all = 0xf0f0; | ||
534 | |||
535 | /* | 527 | /* |
536 | * Set up the IDE ports | 528 | * Set up the IDE ports |
537 | */ | 529 | */ |
538 | 530 | ||
539 | for (port = 0; port < channels; ++port) { | 531 | for (port = 0; port < channels; ++port) { |
540 | ide_pci_enablebit_t *e = &(d->enablebits[port]); | 532 | const ide_pci_enablebit_t *e = &(d->enablebits[port]); |
541 | 533 | ||
542 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || | 534 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || |
543 | (tmp & e->mask) != e->val)) | 535 | (tmp & e->mask) != e->val)) { |
536 | printk(KERN_INFO "%s: IDE port disabled\n", d->name); | ||
544 | continue; /* port not enabled */ | 537 | continue; /* port not enabled */ |
538 | } | ||
545 | 539 | ||
546 | if ((hwif = ide_hwif_configure(dev, d, mate, port, pciirq)) == NULL) | 540 | if ((hwif = ide_hwif_configure(dev, d, mate, port, pciirq)) == NULL) |
547 | continue; | 541 | continue; |
@@ -549,11 +543,7 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a | |||
549 | /* setup proper ancestral information */ | 543 | /* setup proper ancestral information */ |
550 | hwif->gendev.parent = &dev->dev; | 544 | hwif->gendev.parent = &dev->dev; |
551 | 545 | ||
552 | if (hwif->channel) { | 546 | *(idx + port) = hwif->index; |
553 | index->b.high = hwif->index; | ||
554 | } else { | ||
555 | index->b.low = hwif->index; | ||
556 | } | ||
557 | 547 | ||
558 | 548 | ||
559 | if (d->init_iops) | 549 | if (d->init_iops) |
@@ -562,15 +552,28 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a | |||
562 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) | 552 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) |
563 | ide_hwif_setup_dma(dev, d, hwif); | 553 | ide_hwif_setup_dma(dev, d, hwif); |
564 | 554 | ||
565 | if ((d->host_flags & IDE_HFLAG_LEGACY_IRQS) && hwif->irq == 0) | 555 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || |
556 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) | ||
566 | hwif->irq = port ? 15 : 14; | 557 | hwif->irq = port ? 15 : 14; |
567 | 558 | ||
559 | hwif->fixup = d->fixup; | ||
560 | |||
568 | hwif->host_flags = d->host_flags; | 561 | hwif->host_flags = d->host_flags; |
569 | hwif->pio_mask = d->pio_mask; | 562 | hwif->pio_mask = d->pio_mask; |
570 | 563 | ||
571 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) | 564 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) |
572 | hwif->mate->serialized = hwif->serialized = 1; | 565 | hwif->mate->serialized = hwif->serialized = 1; |
573 | 566 | ||
567 | if (d->host_flags & IDE_HFLAG_IO_32BIT) { | ||
568 | hwif->drives[0].io_32bit = 1; | ||
569 | hwif->drives[1].io_32bit = 1; | ||
570 | } | ||
571 | |||
572 | if (d->host_flags & IDE_HFLAG_UNMASK_IRQS) { | ||
573 | hwif->drives[0].unmask = 1; | ||
574 | hwif->drives[1].unmask = 1; | ||
575 | } | ||
576 | |||
574 | if (hwif->dma_base) { | 577 | if (hwif->dma_base) { |
575 | hwif->swdma_mask = d->swdma_mask; | 578 | hwif->swdma_mask = d->swdma_mask; |
576 | hwif->mwdma_mask = d->mwdma_mask; | 579 | hwif->mwdma_mask = d->mwdma_mask; |
@@ -580,6 +583,9 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a | |||
580 | hwif->drives[0].autotune = 1; | 583 | hwif->drives[0].autotune = 1; |
581 | hwif->drives[1].autotune = 1; | 584 | hwif->drives[1].autotune = 1; |
582 | 585 | ||
586 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) | ||
587 | hwif->rqsize = 256; | ||
588 | |||
583 | if (d->init_hwif) | 589 | if (d->init_hwif) |
584 | /* Call chipset-specific routine | 590 | /* Call chipset-specific routine |
585 | * for each enabled hwif | 591 | * for each enabled hwif |
@@ -587,10 +593,7 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a | |||
587 | d->init_hwif(hwif); | 593 | d->init_hwif(hwif); |
588 | 594 | ||
589 | mate = hwif; | 595 | mate = hwif; |
590 | at_least_one_hwif_enabled = 1; | ||
591 | } | 596 | } |
592 | if (!at_least_one_hwif_enabled) | ||
593 | printk(KERN_INFO "%s: neither IDE port enabled (BIOS)\n", d->name); | ||
594 | } | 597 | } |
595 | 598 | ||
596 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); | 599 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); |
@@ -602,13 +605,13 @@ EXPORT_SYMBOL_GPL(ide_pci_setup_ports); | |||
602 | * | 605 | * |
603 | * One thing that is not standardized is the location of the | 606 | * One thing that is not standardized is the location of the |
604 | * primary/secondary interface "enable/disable" bits. For chipsets that | 607 | * primary/secondary interface "enable/disable" bits. For chipsets that |
605 | * we "know" about, this information is in the ide_pci_device_t struct; | 608 | * we "know" about, this information is in the struct ide_port_info; |
606 | * for all other chipsets, we just assume both interfaces are enabled. | 609 | * for all other chipsets, we just assume both interfaces are enabled. |
607 | */ | 610 | */ |
608 | static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, | 611 | static int do_ide_setup_pci_device(struct pci_dev *dev, |
609 | ata_index_t *index, u8 noisy) | 612 | const struct ide_port_info *d, |
613 | u8 *idx, u8 noisy) | ||
610 | { | 614 | { |
611 | static ata_index_t ata_index = { .b = { .low = 0xff, .high = 0xff } }; | ||
612 | int tried_config = 0; | 615 | int tried_config = 0; |
613 | int pciirq, ret; | 616 | int pciirq, ret; |
614 | 617 | ||
@@ -658,51 +661,35 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, | |||
658 | 661 | ||
659 | /* FIXME: silent failure can happen */ | 662 | /* FIXME: silent failure can happen */ |
660 | 663 | ||
661 | *index = ata_index; | 664 | ide_pci_setup_ports(dev, d, pciirq, idx); |
662 | ide_pci_setup_ports(dev, d, pciirq, index); | ||
663 | out: | 665 | out: |
664 | return ret; | 666 | return ret; |
665 | } | 667 | } |
666 | 668 | ||
667 | int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d) | 669 | int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) |
668 | { | 670 | { |
669 | ide_hwif_t *hwif = NULL, *mate = NULL; | 671 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
670 | ata_index_t index_list; | ||
671 | int ret; | 672 | int ret; |
672 | 673 | ||
673 | ret = do_ide_setup_pci_device(dev, d, &index_list, 1); | 674 | ret = do_ide_setup_pci_device(dev, d, &idx[0], 1); |
674 | if (ret < 0) | ||
675 | goto out; | ||
676 | 675 | ||
677 | if ((index_list.b.low & 0xf0) != 0xf0) | 676 | if (ret >= 0) |
678 | hwif = &ide_hwifs[index_list.b.low]; | 677 | ide_device_add(idx); |
679 | if ((index_list.b.high & 0xf0) != 0xf0) | ||
680 | mate = &ide_hwifs[index_list.b.high]; | ||
681 | 678 | ||
682 | if (hwif) | ||
683 | probe_hwif_init_with_fixup(hwif, d->fixup); | ||
684 | if (mate) | ||
685 | probe_hwif_init_with_fixup(mate, d->fixup); | ||
686 | |||
687 | if (hwif) | ||
688 | ide_proc_register_port(hwif); | ||
689 | if (mate) | ||
690 | ide_proc_register_port(mate); | ||
691 | out: | ||
692 | return ret; | 679 | return ret; |
693 | } | 680 | } |
694 | 681 | ||
695 | EXPORT_SYMBOL_GPL(ide_setup_pci_device); | 682 | EXPORT_SYMBOL_GPL(ide_setup_pci_device); |
696 | 683 | ||
697 | int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | 684 | int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, |
698 | ide_pci_device_t *d) | 685 | const struct ide_port_info *d) |
699 | { | 686 | { |
700 | struct pci_dev *pdev[] = { dev1, dev2 }; | 687 | struct pci_dev *pdev[] = { dev1, dev2 }; |
701 | ata_index_t index_list[2]; | ||
702 | int ret, i; | 688 | int ret, i; |
689 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
703 | 690 | ||
704 | for (i = 0; i < 2; i++) { | 691 | for (i = 0; i < 2; i++) { |
705 | ret = do_ide_setup_pci_device(pdev[i], d, index_list + i, !i); | 692 | ret = do_ide_setup_pci_device(pdev[i], d, &idx[i*2], !i); |
706 | /* | 693 | /* |
707 | * FIXME: Mom, mom, they stole me the helper function to undo | 694 | * FIXME: Mom, mom, they stole me the helper function to undo |
708 | * do_ide_setup_pci_device() on the first device! | 695 | * do_ide_setup_pci_device() on the first device! |
@@ -711,25 +698,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |||
711 | goto out; | 698 | goto out; |
712 | } | 699 | } |
713 | 700 | ||
714 | for (i = 0; i < 2; i++) { | 701 | ide_device_add(idx); |
715 | u8 idx[2] = { index_list[i].b.low, index_list[i].b.high }; | ||
716 | int j; | ||
717 | |||
718 | for (j = 0; j < 2; j++) { | ||
719 | if ((idx[j] & 0xf0) != 0xf0) | ||
720 | probe_hwif_init(ide_hwifs + idx[j]); | ||
721 | } | ||
722 | } | ||
723 | |||
724 | for (i = 0; i < 2; i++) { | ||
725 | u8 idx[2] = { index_list[i].b.low, index_list[i].b.high }; | ||
726 | int j; | ||
727 | |||
728 | for (j = 0; j < 2; j++) { | ||
729 | if ((idx[j] & 0xf0) != 0xf0) | ||
730 | ide_proc_register_port(ide_hwifs + idx[j]); | ||
731 | } | ||
732 | } | ||
733 | out: | 702 | out: |
734 | return ret; | 703 | return ret; |
735 | } | 704 | } |
@@ -754,9 +723,6 @@ static LIST_HEAD(ide_pci_drivers); | |||
754 | * hands the controllers off to the core PCI code to do the rest of | 723 | * hands the controllers off to the core PCI code to do the rest of |
755 | * the work. | 724 | * the work. |
756 | * | 725 | * |
757 | * The driver_data of the driver table must point to an ide_pci_device_t | ||
758 | * describing the interface. | ||
759 | * | ||
760 | * Returns are the same as for pci_register_driver | 726 | * Returns are the same as for pci_register_driver |
761 | */ | 727 | */ |
762 | 728 | ||
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 93644f82592c..d08fb30768bc 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -2797,11 +2797,12 @@ static void cma_remove_one(struct ib_device *device) | |||
2797 | 2797 | ||
2798 | static int cma_init(void) | 2798 | static int cma_init(void) |
2799 | { | 2799 | { |
2800 | int ret, low, high; | 2800 | int ret, low, high, remaining; |
2801 | 2801 | ||
2802 | get_random_bytes(&next_port, sizeof next_port); | 2802 | get_random_bytes(&next_port, sizeof next_port); |
2803 | inet_get_local_port_range(&low, &high); | 2803 | inet_get_local_port_range(&low, &high); |
2804 | next_port = ((unsigned int) next_port % (high - low)) + low; | 2804 | remaining = (high - low) + 1; |
2805 | next_port = ((unsigned int) next_port % remaining) + low; | ||
2805 | 2806 | ||
2806 | cma_wq = create_singlethread_workqueue("rdma_cm"); | 2807 | cma_wq = create_singlethread_workqueue("rdma_cm"); |
2807 | if (!cma_wq) | 2808 | if (!cma_wq) |
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 1d62c8b88e12..e5b4e9bfbdc5 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -495,7 +495,7 @@ static unsigned int evdev_poll(struct file *file, poll_table *wait) | |||
495 | #ifdef CONFIG_COMPAT | 495 | #ifdef CONFIG_COMPAT |
496 | 496 | ||
497 | #define BITS_PER_LONG_COMPAT (sizeof(compat_long_t) * 8) | 497 | #define BITS_PER_LONG_COMPAT (sizeof(compat_long_t) * 8) |
498 | #define NBITS_COMPAT(x) ((((x) - 1) / BITS_PER_LONG_COMPAT) + 1) | 498 | #define BITS_TO_LONGS_COMPAT(x) ((((x) - 1) / BITS_PER_LONG_COMPAT) + 1) |
499 | 499 | ||
500 | #ifdef __BIG_ENDIAN | 500 | #ifdef __BIG_ENDIAN |
501 | static int bits_to_user(unsigned long *bits, unsigned int maxbit, | 501 | static int bits_to_user(unsigned long *bits, unsigned int maxbit, |
@@ -504,7 +504,7 @@ static int bits_to_user(unsigned long *bits, unsigned int maxbit, | |||
504 | int len, i; | 504 | int len, i; |
505 | 505 | ||
506 | if (compat) { | 506 | if (compat) { |
507 | len = NBITS_COMPAT(maxbit) * sizeof(compat_long_t); | 507 | len = BITS_TO_LONGS_COMPAT(maxbit) * sizeof(compat_long_t); |
508 | if (len > maxlen) | 508 | if (len > maxlen) |
509 | len = maxlen; | 509 | len = maxlen; |
510 | 510 | ||
@@ -515,7 +515,7 @@ static int bits_to_user(unsigned long *bits, unsigned int maxbit, | |||
515 | sizeof(compat_long_t))) | 515 | sizeof(compat_long_t))) |
516 | return -EFAULT; | 516 | return -EFAULT; |
517 | } else { | 517 | } else { |
518 | len = NBITS(maxbit) * sizeof(long); | 518 | len = BITS_TO_LONGS(maxbit) * sizeof(long); |
519 | if (len > maxlen) | 519 | if (len > maxlen) |
520 | len = maxlen; | 520 | len = maxlen; |
521 | 521 | ||
@@ -530,8 +530,8 @@ static int bits_to_user(unsigned long *bits, unsigned int maxbit, | |||
530 | unsigned int maxlen, void __user *p, int compat) | 530 | unsigned int maxlen, void __user *p, int compat) |
531 | { | 531 | { |
532 | int len = compat ? | 532 | int len = compat ? |
533 | NBITS_COMPAT(maxbit) * sizeof(compat_long_t) : | 533 | BITS_TO_LONGS_COMPAT(maxbit) * sizeof(compat_long_t) : |
534 | NBITS(maxbit) * sizeof(long); | 534 | BITS_TO_LONGS(maxbit) * sizeof(long); |
535 | 535 | ||
536 | if (len > maxlen) | 536 | if (len > maxlen) |
537 | len = maxlen; | 537 | len = maxlen; |
@@ -545,7 +545,7 @@ static int bits_to_user(unsigned long *bits, unsigned int maxbit, | |||
545 | static int bits_to_user(unsigned long *bits, unsigned int maxbit, | 545 | static int bits_to_user(unsigned long *bits, unsigned int maxbit, |
546 | unsigned int maxlen, void __user *p, int compat) | 546 | unsigned int maxlen, void __user *p, int compat) |
547 | { | 547 | { |
548 | int len = NBITS(maxbit) * sizeof(long); | 548 | int len = BITS_TO_LONGS(maxbit) * sizeof(long); |
549 | 549 | ||
550 | if (len > maxlen) | 550 | if (len > maxlen) |
551 | len = maxlen; | 551 | len = maxlen; |
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index ec1b6cfefcd3..bfc6061f1554 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c | |||
@@ -136,7 +136,8 @@ static int gameport_measure_speed(struct gameport *gameport) | |||
136 | } | 136 | } |
137 | 137 | ||
138 | gameport_close(gameport); | 138 | gameport_close(gameport); |
139 | return (cpu_data[raw_smp_processor_id()].loops_per_jiffy * (unsigned long)HZ / (1000 / 50)) / (tx < 1 ? 1 : tx); | 139 | return (cpu_data(raw_smp_processor_id()).loops_per_jiffy * |
140 | (unsigned long)HZ / (1000 / 50)) / (tx < 1 ? 1 : tx); | ||
140 | 141 | ||
141 | #else | 142 | #else |
142 | 143 | ||
diff --git a/drivers/input/input.c b/drivers/input/input.c index 2f2b020cd629..307c7b5c2b33 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -584,10 +584,10 @@ static int input_default_setkeycode(struct input_dev *dev, | |||
584 | 584 | ||
585 | 585 | ||
586 | #define MATCH_BIT(bit, max) \ | 586 | #define MATCH_BIT(bit, max) \ |
587 | for (i = 0; i < NBITS(max); i++) \ | 587 | for (i = 0; i < BITS_TO_LONGS(max); i++) \ |
588 | if ((id->bit[i] & dev->bit[i]) != id->bit[i]) \ | 588 | if ((id->bit[i] & dev->bit[i]) != id->bit[i]) \ |
589 | break; \ | 589 | break; \ |
590 | if (i != NBITS(max)) \ | 590 | if (i != BITS_TO_LONGS(max)) \ |
591 | continue; | 591 | continue; |
592 | 592 | ||
593 | static const struct input_device_id *input_match_device(const struct input_device_id *id, | 593 | static const struct input_device_id *input_match_device(const struct input_device_id *id, |
@@ -698,7 +698,7 @@ static void input_seq_print_bitmap(struct seq_file *seq, const char *name, | |||
698 | { | 698 | { |
699 | int i; | 699 | int i; |
700 | 700 | ||
701 | for (i = NBITS(max) - 1; i > 0; i--) | 701 | for (i = BITS_TO_LONGS(max) - 1; i > 0; i--) |
702 | if (bitmap[i]) | 702 | if (bitmap[i]) |
703 | break; | 703 | break; |
704 | 704 | ||
@@ -892,7 +892,7 @@ static int input_print_modalias_bits(char *buf, int size, | |||
892 | 892 | ||
893 | len += snprintf(buf, max(size, 0), "%c", name); | 893 | len += snprintf(buf, max(size, 0), "%c", name); |
894 | for (i = min_bit; i < max_bit; i++) | 894 | for (i = min_bit; i < max_bit; i++) |
895 | if (bm[LONG(i)] & BIT(i)) | 895 | if (bm[BIT_WORD(i)] & BIT_MASK(i)) |
896 | len += snprintf(buf + len, max(size - len, 0), "%X,", i); | 896 | len += snprintf(buf + len, max(size - len, 0), "%X,", i); |
897 | return len; | 897 | return len; |
898 | } | 898 | } |
@@ -991,7 +991,7 @@ static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, | |||
991 | int i; | 991 | int i; |
992 | int len = 0; | 992 | int len = 0; |
993 | 993 | ||
994 | for (i = NBITS(max) - 1; i > 0; i--) | 994 | for (i = BITS_TO_LONGS(max) - 1; i > 0; i--) |
995 | if (bitmap[i]) | 995 | if (bitmap[i]) |
996 | break; | 996 | break; |
997 | 997 | ||
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index 2b201f9aa024..22b2789ef58a 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -844,8 +844,8 @@ static const struct input_device_id joydev_blacklist[] = { | |||
844 | { | 844 | { |
845 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 845 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
846 | INPUT_DEVICE_ID_MATCH_KEYBIT, | 846 | INPUT_DEVICE_ID_MATCH_KEYBIT, |
847 | .evbit = { BIT(EV_KEY) }, | 847 | .evbit = { BIT_MASK(EV_KEY) }, |
848 | .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, | 848 | .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, |
849 | }, /* Avoid itouchpads, touchscreens and tablets */ | 849 | }, /* Avoid itouchpads, touchscreens and tablets */ |
850 | { } /* Terminating entry */ | 850 | { } /* Terminating entry */ |
851 | }; | 851 | }; |
@@ -854,20 +854,20 @@ static const struct input_device_id joydev_ids[] = { | |||
854 | { | 854 | { |
855 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 855 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
856 | INPUT_DEVICE_ID_MATCH_ABSBIT, | 856 | INPUT_DEVICE_ID_MATCH_ABSBIT, |
857 | .evbit = { BIT(EV_ABS) }, | 857 | .evbit = { BIT_MASK(EV_ABS) }, |
858 | .absbit = { BIT(ABS_X) }, | 858 | .absbit = { BIT_MASK(ABS_X) }, |
859 | }, | 859 | }, |
860 | { | 860 | { |
861 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 861 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
862 | INPUT_DEVICE_ID_MATCH_ABSBIT, | 862 | INPUT_DEVICE_ID_MATCH_ABSBIT, |
863 | .evbit = { BIT(EV_ABS) }, | 863 | .evbit = { BIT_MASK(EV_ABS) }, |
864 | .absbit = { BIT(ABS_WHEEL) }, | 864 | .absbit = { BIT_MASK(ABS_WHEEL) }, |
865 | }, | 865 | }, |
866 | { | 866 | { |
867 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 867 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
868 | INPUT_DEVICE_ID_MATCH_ABSBIT, | 868 | INPUT_DEVICE_ID_MATCH_ABSBIT, |
869 | .evbit = { BIT(EV_ABS) }, | 869 | .evbit = { BIT_MASK(EV_ABS) }, |
870 | .absbit = { BIT(ABS_THROTTLE) }, | 870 | .absbit = { BIT_MASK(ABS_THROTTLE) }, |
871 | }, | 871 | }, |
872 | { } /* Terminating entry */ | 872 | { } /* Terminating entry */ |
873 | }; | 873 | }; |
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c index ff701ab10d74..52ba16f487c7 100644 --- a/drivers/input/joystick/a3d.c +++ b/drivers/input/joystick/a3d.c | |||
@@ -326,14 +326,19 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
326 | 326 | ||
327 | a3d->length = 33; | 327 | a3d->length = 33; |
328 | 328 | ||
329 | input_dev->evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); | 329 | input_dev->evbit[0] |= BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY) | |
330 | input_dev->relbit[0] |= BIT(REL_X) | BIT(REL_Y); | 330 | BIT_MASK(EV_REL); |
331 | input_dev->absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER) | 331 | input_dev->relbit[0] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
332 | | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y) | BIT(ABS_HAT1X) | BIT(ABS_HAT1Y); | 332 | input_dev->absbit[0] |= BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
333 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | 333 | BIT_MASK(ABS_THROTTLE) | BIT_MASK(ABS_RUDDER) | |
334 | | BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 334 | BIT_MASK(ABS_HAT0X) | BIT_MASK(ABS_HAT0Y) | |
335 | input_dev->keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | 335 | BIT_MASK(ABS_HAT1X) | BIT_MASK(ABS_HAT1Y); |
336 | | BIT(BTN_PINKIE); | 336 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_RIGHT) | |
337 | BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | | ||
338 | BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA); | ||
339 | input_dev->keybit[BIT_WORD(BTN_JOYSTICK)] |= | ||
340 | BIT_MASK(BTN_TRIGGER) | BIT_MASK(BTN_THUMB) | | ||
341 | BIT_MASK(BTN_TOP) | BIT_MASK(BTN_PINKIE); | ||
337 | 342 | ||
338 | a3d_read(a3d, data); | 343 | a3d_read(a3d, data); |
339 | 344 | ||
@@ -348,9 +353,10 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
348 | } else { | 353 | } else { |
349 | a3d->length = 29; | 354 | a3d->length = 29; |
350 | 355 | ||
351 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_REL); | 356 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
352 | input_dev->relbit[0] |= BIT(REL_X) | BIT(REL_Y); | 357 | input_dev->relbit[0] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
353 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE); | 358 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_RIGHT) | |
359 | BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE); | ||
354 | 360 | ||
355 | a3d_read(a3d, data); | 361 | a3d_read(a3d, data); |
356 | 362 | ||
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c index 28140c4a110d..d1ca8a14950f 100644 --- a/drivers/input/joystick/adi.c +++ b/drivers/input/joystick/adi.c | |||
@@ -431,7 +431,7 @@ static int adi_init_input(struct adi *adi, struct adi_port *port, int half) | |||
431 | input_dev->open = adi_open; | 431 | input_dev->open = adi_open; |
432 | input_dev->close = adi_close; | 432 | input_dev->close = adi_close; |
433 | 433 | ||
434 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 434 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
435 | 435 | ||
436 | for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) | 436 | for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) |
437 | set_bit(adi->abs[i], input_dev->absbit); | 437 | set_bit(adi->abs[i], input_dev->absbit); |
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c index b0f5541ec3e6..5cf9f3610e67 100644 --- a/drivers/input/joystick/amijoy.c +++ b/drivers/input/joystick/amijoy.c | |||
@@ -137,9 +137,10 @@ static int __init amijoy_init(void) | |||
137 | amijoy_dev[i]->open = amijoy_open; | 137 | amijoy_dev[i]->open = amijoy_open; |
138 | amijoy_dev[i]->close = amijoy_close; | 138 | amijoy_dev[i]->close = amijoy_close; |
139 | 139 | ||
140 | amijoy_dev[i]->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 140 | amijoy_dev[i]->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
141 | amijoy_dev[i]->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | 141 | amijoy_dev[i]->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y); |
142 | amijoy_dev[i]->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 142 | amijoy_dev[i]->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
143 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); | ||
143 | for (j = 0; j < 2; j++) { | 144 | for (j = 0; j < 2; j++) { |
144 | amijoy_dev[i]->absmin[ABS_X + j] = -1; | 145 | amijoy_dev[i]->absmin[ABS_X + j] = -1; |
145 | amijoy_dev[i]->absmax[ABS_X + j] = 1; | 146 | amijoy_dev[i]->absmax[ABS_X + j] = 1; |
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c index bdd157c1ebf8..15739880afc6 100644 --- a/drivers/input/joystick/analog.c +++ b/drivers/input/joystick/analog.c | |||
@@ -456,7 +456,7 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i | |||
456 | input_dev->open = analog_open; | 456 | input_dev->open = analog_open; |
457 | input_dev->close = analog_close; | 457 | input_dev->close = analog_close; |
458 | 458 | ||
459 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 459 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
460 | 460 | ||
461 | for (i = j = 0; i < 4; i++) | 461 | for (i = j = 0; i < 4; i++) |
462 | if (analog->mask & (1 << i)) { | 462 | if (analog->mask & (1 << i)) { |
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c index d3352a849b85..55646a6d89f5 100644 --- a/drivers/input/joystick/cobra.c +++ b/drivers/input/joystick/cobra.c | |||
@@ -218,7 +218,7 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
218 | input_dev->open = cobra_open; | 218 | input_dev->open = cobra_open; |
219 | input_dev->close = cobra_close; | 219 | input_dev->close = cobra_close; |
220 | 220 | ||
221 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 221 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
222 | input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0); | 222 | input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0); |
223 | input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0); | 223 | input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0); |
224 | for (j = 0; cobra_btn[j]; j++) | 224 | for (j = 0; cobra_btn[j]; j++) |
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index b069ee18e353..27fc475bd3a1 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c | |||
@@ -631,7 +631,7 @@ static struct db9 __init *db9_probe(int parport, int mode) | |||
631 | input_dev->open = db9_open; | 631 | input_dev->open = db9_open; |
632 | input_dev->close = db9_close; | 632 | input_dev->close = db9_close; |
633 | 633 | ||
634 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 634 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
635 | for (j = 0; j < db9_mode->n_buttons; j++) | 635 | for (j = 0; j < db9_mode->n_buttons; j++) |
636 | set_bit(db9_mode->buttons[j], input_dev->keybit); | 636 | set_bit(db9_mode->buttons[j], input_dev->keybit); |
637 | for (j = 0; j < db9_mode->n_axis; j++) { | 637 | for (j = 0; j < db9_mode->n_axis; j++) { |
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index 1a452e0e5f25..df2a9d02ca6c 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c | |||
@@ -653,12 +653,12 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) | |||
653 | input_dev->close = gc_close; | 653 | input_dev->close = gc_close; |
654 | 654 | ||
655 | if (pad_type != GC_SNESMOUSE) { | 655 | if (pad_type != GC_SNESMOUSE) { |
656 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 656 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
657 | 657 | ||
658 | for (i = 0; i < 2; i++) | 658 | for (i = 0; i < 2; i++) |
659 | input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0); | 659 | input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0); |
660 | } else | 660 | } else |
661 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 661 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
662 | 662 | ||
663 | gc->pads[0] |= gc_status_bit[idx]; | 663 | gc->pads[0] |= gc_status_bit[idx]; |
664 | gc->pads[pad_type] |= gc_status_bit[idx]; | 664 | gc->pads[pad_type] |= gc_status_bit[idx]; |
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c index d514aebf7554..1f6302c0eb3f 100644 --- a/drivers/input/joystick/gf2k.c +++ b/drivers/input/joystick/gf2k.c | |||
@@ -315,7 +315,7 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
315 | input_dev->open = gf2k_open; | 315 | input_dev->open = gf2k_open; |
316 | input_dev->close = gf2k_close; | 316 | input_dev->close = gf2k_close; |
317 | 317 | ||
318 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 318 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
319 | 319 | ||
320 | for (i = 0; i < gf2k_axes[gf2k->id]; i++) | 320 | for (i = 0; i < gf2k_axes[gf2k->id]; i++) |
321 | set_bit(gf2k_abs[i], input_dev->absbit); | 321 | set_bit(gf2k_abs[i], input_dev->absbit); |
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c index 73eb5ab6f140..fd3853ab1aad 100644 --- a/drivers/input/joystick/grip.c +++ b/drivers/input/joystick/grip.c | |||
@@ -370,7 +370,7 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
370 | input_dev->open = grip_open; | 370 | input_dev->open = grip_open; |
371 | input_dev->close = grip_close; | 371 | input_dev->close = grip_close; |
372 | 372 | ||
373 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 373 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
374 | 374 | ||
375 | for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) { | 375 | for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) { |
376 | 376 | ||
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c index 4ed3a3eadf19..c57e21d68c00 100644 --- a/drivers/input/joystick/grip_mp.c +++ b/drivers/input/joystick/grip_mp.c | |||
@@ -606,7 +606,7 @@ static int register_slot(int slot, struct grip_mp *grip) | |||
606 | input_dev->open = grip_open; | 606 | input_dev->open = grip_open; |
607 | input_dev->close = grip_close; | 607 | input_dev->close = grip_close; |
608 | 608 | ||
609 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 609 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
610 | 610 | ||
611 | for (j = 0; (t = grip_abs[port->mode][j]) >= 0; j++) | 611 | for (j = 0; (t = grip_abs[port->mode][j]) >= 0; j++) |
612 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); | 612 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c index d4e8073caf27..aa6bfb3fb8cd 100644 --- a/drivers/input/joystick/guillemot.c +++ b/drivers/input/joystick/guillemot.c | |||
@@ -238,7 +238,7 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver * | |||
238 | input_dev->open = guillemot_open; | 238 | input_dev->open = guillemot_open; |
239 | input_dev->close = guillemot_close; | 239 | input_dev->close = guillemot_close; |
240 | 240 | ||
241 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 241 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
242 | 242 | ||
243 | for (i = 0; (t = guillemot->type->abs[i]) >= 0; i++) | 243 | for (i = 0; (t = guillemot->type->abs[i]) >= 0; i++) |
244 | input_set_abs_params(input_dev, t, 0, 255, 0, 0); | 244 | input_set_abs_params(input_dev, t, 0, 255, 0, 0); |
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index 682244b1c042..6f826b37d9aa 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c | |||
@@ -389,7 +389,8 @@ int iforce_init_device(struct iforce *iforce) | |||
389 | * Set input device bitfields and ranges. | 389 | * Set input device bitfields and ranges. |
390 | */ | 390 | */ |
391 | 391 | ||
392 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_FF_STATUS); | 392 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | |
393 | BIT_MASK(EV_FF_STATUS); | ||
393 | 394 | ||
394 | for (i = 0; iforce->type->btn[i] >= 0; i++) | 395 | for (i = 0; iforce->type->btn[i] >= 0; i++) |
395 | set_bit(iforce->type->btn[i], input_dev->keybit); | 396 | set_bit(iforce->type->btn[i], input_dev->keybit); |
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h index 40a853ac21c7..a964a7cfd210 100644 --- a/drivers/input/joystick/iforce/iforce.h +++ b/drivers/input/joystick/iforce/iforce.h | |||
@@ -62,13 +62,13 @@ | |||
62 | #define FF_CORE_IS_PLAYED 3 /* Effect is currently being played */ | 62 | #define FF_CORE_IS_PLAYED 3 /* Effect is currently being played */ |
63 | #define FF_CORE_SHOULD_PLAY 4 /* User wants the effect to be played */ | 63 | #define FF_CORE_SHOULD_PLAY 4 /* User wants the effect to be played */ |
64 | #define FF_CORE_UPDATE 5 /* Effect is being updated */ | 64 | #define FF_CORE_UPDATE 5 /* Effect is being updated */ |
65 | #define FF_MODCORE_MAX 5 | 65 | #define FF_MODCORE_CNT 6 |
66 | 66 | ||
67 | struct iforce_core_effect { | 67 | struct iforce_core_effect { |
68 | /* Information about where modifiers are stored in the device's memory */ | 68 | /* Information about where modifiers are stored in the device's memory */ |
69 | struct resource mod1_chunk; | 69 | struct resource mod1_chunk; |
70 | struct resource mod2_chunk; | 70 | struct resource mod2_chunk; |
71 | unsigned long flags[NBITS(FF_MODCORE_MAX)]; | 71 | unsigned long flags[BITS_TO_LONGS(FF_MODCORE_CNT)]; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | #define FF_CMD_EFFECT 0x010e | 74 | #define FF_CMD_EFFECT 0x010e |
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c index 1aec1e9d7c59..bc8ea95dfd0e 100644 --- a/drivers/input/joystick/interact.c +++ b/drivers/input/joystick/interact.c | |||
@@ -269,7 +269,7 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d | |||
269 | input_dev->open = interact_open; | 269 | input_dev->open = interact_open; |
270 | input_dev->close = interact_close; | 270 | input_dev->close = interact_close; |
271 | 271 | ||
272 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 272 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
273 | 273 | ||
274 | for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { | 274 | for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { |
275 | set_bit(t, input_dev->absbit); | 275 | set_bit(t, input_dev->absbit); |
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c index b35604ee43ae..54e676948ebb 100644 --- a/drivers/input/joystick/magellan.c +++ b/drivers/input/joystick/magellan.c | |||
@@ -170,7 +170,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv) | |||
170 | input_dev->id.version = 0x0100; | 170 | input_dev->id.version = 0x0100; |
171 | input_dev->dev.parent = &serio->dev; | 171 | input_dev->dev.parent = &serio->dev; |
172 | 172 | ||
173 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 173 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
174 | 174 | ||
175 | for (i = 0; i < 9; i++) | 175 | for (i = 0; i < 9; i++) |
176 | set_bit(magellan_buttons[i], input_dev->keybit); | 176 | set_bit(magellan_buttons[i], input_dev->keybit); |
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index 2adf73f63c94..7b4865fdee54 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c | |||
@@ -758,7 +758,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
758 | input_dev->open = sw_open; | 758 | input_dev->open = sw_open; |
759 | input_dev->close = sw_close; | 759 | input_dev->close = sw_close; |
760 | 760 | ||
761 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 761 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
762 | 762 | ||
763 | for (j = 0; (bits = sw_bit[sw->type][j]); j++) { | 763 | for (j = 0; (bits = sw_bit[sw->type][j]); j++) { |
764 | code = sw_abs[sw->type][j]; | 764 | code = sw_abs[sw->type][j]; |
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c index abb7c4cf54ad..d4087fd49656 100644 --- a/drivers/input/joystick/spaceball.c +++ b/drivers/input/joystick/spaceball.c | |||
@@ -228,18 +228,23 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv) | |||
228 | input_dev->id.version = 0x0100; | 228 | input_dev->id.version = 0x0100; |
229 | input_dev->dev.parent = &serio->dev; | 229 | input_dev->dev.parent = &serio->dev; |
230 | 230 | ||
231 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 231 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
232 | 232 | ||
233 | switch (id) { | 233 | switch (id) { |
234 | case SPACEBALL_4000FLX: | 234 | case SPACEBALL_4000FLX: |
235 | case SPACEBALL_4000FLX_L: | 235 | case SPACEBALL_4000FLX_L: |
236 | input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_9); | 236 | input_dev->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_9); |
237 | input_dev->keybit[LONG(BTN_A)] |= BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_MODE); | 237 | input_dev->keybit[BIT_WORD(BTN_A)] |= BIT_MASK(BTN_A) | |
238 | BIT_MASK(BTN_B) | BIT_MASK(BTN_C) | | ||
239 | BIT_MASK(BTN_MODE); | ||
238 | default: | 240 | default: |
239 | input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | 241 | input_dev->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_2) | |
240 | | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7) | BIT(BTN_8); | 242 | BIT_MASK(BTN_3) | BIT_MASK(BTN_4) | |
243 | BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | | ||
244 | BIT_MASK(BTN_7) | BIT_MASK(BTN_8); | ||
241 | case SPACEBALL_3003C: | 245 | case SPACEBALL_3003C: |
242 | input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_1) | BIT(BTN_8); | 246 | input_dev->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_1) | |
247 | BIT_MASK(BTN_8); | ||
243 | } | 248 | } |
244 | 249 | ||
245 | for (i = 0; i < 3; i++) { | 250 | for (i = 0; i < 3; i++) { |
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c index c4937f1e837c..f7ce4004f4ba 100644 --- a/drivers/input/joystick/spaceorb.c +++ b/drivers/input/joystick/spaceorb.c | |||
@@ -185,7 +185,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv) | |||
185 | input_dev->id.version = 0x0100; | 185 | input_dev->id.version = 0x0100; |
186 | input_dev->dev.parent = &serio->dev; | 186 | input_dev->dev.parent = &serio->dev; |
187 | 187 | ||
188 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 188 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
189 | 189 | ||
190 | for (i = 0; i < 6; i++) | 190 | for (i = 0; i < 6; i++) |
191 | set_bit(spaceorb_buttons[i], input_dev->keybit); | 191 | set_bit(spaceorb_buttons[i], input_dev->keybit); |
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c index 8581ee991d4e..baa10b2f7ba1 100644 --- a/drivers/input/joystick/stinger.c +++ b/drivers/input/joystick/stinger.c | |||
@@ -156,10 +156,11 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv) | |||
156 | input_dev->id.version = 0x0100; | 156 | input_dev->id.version = 0x0100; |
157 | input_dev->dev.parent = &serio->dev; | 157 | input_dev->dev.parent = &serio->dev; |
158 | 158 | ||
159 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 159 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
160 | input_dev->keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) | | 160 | input_dev->keybit[BIT_WORD(BTN_A)] = BIT_MASK(BTN_A) | BIT_MASK(BTN_B) | |
161 | BIT(BTN_Y) | BIT(BTN_Z) | BIT(BTN_TL) | BIT(BTN_TR) | | 161 | BIT_MASK(BTN_C) | BIT_MASK(BTN_X) | BIT_MASK(BTN_Y) | |
162 | BIT(BTN_START) | BIT(BTN_SELECT); | 162 | BIT_MASK(BTN_Z) | BIT_MASK(BTN_TL) | BIT_MASK(BTN_TR) | |
163 | BIT_MASK(BTN_START) | BIT_MASK(BTN_SELECT); | ||
163 | input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 4); | 164 | input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 4); |
164 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 4); | 165 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 4); |
165 | 166 | ||
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c index 3b36ee04f726..0feeb8acb532 100644 --- a/drivers/input/joystick/tmdc.c +++ b/drivers/input/joystick/tmdc.c | |||
@@ -333,7 +333,7 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) | |||
333 | input_dev->open = tmdc_open; | 333 | input_dev->open = tmdc_open; |
334 | input_dev->close = tmdc_close; | 334 | input_dev->close = tmdc_close; |
335 | 335 | ||
336 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 336 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
337 | 337 | ||
338 | for (i = 0; i < port->absc && i < TMDC_ABS; i++) | 338 | for (i = 0; i < port->absc && i < TMDC_ABS; i++) |
339 | if (port->abs[i] >= 0) | 339 | if (port->abs[i] >= 0) |
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index 8381c6f14373..bbebd4e2ad7f 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c | |||
@@ -229,7 +229,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) | |||
229 | input_dev->open = tgfx_open; | 229 | input_dev->open = tgfx_open; |
230 | input_dev->close = tgfx_close; | 230 | input_dev->close = tgfx_close; |
231 | 231 | ||
232 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 232 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
233 | input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0); | 233 | input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0); |
234 | input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0); | 234 | input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0); |
235 | 235 | ||
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c index c91504ec38eb..1085c841fec4 100644 --- a/drivers/input/joystick/twidjoy.c +++ b/drivers/input/joystick/twidjoy.c | |||
@@ -207,7 +207,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv) | |||
207 | input_dev->id.version = 0x0100; | 207 | input_dev->id.version = 0x0100; |
208 | input_dev->dev.parent = &serio->dev; | 208 | input_dev->dev.parent = &serio->dev; |
209 | 209 | ||
210 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 210 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
211 | input_set_abs_params(input_dev, ABS_X, -50, 50, 4, 4); | 211 | input_set_abs_params(input_dev, ABS_X, -50, 50, 4, 4); |
212 | input_set_abs_params(input_dev, ABS_Y, -50, 50, 4, 4); | 212 | input_set_abs_params(input_dev, ABS_Y, -50, 50, 4, 4); |
213 | 213 | ||
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c index 4e85f72eefd7..e928b6e3724a 100644 --- a/drivers/input/joystick/warrior.c +++ b/drivers/input/joystick/warrior.c | |||
@@ -162,9 +162,11 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv) | |||
162 | input_dev->id.version = 0x0100; | 162 | input_dev->id.version = 0x0100; |
163 | input_dev->dev.parent = &serio->dev; | 163 | input_dev->dev.parent = &serio->dev; |
164 | 164 | ||
165 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS); | 165 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL) | |
166 | input_dev->keybit[LONG(BTN_TRIGGER)] = BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_TOP2); | 166 | BIT_MASK(EV_ABS); |
167 | input_dev->relbit[0] = BIT(REL_DIAL); | 167 | input_dev->keybit[BIT_WORD(BTN_TRIGGER)] = BIT_MASK(BTN_TRIGGER) | |
168 | BIT_MASK(BTN_THUMB) | BIT_MASK(BTN_TOP) | BIT_MASK(BTN_TOP2); | ||
169 | input_dev->relbit[0] = BIT_MASK(REL_DIAL); | ||
168 | input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 8); | 170 | input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 8); |
169 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 8); | 171 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 8); |
170 | input_set_abs_params(input_dev, ABS_THROTTLE, -112, 112, 0, 0); | 172 | input_set_abs_params(input_dev, ABS_THROTTLE, -112, 112, 0, 0); |
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 623629a69b03..6dd375825a14 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c | |||
@@ -658,7 +658,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
658 | input_dev->open = xpad_open; | 658 | input_dev->open = xpad_open; |
659 | input_dev->close = xpad_close; | 659 | input_dev->close = xpad_close; |
660 | 660 | ||
661 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 661 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
662 | 662 | ||
663 | /* set up buttons */ | 663 | /* set up buttons */ |
664 | for (i = 0; xpad_btn[i] >= 0; i++) | 664 | for (i = 0; xpad_btn[i] >= 0; i++) |
diff --git a/drivers/input/keyboard/aaed2000_kbd.c b/drivers/input/keyboard/aaed2000_kbd.c index 63d6ead6b877..72abc196ce66 100644 --- a/drivers/input/keyboard/aaed2000_kbd.c +++ b/drivers/input/keyboard/aaed2000_kbd.c | |||
@@ -125,7 +125,7 @@ static int __devinit aaedkbd_probe(struct platform_device *pdev) | |||
125 | input_dev->id.version = 0x0100; | 125 | input_dev->id.version = 0x0100; |
126 | input_dev->dev.parent = &pdev->dev; | 126 | input_dev->dev.parent = &pdev->dev; |
127 | 127 | ||
128 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 128 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
129 | input_dev->keycode = aaedkbd->keycode; | 129 | input_dev->keycode = aaedkbd->keycode; |
130 | input_dev->keycodesize = sizeof(unsigned char); | 130 | input_dev->keycodesize = sizeof(unsigned char); |
131 | input_dev->keycodemax = ARRAY_SIZE(aaedkbd_keycode); | 131 | input_dev->keycodemax = ARRAY_SIZE(aaedkbd_keycode); |
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index c67e84ec2d6a..81bf7562aca0 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c | |||
@@ -209,7 +209,7 @@ static int __init amikbd_init(void) | |||
209 | amikbd_dev->id.product = 0x0001; | 209 | amikbd_dev->id.product = 0x0001; |
210 | amikbd_dev->id.version = 0x0100; | 210 | amikbd_dev->id.version = 0x0100; |
211 | 211 | ||
212 | amikbd_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 212 | amikbd_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
213 | 213 | ||
214 | for (i = 0; i < 0x78; i++) | 214 | for (i = 0; i < 0x78; i++) |
215 | set_bit(i, amikbd_dev->keybit); | 215 | set_bit(i, amikbd_dev->keybit); |
diff --git a/drivers/input/keyboard/atakbd.c b/drivers/input/keyboard/atakbd.c index a1800151b6ce..4e92100c56a8 100644 --- a/drivers/input/keyboard/atakbd.c +++ b/drivers/input/keyboard/atakbd.c | |||
@@ -237,7 +237,7 @@ static int __init atakbd_init(void) | |||
237 | atakbd_dev->id.product = 0x0001; | 237 | atakbd_dev->id.product = 0x0001; |
238 | atakbd_dev->id.version = 0x0100; | 238 | atakbd_dev->id.version = 0x0100; |
239 | 239 | ||
240 | atakbd_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 240 | atakbd_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
241 | atakbd_dev->keycode = atakbd_keycode; | 241 | atakbd_dev->keycode = atakbd_keycode; |
242 | atakbd_dev->keycodesize = sizeof(unsigned char); | 242 | atakbd_dev->keycodesize = sizeof(unsigned char); |
243 | atakbd_dev->keycodemax = ARRAY_SIZE(atakbd_keycode); | 243 | atakbd_dev->keycodemax = ARRAY_SIZE(atakbd_keycode); |
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 41fc3d03b6eb..b39c5b31e620 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -900,27 +900,32 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd) | |||
900 | 900 | ||
901 | input_set_drvdata(input_dev, atkbd); | 901 | input_set_drvdata(input_dev, atkbd); |
902 | 902 | ||
903 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC); | 903 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | |
904 | BIT_MASK(EV_MSC); | ||
904 | 905 | ||
905 | if (atkbd->write) { | 906 | if (atkbd->write) { |
906 | input_dev->evbit[0] |= BIT(EV_LED); | 907 | input_dev->evbit[0] |= BIT_MASK(EV_LED); |
907 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 908 | input_dev->ledbit[0] = BIT_MASK(LED_NUML) | |
909 | BIT_MASK(LED_CAPSL) | BIT_MASK(LED_SCROLLL); | ||
908 | } | 910 | } |
909 | 911 | ||
910 | if (atkbd->extra) | 912 | if (atkbd->extra) |
911 | input_dev->ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) | | 913 | input_dev->ledbit[0] |= BIT_MASK(LED_COMPOSE) | |
912 | BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC); | 914 | BIT_MASK(LED_SUSPEND) | BIT_MASK(LED_SLEEP) | |
915 | BIT_MASK(LED_MUTE) | BIT_MASK(LED_MISC); | ||
913 | 916 | ||
914 | if (!atkbd->softrepeat) { | 917 | if (!atkbd->softrepeat) { |
915 | input_dev->rep[REP_DELAY] = 250; | 918 | input_dev->rep[REP_DELAY] = 250; |
916 | input_dev->rep[REP_PERIOD] = 33; | 919 | input_dev->rep[REP_PERIOD] = 33; |
917 | } | 920 | } |
918 | 921 | ||
919 | input_dev->mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN); | 922 | input_dev->mscbit[0] = atkbd->softraw ? BIT_MASK(MSC_SCAN) : |
923 | BIT_MASK(MSC_RAW) | BIT_MASK(MSC_SCAN); | ||
920 | 924 | ||
921 | if (atkbd->scroll) { | 925 | if (atkbd->scroll) { |
922 | input_dev->evbit[0] |= BIT(EV_REL); | 926 | input_dev->evbit[0] |= BIT_MASK(EV_REL); |
923 | input_dev->relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL); | 927 | input_dev->relbit[0] = BIT_MASK(REL_WHEEL) | |
928 | BIT_MASK(REL_HWHEEL); | ||
924 | set_bit(BTN_MIDDLE, input_dev->keybit); | 929 | set_bit(BTN_MIDDLE, input_dev->keybit); |
925 | } | 930 | } |
926 | 931 | ||
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 6578bfff644b..790fed368aae 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c | |||
@@ -325,7 +325,8 @@ static int __init corgikbd_probe(struct platform_device *pdev) | |||
325 | input_dev->id.version = 0x0100; | 325 | input_dev->id.version = 0x0100; |
326 | input_dev->dev.parent = &pdev->dev; | 326 | input_dev->dev.parent = &pdev->dev; |
327 | 327 | ||
328 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | 328 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | |
329 | BIT_MASK(EV_PWR) | BIT_MASK(EV_SW); | ||
329 | input_dev->keycode = corgikbd->keycode; | 330 | input_dev->keycode = corgikbd->keycode; |
330 | input_dev->keycodesize = sizeof(unsigned char); | 331 | input_dev->keycodesize = sizeof(unsigned char); |
331 | input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode); | 332 | input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode); |
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index e2a3293bc67e..3eddf52a0bba 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -62,7 +62,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
62 | 62 | ||
63 | platform_set_drvdata(pdev, input); | 63 | platform_set_drvdata(pdev, input); |
64 | 64 | ||
65 | input->evbit[0] = BIT(EV_KEY); | 65 | input->evbit[0] = BIT_MASK(EV_KEY); |
66 | 66 | ||
67 | input->name = pdev->name; | 67 | input->name = pdev->name; |
68 | input->phys = "gpio-keys/input0"; | 68 | input->phys = "gpio-keys/input0"; |
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index cdd254f2e6c7..adbf29f0169d 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c | |||
@@ -323,8 +323,9 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
323 | goto bail2; | 323 | goto bail2; |
324 | } | 324 | } |
325 | 325 | ||
326 | kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 326 | kbd->dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
327 | kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 327 | kbd->dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) | |
328 | BIT_MASK(LED_SCROLLL); | ||
328 | kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; | 329 | kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; |
329 | kbd->dev->keycodesize = sizeof(hil_kbd_set1[0]); | 330 | kbd->dev->keycodesize = sizeof(hil_kbd_set1[0]); |
330 | kbd->dev->keycode = hil_kbd_set1; | 331 | kbd->dev->keycode = hil_kbd_set1; |
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c index 499b6974457f..50d80ecf0b80 100644 --- a/drivers/input/keyboard/hilkbd.c +++ b/drivers/input/keyboard/hilkbd.c | |||
@@ -266,8 +266,9 @@ hil_keyb_init(void) | |||
266 | if (hphilkeyb_keycode[i] != KEY_RESERVED) | 266 | if (hphilkeyb_keycode[i] != KEY_RESERVED) |
267 | set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit); | 267 | set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit); |
268 | 268 | ||
269 | hil_dev.dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 269 | hil_dev.dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
270 | hil_dev.dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 270 | hil_dev.dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) | |
271 | BIT_MASK(LED_SCROLLL); | ||
271 | hil_dev.dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; | 272 | hil_dev.dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; |
272 | hil_dev.dev->keycodesize= sizeof(hphilkeyb_keycode[0]); | 273 | hil_dev.dev->keycodesize= sizeof(hphilkeyb_keycode[0]); |
273 | hil_dev.dev->keycode = hphilkeyb_keycode; | 274 | hil_dev.dev->keycode = hphilkeyb_keycode; |
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 7a41b271f222..5a0ca18d6755 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c | |||
@@ -233,7 +233,7 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
233 | input_dev->id.version = 0x0100; | 233 | input_dev->id.version = 0x0100; |
234 | input_dev->dev.parent = &dev->dev; | 234 | input_dev->dev.parent = &dev->dev; |
235 | 235 | ||
236 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 236 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
237 | input_dev->keycode = locomokbd->keycode; | 237 | input_dev->keycode = locomokbd->keycode; |
238 | input_dev->keycodesize = sizeof(unsigned char); | 238 | input_dev->keycodesize = sizeof(unsigned char); |
239 | input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode); | 239 | input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode); |
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index b97a41e3ee56..48d1cab0aa1c 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c | |||
@@ -106,7 +106,7 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
106 | input_dev->id.version = 0x0100; | 106 | input_dev->id.version = 0x0100; |
107 | input_dev->dev.parent = &serio->dev; | 107 | input_dev->dev.parent = &serio->dev; |
108 | 108 | ||
109 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 109 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
110 | input_dev->keycode = nkbd->keycode; | 110 | input_dev->keycode = nkbd->keycode; |
111 | input_dev->keycodesize = sizeof(unsigned char); | 111 | input_dev->keycodesize = sizeof(unsigned char); |
112 | input_dev->keycodemax = ARRAY_SIZE(nkbd_keycode); | 112 | input_dev->keycodemax = ARRAY_SIZE(nkbd_keycode); |
diff --git a/drivers/input/keyboard/pxa27x_keyboard.c b/drivers/input/keyboard/pxa27x_keyboard.c index b7061aa38816..bdd64ee4c5c8 100644 --- a/drivers/input/keyboard/pxa27x_keyboard.c +++ b/drivers/input/keyboard/pxa27x_keyboard.c | |||
@@ -183,8 +183,9 @@ static int __devinit pxakbd_probe(struct platform_device *pdev) | |||
183 | input_dev->close = pxakbd_close; | 183 | input_dev->close = pxakbd_close; |
184 | input_dev->dev.parent = &pdev->dev; | 184 | input_dev->dev.parent = &pdev->dev; |
185 | 185 | ||
186 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL); | 186 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | |
187 | input_dev->relbit[LONG(REL_WHEEL)] = BIT(REL_WHEEL); | 187 | BIT_MASK(EV_REL); |
188 | input_dev->relbit[BIT_WORD(REL_WHEEL)] = BIT_MASK(REL_WHEEL); | ||
188 | for (row = 0; row < pdata->nr_rows; row++) { | 189 | for (row = 0; row < pdata->nr_rows; row++) { |
189 | for (col = 0; col < pdata->nr_cols; col++) { | 190 | for (col = 0; col < pdata->nr_cols; col++) { |
190 | int code = pdata->keycodes[row][col]; | 191 | int code = pdata->keycodes[row][col]; |
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index 41b80385476c..410d78a774d0 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c | |||
@@ -381,7 +381,8 @@ static int __init spitzkbd_probe(struct platform_device *dev) | |||
381 | input_dev->id.product = 0x0001; | 381 | input_dev->id.product = 0x0001; |
382 | input_dev->id.version = 0x0100; | 382 | input_dev->id.version = 0x0100; |
383 | 383 | ||
384 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | 384 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | |
385 | BIT_MASK(EV_PWR) | BIT_MASK(EV_SW); | ||
385 | input_dev->keycode = spitzkbd->keycode; | 386 | input_dev->keycode = spitzkbd->keycode; |
386 | input_dev->keycodesize = sizeof(unsigned char); | 387 | input_dev->keycodesize = sizeof(unsigned char); |
387 | input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode); | 388 | input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode); |
diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c index b44b0684d543..7437219370b1 100644 --- a/drivers/input/keyboard/stowaway.c +++ b/drivers/input/keyboard/stowaway.c | |||
@@ -110,7 +110,7 @@ static int skbd_connect(struct serio *serio, struct serio_driver *drv) | |||
110 | input_dev->id.version = 0x0100; | 110 | input_dev->id.version = 0x0100; |
111 | input_dev->dev.parent = &serio->dev; | 111 | input_dev->dev.parent = &serio->dev; |
112 | 112 | ||
113 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 113 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
114 | input_dev->keycode = skbd->keycode; | 114 | input_dev->keycode = skbd->keycode; |
115 | input_dev->keycodesize = sizeof(unsigned char); | 115 | input_dev->keycodesize = sizeof(unsigned char); |
116 | input_dev->keycodemax = ARRAY_SIZE(skbd_keycode); | 116 | input_dev->keycodemax = ARRAY_SIZE(skbd_keycode); |
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 1d4e39624cfe..be0f5d19d023 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c | |||
@@ -277,9 +277,11 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
277 | 277 | ||
278 | input_dev->event = sunkbd_event; | 278 | input_dev->event = sunkbd_event; |
279 | 279 | ||
280 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP); | 280 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_LED) | |
281 | input_dev->ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML); | 281 | BIT_MASK(EV_SND) | BIT_MASK(EV_REP); |
282 | input_dev->sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL); | 282 | input_dev->ledbit[0] = BIT_MASK(LED_CAPSL) | BIT_MASK(LED_COMPOSE) | |
283 | BIT_MASK(LED_SCROLLL) | BIT_MASK(LED_NUML); | ||
284 | input_dev->sndbit[0] = BIT_MASK(SND_CLICK) | BIT_MASK(SND_BELL); | ||
283 | 285 | ||
284 | input_dev->keycode = sunkbd->keycode; | 286 | input_dev->keycode = sunkbd->keycode; |
285 | input_dev->keycodesize = sizeof(unsigned char); | 287 | input_dev->keycodesize = sizeof(unsigned char); |
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index f3a56eb58ed1..152a2c070508 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c | |||
@@ -110,7 +110,7 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
110 | input_dev->id.version = 0x0100; | 110 | input_dev->id.version = 0x0100; |
111 | input_dev->dev.parent = &serio->dev; | 111 | input_dev->dev.parent = &serio->dev; |
112 | 112 | ||
113 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 113 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
114 | input_dev->keycode = xtkbd->keycode; | 114 | input_dev->keycode = xtkbd->keycode; |
115 | input_dev->keycodesize = sizeof(unsigned char); | 115 | input_dev->keycodesize = sizeof(unsigned char); |
116 | input_dev->keycodemax = ARRAY_SIZE(xtkbd_keycode); | 116 | input_dev->keycodemax = ARRAY_SIZE(xtkbd_keycode); |
diff --git a/drivers/input/misc/ati_remote.c b/drivers/input/misc/ati_remote.c index 471aab206443..3a7937481ad8 100644 --- a/drivers/input/misc/ati_remote.c +++ b/drivers/input/misc/ati_remote.c | |||
@@ -662,10 +662,10 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) | |||
662 | struct input_dev *idev = ati_remote->idev; | 662 | struct input_dev *idev = ati_remote->idev; |
663 | int i; | 663 | int i; |
664 | 664 | ||
665 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 665 | idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
666 | idev->keybit[LONG(BTN_MOUSE)] = ( BIT(BTN_LEFT) | BIT(BTN_RIGHT) | | 666 | idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
667 | BIT(BTN_SIDE) | BIT(BTN_EXTRA) ); | 667 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA); |
668 | idev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 668 | idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
669 | for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) | 669 | for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) |
670 | if (ati_remote_tbl[i].type == EV_KEY) | 670 | if (ati_remote_tbl[i].type == EV_KEY) |
671 | set_bit(ati_remote_tbl[i].code, idev->keybit); | 671 | set_bit(ati_remote_tbl[i].code, idev->keybit); |
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c index 1031543e5c3f..f2709b82485c 100644 --- a/drivers/input/misc/ati_remote2.c +++ b/drivers/input/misc/ati_remote2.c | |||
@@ -346,9 +346,10 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2) | |||
346 | ar2->idev = idev; | 346 | ar2->idev = idev; |
347 | input_set_drvdata(idev, ar2); | 347 | input_set_drvdata(idev, ar2); |
348 | 348 | ||
349 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL); | 349 | idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_REL); |
350 | idev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); | 350 | idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
351 | idev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 351 | BIT_MASK(BTN_RIGHT); |
352 | idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
352 | for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) | 353 | for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) |
353 | set_bit(ati_remote2_key_table[i].key_code, idev->keybit); | 354 | set_bit(ati_remote2_key_table[i].key_code, idev->keybit); |
354 | 355 | ||
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c index e43e92fd9e23..4e3ad657ed80 100644 --- a/drivers/input/misc/atlas_btns.c +++ b/drivers/input/misc/atlas_btns.c | |||
@@ -81,7 +81,7 @@ static int atlas_acpi_button_add(struct acpi_device *device) | |||
81 | input_dev->name = "Atlas ACPI button driver"; | 81 | input_dev->name = "Atlas ACPI button driver"; |
82 | input_dev->phys = "ASIM0000/atlas/input0"; | 82 | input_dev->phys = "ASIM0000/atlas/input0"; |
83 | input_dev->id.bustype = BUS_HOST; | 83 | input_dev->id.bustype = BUS_HOST; |
84 | input_dev->evbit[LONG(EV_KEY)] = BIT(EV_KEY); | 84 | input_dev->evbit[BIT_WORD(EV_KEY)] = BIT_MASK(EV_KEY); |
85 | 85 | ||
86 | set_bit(KEY_F1, input_dev->keybit); | 86 | set_bit(KEY_F1, input_dev->keybit); |
87 | set_bit(KEY_F2, input_dev->keybit); | 87 | set_bit(KEY_F2, input_dev->keybit); |
diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c index 064b07936019..1aef97ed5e84 100644 --- a/drivers/input/misc/cobalt_btns.c +++ b/drivers/input/misc/cobalt_btns.c | |||
@@ -104,7 +104,7 @@ static int __devinit cobalt_buttons_probe(struct platform_device *pdev) | |||
104 | input->id.bustype = BUS_HOST; | 104 | input->id.bustype = BUS_HOST; |
105 | input->cdev.dev = &pdev->dev; | 105 | input->cdev.dev = &pdev->dev; |
106 | 106 | ||
107 | input->evbit[0] = BIT(EV_KEY); | 107 | input->evbit[0] = BIT_MASK(EV_KEY); |
108 | for (i = 0; i < ARRAY_SIZE(buttons_map); i++) { | 108 | for (i = 0; i < ARRAY_SIZE(buttons_map); i++) { |
109 | set_bit(buttons_map[i].keycode, input->keybit); | 109 | set_bit(buttons_map[i].keycode, input->keybit); |
110 | buttons_map[i].count = 0; | 110 | buttons_map[i].count = 0; |
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c index e759944041ab..d2ade7443b7d 100644 --- a/drivers/input/misc/ixp4xx-beeper.c +++ b/drivers/input/misc/ixp4xx-beeper.c | |||
@@ -109,8 +109,8 @@ static int __devinit ixp4xx_spkr_probe(struct platform_device *dev) | |||
109 | input_dev->id.version = 0x0100; | 109 | input_dev->id.version = 0x0100; |
110 | input_dev->dev.parent = &dev->dev; | 110 | input_dev->dev.parent = &dev->dev; |
111 | 111 | ||
112 | input_dev->evbit[0] = BIT(EV_SND); | 112 | input_dev->evbit[0] = BIT_MASK(EV_SND); |
113 | input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | 113 | input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); |
114 | input_dev->event = ixp4xx_spkr_event; | 114 | input_dev->event = ixp4xx_spkr_event; |
115 | 115 | ||
116 | err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt, | 116 | err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt, |
diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c index 1bffc9fa98c2..fd74347047dd 100644 --- a/drivers/input/misc/keyspan_remote.c +++ b/drivers/input/misc/keyspan_remote.c | |||
@@ -497,7 +497,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
497 | usb_to_input_id(udev, &input_dev->id); | 497 | usb_to_input_id(udev, &input_dev->id); |
498 | input_dev->dev.parent = &interface->dev; | 498 | input_dev->dev.parent = &interface->dev; |
499 | 499 | ||
500 | input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ | 500 | input_dev->evbit[0] = BIT_MASK(EV_KEY); /* We will only report KEY events. */ |
501 | for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) | 501 | for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) |
502 | if (keyspan_key_table[i] != KEY_RESERVED) | 502 | if (keyspan_key_table[i] != KEY_RESERVED) |
503 | set_bit(keyspan_key_table[i], input_dev->keybit); | 503 | set_bit(keyspan_key_table[i], input_dev->keybit); |
diff --git a/drivers/input/misc/m68kspkr.c b/drivers/input/misc/m68kspkr.c index e9f26e766b4d..0c64d9bb718e 100644 --- a/drivers/input/misc/m68kspkr.c +++ b/drivers/input/misc/m68kspkr.c | |||
@@ -65,8 +65,8 @@ static int __devinit m68kspkr_probe(struct platform_device *dev) | |||
65 | input_dev->id.version = 0x0100; | 65 | input_dev->id.version = 0x0100; |
66 | input_dev->dev.parent = &dev->dev; | 66 | input_dev->dev.parent = &dev->dev; |
67 | 67 | ||
68 | input_dev->evbit[0] = BIT(EV_SND); | 68 | input_dev->evbit[0] = BIT_MASK(EV_SND); |
69 | input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | 69 | input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); |
70 | input_dev->event = m68kspkr_event; | 70 | input_dev->event = m68kspkr_event; |
71 | 71 | ||
72 | err = input_register_device(input_dev); | 72 | err = input_register_device(input_dev); |
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c index c19f77fbaf2a..4941a9e61e90 100644 --- a/drivers/input/misc/pcspkr.c +++ b/drivers/input/misc/pcspkr.c | |||
@@ -86,8 +86,8 @@ static int __devinit pcspkr_probe(struct platform_device *dev) | |||
86 | pcspkr_dev->id.version = 0x0100; | 86 | pcspkr_dev->id.version = 0x0100; |
87 | pcspkr_dev->dev.parent = &dev->dev; | 87 | pcspkr_dev->dev.parent = &dev->dev; |
88 | 88 | ||
89 | pcspkr_dev->evbit[0] = BIT(EV_SND); | 89 | pcspkr_dev->evbit[0] = BIT_MASK(EV_SND); |
90 | pcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | 90 | pcspkr_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); |
91 | pcspkr_dev->event = pcspkr_event; | 91 | pcspkr_dev->event = pcspkr_event; |
92 | 92 | ||
93 | err = input_register_device(pcspkr_dev); | 93 | err = input_register_device(pcspkr_dev); |
diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c index 448a470d28f2..7a7b8c7b9633 100644 --- a/drivers/input/misc/powermate.c +++ b/drivers/input/misc/powermate.c | |||
@@ -363,10 +363,11 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
363 | 363 | ||
364 | input_dev->event = powermate_input_event; | 364 | input_dev->event = powermate_input_event; |
365 | 365 | ||
366 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | 366 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL) | |
367 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | 367 | BIT_MASK(EV_MSC); |
368 | input_dev->relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | 368 | input_dev->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0); |
369 | input_dev->mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | 369 | input_dev->relbit[BIT_WORD(REL_DIAL)] = BIT_MASK(REL_DIAL); |
370 | input_dev->mscbit[BIT_WORD(MSC_PULSELED)] = BIT_MASK(MSC_PULSELED); | ||
370 | 371 | ||
371 | /* get a handle to the interrupt data pipe */ | 372 | /* get a handle to the interrupt data pipe */ |
372 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | 373 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); |
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index e36ec1d92be8..a3637d870880 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c | |||
@@ -115,8 +115,8 @@ static int __devinit sparcspkr_probe(struct device *dev) | |||
115 | input_dev->id.version = 0x0100; | 115 | input_dev->id.version = 0x0100; |
116 | input_dev->dev.parent = dev; | 116 | input_dev->dev.parent = dev; |
117 | 117 | ||
118 | input_dev->evbit[0] = BIT(EV_SND); | 118 | input_dev->evbit[0] = BIT_MASK(EV_SND); |
119 | input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | 119 | input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); |
120 | 120 | ||
121 | input_dev->event = state->event; | 121 | input_dev->event = state->event; |
122 | 122 | ||
diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c index ab15880fd566..46279ef2b649 100644 --- a/drivers/input/misc/yealink.c +++ b/drivers/input/misc/yealink.c | |||
@@ -945,7 +945,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
945 | /* input_dev->event = input_ev; TODO */ | 945 | /* input_dev->event = input_ev; TODO */ |
946 | 946 | ||
947 | /* register available key events */ | 947 | /* register available key events */ |
948 | input_dev->evbit[0] = BIT(EV_KEY); | 948 | input_dev->evbit[0] = BIT_MASK(EV_KEY); |
949 | for (i = 0; i < 256; i++) { | 949 | for (i = 0; i < 256; i++) { |
950 | int k = map_p1k_to_key(i); | 950 | int k = map_p1k_to_key(i); |
951 | if (k >= 0) { | 951 | if (k >= 0) { |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 64d70a9b714c..2b5ed119c9a9 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -455,24 +455,25 @@ int alps_init(struct psmouse *psmouse) | |||
455 | if (alps_hw_init(psmouse, &version)) | 455 | if (alps_hw_init(psmouse, &version)) |
456 | goto init_fail; | 456 | goto init_fail; |
457 | 457 | ||
458 | dev1->evbit[LONG(EV_KEY)] |= BIT(EV_KEY); | 458 | dev1->evbit[BIT_WORD(EV_KEY)] |= BIT_MASK(EV_KEY); |
459 | dev1->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH); | 459 | dev1->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH); |
460 | dev1->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER); | 460 | dev1->keybit[BIT_WORD(BTN_TOOL_FINGER)] |= BIT_MASK(BTN_TOOL_FINGER); |
461 | dev1->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 461 | dev1->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | |
462 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); | ||
462 | 463 | ||
463 | dev1->evbit[LONG(EV_ABS)] |= BIT(EV_ABS); | 464 | dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS); |
464 | input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); | 465 | input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); |
465 | input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); | 466 | input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); |
466 | input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0); | 467 | input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0); |
467 | 468 | ||
468 | if (priv->i->flags & ALPS_WHEEL) { | 469 | if (priv->i->flags & ALPS_WHEEL) { |
469 | dev1->evbit[LONG(EV_REL)] |= BIT(EV_REL); | 470 | dev1->evbit[BIT_WORD(EV_REL)] |= BIT_MASK(EV_REL); |
470 | dev1->relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL); | 471 | dev1->relbit[BIT_WORD(REL_WHEEL)] |= BIT_MASK(REL_WHEEL); |
471 | } | 472 | } |
472 | 473 | ||
473 | if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { | 474 | if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { |
474 | dev1->keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD); | 475 | dev1->keybit[BIT_WORD(BTN_FORWARD)] |= BIT_MASK(BTN_FORWARD); |
475 | dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); | 476 | dev1->keybit[BIT_WORD(BTN_BACK)] |= BIT_MASK(BTN_BACK); |
476 | } | 477 | } |
477 | 478 | ||
478 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys); | 479 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys); |
@@ -483,9 +484,10 @@ int alps_init(struct psmouse *psmouse) | |||
483 | dev2->id.product = PSMOUSE_ALPS; | 484 | dev2->id.product = PSMOUSE_ALPS; |
484 | dev2->id.version = 0x0000; | 485 | dev2->id.version = 0x0000; |
485 | 486 | ||
486 | dev2->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 487 | dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
487 | dev2->relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y); | 488 | dev2->relbit[BIT_WORD(REL_X)] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
488 | dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 489 | dev2->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | |
490 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); | ||
489 | 491 | ||
490 | if (input_register_device(priv->dev2)) | 492 | if (input_register_device(priv->dev2)) |
491 | goto init_fail; | 493 | goto init_fail; |
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c index 239a0e16d91a..a185ac78a42c 100644 --- a/drivers/input/mouse/amimouse.c +++ b/drivers/input/mouse/amimouse.c | |||
@@ -111,9 +111,10 @@ static int __init amimouse_init(void) | |||
111 | amimouse_dev->id.product = 0x0002; | 111 | amimouse_dev->id.product = 0x0002; |
112 | amimouse_dev->id.version = 0x0100; | 112 | amimouse_dev->id.version = 0x0100; |
113 | 113 | ||
114 | amimouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 114 | amimouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
115 | amimouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 115 | amimouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
116 | amimouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 116 | amimouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
117 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); | ||
117 | amimouse_dev->open = amimouse_open; | 118 | amimouse_dev->open = amimouse_open; |
118 | amimouse_dev->close = amimouse_close; | 119 | amimouse_dev->close = amimouse_close; |
119 | 120 | ||
diff --git a/drivers/input/mouse/atarimouse.c b/drivers/input/mouse/atarimouse.c index c8c7244b48a1..98a3561d4b05 100644 --- a/drivers/input/mouse/atarimouse.c +++ b/drivers/input/mouse/atarimouse.c | |||
@@ -137,9 +137,10 @@ static int __init atamouse_init(void) | |||
137 | atamouse_dev->id.product = 0x0002; | 137 | atamouse_dev->id.product = 0x0002; |
138 | atamouse_dev->id.version = 0x0100; | 138 | atamouse_dev->id.version = 0x0100; |
139 | 139 | ||
140 | atamouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 140 | atamouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
141 | atamouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 141 | atamouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
142 | atamouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 142 | atamouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
143 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); | ||
143 | atamouse_dev->open = atamouse_open; | 144 | atamouse_dev->open = atamouse_open; |
144 | atamouse_dev->close = atamouse_close; | 145 | atamouse_dev->close = atamouse_close; |
145 | 146 | ||
diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c index 449bf4dcbbcc..27f88fbb7136 100644 --- a/drivers/input/mouse/hil_ptr.c +++ b/drivers/input/mouse/hil_ptr.c | |||
@@ -298,12 +298,12 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) | |||
298 | idd = ptr->idd + 1; | 298 | idd = ptr->idd + 1; |
299 | txt = "unknown"; | 299 | txt = "unknown"; |
300 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { | 300 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { |
301 | ptr->dev->evbit[0] = BIT(EV_REL); | 301 | ptr->dev->evbit[0] = BIT_MASK(EV_REL); |
302 | txt = "relative"; | 302 | txt = "relative"; |
303 | } | 303 | } |
304 | 304 | ||
305 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_ABS) { | 305 | if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_ABS) { |
306 | ptr->dev->evbit[0] = BIT(EV_ABS); | 306 | ptr->dev->evbit[0] = BIT_MASK(EV_ABS); |
307 | txt = "absolute"; | 307 | txt = "absolute"; |
308 | } | 308 | } |
309 | if (!ptr->dev->evbit[0]) | 309 | if (!ptr->dev->evbit[0]) |
@@ -311,7 +311,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) | |||
311 | 311 | ||
312 | ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); | 312 | ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); |
313 | if (ptr->nbtn) | 313 | if (ptr->nbtn) |
314 | ptr->dev->evbit[0] |= BIT(EV_KEY); | 314 | ptr->dev->evbit[0] |= BIT_MASK(EV_KEY); |
315 | 315 | ||
316 | naxsets = HIL_IDD_NUM_AXSETS(*idd); | 316 | naxsets = HIL_IDD_NUM_AXSETS(*idd); |
317 | ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); | 317 | ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); |
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c index 79b624fe8994..655a39217432 100644 --- a/drivers/input/mouse/inport.c +++ b/drivers/input/mouse/inport.c | |||
@@ -163,9 +163,10 @@ static int __init inport_init(void) | |||
163 | inport_dev->id.product = 0x0001; | 163 | inport_dev->id.product = 0x0001; |
164 | inport_dev->id.version = 0x0100; | 164 | inport_dev->id.version = 0x0100; |
165 | 165 | ||
166 | inport_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 166 | inport_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
167 | inport_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 167 | inport_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
168 | inport_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 168 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
169 | inport_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
169 | 170 | ||
170 | inport_dev->open = inport_open; | 171 | inport_dev->open = inport_open; |
171 | inport_dev->close = inport_close; | 172 | inport_dev->close = inport_close; |
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c index d7de4c53b3d8..9ec57d80186e 100644 --- a/drivers/input/mouse/lifebook.c +++ b/drivers/input/mouse/lifebook.c | |||
@@ -270,9 +270,10 @@ static int lifebook_create_relative_device(struct psmouse *psmouse) | |||
270 | dev2->id.version = 0x0000; | 270 | dev2->id.version = 0x0000; |
271 | dev2->dev.parent = &psmouse->ps2dev.serio->dev; | 271 | dev2->dev.parent = &psmouse->ps2dev.serio->dev; |
272 | 272 | ||
273 | dev2->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 273 | dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
274 | dev2->relbit[LONG(REL_X)] = BIT(REL_X) | BIT(REL_Y); | 274 | dev2->relbit[BIT_WORD(REL_X)] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
275 | dev2->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); | 275 | dev2->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
276 | BIT_MASK(BTN_RIGHT); | ||
276 | 277 | ||
277 | error = input_register_device(priv->dev2); | 278 | error = input_register_device(priv->dev2); |
278 | if (error) | 279 | if (error) |
@@ -295,9 +296,9 @@ int lifebook_init(struct psmouse *psmouse) | |||
295 | if (lifebook_absolute_mode(psmouse)) | 296 | if (lifebook_absolute_mode(psmouse)) |
296 | return -1; | 297 | return -1; |
297 | 298 | ||
298 | dev1->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); | 299 | dev1->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY); |
299 | dev1->relbit[0] = 0; | 300 | dev1->relbit[0] = 0; |
300 | dev1->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 301 | dev1->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
301 | input_set_abs_params(dev1, ABS_X, 0, max_coord, 0, 0); | 302 | input_set_abs_params(dev1, ABS_X, 0, max_coord, 0, 0); |
302 | input_set_abs_params(dev1, ABS_Y, 0, max_coord, 0, 0); | 303 | input_set_abs_params(dev1, ABS_Y, 0, max_coord, 0, 0); |
303 | 304 | ||
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c index 26c3b2e2ca94..b23a4f3ea5cd 100644 --- a/drivers/input/mouse/logibm.c +++ b/drivers/input/mouse/logibm.c | |||
@@ -156,9 +156,10 @@ static int __init logibm_init(void) | |||
156 | logibm_dev->id.product = 0x0001; | 156 | logibm_dev->id.product = 0x0001; |
157 | logibm_dev->id.version = 0x0100; | 157 | logibm_dev->id.version = 0x0100; |
158 | 158 | ||
159 | logibm_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 159 | logibm_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
160 | logibm_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 160 | logibm_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
161 | logibm_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 161 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
162 | logibm_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
162 | 163 | ||
163 | logibm_dev->open = logibm_open; | 164 | logibm_dev->open = logibm_open; |
164 | logibm_dev->close = logibm_close; | 165 | logibm_dev->close = logibm_close; |
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c index 05d992e514f0..8991ab0b4fe3 100644 --- a/drivers/input/mouse/pc110pad.c +++ b/drivers/input/mouse/pc110pad.c | |||
@@ -144,9 +144,9 @@ static int __init pc110pad_init(void) | |||
144 | pc110pad_dev->id.product = 0x0001; | 144 | pc110pad_dev->id.product = 0x0001; |
145 | pc110pad_dev->id.version = 0x0100; | 145 | pc110pad_dev->id.version = 0x0100; |
146 | 146 | ||
147 | pc110pad_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 147 | pc110pad_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
148 | pc110pad_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | 148 | pc110pad_dev->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y); |
149 | pc110pad_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 149 | pc110pad_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
150 | 150 | ||
151 | pc110pad_dev->absmax[ABS_X] = 0x1ff; | 151 | pc110pad_dev->absmax[ABS_X] = 0x1ff; |
152 | pc110pad_dev->absmax[ABS_Y] = 0x0ff; | 152 | pc110pad_dev->absmax[ABS_Y] = 0x0ff; |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 073525756532..da316d13d7f5 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -1115,9 +1115,10 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse | |||
1115 | 1115 | ||
1116 | input_dev->dev.parent = &psmouse->ps2dev.serio->dev; | 1116 | input_dev->dev.parent = &psmouse->ps2dev.serio->dev; |
1117 | 1117 | ||
1118 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 1118 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
1119 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 1119 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
1120 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 1120 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
1121 | input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
1121 | 1122 | ||
1122 | psmouse->set_rate = psmouse_set_rate; | 1123 | psmouse->set_rate = psmouse_set_rate; |
1123 | psmouse->set_resolution = psmouse_set_resolution; | 1124 | psmouse->set_resolution = psmouse_set_resolution; |
diff --git a/drivers/input/mouse/rpcmouse.c b/drivers/input/mouse/rpcmouse.c index 355efd0423e7..18a48636ba4a 100644 --- a/drivers/input/mouse/rpcmouse.c +++ b/drivers/input/mouse/rpcmouse.c | |||
@@ -78,9 +78,10 @@ static int __init rpcmouse_init(void) | |||
78 | rpcmouse_dev->id.product = 0x0001; | 78 | rpcmouse_dev->id.product = 0x0001; |
79 | rpcmouse_dev->id.version = 0x0100; | 79 | rpcmouse_dev->id.version = 0x0100; |
80 | 80 | ||
81 | rpcmouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 81 | rpcmouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
82 | rpcmouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 82 | rpcmouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
83 | rpcmouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 83 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
84 | rpcmouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
84 | 85 | ||
85 | rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX); | 86 | rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX); |
86 | rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY); | 87 | rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY); |
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c index 77b8ee2b9651..ed917bfd086a 100644 --- a/drivers/input/mouse/sermouse.c +++ b/drivers/input/mouse/sermouse.c | |||
@@ -268,9 +268,10 @@ static int sermouse_connect(struct serio *serio, struct serio_driver *drv) | |||
268 | input_dev->id.version = 0x0100; | 268 | input_dev->id.version = 0x0100; |
269 | input_dev->dev.parent = &serio->dev; | 269 | input_dev->dev.parent = &serio->dev; |
270 | 270 | ||
271 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 271 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
272 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); | 272 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
273 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 273 | BIT_MASK(BTN_RIGHT); |
274 | input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
274 | 275 | ||
275 | if (c & 0x01) set_bit(BTN_MIDDLE, input_dev->keybit); | 276 | if (c & 0x01) set_bit(BTN_MIDDLE, input_dev->keybit); |
276 | if (c & 0x02) set_bit(BTN_SIDE, input_dev->keybit); | 277 | if (c & 0x02) set_bit(BTN_SIDE, input_dev->keybit); |
diff --git a/drivers/input/mouse/touchkit_ps2.c b/drivers/input/mouse/touchkit_ps2.c index 7b977fd23571..3fadb2accac0 100644 --- a/drivers/input/mouse/touchkit_ps2.c +++ b/drivers/input/mouse/touchkit_ps2.c | |||
@@ -85,7 +85,7 @@ int touchkit_ps2_detect(struct psmouse *psmouse, int set_properties) | |||
85 | return -ENODEV; | 85 | return -ENODEV; |
86 | 86 | ||
87 | if (set_properties) { | 87 | if (set_properties) { |
88 | dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 88 | dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
89 | set_bit(BTN_TOUCH, dev->keybit); | 89 | set_bit(BTN_TOUCH, dev->keybit); |
90 | input_set_abs_params(dev, ABS_X, 0, TOUCHKIT_MAX_XC, 0, 0); | 90 | input_set_abs_params(dev, ABS_X, 0, TOUCHKIT_MAX_XC, 0, 0); |
91 | input_set_abs_params(dev, ABS_Y, 0, TOUCHKIT_MAX_YC, 0, 0); | 91 | input_set_abs_params(dev, ABS_Y, 0, TOUCHKIT_MAX_YC, 0, 0); |
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 79146d6ed2ab..78c3ea75da2a 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -998,34 +998,36 @@ static const struct input_device_id mousedev_ids[] = { | |||
998 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 998 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
999 | INPUT_DEVICE_ID_MATCH_KEYBIT | | 999 | INPUT_DEVICE_ID_MATCH_KEYBIT | |
1000 | INPUT_DEVICE_ID_MATCH_RELBIT, | 1000 | INPUT_DEVICE_ID_MATCH_RELBIT, |
1001 | .evbit = { BIT(EV_KEY) | BIT(EV_REL) }, | 1001 | .evbit = { BIT_MASK(EV_KEY) | BIT_MASK(EV_REL) }, |
1002 | .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) }, | 1002 | .keybit = { [BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) }, |
1003 | .relbit = { BIT(REL_X) | BIT(REL_Y) }, | 1003 | .relbit = { BIT_MASK(REL_X) | BIT_MASK(REL_Y) }, |
1004 | }, /* A mouse like device, at least one button, | 1004 | }, /* A mouse like device, at least one button, |
1005 | two relative axes */ | 1005 | two relative axes */ |
1006 | { | 1006 | { |
1007 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 1007 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
1008 | INPUT_DEVICE_ID_MATCH_RELBIT, | 1008 | INPUT_DEVICE_ID_MATCH_RELBIT, |
1009 | .evbit = { BIT(EV_KEY) | BIT(EV_REL) }, | 1009 | .evbit = { BIT_MASK(EV_KEY) | BIT_MASK(EV_REL) }, |
1010 | .relbit = { BIT(REL_WHEEL) }, | 1010 | .relbit = { BIT_MASK(REL_WHEEL) }, |
1011 | }, /* A separate scrollwheel */ | 1011 | }, /* A separate scrollwheel */ |
1012 | { | 1012 | { |
1013 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 1013 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
1014 | INPUT_DEVICE_ID_MATCH_KEYBIT | | 1014 | INPUT_DEVICE_ID_MATCH_KEYBIT | |
1015 | INPUT_DEVICE_ID_MATCH_ABSBIT, | 1015 | INPUT_DEVICE_ID_MATCH_ABSBIT, |
1016 | .evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, | 1016 | .evbit = { BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) }, |
1017 | .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, | 1017 | .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, |
1018 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) }, | 1018 | .absbit = { BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) }, |
1019 | }, /* A tablet like device, at least touch detection, | 1019 | }, /* A tablet like device, at least touch detection, |
1020 | two absolute axes */ | 1020 | two absolute axes */ |
1021 | { | 1021 | { |
1022 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 1022 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
1023 | INPUT_DEVICE_ID_MATCH_KEYBIT | | 1023 | INPUT_DEVICE_ID_MATCH_KEYBIT | |
1024 | INPUT_DEVICE_ID_MATCH_ABSBIT, | 1024 | INPUT_DEVICE_ID_MATCH_ABSBIT, |
1025 | .evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, | 1025 | .evbit = { BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) }, |
1026 | .keybit = { [LONG(BTN_TOOL_FINGER)] = BIT(BTN_TOOL_FINGER) }, | 1026 | .keybit = { [BIT_WORD(BTN_TOOL_FINGER)] = |
1027 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | | 1027 | BIT_MASK(BTN_TOOL_FINGER) }, |
1028 | BIT(ABS_TOOL_WIDTH) }, | 1028 | .absbit = { BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
1029 | BIT_MASK(ABS_PRESSURE) | | ||
1030 | BIT_MASK(ABS_TOOL_WIDTH) }, | ||
1029 | }, /* A touchpad */ | 1031 | }, /* A touchpad */ |
1030 | 1032 | ||
1031 | { }, /* Terminating entry */ | 1033 | { }, /* Terminating entry */ |
diff --git a/drivers/input/tablet/acecad.c b/drivers/input/tablet/acecad.c index dd2310458c46..b973d0ef6d16 100644 --- a/drivers/input/tablet/acecad.c +++ b/drivers/input/tablet/acecad.c | |||
@@ -192,10 +192,14 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
192 | input_dev->open = usb_acecad_open; | 192 | input_dev->open = usb_acecad_open; |
193 | input_dev->close = usb_acecad_close; | 193 | input_dev->close = usb_acecad_close; |
194 | 194 | ||
195 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 195 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
196 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 196 | input_dev->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
197 | input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 197 | BIT_MASK(ABS_PRESSURE); |
198 | input_dev->keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | 198 | input_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
199 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); | ||
200 | input_dev->keybit[BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_TOOL_PEN) | | ||
201 | BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS) | | ||
202 | BIT_MASK(BTN_STYLUS2); | ||
199 | 203 | ||
200 | switch (id->driver_info) { | 204 | switch (id->driver_info) { |
201 | case 0: | 205 | case 0: |
diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c index b2ca10f2fe0e..d2c6da264722 100644 --- a/drivers/input/tablet/gtco.c +++ b/drivers/input/tablet/gtco.c | |||
@@ -573,10 +573,12 @@ static void gtco_setup_caps(struct input_dev *inputdev) | |||
573 | struct gtco *device = input_get_drvdata(inputdev); | 573 | struct gtco *device = input_get_drvdata(inputdev); |
574 | 574 | ||
575 | /* Which events */ | 575 | /* Which events */ |
576 | inputdev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | 576 | inputdev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | |
577 | BIT_MASK(EV_MSC); | ||
577 | 578 | ||
578 | /* Misc event menu block */ | 579 | /* Misc event menu block */ |
579 | inputdev->mscbit[0] = BIT(MSC_SCAN)|BIT(MSC_SERIAL)|BIT(MSC_RAW) ; | 580 | inputdev->mscbit[0] = BIT_MASK(MSC_SCAN) | BIT_MASK(MSC_SERIAL) | |
581 | BIT_MASK(MSC_RAW); | ||
580 | 582 | ||
581 | /* Absolute values based on HID report info */ | 583 | /* Absolute values based on HID report info */ |
582 | input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X, | 584 | input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X, |
diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c index 91e6d00d4a43..1182fc133167 100644 --- a/drivers/input/tablet/kbtab.c +++ b/drivers/input/tablet/kbtab.c | |||
@@ -153,10 +153,13 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
153 | input_dev->open = kbtab_open; | 153 | input_dev->open = kbtab_open; |
154 | input_dev->close = kbtab_close; | 154 | input_dev->close = kbtab_close; |
155 | 155 | ||
156 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | 156 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | |
157 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 157 | BIT_MASK(EV_MSC); |
158 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); | 158 | input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | |
159 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); | 159 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); |
160 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) | | ||
161 | BIT_MASK(BTN_TOUCH); | ||
162 | input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); | ||
160 | input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); | 163 | input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); |
161 | input_set_abs_params(input_dev, ABS_Y, 0, 0x1750, 4, 0); | 164 | input_set_abs_params(input_dev, ABS_Y, 0, 0x1750, 4, 0); |
162 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); | 165 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); |
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 064e123c9b76..d64b1ea136b3 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -140,48 +140,58 @@ static void wacom_close(struct input_dev *dev) | |||
140 | 140 | ||
141 | void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 141 | void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
142 | { | 142 | { |
143 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_1) | BIT(BTN_5); | 143 | input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_1) | |
144 | BIT_MASK(BTN_5); | ||
144 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); | 145 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
145 | } | 146 | } |
146 | 147 | ||
147 | void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 148 | void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
148 | { | 149 | { |
149 | input_dev->evbit[0] |= BIT(EV_MSC); | 150 | input_dev->evbit[0] |= BIT_MASK(EV_MSC); |
150 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); | 151 | input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); |
151 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); | 152 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); |
152 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_4); | 153 | input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) | |
154 | BIT_MASK(BTN_4); | ||
153 | } | 155 | } |
154 | 156 | ||
155 | void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 157 | void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
156 | { | 158 | { |
157 | input_dev->evbit[0] |= BIT(EV_REL); | 159 | input_dev->evbit[0] |= BIT_MASK(EV_REL); |
158 | input_dev->relbit[0] |= BIT(REL_WHEEL); | 160 | input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); |
159 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 161 | input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | |
160 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); | 162 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); |
163 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | | ||
164 | BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); | ||
161 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); | 165 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); |
162 | } | 166 | } |
163 | 167 | ||
164 | void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 168 | void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
165 | { | 169 | { |
166 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); | 170 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); |
167 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3); | 171 | input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) | |
172 | BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3); | ||
168 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); | 173 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); |
169 | } | 174 | } |
170 | 175 | ||
171 | void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 176 | void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
172 | { | 177 | { |
173 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); | 178 | input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_4) | |
179 | BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | BIT_MASK(BTN_7); | ||
174 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); | 180 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); |
175 | } | 181 | } |
176 | 182 | ||
177 | void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 183 | void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
178 | { | 184 | { |
179 | input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); | 185 | input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL); |
180 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); | 186 | input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); |
181 | input_dev->relbit[0] |= BIT(REL_WHEEL); | 187 | input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); |
182 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 188 | input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | |
183 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) | 189 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE) | |
184 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); | 190 | BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA); |
191 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | | ||
192 | BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) | | ||
193 | BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) | | ||
194 | BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2); | ||
185 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); | 195 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); |
186 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); | 196 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); |
187 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); | 197 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); |
@@ -192,12 +202,13 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | |||
192 | 202 | ||
193 | void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 203 | void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
194 | { | 204 | { |
195 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); | 205 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_STYLUS2) | |
206 | BIT_MASK(BTN_TOOL_RUBBER); | ||
196 | } | 207 | } |
197 | 208 | ||
198 | void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 209 | void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
199 | { | 210 | { |
200 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER); | 211 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER); |
201 | } | 212 | } |
202 | 213 | ||
203 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) | 214 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) |
@@ -243,12 +254,13 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
243 | input_dev->open = wacom_open; | 254 | input_dev->open = wacom_open; |
244 | input_dev->close = wacom_close; | 255 | input_dev->close = wacom_close; |
245 | 256 | ||
246 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | 257 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
247 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | 258 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) | |
259 | BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS); | ||
248 | input_set_abs_params(input_dev, ABS_X, 0, wacom_wac->features->x_max, 4, 0); | 260 | input_set_abs_params(input_dev, ABS_X, 0, wacom_wac->features->x_max, 4, 0); |
249 | input_set_abs_params(input_dev, ABS_Y, 0, wacom_wac->features->y_max, 4, 0); | 261 | input_set_abs_params(input_dev, ABS_Y, 0, wacom_wac->features->y_max, 4, 0); |
250 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom_wac->features->pressure_max, 0, 0); | 262 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom_wac->features->pressure_max, 0, 0); |
251 | input_dev->absbit[LONG(ABS_MISC)] |= BIT(ABS_MISC); | 263 | input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); |
252 | 264 | ||
253 | wacom_init_input_dev(input_dev, wacom_wac); | 265 | wacom_init_input_dev(input_dev, wacom_wac); |
254 | 266 | ||
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 51ae4fb7d123..f59aecf5ec15 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -917,8 +917,8 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
917 | input_dev->phys = ts->phys; | 917 | input_dev->phys = ts->phys; |
918 | input_dev->dev.parent = &spi->dev; | 918 | input_dev->dev.parent = &spi->dev; |
919 | 919 | ||
920 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 920 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
921 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 921 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
922 | input_set_abs_params(input_dev, ABS_X, | 922 | input_set_abs_params(input_dev, ABS_X, |
923 | pdata->x_min ? : 0, | 923 | pdata->x_min ? : 0, |
924 | pdata->x_max ? : MAX_12BIT, | 924 | pdata->x_max ? : MAX_12BIT, |
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index e6a31d118786..b1b2e07bf080 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c | |||
@@ -302,8 +302,8 @@ static int __init corgits_probe(struct platform_device *pdev) | |||
302 | input_dev->id.version = 0x0100; | 302 | input_dev->id.version = 0x0100; |
303 | input_dev->dev.parent = &pdev->dev; | 303 | input_dev->dev.parent = &pdev->dev; |
304 | 304 | ||
305 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 305 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
306 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 306 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
307 | input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); | 307 | input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); |
308 | input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); | 308 | input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); |
309 | input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); | 309 | input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); |
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index 557d781719f1..d20689cdbd5d 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c | |||
@@ -320,8 +320,8 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv) | |||
320 | input_dev->id.version = 0x0100; | 320 | input_dev->id.version = 0x0100; |
321 | input_dev->dev.parent = &serio->dev; | 321 | input_dev->dev.parent = &serio->dev; |
322 | 322 | ||
323 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 323 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
324 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 324 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
325 | 325 | ||
326 | serio_set_drvdata(serio, elo); | 326 | serio_set_drvdata(serio, elo); |
327 | err = serio_open(serio, drv); | 327 | err = serio_open(serio, drv); |
diff --git a/drivers/input/touchscreen/fujitsu_ts.c b/drivers/input/touchscreen/fujitsu_ts.c index daf7a4afc935..80b21800355f 100644 --- a/drivers/input/touchscreen/fujitsu_ts.c +++ b/drivers/input/touchscreen/fujitsu_ts.c | |||
@@ -122,8 +122,8 @@ static int fujitsu_connect(struct serio *serio, struct serio_driver *drv) | |||
122 | input_dev->id.vendor = SERIO_FUJITSU; | 122 | input_dev->id.vendor = SERIO_FUJITSU; |
123 | input_dev->id.product = 0; | 123 | input_dev->id.product = 0; |
124 | input_dev->id.version = 0x0100; | 124 | input_dev->id.version = 0x0100; |
125 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 125 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
126 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 126 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
127 | 127 | ||
128 | input_set_abs_params(input_dev, ABS_X, 0, 4096, 0, 0); | 128 | input_set_abs_params(input_dev, ABS_X, 0, 4096, 0, 0); |
129 | input_set_abs_params(input_dev, ABS_Y, 0, 4096, 0, 0); | 129 | input_set_abs_params(input_dev, ABS_Y, 0, 4096, 0, 0); |
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c index 39d602600d7c..a48a15868c4a 100644 --- a/drivers/input/touchscreen/gunze.c +++ b/drivers/input/touchscreen/gunze.c | |||
@@ -137,8 +137,8 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv) | |||
137 | input_dev->id.product = 0x0051; | 137 | input_dev->id.product = 0x0051; |
138 | input_dev->id.version = 0x0100; | 138 | input_dev->id.version = 0x0100; |
139 | input_dev->dev.parent = &serio->dev; | 139 | input_dev->dev.parent = &serio->dev; |
140 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 140 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
141 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 141 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
142 | input_set_abs_params(input_dev, ABS_X, 24, 1000, 0, 0); | 142 | input_set_abs_params(input_dev, ABS_X, 24, 1000, 0, 0); |
143 | input_set_abs_params(input_dev, ABS_Y, 24, 1000, 0, 0); | 143 | input_set_abs_params(input_dev, ABS_Y, 24, 1000, 0, 0); |
144 | 144 | ||
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c index 09ed7803cb8f..2ae6c6016a86 100644 --- a/drivers/input/touchscreen/h3600_ts_input.c +++ b/drivers/input/touchscreen/h3600_ts_input.c | |||
@@ -373,8 +373,9 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
373 | 373 | ||
374 | input_dev->event = h3600ts_event; | 374 | input_dev->event = h3600ts_event; |
375 | 375 | ||
376 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR); | 376 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | |
377 | input_dev->ledbit[0] = BIT(LED_SLEEP); | 377 | BIT_MASK(EV_LED) | BIT_MASK(EV_PWR); |
378 | input_dev->ledbit[0] = BIT_MASK(LED_SLEEP); | ||
378 | input_set_abs_params(input_dev, ABS_X, 60, 985, 0, 0); | 379 | input_set_abs_params(input_dev, ABS_X, 60, 985, 0, 0); |
379 | input_set_abs_params(input_dev, ABS_Y, 35, 1024, 0, 0); | 380 | input_set_abs_params(input_dev, ABS_Y, 35, 1024, 0, 0); |
380 | 381 | ||
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c index 1a15475aedfc..c38d4e0f95c6 100644 --- a/drivers/input/touchscreen/hp680_ts_input.c +++ b/drivers/input/touchscreen/hp680_ts_input.c | |||
@@ -81,8 +81,8 @@ static int __init hp680_ts_init(void) | |||
81 | if (!hp680_ts_dev) | 81 | if (!hp680_ts_dev) |
82 | return -ENOMEM; | 82 | return -ENOMEM; |
83 | 83 | ||
84 | hp680_ts_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); | 84 | hp680_ts_dev->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY); |
85 | hp680_ts_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 85 | hp680_ts_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
86 | 86 | ||
87 | input_set_abs_params(hp680_ts_dev, ABS_X, | 87 | input_set_abs_params(hp680_ts_dev, ABS_X, |
88 | HP680_TS_ABS_X_MIN, HP680_TS_ABS_X_MAX, 0, 0); | 88 | HP680_TS_ABS_X_MIN, HP680_TS_ABS_X_MAX, 0, 0); |
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c index 44140feeffc5..80a658868706 100644 --- a/drivers/input/touchscreen/mk712.c +++ b/drivers/input/touchscreen/mk712.c | |||
@@ -186,8 +186,8 @@ static int __init mk712_init(void) | |||
186 | mk712_dev->open = mk712_open; | 186 | mk712_dev->open = mk712_open; |
187 | mk712_dev->close = mk712_close; | 187 | mk712_dev->close = mk712_close; |
188 | 188 | ||
189 | mk712_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 189 | mk712_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
190 | mk712_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 190 | mk712_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
191 | input_set_abs_params(mk712_dev, ABS_X, 0, 0xfff, 88, 0); | 191 | input_set_abs_params(mk712_dev, ABS_X, 0, 0xfff, 88, 0); |
192 | input_set_abs_params(mk712_dev, ABS_Y, 0, 0xfff, 88, 0); | 192 | input_set_abs_params(mk712_dev, ABS_Y, 0, 0xfff, 88, 0); |
193 | 193 | ||
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c index 4ec3b1f940c8..9077228418b7 100644 --- a/drivers/input/touchscreen/mtouch.c +++ b/drivers/input/touchscreen/mtouch.c | |||
@@ -151,8 +151,8 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv) | |||
151 | input_dev->id.product = 0; | 151 | input_dev->id.product = 0; |
152 | input_dev->id.version = 0x0100; | 152 | input_dev->id.version = 0x0100; |
153 | input_dev->dev.parent = &serio->dev; | 153 | input_dev->dev.parent = &serio->dev; |
154 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 154 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
155 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 155 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
156 | input_set_abs_params(mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0); | 156 | input_set_abs_params(mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0); |
157 | input_set_abs_params(mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0); | 157 | input_set_abs_params(mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0); |
158 | 158 | ||
diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c index f2c0d3c7149c..c7f9cebebbb6 100644 --- a/drivers/input/touchscreen/penmount.c +++ b/drivers/input/touchscreen/penmount.c | |||
@@ -113,8 +113,8 @@ static int pm_connect(struct serio *serio, struct serio_driver *drv) | |||
113 | input_dev->id.version = 0x0100; | 113 | input_dev->id.version = 0x0100; |
114 | input_dev->dev.parent = &serio->dev; | 114 | input_dev->dev.parent = &serio->dev; |
115 | 115 | ||
116 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 116 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
117 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 117 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
118 | input_set_abs_params(pm->dev, ABS_X, 0, 0x3ff, 0, 0); | 118 | input_set_abs_params(pm->dev, ABS_X, 0, 0x3ff, 0, 0); |
119 | input_set_abs_params(pm->dev, ABS_Y, 0, 0x3ff, 0, 0); | 119 | input_set_abs_params(pm->dev, ABS_Y, 0, 0x3ff, 0, 0); |
120 | 120 | ||
diff --git a/drivers/input/touchscreen/touchright.c b/drivers/input/touchscreen/touchright.c index 3def7bb1df44..3a5c142c2a78 100644 --- a/drivers/input/touchscreen/touchright.c +++ b/drivers/input/touchscreen/touchright.c | |||
@@ -125,8 +125,8 @@ static int tr_connect(struct serio *serio, struct serio_driver *drv) | |||
125 | input_dev->id.product = 0; | 125 | input_dev->id.product = 0; |
126 | input_dev->id.version = 0x0100; | 126 | input_dev->id.version = 0x0100; |
127 | input_dev->dev.parent = &serio->dev; | 127 | input_dev->dev.parent = &serio->dev; |
128 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 128 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
129 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 129 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
130 | input_set_abs_params(tr->dev, ABS_X, TR_MIN_XC, TR_MAX_XC, 0, 0); | 130 | input_set_abs_params(tr->dev, ABS_X, TR_MIN_XC, TR_MAX_XC, 0, 0); |
131 | input_set_abs_params(tr->dev, ABS_Y, TR_MIN_YC, TR_MAX_YC, 0, 0); | 131 | input_set_abs_params(tr->dev, ABS_Y, TR_MIN_YC, TR_MAX_YC, 0, 0); |
132 | 132 | ||
diff --git a/drivers/input/touchscreen/touchwin.c b/drivers/input/touchscreen/touchwin.c index ac4bdcf18666..763a656a59f8 100644 --- a/drivers/input/touchscreen/touchwin.c +++ b/drivers/input/touchscreen/touchwin.c | |||
@@ -132,8 +132,8 @@ static int tw_connect(struct serio *serio, struct serio_driver *drv) | |||
132 | input_dev->id.product = 0; | 132 | input_dev->id.product = 0; |
133 | input_dev->id.version = 0x0100; | 133 | input_dev->id.version = 0x0100; |
134 | input_dev->dev.parent = &serio->dev; | 134 | input_dev->dev.parent = &serio->dev; |
135 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 135 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
136 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 136 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
137 | input_set_abs_params(tw->dev, ABS_X, TW_MIN_XC, TW_MAX_XC, 0, 0); | 137 | input_set_abs_params(tw->dev, ABS_X, TW_MIN_XC, TW_MAX_XC, 0, 0); |
138 | input_set_abs_params(tw->dev, ABS_Y, TW_MIN_YC, TW_MAX_YC, 0, 0); | 138 | input_set_abs_params(tw->dev, ABS_Y, TW_MIN_YC, TW_MAX_YC, 0, 0); |
139 | 139 | ||
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c index 89373b01d8f5..7549939b9535 100644 --- a/drivers/input/touchscreen/ucb1400_ts.c +++ b/drivers/input/touchscreen/ucb1400_ts.c | |||
@@ -517,7 +517,7 @@ static int ucb1400_ts_probe(struct device *dev) | |||
517 | idev->id.product = id; | 517 | idev->id.product = id; |
518 | idev->open = ucb1400_ts_open; | 518 | idev->open = ucb1400_ts_open; |
519 | idev->close = ucb1400_ts_close; | 519 | idev->close = ucb1400_ts_close; |
520 | idev->evbit[0] = BIT(EV_ABS); | 520 | idev->evbit[0] = BIT_MASK(EV_ABS); |
521 | 521 | ||
522 | ucb1400_adc_enable(ucb); | 522 | ucb1400_adc_enable(ucb); |
523 | x_res = ucb1400_ts_read_xres(ucb); | 523 | x_res = ucb1400_ts_read_xres(ucb); |
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 9fb3d5c30999..5f34b78d5ddb 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c | |||
@@ -868,8 +868,8 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
868 | input_dev->open = usbtouch_open; | 868 | input_dev->open = usbtouch_open; |
869 | input_dev->close = usbtouch_close; | 869 | input_dev->close = usbtouch_close; |
870 | 870 | ||
871 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 871 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
872 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 872 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
873 | input_set_abs_params(input_dev, ABS_X, type->min_xc, type->max_xc, 0, 0); | 873 | input_set_abs_params(input_dev, ABS_X, type->min_xc, type->max_xc, 0, 0); |
874 | input_set_abs_params(input_dev, ABS_Y, type->min_yc, type->max_yc, 0, 0); | 874 | input_set_abs_params(input_dev, ABS_Y, type->min_yc, type->max_yc, 0, 0); |
875 | if (type->max_press) | 875 | if (type->max_press) |
diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c index 428872b653e9..669f6f67449c 100644 --- a/drivers/isdn/hardware/avm/b1dma.c +++ b/drivers/isdn/hardware/avm/b1dma.c | |||
@@ -486,11 +486,13 @@ static void b1dma_handle_rx(avmcard *card) | |||
486 | card->name); | 486 | card->name); |
487 | } else { | 487 | } else { |
488 | memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); | 488 | memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); |
489 | if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF) | 489 | if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF) { |
490 | spin_lock(&card->lock); | ||
490 | capilib_data_b3_conf(&cinfo->ncci_head, ApplId, | 491 | capilib_data_b3_conf(&cinfo->ncci_head, ApplId, |
491 | CAPIMSG_NCCI(skb->data), | 492 | CAPIMSG_NCCI(skb->data), |
492 | CAPIMSG_MSGID(skb->data)); | 493 | CAPIMSG_MSGID(skb->data)); |
493 | 494 | spin_unlock(&card->lock); | |
495 | } | ||
494 | capi_ctr_handle_message(ctrl, ApplId, skb); | 496 | capi_ctr_handle_message(ctrl, ApplId, skb); |
495 | } | 497 | } |
496 | break; | 498 | break; |
@@ -500,9 +502,9 @@ static void b1dma_handle_rx(avmcard *card) | |||
500 | ApplId = _get_word(&p); | 502 | ApplId = _get_word(&p); |
501 | NCCI = _get_word(&p); | 503 | NCCI = _get_word(&p); |
502 | WindowSize = _get_word(&p); | 504 | WindowSize = _get_word(&p); |
503 | 505 | spin_lock(&card->lock); | |
504 | capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize); | 506 | capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize); |
505 | 507 | spin_unlock(&card->lock); | |
506 | break; | 508 | break; |
507 | 509 | ||
508 | case RECEIVE_FREE_NCCI: | 510 | case RECEIVE_FREE_NCCI: |
@@ -510,9 +512,11 @@ static void b1dma_handle_rx(avmcard *card) | |||
510 | ApplId = _get_word(&p); | 512 | ApplId = _get_word(&p); |
511 | NCCI = _get_word(&p); | 513 | NCCI = _get_word(&p); |
512 | 514 | ||
513 | if (NCCI != 0xffffffff) | 515 | if (NCCI != 0xffffffff) { |
516 | spin_lock(&card->lock); | ||
514 | capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI); | 517 | capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI); |
515 | 518 | spin_unlock(&card->lock); | |
519 | } | ||
516 | break; | 520 | break; |
517 | 521 | ||
518 | case RECEIVE_START: | 522 | case RECEIVE_START: |
@@ -751,10 +755,10 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl) | |||
751 | 755 | ||
752 | spin_lock_irqsave(&card->lock, flags); | 756 | spin_lock_irqsave(&card->lock, flags); |
753 | b1dma_reset(card); | 757 | b1dma_reset(card); |
754 | spin_unlock_irqrestore(&card->lock, flags); | ||
755 | 758 | ||
756 | memset(cinfo->version, 0, sizeof(cinfo->version)); | 759 | memset(cinfo->version, 0, sizeof(cinfo->version)); |
757 | capilib_release(&cinfo->ncci_head); | 760 | capilib_release(&cinfo->ncci_head); |
761 | spin_unlock_irqrestore(&card->lock, flags); | ||
758 | capi_ctr_reseted(ctrl); | 762 | capi_ctr_reseted(ctrl); |
759 | } | 763 | } |
760 | 764 | ||
@@ -803,8 +807,11 @@ void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl) | |||
803 | avmcard *card = cinfo->card; | 807 | avmcard *card = cinfo->card; |
804 | struct sk_buff *skb; | 808 | struct sk_buff *skb; |
805 | void *p; | 809 | void *p; |
810 | unsigned long flags; | ||
806 | 811 | ||
812 | spin_lock_irqsave(&card->lock, flags); | ||
807 | capilib_release_appl(&cinfo->ncci_head, appl); | 813 | capilib_release_appl(&cinfo->ncci_head, appl); |
814 | spin_unlock_irqrestore(&card->lock, flags); | ||
808 | 815 | ||
809 | skb = alloc_skb(7, GFP_ATOMIC); | 816 | skb = alloc_skb(7, GFP_ATOMIC); |
810 | if (!skb) { | 817 | if (!skb) { |
@@ -832,10 +839,13 @@ u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) | |||
832 | u16 retval = CAPI_NOERROR; | 839 | u16 retval = CAPI_NOERROR; |
833 | 840 | ||
834 | if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) { | 841 | if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) { |
842 | unsigned long flags; | ||
843 | spin_lock_irqsave(&card->lock, flags); | ||
835 | retval = capilib_data_b3_req(&cinfo->ncci_head, | 844 | retval = capilib_data_b3_req(&cinfo->ncci_head, |
836 | CAPIMSG_APPID(skb->data), | 845 | CAPIMSG_APPID(skb->data), |
837 | CAPIMSG_NCCI(skb->data), | 846 | CAPIMSG_NCCI(skb->data), |
838 | CAPIMSG_MSGID(skb->data)); | 847 | CAPIMSG_MSGID(skb->data)); |
848 | spin_unlock_irqrestore(&card->lock, flags); | ||
839 | } | 849 | } |
840 | if (retval == CAPI_NOERROR) | 850 | if (retval == CAPI_NOERROR) |
841 | b1dma_queue_tx(card, skb); | 851 | b1dma_queue_tx(card, skb); |
diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c index 8710cf6214d9..4bbbbe688077 100644 --- a/drivers/isdn/hardware/avm/c4.c +++ b/drivers/isdn/hardware/avm/c4.c | |||
@@ -678,7 +678,9 @@ static irqreturn_t c4_handle_interrupt(avmcard *card) | |||
678 | for (i=0; i < card->nr_controllers; i++) { | 678 | for (i=0; i < card->nr_controllers; i++) { |
679 | avmctrl_info *cinfo = &card->ctrlinfo[i]; | 679 | avmctrl_info *cinfo = &card->ctrlinfo[i]; |
680 | memset(cinfo->version, 0, sizeof(cinfo->version)); | 680 | memset(cinfo->version, 0, sizeof(cinfo->version)); |
681 | spin_lock_irqsave(&card->lock, flags); | ||
681 | capilib_release(&cinfo->ncci_head); | 682 | capilib_release(&cinfo->ncci_head); |
683 | spin_unlock_irqrestore(&card->lock, flags); | ||
682 | capi_ctr_reseted(&cinfo->capi_ctrl); | 684 | capi_ctr_reseted(&cinfo->capi_ctrl); |
683 | } | 685 | } |
684 | card->nlogcontr = 0; | 686 | card->nlogcontr = 0; |
diff --git a/drivers/isdn/hardware/avm/t1isa.c b/drivers/isdn/hardware/avm/t1isa.c index c925020fe9b7..6130724e46e7 100644 --- a/drivers/isdn/hardware/avm/t1isa.c +++ b/drivers/isdn/hardware/avm/t1isa.c | |||
@@ -180,8 +180,8 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) | |||
180 | 180 | ||
181 | ApplId = (unsigned) b1_get_word(card->port); | 181 | ApplId = (unsigned) b1_get_word(card->port); |
182 | MsgLen = t1_get_slice(card->port, card->msgbuf); | 182 | MsgLen = t1_get_slice(card->port, card->msgbuf); |
183 | spin_unlock_irqrestore(&card->lock, flags); | ||
184 | if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { | 183 | if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { |
184 | spin_unlock_irqrestore(&card->lock, flags); | ||
185 | printk(KERN_ERR "%s: incoming packet dropped\n", | 185 | printk(KERN_ERR "%s: incoming packet dropped\n", |
186 | card->name); | 186 | card->name); |
187 | } else { | 187 | } else { |
@@ -190,7 +190,7 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) | |||
190 | capilib_data_b3_conf(&cinfo->ncci_head, ApplId, | 190 | capilib_data_b3_conf(&cinfo->ncci_head, ApplId, |
191 | CAPIMSG_NCCI(skb->data), | 191 | CAPIMSG_NCCI(skb->data), |
192 | CAPIMSG_MSGID(skb->data)); | 192 | CAPIMSG_MSGID(skb->data)); |
193 | 193 | spin_unlock_irqrestore(&card->lock, flags); | |
194 | capi_ctr_handle_message(ctrl, ApplId, skb); | 194 | capi_ctr_handle_message(ctrl, ApplId, skb); |
195 | } | 195 | } |
196 | break; | 196 | break; |
@@ -200,21 +200,17 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) | |||
200 | ApplId = b1_get_word(card->port); | 200 | ApplId = b1_get_word(card->port); |
201 | NCCI = b1_get_word(card->port); | 201 | NCCI = b1_get_word(card->port); |
202 | WindowSize = b1_get_word(card->port); | 202 | WindowSize = b1_get_word(card->port); |
203 | spin_unlock_irqrestore(&card->lock, flags); | ||
204 | |||
205 | capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize); | 203 | capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize); |
206 | 204 | spin_unlock_irqrestore(&card->lock, flags); | |
207 | break; | 205 | break; |
208 | 206 | ||
209 | case RECEIVE_FREE_NCCI: | 207 | case RECEIVE_FREE_NCCI: |
210 | 208 | ||
211 | ApplId = b1_get_word(card->port); | 209 | ApplId = b1_get_word(card->port); |
212 | NCCI = b1_get_word(card->port); | 210 | NCCI = b1_get_word(card->port); |
213 | spin_unlock_irqrestore(&card->lock, flags); | ||
214 | |||
215 | if (NCCI != 0xffffffff) | 211 | if (NCCI != 0xffffffff) |
216 | capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI); | 212 | capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI); |
217 | 213 | spin_unlock_irqrestore(&card->lock, flags); | |
218 | break; | 214 | break; |
219 | 215 | ||
220 | case RECEIVE_START: | 216 | case RECEIVE_START: |
@@ -333,13 +329,16 @@ static void t1isa_reset_ctr(struct capi_ctr *ctrl) | |||
333 | avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); | 329 | avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); |
334 | avmcard *card = cinfo->card; | 330 | avmcard *card = cinfo->card; |
335 | unsigned int port = card->port; | 331 | unsigned int port = card->port; |
332 | unsigned long flags; | ||
336 | 333 | ||
337 | t1_disable_irq(port); | 334 | t1_disable_irq(port); |
338 | b1_reset(port); | 335 | b1_reset(port); |
339 | b1_reset(port); | 336 | b1_reset(port); |
340 | 337 | ||
341 | memset(cinfo->version, 0, sizeof(cinfo->version)); | 338 | memset(cinfo->version, 0, sizeof(cinfo->version)); |
339 | spin_lock_irqsave(&card->lock, flags); | ||
342 | capilib_release(&cinfo->ncci_head); | 340 | capilib_release(&cinfo->ncci_head); |
341 | spin_unlock_irqrestore(&card->lock, flags); | ||
343 | capi_ctr_reseted(ctrl); | 342 | capi_ctr_reseted(ctrl); |
344 | } | 343 | } |
345 | 344 | ||
@@ -466,29 +465,26 @@ static u16 t1isa_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) | |||
466 | u8 subcmd = CAPIMSG_SUBCOMMAND(skb->data); | 465 | u8 subcmd = CAPIMSG_SUBCOMMAND(skb->data); |
467 | u16 dlen, retval; | 466 | u16 dlen, retval; |
468 | 467 | ||
468 | spin_lock_irqsave(&card->lock, flags); | ||
469 | if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) { | 469 | if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) { |
470 | retval = capilib_data_b3_req(&cinfo->ncci_head, | 470 | retval = capilib_data_b3_req(&cinfo->ncci_head, |
471 | CAPIMSG_APPID(skb->data), | 471 | CAPIMSG_APPID(skb->data), |
472 | CAPIMSG_NCCI(skb->data), | 472 | CAPIMSG_NCCI(skb->data), |
473 | CAPIMSG_MSGID(skb->data)); | 473 | CAPIMSG_MSGID(skb->data)); |
474 | if (retval != CAPI_NOERROR) | 474 | if (retval != CAPI_NOERROR) { |
475 | spin_unlock_irqrestore(&card->lock, flags); | ||
475 | return retval; | 476 | return retval; |
476 | 477 | } | |
477 | dlen = CAPIMSG_DATALEN(skb->data); | 478 | dlen = CAPIMSG_DATALEN(skb->data); |
478 | 479 | ||
479 | spin_lock_irqsave(&card->lock, flags); | ||
480 | b1_put_byte(port, SEND_DATA_B3_REQ); | 480 | b1_put_byte(port, SEND_DATA_B3_REQ); |
481 | t1_put_slice(port, skb->data, len); | 481 | t1_put_slice(port, skb->data, len); |
482 | t1_put_slice(port, skb->data + len, dlen); | 482 | t1_put_slice(port, skb->data + len, dlen); |
483 | spin_unlock_irqrestore(&card->lock, flags); | ||
484 | } else { | 483 | } else { |
485 | |||
486 | spin_lock_irqsave(&card->lock, flags); | ||
487 | b1_put_byte(port, SEND_MESSAGE); | 484 | b1_put_byte(port, SEND_MESSAGE); |
488 | t1_put_slice(port, skb->data, len); | 485 | t1_put_slice(port, skb->data, len); |
489 | spin_unlock_irqrestore(&card->lock, flags); | ||
490 | } | 486 | } |
491 | 487 | spin_unlock_irqrestore(&card->lock, flags); | |
492 | dev_kfree_skb_any(skb); | 488 | dev_kfree_skb_any(skb); |
493 | return CAPI_NOERROR; | 489 | return CAPI_NOERROR; |
494 | } | 490 | } |
diff --git a/drivers/isdn/sc/debug.h b/drivers/isdn/sc/debug.h deleted file mode 100644 index e9db96ede4b2..000000000000 --- a/drivers/isdn/sc/debug.h +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | /* $Id: debug.h,v 1.2.8.1 2001/09/23 22:24:59 kai Exp $ | ||
2 | * | ||
3 | * Copyright (C) 1996 SpellCaster Telecommunications Inc. | ||
4 | * | ||
5 | * This software may be used and distributed according to the terms | ||
6 | * of the GNU General Public License, incorporated herein by reference. | ||
7 | * | ||
8 | * For more information, please contact gpl-info@spellcast.com or write: | ||
9 | * | ||
10 | * SpellCaster Telecommunications Inc. | ||
11 | * 5621 Finch Avenue East, Unit #3 | ||
12 | * Scarborough, Ontario Canada | ||
13 | * M1B 2T9 | ||
14 | * +1 (416) 297-8565 | ||
15 | * +1 (416) 297-6433 Facsimile | ||
16 | */ | ||
17 | |||
18 | #define REQUEST_IRQ(a,b,c,d,e) request_irq(a,b,c,d,e) | ||
19 | #define FREE_IRQ(a,b) free_irq(a,b) | ||
diff --git a/drivers/isdn/sc/includes.h b/drivers/isdn/sc/includes.h index 5286e0c810a9..4766e5b77378 100644 --- a/drivers/isdn/sc/includes.h +++ b/drivers/isdn/sc/includes.h | |||
@@ -14,4 +14,3 @@ | |||
14 | #include <linux/timer.h> | 14 | #include <linux/timer.h> |
15 | #include <linux/wait.h> | 15 | #include <linux/wait.h> |
16 | #include <linux/isdnif.h> | 16 | #include <linux/isdnif.h> |
17 | #include "debug.h" | ||
diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c index 0bf76344a0d5..d09c854cfac7 100644 --- a/drivers/isdn/sc/init.c +++ b/drivers/isdn/sc/init.c | |||
@@ -404,7 +404,7 @@ static void __exit sc_exit(void) | |||
404 | /* | 404 | /* |
405 | * Release the IRQ | 405 | * Release the IRQ |
406 | */ | 406 | */ |
407 | FREE_IRQ(sc_adapter[i]->interrupt, NULL); | 407 | free_irq(sc_adapter[i]->interrupt, NULL); |
408 | 408 | ||
409 | /* | 409 | /* |
410 | * Reset for a clean start | 410 | * Reset for a clean start |
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index 2766e4fc4ea8..883da72b5368 100644 --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c | |||
@@ -791,8 +791,10 @@ adbhid_input_register(int id, int default_id, int original_handler_id, | |||
791 | if (hid->keycode[i]) | 791 | if (hid->keycode[i]) |
792 | set_bit(hid->keycode[i], input_dev->keybit); | 792 | set_bit(hid->keycode[i], input_dev->keybit); |
793 | 793 | ||
794 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 794 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_LED) | |
795 | input_dev->ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML); | 795 | BIT_MASK(EV_REP); |
796 | input_dev->ledbit[0] = BIT_MASK(LED_SCROLLL) | | ||
797 | BIT_MASK(LED_CAPSL) | BIT_MASK(LED_NUML); | ||
796 | input_dev->event = adbhid_kbd_event; | 798 | input_dev->event = adbhid_kbd_event; |
797 | input_dev->keycodemax = KEY_FN; | 799 | input_dev->keycodemax = KEY_FN; |
798 | input_dev->keycodesize = sizeof(hid->keycode[0]); | 800 | input_dev->keycodesize = sizeof(hid->keycode[0]); |
@@ -801,16 +803,18 @@ adbhid_input_register(int id, int default_id, int original_handler_id, | |||
801 | case ADB_MOUSE: | 803 | case ADB_MOUSE: |
802 | sprintf(hid->name, "ADB mouse"); | 804 | sprintf(hid->name, "ADB mouse"); |
803 | 805 | ||
804 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 806 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
805 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 807 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
806 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 808 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
809 | input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
807 | break; | 810 | break; |
808 | 811 | ||
809 | case ADB_MISC: | 812 | case ADB_MISC: |
810 | switch (original_handler_id) { | 813 | switch (original_handler_id) { |
811 | case 0x02: /* Adjustable keyboard button device */ | 814 | case 0x02: /* Adjustable keyboard button device */ |
812 | sprintf(hid->name, "ADB adjustable keyboard buttons"); | 815 | sprintf(hid->name, "ADB adjustable keyboard buttons"); |
813 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 816 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | |
817 | BIT_MASK(EV_REP); | ||
814 | set_bit(KEY_SOUND, input_dev->keybit); | 818 | set_bit(KEY_SOUND, input_dev->keybit); |
815 | set_bit(KEY_MUTE, input_dev->keybit); | 819 | set_bit(KEY_MUTE, input_dev->keybit); |
816 | set_bit(KEY_VOLUMEUP, input_dev->keybit); | 820 | set_bit(KEY_VOLUMEUP, input_dev->keybit); |
@@ -818,7 +822,8 @@ adbhid_input_register(int id, int default_id, int original_handler_id, | |||
818 | break; | 822 | break; |
819 | case 0x1f: /* Powerbook button device */ | 823 | case 0x1f: /* Powerbook button device */ |
820 | sprintf(hid->name, "ADB Powerbook buttons"); | 824 | sprintf(hid->name, "ADB Powerbook buttons"); |
821 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 825 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | |
826 | BIT_MASK(EV_REP); | ||
822 | set_bit(KEY_MUTE, input_dev->keybit); | 827 | set_bit(KEY_MUTE, input_dev->keybit); |
823 | set_bit(KEY_VOLUMEUP, input_dev->keybit); | 828 | set_bit(KEY_VOLUMEUP, input_dev->keybit); |
824 | set_bit(KEY_VOLUMEDOWN, input_dev->keybit); | 829 | set_bit(KEY_VOLUMEDOWN, input_dev->keybit); |
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index 33dee3a773ed..89302309da92 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c | |||
@@ -117,9 +117,10 @@ static int emumousebtn_input_register(void) | |||
117 | emumousebtn->id.product = 0x0001; | 117 | emumousebtn->id.product = 0x0001; |
118 | emumousebtn->id.version = 0x0100; | 118 | emumousebtn->id.version = 0x0100; |
119 | 119 | ||
120 | emumousebtn->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 120 | emumousebtn->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
121 | emumousebtn->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 121 | emumousebtn->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
122 | emumousebtn->relbit[0] = BIT(REL_X) | BIT(REL_Y); | 122 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
123 | emumousebtn->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
123 | 124 | ||
124 | ret = input_register_device(emumousebtn); | 125 | ret = input_register_device(emumousebtn); |
125 | if (ret) | 126 | if (ret) |
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index c803d2bba65d..48d647abea46 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c | |||
@@ -563,7 +563,7 @@ static void media_bay_step(int i) | |||
563 | ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL); | 563 | ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL); |
564 | hw.irq = bay->cd_irq; | 564 | hw.irq = bay->cd_irq; |
565 | hw.chipset = ide_pmac; | 565 | hw.chipset = ide_pmac; |
566 | bay->cd_index = ide_register_hw(&hw, 0, NULL); | 566 | bay->cd_index = ide_register_hw(&hw, NULL, 0, NULL); |
567 | pmu_resume(); | 567 | pmu_resume(); |
568 | } | 568 | } |
569 | if (bay->cd_index == -1) { | 569 | if (bay->cd_index == -1) { |
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 34a8c60a254a..9b6fbf044fd8 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig | |||
@@ -267,6 +267,12 @@ config DM_MULTIPATH_RDAC | |||
267 | ---help--- | 267 | ---help--- |
268 | Multipath support for LSI/Engenio RDAC. | 268 | Multipath support for LSI/Engenio RDAC. |
269 | 269 | ||
270 | config DM_MULTIPATH_HP | ||
271 | tristate "HP MSA multipath support (EXPERIMENTAL)" | ||
272 | depends on DM_MULTIPATH && BLK_DEV_DM && EXPERIMENTAL | ||
273 | ---help--- | ||
274 | Multipath support for HP MSA (Active/Passive) series hardware. | ||
275 | |||
270 | config DM_DELAY | 276 | config DM_DELAY |
271 | tristate "I/O delaying target (EXPERIMENTAL)" | 277 | tristate "I/O delaying target (EXPERIMENTAL)" |
272 | depends on BLK_DEV_DM && EXPERIMENTAL | 278 | depends on BLK_DEV_DM && EXPERIMENTAL |
@@ -276,4 +282,10 @@ config DM_DELAY | |||
276 | 282 | ||
277 | If unsure, say N. | 283 | If unsure, say N. |
278 | 284 | ||
285 | config DM_UEVENT | ||
286 | bool "DM uevents (EXPERIMENTAL)" | ||
287 | depends on BLK_DEV_DM && EXPERIMENTAL | ||
288 | ---help--- | ||
289 | Generate udev events for DM events. | ||
290 | |||
279 | endif # MD | 291 | endif # MD |
diff --git a/drivers/md/Makefile b/drivers/md/Makefile index c49366cdc05d..d9aa7edb8780 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile | |||
@@ -8,6 +8,7 @@ dm-multipath-objs := dm-hw-handler.o dm-path-selector.o dm-mpath.o | |||
8 | dm-snapshot-objs := dm-snap.o dm-exception-store.o | 8 | dm-snapshot-objs := dm-snap.o dm-exception-store.o |
9 | dm-mirror-objs := dm-log.o dm-raid1.o | 9 | dm-mirror-objs := dm-log.o dm-raid1.o |
10 | dm-rdac-objs := dm-mpath-rdac.o | 10 | dm-rdac-objs := dm-mpath-rdac.o |
11 | dm-hp-sw-objs := dm-mpath-hp-sw.o | ||
11 | md-mod-objs := md.o bitmap.o | 12 | md-mod-objs := md.o bitmap.o |
12 | raid456-objs := raid5.o raid6algos.o raid6recov.o raid6tables.o \ | 13 | raid456-objs := raid5.o raid6algos.o raid6recov.o raid6tables.o \ |
13 | raid6int1.o raid6int2.o raid6int4.o \ | 14 | raid6int1.o raid6int2.o raid6int4.o \ |
@@ -35,6 +36,7 @@ obj-$(CONFIG_DM_CRYPT) += dm-crypt.o | |||
35 | obj-$(CONFIG_DM_DELAY) += dm-delay.o | 36 | obj-$(CONFIG_DM_DELAY) += dm-delay.o |
36 | obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o | 37 | obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o |
37 | obj-$(CONFIG_DM_MULTIPATH_EMC) += dm-emc.o | 38 | obj-$(CONFIG_DM_MULTIPATH_EMC) += dm-emc.o |
39 | obj-$(CONFIG_DM_MULTIPATH_HP) += dm-hp-sw.o | ||
38 | obj-$(CONFIG_DM_MULTIPATH_RDAC) += dm-rdac.o | 40 | obj-$(CONFIG_DM_MULTIPATH_RDAC) += dm-rdac.o |
39 | obj-$(CONFIG_DM_SNAPSHOT) += dm-snapshot.o | 41 | obj-$(CONFIG_DM_SNAPSHOT) += dm-snapshot.o |
40 | obj-$(CONFIG_DM_MIRROR) += dm-mirror.o | 42 | obj-$(CONFIG_DM_MIRROR) += dm-mirror.o |
@@ -48,6 +50,10 @@ ifeq ($(CONFIG_ALTIVEC),y) | |||
48 | altivec_flags := -maltivec -mabi=altivec | 50 | altivec_flags := -maltivec -mabi=altivec |
49 | endif | 51 | endif |
50 | 52 | ||
53 | ifeq ($(CONFIG_DM_UEVENT),y) | ||
54 | dm-mod-objs += dm-uevent.o | ||
55 | endif | ||
56 | |||
51 | targets += raid6int1.c | 57 | targets += raid6int1.c |
52 | $(obj)/raid6int1.c: UNROLL := 1 | 58 | $(obj)/raid6int1.c: UNROLL := 1 |
53 | $(obj)/raid6int1.c: $(src)/raid6int.uc $(src)/unroll.pl FORCE | 59 | $(obj)/raid6int1.c: $(src)/raid6int.uc $(src)/unroll.pl FORCE |
diff --git a/drivers/md/dm-bio-list.h b/drivers/md/dm-bio-list.h index 3f7b827649e3..d4509be0fe67 100644 --- a/drivers/md/dm-bio-list.h +++ b/drivers/md/dm-bio-list.h | |||
@@ -21,11 +21,6 @@ static inline int bio_list_empty(const struct bio_list *bl) | |||
21 | return bl->head == NULL; | 21 | return bl->head == NULL; |
22 | } | 22 | } |
23 | 23 | ||
24 | #define BIO_LIST_INIT { .head = NULL, .tail = NULL } | ||
25 | |||
26 | #define BIO_LIST(bl) \ | ||
27 | struct bio_list bl = BIO_LIST_INIT | ||
28 | |||
29 | static inline void bio_list_init(struct bio_list *bl) | 24 | static inline void bio_list_init(struct bio_list *bl) |
30 | { | 25 | { |
31 | bl->head = bl->tail = NULL; | 26 | bl->head = bl->tail = NULL; |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 64fee90bb68b..b41f945df8a1 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -36,7 +36,6 @@ struct dm_crypt_io { | |||
36 | struct work_struct work; | 36 | struct work_struct work; |
37 | atomic_t pending; | 37 | atomic_t pending; |
38 | int error; | 38 | int error; |
39 | int post_process; | ||
40 | }; | 39 | }; |
41 | 40 | ||
42 | /* | 41 | /* |
@@ -57,7 +56,7 @@ struct crypt_config; | |||
57 | 56 | ||
58 | struct crypt_iv_operations { | 57 | struct crypt_iv_operations { |
59 | int (*ctr)(struct crypt_config *cc, struct dm_target *ti, | 58 | int (*ctr)(struct crypt_config *cc, struct dm_target *ti, |
60 | const char *opts); | 59 | const char *opts); |
61 | void (*dtr)(struct crypt_config *cc); | 60 | void (*dtr)(struct crypt_config *cc); |
62 | const char *(*status)(struct crypt_config *cc); | 61 | const char *(*status)(struct crypt_config *cc); |
63 | int (*generator)(struct crypt_config *cc, u8 *iv, sector_t sector); | 62 | int (*generator)(struct crypt_config *cc, u8 *iv, sector_t sector); |
@@ -80,6 +79,8 @@ struct crypt_config { | |||
80 | mempool_t *page_pool; | 79 | mempool_t *page_pool; |
81 | struct bio_set *bs; | 80 | struct bio_set *bs; |
82 | 81 | ||
82 | struct workqueue_struct *io_queue; | ||
83 | struct workqueue_struct *crypt_queue; | ||
83 | /* | 84 | /* |
84 | * crypto related data | 85 | * crypto related data |
85 | */ | 86 | */ |
@@ -137,7 +138,7 @@ static int crypt_iv_plain_gen(struct crypt_config *cc, u8 *iv, sector_t sector) | |||
137 | } | 138 | } |
138 | 139 | ||
139 | static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, | 140 | static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, |
140 | const char *opts) | 141 | const char *opts) |
141 | { | 142 | { |
142 | struct crypto_cipher *essiv_tfm; | 143 | struct crypto_cipher *essiv_tfm; |
143 | struct crypto_hash *hash_tfm; | 144 | struct crypto_hash *hash_tfm; |
@@ -175,6 +176,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, | |||
175 | 176 | ||
176 | if (err) { | 177 | if (err) { |
177 | ti->error = "Error calculating hash in ESSIV"; | 178 | ti->error = "Error calculating hash in ESSIV"; |
179 | kfree(salt); | ||
178 | return err; | 180 | return err; |
179 | } | 181 | } |
180 | 182 | ||
@@ -188,7 +190,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, | |||
188 | if (crypto_cipher_blocksize(essiv_tfm) != | 190 | if (crypto_cipher_blocksize(essiv_tfm) != |
189 | crypto_blkcipher_ivsize(cc->tfm)) { | 191 | crypto_blkcipher_ivsize(cc->tfm)) { |
190 | ti->error = "Block size of ESSIV cipher does " | 192 | ti->error = "Block size of ESSIV cipher does " |
191 | "not match IV size of block cipher"; | 193 | "not match IV size of block cipher"; |
192 | crypto_free_cipher(essiv_tfm); | 194 | crypto_free_cipher(essiv_tfm); |
193 | kfree(salt); | 195 | kfree(salt); |
194 | return -EINVAL; | 196 | return -EINVAL; |
@@ -319,10 +321,10 @@ crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out, | |||
319 | return r; | 321 | return r; |
320 | } | 322 | } |
321 | 323 | ||
322 | static void | 324 | static void crypt_convert_init(struct crypt_config *cc, |
323 | crypt_convert_init(struct crypt_config *cc, struct convert_context *ctx, | 325 | struct convert_context *ctx, |
324 | struct bio *bio_out, struct bio *bio_in, | 326 | struct bio *bio_out, struct bio *bio_in, |
325 | sector_t sector, int write) | 327 | sector_t sector, int write) |
326 | { | 328 | { |
327 | ctx->bio_in = bio_in; | 329 | ctx->bio_in = bio_in; |
328 | ctx->bio_out = bio_out; | 330 | ctx->bio_out = bio_out; |
@@ -338,7 +340,7 @@ crypt_convert_init(struct crypt_config *cc, struct convert_context *ctx, | |||
338 | * Encrypt / decrypt data from one bio to another one (can be the same one) | 340 | * Encrypt / decrypt data from one bio to another one (can be the same one) |
339 | */ | 341 | */ |
340 | static int crypt_convert(struct crypt_config *cc, | 342 | static int crypt_convert(struct crypt_config *cc, |
341 | struct convert_context *ctx) | 343 | struct convert_context *ctx) |
342 | { | 344 | { |
343 | int r = 0; | 345 | int r = 0; |
344 | 346 | ||
@@ -370,7 +372,7 @@ static int crypt_convert(struct crypt_config *cc, | |||
370 | } | 372 | } |
371 | 373 | ||
372 | r = crypt_convert_scatterlist(cc, &sg_out, &sg_in, sg_in.length, | 374 | r = crypt_convert_scatterlist(cc, &sg_out, &sg_in, sg_in.length, |
373 | ctx->write, ctx->sector); | 375 | ctx->write, ctx->sector); |
374 | if (r < 0) | 376 | if (r < 0) |
375 | break; | 377 | break; |
376 | 378 | ||
@@ -380,13 +382,13 @@ static int crypt_convert(struct crypt_config *cc, | |||
380 | return r; | 382 | return r; |
381 | } | 383 | } |
382 | 384 | ||
383 | static void dm_crypt_bio_destructor(struct bio *bio) | 385 | static void dm_crypt_bio_destructor(struct bio *bio) |
384 | { | 386 | { |
385 | struct dm_crypt_io *io = bio->bi_private; | 387 | struct dm_crypt_io *io = bio->bi_private; |
386 | struct crypt_config *cc = io->target->private; | 388 | struct crypt_config *cc = io->target->private; |
387 | 389 | ||
388 | bio_free(bio, cc->bs); | 390 | bio_free(bio, cc->bs); |
389 | } | 391 | } |
390 | 392 | ||
391 | /* | 393 | /* |
392 | * Generate a new unfragmented bio with the given size | 394 | * Generate a new unfragmented bio with the given size |
@@ -458,7 +460,7 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) | |||
458 | * One of the bios was finished. Check for completion of | 460 | * One of the bios was finished. Check for completion of |
459 | * the whole request and correctly clean up the buffer. | 461 | * the whole request and correctly clean up the buffer. |
460 | */ | 462 | */ |
461 | static void dec_pending(struct dm_crypt_io *io, int error) | 463 | static void crypt_dec_pending(struct dm_crypt_io *io, int error) |
462 | { | 464 | { |
463 | struct crypt_config *cc = (struct crypt_config *) io->target->private; | 465 | struct crypt_config *cc = (struct crypt_config *) io->target->private; |
464 | 466 | ||
@@ -474,18 +476,36 @@ static void dec_pending(struct dm_crypt_io *io, int error) | |||
474 | } | 476 | } |
475 | 477 | ||
476 | /* | 478 | /* |
477 | * kcryptd: | 479 | * kcryptd/kcryptd_io: |
478 | * | 480 | * |
479 | * Needed because it would be very unwise to do decryption in an | 481 | * Needed because it would be very unwise to do decryption in an |
480 | * interrupt context. | 482 | * interrupt context. |
483 | * | ||
484 | * kcryptd performs the actual encryption or decryption. | ||
485 | * | ||
486 | * kcryptd_io performs the IO submission. | ||
487 | * | ||
488 | * They must be separated as otherwise the final stages could be | ||
489 | * starved by new requests which can block in the first stages due | ||
490 | * to memory allocation. | ||
481 | */ | 491 | */ |
482 | static struct workqueue_struct *_kcryptd_workqueue; | ||
483 | static void kcryptd_do_work(struct work_struct *work); | 492 | static void kcryptd_do_work(struct work_struct *work); |
493 | static void kcryptd_do_crypt(struct work_struct *work); | ||
484 | 494 | ||
485 | static void kcryptd_queue_io(struct dm_crypt_io *io) | 495 | static void kcryptd_queue_io(struct dm_crypt_io *io) |
486 | { | 496 | { |
497 | struct crypt_config *cc = io->target->private; | ||
498 | |||
487 | INIT_WORK(&io->work, kcryptd_do_work); | 499 | INIT_WORK(&io->work, kcryptd_do_work); |
488 | queue_work(_kcryptd_workqueue, &io->work); | 500 | queue_work(cc->io_queue, &io->work); |
501 | } | ||
502 | |||
503 | static void kcryptd_queue_crypt(struct dm_crypt_io *io) | ||
504 | { | ||
505 | struct crypt_config *cc = io->target->private; | ||
506 | |||
507 | INIT_WORK(&io->work, kcryptd_do_crypt); | ||
508 | queue_work(cc->crypt_queue, &io->work); | ||
489 | } | 509 | } |
490 | 510 | ||
491 | static void crypt_endio(struct bio *clone, int error) | 511 | static void crypt_endio(struct bio *clone, int error) |
@@ -508,13 +528,12 @@ static void crypt_endio(struct bio *clone, int error) | |||
508 | } | 528 | } |
509 | 529 | ||
510 | bio_put(clone); | 530 | bio_put(clone); |
511 | io->post_process = 1; | 531 | kcryptd_queue_crypt(io); |
512 | kcryptd_queue_io(io); | ||
513 | return; | 532 | return; |
514 | 533 | ||
515 | out: | 534 | out: |
516 | bio_put(clone); | 535 | bio_put(clone); |
517 | dec_pending(io, error); | 536 | crypt_dec_pending(io, error); |
518 | } | 537 | } |
519 | 538 | ||
520 | static void clone_init(struct dm_crypt_io *io, struct bio *clone) | 539 | static void clone_init(struct dm_crypt_io *io, struct bio *clone) |
@@ -544,7 +563,7 @@ static void process_read(struct dm_crypt_io *io) | |||
544 | */ | 563 | */ |
545 | clone = bio_alloc_bioset(GFP_NOIO, bio_segments(base_bio), cc->bs); | 564 | clone = bio_alloc_bioset(GFP_NOIO, bio_segments(base_bio), cc->bs); |
546 | if (unlikely(!clone)) { | 565 | if (unlikely(!clone)) { |
547 | dec_pending(io, -ENOMEM); | 566 | crypt_dec_pending(io, -ENOMEM); |
548 | return; | 567 | return; |
549 | } | 568 | } |
550 | 569 | ||
@@ -579,7 +598,7 @@ static void process_write(struct dm_crypt_io *io) | |||
579 | while (remaining) { | 598 | while (remaining) { |
580 | clone = crypt_alloc_buffer(io, remaining); | 599 | clone = crypt_alloc_buffer(io, remaining); |
581 | if (unlikely(!clone)) { | 600 | if (unlikely(!clone)) { |
582 | dec_pending(io, -ENOMEM); | 601 | crypt_dec_pending(io, -ENOMEM); |
583 | return; | 602 | return; |
584 | } | 603 | } |
585 | 604 | ||
@@ -589,7 +608,7 @@ static void process_write(struct dm_crypt_io *io) | |||
589 | if (unlikely(crypt_convert(cc, &ctx) < 0)) { | 608 | if (unlikely(crypt_convert(cc, &ctx) < 0)) { |
590 | crypt_free_buffer_pages(cc, clone); | 609 | crypt_free_buffer_pages(cc, clone); |
591 | bio_put(clone); | 610 | bio_put(clone); |
592 | dec_pending(io, -EIO); | 611 | crypt_dec_pending(io, -EIO); |
593 | return; | 612 | return; |
594 | } | 613 | } |
595 | 614 | ||
@@ -624,17 +643,23 @@ static void process_read_endio(struct dm_crypt_io *io) | |||
624 | crypt_convert_init(cc, &ctx, io->base_bio, io->base_bio, | 643 | crypt_convert_init(cc, &ctx, io->base_bio, io->base_bio, |
625 | io->base_bio->bi_sector - io->target->begin, 0); | 644 | io->base_bio->bi_sector - io->target->begin, 0); |
626 | 645 | ||
627 | dec_pending(io, crypt_convert(cc, &ctx)); | 646 | crypt_dec_pending(io, crypt_convert(cc, &ctx)); |
628 | } | 647 | } |
629 | 648 | ||
630 | static void kcryptd_do_work(struct work_struct *work) | 649 | static void kcryptd_do_work(struct work_struct *work) |
631 | { | 650 | { |
632 | struct dm_crypt_io *io = container_of(work, struct dm_crypt_io, work); | 651 | struct dm_crypt_io *io = container_of(work, struct dm_crypt_io, work); |
633 | 652 | ||
634 | if (io->post_process) | 653 | if (bio_data_dir(io->base_bio) == READ) |
635 | process_read_endio(io); | ||
636 | else if (bio_data_dir(io->base_bio) == READ) | ||
637 | process_read(io); | 654 | process_read(io); |
655 | } | ||
656 | |||
657 | static void kcryptd_do_crypt(struct work_struct *work) | ||
658 | { | ||
659 | struct dm_crypt_io *io = container_of(work, struct dm_crypt_io, work); | ||
660 | |||
661 | if (bio_data_dir(io->base_bio) == READ) | ||
662 | process_read_endio(io); | ||
638 | else | 663 | else |
639 | process_write(io); | 664 | process_write(io); |
640 | } | 665 | } |
@@ -690,7 +715,7 @@ static int crypt_set_key(struct crypt_config *cc, char *key) | |||
690 | cc->key_size = key_size; /* initial settings */ | 715 | cc->key_size = key_size; /* initial settings */ |
691 | 716 | ||
692 | if ((!key_size && strcmp(key, "-")) || | 717 | if ((!key_size && strcmp(key, "-")) || |
693 | (key_size && crypt_decode_key(cc->key, key, key_size) < 0)) | 718 | (key_size && crypt_decode_key(cc->key, key, key_size) < 0)) |
694 | return -EINVAL; | 719 | return -EINVAL; |
695 | 720 | ||
696 | set_bit(DM_CRYPT_KEY_VALID, &cc->flags); | 721 | set_bit(DM_CRYPT_KEY_VALID, &cc->flags); |
@@ -746,7 +771,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
746 | 771 | ||
747 | if (crypt_set_key(cc, argv[1])) { | 772 | if (crypt_set_key(cc, argv[1])) { |
748 | ti->error = "Error decoding key"; | 773 | ti->error = "Error decoding key"; |
749 | goto bad1; | 774 | goto bad_cipher; |
750 | } | 775 | } |
751 | 776 | ||
752 | /* Compatiblity mode for old dm-crypt cipher strings */ | 777 | /* Compatiblity mode for old dm-crypt cipher strings */ |
@@ -757,19 +782,19 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
757 | 782 | ||
758 | if (strcmp(chainmode, "ecb") && !ivmode) { | 783 | if (strcmp(chainmode, "ecb") && !ivmode) { |
759 | ti->error = "This chaining mode requires an IV mechanism"; | 784 | ti->error = "This chaining mode requires an IV mechanism"; |
760 | goto bad1; | 785 | goto bad_cipher; |
761 | } | 786 | } |
762 | 787 | ||
763 | if (snprintf(cc->cipher, CRYPTO_MAX_ALG_NAME, "%s(%s)", chainmode, | 788 | if (snprintf(cc->cipher, CRYPTO_MAX_ALG_NAME, "%s(%s)", |
764 | cipher) >= CRYPTO_MAX_ALG_NAME) { | 789 | chainmode, cipher) >= CRYPTO_MAX_ALG_NAME) { |
765 | ti->error = "Chain mode + cipher name is too long"; | 790 | ti->error = "Chain mode + cipher name is too long"; |
766 | goto bad1; | 791 | goto bad_cipher; |
767 | } | 792 | } |
768 | 793 | ||
769 | tfm = crypto_alloc_blkcipher(cc->cipher, 0, CRYPTO_ALG_ASYNC); | 794 | tfm = crypto_alloc_blkcipher(cc->cipher, 0, CRYPTO_ALG_ASYNC); |
770 | if (IS_ERR(tfm)) { | 795 | if (IS_ERR(tfm)) { |
771 | ti->error = "Error allocating crypto tfm"; | 796 | ti->error = "Error allocating crypto tfm"; |
772 | goto bad1; | 797 | goto bad_cipher; |
773 | } | 798 | } |
774 | 799 | ||
775 | strcpy(cc->cipher, cipher); | 800 | strcpy(cc->cipher, cipher); |
@@ -793,18 +818,18 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
793 | cc->iv_gen_ops = &crypt_iv_null_ops; | 818 | cc->iv_gen_ops = &crypt_iv_null_ops; |
794 | else { | 819 | else { |
795 | ti->error = "Invalid IV mode"; | 820 | ti->error = "Invalid IV mode"; |
796 | goto bad2; | 821 | goto bad_ivmode; |
797 | } | 822 | } |
798 | 823 | ||
799 | if (cc->iv_gen_ops && cc->iv_gen_ops->ctr && | 824 | if (cc->iv_gen_ops && cc->iv_gen_ops->ctr && |
800 | cc->iv_gen_ops->ctr(cc, ti, ivopts) < 0) | 825 | cc->iv_gen_ops->ctr(cc, ti, ivopts) < 0) |
801 | goto bad2; | 826 | goto bad_ivmode; |
802 | 827 | ||
803 | cc->iv_size = crypto_blkcipher_ivsize(tfm); | 828 | cc->iv_size = crypto_blkcipher_ivsize(tfm); |
804 | if (cc->iv_size) | 829 | if (cc->iv_size) |
805 | /* at least a 64 bit sector number should fit in our buffer */ | 830 | /* at least a 64 bit sector number should fit in our buffer */ |
806 | cc->iv_size = max(cc->iv_size, | 831 | cc->iv_size = max(cc->iv_size, |
807 | (unsigned int)(sizeof(u64) / sizeof(u8))); | 832 | (unsigned int)(sizeof(u64) / sizeof(u8))); |
808 | else { | 833 | else { |
809 | if (cc->iv_gen_ops) { | 834 | if (cc->iv_gen_ops) { |
810 | DMWARN("Selected cipher does not support IVs"); | 835 | DMWARN("Selected cipher does not support IVs"); |
@@ -817,13 +842,13 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
817 | cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool); | 842 | cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool); |
818 | if (!cc->io_pool) { | 843 | if (!cc->io_pool) { |
819 | ti->error = "Cannot allocate crypt io mempool"; | 844 | ti->error = "Cannot allocate crypt io mempool"; |
820 | goto bad3; | 845 | goto bad_slab_pool; |
821 | } | 846 | } |
822 | 847 | ||
823 | cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0); | 848 | cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0); |
824 | if (!cc->page_pool) { | 849 | if (!cc->page_pool) { |
825 | ti->error = "Cannot allocate page mempool"; | 850 | ti->error = "Cannot allocate page mempool"; |
826 | goto bad4; | 851 | goto bad_page_pool; |
827 | } | 852 | } |
828 | 853 | ||
829 | cc->bs = bioset_create(MIN_IOS, MIN_IOS); | 854 | cc->bs = bioset_create(MIN_IOS, MIN_IOS); |
@@ -834,25 +859,25 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
834 | 859 | ||
835 | if (crypto_blkcipher_setkey(tfm, cc->key, key_size) < 0) { | 860 | if (crypto_blkcipher_setkey(tfm, cc->key, key_size) < 0) { |
836 | ti->error = "Error setting key"; | 861 | ti->error = "Error setting key"; |
837 | goto bad5; | 862 | goto bad_device; |
838 | } | 863 | } |
839 | 864 | ||
840 | if (sscanf(argv[2], "%llu", &tmpll) != 1) { | 865 | if (sscanf(argv[2], "%llu", &tmpll) != 1) { |
841 | ti->error = "Invalid iv_offset sector"; | 866 | ti->error = "Invalid iv_offset sector"; |
842 | goto bad5; | 867 | goto bad_device; |
843 | } | 868 | } |
844 | cc->iv_offset = tmpll; | 869 | cc->iv_offset = tmpll; |
845 | 870 | ||
846 | if (sscanf(argv[4], "%llu", &tmpll) != 1) { | 871 | if (sscanf(argv[4], "%llu", &tmpll) != 1) { |
847 | ti->error = "Invalid device sector"; | 872 | ti->error = "Invalid device sector"; |
848 | goto bad5; | 873 | goto bad_device; |
849 | } | 874 | } |
850 | cc->start = tmpll; | 875 | cc->start = tmpll; |
851 | 876 | ||
852 | if (dm_get_device(ti, argv[3], cc->start, ti->len, | 877 | if (dm_get_device(ti, argv[3], cc->start, ti->len, |
853 | dm_table_get_mode(ti->table), &cc->dev)) { | 878 | dm_table_get_mode(ti->table), &cc->dev)) { |
854 | ti->error = "Device lookup failed"; | 879 | ti->error = "Device lookup failed"; |
855 | goto bad5; | 880 | goto bad_device; |
856 | } | 881 | } |
857 | 882 | ||
858 | if (ivmode && cc->iv_gen_ops) { | 883 | if (ivmode && cc->iv_gen_ops) { |
@@ -861,27 +886,45 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
861 | cc->iv_mode = kmalloc(strlen(ivmode) + 1, GFP_KERNEL); | 886 | cc->iv_mode = kmalloc(strlen(ivmode) + 1, GFP_KERNEL); |
862 | if (!cc->iv_mode) { | 887 | if (!cc->iv_mode) { |
863 | ti->error = "Error kmallocing iv_mode string"; | 888 | ti->error = "Error kmallocing iv_mode string"; |
864 | goto bad5; | 889 | goto bad_ivmode_string; |
865 | } | 890 | } |
866 | strcpy(cc->iv_mode, ivmode); | 891 | strcpy(cc->iv_mode, ivmode); |
867 | } else | 892 | } else |
868 | cc->iv_mode = NULL; | 893 | cc->iv_mode = NULL; |
869 | 894 | ||
895 | cc->io_queue = create_singlethread_workqueue("kcryptd_io"); | ||
896 | if (!cc->io_queue) { | ||
897 | ti->error = "Couldn't create kcryptd io queue"; | ||
898 | goto bad_io_queue; | ||
899 | } | ||
900 | |||
901 | cc->crypt_queue = create_singlethread_workqueue("kcryptd"); | ||
902 | if (!cc->crypt_queue) { | ||
903 | ti->error = "Couldn't create kcryptd queue"; | ||
904 | goto bad_crypt_queue; | ||
905 | } | ||
906 | |||
870 | ti->private = cc; | 907 | ti->private = cc; |
871 | return 0; | 908 | return 0; |
872 | 909 | ||
873 | bad5: | 910 | bad_crypt_queue: |
911 | destroy_workqueue(cc->io_queue); | ||
912 | bad_io_queue: | ||
913 | kfree(cc->iv_mode); | ||
914 | bad_ivmode_string: | ||
915 | dm_put_device(ti, cc->dev); | ||
916 | bad_device: | ||
874 | bioset_free(cc->bs); | 917 | bioset_free(cc->bs); |
875 | bad_bs: | 918 | bad_bs: |
876 | mempool_destroy(cc->page_pool); | 919 | mempool_destroy(cc->page_pool); |
877 | bad4: | 920 | bad_page_pool: |
878 | mempool_destroy(cc->io_pool); | 921 | mempool_destroy(cc->io_pool); |
879 | bad3: | 922 | bad_slab_pool: |
880 | if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) | 923 | if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) |
881 | cc->iv_gen_ops->dtr(cc); | 924 | cc->iv_gen_ops->dtr(cc); |
882 | bad2: | 925 | bad_ivmode: |
883 | crypto_free_blkcipher(tfm); | 926 | crypto_free_blkcipher(tfm); |
884 | bad1: | 927 | bad_cipher: |
885 | /* Must zero key material before freeing */ | 928 | /* Must zero key material before freeing */ |
886 | memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8)); | 929 | memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8)); |
887 | kfree(cc); | 930 | kfree(cc); |
@@ -892,7 +935,8 @@ static void crypt_dtr(struct dm_target *ti) | |||
892 | { | 935 | { |
893 | struct crypt_config *cc = (struct crypt_config *) ti->private; | 936 | struct crypt_config *cc = (struct crypt_config *) ti->private; |
894 | 937 | ||
895 | flush_workqueue(_kcryptd_workqueue); | 938 | destroy_workqueue(cc->io_queue); |
939 | destroy_workqueue(cc->crypt_queue); | ||
896 | 940 | ||
897 | bioset_free(cc->bs); | 941 | bioset_free(cc->bs); |
898 | mempool_destroy(cc->page_pool); | 942 | mempool_destroy(cc->page_pool); |
@@ -918,9 +962,13 @@ static int crypt_map(struct dm_target *ti, struct bio *bio, | |||
918 | io = mempool_alloc(cc->io_pool, GFP_NOIO); | 962 | io = mempool_alloc(cc->io_pool, GFP_NOIO); |
919 | io->target = ti; | 963 | io->target = ti; |
920 | io->base_bio = bio; | 964 | io->base_bio = bio; |
921 | io->error = io->post_process = 0; | 965 | io->error = 0; |
922 | atomic_set(&io->pending, 0); | 966 | atomic_set(&io->pending, 0); |
923 | kcryptd_queue_io(io); | 967 | |
968 | if (bio_data_dir(io->base_bio) == READ) | ||
969 | kcryptd_queue_io(io); | ||
970 | else | ||
971 | kcryptd_queue_crypt(io); | ||
924 | 972 | ||
925 | return DM_MAPIO_SUBMITTED; | 973 | return DM_MAPIO_SUBMITTED; |
926 | } | 974 | } |
@@ -1037,25 +1085,12 @@ static int __init dm_crypt_init(void) | |||
1037 | if (!_crypt_io_pool) | 1085 | if (!_crypt_io_pool) |
1038 | return -ENOMEM; | 1086 | return -ENOMEM; |
1039 | 1087 | ||
1040 | _kcryptd_workqueue = create_workqueue("kcryptd"); | ||
1041 | if (!_kcryptd_workqueue) { | ||
1042 | r = -ENOMEM; | ||
1043 | DMERR("couldn't create kcryptd"); | ||
1044 | goto bad1; | ||
1045 | } | ||
1046 | |||
1047 | r = dm_register_target(&crypt_target); | 1088 | r = dm_register_target(&crypt_target); |
1048 | if (r < 0) { | 1089 | if (r < 0) { |
1049 | DMERR("register failed %d", r); | 1090 | DMERR("register failed %d", r); |
1050 | goto bad2; | 1091 | kmem_cache_destroy(_crypt_io_pool); |
1051 | } | 1092 | } |
1052 | 1093 | ||
1053 | return 0; | ||
1054 | |||
1055 | bad2: | ||
1056 | destroy_workqueue(_kcryptd_workqueue); | ||
1057 | bad1: | ||
1058 | kmem_cache_destroy(_crypt_io_pool); | ||
1059 | return r; | 1094 | return r; |
1060 | } | 1095 | } |
1061 | 1096 | ||
@@ -1066,7 +1101,6 @@ static void __exit dm_crypt_exit(void) | |||
1066 | if (r < 0) | 1101 | if (r < 0) |
1067 | DMERR("unregister failed %d", r); | 1102 | DMERR("unregister failed %d", r); |
1068 | 1103 | ||
1069 | destroy_workqueue(_kcryptd_workqueue); | ||
1070 | kmem_cache_destroy(_crypt_io_pool); | 1104 | kmem_cache_destroy(_crypt_io_pool); |
1071 | } | 1105 | } |
1072 | 1106 | ||
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c index 6928c136d3c5..bdd37f881c42 100644 --- a/drivers/md/dm-delay.c +++ b/drivers/md/dm-delay.c | |||
@@ -83,7 +83,7 @@ static struct bio *flush_delayed_bios(struct delay_c *dc, int flush_all) | |||
83 | struct dm_delay_info *delayed, *next; | 83 | struct dm_delay_info *delayed, *next; |
84 | unsigned long next_expires = 0; | 84 | unsigned long next_expires = 0; |
85 | int start_timer = 0; | 85 | int start_timer = 0; |
86 | BIO_LIST(flush_bios); | 86 | struct bio_list flush_bios = { }; |
87 | 87 | ||
88 | mutex_lock(&delayed_bios_lock); | 88 | mutex_lock(&delayed_bios_lock); |
89 | list_for_each_entry_safe(delayed, next, &dc->delayed_bios, list) { | 89 | list_for_each_entry_safe(delayed, next, &dc->delayed_bios, list) { |
@@ -163,34 +163,32 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
163 | goto bad; | 163 | goto bad; |
164 | } | 164 | } |
165 | 165 | ||
166 | if (argc == 3) { | 166 | dc->dev_write = NULL; |
167 | dc->dev_write = NULL; | 167 | if (argc == 3) |
168 | goto out; | 168 | goto out; |
169 | } | ||
170 | 169 | ||
171 | if (sscanf(argv[4], "%llu", &tmpll) != 1) { | 170 | if (sscanf(argv[4], "%llu", &tmpll) != 1) { |
172 | ti->error = "Invalid write device sector"; | 171 | ti->error = "Invalid write device sector"; |
173 | goto bad; | 172 | goto bad_dev_read; |
174 | } | 173 | } |
175 | dc->start_write = tmpll; | 174 | dc->start_write = tmpll; |
176 | 175 | ||
177 | if (sscanf(argv[5], "%u", &dc->write_delay) != 1) { | 176 | if (sscanf(argv[5], "%u", &dc->write_delay) != 1) { |
178 | ti->error = "Invalid write delay"; | 177 | ti->error = "Invalid write delay"; |
179 | goto bad; | 178 | goto bad_dev_read; |
180 | } | 179 | } |
181 | 180 | ||
182 | if (dm_get_device(ti, argv[3], dc->start_write, ti->len, | 181 | if (dm_get_device(ti, argv[3], dc->start_write, ti->len, |
183 | dm_table_get_mode(ti->table), &dc->dev_write)) { | 182 | dm_table_get_mode(ti->table), &dc->dev_write)) { |
184 | ti->error = "Write device lookup failed"; | 183 | ti->error = "Write device lookup failed"; |
185 | dm_put_device(ti, dc->dev_read); | 184 | goto bad_dev_read; |
186 | goto bad; | ||
187 | } | 185 | } |
188 | 186 | ||
189 | out: | 187 | out: |
190 | dc->delayed_pool = mempool_create_slab_pool(128, delayed_cache); | 188 | dc->delayed_pool = mempool_create_slab_pool(128, delayed_cache); |
191 | if (!dc->delayed_pool) { | 189 | if (!dc->delayed_pool) { |
192 | DMERR("Couldn't create delayed bio pool."); | 190 | DMERR("Couldn't create delayed bio pool."); |
193 | goto bad; | 191 | goto bad_dev_write; |
194 | } | 192 | } |
195 | 193 | ||
196 | setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc); | 194 | setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc); |
@@ -203,6 +201,11 @@ out: | |||
203 | ti->private = dc; | 201 | ti->private = dc; |
204 | return 0; | 202 | return 0; |
205 | 203 | ||
204 | bad_dev_write: | ||
205 | if (dc->dev_write) | ||
206 | dm_put_device(ti, dc->dev_write); | ||
207 | bad_dev_read: | ||
208 | dm_put_device(ti, dc->dev_read); | ||
206 | bad: | 209 | bad: |
207 | kfree(dc); | 210 | kfree(dc); |
208 | return -EINVAL; | 211 | return -EINVAL; |
@@ -305,7 +308,7 @@ static int delay_status(struct dm_target *ti, status_type_t type, | |||
305 | (unsigned long long) dc->start_read, | 308 | (unsigned long long) dc->start_read, |
306 | dc->read_delay); | 309 | dc->read_delay); |
307 | if (dc->dev_write) | 310 | if (dc->dev_write) |
308 | DMEMIT("%s %llu %u", dc->dev_write->name, | 311 | DMEMIT(" %s %llu %u", dc->dev_write->name, |
309 | (unsigned long long) dc->start_write, | 312 | (unsigned long long) dc->start_write, |
310 | dc->write_delay); | 313 | dc->write_delay); |
311 | break; | 314 | break; |
diff --git a/drivers/md/dm-emc.c b/drivers/md/dm-emc.c index 342517261ece..6b91b9ab1d41 100644 --- a/drivers/md/dm-emc.c +++ b/drivers/md/dm-emc.c | |||
@@ -81,7 +81,7 @@ static struct bio *get_failover_bio(struct dm_path *path, unsigned data_size) | |||
81 | } | 81 | } |
82 | 82 | ||
83 | if (bio_add_page(bio, page, data_size, 0) != data_size) { | 83 | if (bio_add_page(bio, page, data_size, 0) != data_size) { |
84 | DMERR("get_failover_bio: alloc_page() failed."); | 84 | DMERR("get_failover_bio: bio_add_page() failed."); |
85 | __free_page(page); | 85 | __free_page(page); |
86 | bio_put(bio); | 86 | bio_put(bio); |
87 | return NULL; | 87 | return NULL; |
@@ -211,12 +211,10 @@ fail_path: | |||
211 | 211 | ||
212 | static struct emc_handler *alloc_emc_handler(void) | 212 | static struct emc_handler *alloc_emc_handler(void) |
213 | { | 213 | { |
214 | struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL); | 214 | struct emc_handler *h = kzalloc(sizeof(*h), GFP_KERNEL); |
215 | 215 | ||
216 | if (h) { | 216 | if (h) |
217 | memset(h, 0, sizeof(*h)); | ||
218 | spin_lock_init(&h->lock); | 217 | spin_lock_init(&h->lock); |
219 | } | ||
220 | 218 | ||
221 | return h; | 219 | return h; |
222 | } | 220 | } |
diff --git a/drivers/md/dm-hw-handler.c b/drivers/md/dm-hw-handler.c index baafaaba4d4b..2ee84d8aa0bf 100644 --- a/drivers/md/dm-hw-handler.c +++ b/drivers/md/dm-hw-handler.c | |||
@@ -91,12 +91,10 @@ void dm_put_hw_handler(struct hw_handler_type *hwht) | |||
91 | 91 | ||
92 | static struct hwh_internal *_alloc_hw_handler(struct hw_handler_type *hwht) | 92 | static struct hwh_internal *_alloc_hw_handler(struct hw_handler_type *hwht) |
93 | { | 93 | { |
94 | struct hwh_internal *hwhi = kmalloc(sizeof(*hwhi), GFP_KERNEL); | 94 | struct hwh_internal *hwhi = kzalloc(sizeof(*hwhi), GFP_KERNEL); |
95 | 95 | ||
96 | if (hwhi) { | 96 | if (hwhi) |
97 | memset(hwhi, 0, sizeof(*hwhi)); | ||
98 | hwhi->hwht = *hwht; | 97 | hwhi->hwht = *hwht; |
99 | } | ||
100 | 98 | ||
101 | return hwhi; | 99 | return hwhi; |
102 | } | 100 | } |
diff --git a/drivers/md/dm-hw-handler.h b/drivers/md/dm-hw-handler.h index e0832e6fcf36..46809dcb121a 100644 --- a/drivers/md/dm-hw-handler.h +++ b/drivers/md/dm-hw-handler.h | |||
@@ -58,5 +58,6 @@ unsigned dm_scsi_err_handler(struct hw_handler *hwh, struct bio *bio); | |||
58 | #define MP_FAIL_PATH 1 | 58 | #define MP_FAIL_PATH 1 |
59 | #define MP_BYPASS_PG 2 | 59 | #define MP_BYPASS_PG 2 |
60 | #define MP_ERROR_IO 4 /* Don't retry this I/O */ | 60 | #define MP_ERROR_IO 4 /* Don't retry this I/O */ |
61 | #define MP_RETRY 8 | ||
61 | 62 | ||
62 | #endif | 63 | #endif |
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index b441d82c338a..138200bf5e0b 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -700,7 +700,7 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size) | |||
700 | int r; | 700 | int r; |
701 | char *new_name = (char *) param + param->data_start; | 701 | char *new_name = (char *) param + param->data_start; |
702 | 702 | ||
703 | if (new_name < (char *) (param + 1) || | 703 | if (new_name < (char *) param->data || |
704 | invalid_str(new_name, (void *) param + param_size)) { | 704 | invalid_str(new_name, (void *) param + param_size)) { |
705 | DMWARN("Invalid new logical volume name supplied."); | 705 | DMWARN("Invalid new logical volume name supplied."); |
706 | return -EINVAL; | 706 | return -EINVAL; |
@@ -726,7 +726,7 @@ static int dev_set_geometry(struct dm_ioctl *param, size_t param_size) | |||
726 | if (!md) | 726 | if (!md) |
727 | return -ENXIO; | 727 | return -ENXIO; |
728 | 728 | ||
729 | if (geostr < (char *) (param + 1) || | 729 | if (geostr < (char *) param->data || |
730 | invalid_str(geostr, (void *) param + param_size)) { | 730 | invalid_str(geostr, (void *) param + param_size)) { |
731 | DMWARN("Invalid geometry supplied."); | 731 | DMWARN("Invalid geometry supplied."); |
732 | goto out; | 732 | goto out; |
@@ -1233,7 +1233,7 @@ static int target_message(struct dm_ioctl *param, size_t param_size) | |||
1233 | if (r) | 1233 | if (r) |
1234 | goto out; | 1234 | goto out; |
1235 | 1235 | ||
1236 | if (tmsg < (struct dm_target_msg *) (param + 1) || | 1236 | if (tmsg < (struct dm_target_msg *) param->data || |
1237 | invalid_str(tmsg->message, (void *) param + param_size)) { | 1237 | invalid_str(tmsg->message, (void *) param + param_size)) { |
1238 | DMWARN("Invalid target message parameters."); | 1238 | DMWARN("Invalid target message parameters."); |
1239 | r = -EINVAL; | 1239 | r = -EINVAL; |
@@ -1358,7 +1358,7 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) | |||
1358 | if (tmp.data_size < sizeof(tmp)) | 1358 | if (tmp.data_size < sizeof(tmp)) |
1359 | return -EINVAL; | 1359 | return -EINVAL; |
1360 | 1360 | ||
1361 | dmi = (struct dm_ioctl *) vmalloc(tmp.data_size); | 1361 | dmi = vmalloc(tmp.data_size); |
1362 | if (!dmi) | 1362 | if (!dmi) |
1363 | return -ENOMEM; | 1363 | return -ENOMEM; |
1364 | 1364 | ||
@@ -1515,3 +1515,35 @@ void dm_interface_exit(void) | |||
1515 | 1515 | ||
1516 | dm_hash_exit(); | 1516 | dm_hash_exit(); |
1517 | } | 1517 | } |
1518 | |||
1519 | /** | ||
1520 | * dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers | ||
1521 | * @md: Pointer to mapped_device | ||
1522 | * @name: Buffer (size DM_NAME_LEN) for name | ||
1523 | * @uuid: Buffer (size DM_UUID_LEN) for uuid or empty string if uuid not defined | ||
1524 | */ | ||
1525 | int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid) | ||
1526 | { | ||
1527 | int r = 0; | ||
1528 | struct hash_cell *hc; | ||
1529 | |||
1530 | if (!md) | ||
1531 | return -ENXIO; | ||
1532 | |||
1533 | dm_get(md); | ||
1534 | down_read(&_hash_lock); | ||
1535 | hc = dm_get_mdptr(md); | ||
1536 | if (!hc || hc->md != md) { | ||
1537 | r = -ENXIO; | ||
1538 | goto out; | ||
1539 | } | ||
1540 | |||
1541 | strcpy(name, hc->name); | ||
1542 | strcpy(uuid, hc->uuid ? : ""); | ||
1543 | |||
1544 | out: | ||
1545 | up_read(&_hash_lock); | ||
1546 | dm_put(md); | ||
1547 | |||
1548 | return r; | ||
1549 | } | ||
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index a66428d860fe..072ee4353eab 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c | |||
@@ -696,7 +696,7 @@ static struct dirty_log_type _disk_type = { | |||
696 | .module = THIS_MODULE, | 696 | .module = THIS_MODULE, |
697 | .ctr = disk_ctr, | 697 | .ctr = disk_ctr, |
698 | .dtr = disk_dtr, | 698 | .dtr = disk_dtr, |
699 | .suspend = disk_flush, | 699 | .postsuspend = disk_flush, |
700 | .resume = disk_resume, | 700 | .resume = disk_resume, |
701 | .get_region_size = core_get_region_size, | 701 | .get_region_size = core_get_region_size, |
702 | .is_clean = core_is_clean, | 702 | .is_clean = core_is_clean, |
diff --git a/drivers/md/dm-log.h b/drivers/md/dm-log.h index 86a301c8daf1..3fae87eb5963 100644 --- a/drivers/md/dm-log.h +++ b/drivers/md/dm-log.h | |||
@@ -32,7 +32,8 @@ struct dirty_log_type { | |||
32 | * There are times when we don't want the log to touch | 32 | * There are times when we don't want the log to touch |
33 | * the disk. | 33 | * the disk. |
34 | */ | 34 | */ |
35 | int (*suspend)(struct dirty_log *log); | 35 | int (*presuspend)(struct dirty_log *log); |
36 | int (*postsuspend)(struct dirty_log *log); | ||
36 | int (*resume)(struct dirty_log *log); | 37 | int (*resume)(struct dirty_log *log); |
37 | 38 | ||
38 | /* | 39 | /* |
diff --git a/drivers/md/dm-mpath-hp-sw.c b/drivers/md/dm-mpath-hp-sw.c new file mode 100644 index 000000000000..204bf42c9449 --- /dev/null +++ b/drivers/md/dm-mpath-hp-sw.c | |||
@@ -0,0 +1,248 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005 Mike Christie, All rights reserved. | ||
3 | * Copyright (C) 2007 Red Hat, Inc. All rights reserved. | ||
4 | * Authors: Mike Christie | ||
5 | * Dave Wysochanski | ||
6 | * | ||
7 | * This file is released under the GPL. | ||
8 | * | ||
9 | * This module implements the specific path activation code for | ||
10 | * HP StorageWorks and FSC FibreCat Asymmetric (Active/Passive) | ||
11 | * storage arrays. | ||
12 | * These storage arrays have controller-based failover, not | ||
13 | * LUN-based failover. However, LUN-based failover is the design | ||
14 | * of dm-multipath. Thus, this module is written for LUN-based failover. | ||
15 | */ | ||
16 | #include <linux/blkdev.h> | ||
17 | #include <linux/list.h> | ||
18 | #include <linux/types.h> | ||
19 | #include <scsi/scsi.h> | ||
20 | #include <scsi/scsi_cmnd.h> | ||
21 | #include <scsi/scsi_dbg.h> | ||
22 | |||
23 | #include "dm.h" | ||
24 | #include "dm-hw-handler.h" | ||
25 | |||
26 | #define DM_MSG_PREFIX "multipath hp-sw" | ||
27 | #define DM_HP_HWH_NAME "hp-sw" | ||
28 | #define DM_HP_HWH_VER "1.0.0" | ||
29 | |||
30 | struct hp_sw_context { | ||
31 | unsigned char sense[SCSI_SENSE_BUFFERSIZE]; | ||
32 | }; | ||
33 | |||
34 | /* | ||
35 | * hp_sw_error_is_retryable - Is an HP-specific check condition retryable? | ||
36 | * @req: path activation request | ||
37 | * | ||
38 | * Examine error codes of request and determine whether the error is retryable. | ||
39 | * Some error codes are already retried by scsi-ml (see | ||
40 | * scsi_decide_disposition), but some HP specific codes are not. | ||
41 | * The intent of this routine is to supply the logic for the HP specific | ||
42 | * check conditions. | ||
43 | * | ||
44 | * Returns: | ||
45 | * 1 - command completed with retryable error | ||
46 | * 0 - command completed with non-retryable error | ||
47 | * | ||
48 | * Possible optimizations | ||
49 | * 1. More hardware-specific error codes | ||
50 | */ | ||
51 | static int hp_sw_error_is_retryable(struct request *req) | ||
52 | { | ||
53 | /* | ||
54 | * NOT_READY is known to be retryable | ||
55 | * For now we just dump out the sense data and call it retryable | ||
56 | */ | ||
57 | if (status_byte(req->errors) == CHECK_CONDITION) | ||
58 | __scsi_print_sense(DM_HP_HWH_NAME, req->sense, req->sense_len); | ||
59 | |||
60 | /* | ||
61 | * At this point we don't have complete information about all the error | ||
62 | * codes from this hardware, so we are just conservative and retry | ||
63 | * when in doubt. | ||
64 | */ | ||
65 | return 1; | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * hp_sw_end_io - Completion handler for HP path activation. | ||
70 | * @req: path activation request | ||
71 | * @error: scsi-ml error | ||
72 | * | ||
73 | * Check sense data, free request structure, and notify dm that | ||
74 | * pg initialization has completed. | ||
75 | * | ||
76 | * Context: scsi-ml softirq | ||
77 | * | ||
78 | */ | ||
79 | static void hp_sw_end_io(struct request *req, int error) | ||
80 | { | ||
81 | struct dm_path *path = req->end_io_data; | ||
82 | unsigned err_flags = 0; | ||
83 | |||
84 | if (!error) { | ||
85 | DMDEBUG("%s path activation command - success", | ||
86 | path->dev->name); | ||
87 | goto out; | ||
88 | } | ||
89 | |||
90 | if (hp_sw_error_is_retryable(req)) { | ||
91 | DMDEBUG("%s path activation command - retry", | ||
92 | path->dev->name); | ||
93 | err_flags = MP_RETRY; | ||
94 | goto out; | ||
95 | } | ||
96 | |||
97 | DMWARN("%s path activation fail - error=0x%x", | ||
98 | path->dev->name, error); | ||
99 | err_flags = MP_FAIL_PATH; | ||
100 | |||
101 | out: | ||
102 | req->end_io_data = NULL; | ||
103 | __blk_put_request(req->q, req); | ||
104 | dm_pg_init_complete(path, err_flags); | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * hp_sw_get_request - Allocate an HP specific path activation request | ||
109 | * @path: path on which request will be sent (needed for request queue) | ||
110 | * | ||
111 | * The START command is used for path activation request. | ||
112 | * These arrays are controller-based failover, not LUN based. | ||
113 | * One START command issued to a single path will fail over all | ||
114 | * LUNs for the same controller. | ||
115 | * | ||
116 | * Possible optimizations | ||
117 | * 1. Make timeout configurable | ||
118 | * 2. Preallocate request | ||
119 | */ | ||
120 | static struct request *hp_sw_get_request(struct dm_path *path) | ||
121 | { | ||
122 | struct request *req; | ||
123 | struct block_device *bdev = path->dev->bdev; | ||
124 | struct request_queue *q = bdev_get_queue(bdev); | ||
125 | struct hp_sw_context *h = path->hwhcontext; | ||
126 | |||
127 | req = blk_get_request(q, WRITE, GFP_NOIO); | ||
128 | if (!req) | ||
129 | goto out; | ||
130 | |||
131 | req->timeout = 60 * HZ; | ||
132 | |||
133 | req->errors = 0; | ||
134 | req->cmd_type = REQ_TYPE_BLOCK_PC; | ||
135 | req->cmd_flags |= REQ_FAILFAST | REQ_NOMERGE; | ||
136 | req->end_io_data = path; | ||
137 | req->sense = h->sense; | ||
138 | memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE); | ||
139 | |||
140 | memset(&req->cmd, 0, BLK_MAX_CDB); | ||
141 | req->cmd[0] = START_STOP; | ||
142 | req->cmd[4] = 1; | ||
143 | req->cmd_len = COMMAND_SIZE(req->cmd[0]); | ||
144 | |||
145 | out: | ||
146 | return req; | ||
147 | } | ||
148 | |||
149 | /* | ||
150 | * hp_sw_pg_init - HP path activation implementation. | ||
151 | * @hwh: hardware handler specific data | ||
152 | * @bypassed: unused; is the path group bypassed? (see dm-mpath.c) | ||
153 | * @path: path to send initialization command | ||
154 | * | ||
155 | * Send an HP-specific path activation command on 'path'. | ||
156 | * Do not try to optimize in any way, just send the activation command. | ||
157 | * More than one path activation command may be sent to the same controller. | ||
158 | * This seems to work fine for basic failover support. | ||
159 | * | ||
160 | * Possible optimizations | ||
161 | * 1. Detect an in-progress activation request and avoid submitting another one | ||
162 | * 2. Model the controller and only send a single activation request at a time | ||
163 | * 3. Determine the state of a path before sending an activation request | ||
164 | * | ||
165 | * Context: kmpathd (see process_queued_ios() in dm-mpath.c) | ||
166 | */ | ||
167 | static void hp_sw_pg_init(struct hw_handler *hwh, unsigned bypassed, | ||
168 | struct dm_path *path) | ||
169 | { | ||
170 | struct request *req; | ||
171 | struct hp_sw_context *h; | ||
172 | |||
173 | path->hwhcontext = hwh->context; | ||
174 | h = hwh->context; | ||
175 | |||
176 | req = hp_sw_get_request(path); | ||
177 | if (!req) { | ||
178 | DMERR("%s path activation command - allocation fail", | ||
179 | path->dev->name); | ||
180 | goto retry; | ||
181 | } | ||
182 | |||
183 | DMDEBUG("%s path activation command - sent", path->dev->name); | ||
184 | |||
185 | blk_execute_rq_nowait(req->q, NULL, req, 1, hp_sw_end_io); | ||
186 | return; | ||
187 | |||
188 | retry: | ||
189 | dm_pg_init_complete(path, MP_RETRY); | ||
190 | } | ||
191 | |||
192 | static int hp_sw_create(struct hw_handler *hwh, unsigned argc, char **argv) | ||
193 | { | ||
194 | struct hp_sw_context *h; | ||
195 | |||
196 | h = kmalloc(sizeof(*h), GFP_KERNEL); | ||
197 | if (!h) | ||
198 | return -ENOMEM; | ||
199 | |||
200 | hwh->context = h; | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static void hp_sw_destroy(struct hw_handler *hwh) | ||
206 | { | ||
207 | struct hp_sw_context *h = hwh->context; | ||
208 | |||
209 | kfree(h); | ||
210 | } | ||
211 | |||
212 | static struct hw_handler_type hp_sw_hwh = { | ||
213 | .name = DM_HP_HWH_NAME, | ||
214 | .module = THIS_MODULE, | ||
215 | .create = hp_sw_create, | ||
216 | .destroy = hp_sw_destroy, | ||
217 | .pg_init = hp_sw_pg_init, | ||
218 | }; | ||
219 | |||
220 | static int __init hp_sw_init(void) | ||
221 | { | ||
222 | int r; | ||
223 | |||
224 | r = dm_register_hw_handler(&hp_sw_hwh); | ||
225 | if (r < 0) | ||
226 | DMERR("register failed %d", r); | ||
227 | else | ||
228 | DMINFO("version " DM_HP_HWH_VER " loaded"); | ||
229 | |||
230 | return r; | ||
231 | } | ||
232 | |||
233 | static void __exit hp_sw_exit(void) | ||
234 | { | ||
235 | int r; | ||
236 | |||
237 | r = dm_unregister_hw_handler(&hp_sw_hwh); | ||
238 | if (r < 0) | ||
239 | DMERR("unregister failed %d", r); | ||
240 | } | ||
241 | |||
242 | module_init(hp_sw_init); | ||
243 | module_exit(hp_sw_exit); | ||
244 | |||
245 | MODULE_DESCRIPTION("DM Multipath HP StorageWorks / FSC FibreCat (A/P) support"); | ||
246 | MODULE_AUTHOR("Mike Christie, Dave Wysochanski <dm-devel@redhat.com>"); | ||
247 | MODULE_LICENSE("GPL"); | ||
248 | MODULE_VERSION(DM_HP_HWH_VER); | ||
diff --git a/drivers/md/dm-mpath-rdac.c b/drivers/md/dm-mpath-rdac.c index 16b161345775..e04eb5c697fb 100644 --- a/drivers/md/dm-mpath-rdac.c +++ b/drivers/md/dm-mpath-rdac.c | |||
@@ -664,20 +664,21 @@ static struct hw_handler_type rdac_handler = { | |||
664 | 664 | ||
665 | static int __init rdac_init(void) | 665 | static int __init rdac_init(void) |
666 | { | 666 | { |
667 | int r = dm_register_hw_handler(&rdac_handler); | 667 | int r; |
668 | |||
669 | if (r < 0) { | ||
670 | DMERR("%s: register failed %d", RDAC_DM_HWH_NAME, r); | ||
671 | return r; | ||
672 | } | ||
673 | 668 | ||
674 | rdac_wkqd = create_singlethread_workqueue("rdac_wkqd"); | 669 | rdac_wkqd = create_singlethread_workqueue("rdac_wkqd"); |
675 | if (!rdac_wkqd) { | 670 | if (!rdac_wkqd) { |
676 | DMERR("Failed to create workqueue rdac_wkqd."); | 671 | DMERR("Failed to create workqueue rdac_wkqd."); |
677 | dm_unregister_hw_handler(&rdac_handler); | ||
678 | return -ENOMEM; | 672 | return -ENOMEM; |
679 | } | 673 | } |
680 | 674 | ||
675 | r = dm_register_hw_handler(&rdac_handler); | ||
676 | if (r < 0) { | ||
677 | DMERR("%s: register failed %d", RDAC_DM_HWH_NAME, r); | ||
678 | destroy_workqueue(rdac_wkqd); | ||
679 | return r; | ||
680 | } | ||
681 | |||
681 | DMINFO("%s: version %s loaded", RDAC_DM_HWH_NAME, RDAC_DM_HWH_VER); | 682 | DMINFO("%s: version %s loaded", RDAC_DM_HWH_NAME, RDAC_DM_HWH_VER); |
682 | return 0; | 683 | return 0; |
683 | } | 684 | } |
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 31056abca89d..24b2b1e32fae 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "dm-hw-handler.h" | 10 | #include "dm-hw-handler.h" |
11 | #include "dm-bio-list.h" | 11 | #include "dm-bio-list.h" |
12 | #include "dm-bio-record.h" | 12 | #include "dm-bio-record.h" |
13 | #include "dm-uevent.h" | ||
13 | 14 | ||
14 | #include <linux/ctype.h> | 15 | #include <linux/ctype.h> |
15 | #include <linux/init.h> | 16 | #include <linux/init.h> |
@@ -75,6 +76,8 @@ struct multipath { | |||
75 | unsigned queue_io; /* Must we queue all I/O? */ | 76 | unsigned queue_io; /* Must we queue all I/O? */ |
76 | unsigned queue_if_no_path; /* Queue I/O if last path fails? */ | 77 | unsigned queue_if_no_path; /* Queue I/O if last path fails? */ |
77 | unsigned saved_queue_if_no_path;/* Saved state during suspension */ | 78 | unsigned saved_queue_if_no_path;/* Saved state during suspension */ |
79 | unsigned pg_init_retries; /* Number of times to retry pg_init */ | ||
80 | unsigned pg_init_count; /* Number of times pg_init called */ | ||
78 | 81 | ||
79 | struct work_struct process_queued_ios; | 82 | struct work_struct process_queued_ios; |
80 | struct bio_list queued_ios; | 83 | struct bio_list queued_ios; |
@@ -225,6 +228,8 @@ static void __switch_pg(struct multipath *m, struct pgpath *pgpath) | |||
225 | m->pg_init_required = 0; | 228 | m->pg_init_required = 0; |
226 | m->queue_io = 0; | 229 | m->queue_io = 0; |
227 | } | 230 | } |
231 | |||
232 | m->pg_init_count = 0; | ||
228 | } | 233 | } |
229 | 234 | ||
230 | static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg) | 235 | static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg) |
@@ -424,6 +429,7 @@ static void process_queued_ios(struct work_struct *work) | |||
424 | must_queue = 0; | 429 | must_queue = 0; |
425 | 430 | ||
426 | if (m->pg_init_required && !m->pg_init_in_progress) { | 431 | if (m->pg_init_required && !m->pg_init_in_progress) { |
432 | m->pg_init_count++; | ||
427 | m->pg_init_required = 0; | 433 | m->pg_init_required = 0; |
428 | m->pg_init_in_progress = 1; | 434 | m->pg_init_in_progress = 1; |
429 | init_required = 1; | 435 | init_required = 1; |
@@ -689,9 +695,11 @@ static int parse_features(struct arg_set *as, struct multipath *m) | |||
689 | int r; | 695 | int r; |
690 | unsigned argc; | 696 | unsigned argc; |
691 | struct dm_target *ti = m->ti; | 697 | struct dm_target *ti = m->ti; |
698 | const char *param_name; | ||
692 | 699 | ||
693 | static struct param _params[] = { | 700 | static struct param _params[] = { |
694 | {0, 1, "invalid number of feature args"}, | 701 | {0, 3, "invalid number of feature args"}, |
702 | {1, 50, "pg_init_retries must be between 1 and 50"}, | ||
695 | }; | 703 | }; |
696 | 704 | ||
697 | r = read_param(_params, shift(as), &argc, &ti->error); | 705 | r = read_param(_params, shift(as), &argc, &ti->error); |
@@ -701,12 +709,28 @@ static int parse_features(struct arg_set *as, struct multipath *m) | |||
701 | if (!argc) | 709 | if (!argc) |
702 | return 0; | 710 | return 0; |
703 | 711 | ||
704 | if (!strnicmp(shift(as), MESG_STR("queue_if_no_path"))) | 712 | do { |
705 | return queue_if_no_path(m, 1, 0); | 713 | param_name = shift(as); |
706 | else { | 714 | argc--; |
715 | |||
716 | if (!strnicmp(param_name, MESG_STR("queue_if_no_path"))) { | ||
717 | r = queue_if_no_path(m, 1, 0); | ||
718 | continue; | ||
719 | } | ||
720 | |||
721 | if (!strnicmp(param_name, MESG_STR("pg_init_retries")) && | ||
722 | (argc >= 1)) { | ||
723 | r = read_param(_params + 1, shift(as), | ||
724 | &m->pg_init_retries, &ti->error); | ||
725 | argc--; | ||
726 | continue; | ||
727 | } | ||
728 | |||
707 | ti->error = "Unrecognised multipath feature request"; | 729 | ti->error = "Unrecognised multipath feature request"; |
708 | return -EINVAL; | 730 | r = -EINVAL; |
709 | } | 731 | } while (argc && !r); |
732 | |||
733 | return r; | ||
710 | } | 734 | } |
711 | 735 | ||
712 | static int multipath_ctr(struct dm_target *ti, unsigned int argc, | 736 | static int multipath_ctr(struct dm_target *ti, unsigned int argc, |
@@ -834,6 +858,9 @@ static int fail_path(struct pgpath *pgpath) | |||
834 | if (pgpath == m->current_pgpath) | 858 | if (pgpath == m->current_pgpath) |
835 | m->current_pgpath = NULL; | 859 | m->current_pgpath = NULL; |
836 | 860 | ||
861 | dm_path_uevent(DM_UEVENT_PATH_FAILED, m->ti, | ||
862 | pgpath->path.dev->name, m->nr_valid_paths); | ||
863 | |||
837 | queue_work(kmultipathd, &m->trigger_event); | 864 | queue_work(kmultipathd, &m->trigger_event); |
838 | 865 | ||
839 | out: | 866 | out: |
@@ -873,6 +900,9 @@ static int reinstate_path(struct pgpath *pgpath) | |||
873 | if (!m->nr_valid_paths++ && m->queue_size) | 900 | if (!m->nr_valid_paths++ && m->queue_size) |
874 | queue_work(kmultipathd, &m->process_queued_ios); | 901 | queue_work(kmultipathd, &m->process_queued_ios); |
875 | 902 | ||
903 | dm_path_uevent(DM_UEVENT_PATH_REINSTATED, m->ti, | ||
904 | pgpath->path.dev->name, m->nr_valid_paths); | ||
905 | |||
876 | queue_work(kmultipathd, &m->trigger_event); | 906 | queue_work(kmultipathd, &m->trigger_event); |
877 | 907 | ||
878 | out: | 908 | out: |
@@ -976,6 +1006,26 @@ static int bypass_pg_num(struct multipath *m, const char *pgstr, int bypassed) | |||
976 | } | 1006 | } |
977 | 1007 | ||
978 | /* | 1008 | /* |
1009 | * Should we retry pg_init immediately? | ||
1010 | */ | ||
1011 | static int pg_init_limit_reached(struct multipath *m, struct pgpath *pgpath) | ||
1012 | { | ||
1013 | unsigned long flags; | ||
1014 | int limit_reached = 0; | ||
1015 | |||
1016 | spin_lock_irqsave(&m->lock, flags); | ||
1017 | |||
1018 | if (m->pg_init_count <= m->pg_init_retries) | ||
1019 | m->pg_init_required = 1; | ||
1020 | else | ||
1021 | limit_reached = 1; | ||
1022 | |||
1023 | spin_unlock_irqrestore(&m->lock, flags); | ||
1024 | |||
1025 | return limit_reached; | ||
1026 | } | ||
1027 | |||
1028 | /* | ||
979 | * pg_init must call this when it has completed its initialisation | 1029 | * pg_init must call this when it has completed its initialisation |
980 | */ | 1030 | */ |
981 | void dm_pg_init_complete(struct dm_path *path, unsigned err_flags) | 1031 | void dm_pg_init_complete(struct dm_path *path, unsigned err_flags) |
@@ -985,8 +1035,14 @@ void dm_pg_init_complete(struct dm_path *path, unsigned err_flags) | |||
985 | struct multipath *m = pg->m; | 1035 | struct multipath *m = pg->m; |
986 | unsigned long flags; | 1036 | unsigned long flags; |
987 | 1037 | ||
988 | /* We insist on failing the path if the PG is already bypassed. */ | 1038 | /* |
989 | if (err_flags && pg->bypassed) | 1039 | * If requested, retry pg_init until maximum number of retries exceeded. |
1040 | * If retry not requested and PG already bypassed, always fail the path. | ||
1041 | */ | ||
1042 | if (err_flags & MP_RETRY) { | ||
1043 | if (pg_init_limit_reached(m, pgpath)) | ||
1044 | err_flags |= MP_FAIL_PATH; | ||
1045 | } else if (err_flags && pg->bypassed) | ||
990 | err_flags |= MP_FAIL_PATH; | 1046 | err_flags |= MP_FAIL_PATH; |
991 | 1047 | ||
992 | if (err_flags & MP_FAIL_PATH) | 1048 | if (err_flags & MP_FAIL_PATH) |
@@ -996,7 +1052,7 @@ void dm_pg_init_complete(struct dm_path *path, unsigned err_flags) | |||
996 | bypass_pg(m, pg, 1); | 1052 | bypass_pg(m, pg, 1); |
997 | 1053 | ||
998 | spin_lock_irqsave(&m->lock, flags); | 1054 | spin_lock_irqsave(&m->lock, flags); |
999 | if (err_flags) { | 1055 | if (err_flags & ~MP_RETRY) { |
1000 | m->current_pgpath = NULL; | 1056 | m->current_pgpath = NULL; |
1001 | m->current_pg = NULL; | 1057 | m->current_pg = NULL; |
1002 | } else if (!m->pg_init_required) | 1058 | } else if (!m->pg_init_required) |
@@ -1148,11 +1204,15 @@ static int multipath_status(struct dm_target *ti, status_type_t type, | |||
1148 | 1204 | ||
1149 | /* Features */ | 1205 | /* Features */ |
1150 | if (type == STATUSTYPE_INFO) | 1206 | if (type == STATUSTYPE_INFO) |
1151 | DMEMIT("1 %u ", m->queue_size); | 1207 | DMEMIT("2 %u %u ", m->queue_size, m->pg_init_count); |
1152 | else if (m->queue_if_no_path) | 1208 | else { |
1153 | DMEMIT("1 queue_if_no_path "); | 1209 | DMEMIT("%u ", m->queue_if_no_path + |
1154 | else | 1210 | (m->pg_init_retries > 0) * 2); |
1155 | DMEMIT("0 "); | 1211 | if (m->queue_if_no_path) |
1212 | DMEMIT("queue_if_no_path "); | ||
1213 | if (m->pg_init_retries) | ||
1214 | DMEMIT("pg_init_retries %u ", m->pg_init_retries); | ||
1215 | } | ||
1156 | 1216 | ||
1157 | if (hwh->type && hwh->type->status) | 1217 | if (hwh->type && hwh->type->status) |
1158 | sz += hwh->type->status(hwh, type, result + sz, maxlen - sz); | 1218 | sz += hwh->type->status(hwh, type, result + sz, maxlen - sz); |
diff --git a/drivers/md/dm-path-selector.c b/drivers/md/dm-path-selector.c index f10a0c89b3f4..ca1bb636a3e4 100644 --- a/drivers/md/dm-path-selector.c +++ b/drivers/md/dm-path-selector.c | |||
@@ -94,12 +94,10 @@ out: | |||
94 | 94 | ||
95 | static struct ps_internal *_alloc_path_selector(struct path_selector_type *pst) | 95 | static struct ps_internal *_alloc_path_selector(struct path_selector_type *pst) |
96 | { | 96 | { |
97 | struct ps_internal *psi = kmalloc(sizeof(*psi), GFP_KERNEL); | 97 | struct ps_internal *psi = kzalloc(sizeof(*psi), GFP_KERNEL); |
98 | 98 | ||
99 | if (psi) { | 99 | if (psi) |
100 | memset(psi, 0, sizeof(*psi)); | ||
101 | psi->pst = *pst; | 100 | psi->pst = *pst; |
102 | } | ||
103 | 101 | ||
104 | return psi; | 102 | return psi; |
105 | } | 103 | } |
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index d09ff15490a5..31123d4a6b9c 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/time.h> | 19 | #include <linux/time.h> |
20 | #include <linux/vmalloc.h> | 20 | #include <linux/vmalloc.h> |
21 | #include <linux/workqueue.h> | 21 | #include <linux/workqueue.h> |
22 | #include <linux/log2.h> | ||
22 | 23 | ||
23 | #define DM_MSG_PREFIX "raid1" | 24 | #define DM_MSG_PREFIX "raid1" |
24 | #define DM_IO_PAGES 64 | 25 | #define DM_IO_PAGES 64 |
@@ -113,6 +114,7 @@ struct region { | |||
113 | * Mirror set structures. | 114 | * Mirror set structures. |
114 | *---------------------------------------------------------------*/ | 115 | *---------------------------------------------------------------*/ |
115 | struct mirror { | 116 | struct mirror { |
117 | struct mirror_set *ms; | ||
116 | atomic_t error_count; | 118 | atomic_t error_count; |
117 | struct dm_dev *dev; | 119 | struct dm_dev *dev; |
118 | sector_t offset; | 120 | sector_t offset; |
@@ -974,6 +976,7 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, | |||
974 | 976 | ||
975 | if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) { | 977 | if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) { |
976 | ti->error = "Error creating dirty region hash"; | 978 | ti->error = "Error creating dirty region hash"; |
979 | dm_io_client_destroy(ms->io_client); | ||
977 | kfree(ms); | 980 | kfree(ms); |
978 | return NULL; | 981 | return NULL; |
979 | } | 982 | } |
@@ -994,7 +997,7 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti, | |||
994 | 997 | ||
995 | static inline int _check_region_size(struct dm_target *ti, uint32_t size) | 998 | static inline int _check_region_size(struct dm_target *ti, uint32_t size) |
996 | { | 999 | { |
997 | return !(size % (PAGE_SIZE >> 9) || (size & (size - 1)) || | 1000 | return !(size % (PAGE_SIZE >> 9) || !is_power_of_2(size) || |
998 | size > ti->len); | 1001 | size > ti->len); |
999 | } | 1002 | } |
1000 | 1003 | ||
@@ -1015,6 +1018,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti, | |||
1015 | return -ENXIO; | 1018 | return -ENXIO; |
1016 | } | 1019 | } |
1017 | 1020 | ||
1021 | ms->mirror[mirror].ms = ms; | ||
1018 | ms->mirror[mirror].offset = offset; | 1022 | ms->mirror[mirror].offset = offset; |
1019 | 1023 | ||
1020 | return 0; | 1024 | return 0; |
@@ -1163,16 +1167,14 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
1163 | ms->kmirrord_wq = create_singlethread_workqueue("kmirrord"); | 1167 | ms->kmirrord_wq = create_singlethread_workqueue("kmirrord"); |
1164 | if (!ms->kmirrord_wq) { | 1168 | if (!ms->kmirrord_wq) { |
1165 | DMERR("couldn't start kmirrord"); | 1169 | DMERR("couldn't start kmirrord"); |
1166 | free_context(ms, ti, m); | 1170 | r = -ENOMEM; |
1167 | return -ENOMEM; | 1171 | goto err_free_context; |
1168 | } | 1172 | } |
1169 | INIT_WORK(&ms->kmirrord_work, do_mirror); | 1173 | INIT_WORK(&ms->kmirrord_work, do_mirror); |
1170 | 1174 | ||
1171 | r = parse_features(ms, argc, argv, &args_used); | 1175 | r = parse_features(ms, argc, argv, &args_used); |
1172 | if (r) { | 1176 | if (r) |
1173 | free_context(ms, ti, ms->nr_mirrors); | 1177 | goto err_destroy_wq; |
1174 | return r; | ||
1175 | } | ||
1176 | 1178 | ||
1177 | argv += args_used; | 1179 | argv += args_used; |
1178 | argc -= args_used; | 1180 | argc -= args_used; |
@@ -1188,19 +1190,22 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
1188 | 1190 | ||
1189 | if (argc) { | 1191 | if (argc) { |
1190 | ti->error = "Too many mirror arguments"; | 1192 | ti->error = "Too many mirror arguments"; |
1191 | free_context(ms, ti, ms->nr_mirrors); | 1193 | r = -EINVAL; |
1192 | return -EINVAL; | 1194 | goto err_destroy_wq; |
1193 | } | 1195 | } |
1194 | 1196 | ||
1195 | r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client); | 1197 | r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client); |
1196 | if (r) { | 1198 | if (r) |
1197 | destroy_workqueue(ms->kmirrord_wq); | 1199 | goto err_destroy_wq; |
1198 | free_context(ms, ti, ms->nr_mirrors); | ||
1199 | return r; | ||
1200 | } | ||
1201 | 1200 | ||
1202 | wake(ms); | 1201 | wake(ms); |
1203 | return 0; | 1202 | return 0; |
1203 | |||
1204 | err_destroy_wq: | ||
1205 | destroy_workqueue(ms->kmirrord_wq); | ||
1206 | err_free_context: | ||
1207 | free_context(ms, ti, ms->nr_mirrors); | ||
1208 | return r; | ||
1204 | } | 1209 | } |
1205 | 1210 | ||
1206 | static void mirror_dtr(struct dm_target *ti) | 1211 | static void mirror_dtr(struct dm_target *ti) |
@@ -1302,7 +1307,7 @@ static void mirror_postsuspend(struct dm_target *ti) | |||
1302 | wait_event(_kmirrord_recovery_stopped, | 1307 | wait_event(_kmirrord_recovery_stopped, |
1303 | !atomic_read(&ms->rh.recovery_in_flight)); | 1308 | !atomic_read(&ms->rh.recovery_in_flight)); |
1304 | 1309 | ||
1305 | if (log->type->suspend && log->type->suspend(log)) | 1310 | if (log->type->postsuspend && log->type->postsuspend(log)) |
1306 | /* FIXME: need better error handling */ | 1311 | /* FIXME: need better error handling */ |
1307 | DMWARN("log suspend failed"); | 1312 | DMWARN("log suspend failed"); |
1308 | } | 1313 | } |
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 98a633f3d6b0..cee16fadd9ee 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/vmalloc.h> | 19 | #include <linux/vmalloc.h> |
20 | #include <linux/log2.h> | ||
20 | 21 | ||
21 | #include "dm-snap.h" | 22 | #include "dm-snap.h" |
22 | #include "dm-bio-list.h" | 23 | #include "dm-bio-list.h" |
@@ -415,7 +416,7 @@ static int set_chunk_size(struct dm_snapshot *s, const char *chunk_size_arg, | |||
415 | chunk_size = round_up(chunk_size, PAGE_SIZE >> 9); | 416 | chunk_size = round_up(chunk_size, PAGE_SIZE >> 9); |
416 | 417 | ||
417 | /* Check chunk_size is a power of 2 */ | 418 | /* Check chunk_size is a power of 2 */ |
418 | if (chunk_size & (chunk_size - 1)) { | 419 | if (!is_power_of_2(chunk_size)) { |
419 | *error = "Chunk size is not a power of 2"; | 420 | *error = "Chunk size is not a power of 2"; |
420 | return -EINVAL; | 421 | return -EINVAL; |
421 | } | 422 | } |
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index 51f5e0760012..969944a8aba2 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/blkdev.h> | 11 | #include <linux/blkdev.h> |
12 | #include <linux/bio.h> | 12 | #include <linux/bio.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/log2.h> | ||
14 | 15 | ||
15 | #define DM_MSG_PREFIX "striped" | 16 | #define DM_MSG_PREFIX "striped" |
16 | 17 | ||
@@ -99,7 +100,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
99 | /* | 100 | /* |
100 | * chunk_size is a power of two | 101 | * chunk_size is a power of two |
101 | */ | 102 | */ |
102 | if (!chunk_size || (chunk_size & (chunk_size - 1)) || | 103 | if (!is_power_of_2(chunk_size) || |
103 | (chunk_size < (PAGE_SIZE >> SECTOR_SHIFT))) { | 104 | (chunk_size < (PAGE_SIZE >> SECTOR_SHIFT))) { |
104 | ti->error = "Invalid chunk size"; | 105 | ti->error = "Invalid chunk size"; |
105 | return -EINVAL; | 106 | return -EINVAL; |
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index fbe477bb2c68..8939e6105088 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -213,12 +213,11 @@ static int alloc_targets(struct dm_table *t, unsigned int num) | |||
213 | int dm_table_create(struct dm_table **result, int mode, | 213 | int dm_table_create(struct dm_table **result, int mode, |
214 | unsigned num_targets, struct mapped_device *md) | 214 | unsigned num_targets, struct mapped_device *md) |
215 | { | 215 | { |
216 | struct dm_table *t = kmalloc(sizeof(*t), GFP_KERNEL); | 216 | struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL); |
217 | 217 | ||
218 | if (!t) | 218 | if (!t) |
219 | return -ENOMEM; | 219 | return -ENOMEM; |
220 | 220 | ||
221 | memset(t, 0, sizeof(*t)); | ||
222 | INIT_LIST_HEAD(&t->devices); | 221 | INIT_LIST_HEAD(&t->devices); |
223 | atomic_set(&t->holders, 1); | 222 | atomic_set(&t->holders, 1); |
224 | 223 | ||
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index 477a041a41cf..835cf95b857f 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c | |||
@@ -88,12 +88,10 @@ void dm_put_target_type(struct target_type *t) | |||
88 | 88 | ||
89 | static struct tt_internal *alloc_target(struct target_type *t) | 89 | static struct tt_internal *alloc_target(struct target_type *t) |
90 | { | 90 | { |
91 | struct tt_internal *ti = kmalloc(sizeof(*ti), GFP_KERNEL); | 91 | struct tt_internal *ti = kzalloc(sizeof(*ti), GFP_KERNEL); |
92 | 92 | ||
93 | if (ti) { | 93 | if (ti) |
94 | memset(ti, 0, sizeof(*ti)); | ||
95 | ti->tt = *t; | 94 | ti->tt = *t; |
96 | } | ||
97 | 95 | ||
98 | return ti; | 96 | return ti; |
99 | } | 97 | } |
diff --git a/drivers/md/dm-uevent.c b/drivers/md/dm-uevent.c new file mode 100644 index 000000000000..50377e5dc2a3 --- /dev/null +++ b/drivers/md/dm-uevent.c | |||
@@ -0,0 +1,222 @@ | |||
1 | /* | ||
2 | * Device Mapper Uevent Support (dm-uevent) | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | * | ||
18 | * Copyright IBM Corporation, 2007 | ||
19 | * Author: Mike Anderson <andmike@linux.vnet.ibm.com> | ||
20 | */ | ||
21 | #include <linux/list.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/kobject.h> | ||
24 | #include <linux/dm-ioctl.h> | ||
25 | |||
26 | #include "dm.h" | ||
27 | #include "dm-uevent.h" | ||
28 | |||
29 | #define DM_MSG_PREFIX "uevent" | ||
30 | |||
31 | static const struct { | ||
32 | enum dm_uevent_type type; | ||
33 | enum kobject_action action; | ||
34 | char *name; | ||
35 | } _dm_uevent_type_names[] = { | ||
36 | {DM_UEVENT_PATH_FAILED, KOBJ_CHANGE, "PATH_FAILED"}, | ||
37 | {DM_UEVENT_PATH_REINSTATED, KOBJ_CHANGE, "PATH_REINSTATED"}, | ||
38 | }; | ||
39 | |||
40 | static struct kmem_cache *_dm_event_cache; | ||
41 | |||
42 | struct dm_uevent { | ||
43 | struct mapped_device *md; | ||
44 | enum kobject_action action; | ||
45 | struct kobj_uevent_env ku_env; | ||
46 | struct list_head elist; | ||
47 | char name[DM_NAME_LEN]; | ||
48 | char uuid[DM_UUID_LEN]; | ||
49 | }; | ||
50 | |||
51 | static void dm_uevent_free(struct dm_uevent *event) | ||
52 | { | ||
53 | kmem_cache_free(_dm_event_cache, event); | ||
54 | } | ||
55 | |||
56 | static struct dm_uevent *dm_uevent_alloc(struct mapped_device *md) | ||
57 | { | ||
58 | struct dm_uevent *event; | ||
59 | |||
60 | event = kmem_cache_zalloc(_dm_event_cache, GFP_ATOMIC); | ||
61 | if (!event) | ||
62 | return NULL; | ||
63 | |||
64 | INIT_LIST_HEAD(&event->elist); | ||
65 | event->md = md; | ||
66 | |||
67 | return event; | ||
68 | } | ||
69 | |||
70 | static struct dm_uevent *dm_build_path_uevent(struct mapped_device *md, | ||
71 | struct dm_target *ti, | ||
72 | enum kobject_action action, | ||
73 | const char *dm_action, | ||
74 | const char *path, | ||
75 | unsigned nr_valid_paths) | ||
76 | { | ||
77 | struct dm_uevent *event; | ||
78 | |||
79 | event = dm_uevent_alloc(md); | ||
80 | if (!event) { | ||
81 | DMERR("%s: dm_uevent_alloc() failed", __FUNCTION__); | ||
82 | goto err_nomem; | ||
83 | } | ||
84 | |||
85 | event->action = action; | ||
86 | |||
87 | if (add_uevent_var(&event->ku_env, "DM_TARGET=%s", ti->type->name)) { | ||
88 | DMERR("%s: add_uevent_var() for DM_TARGET failed", | ||
89 | __FUNCTION__); | ||
90 | goto err_add; | ||
91 | } | ||
92 | |||
93 | if (add_uevent_var(&event->ku_env, "DM_ACTION=%s", dm_action)) { | ||
94 | DMERR("%s: add_uevent_var() for DM_ACTION failed", | ||
95 | __FUNCTION__); | ||
96 | goto err_add; | ||
97 | } | ||
98 | |||
99 | if (add_uevent_var(&event->ku_env, "DM_SEQNUM=%u", | ||
100 | dm_next_uevent_seq(md))) { | ||
101 | DMERR("%s: add_uevent_var() for DM_SEQNUM failed", | ||
102 | __FUNCTION__); | ||
103 | goto err_add; | ||
104 | } | ||
105 | |||
106 | if (add_uevent_var(&event->ku_env, "DM_PATH=%s", path)) { | ||
107 | DMERR("%s: add_uevent_var() for DM_PATH failed", __FUNCTION__); | ||
108 | goto err_add; | ||
109 | } | ||
110 | |||
111 | if (add_uevent_var(&event->ku_env, "DM_NR_VALID_PATHS=%d", | ||
112 | nr_valid_paths)) { | ||
113 | DMERR("%s: add_uevent_var() for DM_NR_VALID_PATHS failed", | ||
114 | __FUNCTION__); | ||
115 | goto err_add; | ||
116 | } | ||
117 | |||
118 | return event; | ||
119 | |||
120 | err_add: | ||
121 | dm_uevent_free(event); | ||
122 | err_nomem: | ||
123 | return ERR_PTR(-ENOMEM); | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * dm_send_uevents - send uevents for given list | ||
128 | * | ||
129 | * @events: list of events to send | ||
130 | * @kobj: kobject generating event | ||
131 | * | ||
132 | */ | ||
133 | void dm_send_uevents(struct list_head *events, struct kobject *kobj) | ||
134 | { | ||
135 | int r; | ||
136 | struct dm_uevent *event, *next; | ||
137 | |||
138 | list_for_each_entry_safe(event, next, events, elist) { | ||
139 | list_del_init(&event->elist); | ||
140 | |||
141 | /* | ||
142 | * Need to call dm_copy_name_and_uuid from here for now. | ||
143 | * Context of previous var adds and locking used for | ||
144 | * hash_cell not compatable. | ||
145 | */ | ||
146 | if (dm_copy_name_and_uuid(event->md, event->name, | ||
147 | event->uuid)) { | ||
148 | DMERR("%s: dm_copy_name_and_uuid() failed", | ||
149 | __FUNCTION__); | ||
150 | goto uevent_free; | ||
151 | } | ||
152 | |||
153 | if (add_uevent_var(&event->ku_env, "DM_NAME=%s", event->name)) { | ||
154 | DMERR("%s: add_uevent_var() for DM_NAME failed", | ||
155 | __FUNCTION__); | ||
156 | goto uevent_free; | ||
157 | } | ||
158 | |||
159 | if (add_uevent_var(&event->ku_env, "DM_UUID=%s", event->uuid)) { | ||
160 | DMERR("%s: add_uevent_var() for DM_UUID failed", | ||
161 | __FUNCTION__); | ||
162 | goto uevent_free; | ||
163 | } | ||
164 | |||
165 | r = kobject_uevent_env(kobj, event->action, event->ku_env.envp); | ||
166 | if (r) | ||
167 | DMERR("%s: kobject_uevent_env failed", __FUNCTION__); | ||
168 | uevent_free: | ||
169 | dm_uevent_free(event); | ||
170 | } | ||
171 | } | ||
172 | EXPORT_SYMBOL_GPL(dm_send_uevents); | ||
173 | |||
174 | /** | ||
175 | * dm_path_uevent - called to create a new path event and queue it | ||
176 | * | ||
177 | * @event_type: path event type enum | ||
178 | * @ti: pointer to a dm_target | ||
179 | * @path: string containing pathname | ||
180 | * @nr_valid_paths: number of valid paths remaining | ||
181 | * | ||
182 | */ | ||
183 | void dm_path_uevent(enum dm_uevent_type event_type, struct dm_target *ti, | ||
184 | const char *path, unsigned nr_valid_paths) | ||
185 | { | ||
186 | struct mapped_device *md = dm_table_get_md(ti->table); | ||
187 | struct dm_uevent *event; | ||
188 | |||
189 | if (event_type >= ARRAY_SIZE(_dm_uevent_type_names)) { | ||
190 | DMERR("%s: Invalid event_type %d", __FUNCTION__, event_type); | ||
191 | goto out; | ||
192 | } | ||
193 | |||
194 | event = dm_build_path_uevent(md, ti, | ||
195 | _dm_uevent_type_names[event_type].action, | ||
196 | _dm_uevent_type_names[event_type].name, | ||
197 | path, nr_valid_paths); | ||
198 | if (IS_ERR(event)) | ||
199 | goto out; | ||
200 | |||
201 | dm_uevent_add(md, &event->elist); | ||
202 | |||
203 | out: | ||
204 | dm_put(md); | ||
205 | } | ||
206 | EXPORT_SYMBOL_GPL(dm_path_uevent); | ||
207 | |||
208 | int dm_uevent_init(void) | ||
209 | { | ||
210 | _dm_event_cache = KMEM_CACHE(dm_uevent, 0); | ||
211 | if (!_dm_event_cache) | ||
212 | return -ENOMEM; | ||
213 | |||
214 | DMINFO("version 1.0.3"); | ||
215 | |||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | void dm_uevent_exit(void) | ||
220 | { | ||
221 | kmem_cache_destroy(_dm_event_cache); | ||
222 | } | ||
diff --git a/drivers/md/dm-uevent.h b/drivers/md/dm-uevent.h new file mode 100644 index 000000000000..2eccc8bd671a --- /dev/null +++ b/drivers/md/dm-uevent.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * Device Mapper Uevent Support | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | * | ||
18 | * Copyright IBM Corporation, 2007 | ||
19 | * Author: Mike Anderson <andmike@linux.vnet.ibm.com> | ||
20 | */ | ||
21 | #ifndef DM_UEVENT_H | ||
22 | #define DM_UEVENT_H | ||
23 | |||
24 | enum dm_uevent_type { | ||
25 | DM_UEVENT_PATH_FAILED, | ||
26 | DM_UEVENT_PATH_REINSTATED, | ||
27 | }; | ||
28 | |||
29 | #ifdef CONFIG_DM_UEVENT | ||
30 | |||
31 | extern int dm_uevent_init(void); | ||
32 | extern void dm_uevent_exit(void); | ||
33 | extern void dm_send_uevents(struct list_head *events, struct kobject *kobj); | ||
34 | extern void dm_path_uevent(enum dm_uevent_type event_type, | ||
35 | struct dm_target *ti, const char *path, | ||
36 | unsigned nr_valid_paths); | ||
37 | |||
38 | #else | ||
39 | |||
40 | static inline int dm_uevent_init(void) | ||
41 | { | ||
42 | return 0; | ||
43 | } | ||
44 | static inline void dm_uevent_exit(void) | ||
45 | { | ||
46 | } | ||
47 | static inline void dm_send_uevents(struct list_head *events, | ||
48 | struct kobject *kobj) | ||
49 | { | ||
50 | } | ||
51 | static inline void dm_path_uevent(enum dm_uevent_type event_type, | ||
52 | struct dm_target *ti, const char *path, | ||
53 | unsigned nr_valid_paths) | ||
54 | { | ||
55 | } | ||
56 | |||
57 | #endif /* CONFIG_DM_UEVENT */ | ||
58 | |||
59 | #endif /* DM_UEVENT_H */ | ||
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index d837d37f6209..07cbbb8eb3e0 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include "dm.h" | 8 | #include "dm.h" |
9 | #include "dm-bio-list.h" | 9 | #include "dm-bio-list.h" |
10 | #include "dm-uevent.h" | ||
10 | 11 | ||
11 | #include <linux/init.h> | 12 | #include <linux/init.h> |
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
@@ -112,6 +113,9 @@ struct mapped_device { | |||
112 | */ | 113 | */ |
113 | atomic_t event_nr; | 114 | atomic_t event_nr; |
114 | wait_queue_head_t eventq; | 115 | wait_queue_head_t eventq; |
116 | atomic_t uevent_seq; | ||
117 | struct list_head uevent_list; | ||
118 | spinlock_t uevent_lock; /* Protect access to uevent_list */ | ||
115 | 119 | ||
116 | /* | 120 | /* |
117 | * freeze/thaw support require holding onto a super block | 121 | * freeze/thaw support require holding onto a super block |
@@ -143,11 +147,19 @@ static int __init local_init(void) | |||
143 | return -ENOMEM; | 147 | return -ENOMEM; |
144 | } | 148 | } |
145 | 149 | ||
150 | r = dm_uevent_init(); | ||
151 | if (r) { | ||
152 | kmem_cache_destroy(_tio_cache); | ||
153 | kmem_cache_destroy(_io_cache); | ||
154 | return r; | ||
155 | } | ||
156 | |||
146 | _major = major; | 157 | _major = major; |
147 | r = register_blkdev(_major, _name); | 158 | r = register_blkdev(_major, _name); |
148 | if (r < 0) { | 159 | if (r < 0) { |
149 | kmem_cache_destroy(_tio_cache); | 160 | kmem_cache_destroy(_tio_cache); |
150 | kmem_cache_destroy(_io_cache); | 161 | kmem_cache_destroy(_io_cache); |
162 | dm_uevent_exit(); | ||
151 | return r; | 163 | return r; |
152 | } | 164 | } |
153 | 165 | ||
@@ -162,6 +174,7 @@ static void local_exit(void) | |||
162 | kmem_cache_destroy(_tio_cache); | 174 | kmem_cache_destroy(_tio_cache); |
163 | kmem_cache_destroy(_io_cache); | 175 | kmem_cache_destroy(_io_cache); |
164 | unregister_blkdev(_major, _name); | 176 | unregister_blkdev(_major, _name); |
177 | dm_uevent_exit(); | ||
165 | 178 | ||
166 | _major = 0; | 179 | _major = 0; |
167 | 180 | ||
@@ -751,15 +764,13 @@ static void __clone_and_map(struct clone_info *ci) | |||
751 | /* | 764 | /* |
752 | * Split the bio into several clones. | 765 | * Split the bio into several clones. |
753 | */ | 766 | */ |
754 | static void __split_bio(struct mapped_device *md, struct bio *bio) | 767 | static int __split_bio(struct mapped_device *md, struct bio *bio) |
755 | { | 768 | { |
756 | struct clone_info ci; | 769 | struct clone_info ci; |
757 | 770 | ||
758 | ci.map = dm_get_table(md); | 771 | ci.map = dm_get_table(md); |
759 | if (!ci.map) { | 772 | if (unlikely(!ci.map)) |
760 | bio_io_error(bio); | 773 | return -EIO; |
761 | return; | ||
762 | } | ||
763 | 774 | ||
764 | ci.md = md; | 775 | ci.md = md; |
765 | ci.bio = bio; | 776 | ci.bio = bio; |
@@ -779,6 +790,8 @@ static void __split_bio(struct mapped_device *md, struct bio *bio) | |||
779 | /* drop the extra reference count */ | 790 | /* drop the extra reference count */ |
780 | dec_pending(ci.io, 0); | 791 | dec_pending(ci.io, 0); |
781 | dm_table_put(ci.map); | 792 | dm_table_put(ci.map); |
793 | |||
794 | return 0; | ||
782 | } | 795 | } |
783 | /*----------------------------------------------------------------- | 796 | /*----------------------------------------------------------------- |
784 | * CRUD END | 797 | * CRUD END |
@@ -790,7 +803,7 @@ static void __split_bio(struct mapped_device *md, struct bio *bio) | |||
790 | */ | 803 | */ |
791 | static int dm_request(struct request_queue *q, struct bio *bio) | 804 | static int dm_request(struct request_queue *q, struct bio *bio) |
792 | { | 805 | { |
793 | int r; | 806 | int r = -EIO; |
794 | int rw = bio_data_dir(bio); | 807 | int rw = bio_data_dir(bio); |
795 | struct mapped_device *md = q->queuedata; | 808 | struct mapped_device *md = q->queuedata; |
796 | 809 | ||
@@ -815,18 +828,11 @@ static int dm_request(struct request_queue *q, struct bio *bio) | |||
815 | while (test_bit(DMF_BLOCK_IO, &md->flags)) { | 828 | while (test_bit(DMF_BLOCK_IO, &md->flags)) { |
816 | up_read(&md->io_lock); | 829 | up_read(&md->io_lock); |
817 | 830 | ||
818 | if (bio_rw(bio) == READA) { | 831 | if (bio_rw(bio) != READA) |
819 | bio_io_error(bio); | 832 | r = queue_io(md, bio); |
820 | return 0; | ||
821 | } | ||
822 | |||
823 | r = queue_io(md, bio); | ||
824 | if (r < 0) { | ||
825 | bio_io_error(bio); | ||
826 | return 0; | ||
827 | 833 | ||
828 | } else if (r == 0) | 834 | if (r <= 0) |
829 | return 0; /* deferred successfully */ | 835 | goto out_req; |
830 | 836 | ||
831 | /* | 837 | /* |
832 | * We're in a while loop, because someone could suspend | 838 | * We're in a while loop, because someone could suspend |
@@ -835,8 +841,13 @@ static int dm_request(struct request_queue *q, struct bio *bio) | |||
835 | down_read(&md->io_lock); | 841 | down_read(&md->io_lock); |
836 | } | 842 | } |
837 | 843 | ||
838 | __split_bio(md, bio); | 844 | r = __split_bio(md, bio); |
839 | up_read(&md->io_lock); | 845 | up_read(&md->io_lock); |
846 | |||
847 | out_req: | ||
848 | if (r < 0) | ||
849 | bio_io_error(bio); | ||
850 | |||
840 | return 0; | 851 | return 0; |
841 | } | 852 | } |
842 | 853 | ||
@@ -977,6 +988,9 @@ static struct mapped_device *alloc_dev(int minor) | |||
977 | atomic_set(&md->holders, 1); | 988 | atomic_set(&md->holders, 1); |
978 | atomic_set(&md->open_count, 0); | 989 | atomic_set(&md->open_count, 0); |
979 | atomic_set(&md->event_nr, 0); | 990 | atomic_set(&md->event_nr, 0); |
991 | atomic_set(&md->uevent_seq, 0); | ||
992 | INIT_LIST_HEAD(&md->uevent_list); | ||
993 | spin_lock_init(&md->uevent_lock); | ||
980 | 994 | ||
981 | md->queue = blk_alloc_queue(GFP_KERNEL); | 995 | md->queue = blk_alloc_queue(GFP_KERNEL); |
982 | if (!md->queue) | 996 | if (!md->queue) |
@@ -1044,12 +1058,14 @@ static struct mapped_device *alloc_dev(int minor) | |||
1044 | return NULL; | 1058 | return NULL; |
1045 | } | 1059 | } |
1046 | 1060 | ||
1061 | static void unlock_fs(struct mapped_device *md); | ||
1062 | |||
1047 | static void free_dev(struct mapped_device *md) | 1063 | static void free_dev(struct mapped_device *md) |
1048 | { | 1064 | { |
1049 | int minor = md->disk->first_minor; | 1065 | int minor = md->disk->first_minor; |
1050 | 1066 | ||
1051 | if (md->suspended_bdev) { | 1067 | if (md->suspended_bdev) { |
1052 | thaw_bdev(md->suspended_bdev, NULL); | 1068 | unlock_fs(md); |
1053 | bdput(md->suspended_bdev); | 1069 | bdput(md->suspended_bdev); |
1054 | } | 1070 | } |
1055 | mempool_destroy(md->tio_pool); | 1071 | mempool_destroy(md->tio_pool); |
@@ -1073,8 +1089,16 @@ static void free_dev(struct mapped_device *md) | |||
1073 | */ | 1089 | */ |
1074 | static void event_callback(void *context) | 1090 | static void event_callback(void *context) |
1075 | { | 1091 | { |
1092 | unsigned long flags; | ||
1093 | LIST_HEAD(uevents); | ||
1076 | struct mapped_device *md = (struct mapped_device *) context; | 1094 | struct mapped_device *md = (struct mapped_device *) context; |
1077 | 1095 | ||
1096 | spin_lock_irqsave(&md->uevent_lock, flags); | ||
1097 | list_splice_init(&md->uevent_list, &uevents); | ||
1098 | spin_unlock_irqrestore(&md->uevent_lock, flags); | ||
1099 | |||
1100 | dm_send_uevents(&uevents, &md->disk->kobj); | ||
1101 | |||
1078 | atomic_inc(&md->event_nr); | 1102 | atomic_inc(&md->event_nr); |
1079 | wake_up(&md->eventq); | 1103 | wake_up(&md->eventq); |
1080 | } | 1104 | } |
@@ -1233,7 +1257,8 @@ static void __flush_deferred_io(struct mapped_device *md, struct bio *c) | |||
1233 | while (c) { | 1257 | while (c) { |
1234 | n = c->bi_next; | 1258 | n = c->bi_next; |
1235 | c->bi_next = NULL; | 1259 | c->bi_next = NULL; |
1236 | __split_bio(md, c); | 1260 | if (__split_bio(md, c)) |
1261 | bio_io_error(c); | ||
1237 | c = n; | 1262 | c = n; |
1238 | } | 1263 | } |
1239 | } | 1264 | } |
@@ -1491,6 +1516,11 @@ out: | |||
1491 | /*----------------------------------------------------------------- | 1516 | /*----------------------------------------------------------------- |
1492 | * Event notification. | 1517 | * Event notification. |
1493 | *---------------------------------------------------------------*/ | 1518 | *---------------------------------------------------------------*/ |
1519 | uint32_t dm_next_uevent_seq(struct mapped_device *md) | ||
1520 | { | ||
1521 | return atomic_add_return(1, &md->uevent_seq); | ||
1522 | } | ||
1523 | |||
1494 | uint32_t dm_get_event_nr(struct mapped_device *md) | 1524 | uint32_t dm_get_event_nr(struct mapped_device *md) |
1495 | { | 1525 | { |
1496 | return atomic_read(&md->event_nr); | 1526 | return atomic_read(&md->event_nr); |
@@ -1502,6 +1532,15 @@ int dm_wait_event(struct mapped_device *md, int event_nr) | |||
1502 | (event_nr != atomic_read(&md->event_nr))); | 1532 | (event_nr != atomic_read(&md->event_nr))); |
1503 | } | 1533 | } |
1504 | 1534 | ||
1535 | void dm_uevent_add(struct mapped_device *md, struct list_head *elist) | ||
1536 | { | ||
1537 | unsigned long flags; | ||
1538 | |||
1539 | spin_lock_irqsave(&md->uevent_lock, flags); | ||
1540 | list_add(elist, &md->uevent_list); | ||
1541 | spin_unlock_irqrestore(&md->uevent_lock, flags); | ||
1542 | } | ||
1543 | |||
1505 | /* | 1544 | /* |
1506 | * The gendisk is only valid as long as you have a reference | 1545 | * The gendisk is only valid as long as you have a reference |
1507 | * count on 'md'. | 1546 | * count on 'md'. |
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c index 7e052378c47e..f3831f31223e 100644 --- a/drivers/md/kcopyd.c +++ b/drivers/md/kcopyd.c | |||
@@ -198,7 +198,7 @@ struct kcopyd_job { | |||
198 | * These fields are only used if the job has been split | 198 | * These fields are only used if the job has been split |
199 | * into more manageable parts. | 199 | * into more manageable parts. |
200 | */ | 200 | */ |
201 | struct semaphore lock; | 201 | struct mutex lock; |
202 | atomic_t sub_jobs; | 202 | atomic_t sub_jobs; |
203 | sector_t progress; | 203 | sector_t progress; |
204 | }; | 204 | }; |
@@ -456,7 +456,7 @@ static void segment_complete(int read_err, | |||
456 | sector_t count = 0; | 456 | sector_t count = 0; |
457 | struct kcopyd_job *job = (struct kcopyd_job *) context; | 457 | struct kcopyd_job *job = (struct kcopyd_job *) context; |
458 | 458 | ||
459 | down(&job->lock); | 459 | mutex_lock(&job->lock); |
460 | 460 | ||
461 | /* update the error */ | 461 | /* update the error */ |
462 | if (read_err) | 462 | if (read_err) |
@@ -480,7 +480,7 @@ static void segment_complete(int read_err, | |||
480 | job->progress += count; | 480 | job->progress += count; |
481 | } | 481 | } |
482 | } | 482 | } |
483 | up(&job->lock); | 483 | mutex_unlock(&job->lock); |
484 | 484 | ||
485 | if (count) { | 485 | if (count) { |
486 | int i; | 486 | int i; |
@@ -562,7 +562,7 @@ int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from, | |||
562 | dispatch_job(job); | 562 | dispatch_job(job); |
563 | 563 | ||
564 | else { | 564 | else { |
565 | init_MUTEX(&job->lock); | 565 | mutex_init(&job->lock); |
566 | job->progress = 0; | 566 | job->progress = 0; |
567 | split_job(job); | 567 | split_job(job); |
568 | } | 568 | } |
diff --git a/drivers/md/md.c b/drivers/md/md.c index c059ae6f37e5..808cd9549456 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -4717,7 +4717,7 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev, | |||
4717 | 4717 | ||
4718 | void md_unregister_thread(mdk_thread_t *thread) | 4718 | void md_unregister_thread(mdk_thread_t *thread) |
4719 | { | 4719 | { |
4720 | dprintk("interrupting MD-thread pid %d\n", thread->tsk->pid); | 4720 | dprintk("interrupting MD-thread pid %d\n", task_pid_nr(thread->tsk)); |
4721 | 4721 | ||
4722 | kthread_stop(thread->tsk); | 4722 | kthread_stop(thread->tsk); |
4723 | kfree(thread); | 4723 | kfree(thread); |
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 5a12b5679556..154a7ce7cb82 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c | |||
@@ -820,7 +820,7 @@ static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2) | |||
820 | 820 | ||
821 | input_dev->name = DRIVER_NAME " remote control"; | 821 | input_dev->name = DRIVER_NAME " remote control"; |
822 | input_dev->phys = cinergyt2->phys; | 822 | input_dev->phys = cinergyt2->phys; |
823 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 823 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
824 | for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3) | 824 | for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3) |
825 | set_bit(rc_keys[i + 2], input_dev->keybit); | 825 | set_bit(rc_keys[i + 2], input_dev->keybit); |
826 | input_dev->keycodesize = 0; | 826 | input_dev->keycodesize = 0; |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c index 7b9f35bfb4f0..c0c2c22ddd83 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c | |||
@@ -106,7 +106,7 @@ int dvb_usb_remote_init(struct dvb_usb_device *d) | |||
106 | if (!input_dev) | 106 | if (!input_dev) |
107 | return -ENOMEM; | 107 | return -ENOMEM; |
108 | 108 | ||
109 | input_dev->evbit[0] = BIT(EV_KEY); | 109 | input_dev->evbit[0] = BIT_MASK(EV_KEY); |
110 | input_dev->name = "IR-receiver inside an USB DVB receiver"; | 110 | input_dev->name = "IR-receiver inside an USB DVB receiver"; |
111 | input_dev->phys = d->rc_phys; | 111 | input_dev->phys = d->rc_phys; |
112 | usb_to_input_id(d->udev, &input_dev->id); | 112 | usb_to_input_id(d->udev, &input_dev->id); |
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c index 5d19c402dad1..a283e1de83fa 100644 --- a/drivers/media/dvb/ttpci/av7110_ir.c +++ b/drivers/media/dvb/ttpci/av7110_ir.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/proc_fs.h> | 28 | #include <linux/proc_fs.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <asm/bitops.h> | 30 | #include <linux/bitops.h> |
31 | 31 | ||
32 | #include "av7110.h" | 32 | #include "av7110.h" |
33 | #include "av7110_hw.h" | 33 | #include "av7110_hw.h" |
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 5e691fd79904..1ec981d98b91 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c | |||
@@ -1198,7 +1198,7 @@ static int ttusb_init_rc( struct ttusb_dec *dec) | |||
1198 | 1198 | ||
1199 | input_dev->name = "ttusb_dec remote control"; | 1199 | input_dev->name = "ttusb_dec remote control"; |
1200 | input_dev->phys = dec->rc_phys; | 1200 | input_dev->phys = dec->rc_phys; |
1201 | input_dev->evbit[0] = BIT(EV_KEY); | 1201 | input_dev->evbit[0] = BIT_MASK(EV_KEY); |
1202 | input_dev->keycodesize = sizeof(u16); | 1202 | input_dev->keycodesize = sizeof(u16); |
1203 | input_dev->keycodemax = 0x1a; | 1203 | input_dev->keycodemax = 0x1a; |
1204 | input_dev->keycode = rc_keys; | 1204 | input_dev->keycode = rc_keys; |
diff --git a/drivers/media/video/usbvideo/konicawc.c b/drivers/media/video/usbvideo/konicawc.c index 491505d6fdee..3e93f8058770 100644 --- a/drivers/media/video/usbvideo/konicawc.c +++ b/drivers/media/video/usbvideo/konicawc.c | |||
@@ -238,8 +238,8 @@ static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev | |||
238 | usb_to_input_id(dev, &input_dev->id); | 238 | usb_to_input_id(dev, &input_dev->id); |
239 | input_dev->dev.parent = &dev->dev; | 239 | input_dev->dev.parent = &dev->dev; |
240 | 240 | ||
241 | input_dev->evbit[0] = BIT(EV_KEY); | 241 | input_dev->evbit[0] = BIT_MASK(EV_KEY); |
242 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | 242 | input_dev->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0); |
243 | 243 | ||
244 | input_dev->private = cam; | 244 | input_dev->private = cam; |
245 | 245 | ||
diff --git a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c index dd1a6d6bbc9e..d847273eeba0 100644 --- a/drivers/media/video/usbvideo/quickcam_messenger.c +++ b/drivers/media/video/usbvideo/quickcam_messenger.c | |||
@@ -102,8 +102,8 @@ static void qcm_register_input(struct qcm *cam, struct usb_device *dev) | |||
102 | usb_to_input_id(dev, &input_dev->id); | 102 | usb_to_input_id(dev, &input_dev->id); |
103 | input_dev->dev.parent = &dev->dev; | 103 | input_dev->dev.parent = &dev->dev; |
104 | 104 | ||
105 | input_dev->evbit[0] = BIT(EV_KEY); | 105 | input_dev->evbit[0] = BIT_MASK(EV_KEY); |
106 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | 106 | input_dev->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0); |
107 | 107 | ||
108 | input_dev->private = cam; | 108 | input_dev->private = cam; |
109 | 109 | ||
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c index 1c14fa2bd411..419e5af78533 100644 --- a/drivers/media/video/zoran_driver.c +++ b/drivers/media/video/zoran_driver.c | |||
@@ -1285,7 +1285,7 @@ zoran_open (struct inode *inode, | |||
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | dprintk(1, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n", | 1287 | dprintk(1, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n", |
1288 | ZR_DEVNAME(zr), current->comm, current->pid, zr->user); | 1288 | ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user); |
1289 | 1289 | ||
1290 | /* now, create the open()-specific file_ops struct */ | 1290 | /* now, create the open()-specific file_ops struct */ |
1291 | fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL); | 1291 | fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL); |
@@ -1358,7 +1358,7 @@ zoran_close (struct inode *inode, | |||
1358 | struct zoran *zr = fh->zr; | 1358 | struct zoran *zr = fh->zr; |
1359 | 1359 | ||
1360 | dprintk(1, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n", | 1360 | dprintk(1, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n", |
1361 | ZR_DEVNAME(zr), current->comm, current->pid, zr->user); | 1361 | ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user); |
1362 | 1362 | ||
1363 | /* kernel locks (fs/device.c), so don't do that ourselves | 1363 | /* kernel locks (fs/device.c), so don't do that ourselves |
1364 | * (prevents deadlocks) */ | 1364 | * (prevents deadlocks) */ |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 346c44eff95e..cf02ddc3436f 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -111,6 +111,21 @@ config ASUS_LAPTOP | |||
111 | 111 | ||
112 | If you have an ACPI-compatible ASUS laptop, say Y or M here. | 112 | If you have an ACPI-compatible ASUS laptop, say Y or M here. |
113 | 113 | ||
114 | config FUJITSU_LAPTOP | ||
115 | tristate "Fujitsu Laptop Extras" | ||
116 | depends on X86 | ||
117 | depends on ACPI | ||
118 | depends on BACKLIGHT_CLASS_DEVICE | ||
119 | ---help--- | ||
120 | This is a driver for laptops built by Fujitsu: | ||
121 | |||
122 | * P2xxx/P5xxx/S6xxx/S7xxx series Lifebooks | ||
123 | * Possibly other Fujitsu laptop models | ||
124 | |||
125 | It adds support for LCD brightness control. | ||
126 | |||
127 | If you have a Fujitsu laptop, say Y or M here. | ||
128 | |||
114 | config MSI_LAPTOP | 129 | config MSI_LAPTOP |
115 | tristate "MSI Laptop Extras" | 130 | tristate "MSI Laptop Extras" |
116 | depends on X86 | 131 | depends on X86 |
@@ -134,6 +149,7 @@ config SONY_LAPTOP | |||
134 | tristate "Sony Laptop Extras" | 149 | tristate "Sony Laptop Extras" |
135 | depends on X86 && ACPI | 150 | depends on X86 && ACPI |
136 | select BACKLIGHT_CLASS_DEVICE | 151 | select BACKLIGHT_CLASS_DEVICE |
152 | depends on INPUT | ||
137 | ---help--- | 153 | ---help--- |
138 | This mini-driver drives the SNC and SPIC devices present in the ACPI | 154 | This mini-driver drives the SNC and SPIC devices present in the ACPI |
139 | BIOS of the Sony Vaio laptops. | 155 | BIOS of the Sony Vaio laptops. |
@@ -156,6 +172,7 @@ config THINKPAD_ACPI | |||
156 | select BACKLIGHT_CLASS_DEVICE | 172 | select BACKLIGHT_CLASS_DEVICE |
157 | select HWMON | 173 | select HWMON |
158 | select NVRAM | 174 | select NVRAM |
175 | depends on INPUT | ||
159 | ---help--- | 176 | ---help--- |
160 | This is a driver for the IBM and Lenovo ThinkPad laptops. It adds | 177 | This is a driver for the IBM and Lenovo ThinkPad laptops. It adds |
161 | support for Fn-Fx key combinations, Bluetooth control, video | 178 | support for Fn-Fx key combinations, Bluetooth control, video |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index a24c61475c2f..87f2685d728f 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -15,4 +15,5 @@ obj-$(CONFIG_PHANTOM) += phantom.o | |||
15 | obj-$(CONFIG_SGI_IOC4) += ioc4.o | 15 | obj-$(CONFIG_SGI_IOC4) += ioc4.o |
16 | obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o | 16 | obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o |
17 | obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o | 17 | obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o |
18 | obj-$(CONFIG_FUJITSU_LAPTOP) += fujitsu-laptop.o | ||
18 | obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o | 19 | obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o |
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c new file mode 100644 index 000000000000..d366a6cc1fd9 --- /dev/null +++ b/drivers/misc/fujitsu-laptop.c | |||
@@ -0,0 +1,358 @@ | |||
1 | /*-*-linux-c-*-*/ | ||
2 | |||
3 | /* | ||
4 | Copyright (C) 2007 Jonathan Woithe <jwoithe@physics.adelaide.edu.au> | ||
5 | Based on earlier work: | ||
6 | Copyright (C) 2003 Shane Spencer <shane@bogomip.com> | ||
7 | Adrian Yee <brewt-fujitsu@brewt.org> | ||
8 | |||
9 | Templated from msi-laptop.c which is copyright by its respective authors. | ||
10 | |||
11 | This program is free software; you can redistribute it and/or modify | ||
12 | it under the terms of the GNU General Public License as published by | ||
13 | the Free Software Foundation; either version 2 of the License, or | ||
14 | (at your option) any later version. | ||
15 | |||
16 | This program is distributed in the hope that it will be useful, but | ||
17 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | General Public License for more details. | ||
20 | |||
21 | You should have received a copy of the GNU General Public License | ||
22 | along with this program; if not, write to the Free Software | ||
23 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
24 | 02110-1301, USA. | ||
25 | */ | ||
26 | |||
27 | /* | ||
28 | * fujitsu-laptop.c - Fujitsu laptop support, providing access to additional | ||
29 | * features made available on a range of Fujitsu laptops including the | ||
30 | * P2xxx/P5xxx/S6xxx/S7xxx series. | ||
31 | * | ||
32 | * This driver exports a few files in /sys/devices/platform/fujitsu-laptop/; | ||
33 | * others may be added at a later date. | ||
34 | * | ||
35 | * lcd_level - Screen brightness: contains a single integer in the | ||
36 | * range 0..7. (rw) | ||
37 | * | ||
38 | * In addition to these platform device attributes the driver | ||
39 | * registers itself in the Linux backlight control subsystem and is | ||
40 | * available to userspace under /sys/class/backlight/fujitsu-laptop/. | ||
41 | * | ||
42 | * This driver has been tested on a Fujitsu Lifebook S7020. It should | ||
43 | * work on most P-series and S-series Lifebooks, but YMMV. | ||
44 | */ | ||
45 | |||
46 | #include <linux/module.h> | ||
47 | #include <linux/kernel.h> | ||
48 | #include <linux/init.h> | ||
49 | #include <linux/acpi.h> | ||
50 | #include <linux/dmi.h> | ||
51 | #include <linux/backlight.h> | ||
52 | #include <linux/platform_device.h> | ||
53 | #include <linux/autoconf.h> | ||
54 | |||
55 | #define FUJITSU_DRIVER_VERSION "0.3" | ||
56 | |||
57 | #define FUJITSU_LCD_N_LEVELS 8 | ||
58 | |||
59 | #define ACPI_FUJITSU_CLASS "fujitsu" | ||
60 | #define ACPI_FUJITSU_HID "FUJ02B1" | ||
61 | #define ACPI_FUJITSU_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI extras driver" | ||
62 | #define ACPI_FUJITSU_DEVICE_NAME "Fujitsu FUJ02B1" | ||
63 | |||
64 | struct fujitsu_t { | ||
65 | acpi_handle acpi_handle; | ||
66 | struct backlight_device *bl_device; | ||
67 | struct platform_device *pf_device; | ||
68 | |||
69 | unsigned long fuj02b1_state; | ||
70 | unsigned int brightness_changed; | ||
71 | unsigned int brightness_level; | ||
72 | }; | ||
73 | |||
74 | static struct fujitsu_t *fujitsu; | ||
75 | |||
76 | /* Hardware access */ | ||
77 | |||
78 | static int set_lcd_level(int level) | ||
79 | { | ||
80 | acpi_status status = AE_OK; | ||
81 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | ||
82 | struct acpi_object_list arg_list = { 1, &arg0 }; | ||
83 | acpi_handle handle = NULL; | ||
84 | |||
85 | if (level < 0 || level >= FUJITSU_LCD_N_LEVELS) | ||
86 | return -EINVAL; | ||
87 | |||
88 | if (!fujitsu) | ||
89 | return -EINVAL; | ||
90 | |||
91 | status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle); | ||
92 | if (ACPI_FAILURE(status)) { | ||
93 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "SBLL not present\n")); | ||
94 | return -ENODEV; | ||
95 | } | ||
96 | |||
97 | arg0.integer.value = level; | ||
98 | |||
99 | status = acpi_evaluate_object(handle, NULL, &arg_list, NULL); | ||
100 | if (ACPI_FAILURE(status)) | ||
101 | return -ENODEV; | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | static int get_lcd_level(void) | ||
107 | { | ||
108 | unsigned long state = 0; | ||
109 | acpi_status status = AE_OK; | ||
110 | |||
111 | // Get the Brightness | ||
112 | status = | ||
113 | acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state); | ||
114 | if (status < 0) | ||
115 | return status; | ||
116 | |||
117 | fujitsu->fuj02b1_state = state; | ||
118 | fujitsu->brightness_level = state & 0x0fffffff; | ||
119 | |||
120 | if (state & 0x80000000) | ||
121 | fujitsu->brightness_changed = 1; | ||
122 | else | ||
123 | fujitsu->brightness_changed = 0; | ||
124 | |||
125 | if (status < 0) | ||
126 | return status; | ||
127 | |||
128 | return fujitsu->brightness_level; | ||
129 | } | ||
130 | |||
131 | /* Backlight device stuff */ | ||
132 | |||
133 | static int bl_get_brightness(struct backlight_device *b) | ||
134 | { | ||
135 | return get_lcd_level(); | ||
136 | } | ||
137 | |||
138 | static int bl_update_status(struct backlight_device *b) | ||
139 | { | ||
140 | return set_lcd_level(b->props.brightness); | ||
141 | } | ||
142 | |||
143 | static struct backlight_ops fujitsubl_ops = { | ||
144 | .get_brightness = bl_get_brightness, | ||
145 | .update_status = bl_update_status, | ||
146 | }; | ||
147 | |||
148 | /* Platform device */ | ||
149 | |||
150 | static ssize_t show_lcd_level(struct device *dev, | ||
151 | struct device_attribute *attr, char *buf) | ||
152 | { | ||
153 | |||
154 | int ret; | ||
155 | |||
156 | ret = get_lcd_level(); | ||
157 | if (ret < 0) | ||
158 | return ret; | ||
159 | |||
160 | return sprintf(buf, "%i\n", ret); | ||
161 | } | ||
162 | |||
163 | static ssize_t store_lcd_level(struct device *dev, | ||
164 | struct device_attribute *attr, const char *buf, | ||
165 | size_t count) | ||
166 | { | ||
167 | |||
168 | int level, ret; | ||
169 | |||
170 | if (sscanf(buf, "%i", &level) != 1 | ||
171 | || (level < 0 || level >= FUJITSU_LCD_N_LEVELS)) | ||
172 | return -EINVAL; | ||
173 | |||
174 | ret = set_lcd_level(level); | ||
175 | if (ret < 0) | ||
176 | return ret; | ||
177 | |||
178 | return count; | ||
179 | } | ||
180 | |||
181 | static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level); | ||
182 | |||
183 | static struct attribute *fujitsupf_attributes[] = { | ||
184 | &dev_attr_lcd_level.attr, | ||
185 | NULL | ||
186 | }; | ||
187 | |||
188 | static struct attribute_group fujitsupf_attribute_group = { | ||
189 | .attrs = fujitsupf_attributes | ||
190 | }; | ||
191 | |||
192 | static struct platform_driver fujitsupf_driver = { | ||
193 | .driver = { | ||
194 | .name = "fujitsu-laptop", | ||
195 | .owner = THIS_MODULE, | ||
196 | } | ||
197 | }; | ||
198 | |||
199 | /* ACPI device */ | ||
200 | |||
201 | int acpi_fujitsu_add(struct acpi_device *device) | ||
202 | { | ||
203 | int result = 0; | ||
204 | int state = 0; | ||
205 | |||
206 | ACPI_FUNCTION_TRACE("acpi_fujitsu_add"); | ||
207 | |||
208 | if (!device) | ||
209 | return -EINVAL; | ||
210 | |||
211 | fujitsu->acpi_handle = device->handle; | ||
212 | sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME); | ||
213 | sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); | ||
214 | acpi_driver_data(device) = fujitsu; | ||
215 | |||
216 | result = acpi_bus_get_power(fujitsu->acpi_handle, &state); | ||
217 | if (result) { | ||
218 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
219 | "Error reading power state\n")); | ||
220 | goto end; | ||
221 | } | ||
222 | |||
223 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", | ||
224 | acpi_device_name(device), acpi_device_bid(device), | ||
225 | !device->power.state ? "on" : "off"); | ||
226 | |||
227 | end: | ||
228 | |||
229 | return result; | ||
230 | } | ||
231 | |||
232 | int acpi_fujitsu_remove(struct acpi_device *device, int type) | ||
233 | { | ||
234 | ACPI_FUNCTION_TRACE("acpi_fujitsu_remove"); | ||
235 | |||
236 | if (!device || !acpi_driver_data(device)) | ||
237 | return -EINVAL; | ||
238 | fujitsu->acpi_handle = 0; | ||
239 | |||
240 | return 0; | ||
241 | } | ||
242 | |||
243 | static const struct acpi_device_id fujitsu_device_ids[] = { | ||
244 | {ACPI_FUJITSU_HID, 0}, | ||
245 | {"", 0}, | ||
246 | }; | ||
247 | |||
248 | static struct acpi_driver acpi_fujitsu_driver = { | ||
249 | .name = ACPI_FUJITSU_DRIVER_NAME, | ||
250 | .class = ACPI_FUJITSU_CLASS, | ||
251 | .ids = fujitsu_device_ids, | ||
252 | .ops = { | ||
253 | .add = acpi_fujitsu_add, | ||
254 | .remove = acpi_fujitsu_remove, | ||
255 | }, | ||
256 | }; | ||
257 | |||
258 | /* Initialization */ | ||
259 | |||
260 | static int __init fujitsu_init(void) | ||
261 | { | ||
262 | int ret, result; | ||
263 | |||
264 | if (acpi_disabled) | ||
265 | return -ENODEV; | ||
266 | |||
267 | fujitsu = kmalloc(sizeof(struct fujitsu_t), GFP_KERNEL); | ||
268 | if (!fujitsu) | ||
269 | return -ENOMEM; | ||
270 | memset(fujitsu, 0, sizeof(struct fujitsu_t)); | ||
271 | |||
272 | result = acpi_bus_register_driver(&acpi_fujitsu_driver); | ||
273 | if (result < 0) { | ||
274 | ret = -ENODEV; | ||
275 | goto fail_acpi; | ||
276 | } | ||
277 | |||
278 | /* Register backlight stuff */ | ||
279 | |||
280 | fujitsu->bl_device = | ||
281 | backlight_device_register("fujitsu-laptop", NULL, NULL, | ||
282 | &fujitsubl_ops); | ||
283 | if (IS_ERR(fujitsu->bl_device)) | ||
284 | return PTR_ERR(fujitsu->bl_device); | ||
285 | |||
286 | fujitsu->bl_device->props.max_brightness = FUJITSU_LCD_N_LEVELS - 1; | ||
287 | ret = platform_driver_register(&fujitsupf_driver); | ||
288 | if (ret) | ||
289 | goto fail_backlight; | ||
290 | |||
291 | /* Register platform stuff */ | ||
292 | |||
293 | fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1); | ||
294 | if (!fujitsu->pf_device) { | ||
295 | ret = -ENOMEM; | ||
296 | goto fail_platform_driver; | ||
297 | } | ||
298 | |||
299 | ret = platform_device_add(fujitsu->pf_device); | ||
300 | if (ret) | ||
301 | goto fail_platform_device1; | ||
302 | |||
303 | ret = | ||
304 | sysfs_create_group(&fujitsu->pf_device->dev.kobj, | ||
305 | &fujitsupf_attribute_group); | ||
306 | if (ret) | ||
307 | goto fail_platform_device2; | ||
308 | |||
309 | printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION | ||
310 | " successfully loaded.\n"); | ||
311 | |||
312 | return 0; | ||
313 | |||
314 | fail_platform_device2: | ||
315 | |||
316 | platform_device_del(fujitsu->pf_device); | ||
317 | |||
318 | fail_platform_device1: | ||
319 | |||
320 | platform_device_put(fujitsu->pf_device); | ||
321 | |||
322 | fail_platform_driver: | ||
323 | |||
324 | platform_driver_unregister(&fujitsupf_driver); | ||
325 | |||
326 | fail_backlight: | ||
327 | |||
328 | backlight_device_unregister(fujitsu->bl_device); | ||
329 | |||
330 | fail_acpi: | ||
331 | |||
332 | kfree(fujitsu); | ||
333 | |||
334 | return ret; | ||
335 | } | ||
336 | |||
337 | static void __exit fujitsu_cleanup(void) | ||
338 | { | ||
339 | sysfs_remove_group(&fujitsu->pf_device->dev.kobj, | ||
340 | &fujitsupf_attribute_group); | ||
341 | platform_device_unregister(fujitsu->pf_device); | ||
342 | platform_driver_unregister(&fujitsupf_driver); | ||
343 | backlight_device_unregister(fujitsu->bl_device); | ||
344 | |||
345 | acpi_bus_unregister_driver(&acpi_fujitsu_driver); | ||
346 | |||
347 | kfree(fujitsu); | ||
348 | |||
349 | printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n"); | ||
350 | } | ||
351 | |||
352 | module_init(fujitsu_init); | ||
353 | module_exit(fujitsu_cleanup); | ||
354 | |||
355 | MODULE_AUTHOR("Jonathan Woithe"); | ||
356 | MODULE_DESCRIPTION("Fujitsu laptop extras support"); | ||
357 | MODULE_VERSION(FUJITSU_DRIVER_VERSION); | ||
358 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/misc/ibmasm/remote.c b/drivers/misc/ibmasm/remote.c index 0550ce075fc4..1d9defb1a10c 100644 --- a/drivers/misc/ibmasm/remote.c +++ b/drivers/misc/ibmasm/remote.c | |||
@@ -226,9 +226,9 @@ int ibmasm_init_remote_input_dev(struct service_processor *sp) | |||
226 | mouse_dev->id.product = pdev->device; | 226 | mouse_dev->id.product = pdev->device; |
227 | mouse_dev->id.version = 1; | 227 | mouse_dev->id.version = 1; |
228 | mouse_dev->dev.parent = sp->dev; | 228 | mouse_dev->dev.parent = sp->dev; |
229 | mouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 229 | mouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
230 | mouse_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | | 230 | mouse_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | |
231 | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 231 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); |
232 | set_bit(BTN_TOUCH, mouse_dev->keybit); | 232 | set_bit(BTN_TOUCH, mouse_dev->keybit); |
233 | mouse_dev->name = "ibmasm RSA I remote mouse"; | 233 | mouse_dev->name = "ibmasm RSA I remote mouse"; |
234 | input_set_abs_params(mouse_dev, ABS_X, 0, MOUSE_X_MAX, 0, 0); | 234 | input_set_abs_params(mouse_dev, ABS_X, 0, MOUSE_X_MAX, 0, 0); |
@@ -239,7 +239,7 @@ int ibmasm_init_remote_input_dev(struct service_processor *sp) | |||
239 | keybd_dev->id.product = pdev->device; | 239 | keybd_dev->id.product = pdev->device; |
240 | keybd_dev->id.version = 2; | 240 | keybd_dev->id.version = 2; |
241 | keybd_dev->dev.parent = sp->dev; | 241 | keybd_dev->dev.parent = sp->dev; |
242 | keybd_dev->evbit[0] = BIT(EV_KEY); | 242 | keybd_dev->evbit[0] = BIT_MASK(EV_KEY); |
243 | keybd_dev->name = "ibmasm RSA I remote keyboard"; | 243 | keybd_dev->name = "ibmasm RSA I remote keyboard"; |
244 | 244 | ||
245 | for (i = 0; i < XLATE_SIZE; i++) { | 245 | for (i = 0; i < XLATE_SIZE; i++) { |
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index 5108b7c576df..cd221fd0fb94 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * You need an userspace library to cooperate with this driver. It (and other | 9 | * You need an userspace library to cooperate with this driver. It (and other |
10 | * info) may be obtained here: | 10 | * info) may be obtained here: |
11 | * http://www.fi.muni.cz/~xslaby/phantom.html | 11 | * http://www.fi.muni.cz/~xslaby/phantom.html |
12 | * or alternatively, you might use OpenHaptics provided by Sensable. | ||
12 | */ | 13 | */ |
13 | 14 | ||
14 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
@@ -24,13 +25,14 @@ | |||
24 | #include <asm/atomic.h> | 25 | #include <asm/atomic.h> |
25 | #include <asm/io.h> | 26 | #include <asm/io.h> |
26 | 27 | ||
27 | #define PHANTOM_VERSION "n0.9.5" | 28 | #define PHANTOM_VERSION "n0.9.7" |
28 | 29 | ||
29 | #define PHANTOM_MAX_MINORS 8 | 30 | #define PHANTOM_MAX_MINORS 8 |
30 | 31 | ||
31 | #define PHN_IRQCTL 0x4c /* irq control in caddr space */ | 32 | #define PHN_IRQCTL 0x4c /* irq control in caddr space */ |
32 | 33 | ||
33 | #define PHB_RUNNING 1 | 34 | #define PHB_RUNNING 1 |
35 | #define PHB_NOT_OH 2 | ||
34 | 36 | ||
35 | static struct class *phantom_class; | 37 | static struct class *phantom_class; |
36 | static int phantom_major; | 38 | static int phantom_major; |
@@ -47,7 +49,11 @@ struct phantom_device { | |||
47 | struct cdev cdev; | 49 | struct cdev cdev; |
48 | 50 | ||
49 | struct mutex open_lock; | 51 | struct mutex open_lock; |
50 | spinlock_t ioctl_lock; | 52 | spinlock_t regs_lock; |
53 | |||
54 | /* used in NOT_OH mode */ | ||
55 | struct phm_regs oregs; | ||
56 | u32 ctl_reg; | ||
51 | }; | 57 | }; |
52 | 58 | ||
53 | static unsigned char phantom_devices[PHANTOM_MAX_MINORS]; | 59 | static unsigned char phantom_devices[PHANTOM_MAX_MINORS]; |
@@ -82,6 +88,7 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, | |||
82 | struct phm_regs rs; | 88 | struct phm_regs rs; |
83 | struct phm_reg r; | 89 | struct phm_reg r; |
84 | void __user *argp = (void __user *)arg; | 90 | void __user *argp = (void __user *)arg; |
91 | unsigned long flags; | ||
85 | unsigned int i; | 92 | unsigned int i; |
86 | 93 | ||
87 | if (_IOC_TYPE(cmd) != PH_IOC_MAGIC || | 94 | if (_IOC_TYPE(cmd) != PH_IOC_MAGIC || |
@@ -96,32 +103,45 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, | |||
96 | if (r.reg > 7) | 103 | if (r.reg > 7) |
97 | return -EINVAL; | 104 | return -EINVAL; |
98 | 105 | ||
99 | spin_lock(&dev->ioctl_lock); | 106 | spin_lock_irqsave(&dev->regs_lock, flags); |
100 | if (r.reg == PHN_CONTROL && (r.value & PHN_CTL_IRQ) && | 107 | if (r.reg == PHN_CONTROL && (r.value & PHN_CTL_IRQ) && |
101 | phantom_status(dev, dev->status | PHB_RUNNING)){ | 108 | phantom_status(dev, dev->status | PHB_RUNNING)){ |
102 | spin_unlock(&dev->ioctl_lock); | 109 | spin_unlock_irqrestore(&dev->regs_lock, flags); |
103 | return -ENODEV; | 110 | return -ENODEV; |
104 | } | 111 | } |
105 | 112 | ||
106 | pr_debug("phantom: writing %x to %u\n", r.value, r.reg); | 113 | pr_debug("phantom: writing %x to %u\n", r.value, r.reg); |
114 | |||
115 | /* preserve amp bit (don't allow to change it when in NOT_OH) */ | ||
116 | if (r.reg == PHN_CONTROL && (dev->status & PHB_NOT_OH)) { | ||
117 | r.value &= ~PHN_CTL_AMP; | ||
118 | r.value |= dev->ctl_reg & PHN_CTL_AMP; | ||
119 | dev->ctl_reg = r.value; | ||
120 | } | ||
121 | |||
107 | iowrite32(r.value, dev->iaddr + r.reg); | 122 | iowrite32(r.value, dev->iaddr + r.reg); |
108 | ioread32(dev->iaddr); /* PCI posting */ | 123 | ioread32(dev->iaddr); /* PCI posting */ |
109 | 124 | ||
110 | if (r.reg == PHN_CONTROL && !(r.value & PHN_CTL_IRQ)) | 125 | if (r.reg == PHN_CONTROL && !(r.value & PHN_CTL_IRQ)) |
111 | phantom_status(dev, dev->status & ~PHB_RUNNING); | 126 | phantom_status(dev, dev->status & ~PHB_RUNNING); |
112 | spin_unlock(&dev->ioctl_lock); | 127 | spin_unlock_irqrestore(&dev->regs_lock, flags); |
113 | break; | 128 | break; |
114 | case PHN_SET_REGS: | 129 | case PHN_SET_REGS: |
115 | if (copy_from_user(&rs, argp, sizeof(rs))) | 130 | if (copy_from_user(&rs, argp, sizeof(rs))) |
116 | return -EFAULT; | 131 | return -EFAULT; |
117 | 132 | ||
118 | pr_debug("phantom: SRS %u regs %x\n", rs.count, rs.mask); | 133 | pr_debug("phantom: SRS %u regs %x\n", rs.count, rs.mask); |
119 | spin_lock(&dev->ioctl_lock); | 134 | spin_lock_irqsave(&dev->regs_lock, flags); |
120 | for (i = 0; i < min(rs.count, 8U); i++) | 135 | if (dev->status & PHB_NOT_OH) |
121 | if ((1 << i) & rs.mask) | 136 | memcpy(&dev->oregs, &rs, sizeof(rs)); |
122 | iowrite32(rs.values[i], dev->oaddr + i); | 137 | else { |
123 | ioread32(dev->iaddr); /* PCI posting */ | 138 | u32 m = min(rs.count, 8U); |
124 | spin_unlock(&dev->ioctl_lock); | 139 | for (i = 0; i < m; i++) |
140 | if (rs.mask & BIT(i)) | ||
141 | iowrite32(rs.values[i], dev->oaddr + i); | ||
142 | ioread32(dev->iaddr); /* PCI posting */ | ||
143 | } | ||
144 | spin_unlock_irqrestore(&dev->regs_lock, flags); | ||
125 | break; | 145 | break; |
126 | case PHN_GET_REG: | 146 | case PHN_GET_REG: |
127 | if (copy_from_user(&r, argp, sizeof(r))) | 147 | if (copy_from_user(&r, argp, sizeof(r))) |
@@ -135,20 +155,35 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, | |||
135 | if (copy_to_user(argp, &r, sizeof(r))) | 155 | if (copy_to_user(argp, &r, sizeof(r))) |
136 | return -EFAULT; | 156 | return -EFAULT; |
137 | break; | 157 | break; |
138 | case PHN_GET_REGS: | 158 | case PHN_GET_REGS: { |
159 | u32 m; | ||
160 | |||
139 | if (copy_from_user(&rs, argp, sizeof(rs))) | 161 | if (copy_from_user(&rs, argp, sizeof(rs))) |
140 | return -EFAULT; | 162 | return -EFAULT; |
141 | 163 | ||
164 | m = min(rs.count, 8U); | ||
165 | |||
142 | pr_debug("phantom: GRS %u regs %x\n", rs.count, rs.mask); | 166 | pr_debug("phantom: GRS %u regs %x\n", rs.count, rs.mask); |
143 | spin_lock(&dev->ioctl_lock); | 167 | spin_lock_irqsave(&dev->regs_lock, flags); |
144 | for (i = 0; i < min(rs.count, 8U); i++) | 168 | for (i = 0; i < m; i++) |
145 | if ((1 << i) & rs.mask) | 169 | if (rs.mask & BIT(i)) |
146 | rs.values[i] = ioread32(dev->iaddr + i); | 170 | rs.values[i] = ioread32(dev->iaddr + i); |
147 | spin_unlock(&dev->ioctl_lock); | 171 | spin_unlock_irqrestore(&dev->regs_lock, flags); |
148 | 172 | ||
149 | if (copy_to_user(argp, &rs, sizeof(rs))) | 173 | if (copy_to_user(argp, &rs, sizeof(rs))) |
150 | return -EFAULT; | 174 | return -EFAULT; |
151 | break; | 175 | break; |
176 | } case PHN_NOT_OH: | ||
177 | spin_lock_irqsave(&dev->regs_lock, flags); | ||
178 | if (dev->status & PHB_RUNNING) { | ||
179 | printk(KERN_ERR "phantom: you need to set NOT_OH " | ||
180 | "before you start the device!\n"); | ||
181 | spin_unlock_irqrestore(&dev->regs_lock, flags); | ||
182 | return -EINVAL; | ||
183 | } | ||
184 | dev->status |= PHB_NOT_OH; | ||
185 | spin_unlock_irqrestore(&dev->regs_lock, flags); | ||
186 | break; | ||
152 | default: | 187 | default: |
153 | return -ENOTTY; | 188 | return -ENOTTY; |
154 | } | 189 | } |
@@ -171,8 +206,11 @@ static int phantom_open(struct inode *inode, struct file *file) | |||
171 | return -EINVAL; | 206 | return -EINVAL; |
172 | } | 207 | } |
173 | 208 | ||
209 | WARN_ON(dev->status & PHB_NOT_OH); | ||
210 | |||
174 | file->private_data = dev; | 211 | file->private_data = dev; |
175 | 212 | ||
213 | atomic_set(&dev->counter, 0); | ||
176 | dev->opened++; | 214 | dev->opened++; |
177 | mutex_unlock(&dev->open_lock); | 215 | mutex_unlock(&dev->open_lock); |
178 | 216 | ||
@@ -187,6 +225,7 @@ static int phantom_release(struct inode *inode, struct file *file) | |||
187 | 225 | ||
188 | dev->opened = 0; | 226 | dev->opened = 0; |
189 | phantom_status(dev, dev->status & ~PHB_RUNNING); | 227 | phantom_status(dev, dev->status & ~PHB_RUNNING); |
228 | dev->status &= ~PHB_NOT_OH; | ||
190 | 229 | ||
191 | mutex_unlock(&dev->open_lock); | 230 | mutex_unlock(&dev->open_lock); |
192 | 231 | ||
@@ -220,12 +259,32 @@ static struct file_operations phantom_file_ops = { | |||
220 | static irqreturn_t phantom_isr(int irq, void *data) | 259 | static irqreturn_t phantom_isr(int irq, void *data) |
221 | { | 260 | { |
222 | struct phantom_device *dev = data; | 261 | struct phantom_device *dev = data; |
262 | unsigned int i; | ||
263 | u32 ctl; | ||
223 | 264 | ||
224 | if (!(ioread32(dev->iaddr + PHN_CONTROL) & PHN_CTL_IRQ)) | 265 | spin_lock(&dev->regs_lock); |
266 | ctl = ioread32(dev->iaddr + PHN_CONTROL); | ||
267 | if (!(ctl & PHN_CTL_IRQ)) { | ||
268 | spin_unlock(&dev->regs_lock); | ||
225 | return IRQ_NONE; | 269 | return IRQ_NONE; |
270 | } | ||
226 | 271 | ||
227 | iowrite32(0, dev->iaddr); | 272 | iowrite32(0, dev->iaddr); |
228 | iowrite32(0xc0, dev->iaddr); | 273 | iowrite32(0xc0, dev->iaddr); |
274 | |||
275 | if (dev->status & PHB_NOT_OH) { | ||
276 | struct phm_regs *r = &dev->oregs; | ||
277 | u32 m = min(r->count, 8U); | ||
278 | |||
279 | for (i = 0; i < m; i++) | ||
280 | if (r->mask & BIT(i)) | ||
281 | iowrite32(r->values[i], dev->oaddr + i); | ||
282 | |||
283 | dev->ctl_reg ^= PHN_CTL_AMP; | ||
284 | iowrite32(dev->ctl_reg, dev->iaddr + PHN_CONTROL); | ||
285 | } | ||
286 | spin_unlock(&dev->regs_lock); | ||
287 | |||
229 | ioread32(dev->iaddr); /* PCI posting */ | 288 | ioread32(dev->iaddr); /* PCI posting */ |
230 | 289 | ||
231 | atomic_inc(&dev->counter); | 290 | atomic_inc(&dev->counter); |
@@ -297,7 +356,7 @@ static int __devinit phantom_probe(struct pci_dev *pdev, | |||
297 | } | 356 | } |
298 | 357 | ||
299 | mutex_init(&pht->open_lock); | 358 | mutex_init(&pht->open_lock); |
300 | spin_lock_init(&pht->ioctl_lock); | 359 | spin_lock_init(&pht->regs_lock); |
301 | init_waitqueue_head(&pht->wait); | 360 | init_waitqueue_head(&pht->wait); |
302 | cdev_init(&pht->cdev, &phantom_file_ops); | 361 | cdev_init(&pht->cdev, &phantom_file_ops); |
303 | pht->cdev.owner = THIS_MODULE; | 362 | pht->cdev.owner = THIS_MODULE; |
@@ -378,6 +437,8 @@ static int phantom_suspend(struct pci_dev *pdev, pm_message_t state) | |||
378 | iowrite32(0, dev->caddr + PHN_IRQCTL); | 437 | iowrite32(0, dev->caddr + PHN_IRQCTL); |
379 | ioread32(dev->caddr + PHN_IRQCTL); /* PCI posting */ | 438 | ioread32(dev->caddr + PHN_IRQCTL); /* PCI posting */ |
380 | 439 | ||
440 | synchronize_irq(pdev->irq); | ||
441 | |||
381 | return 0; | 442 | return 0; |
382 | } | 443 | } |
383 | 444 | ||
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c index e73a71f04bb4..1bfbb87e5793 100644 --- a/drivers/misc/sony-laptop.c +++ b/drivers/misc/sony-laptop.c | |||
@@ -411,9 +411,9 @@ static int sony_laptop_setup_input(void) | |||
411 | jog_dev->id.bustype = BUS_ISA; | 411 | jog_dev->id.bustype = BUS_ISA; |
412 | jog_dev->id.vendor = PCI_VENDOR_ID_SONY; | 412 | jog_dev->id.vendor = PCI_VENDOR_ID_SONY; |
413 | 413 | ||
414 | jog_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 414 | jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
415 | jog_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE); | 415 | jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE); |
416 | jog_dev->relbit[0] = BIT(REL_WHEEL); | 416 | jog_dev->relbit[0] = BIT_MASK(REL_WHEEL); |
417 | 417 | ||
418 | error = input_register_device(jog_dev); | 418 | error = input_register_device(jog_dev); |
419 | if (error) | 419 | if (error) |
@@ -1173,7 +1173,8 @@ static struct acpi_driver sony_nc_driver = { | |||
1173 | #define SONYPI_TYPE3_OFFSET 0x12 | 1173 | #define SONYPI_TYPE3_OFFSET 0x12 |
1174 | 1174 | ||
1175 | struct sony_pic_ioport { | 1175 | struct sony_pic_ioport { |
1176 | struct acpi_resource_io io; | 1176 | struct acpi_resource_io io1; |
1177 | struct acpi_resource_io io2; | ||
1177 | struct list_head list; | 1178 | struct list_head list; |
1178 | }; | 1179 | }; |
1179 | 1180 | ||
@@ -1443,11 +1444,11 @@ static u8 sony_pic_call1(u8 dev) | |||
1443 | { | 1444 | { |
1444 | u8 v1, v2; | 1445 | u8 v1, v2; |
1445 | 1446 | ||
1446 | wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, | 1447 | wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, |
1447 | ITERATIONS_LONG); | 1448 | ITERATIONS_LONG); |
1448 | outb(dev, spic_dev.cur_ioport->io.minimum + 4); | 1449 | outb(dev, spic_dev.cur_ioport->io1.minimum + 4); |
1449 | v1 = inb_p(spic_dev.cur_ioport->io.minimum + 4); | 1450 | v1 = inb_p(spic_dev.cur_ioport->io1.minimum + 4); |
1450 | v2 = inb_p(spic_dev.cur_ioport->io.minimum); | 1451 | v2 = inb_p(spic_dev.cur_ioport->io1.minimum); |
1451 | dprintk("sony_pic_call1: 0x%.4x\n", (v2 << 8) | v1); | 1452 | dprintk("sony_pic_call1: 0x%.4x\n", (v2 << 8) | v1); |
1452 | return v2; | 1453 | return v2; |
1453 | } | 1454 | } |
@@ -1456,13 +1457,13 @@ static u8 sony_pic_call2(u8 dev, u8 fn) | |||
1456 | { | 1457 | { |
1457 | u8 v1; | 1458 | u8 v1; |
1458 | 1459 | ||
1459 | wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, | 1460 | wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, |
1460 | ITERATIONS_LONG); | 1461 | ITERATIONS_LONG); |
1461 | outb(dev, spic_dev.cur_ioport->io.minimum + 4); | 1462 | outb(dev, spic_dev.cur_ioport->io1.minimum + 4); |
1462 | wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, | 1463 | wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, |
1463 | ITERATIONS_LONG); | 1464 | ITERATIONS_LONG); |
1464 | outb(fn, spic_dev.cur_ioport->io.minimum); | 1465 | outb(fn, spic_dev.cur_ioport->io1.minimum); |
1465 | v1 = inb_p(spic_dev.cur_ioport->io.minimum); | 1466 | v1 = inb_p(spic_dev.cur_ioport->io1.minimum); |
1466 | dprintk("sony_pic_call2: 0x%.4x\n", v1); | 1467 | dprintk("sony_pic_call2: 0x%.4x\n", v1); |
1467 | return v1; | 1468 | return v1; |
1468 | } | 1469 | } |
@@ -1471,13 +1472,13 @@ static u8 sony_pic_call3(u8 dev, u8 fn, u8 v) | |||
1471 | { | 1472 | { |
1472 | u8 v1; | 1473 | u8 v1; |
1473 | 1474 | ||
1474 | wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG); | 1475 | wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); |
1475 | outb(dev, spic_dev.cur_ioport->io.minimum + 4); | 1476 | outb(dev, spic_dev.cur_ioport->io1.minimum + 4); |
1476 | wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG); | 1477 | wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); |
1477 | outb(fn, spic_dev.cur_ioport->io.minimum); | 1478 | outb(fn, spic_dev.cur_ioport->io1.minimum); |
1478 | wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG); | 1479 | wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); |
1479 | outb(v, spic_dev.cur_ioport->io.minimum); | 1480 | outb(v, spic_dev.cur_ioport->io1.minimum); |
1480 | v1 = inb_p(spic_dev.cur_ioport->io.minimum); | 1481 | v1 = inb_p(spic_dev.cur_ioport->io1.minimum); |
1481 | dprintk("sony_pic_call3: 0x%.4x\n", v1); | 1482 | dprintk("sony_pic_call3: 0x%.4x\n", v1); |
1482 | return v1; | 1483 | return v1; |
1483 | } | 1484 | } |
@@ -2074,7 +2075,18 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context) | |||
2074 | 2075 | ||
2075 | switch (resource->type) { | 2076 | switch (resource->type) { |
2076 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 2077 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
2078 | { | ||
2079 | /* start IO enumeration */ | ||
2080 | struct sony_pic_ioport *ioport = kzalloc(sizeof(*ioport), GFP_KERNEL); | ||
2081 | if (!ioport) | ||
2082 | return AE_ERROR; | ||
2083 | |||
2084 | list_add(&ioport->list, &dev->ioports); | ||
2085 | return AE_OK; | ||
2086 | } | ||
2087 | |||
2077 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: | 2088 | case ACPI_RESOURCE_TYPE_END_DEPENDENT: |
2089 | /* end IO enumeration */ | ||
2078 | return AE_OK; | 2090 | return AE_OK; |
2079 | 2091 | ||
2080 | case ACPI_RESOURCE_TYPE_IRQ: | 2092 | case ACPI_RESOURCE_TYPE_IRQ: |
@@ -2101,7 +2113,7 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context) | |||
2101 | if (!interrupt) | 2113 | if (!interrupt) |
2102 | return AE_ERROR; | 2114 | return AE_ERROR; |
2103 | 2115 | ||
2104 | list_add_tail(&interrupt->list, &dev->interrupts); | 2116 | list_add(&interrupt->list, &dev->interrupts); |
2105 | interrupt->irq.triggering = p->triggering; | 2117 | interrupt->irq.triggering = p->triggering; |
2106 | interrupt->irq.polarity = p->polarity; | 2118 | interrupt->irq.polarity = p->polarity; |
2107 | interrupt->irq.sharable = p->sharable; | 2119 | interrupt->irq.sharable = p->sharable; |
@@ -2113,18 +2125,27 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context) | |||
2113 | case ACPI_RESOURCE_TYPE_IO: | 2125 | case ACPI_RESOURCE_TYPE_IO: |
2114 | { | 2126 | { |
2115 | struct acpi_resource_io *io = &resource->data.io; | 2127 | struct acpi_resource_io *io = &resource->data.io; |
2116 | struct sony_pic_ioport *ioport = NULL; | 2128 | struct sony_pic_ioport *ioport = |
2129 | list_first_entry(&dev->ioports, struct sony_pic_ioport, list); | ||
2117 | if (!io) { | 2130 | if (!io) { |
2118 | dprintk("Blank IO resource\n"); | 2131 | dprintk("Blank IO resource\n"); |
2119 | return AE_OK; | 2132 | return AE_OK; |
2120 | } | 2133 | } |
2121 | 2134 | ||
2122 | ioport = kzalloc(sizeof(*ioport), GFP_KERNEL); | 2135 | if (!ioport->io1.minimum) { |
2123 | if (!ioport) | 2136 | memcpy(&ioport->io1, io, sizeof(*io)); |
2137 | dprintk("IO1 at 0x%.4x (0x%.2x)\n", ioport->io1.minimum, | ||
2138 | ioport->io1.address_length); | ||
2139 | } | ||
2140 | else if (!ioport->io2.minimum) { | ||
2141 | memcpy(&ioport->io2, io, sizeof(*io)); | ||
2142 | dprintk("IO2 at 0x%.4x (0x%.2x)\n", ioport->io2.minimum, | ||
2143 | ioport->io2.address_length); | ||
2144 | } | ||
2145 | else { | ||
2146 | printk(KERN_ERR DRV_PFX "Unknown SPIC Type, more than 2 IO Ports\n"); | ||
2124 | return AE_ERROR; | 2147 | return AE_ERROR; |
2125 | 2148 | } | |
2126 | list_add_tail(&ioport->list, &dev->ioports); | ||
2127 | memcpy(&ioport->io, io, sizeof(*io)); | ||
2128 | return AE_OK; | 2149 | return AE_OK; |
2129 | } | 2150 | } |
2130 | default: | 2151 | default: |
@@ -2199,10 +2220,22 @@ static int sony_pic_enable(struct acpi_device *device, | |||
2199 | { | 2220 | { |
2200 | acpi_status status; | 2221 | acpi_status status; |
2201 | int result = 0; | 2222 | int result = 0; |
2223 | /* Type 1 resource layout is: | ||
2224 | * IO | ||
2225 | * IO | ||
2226 | * IRQNoFlags | ||
2227 | * End | ||
2228 | * | ||
2229 | * Type 2 and 3 resource layout is: | ||
2230 | * IO | ||
2231 | * IRQNoFlags | ||
2232 | * End | ||
2233 | */ | ||
2202 | struct { | 2234 | struct { |
2203 | struct acpi_resource io_res; | 2235 | struct acpi_resource res1; |
2204 | struct acpi_resource irq_res; | 2236 | struct acpi_resource res2; |
2205 | struct acpi_resource end; | 2237 | struct acpi_resource res3; |
2238 | struct acpi_resource res4; | ||
2206 | } *resource; | 2239 | } *resource; |
2207 | struct acpi_buffer buffer = { 0, NULL }; | 2240 | struct acpi_buffer buffer = { 0, NULL }; |
2208 | 2241 | ||
@@ -2217,21 +2250,49 @@ static int sony_pic_enable(struct acpi_device *device, | |||
2217 | buffer.length = sizeof(*resource) + 1; | 2250 | buffer.length = sizeof(*resource) + 1; |
2218 | buffer.pointer = resource; | 2251 | buffer.pointer = resource; |
2219 | 2252 | ||
2220 | /* setup io resource */ | 2253 | /* setup Type 1 resources */ |
2221 | resource->io_res.type = ACPI_RESOURCE_TYPE_IO; | 2254 | if (spic_dev.model == SONYPI_DEVICE_TYPE1) { |
2222 | resource->io_res.length = sizeof(struct acpi_resource); | ||
2223 | memcpy(&resource->io_res.data.io, &ioport->io, | ||
2224 | sizeof(struct acpi_resource_io)); | ||
2225 | 2255 | ||
2226 | /* setup irq resource */ | 2256 | /* setup io resources */ |
2227 | resource->irq_res.type = ACPI_RESOURCE_TYPE_IRQ; | 2257 | resource->res1.type = ACPI_RESOURCE_TYPE_IO; |
2228 | resource->irq_res.length = sizeof(struct acpi_resource); | 2258 | resource->res1.length = sizeof(struct acpi_resource); |
2229 | memcpy(&resource->irq_res.data.irq, &irq->irq, | 2259 | memcpy(&resource->res1.data.io, &ioport->io1, |
2230 | sizeof(struct acpi_resource_irq)); | 2260 | sizeof(struct acpi_resource_io)); |
2231 | /* we requested a shared irq */ | ||
2232 | resource->irq_res.data.irq.sharable = ACPI_SHARED; | ||
2233 | 2261 | ||
2234 | resource->end.type = ACPI_RESOURCE_TYPE_END_TAG; | 2262 | resource->res2.type = ACPI_RESOURCE_TYPE_IO; |
2263 | resource->res2.length = sizeof(struct acpi_resource); | ||
2264 | memcpy(&resource->res2.data.io, &ioport->io2, | ||
2265 | sizeof(struct acpi_resource_io)); | ||
2266 | |||
2267 | /* setup irq resource */ | ||
2268 | resource->res3.type = ACPI_RESOURCE_TYPE_IRQ; | ||
2269 | resource->res3.length = sizeof(struct acpi_resource); | ||
2270 | memcpy(&resource->res3.data.irq, &irq->irq, | ||
2271 | sizeof(struct acpi_resource_irq)); | ||
2272 | /* we requested a shared irq */ | ||
2273 | resource->res3.data.irq.sharable = ACPI_SHARED; | ||
2274 | |||
2275 | resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; | ||
2276 | |||
2277 | } | ||
2278 | /* setup Type 2/3 resources */ | ||
2279 | else { | ||
2280 | /* setup io resource */ | ||
2281 | resource->res1.type = ACPI_RESOURCE_TYPE_IO; | ||
2282 | resource->res1.length = sizeof(struct acpi_resource); | ||
2283 | memcpy(&resource->res1.data.io, &ioport->io1, | ||
2284 | sizeof(struct acpi_resource_io)); | ||
2285 | |||
2286 | /* setup irq resource */ | ||
2287 | resource->res2.type = ACPI_RESOURCE_TYPE_IRQ; | ||
2288 | resource->res2.length = sizeof(struct acpi_resource); | ||
2289 | memcpy(&resource->res2.data.irq, &irq->irq, | ||
2290 | sizeof(struct acpi_resource_irq)); | ||
2291 | /* we requested a shared irq */ | ||
2292 | resource->res2.data.irq.sharable = ACPI_SHARED; | ||
2293 | |||
2294 | resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; | ||
2295 | } | ||
2235 | 2296 | ||
2236 | /* Attempt to set the resource */ | 2297 | /* Attempt to set the resource */ |
2237 | dprintk("Evaluating _SRS\n"); | 2298 | dprintk("Evaluating _SRS\n"); |
@@ -2239,7 +2300,7 @@ static int sony_pic_enable(struct acpi_device *device, | |||
2239 | 2300 | ||
2240 | /* check for total failure */ | 2301 | /* check for total failure */ |
2241 | if (ACPI_FAILURE(status)) { | 2302 | if (ACPI_FAILURE(status)) { |
2242 | printk(KERN_ERR DRV_PFX "Error evaluating _SRS"); | 2303 | printk(KERN_ERR DRV_PFX "Error evaluating _SRS\n"); |
2243 | result = -ENODEV; | 2304 | result = -ENODEV; |
2244 | goto end; | 2305 | goto end; |
2245 | } | 2306 | } |
@@ -2268,11 +2329,14 @@ static irqreturn_t sony_pic_irq(int irq, void *dev_id) | |||
2268 | 2329 | ||
2269 | struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id; | 2330 | struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id; |
2270 | 2331 | ||
2271 | ev = inb_p(dev->cur_ioport->io.minimum); | 2332 | ev = inb_p(dev->cur_ioport->io1.minimum); |
2272 | data_mask = inb_p(dev->cur_ioport->io.minimum + dev->evport_offset); | 2333 | if (dev->cur_ioport->io2.minimum) |
2334 | data_mask = inb_p(dev->cur_ioport->io2.minimum); | ||
2335 | else | ||
2336 | data_mask = inb_p(dev->cur_ioport->io1.minimum + dev->evport_offset); | ||
2273 | 2337 | ||
2274 | dprintk("event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n", | 2338 | dprintk("event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n", |
2275 | ev, data_mask, dev->cur_ioport->io.minimum, dev->evport_offset); | 2339 | ev, data_mask, dev->cur_ioport->io1.minimum, dev->evport_offset); |
2276 | 2340 | ||
2277 | if (ev == 0x00 || ev == 0xff) | 2341 | if (ev == 0x00 || ev == 0xff) |
2278 | return IRQ_HANDLED; | 2342 | return IRQ_HANDLED; |
@@ -2323,8 +2387,11 @@ static int sony_pic_remove(struct acpi_device *device, int type) | |||
2323 | } | 2387 | } |
2324 | 2388 | ||
2325 | free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); | 2389 | free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); |
2326 | release_region(spic_dev.cur_ioport->io.minimum, | 2390 | release_region(spic_dev.cur_ioport->io1.minimum, |
2327 | spic_dev.cur_ioport->io.address_length); | 2391 | spic_dev.cur_ioport->io1.address_length); |
2392 | if (spic_dev.cur_ioport->io2.minimum) | ||
2393 | release_region(spic_dev.cur_ioport->io2.minimum, | ||
2394 | spic_dev.cur_ioport->io2.address_length); | ||
2328 | 2395 | ||
2329 | sonypi_compat_exit(); | 2396 | sonypi_compat_exit(); |
2330 | 2397 | ||
@@ -2397,14 +2464,36 @@ static int sony_pic_add(struct acpi_device *device) | |||
2397 | goto err_remove_input; | 2464 | goto err_remove_input; |
2398 | 2465 | ||
2399 | /* request io port */ | 2466 | /* request io port */ |
2400 | list_for_each_entry(io, &spic_dev.ioports, list) { | 2467 | list_for_each_entry_reverse(io, &spic_dev.ioports, list) { |
2401 | if (request_region(io->io.minimum, io->io.address_length, | 2468 | if (request_region(io->io1.minimum, io->io1.address_length, |
2402 | "Sony Programable I/O Device")) { | 2469 | "Sony Programable I/O Device")) { |
2403 | dprintk("I/O port: 0x%.4x (0x%.4x) + 0x%.2x\n", | 2470 | dprintk("I/O port1: 0x%.4x (0x%.4x) + 0x%.2x\n", |
2404 | io->io.minimum, io->io.maximum, | 2471 | io->io1.minimum, io->io1.maximum, |
2405 | io->io.address_length); | 2472 | io->io1.address_length); |
2406 | spic_dev.cur_ioport = io; | 2473 | /* Type 1 have 2 ioports */ |
2407 | break; | 2474 | if (io->io2.minimum) { |
2475 | if (request_region(io->io2.minimum, | ||
2476 | io->io2.address_length, | ||
2477 | "Sony Programable I/O Device")) { | ||
2478 | dprintk("I/O port2: 0x%.4x (0x%.4x) + 0x%.2x\n", | ||
2479 | io->io2.minimum, io->io2.maximum, | ||
2480 | io->io2.address_length); | ||
2481 | spic_dev.cur_ioport = io; | ||
2482 | break; | ||
2483 | } | ||
2484 | else { | ||
2485 | dprintk("Unable to get I/O port2: " | ||
2486 | "0x%.4x (0x%.4x) + 0x%.2x\n", | ||
2487 | io->io2.minimum, io->io2.maximum, | ||
2488 | io->io2.address_length); | ||
2489 | release_region(io->io1.minimum, | ||
2490 | io->io1.address_length); | ||
2491 | } | ||
2492 | } | ||
2493 | else { | ||
2494 | spic_dev.cur_ioport = io; | ||
2495 | break; | ||
2496 | } | ||
2408 | } | 2497 | } |
2409 | } | 2498 | } |
2410 | if (!spic_dev.cur_ioport) { | 2499 | if (!spic_dev.cur_ioport) { |
@@ -2414,7 +2503,7 @@ static int sony_pic_add(struct acpi_device *device) | |||
2414 | } | 2503 | } |
2415 | 2504 | ||
2416 | /* request IRQ */ | 2505 | /* request IRQ */ |
2417 | list_for_each_entry(irq, &spic_dev.interrupts, list) { | 2506 | list_for_each_entry_reverse(irq, &spic_dev.interrupts, list) { |
2418 | if (!request_irq(irq->irq.interrupts[0], sony_pic_irq, | 2507 | if (!request_irq(irq->irq.interrupts[0], sony_pic_irq, |
2419 | IRQF_SHARED, "sony-laptop", &spic_dev)) { | 2508 | IRQF_SHARED, "sony-laptop", &spic_dev)) { |
2420 | dprintk("IRQ: %d - triggering: %d - " | 2509 | dprintk("IRQ: %d - triggering: %d - " |
@@ -2462,8 +2551,11 @@ err_free_irq: | |||
2462 | free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); | 2551 | free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); |
2463 | 2552 | ||
2464 | err_release_region: | 2553 | err_release_region: |
2465 | release_region(spic_dev.cur_ioport->io.minimum, | 2554 | release_region(spic_dev.cur_ioport->io1.minimum, |
2466 | spic_dev.cur_ioport->io.address_length); | 2555 | spic_dev.cur_ioport->io1.address_length); |
2556 | if (spic_dev.cur_ioport->io2.minimum) | ||
2557 | release_region(spic_dev.cur_ioport->io2.minimum, | ||
2558 | spic_dev.cur_ioport->io2.address_length); | ||
2467 | 2559 | ||
2468 | err_remove_compat: | 2560 | err_remove_compat: |
2469 | sonypi_compat_exit(); | 2561 | sonypi_compat_exit(); |
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 81e068fa7ac5..e953276664a0 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -22,7 +22,7 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define IBM_VERSION "0.16" | 24 | #define IBM_VERSION "0.16" |
25 | #define TPACPI_SYSFS_VERSION 0x010000 | 25 | #define TPACPI_SYSFS_VERSION 0x020000 |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * Changelog: | 28 | * Changelog: |
@@ -117,6 +117,12 @@ IBM_BIOS_MODULE_ALIAS("K[U,X-Z]"); | |||
117 | 117 | ||
118 | #define __unused __attribute__ ((unused)) | 118 | #define __unused __attribute__ ((unused)) |
119 | 119 | ||
120 | static enum { | ||
121 | TPACPI_LIFE_INIT = 0, | ||
122 | TPACPI_LIFE_RUNNING, | ||
123 | TPACPI_LIFE_EXITING, | ||
124 | } tpacpi_lifecycle; | ||
125 | |||
120 | /**************************************************************************** | 126 | /**************************************************************************** |
121 | **************************************************************************** | 127 | **************************************************************************** |
122 | * | 128 | * |
@@ -342,6 +348,9 @@ static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data) | |||
342 | { | 348 | { |
343 | struct ibm_struct *ibm = data; | 349 | struct ibm_struct *ibm = data; |
344 | 350 | ||
351 | if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING) | ||
352 | return; | ||
353 | |||
345 | if (!ibm || !ibm->acpi || !ibm->acpi->notify) | 354 | if (!ibm || !ibm->acpi || !ibm->acpi->notify) |
346 | return; | 355 | return; |
347 | 356 | ||
@@ -517,8 +526,10 @@ static char *next_cmd(char **cmds) | |||
517 | ****************************************************************************/ | 526 | ****************************************************************************/ |
518 | 527 | ||
519 | static struct platform_device *tpacpi_pdev; | 528 | static struct platform_device *tpacpi_pdev; |
529 | static struct platform_device *tpacpi_sensors_pdev; | ||
520 | static struct device *tpacpi_hwmon; | 530 | static struct device *tpacpi_hwmon; |
521 | static struct input_dev *tpacpi_inputdev; | 531 | static struct input_dev *tpacpi_inputdev; |
532 | static struct mutex tpacpi_inputdev_send_mutex; | ||
522 | 533 | ||
523 | 534 | ||
524 | static int tpacpi_resume_handler(struct platform_device *pdev) | 535 | static int tpacpi_resume_handler(struct platform_device *pdev) |
@@ -543,6 +554,12 @@ static struct platform_driver tpacpi_pdriver = { | |||
543 | .resume = tpacpi_resume_handler, | 554 | .resume = tpacpi_resume_handler, |
544 | }; | 555 | }; |
545 | 556 | ||
557 | static struct platform_driver tpacpi_hwmon_pdriver = { | ||
558 | .driver = { | ||
559 | .name = IBM_HWMON_DRVR_NAME, | ||
560 | .owner = THIS_MODULE, | ||
561 | }, | ||
562 | }; | ||
546 | 563 | ||
547 | /************************************************************************* | 564 | /************************************************************************* |
548 | * thinkpad-acpi driver attributes | 565 | * thinkpad-acpi driver attributes |
@@ -692,6 +709,8 @@ static int parse_strtoul(const char *buf, | |||
692 | { | 709 | { |
693 | char *endp; | 710 | char *endp; |
694 | 711 | ||
712 | while (*buf && isspace(*buf)) | ||
713 | buf++; | ||
695 | *value = simple_strtoul(buf, &endp, 0); | 714 | *value = simple_strtoul(buf, &endp, 0); |
696 | while (*endp && isspace(*endp)) | 715 | while (*endp && isspace(*endp)) |
697 | endp++; | 716 | endp++; |
@@ -989,6 +1008,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
989 | 1008 | ||
990 | int res, i; | 1009 | int res, i; |
991 | int status; | 1010 | int status; |
1011 | int hkeyv; | ||
992 | 1012 | ||
993 | vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n"); | 1013 | vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n"); |
994 | 1014 | ||
@@ -1014,18 +1034,35 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
1014 | return res; | 1034 | return res; |
1015 | 1035 | ||
1016 | /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, | 1036 | /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, |
1017 | A30, R30, R31, T20-22, X20-21, X22-24 */ | 1037 | A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking |
1018 | tp_features.hotkey_mask = | 1038 | for HKEY interface version 0x100 */ |
1019 | acpi_evalf(hkey_handle, NULL, "DHKN", "qv"); | 1039 | if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) { |
1040 | if ((hkeyv >> 8) != 1) { | ||
1041 | printk(IBM_ERR "unknown version of the " | ||
1042 | "HKEY interface: 0x%x\n", hkeyv); | ||
1043 | printk(IBM_ERR "please report this to %s\n", | ||
1044 | IBM_MAIL); | ||
1045 | } else { | ||
1046 | /* | ||
1047 | * MHKV 0x100 in A31, R40, R40e, | ||
1048 | * T4x, X31, and later | ||
1049 | * */ | ||
1050 | tp_features.hotkey_mask = 1; | ||
1051 | } | ||
1052 | } | ||
1020 | 1053 | ||
1021 | vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n", | 1054 | vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n", |
1022 | str_supported(tp_features.hotkey_mask)); | 1055 | str_supported(tp_features.hotkey_mask)); |
1023 | 1056 | ||
1024 | if (tp_features.hotkey_mask) { | 1057 | if (tp_features.hotkey_mask) { |
1025 | /* MHKA available in A31, R40, R40e, T4x, X31, and later */ | ||
1026 | if (!acpi_evalf(hkey_handle, &hotkey_all_mask, | 1058 | if (!acpi_evalf(hkey_handle, &hotkey_all_mask, |
1027 | "MHKA", "qd")) | 1059 | "MHKA", "qd")) { |
1060 | printk(IBM_ERR | ||
1061 | "missing MHKA handler, " | ||
1062 | "please report this to %s\n", | ||
1063 | IBM_MAIL); | ||
1028 | hotkey_all_mask = 0x080cU; /* FN+F12, FN+F4, FN+F3 */ | 1064 | hotkey_all_mask = 0x080cU; /* FN+F12, FN+F4, FN+F3 */ |
1065 | } | ||
1029 | } | 1066 | } |
1030 | 1067 | ||
1031 | res = hotkey_get(&hotkey_orig_status, &hotkey_orig_mask); | 1068 | res = hotkey_get(&hotkey_orig_status, &hotkey_orig_mask); |
@@ -1131,6 +1168,8 @@ static void tpacpi_input_send_key(unsigned int scancode, | |||
1131 | unsigned int keycode) | 1168 | unsigned int keycode) |
1132 | { | 1169 | { |
1133 | if (keycode != KEY_RESERVED) { | 1170 | if (keycode != KEY_RESERVED) { |
1171 | mutex_lock(&tpacpi_inputdev_send_mutex); | ||
1172 | |||
1134 | input_report_key(tpacpi_inputdev, keycode, 1); | 1173 | input_report_key(tpacpi_inputdev, keycode, 1); |
1135 | if (keycode == KEY_UNKNOWN) | 1174 | if (keycode == KEY_UNKNOWN) |
1136 | input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN, | 1175 | input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN, |
@@ -1142,6 +1181,8 @@ static void tpacpi_input_send_key(unsigned int scancode, | |||
1142 | input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN, | 1181 | input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN, |
1143 | scancode); | 1182 | scancode); |
1144 | input_sync(tpacpi_inputdev); | 1183 | input_sync(tpacpi_inputdev); |
1184 | |||
1185 | mutex_unlock(&tpacpi_inputdev_send_mutex); | ||
1145 | } | 1186 | } |
1146 | } | 1187 | } |
1147 | 1188 | ||
@@ -1149,18 +1190,47 @@ static void tpacpi_input_send_radiosw(void) | |||
1149 | { | 1190 | { |
1150 | int wlsw; | 1191 | int wlsw; |
1151 | 1192 | ||
1152 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) | 1193 | mutex_lock(&tpacpi_inputdev_send_mutex); |
1194 | |||
1195 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) { | ||
1153 | input_report_switch(tpacpi_inputdev, | 1196 | input_report_switch(tpacpi_inputdev, |
1154 | SW_RADIO, !!wlsw); | 1197 | SW_RADIO, !!wlsw); |
1198 | input_sync(tpacpi_inputdev); | ||
1199 | } | ||
1200 | |||
1201 | mutex_unlock(&tpacpi_inputdev_send_mutex); | ||
1155 | } | 1202 | } |
1156 | 1203 | ||
1157 | static void hotkey_notify(struct ibm_struct *ibm, u32 event) | 1204 | static void hotkey_notify(struct ibm_struct *ibm, u32 event) |
1158 | { | 1205 | { |
1159 | u32 hkey; | 1206 | u32 hkey; |
1160 | unsigned int keycode, scancode; | 1207 | unsigned int keycode, scancode; |
1161 | int send_acpi_ev = 0; | 1208 | int send_acpi_ev; |
1209 | int ignore_acpi_ev; | ||
1210 | |||
1211 | if (event != 0x80) { | ||
1212 | printk(IBM_ERR "unknown HKEY notification event %d\n", event); | ||
1213 | /* forward it to userspace, maybe it knows how to handle it */ | ||
1214 | acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, | ||
1215 | ibm->acpi->device->dev.bus_id, | ||
1216 | event, 0); | ||
1217 | return; | ||
1218 | } | ||
1219 | |||
1220 | while (1) { | ||
1221 | if (!acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) { | ||
1222 | printk(IBM_ERR "failed to retrieve HKEY event\n"); | ||
1223 | return; | ||
1224 | } | ||
1225 | |||
1226 | if (hkey == 0) { | ||
1227 | /* queue empty */ | ||
1228 | return; | ||
1229 | } | ||
1230 | |||
1231 | send_acpi_ev = 0; | ||
1232 | ignore_acpi_ev = 0; | ||
1162 | 1233 | ||
1163 | if (event == 0x80 && acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) { | ||
1164 | switch (hkey >> 12) { | 1234 | switch (hkey >> 12) { |
1165 | case 1: | 1235 | case 1: |
1166 | /* 0x1000-0x1FFF: key presses */ | 1236 | /* 0x1000-0x1FFF: key presses */ |
@@ -1182,9 +1252,11 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
1182 | * eat up known LID events */ | 1252 | * eat up known LID events */ |
1183 | if (hkey != 0x5001 && hkey != 0x5002) { | 1253 | if (hkey != 0x5001 && hkey != 0x5002) { |
1184 | printk(IBM_ERR | 1254 | printk(IBM_ERR |
1185 | "unknown LID-related hotkey event: 0x%04x\n", | 1255 | "unknown LID-related HKEY event: 0x%04x\n", |
1186 | hkey); | 1256 | hkey); |
1187 | send_acpi_ev = 1; | 1257 | send_acpi_ev = 1; |
1258 | } else { | ||
1259 | ignore_acpi_ev = 1; | ||
1188 | } | 1260 | } |
1189 | break; | 1261 | break; |
1190 | case 7: | 1262 | case 7: |
@@ -1202,21 +1274,18 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
1202 | printk(IBM_NOTICE "unhandled HKEY event 0x%04x\n", hkey); | 1274 | printk(IBM_NOTICE "unhandled HKEY event 0x%04x\n", hkey); |
1203 | send_acpi_ev = 1; | 1275 | send_acpi_ev = 1; |
1204 | } | 1276 | } |
1205 | } else { | ||
1206 | printk(IBM_ERR "unknown hotkey notification event %d\n", event); | ||
1207 | hkey = 0; | ||
1208 | send_acpi_ev = 1; | ||
1209 | } | ||
1210 | 1277 | ||
1211 | /* Legacy events */ | 1278 | /* Legacy events */ |
1212 | if (send_acpi_ev || hotkey_report_mode < 2) | 1279 | if (!ignore_acpi_ev && (send_acpi_ev || hotkey_report_mode < 2)) { |
1213 | acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey); | 1280 | acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey); |
1281 | } | ||
1214 | 1282 | ||
1215 | /* netlink events */ | 1283 | /* netlink events */ |
1216 | if (send_acpi_ev) { | 1284 | if (!ignore_acpi_ev && send_acpi_ev) { |
1217 | acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, | 1285 | acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, |
1218 | ibm->acpi->device->dev.bus_id, | 1286 | ibm->acpi->device->dev.bus_id, |
1219 | event, hkey); | 1287 | event, hkey); |
1288 | } | ||
1220 | } | 1289 | } |
1221 | } | 1290 | } |
1222 | 1291 | ||
@@ -2812,7 +2881,7 @@ static int __init thermal_init(struct ibm_init_struct *iibm) | |||
2812 | 2881 | ||
2813 | switch(thermal_read_mode) { | 2882 | switch(thermal_read_mode) { |
2814 | case TPACPI_THERMAL_TPEC_16: | 2883 | case TPACPI_THERMAL_TPEC_16: |
2815 | res = sysfs_create_group(&tpacpi_pdev->dev.kobj, | 2884 | res = sysfs_create_group(&tpacpi_sensors_pdev->dev.kobj, |
2816 | &thermal_temp_input16_group); | 2885 | &thermal_temp_input16_group); |
2817 | if (res) | 2886 | if (res) |
2818 | return res; | 2887 | return res; |
@@ -2820,7 +2889,7 @@ static int __init thermal_init(struct ibm_init_struct *iibm) | |||
2820 | case TPACPI_THERMAL_TPEC_8: | 2889 | case TPACPI_THERMAL_TPEC_8: |
2821 | case TPACPI_THERMAL_ACPI_TMP07: | 2890 | case TPACPI_THERMAL_ACPI_TMP07: |
2822 | case TPACPI_THERMAL_ACPI_UPDT: | 2891 | case TPACPI_THERMAL_ACPI_UPDT: |
2823 | res = sysfs_create_group(&tpacpi_pdev->dev.kobj, | 2892 | res = sysfs_create_group(&tpacpi_sensors_pdev->dev.kobj, |
2824 | &thermal_temp_input8_group); | 2893 | &thermal_temp_input8_group); |
2825 | if (res) | 2894 | if (res) |
2826 | return res; | 2895 | return res; |
@@ -2837,13 +2906,13 @@ static void thermal_exit(void) | |||
2837 | { | 2906 | { |
2838 | switch(thermal_read_mode) { | 2907 | switch(thermal_read_mode) { |
2839 | case TPACPI_THERMAL_TPEC_16: | 2908 | case TPACPI_THERMAL_TPEC_16: |
2840 | sysfs_remove_group(&tpacpi_pdev->dev.kobj, | 2909 | sysfs_remove_group(&tpacpi_sensors_pdev->dev.kobj, |
2841 | &thermal_temp_input16_group); | 2910 | &thermal_temp_input16_group); |
2842 | break; | 2911 | break; |
2843 | case TPACPI_THERMAL_TPEC_8: | 2912 | case TPACPI_THERMAL_TPEC_8: |
2844 | case TPACPI_THERMAL_ACPI_TMP07: | 2913 | case TPACPI_THERMAL_ACPI_TMP07: |
2845 | case TPACPI_THERMAL_ACPI_UPDT: | 2914 | case TPACPI_THERMAL_ACPI_UPDT: |
2846 | sysfs_remove_group(&tpacpi_pdev->dev.kobj, | 2915 | sysfs_remove_group(&tpacpi_sensors_pdev->dev.kobj, |
2847 | &thermal_temp_input16_group); | 2916 | &thermal_temp_input16_group); |
2848 | break; | 2917 | break; |
2849 | case TPACPI_THERMAL_NONE: | 2918 | case TPACPI_THERMAL_NONE: |
@@ -3626,7 +3695,7 @@ static struct device_attribute dev_attr_fan_fan1_input = | |||
3626 | __ATTR(fan1_input, S_IRUGO, | 3695 | __ATTR(fan1_input, S_IRUGO, |
3627 | fan_fan1_input_show, NULL); | 3696 | fan_fan1_input_show, NULL); |
3628 | 3697 | ||
3629 | /* sysfs fan fan_watchdog (driver) ------------------------------------- */ | 3698 | /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */ |
3630 | static ssize_t fan_fan_watchdog_show(struct device_driver *drv, | 3699 | static ssize_t fan_fan_watchdog_show(struct device_driver *drv, |
3631 | char *buf) | 3700 | char *buf) |
3632 | { | 3701 | { |
@@ -3768,10 +3837,10 @@ static int __init fan_init(struct ibm_init_struct *iibm) | |||
3768 | 3837 | ||
3769 | if (fan_status_access_mode != TPACPI_FAN_NONE || | 3838 | if (fan_status_access_mode != TPACPI_FAN_NONE || |
3770 | fan_control_access_mode != TPACPI_FAN_WR_NONE) { | 3839 | fan_control_access_mode != TPACPI_FAN_WR_NONE) { |
3771 | rc = sysfs_create_group(&tpacpi_pdev->dev.kobj, | 3840 | rc = sysfs_create_group(&tpacpi_sensors_pdev->dev.kobj, |
3772 | &fan_attr_group); | 3841 | &fan_attr_group); |
3773 | if (!(rc < 0)) | 3842 | if (!(rc < 0)) |
3774 | rc = driver_create_file(&tpacpi_pdriver.driver, | 3843 | rc = driver_create_file(&tpacpi_hwmon_pdriver.driver, |
3775 | &driver_attr_fan_watchdog); | 3844 | &driver_attr_fan_watchdog); |
3776 | if (rc < 0) | 3845 | if (rc < 0) |
3777 | return rc; | 3846 | return rc; |
@@ -3854,8 +3923,8 @@ static void fan_exit(void) | |||
3854 | vdbg_printk(TPACPI_DBG_EXIT, "cancelling any pending fan watchdog tasks\n"); | 3923 | vdbg_printk(TPACPI_DBG_EXIT, "cancelling any pending fan watchdog tasks\n"); |
3855 | 3924 | ||
3856 | /* FIXME: can we really do this unconditionally? */ | 3925 | /* FIXME: can we really do this unconditionally? */ |
3857 | sysfs_remove_group(&tpacpi_pdev->dev.kobj, &fan_attr_group); | 3926 | sysfs_remove_group(&tpacpi_sensors_pdev->dev.kobj, &fan_attr_group); |
3858 | driver_remove_file(&tpacpi_pdriver.driver, &driver_attr_fan_watchdog); | 3927 | driver_remove_file(&tpacpi_hwmon_pdriver.driver, &driver_attr_fan_watchdog); |
3859 | 3928 | ||
3860 | cancel_delayed_work(&fan_watchdog_task); | 3929 | cancel_delayed_work(&fan_watchdog_task); |
3861 | flush_scheduled_work(); | 3930 | flush_scheduled_work(); |
@@ -3888,6 +3957,9 @@ static void fan_watchdog_fire(struct work_struct *ignored) | |||
3888 | { | 3957 | { |
3889 | int rc; | 3958 | int rc; |
3890 | 3959 | ||
3960 | if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING) | ||
3961 | return; | ||
3962 | |||
3891 | printk(IBM_NOTICE "fan watchdog: enabling fan\n"); | 3963 | printk(IBM_NOTICE "fan watchdog: enabling fan\n"); |
3892 | rc = fan_set_enable(); | 3964 | rc = fan_set_enable(); |
3893 | if (rc < 0) { | 3965 | if (rc < 0) { |
@@ -3908,7 +3980,8 @@ static void fan_watchdog_reset(void) | |||
3908 | if (fan_watchdog_active) | 3980 | if (fan_watchdog_active) |
3909 | cancel_delayed_work(&fan_watchdog_task); | 3981 | cancel_delayed_work(&fan_watchdog_task); |
3910 | 3982 | ||
3911 | if (fan_watchdog_maxinterval > 0) { | 3983 | if (fan_watchdog_maxinterval > 0 && |
3984 | tpacpi_lifecycle != TPACPI_LIFE_EXITING) { | ||
3912 | fan_watchdog_active = 1; | 3985 | fan_watchdog_active = 1; |
3913 | if (!schedule_delayed_work(&fan_watchdog_task, | 3986 | if (!schedule_delayed_work(&fan_watchdog_task, |
3914 | msecs_to_jiffies(fan_watchdog_maxinterval | 3987 | msecs_to_jiffies(fan_watchdog_maxinterval |
@@ -4302,6 +4375,19 @@ static struct ibm_struct fan_driver_data = { | |||
4302 | **************************************************************************** | 4375 | **************************************************************************** |
4303 | ****************************************************************************/ | 4376 | ****************************************************************************/ |
4304 | 4377 | ||
4378 | /* sysfs name ---------------------------------------------------------- */ | ||
4379 | static ssize_t thinkpad_acpi_pdev_name_show(struct device *dev, | ||
4380 | struct device_attribute *attr, | ||
4381 | char *buf) | ||
4382 | { | ||
4383 | return snprintf(buf, PAGE_SIZE, "%s\n", IBM_NAME); | ||
4384 | } | ||
4385 | |||
4386 | static struct device_attribute dev_attr_thinkpad_acpi_pdev_name = | ||
4387 | __ATTR(name, S_IRUGO, thinkpad_acpi_pdev_name_show, NULL); | ||
4388 | |||
4389 | /* --------------------------------------------------------------------- */ | ||
4390 | |||
4305 | /* /proc support */ | 4391 | /* /proc support */ |
4306 | static struct proc_dir_entry *proc_dir; | 4392 | static struct proc_dir_entry *proc_dir; |
4307 | 4393 | ||
@@ -4674,6 +4760,8 @@ static int __init thinkpad_acpi_module_init(void) | |||
4674 | { | 4760 | { |
4675 | int ret, i; | 4761 | int ret, i; |
4676 | 4762 | ||
4763 | tpacpi_lifecycle = TPACPI_LIFE_INIT; | ||
4764 | |||
4677 | /* Parameter checking */ | 4765 | /* Parameter checking */ |
4678 | if (hotkey_report_mode > 2) | 4766 | if (hotkey_report_mode > 2) |
4679 | return -EINVAL; | 4767 | return -EINVAL; |
@@ -4702,19 +4790,31 @@ static int __init thinkpad_acpi_module_init(void) | |||
4702 | 4790 | ||
4703 | ret = platform_driver_register(&tpacpi_pdriver); | 4791 | ret = platform_driver_register(&tpacpi_pdriver); |
4704 | if (ret) { | 4792 | if (ret) { |
4705 | printk(IBM_ERR "unable to register platform driver\n"); | 4793 | printk(IBM_ERR "unable to register main platform driver\n"); |
4706 | thinkpad_acpi_module_exit(); | 4794 | thinkpad_acpi_module_exit(); |
4707 | return ret; | 4795 | return ret; |
4708 | } | 4796 | } |
4709 | tp_features.platform_drv_registered = 1; | 4797 | tp_features.platform_drv_registered = 1; |
4710 | 4798 | ||
4799 | ret = platform_driver_register(&tpacpi_hwmon_pdriver); | ||
4800 | if (ret) { | ||
4801 | printk(IBM_ERR "unable to register hwmon platform driver\n"); | ||
4802 | thinkpad_acpi_module_exit(); | ||
4803 | return ret; | ||
4804 | } | ||
4805 | tp_features.sensors_pdrv_registered = 1; | ||
4806 | |||
4711 | ret = tpacpi_create_driver_attributes(&tpacpi_pdriver.driver); | 4807 | ret = tpacpi_create_driver_attributes(&tpacpi_pdriver.driver); |
4808 | if (!ret) { | ||
4809 | tp_features.platform_drv_attrs_registered = 1; | ||
4810 | ret = tpacpi_create_driver_attributes(&tpacpi_hwmon_pdriver.driver); | ||
4811 | } | ||
4712 | if (ret) { | 4812 | if (ret) { |
4713 | printk(IBM_ERR "unable to create sysfs driver attributes\n"); | 4813 | printk(IBM_ERR "unable to create sysfs driver attributes\n"); |
4714 | thinkpad_acpi_module_exit(); | 4814 | thinkpad_acpi_module_exit(); |
4715 | return ret; | 4815 | return ret; |
4716 | } | 4816 | } |
4717 | tp_features.platform_drv_attrs_registered = 1; | 4817 | tp_features.sensors_pdrv_attrs_registered = 1; |
4718 | 4818 | ||
4719 | 4819 | ||
4720 | /* Device initialization */ | 4820 | /* Device initialization */ |
@@ -4727,7 +4827,26 @@ static int __init thinkpad_acpi_module_init(void) | |||
4727 | thinkpad_acpi_module_exit(); | 4827 | thinkpad_acpi_module_exit(); |
4728 | return ret; | 4828 | return ret; |
4729 | } | 4829 | } |
4730 | tpacpi_hwmon = hwmon_device_register(&tpacpi_pdev->dev); | 4830 | tpacpi_sensors_pdev = platform_device_register_simple( |
4831 | IBM_HWMON_DRVR_NAME, | ||
4832 | -1, NULL, 0); | ||
4833 | if (IS_ERR(tpacpi_sensors_pdev)) { | ||
4834 | ret = PTR_ERR(tpacpi_sensors_pdev); | ||
4835 | tpacpi_sensors_pdev = NULL; | ||
4836 | printk(IBM_ERR "unable to register hwmon platform device\n"); | ||
4837 | thinkpad_acpi_module_exit(); | ||
4838 | return ret; | ||
4839 | } | ||
4840 | ret = device_create_file(&tpacpi_sensors_pdev->dev, | ||
4841 | &dev_attr_thinkpad_acpi_pdev_name); | ||
4842 | if (ret) { | ||
4843 | printk(IBM_ERR | ||
4844 | "unable to create sysfs hwmon device attributes\n"); | ||
4845 | thinkpad_acpi_module_exit(); | ||
4846 | return ret; | ||
4847 | } | ||
4848 | tp_features.sensors_pdev_attrs_registered = 1; | ||
4849 | tpacpi_hwmon = hwmon_device_register(&tpacpi_sensors_pdev->dev); | ||
4731 | if (IS_ERR(tpacpi_hwmon)) { | 4850 | if (IS_ERR(tpacpi_hwmon)) { |
4732 | ret = PTR_ERR(tpacpi_hwmon); | 4851 | ret = PTR_ERR(tpacpi_hwmon); |
4733 | tpacpi_hwmon = NULL; | 4852 | tpacpi_hwmon = NULL; |
@@ -4735,6 +4854,7 @@ static int __init thinkpad_acpi_module_init(void) | |||
4735 | thinkpad_acpi_module_exit(); | 4854 | thinkpad_acpi_module_exit(); |
4736 | return ret; | 4855 | return ret; |
4737 | } | 4856 | } |
4857 | mutex_init(&tpacpi_inputdev_send_mutex); | ||
4738 | tpacpi_inputdev = input_allocate_device(); | 4858 | tpacpi_inputdev = input_allocate_device(); |
4739 | if (!tpacpi_inputdev) { | 4859 | if (!tpacpi_inputdev) { |
4740 | printk(IBM_ERR "unable to allocate input device\n"); | 4860 | printk(IBM_ERR "unable to allocate input device\n"); |
@@ -4769,6 +4889,7 @@ static int __init thinkpad_acpi_module_init(void) | |||
4769 | tp_features.input_device_registered = 1; | 4889 | tp_features.input_device_registered = 1; |
4770 | } | 4890 | } |
4771 | 4891 | ||
4892 | tpacpi_lifecycle = TPACPI_LIFE_RUNNING; | ||
4772 | return 0; | 4893 | return 0; |
4773 | } | 4894 | } |
4774 | 4895 | ||
@@ -4776,6 +4897,8 @@ static void thinkpad_acpi_module_exit(void) | |||
4776 | { | 4897 | { |
4777 | struct ibm_struct *ibm, *itmp; | 4898 | struct ibm_struct *ibm, *itmp; |
4778 | 4899 | ||
4900 | tpacpi_lifecycle = TPACPI_LIFE_EXITING; | ||
4901 | |||
4779 | list_for_each_entry_safe_reverse(ibm, itmp, | 4902 | list_for_each_entry_safe_reverse(ibm, itmp, |
4780 | &tpacpi_all_drivers, | 4903 | &tpacpi_all_drivers, |
4781 | all_drivers) { | 4904 | all_drivers) { |
@@ -4794,12 +4917,22 @@ static void thinkpad_acpi_module_exit(void) | |||
4794 | if (tpacpi_hwmon) | 4917 | if (tpacpi_hwmon) |
4795 | hwmon_device_unregister(tpacpi_hwmon); | 4918 | hwmon_device_unregister(tpacpi_hwmon); |
4796 | 4919 | ||
4920 | if (tp_features.sensors_pdev_attrs_registered) | ||
4921 | device_remove_file(&tpacpi_sensors_pdev->dev, | ||
4922 | &dev_attr_thinkpad_acpi_pdev_name); | ||
4923 | if (tpacpi_sensors_pdev) | ||
4924 | platform_device_unregister(tpacpi_sensors_pdev); | ||
4797 | if (tpacpi_pdev) | 4925 | if (tpacpi_pdev) |
4798 | platform_device_unregister(tpacpi_pdev); | 4926 | platform_device_unregister(tpacpi_pdev); |
4799 | 4927 | ||
4928 | if (tp_features.sensors_pdrv_attrs_registered) | ||
4929 | tpacpi_remove_driver_attributes(&tpacpi_hwmon_pdriver.driver); | ||
4800 | if (tp_features.platform_drv_attrs_registered) | 4930 | if (tp_features.platform_drv_attrs_registered) |
4801 | tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver); | 4931 | tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver); |
4802 | 4932 | ||
4933 | if (tp_features.sensors_pdrv_registered) | ||
4934 | platform_driver_unregister(&tpacpi_hwmon_pdriver); | ||
4935 | |||
4803 | if (tp_features.platform_drv_registered) | 4936 | if (tp_features.platform_drv_registered) |
4804 | platform_driver_unregister(&tpacpi_pdriver); | 4937 | platform_driver_unregister(&tpacpi_pdriver); |
4805 | 4938 | ||
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h index acd5835ec889..3abcc8120634 100644 --- a/drivers/misc/thinkpad_acpi.h +++ b/drivers/misc/thinkpad_acpi.h | |||
@@ -58,13 +58,14 @@ | |||
58 | 58 | ||
59 | #define IBM_NAME "thinkpad" | 59 | #define IBM_NAME "thinkpad" |
60 | #define IBM_DESC "ThinkPad ACPI Extras" | 60 | #define IBM_DESC "ThinkPad ACPI Extras" |
61 | #define IBM_FILE "thinkpad_acpi" | 61 | #define IBM_FILE IBM_NAME "_acpi" |
62 | #define IBM_URL "http://ibm-acpi.sf.net/" | 62 | #define IBM_URL "http://ibm-acpi.sf.net/" |
63 | #define IBM_MAIL "ibm-acpi-devel@lists.sourceforge.net" | 63 | #define IBM_MAIL "ibm-acpi-devel@lists.sourceforge.net" |
64 | 64 | ||
65 | #define IBM_PROC_DIR "ibm" | 65 | #define IBM_PROC_DIR "ibm" |
66 | #define IBM_ACPI_EVENT_PREFIX "ibm" | 66 | #define IBM_ACPI_EVENT_PREFIX "ibm" |
67 | #define IBM_DRVR_NAME IBM_FILE | 67 | #define IBM_DRVR_NAME IBM_FILE |
68 | #define IBM_HWMON_DRVR_NAME IBM_NAME "_hwmon" | ||
68 | 69 | ||
69 | #define IBM_LOG IBM_FILE ": " | 70 | #define IBM_LOG IBM_FILE ": " |
70 | #define IBM_ERR KERN_ERR IBM_LOG | 71 | #define IBM_ERR KERN_ERR IBM_LOG |
@@ -171,6 +172,7 @@ static int parse_strtoul(const char *buf, unsigned long max, | |||
171 | 172 | ||
172 | /* Device model */ | 173 | /* Device model */ |
173 | static struct platform_device *tpacpi_pdev; | 174 | static struct platform_device *tpacpi_pdev; |
175 | static struct platform_device *tpacpi_sensors_pdev; | ||
174 | static struct device *tpacpi_hwmon; | 176 | static struct device *tpacpi_hwmon; |
175 | static struct platform_driver tpacpi_pdriver; | 177 | static struct platform_driver tpacpi_pdriver; |
176 | static struct input_dev *tpacpi_inputdev; | 178 | static struct input_dev *tpacpi_inputdev; |
@@ -233,22 +235,25 @@ struct ibm_init_struct { | |||
233 | 235 | ||
234 | static struct { | 236 | static struct { |
235 | #ifdef CONFIG_THINKPAD_ACPI_BAY | 237 | #ifdef CONFIG_THINKPAD_ACPI_BAY |
236 | u16 bay_status:1; | 238 | u32 bay_status:1; |
237 | u16 bay_eject:1; | 239 | u32 bay_eject:1; |
238 | u16 bay_status2:1; | 240 | u32 bay_status2:1; |
239 | u16 bay_eject2:1; | 241 | u32 bay_eject2:1; |
240 | #endif | 242 | #endif |
241 | u16 bluetooth:1; | 243 | u32 bluetooth:1; |
242 | u16 hotkey:1; | 244 | u32 hotkey:1; |
243 | u16 hotkey_mask:1; | 245 | u32 hotkey_mask:1; |
244 | u16 hotkey_wlsw:1; | 246 | u32 hotkey_wlsw:1; |
245 | u16 light:1; | 247 | u32 light:1; |
246 | u16 light_status:1; | 248 | u32 light_status:1; |
247 | u16 wan:1; | 249 | u32 wan:1; |
248 | u16 fan_ctrl_status_undef:1; | 250 | u32 fan_ctrl_status_undef:1; |
249 | u16 input_device_registered:1; | 251 | u32 input_device_registered:1; |
250 | u16 platform_drv_registered:1; | 252 | u32 platform_drv_registered:1; |
251 | u16 platform_drv_attrs_registered:1; | 253 | u32 platform_drv_attrs_registered:1; |
254 | u32 sensors_pdrv_registered:1; | ||
255 | u32 sensors_pdrv_attrs_registered:1; | ||
256 | u32 sensors_pdev_attrs_registered:1; | ||
252 | } tp_features; | 257 | } tp_features; |
253 | 258 | ||
254 | struct thinkpad_id_data { | 259 | struct thinkpad_id_data { |
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index a4f1bf33164a..6330c8cc72b5 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c | |||
@@ -1309,7 +1309,7 @@ static int ubi_thread(void *u) | |||
1309 | struct ubi_device *ubi = u; | 1309 | struct ubi_device *ubi = u; |
1310 | 1310 | ||
1311 | ubi_msg("background thread \"%s\" started, PID %d", | 1311 | ubi_msg("background thread \"%s\" started, PID %d", |
1312 | ubi->bgt_name, current->pid); | 1312 | ubi->bgt_name, task_pid_nr(current)); |
1313 | 1313 | ||
1314 | set_freezable(); | 1314 | set_freezable(); |
1315 | for (;;) { | 1315 | for (;;) { |
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 96cee4badd28..da767d3d5af5 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/etherdevice.h> | 26 | #include <linux/etherdevice.h> |
27 | #include <linux/skbuff.h> | 27 | #include <linux/skbuff.h> |
28 | #include <linux/dma-mapping.h> | 28 | #include <linux/dma-mapping.h> |
29 | #include <asm/bitops.h> | 29 | #include <linux/bitops.h> |
30 | #include <asm/io.h> | 30 | #include <asm/io.h> |
31 | #include <asm/irq.h> | 31 | #include <asm/irq.h> |
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 7a045a37056e..084f0292ea6e 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -126,7 +126,7 @@ static struct aggregator *__get_active_agg(struct aggregator *aggregator); | |||
126 | 126 | ||
127 | // ================= main 802.3ad protocol functions ================== | 127 | // ================= main 802.3ad protocol functions ================== |
128 | static int ad_lacpdu_send(struct port *port); | 128 | static int ad_lacpdu_send(struct port *port); |
129 | static int ad_marker_send(struct port *port, struct marker *marker); | 129 | static int ad_marker_send(struct port *port, struct bond_marker *marker); |
130 | static void ad_mux_machine(struct port *port); | 130 | static void ad_mux_machine(struct port *port); |
131 | static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port); | 131 | static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port); |
132 | static void ad_tx_machine(struct port *port); | 132 | static void ad_tx_machine(struct port *port); |
@@ -139,8 +139,8 @@ static void ad_initialize_port(struct port *port, int lacp_fast); | |||
139 | static void ad_initialize_lacpdu(struct lacpdu *Lacpdu); | 139 | static void ad_initialize_lacpdu(struct lacpdu *Lacpdu); |
140 | static void ad_enable_collecting_distributing(struct port *port); | 140 | static void ad_enable_collecting_distributing(struct port *port); |
141 | static void ad_disable_collecting_distributing(struct port *port); | 141 | static void ad_disable_collecting_distributing(struct port *port); |
142 | static void ad_marker_info_received(struct marker *marker_info, struct port *port); | 142 | static void ad_marker_info_received(struct bond_marker *marker_info, struct port *port); |
143 | static void ad_marker_response_received(struct marker *marker, struct port *port); | 143 | static void ad_marker_response_received(struct bond_marker *marker, struct port *port); |
144 | 144 | ||
145 | 145 | ||
146 | ///////////////////////////////////////////////////////////////////////////////// | 146 | ///////////////////////////////////////////////////////////////////////////////// |
@@ -889,12 +889,12 @@ static int ad_lacpdu_send(struct port *port) | |||
889 | * Returns: 0 on success | 889 | * Returns: 0 on success |
890 | * < 0 on error | 890 | * < 0 on error |
891 | */ | 891 | */ |
892 | static int ad_marker_send(struct port *port, struct marker *marker) | 892 | static int ad_marker_send(struct port *port, struct bond_marker *marker) |
893 | { | 893 | { |
894 | struct slave *slave = port->slave; | 894 | struct slave *slave = port->slave; |
895 | struct sk_buff *skb; | 895 | struct sk_buff *skb; |
896 | struct marker_header *marker_header; | 896 | struct bond_marker_header *marker_header; |
897 | int length = sizeof(struct marker_header); | 897 | int length = sizeof(struct bond_marker_header); |
898 | struct mac_addr lacpdu_multicast_address = AD_MULTICAST_LACPDU_ADDR; | 898 | struct mac_addr lacpdu_multicast_address = AD_MULTICAST_LACPDU_ADDR; |
899 | 899 | ||
900 | skb = dev_alloc_skb(length + 16); | 900 | skb = dev_alloc_skb(length + 16); |
@@ -909,7 +909,7 @@ static int ad_marker_send(struct port *port, struct marker *marker) | |||
909 | skb->network_header = skb->mac_header + ETH_HLEN; | 909 | skb->network_header = skb->mac_header + ETH_HLEN; |
910 | skb->protocol = PKT_TYPE_LACPDU; | 910 | skb->protocol = PKT_TYPE_LACPDU; |
911 | 911 | ||
912 | marker_header = (struct marker_header *)skb_put(skb, length); | 912 | marker_header = (struct bond_marker_header *)skb_put(skb, length); |
913 | 913 | ||
914 | marker_header->ad_header.destination_address = lacpdu_multicast_address; | 914 | marker_header->ad_header.destination_address = lacpdu_multicast_address; |
915 | /* Note: source addres is set to be the member's PERMANENT address, because we use it | 915 | /* Note: source addres is set to be the member's PERMANENT address, because we use it |
@@ -1709,7 +1709,7 @@ static void ad_disable_collecting_distributing(struct port *port) | |||
1709 | */ | 1709 | */ |
1710 | static void ad_marker_info_send(struct port *port) | 1710 | static void ad_marker_info_send(struct port *port) |
1711 | { | 1711 | { |
1712 | struct marker marker; | 1712 | struct bond_marker marker; |
1713 | u16 index; | 1713 | u16 index; |
1714 | 1714 | ||
1715 | // fill the marker PDU with the appropriate values | 1715 | // fill the marker PDU with the appropriate values |
@@ -1742,13 +1742,14 @@ static void ad_marker_info_send(struct port *port) | |||
1742 | * @port: the port we're looking at | 1742 | * @port: the port we're looking at |
1743 | * | 1743 | * |
1744 | */ | 1744 | */ |
1745 | static void ad_marker_info_received(struct marker *marker_info,struct port *port) | 1745 | static void ad_marker_info_received(struct bond_marker *marker_info, |
1746 | struct port *port) | ||
1746 | { | 1747 | { |
1747 | struct marker marker; | 1748 | struct bond_marker marker; |
1748 | 1749 | ||
1749 | // copy the received marker data to the response marker | 1750 | // copy the received marker data to the response marker |
1750 | //marker = *marker_info; | 1751 | //marker = *marker_info; |
1751 | memcpy(&marker, marker_info, sizeof(struct marker)); | 1752 | memcpy(&marker, marker_info, sizeof(struct bond_marker)); |
1752 | // change the marker subtype to marker response | 1753 | // change the marker subtype to marker response |
1753 | marker.tlv_type=AD_MARKER_RESPONSE_SUBTYPE; | 1754 | marker.tlv_type=AD_MARKER_RESPONSE_SUBTYPE; |
1754 | // send the marker response | 1755 | // send the marker response |
@@ -1767,7 +1768,8 @@ static void ad_marker_info_received(struct marker *marker_info,struct port *port | |||
1767 | * response for marker PDU's, in this stage, but only to respond to marker | 1768 | * response for marker PDU's, in this stage, but only to respond to marker |
1768 | * information. | 1769 | * information. |
1769 | */ | 1770 | */ |
1770 | static void ad_marker_response_received(struct marker *marker, struct port *port) | 1771 | static void ad_marker_response_received(struct bond_marker *marker, |
1772 | struct port *port) | ||
1771 | { | 1773 | { |
1772 | marker=NULL; // just to satisfy the compiler | 1774 | marker=NULL; // just to satisfy the compiler |
1773 | port=NULL; // just to satisfy the compiler | 1775 | port=NULL; // just to satisfy the compiler |
@@ -2164,15 +2166,15 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u | |||
2164 | case AD_TYPE_MARKER: | 2166 | case AD_TYPE_MARKER: |
2165 | // No need to convert fields to Little Endian since we don't use the marker's fields. | 2167 | // No need to convert fields to Little Endian since we don't use the marker's fields. |
2166 | 2168 | ||
2167 | switch (((struct marker *)lacpdu)->tlv_type) { | 2169 | switch (((struct bond_marker *)lacpdu)->tlv_type) { |
2168 | case AD_MARKER_INFORMATION_SUBTYPE: | 2170 | case AD_MARKER_INFORMATION_SUBTYPE: |
2169 | dprintk("Received Marker Information on port %d\n", port->actor_port_number); | 2171 | dprintk("Received Marker Information on port %d\n", port->actor_port_number); |
2170 | ad_marker_info_received((struct marker *)lacpdu, port); | 2172 | ad_marker_info_received((struct bond_marker *)lacpdu, port); |
2171 | break; | 2173 | break; |
2172 | 2174 | ||
2173 | case AD_MARKER_RESPONSE_SUBTYPE: | 2175 | case AD_MARKER_RESPONSE_SUBTYPE: |
2174 | dprintk("Received Marker Response on port %d\n", port->actor_port_number); | 2176 | dprintk("Received Marker Response on port %d\n", port->actor_port_number); |
2175 | ad_marker_response_received((struct marker *)lacpdu, port); | 2177 | ad_marker_response_received((struct bond_marker *)lacpdu, port); |
2176 | break; | 2178 | break; |
2177 | 2179 | ||
2178 | default: | 2180 | default: |
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h index 862952fa6fd9..f16557264944 100644 --- a/drivers/net/bonding/bond_3ad.h +++ b/drivers/net/bonding/bond_3ad.h | |||
@@ -92,7 +92,7 @@ typedef enum { | |||
92 | typedef enum { | 92 | typedef enum { |
93 | AD_MARKER_INFORMATION_SUBTYPE = 1, // marker imformation subtype | 93 | AD_MARKER_INFORMATION_SUBTYPE = 1, // marker imformation subtype |
94 | AD_MARKER_RESPONSE_SUBTYPE // marker response subtype | 94 | AD_MARKER_RESPONSE_SUBTYPE // marker response subtype |
95 | } marker_subtype_t; | 95 | } bond_marker_subtype_t; |
96 | 96 | ||
97 | // timers types(43.4.9 in the 802.3ad standard) | 97 | // timers types(43.4.9 in the 802.3ad standard) |
98 | typedef enum { | 98 | typedef enum { |
@@ -148,7 +148,7 @@ typedef struct lacpdu_header { | |||
148 | } lacpdu_header_t; | 148 | } lacpdu_header_t; |
149 | 149 | ||
150 | // Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) | 150 | // Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) |
151 | typedef struct marker { | 151 | typedef struct bond_marker { |
152 | u8 subtype; // = 0x02 (marker PDU) | 152 | u8 subtype; // = 0x02 (marker PDU) |
153 | u8 version_number; // = 0x01 | 153 | u8 version_number; // = 0x01 |
154 | u8 tlv_type; // = 0x01 (marker information) | 154 | u8 tlv_type; // = 0x01 (marker information) |
@@ -161,12 +161,12 @@ typedef struct marker { | |||
161 | u8 tlv_type_terminator; // = 0x00 | 161 | u8 tlv_type_terminator; // = 0x00 |
162 | u8 terminator_length; // = 0x00 | 162 | u8 terminator_length; // = 0x00 |
163 | u8 reserved_90[90]; // = 0 | 163 | u8 reserved_90[90]; // = 0 |
164 | } marker_t; | 164 | } bond_marker_t; |
165 | 165 | ||
166 | typedef struct marker_header { | 166 | typedef struct bond_marker_header { |
167 | struct ad_header ad_header; | 167 | struct ad_header ad_header; |
168 | struct marker marker; | 168 | struct bond_marker marker; |
169 | } marker_header_t; | 169 | } bond_marker_header_t; |
170 | 170 | ||
171 | #pragma pack() | 171 | #pragma pack() |
172 | 172 | ||
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c index 314b2f68f78f..edd6828f0a78 100644 --- a/drivers/net/cris/eth_v10.c +++ b/drivers/net/cris/eth_v10.c | |||
@@ -234,6 +234,7 @@ | |||
234 | #include <linux/spinlock.h> | 234 | #include <linux/spinlock.h> |
235 | #include <linux/errno.h> | 235 | #include <linux/errno.h> |
236 | #include <linux/init.h> | 236 | #include <linux/init.h> |
237 | #include <linux/bitops.h> | ||
237 | 238 | ||
238 | #include <linux/if.h> | 239 | #include <linux/if.h> |
239 | #include <linux/mii.h> | 240 | #include <linux/mii.h> |
@@ -247,7 +248,6 @@ | |||
247 | #include <asm/irq.h> | 248 | #include <asm/irq.h> |
248 | #include <asm/dma.h> | 249 | #include <asm/dma.h> |
249 | #include <asm/system.h> | 250 | #include <asm/system.h> |
250 | #include <asm/bitops.h> | ||
251 | #include <asm/ethernet.h> | 251 | #include <asm/ethernet.h> |
252 | #include <asm/cache.h> | 252 | #include <asm/cache.h> |
253 | 253 | ||
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h index 044261703381..2a3df145850d 100644 --- a/drivers/net/cxgb3/adapter.h +++ b/drivers/net/cxgb3/adapter.h | |||
@@ -41,9 +41,9 @@ | |||
41 | #include <linux/timer.h> | 41 | #include <linux/timer.h> |
42 | #include <linux/cache.h> | 42 | #include <linux/cache.h> |
43 | #include <linux/mutex.h> | 43 | #include <linux/mutex.h> |
44 | #include <linux/bitops.h> | ||
44 | #include "t3cdev.h" | 45 | #include "t3cdev.h" |
45 | #include <asm/semaphore.h> | 46 | #include <asm/semaphore.h> |
46 | #include <asm/bitops.h> | ||
47 | #include <asm/io.h> | 47 | #include <asm/io.h> |
48 | 48 | ||
49 | typedef irqreturn_t(*intr_handler_t) (int, void *); | 49 | typedef irqreturn_t(*intr_handler_t) (int, void *); |
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c index 243fc6b354b5..e3dd8b136908 100644 --- a/drivers/net/eth16i.c +++ b/drivers/net/eth16i.c | |||
@@ -170,7 +170,6 @@ static char *version = | |||
170 | 170 | ||
171 | 171 | ||
172 | /* Few macros */ | 172 | /* Few macros */ |
173 | #define BIT(a) ( (1 << (a)) ) | ||
174 | #define BITSET(ioaddr, bnum) ((outb(((inb(ioaddr)) | (bnum)), ioaddr))) | 173 | #define BITSET(ioaddr, bnum) ((outb(((inb(ioaddr)) | (bnum)), ioaddr))) |
175 | #define BITCLR(ioaddr, bnum) ((outb(((inb(ioaddr)) & (~(bnum))), ioaddr))) | 174 | #define BITCLR(ioaddr, bnum) ((outb(((inb(ioaddr)) & (~(bnum))), ioaddr))) |
176 | 175 | ||
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c index bc02e4694804..11b83dae00ac 100644 --- a/drivers/net/hamradio/dmascc.c +++ b/drivers/net/hamradio/dmascc.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/bitops.h> | ||
24 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
25 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
26 | #include <linux/if_arp.h> | 27 | #include <linux/if_arp.h> |
@@ -35,7 +36,6 @@ | |||
35 | #include <linux/sockios.h> | 36 | #include <linux/sockios.h> |
36 | #include <linux/workqueue.h> | 37 | #include <linux/workqueue.h> |
37 | #include <asm/atomic.h> | 38 | #include <asm/atomic.h> |
38 | #include <asm/bitops.h> | ||
39 | #include <asm/dma.h> | 39 | #include <asm/dma.h> |
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | #include <asm/irq.h> | 41 | #include <asm/irq.h> |
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c index 30854f094965..a19b5958cee9 100644 --- a/drivers/net/mac89x0.c +++ b/drivers/net/mac89x0.c | |||
@@ -99,9 +99,9 @@ static char *version = | |||
99 | #include <linux/etherdevice.h> | 99 | #include <linux/etherdevice.h> |
100 | #include <linux/skbuff.h> | 100 | #include <linux/skbuff.h> |
101 | #include <linux/delay.h> | 101 | #include <linux/delay.h> |
102 | #include <linux/bitops.h> | ||
102 | 103 | ||
103 | #include <asm/system.h> | 104 | #include <asm/system.h> |
104 | #include <asm/bitops.h> | ||
105 | #include <asm/io.h> | 105 | #include <asm/io.h> |
106 | #include <asm/hwtest.h> | 106 | #include <asm/hwtest.h> |
107 | #include <asm/macints.h> | 107 | #include <asm/macints.h> |
diff --git a/drivers/net/meth.h b/drivers/net/meth.h index ea3b8fc86d1e..a78dc1ca8c29 100644 --- a/drivers/net/meth.h +++ b/drivers/net/meth.h | |||
@@ -28,9 +28,6 @@ | |||
28 | #define RX_BUFFER_OFFSET (sizeof(rx_status_vector)+2) /* staus vector + 2 bytes of padding */ | 28 | #define RX_BUFFER_OFFSET (sizeof(rx_status_vector)+2) /* staus vector + 2 bytes of padding */ |
29 | #define RX_BUCKET_SIZE 256 | 29 | #define RX_BUCKET_SIZE 256 |
30 | 30 | ||
31 | #undef BIT | ||
32 | #define BIT(x) (1UL << (x)) | ||
33 | |||
34 | /* For more detailed explanations of what each field menas, | 31 | /* For more detailed explanations of what each field menas, |
35 | see Nick's great comments to #defines below (or docs, if | 32 | see Nick's great comments to #defines below (or docs, if |
36 | you are lucky enough toget hold of them :)*/ | 33 | you are lucky enough toget hold of them :)*/ |
diff --git a/drivers/net/s2io-regs.h b/drivers/net/s2io-regs.h index aef66e2d98d2..01f08d726ace 100644 --- a/drivers/net/s2io-regs.h +++ b/drivers/net/s2io-regs.h | |||
@@ -20,17 +20,17 @@ struct XENA_dev_config { | |||
20 | 20 | ||
21 | /* General Control-Status Registers */ | 21 | /* General Control-Status Registers */ |
22 | u64 general_int_status; | 22 | u64 general_int_status; |
23 | #define GEN_INTR_TXPIC BIT(0) | 23 | #define GEN_INTR_TXPIC s2BIT(0) |
24 | #define GEN_INTR_TXDMA BIT(1) | 24 | #define GEN_INTR_TXDMA s2BIT(1) |
25 | #define GEN_INTR_TXMAC BIT(2) | 25 | #define GEN_INTR_TXMAC s2BIT(2) |
26 | #define GEN_INTR_TXXGXS BIT(3) | 26 | #define GEN_INTR_TXXGXS s2BIT(3) |
27 | #define GEN_INTR_TXTRAFFIC BIT(8) | 27 | #define GEN_INTR_TXTRAFFIC s2BIT(8) |
28 | #define GEN_INTR_RXPIC BIT(32) | 28 | #define GEN_INTR_RXPIC s2BIT(32) |
29 | #define GEN_INTR_RXDMA BIT(33) | 29 | #define GEN_INTR_RXDMA s2BIT(33) |
30 | #define GEN_INTR_RXMAC BIT(34) | 30 | #define GEN_INTR_RXMAC s2BIT(34) |
31 | #define GEN_INTR_MC BIT(35) | 31 | #define GEN_INTR_MC s2BIT(35) |
32 | #define GEN_INTR_RXXGXS BIT(36) | 32 | #define GEN_INTR_RXXGXS s2BIT(36) |
33 | #define GEN_INTR_RXTRAFFIC BIT(40) | 33 | #define GEN_INTR_RXTRAFFIC s2BIT(40) |
34 | #define GEN_ERROR_INTR GEN_INTR_TXPIC | GEN_INTR_RXPIC | \ | 34 | #define GEN_ERROR_INTR GEN_INTR_TXPIC | GEN_INTR_RXPIC | \ |
35 | GEN_INTR_TXDMA | GEN_INTR_RXDMA | \ | 35 | GEN_INTR_TXDMA | GEN_INTR_RXDMA | \ |
36 | GEN_INTR_TXMAC | GEN_INTR_RXMAC | \ | 36 | GEN_INTR_TXMAC | GEN_INTR_RXMAC | \ |
@@ -54,36 +54,36 @@ struct XENA_dev_config { | |||
54 | 54 | ||
55 | 55 | ||
56 | u64 adapter_status; | 56 | u64 adapter_status; |
57 | #define ADAPTER_STATUS_TDMA_READY BIT(0) | 57 | #define ADAPTER_STATUS_TDMA_READY s2BIT(0) |
58 | #define ADAPTER_STATUS_RDMA_READY BIT(1) | 58 | #define ADAPTER_STATUS_RDMA_READY s2BIT(1) |
59 | #define ADAPTER_STATUS_PFC_READY BIT(2) | 59 | #define ADAPTER_STATUS_PFC_READY s2BIT(2) |
60 | #define ADAPTER_STATUS_TMAC_BUF_EMPTY BIT(3) | 60 | #define ADAPTER_STATUS_TMAC_BUF_EMPTY s2BIT(3) |
61 | #define ADAPTER_STATUS_PIC_QUIESCENT BIT(5) | 61 | #define ADAPTER_STATUS_PIC_QUIESCENT s2BIT(5) |
62 | #define ADAPTER_STATUS_RMAC_REMOTE_FAULT BIT(6) | 62 | #define ADAPTER_STATUS_RMAC_REMOTE_FAULT s2BIT(6) |
63 | #define ADAPTER_STATUS_RMAC_LOCAL_FAULT BIT(7) | 63 | #define ADAPTER_STATUS_RMAC_LOCAL_FAULT s2BIT(7) |
64 | #define ADAPTER_STATUS_RMAC_PCC_IDLE vBIT(0xFF,8,8) | 64 | #define ADAPTER_STATUS_RMAC_PCC_IDLE vBIT(0xFF,8,8) |
65 | #define ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE vBIT(0x0F,8,8) | 65 | #define ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE vBIT(0x0F,8,8) |
66 | #define ADAPTER_STATUS_RC_PRC_QUIESCENT vBIT(0xFF,16,8) | 66 | #define ADAPTER_STATUS_RC_PRC_QUIESCENT vBIT(0xFF,16,8) |
67 | #define ADAPTER_STATUS_MC_DRAM_READY BIT(24) | 67 | #define ADAPTER_STATUS_MC_DRAM_READY s2BIT(24) |
68 | #define ADAPTER_STATUS_MC_QUEUES_READY BIT(25) | 68 | #define ADAPTER_STATUS_MC_QUEUES_READY s2BIT(25) |
69 | #define ADAPTER_STATUS_M_PLL_LOCK BIT(30) | 69 | #define ADAPTER_STATUS_M_PLL_LOCK s2BIT(30) |
70 | #define ADAPTER_STATUS_P_PLL_LOCK BIT(31) | 70 | #define ADAPTER_STATUS_P_PLL_LOCK s2BIT(31) |
71 | 71 | ||
72 | u64 adapter_control; | 72 | u64 adapter_control; |
73 | #define ADAPTER_CNTL_EN BIT(7) | 73 | #define ADAPTER_CNTL_EN s2BIT(7) |
74 | #define ADAPTER_EOI_TX_ON BIT(15) | 74 | #define ADAPTER_EOI_TX_ON s2BIT(15) |
75 | #define ADAPTER_LED_ON BIT(23) | 75 | #define ADAPTER_LED_ON s2BIT(23) |
76 | #define ADAPTER_UDPI(val) vBIT(val,36,4) | 76 | #define ADAPTER_UDPI(val) vBIT(val,36,4) |
77 | #define ADAPTER_WAIT_INT BIT(48) | 77 | #define ADAPTER_WAIT_INT s2BIT(48) |
78 | #define ADAPTER_ECC_EN BIT(55) | 78 | #define ADAPTER_ECC_EN s2BIT(55) |
79 | 79 | ||
80 | u64 serr_source; | 80 | u64 serr_source; |
81 | #define SERR_SOURCE_PIC BIT(0) | 81 | #define SERR_SOURCE_PIC s2BIT(0) |
82 | #define SERR_SOURCE_TXDMA BIT(1) | 82 | #define SERR_SOURCE_TXDMA s2BIT(1) |
83 | #define SERR_SOURCE_RXDMA BIT(2) | 83 | #define SERR_SOURCE_RXDMA s2BIT(2) |
84 | #define SERR_SOURCE_MAC BIT(3) | 84 | #define SERR_SOURCE_MAC s2BIT(3) |
85 | #define SERR_SOURCE_MC BIT(4) | 85 | #define SERR_SOURCE_MC s2BIT(4) |
86 | #define SERR_SOURCE_XGXS BIT(5) | 86 | #define SERR_SOURCE_XGXS s2BIT(5) |
87 | #define SERR_SOURCE_ANY (SERR_SOURCE_PIC | \ | 87 | #define SERR_SOURCE_ANY (SERR_SOURCE_PIC | \ |
88 | SERR_SOURCE_TXDMA | \ | 88 | SERR_SOURCE_TXDMA | \ |
89 | SERR_SOURCE_RXDMA | \ | 89 | SERR_SOURCE_RXDMA | \ |
@@ -101,41 +101,41 @@ struct XENA_dev_config { | |||
101 | #define PCI_MODE_PCIX_M2_66 0x5 | 101 | #define PCI_MODE_PCIX_M2_66 0x5 |
102 | #define PCI_MODE_PCIX_M2_100 0x6 | 102 | #define PCI_MODE_PCIX_M2_100 0x6 |
103 | #define PCI_MODE_PCIX_M2_133 0x7 | 103 | #define PCI_MODE_PCIX_M2_133 0x7 |
104 | #define PCI_MODE_UNSUPPORTED BIT(0) | 104 | #define PCI_MODE_UNSUPPORTED s2BIT(0) |
105 | #define PCI_MODE_32_BITS BIT(8) | 105 | #define PCI_MODE_32_BITS s2BIT(8) |
106 | #define PCI_MODE_UNKNOWN_MODE BIT(9) | 106 | #define PCI_MODE_UNKNOWN_MODE s2BIT(9) |
107 | 107 | ||
108 | u8 unused_0[0x800 - 0x128]; | 108 | u8 unused_0[0x800 - 0x128]; |
109 | 109 | ||
110 | /* PCI-X Controller registers */ | 110 | /* PCI-X Controller registers */ |
111 | u64 pic_int_status; | 111 | u64 pic_int_status; |
112 | u64 pic_int_mask; | 112 | u64 pic_int_mask; |
113 | #define PIC_INT_TX BIT(0) | 113 | #define PIC_INT_TX s2BIT(0) |
114 | #define PIC_INT_FLSH BIT(1) | 114 | #define PIC_INT_FLSH s2BIT(1) |
115 | #define PIC_INT_MDIO BIT(2) | 115 | #define PIC_INT_MDIO s2BIT(2) |
116 | #define PIC_INT_IIC BIT(3) | 116 | #define PIC_INT_IIC s2BIT(3) |
117 | #define PIC_INT_GPIO BIT(4) | 117 | #define PIC_INT_GPIO s2BIT(4) |
118 | #define PIC_INT_RX BIT(32) | 118 | #define PIC_INT_RX s2BIT(32) |
119 | 119 | ||
120 | u64 txpic_int_reg; | 120 | u64 txpic_int_reg; |
121 | u64 txpic_int_mask; | 121 | u64 txpic_int_mask; |
122 | #define PCIX_INT_REG_ECC_SG_ERR BIT(0) | 122 | #define PCIX_INT_REG_ECC_SG_ERR s2BIT(0) |
123 | #define PCIX_INT_REG_ECC_DB_ERR BIT(1) | 123 | #define PCIX_INT_REG_ECC_DB_ERR s2BIT(1) |
124 | #define PCIX_INT_REG_FLASHR_R_FSM_ERR BIT(8) | 124 | #define PCIX_INT_REG_FLASHR_R_FSM_ERR s2BIT(8) |
125 | #define PCIX_INT_REG_FLASHR_W_FSM_ERR BIT(9) | 125 | #define PCIX_INT_REG_FLASHR_W_FSM_ERR s2BIT(9) |
126 | #define PCIX_INT_REG_INI_TX_FSM_SERR BIT(10) | 126 | #define PCIX_INT_REG_INI_TX_FSM_SERR s2BIT(10) |
127 | #define PCIX_INT_REG_INI_TXO_FSM_ERR BIT(11) | 127 | #define PCIX_INT_REG_INI_TXO_FSM_ERR s2BIT(11) |
128 | #define PCIX_INT_REG_TRT_FSM_SERR BIT(13) | 128 | #define PCIX_INT_REG_TRT_FSM_SERR s2BIT(13) |
129 | #define PCIX_INT_REG_SRT_FSM_SERR BIT(14) | 129 | #define PCIX_INT_REG_SRT_FSM_SERR s2BIT(14) |
130 | #define PCIX_INT_REG_PIFR_FSM_SERR BIT(15) | 130 | #define PCIX_INT_REG_PIFR_FSM_SERR s2BIT(15) |
131 | #define PCIX_INT_REG_WRC_TX_SEND_FSM_SERR BIT(21) | 131 | #define PCIX_INT_REG_WRC_TX_SEND_FSM_SERR s2BIT(21) |
132 | #define PCIX_INT_REG_RRC_TX_REQ_FSM_SERR BIT(23) | 132 | #define PCIX_INT_REG_RRC_TX_REQ_FSM_SERR s2BIT(23) |
133 | #define PCIX_INT_REG_INI_RX_FSM_SERR BIT(48) | 133 | #define PCIX_INT_REG_INI_RX_FSM_SERR s2BIT(48) |
134 | #define PCIX_INT_REG_RA_RX_FSM_SERR BIT(50) | 134 | #define PCIX_INT_REG_RA_RX_FSM_SERR s2BIT(50) |
135 | /* | 135 | /* |
136 | #define PCIX_INT_REG_WRC_RX_SEND_FSM_SERR BIT(52) | 136 | #define PCIX_INT_REG_WRC_RX_SEND_FSM_SERR s2BIT(52) |
137 | #define PCIX_INT_REG_RRC_RX_REQ_FSM_SERR BIT(54) | 137 | #define PCIX_INT_REG_RRC_RX_REQ_FSM_SERR s2BIT(54) |
138 | #define PCIX_INT_REG_RRC_RX_SPLIT_FSM_SERR BIT(58) | 138 | #define PCIX_INT_REG_RRC_RX_SPLIT_FSM_SERR s2BIT(58) |
139 | */ | 139 | */ |
140 | u64 txpic_alarms; | 140 | u64 txpic_alarms; |
141 | u64 rxpic_int_reg; | 141 | u64 rxpic_int_reg; |
@@ -144,92 +144,92 @@ struct XENA_dev_config { | |||
144 | 144 | ||
145 | u64 flsh_int_reg; | 145 | u64 flsh_int_reg; |
146 | u64 flsh_int_mask; | 146 | u64 flsh_int_mask; |
147 | #define PIC_FLSH_INT_REG_CYCLE_FSM_ERR BIT(63) | 147 | #define PIC_FLSH_INT_REG_CYCLE_FSM_ERR s2BIT(63) |
148 | #define PIC_FLSH_INT_REG_ERR BIT(62) | 148 | #define PIC_FLSH_INT_REG_ERR s2BIT(62) |
149 | u64 flash_alarms; | 149 | u64 flash_alarms; |
150 | 150 | ||
151 | u64 mdio_int_reg; | 151 | u64 mdio_int_reg; |
152 | u64 mdio_int_mask; | 152 | u64 mdio_int_mask; |
153 | #define MDIO_INT_REG_MDIO_BUS_ERR BIT(0) | 153 | #define MDIO_INT_REG_MDIO_BUS_ERR s2BIT(0) |
154 | #define MDIO_INT_REG_DTX_BUS_ERR BIT(8) | 154 | #define MDIO_INT_REG_DTX_BUS_ERR s2BIT(8) |
155 | #define MDIO_INT_REG_LASI BIT(39) | 155 | #define MDIO_INT_REG_LASI s2BIT(39) |
156 | u64 mdio_alarms; | 156 | u64 mdio_alarms; |
157 | 157 | ||
158 | u64 iic_int_reg; | 158 | u64 iic_int_reg; |
159 | u64 iic_int_mask; | 159 | u64 iic_int_mask; |
160 | #define IIC_INT_REG_BUS_FSM_ERR BIT(4) | 160 | #define IIC_INT_REG_BUS_FSM_ERR s2BIT(4) |
161 | #define IIC_INT_REG_BIT_FSM_ERR BIT(5) | 161 | #define IIC_INT_REG_BIT_FSM_ERR s2BIT(5) |
162 | #define IIC_INT_REG_CYCLE_FSM_ERR BIT(6) | 162 | #define IIC_INT_REG_CYCLE_FSM_ERR s2BIT(6) |
163 | #define IIC_INT_REG_REQ_FSM_ERR BIT(7) | 163 | #define IIC_INT_REG_REQ_FSM_ERR s2BIT(7) |
164 | #define IIC_INT_REG_ACK_ERR BIT(8) | 164 | #define IIC_INT_REG_ACK_ERR s2BIT(8) |
165 | u64 iic_alarms; | 165 | u64 iic_alarms; |
166 | 166 | ||
167 | u8 unused4[0x08]; | 167 | u8 unused4[0x08]; |
168 | 168 | ||
169 | u64 gpio_int_reg; | 169 | u64 gpio_int_reg; |
170 | #define GPIO_INT_REG_DP_ERR_INT BIT(0) | 170 | #define GPIO_INT_REG_DP_ERR_INT s2BIT(0) |
171 | #define GPIO_INT_REG_LINK_DOWN BIT(1) | 171 | #define GPIO_INT_REG_LINK_DOWN s2BIT(1) |
172 | #define GPIO_INT_REG_LINK_UP BIT(2) | 172 | #define GPIO_INT_REG_LINK_UP s2BIT(2) |
173 | u64 gpio_int_mask; | 173 | u64 gpio_int_mask; |
174 | #define GPIO_INT_MASK_LINK_DOWN BIT(1) | 174 | #define GPIO_INT_MASK_LINK_DOWN s2BIT(1) |
175 | #define GPIO_INT_MASK_LINK_UP BIT(2) | 175 | #define GPIO_INT_MASK_LINK_UP s2BIT(2) |
176 | u64 gpio_alarms; | 176 | u64 gpio_alarms; |
177 | 177 | ||
178 | u8 unused5[0x38]; | 178 | u8 unused5[0x38]; |
179 | 179 | ||
180 | u64 tx_traffic_int; | 180 | u64 tx_traffic_int; |
181 | #define TX_TRAFFIC_INT_n(n) BIT(n) | 181 | #define TX_TRAFFIC_INT_n(n) s2BIT(n) |
182 | u64 tx_traffic_mask; | 182 | u64 tx_traffic_mask; |
183 | 183 | ||
184 | u64 rx_traffic_int; | 184 | u64 rx_traffic_int; |
185 | #define RX_TRAFFIC_INT_n(n) BIT(n) | 185 | #define RX_TRAFFIC_INT_n(n) s2BIT(n) |
186 | u64 rx_traffic_mask; | 186 | u64 rx_traffic_mask; |
187 | 187 | ||
188 | /* PIC Control registers */ | 188 | /* PIC Control registers */ |
189 | u64 pic_control; | 189 | u64 pic_control; |
190 | #define PIC_CNTL_RX_ALARM_MAP_1 BIT(0) | 190 | #define PIC_CNTL_RX_ALARM_MAP_1 s2BIT(0) |
191 | #define PIC_CNTL_SHARED_SPLITS(n) vBIT(n,11,5) | 191 | #define PIC_CNTL_SHARED_SPLITS(n) vBIT(n,11,5) |
192 | 192 | ||
193 | u64 swapper_ctrl; | 193 | u64 swapper_ctrl; |
194 | #define SWAPPER_CTRL_PIF_R_FE BIT(0) | 194 | #define SWAPPER_CTRL_PIF_R_FE s2BIT(0) |
195 | #define SWAPPER_CTRL_PIF_R_SE BIT(1) | 195 | #define SWAPPER_CTRL_PIF_R_SE s2BIT(1) |
196 | #define SWAPPER_CTRL_PIF_W_FE BIT(8) | 196 | #define SWAPPER_CTRL_PIF_W_FE s2BIT(8) |
197 | #define SWAPPER_CTRL_PIF_W_SE BIT(9) | 197 | #define SWAPPER_CTRL_PIF_W_SE s2BIT(9) |
198 | #define SWAPPER_CTRL_TXP_FE BIT(16) | 198 | #define SWAPPER_CTRL_TXP_FE s2BIT(16) |
199 | #define SWAPPER_CTRL_TXP_SE BIT(17) | 199 | #define SWAPPER_CTRL_TXP_SE s2BIT(17) |
200 | #define SWAPPER_CTRL_TXD_R_FE BIT(18) | 200 | #define SWAPPER_CTRL_TXD_R_FE s2BIT(18) |
201 | #define SWAPPER_CTRL_TXD_R_SE BIT(19) | 201 | #define SWAPPER_CTRL_TXD_R_SE s2BIT(19) |
202 | #define SWAPPER_CTRL_TXD_W_FE BIT(20) | 202 | #define SWAPPER_CTRL_TXD_W_FE s2BIT(20) |
203 | #define SWAPPER_CTRL_TXD_W_SE BIT(21) | 203 | #define SWAPPER_CTRL_TXD_W_SE s2BIT(21) |
204 | #define SWAPPER_CTRL_TXF_R_FE BIT(22) | 204 | #define SWAPPER_CTRL_TXF_R_FE s2BIT(22) |
205 | #define SWAPPER_CTRL_TXF_R_SE BIT(23) | 205 | #define SWAPPER_CTRL_TXF_R_SE s2BIT(23) |
206 | #define SWAPPER_CTRL_RXD_R_FE BIT(32) | 206 | #define SWAPPER_CTRL_RXD_R_FE s2BIT(32) |
207 | #define SWAPPER_CTRL_RXD_R_SE BIT(33) | 207 | #define SWAPPER_CTRL_RXD_R_SE s2BIT(33) |
208 | #define SWAPPER_CTRL_RXD_W_FE BIT(34) | 208 | #define SWAPPER_CTRL_RXD_W_FE s2BIT(34) |
209 | #define SWAPPER_CTRL_RXD_W_SE BIT(35) | 209 | #define SWAPPER_CTRL_RXD_W_SE s2BIT(35) |
210 | #define SWAPPER_CTRL_RXF_W_FE BIT(36) | 210 | #define SWAPPER_CTRL_RXF_W_FE s2BIT(36) |
211 | #define SWAPPER_CTRL_RXF_W_SE BIT(37) | 211 | #define SWAPPER_CTRL_RXF_W_SE s2BIT(37) |
212 | #define SWAPPER_CTRL_XMSI_FE BIT(40) | 212 | #define SWAPPER_CTRL_XMSI_FE s2BIT(40) |
213 | #define SWAPPER_CTRL_XMSI_SE BIT(41) | 213 | #define SWAPPER_CTRL_XMSI_SE s2BIT(41) |
214 | #define SWAPPER_CTRL_STATS_FE BIT(48) | 214 | #define SWAPPER_CTRL_STATS_FE s2BIT(48) |
215 | #define SWAPPER_CTRL_STATS_SE BIT(49) | 215 | #define SWAPPER_CTRL_STATS_SE s2BIT(49) |
216 | 216 | ||
217 | u64 pif_rd_swapper_fb; | 217 | u64 pif_rd_swapper_fb; |
218 | #define IF_RD_SWAPPER_FB 0x0123456789ABCDEF | 218 | #define IF_RD_SWAPPER_FB 0x0123456789ABCDEF |
219 | 219 | ||
220 | u64 scheduled_int_ctrl; | 220 | u64 scheduled_int_ctrl; |
221 | #define SCHED_INT_CTRL_TIMER_EN BIT(0) | 221 | #define SCHED_INT_CTRL_TIMER_EN s2BIT(0) |
222 | #define SCHED_INT_CTRL_ONE_SHOT BIT(1) | 222 | #define SCHED_INT_CTRL_ONE_SHOT s2BIT(1) |
223 | #define SCHED_INT_CTRL_INT2MSI(val) vBIT(val,10,6) | 223 | #define SCHED_INT_CTRL_INT2MSI(val) vBIT(val,10,6) |
224 | #define SCHED_INT_PERIOD TBD | 224 | #define SCHED_INT_PERIOD TBD |
225 | 225 | ||
226 | u64 txreqtimeout; | 226 | u64 txreqtimeout; |
227 | #define TXREQTO_VAL(val) vBIT(val,0,32) | 227 | #define TXREQTO_VAL(val) vBIT(val,0,32) |
228 | #define TXREQTO_EN BIT(63) | 228 | #define TXREQTO_EN s2BIT(63) |
229 | 229 | ||
230 | u64 statsreqtimeout; | 230 | u64 statsreqtimeout; |
231 | #define STATREQTO_VAL(n) TBD | 231 | #define STATREQTO_VAL(n) TBD |
232 | #define STATREQTO_EN BIT(63) | 232 | #define STATREQTO_EN s2BIT(63) |
233 | 233 | ||
234 | u64 read_retry_delay; | 234 | u64 read_retry_delay; |
235 | u64 read_retry_acceleration; | 235 | u64 read_retry_acceleration; |
@@ -255,10 +255,10 @@ struct XENA_dev_config { | |||
255 | 255 | ||
256 | /* Automated statistics collection */ | 256 | /* Automated statistics collection */ |
257 | u64 stat_cfg; | 257 | u64 stat_cfg; |
258 | #define STAT_CFG_STAT_EN BIT(0) | 258 | #define STAT_CFG_STAT_EN s2BIT(0) |
259 | #define STAT_CFG_ONE_SHOT_EN BIT(1) | 259 | #define STAT_CFG_ONE_SHOT_EN s2BIT(1) |
260 | #define STAT_CFG_STAT_NS_EN BIT(8) | 260 | #define STAT_CFG_STAT_NS_EN s2BIT(8) |
261 | #define STAT_CFG_STAT_RO BIT(9) | 261 | #define STAT_CFG_STAT_RO s2BIT(9) |
262 | #define STAT_TRSF_PER(n) TBD | 262 | #define STAT_TRSF_PER(n) TBD |
263 | #define PER_SEC 0x208d5 | 263 | #define PER_SEC 0x208d5 |
264 | #define SET_UPDT_PERIOD(n) vBIT((PER_SEC*n),32,32) | 264 | #define SET_UPDT_PERIOD(n) vBIT((PER_SEC*n),32,32) |
@@ -290,18 +290,18 @@ struct XENA_dev_config { | |||
290 | #define I2C_CONTROL_DEV_ID(id) vBIT(id,1,3) | 290 | #define I2C_CONTROL_DEV_ID(id) vBIT(id,1,3) |
291 | #define I2C_CONTROL_ADDR(addr) vBIT(addr,5,11) | 291 | #define I2C_CONTROL_ADDR(addr) vBIT(addr,5,11) |
292 | #define I2C_CONTROL_BYTE_CNT(cnt) vBIT(cnt,22,2) | 292 | #define I2C_CONTROL_BYTE_CNT(cnt) vBIT(cnt,22,2) |
293 | #define I2C_CONTROL_READ BIT(24) | 293 | #define I2C_CONTROL_READ s2BIT(24) |
294 | #define I2C_CONTROL_NACK BIT(25) | 294 | #define I2C_CONTROL_NACK s2BIT(25) |
295 | #define I2C_CONTROL_CNTL_START vBIT(0xE,28,4) | 295 | #define I2C_CONTROL_CNTL_START vBIT(0xE,28,4) |
296 | #define I2C_CONTROL_CNTL_END(val) (val & vBIT(0x1,28,4)) | 296 | #define I2C_CONTROL_CNTL_END(val) (val & vBIT(0x1,28,4)) |
297 | #define I2C_CONTROL_GET_DATA(val) (u32)(val & 0xFFFFFFFF) | 297 | #define I2C_CONTROL_GET_DATA(val) (u32)(val & 0xFFFFFFFF) |
298 | #define I2C_CONTROL_SET_DATA(val) vBIT(val,32,32) | 298 | #define I2C_CONTROL_SET_DATA(val) vBIT(val,32,32) |
299 | 299 | ||
300 | u64 gpio_control; | 300 | u64 gpio_control; |
301 | #define GPIO_CTRL_GPIO_0 BIT(8) | 301 | #define GPIO_CTRL_GPIO_0 s2BIT(8) |
302 | u64 misc_control; | 302 | u64 misc_control; |
303 | #define FAULT_BEHAVIOUR BIT(0) | 303 | #define FAULT_BEHAVIOUR s2BIT(0) |
304 | #define EXT_REQ_EN BIT(1) | 304 | #define EXT_REQ_EN s2BIT(1) |
305 | #define MISC_LINK_STABILITY_PRD(val) vBIT(val,29,3) | 305 | #define MISC_LINK_STABILITY_PRD(val) vBIT(val,29,3) |
306 | 306 | ||
307 | u8 unused7_1[0x230 - 0x208]; | 307 | u8 unused7_1[0x230 - 0x208]; |
@@ -317,29 +317,29 @@ struct XENA_dev_config { | |||
317 | /* TxDMA registers */ | 317 | /* TxDMA registers */ |
318 | u64 txdma_int_status; | 318 | u64 txdma_int_status; |
319 | u64 txdma_int_mask; | 319 | u64 txdma_int_mask; |
320 | #define TXDMA_PFC_INT BIT(0) | 320 | #define TXDMA_PFC_INT s2BIT(0) |
321 | #define TXDMA_TDA_INT BIT(1) | 321 | #define TXDMA_TDA_INT s2BIT(1) |
322 | #define TXDMA_PCC_INT BIT(2) | 322 | #define TXDMA_PCC_INT s2BIT(2) |
323 | #define TXDMA_TTI_INT BIT(3) | 323 | #define TXDMA_TTI_INT s2BIT(3) |
324 | #define TXDMA_LSO_INT BIT(4) | 324 | #define TXDMA_LSO_INT s2BIT(4) |
325 | #define TXDMA_TPA_INT BIT(5) | 325 | #define TXDMA_TPA_INT s2BIT(5) |
326 | #define TXDMA_SM_INT BIT(6) | 326 | #define TXDMA_SM_INT s2BIT(6) |
327 | u64 pfc_err_reg; | 327 | u64 pfc_err_reg; |
328 | #define PFC_ECC_SG_ERR BIT(7) | 328 | #define PFC_ECC_SG_ERR s2BIT(7) |
329 | #define PFC_ECC_DB_ERR BIT(15) | 329 | #define PFC_ECC_DB_ERR s2BIT(15) |
330 | #define PFC_SM_ERR_ALARM BIT(23) | 330 | #define PFC_SM_ERR_ALARM s2BIT(23) |
331 | #define PFC_MISC_0_ERR BIT(31) | 331 | #define PFC_MISC_0_ERR s2BIT(31) |
332 | #define PFC_MISC_1_ERR BIT(32) | 332 | #define PFC_MISC_1_ERR s2BIT(32) |
333 | #define PFC_PCIX_ERR BIT(39) | 333 | #define PFC_PCIX_ERR s2BIT(39) |
334 | u64 pfc_err_mask; | 334 | u64 pfc_err_mask; |
335 | u64 pfc_err_alarm; | 335 | u64 pfc_err_alarm; |
336 | 336 | ||
337 | u64 tda_err_reg; | 337 | u64 tda_err_reg; |
338 | #define TDA_Fn_ECC_SG_ERR vBIT(0xff,0,8) | 338 | #define TDA_Fn_ECC_SG_ERR vBIT(0xff,0,8) |
339 | #define TDA_Fn_ECC_DB_ERR vBIT(0xff,8,8) | 339 | #define TDA_Fn_ECC_DB_ERR vBIT(0xff,8,8) |
340 | #define TDA_SM0_ERR_ALARM BIT(22) | 340 | #define TDA_SM0_ERR_ALARM s2BIT(22) |
341 | #define TDA_SM1_ERR_ALARM BIT(23) | 341 | #define TDA_SM1_ERR_ALARM s2BIT(23) |
342 | #define TDA_PCIX_ERR BIT(39) | 342 | #define TDA_PCIX_ERR s2BIT(39) |
343 | u64 tda_err_mask; | 343 | u64 tda_err_mask; |
344 | u64 tda_err_alarm; | 344 | u64 tda_err_alarm; |
345 | 345 | ||
@@ -351,40 +351,40 @@ struct XENA_dev_config { | |||
351 | #define PCC_SM_ERR_ALARM vBIT(0xff,32,8) | 351 | #define PCC_SM_ERR_ALARM vBIT(0xff,32,8) |
352 | #define PCC_WR_ERR_ALARM vBIT(0xff,40,8) | 352 | #define PCC_WR_ERR_ALARM vBIT(0xff,40,8) |
353 | #define PCC_N_SERR vBIT(0xff,48,8) | 353 | #define PCC_N_SERR vBIT(0xff,48,8) |
354 | #define PCC_6_COF_OV_ERR BIT(56) | 354 | #define PCC_6_COF_OV_ERR s2BIT(56) |
355 | #define PCC_7_COF_OV_ERR BIT(57) | 355 | #define PCC_7_COF_OV_ERR s2BIT(57) |
356 | #define PCC_6_LSO_OV_ERR BIT(58) | 356 | #define PCC_6_LSO_OV_ERR s2BIT(58) |
357 | #define PCC_7_LSO_OV_ERR BIT(59) | 357 | #define PCC_7_LSO_OV_ERR s2BIT(59) |
358 | #define PCC_ENABLE_FOUR vBIT(0x0F,0,8) | 358 | #define PCC_ENABLE_FOUR vBIT(0x0F,0,8) |
359 | u64 pcc_err_mask; | 359 | u64 pcc_err_mask; |
360 | u64 pcc_err_alarm; | 360 | u64 pcc_err_alarm; |
361 | 361 | ||
362 | u64 tti_err_reg; | 362 | u64 tti_err_reg; |
363 | #define TTI_ECC_SG_ERR BIT(7) | 363 | #define TTI_ECC_SG_ERR s2BIT(7) |
364 | #define TTI_ECC_DB_ERR BIT(15) | 364 | #define TTI_ECC_DB_ERR s2BIT(15) |
365 | #define TTI_SM_ERR_ALARM BIT(23) | 365 | #define TTI_SM_ERR_ALARM s2BIT(23) |
366 | u64 tti_err_mask; | 366 | u64 tti_err_mask; |
367 | u64 tti_err_alarm; | 367 | u64 tti_err_alarm; |
368 | 368 | ||
369 | u64 lso_err_reg; | 369 | u64 lso_err_reg; |
370 | #define LSO6_SEND_OFLOW BIT(12) | 370 | #define LSO6_SEND_OFLOW s2BIT(12) |
371 | #define LSO7_SEND_OFLOW BIT(13) | 371 | #define LSO7_SEND_OFLOW s2BIT(13) |
372 | #define LSO6_ABORT BIT(14) | 372 | #define LSO6_ABORT s2BIT(14) |
373 | #define LSO7_ABORT BIT(15) | 373 | #define LSO7_ABORT s2BIT(15) |
374 | #define LSO6_SM_ERR_ALARM BIT(22) | 374 | #define LSO6_SM_ERR_ALARM s2BIT(22) |
375 | #define LSO7_SM_ERR_ALARM BIT(23) | 375 | #define LSO7_SM_ERR_ALARM s2BIT(23) |
376 | u64 lso_err_mask; | 376 | u64 lso_err_mask; |
377 | u64 lso_err_alarm; | 377 | u64 lso_err_alarm; |
378 | 378 | ||
379 | u64 tpa_err_reg; | 379 | u64 tpa_err_reg; |
380 | #define TPA_TX_FRM_DROP BIT(7) | 380 | #define TPA_TX_FRM_DROP s2BIT(7) |
381 | #define TPA_SM_ERR_ALARM BIT(23) | 381 | #define TPA_SM_ERR_ALARM s2BIT(23) |
382 | 382 | ||
383 | u64 tpa_err_mask; | 383 | u64 tpa_err_mask; |
384 | u64 tpa_err_alarm; | 384 | u64 tpa_err_alarm; |
385 | 385 | ||
386 | u64 sm_err_reg; | 386 | u64 sm_err_reg; |
387 | #define SM_SM_ERR_ALARM BIT(15) | 387 | #define SM_SM_ERR_ALARM s2BIT(15) |
388 | u64 sm_err_mask; | 388 | u64 sm_err_mask; |
389 | u64 sm_err_alarm; | 389 | u64 sm_err_alarm; |
390 | 390 | ||
@@ -397,7 +397,7 @@ struct XENA_dev_config { | |||
397 | #define X_MAX_FIFOS 8 | 397 | #define X_MAX_FIFOS 8 |
398 | #define X_FIFO_MAX_LEN 0x1FFF /*8191 */ | 398 | #define X_FIFO_MAX_LEN 0x1FFF /*8191 */ |
399 | u64 tx_fifo_partition_0; | 399 | u64 tx_fifo_partition_0; |
400 | #define TX_FIFO_PARTITION_EN BIT(0) | 400 | #define TX_FIFO_PARTITION_EN s2BIT(0) |
401 | #define TX_FIFO_PARTITION_0_PRI(val) vBIT(val,5,3) | 401 | #define TX_FIFO_PARTITION_0_PRI(val) vBIT(val,5,3) |
402 | #define TX_FIFO_PARTITION_0_LEN(val) vBIT(val,19,13) | 402 | #define TX_FIFO_PARTITION_0_LEN(val) vBIT(val,19,13) |
403 | #define TX_FIFO_PARTITION_1_PRI(val) vBIT(val,37,3) | 403 | #define TX_FIFO_PARTITION_1_PRI(val) vBIT(val,37,3) |
@@ -437,16 +437,16 @@ struct XENA_dev_config { | |||
437 | u64 tx_w_round_robin_4; | 437 | u64 tx_w_round_robin_4; |
438 | 438 | ||
439 | u64 tti_command_mem; | 439 | u64 tti_command_mem; |
440 | #define TTI_CMD_MEM_WE BIT(7) | 440 | #define TTI_CMD_MEM_WE s2BIT(7) |
441 | #define TTI_CMD_MEM_STROBE_NEW_CMD BIT(15) | 441 | #define TTI_CMD_MEM_STROBE_NEW_CMD s2BIT(15) |
442 | #define TTI_CMD_MEM_STROBE_BEING_EXECUTED BIT(15) | 442 | #define TTI_CMD_MEM_STROBE_BEING_EXECUTED s2BIT(15) |
443 | #define TTI_CMD_MEM_OFFSET(n) vBIT(n,26,6) | 443 | #define TTI_CMD_MEM_OFFSET(n) vBIT(n,26,6) |
444 | 444 | ||
445 | u64 tti_data1_mem; | 445 | u64 tti_data1_mem; |
446 | #define TTI_DATA1_MEM_TX_TIMER_VAL(n) vBIT(n,6,26) | 446 | #define TTI_DATA1_MEM_TX_TIMER_VAL(n) vBIT(n,6,26) |
447 | #define TTI_DATA1_MEM_TX_TIMER_AC_CI(n) vBIT(n,38,2) | 447 | #define TTI_DATA1_MEM_TX_TIMER_AC_CI(n) vBIT(n,38,2) |
448 | #define TTI_DATA1_MEM_TX_TIMER_AC_EN BIT(38) | 448 | #define TTI_DATA1_MEM_TX_TIMER_AC_EN s2BIT(38) |
449 | #define TTI_DATA1_MEM_TX_TIMER_CI_EN BIT(39) | 449 | #define TTI_DATA1_MEM_TX_TIMER_CI_EN s2BIT(39) |
450 | #define TTI_DATA1_MEM_TX_URNG_A(n) vBIT(n,41,7) | 450 | #define TTI_DATA1_MEM_TX_URNG_A(n) vBIT(n,41,7) |
451 | #define TTI_DATA1_MEM_TX_URNG_B(n) vBIT(n,49,7) | 451 | #define TTI_DATA1_MEM_TX_URNG_B(n) vBIT(n,49,7) |
452 | #define TTI_DATA1_MEM_TX_URNG_C(n) vBIT(n,57,7) | 452 | #define TTI_DATA1_MEM_TX_URNG_C(n) vBIT(n,57,7) |
@@ -459,11 +459,11 @@ struct XENA_dev_config { | |||
459 | 459 | ||
460 | /* Tx Protocol assist */ | 460 | /* Tx Protocol assist */ |
461 | u64 tx_pa_cfg; | 461 | u64 tx_pa_cfg; |
462 | #define TX_PA_CFG_IGNORE_FRM_ERR BIT(1) | 462 | #define TX_PA_CFG_IGNORE_FRM_ERR s2BIT(1) |
463 | #define TX_PA_CFG_IGNORE_SNAP_OUI BIT(2) | 463 | #define TX_PA_CFG_IGNORE_SNAP_OUI s2BIT(2) |
464 | #define TX_PA_CFG_IGNORE_LLC_CTRL BIT(3) | 464 | #define TX_PA_CFG_IGNORE_LLC_CTRL s2BIT(3) |
465 | #define TX_PA_CFG_IGNORE_L2_ERR BIT(6) | 465 | #define TX_PA_CFG_IGNORE_L2_ERR s2BIT(6) |
466 | #define RX_PA_CFG_STRIP_VLAN_TAG BIT(15) | 466 | #define RX_PA_CFG_STRIP_VLAN_TAG s2BIT(15) |
467 | 467 | ||
468 | /* Recent add, used only debug purposes. */ | 468 | /* Recent add, used only debug purposes. */ |
469 | u64 pcc_enable; | 469 | u64 pcc_enable; |
@@ -477,31 +477,31 @@ struct XENA_dev_config { | |||
477 | /* RxDMA Registers */ | 477 | /* RxDMA Registers */ |
478 | u64 rxdma_int_status; | 478 | u64 rxdma_int_status; |
479 | u64 rxdma_int_mask; | 479 | u64 rxdma_int_mask; |
480 | #define RXDMA_INT_RC_INT_M BIT(0) | 480 | #define RXDMA_INT_RC_INT_M s2BIT(0) |
481 | #define RXDMA_INT_RPA_INT_M BIT(1) | 481 | #define RXDMA_INT_RPA_INT_M s2BIT(1) |
482 | #define RXDMA_INT_RDA_INT_M BIT(2) | 482 | #define RXDMA_INT_RDA_INT_M s2BIT(2) |
483 | #define RXDMA_INT_RTI_INT_M BIT(3) | 483 | #define RXDMA_INT_RTI_INT_M s2BIT(3) |
484 | 484 | ||
485 | u64 rda_err_reg; | 485 | u64 rda_err_reg; |
486 | #define RDA_RXDn_ECC_SG_ERR vBIT(0xFF,0,8) | 486 | #define RDA_RXDn_ECC_SG_ERR vBIT(0xFF,0,8) |
487 | #define RDA_RXDn_ECC_DB_ERR vBIT(0xFF,8,8) | 487 | #define RDA_RXDn_ECC_DB_ERR vBIT(0xFF,8,8) |
488 | #define RDA_FRM_ECC_SG_ERR BIT(23) | 488 | #define RDA_FRM_ECC_SG_ERR s2BIT(23) |
489 | #define RDA_FRM_ECC_DB_N_AERR BIT(31) | 489 | #define RDA_FRM_ECC_DB_N_AERR s2BIT(31) |
490 | #define RDA_SM1_ERR_ALARM BIT(38) | 490 | #define RDA_SM1_ERR_ALARM s2BIT(38) |
491 | #define RDA_SM0_ERR_ALARM BIT(39) | 491 | #define RDA_SM0_ERR_ALARM s2BIT(39) |
492 | #define RDA_MISC_ERR BIT(47) | 492 | #define RDA_MISC_ERR s2BIT(47) |
493 | #define RDA_PCIX_ERR BIT(55) | 493 | #define RDA_PCIX_ERR s2BIT(55) |
494 | #define RDA_RXD_ECC_DB_SERR BIT(63) | 494 | #define RDA_RXD_ECC_DB_SERR s2BIT(63) |
495 | u64 rda_err_mask; | 495 | u64 rda_err_mask; |
496 | u64 rda_err_alarm; | 496 | u64 rda_err_alarm; |
497 | 497 | ||
498 | u64 rc_err_reg; | 498 | u64 rc_err_reg; |
499 | #define RC_PRCn_ECC_SG_ERR vBIT(0xFF,0,8) | 499 | #define RC_PRCn_ECC_SG_ERR vBIT(0xFF,0,8) |
500 | #define RC_PRCn_ECC_DB_ERR vBIT(0xFF,8,8) | 500 | #define RC_PRCn_ECC_DB_ERR vBIT(0xFF,8,8) |
501 | #define RC_FTC_ECC_SG_ERR BIT(23) | 501 | #define RC_FTC_ECC_SG_ERR s2BIT(23) |
502 | #define RC_FTC_ECC_DB_ERR BIT(31) | 502 | #define RC_FTC_ECC_DB_ERR s2BIT(31) |
503 | #define RC_PRCn_SM_ERR_ALARM vBIT(0xFF,32,8) | 503 | #define RC_PRCn_SM_ERR_ALARM vBIT(0xFF,32,8) |
504 | #define RC_FTC_SM_ERR_ALARM BIT(47) | 504 | #define RC_FTC_SM_ERR_ALARM s2BIT(47) |
505 | #define RC_RDA_FAIL_WR_Rn vBIT(0xFF,48,8) | 505 | #define RC_RDA_FAIL_WR_Rn vBIT(0xFF,48,8) |
506 | u64 rc_err_mask; | 506 | u64 rc_err_mask; |
507 | u64 rc_err_alarm; | 507 | u64 rc_err_alarm; |
@@ -517,18 +517,18 @@ struct XENA_dev_config { | |||
517 | u64 prc_pcix_err_alarm; | 517 | u64 prc_pcix_err_alarm; |
518 | 518 | ||
519 | u64 rpa_err_reg; | 519 | u64 rpa_err_reg; |
520 | #define RPA_ECC_SG_ERR BIT(7) | 520 | #define RPA_ECC_SG_ERR s2BIT(7) |
521 | #define RPA_ECC_DB_ERR BIT(15) | 521 | #define RPA_ECC_DB_ERR s2BIT(15) |
522 | #define RPA_FLUSH_REQUEST BIT(22) | 522 | #define RPA_FLUSH_REQUEST s2BIT(22) |
523 | #define RPA_SM_ERR_ALARM BIT(23) | 523 | #define RPA_SM_ERR_ALARM s2BIT(23) |
524 | #define RPA_CREDIT_ERR BIT(31) | 524 | #define RPA_CREDIT_ERR s2BIT(31) |
525 | u64 rpa_err_mask; | 525 | u64 rpa_err_mask; |
526 | u64 rpa_err_alarm; | 526 | u64 rpa_err_alarm; |
527 | 527 | ||
528 | u64 rti_err_reg; | 528 | u64 rti_err_reg; |
529 | #define RTI_ECC_SG_ERR BIT(7) | 529 | #define RTI_ECC_SG_ERR s2BIT(7) |
530 | #define RTI_ECC_DB_ERR BIT(15) | 530 | #define RTI_ECC_DB_ERR s2BIT(15) |
531 | #define RTI_SM_ERR_ALARM BIT(23) | 531 | #define RTI_SM_ERR_ALARM s2BIT(23) |
532 | u64 rti_err_mask; | 532 | u64 rti_err_mask; |
533 | u64 rti_err_alarm; | 533 | u64 rti_err_alarm; |
534 | 534 | ||
@@ -568,49 +568,49 @@ struct XENA_dev_config { | |||
568 | #endif | 568 | #endif |
569 | u64 prc_rxd0_n[RX_MAX_RINGS]; | 569 | u64 prc_rxd0_n[RX_MAX_RINGS]; |
570 | u64 prc_ctrl_n[RX_MAX_RINGS]; | 570 | u64 prc_ctrl_n[RX_MAX_RINGS]; |
571 | #define PRC_CTRL_RC_ENABLED BIT(7) | 571 | #define PRC_CTRL_RC_ENABLED s2BIT(7) |
572 | #define PRC_CTRL_RING_MODE (BIT(14)|BIT(15)) | 572 | #define PRC_CTRL_RING_MODE (s2BIT(14)|s2BIT(15)) |
573 | #define PRC_CTRL_RING_MODE_1 vBIT(0,14,2) | 573 | #define PRC_CTRL_RING_MODE_1 vBIT(0,14,2) |
574 | #define PRC_CTRL_RING_MODE_3 vBIT(1,14,2) | 574 | #define PRC_CTRL_RING_MODE_3 vBIT(1,14,2) |
575 | #define PRC_CTRL_RING_MODE_5 vBIT(2,14,2) | 575 | #define PRC_CTRL_RING_MODE_5 vBIT(2,14,2) |
576 | #define PRC_CTRL_RING_MODE_x vBIT(3,14,2) | 576 | #define PRC_CTRL_RING_MODE_x vBIT(3,14,2) |
577 | #define PRC_CTRL_NO_SNOOP (BIT(22)|BIT(23)) | 577 | #define PRC_CTRL_NO_SNOOP (s2BIT(22)|s2BIT(23)) |
578 | #define PRC_CTRL_NO_SNOOP_DESC BIT(22) | 578 | #define PRC_CTRL_NO_SNOOP_DESC s2BIT(22) |
579 | #define PRC_CTRL_NO_SNOOP_BUFF BIT(23) | 579 | #define PRC_CTRL_NO_SNOOP_BUFF s2BIT(23) |
580 | #define PRC_CTRL_BIMODAL_INTERRUPT BIT(37) | 580 | #define PRC_CTRL_BIMODAL_INTERRUPT s2BIT(37) |
581 | #define PRC_CTRL_GROUP_READS BIT(38) | 581 | #define PRC_CTRL_GROUP_READS s2BIT(38) |
582 | #define PRC_CTRL_RXD_BACKOFF_INTERVAL(val) vBIT(val,40,24) | 582 | #define PRC_CTRL_RXD_BACKOFF_INTERVAL(val) vBIT(val,40,24) |
583 | 583 | ||
584 | u64 prc_alarm_action; | 584 | u64 prc_alarm_action; |
585 | #define PRC_ALARM_ACTION_RR_R0_STOP BIT(3) | 585 | #define PRC_ALARM_ACTION_RR_R0_STOP s2BIT(3) |
586 | #define PRC_ALARM_ACTION_RW_R0_STOP BIT(7) | 586 | #define PRC_ALARM_ACTION_RW_R0_STOP s2BIT(7) |
587 | #define PRC_ALARM_ACTION_RR_R1_STOP BIT(11) | 587 | #define PRC_ALARM_ACTION_RR_R1_STOP s2BIT(11) |
588 | #define PRC_ALARM_ACTION_RW_R1_STOP BIT(15) | 588 | #define PRC_ALARM_ACTION_RW_R1_STOP s2BIT(15) |
589 | #define PRC_ALARM_ACTION_RR_R2_STOP BIT(19) | 589 | #define PRC_ALARM_ACTION_RR_R2_STOP s2BIT(19) |
590 | #define PRC_ALARM_ACTION_RW_R2_STOP BIT(23) | 590 | #define PRC_ALARM_ACTION_RW_R2_STOP s2BIT(23) |
591 | #define PRC_ALARM_ACTION_RR_R3_STOP BIT(27) | 591 | #define PRC_ALARM_ACTION_RR_R3_STOP s2BIT(27) |
592 | #define PRC_ALARM_ACTION_RW_R3_STOP BIT(31) | 592 | #define PRC_ALARM_ACTION_RW_R3_STOP s2BIT(31) |
593 | #define PRC_ALARM_ACTION_RR_R4_STOP BIT(35) | 593 | #define PRC_ALARM_ACTION_RR_R4_STOP s2BIT(35) |
594 | #define PRC_ALARM_ACTION_RW_R4_STOP BIT(39) | 594 | #define PRC_ALARM_ACTION_RW_R4_STOP s2BIT(39) |
595 | #define PRC_ALARM_ACTION_RR_R5_STOP BIT(43) | 595 | #define PRC_ALARM_ACTION_RR_R5_STOP s2BIT(43) |
596 | #define PRC_ALARM_ACTION_RW_R5_STOP BIT(47) | 596 | #define PRC_ALARM_ACTION_RW_R5_STOP s2BIT(47) |
597 | #define PRC_ALARM_ACTION_RR_R6_STOP BIT(51) | 597 | #define PRC_ALARM_ACTION_RR_R6_STOP s2BIT(51) |
598 | #define PRC_ALARM_ACTION_RW_R6_STOP BIT(55) | 598 | #define PRC_ALARM_ACTION_RW_R6_STOP s2BIT(55) |
599 | #define PRC_ALARM_ACTION_RR_R7_STOP BIT(59) | 599 | #define PRC_ALARM_ACTION_RR_R7_STOP s2BIT(59) |
600 | #define PRC_ALARM_ACTION_RW_R7_STOP BIT(63) | 600 | #define PRC_ALARM_ACTION_RW_R7_STOP s2BIT(63) |
601 | 601 | ||
602 | /* Receive traffic interrupts */ | 602 | /* Receive traffic interrupts */ |
603 | u64 rti_command_mem; | 603 | u64 rti_command_mem; |
604 | #define RTI_CMD_MEM_WE BIT(7) | 604 | #define RTI_CMD_MEM_WE s2BIT(7) |
605 | #define RTI_CMD_MEM_STROBE BIT(15) | 605 | #define RTI_CMD_MEM_STROBE s2BIT(15) |
606 | #define RTI_CMD_MEM_STROBE_NEW_CMD BIT(15) | 606 | #define RTI_CMD_MEM_STROBE_NEW_CMD s2BIT(15) |
607 | #define RTI_CMD_MEM_STROBE_CMD_BEING_EXECUTED BIT(15) | 607 | #define RTI_CMD_MEM_STROBE_CMD_BEING_EXECUTED s2BIT(15) |
608 | #define RTI_CMD_MEM_OFFSET(n) vBIT(n,29,3) | 608 | #define RTI_CMD_MEM_OFFSET(n) vBIT(n,29,3) |
609 | 609 | ||
610 | u64 rti_data1_mem; | 610 | u64 rti_data1_mem; |
611 | #define RTI_DATA1_MEM_RX_TIMER_VAL(n) vBIT(n,3,29) | 611 | #define RTI_DATA1_MEM_RX_TIMER_VAL(n) vBIT(n,3,29) |
612 | #define RTI_DATA1_MEM_RX_TIMER_AC_EN BIT(38) | 612 | #define RTI_DATA1_MEM_RX_TIMER_AC_EN s2BIT(38) |
613 | #define RTI_DATA1_MEM_RX_TIMER_CI_EN BIT(39) | 613 | #define RTI_DATA1_MEM_RX_TIMER_CI_EN s2BIT(39) |
614 | #define RTI_DATA1_MEM_RX_URNG_A(n) vBIT(n,41,7) | 614 | #define RTI_DATA1_MEM_RX_URNG_A(n) vBIT(n,41,7) |
615 | #define RTI_DATA1_MEM_RX_URNG_B(n) vBIT(n,49,7) | 615 | #define RTI_DATA1_MEM_RX_URNG_B(n) vBIT(n,49,7) |
616 | #define RTI_DATA1_MEM_RX_URNG_C(n) vBIT(n,57,7) | 616 | #define RTI_DATA1_MEM_RX_URNG_C(n) vBIT(n,57,7) |
@@ -622,10 +622,10 @@ struct XENA_dev_config { | |||
622 | #define RTI_DATA2_MEM_RX_UFC_D(n) vBIT(n,48,16) | 622 | #define RTI_DATA2_MEM_RX_UFC_D(n) vBIT(n,48,16) |
623 | 623 | ||
624 | u64 rx_pa_cfg; | 624 | u64 rx_pa_cfg; |
625 | #define RX_PA_CFG_IGNORE_FRM_ERR BIT(1) | 625 | #define RX_PA_CFG_IGNORE_FRM_ERR s2BIT(1) |
626 | #define RX_PA_CFG_IGNORE_SNAP_OUI BIT(2) | 626 | #define RX_PA_CFG_IGNORE_SNAP_OUI s2BIT(2) |
627 | #define RX_PA_CFG_IGNORE_LLC_CTRL BIT(3) | 627 | #define RX_PA_CFG_IGNORE_LLC_CTRL s2BIT(3) |
628 | #define RX_PA_CFG_IGNORE_L2_ERR BIT(6) | 628 | #define RX_PA_CFG_IGNORE_L2_ERR s2BIT(6) |
629 | 629 | ||
630 | u64 unused_11_1; | 630 | u64 unused_11_1; |
631 | 631 | ||
@@ -641,64 +641,64 @@ struct XENA_dev_config { | |||
641 | /* Media Access Controller Register */ | 641 | /* Media Access Controller Register */ |
642 | u64 mac_int_status; | 642 | u64 mac_int_status; |
643 | u64 mac_int_mask; | 643 | u64 mac_int_mask; |
644 | #define MAC_INT_STATUS_TMAC_INT BIT(0) | 644 | #define MAC_INT_STATUS_TMAC_INT s2BIT(0) |
645 | #define MAC_INT_STATUS_RMAC_INT BIT(1) | 645 | #define MAC_INT_STATUS_RMAC_INT s2BIT(1) |
646 | 646 | ||
647 | u64 mac_tmac_err_reg; | 647 | u64 mac_tmac_err_reg; |
648 | #define TMAC_ECC_SG_ERR BIT(7) | 648 | #define TMAC_ECC_SG_ERR s2BIT(7) |
649 | #define TMAC_ECC_DB_ERR BIT(15) | 649 | #define TMAC_ECC_DB_ERR s2BIT(15) |
650 | #define TMAC_TX_BUF_OVRN BIT(23) | 650 | #define TMAC_TX_BUF_OVRN s2BIT(23) |
651 | #define TMAC_TX_CRI_ERR BIT(31) | 651 | #define TMAC_TX_CRI_ERR s2BIT(31) |
652 | #define TMAC_TX_SM_ERR BIT(39) | 652 | #define TMAC_TX_SM_ERR s2BIT(39) |
653 | #define TMAC_DESC_ECC_SG_ERR BIT(47) | 653 | #define TMAC_DESC_ECC_SG_ERR s2BIT(47) |
654 | #define TMAC_DESC_ECC_DB_ERR BIT(55) | 654 | #define TMAC_DESC_ECC_DB_ERR s2BIT(55) |
655 | 655 | ||
656 | u64 mac_tmac_err_mask; | 656 | u64 mac_tmac_err_mask; |
657 | u64 mac_tmac_err_alarm; | 657 | u64 mac_tmac_err_alarm; |
658 | 658 | ||
659 | u64 mac_rmac_err_reg; | 659 | u64 mac_rmac_err_reg; |
660 | #define RMAC_RX_BUFF_OVRN BIT(0) | 660 | #define RMAC_RX_BUFF_OVRN s2BIT(0) |
661 | #define RMAC_FRM_RCVD_INT BIT(1) | 661 | #define RMAC_FRM_RCVD_INT s2BIT(1) |
662 | #define RMAC_UNUSED_INT BIT(2) | 662 | #define RMAC_UNUSED_INT s2BIT(2) |
663 | #define RMAC_RTS_PNUM_ECC_SG_ERR BIT(5) | 663 | #define RMAC_RTS_PNUM_ECC_SG_ERR s2BIT(5) |
664 | #define RMAC_RTS_DS_ECC_SG_ERR BIT(6) | 664 | #define RMAC_RTS_DS_ECC_SG_ERR s2BIT(6) |
665 | #define RMAC_RD_BUF_ECC_SG_ERR BIT(7) | 665 | #define RMAC_RD_BUF_ECC_SG_ERR s2BIT(7) |
666 | #define RMAC_RTH_MAP_ECC_SG_ERR BIT(8) | 666 | #define RMAC_RTH_MAP_ECC_SG_ERR s2BIT(8) |
667 | #define RMAC_RTH_SPDM_ECC_SG_ERR BIT(9) | 667 | #define RMAC_RTH_SPDM_ECC_SG_ERR s2BIT(9) |
668 | #define RMAC_RTS_VID_ECC_SG_ERR BIT(10) | 668 | #define RMAC_RTS_VID_ECC_SG_ERR s2BIT(10) |
669 | #define RMAC_DA_SHADOW_ECC_SG_ERR BIT(11) | 669 | #define RMAC_DA_SHADOW_ECC_SG_ERR s2BIT(11) |
670 | #define RMAC_RTS_PNUM_ECC_DB_ERR BIT(13) | 670 | #define RMAC_RTS_PNUM_ECC_DB_ERR s2BIT(13) |
671 | #define RMAC_RTS_DS_ECC_DB_ERR BIT(14) | 671 | #define RMAC_RTS_DS_ECC_DB_ERR s2BIT(14) |
672 | #define RMAC_RD_BUF_ECC_DB_ERR BIT(15) | 672 | #define RMAC_RD_BUF_ECC_DB_ERR s2BIT(15) |
673 | #define RMAC_RTH_MAP_ECC_DB_ERR BIT(16) | 673 | #define RMAC_RTH_MAP_ECC_DB_ERR s2BIT(16) |
674 | #define RMAC_RTH_SPDM_ECC_DB_ERR BIT(17) | 674 | #define RMAC_RTH_SPDM_ECC_DB_ERR s2BIT(17) |
675 | #define RMAC_RTS_VID_ECC_DB_ERR BIT(18) | 675 | #define RMAC_RTS_VID_ECC_DB_ERR s2BIT(18) |
676 | #define RMAC_DA_SHADOW_ECC_DB_ERR BIT(19) | 676 | #define RMAC_DA_SHADOW_ECC_DB_ERR s2BIT(19) |
677 | #define RMAC_LINK_STATE_CHANGE_INT BIT(31) | 677 | #define RMAC_LINK_STATE_CHANGE_INT s2BIT(31) |
678 | #define RMAC_RX_SM_ERR BIT(39) | 678 | #define RMAC_RX_SM_ERR s2BIT(39) |
679 | #define RMAC_SINGLE_ECC_ERR (BIT(5) | BIT(6) | BIT(7) |\ | 679 | #define RMAC_SINGLE_ECC_ERR (s2BIT(5) | s2BIT(6) | s2BIT(7) |\ |
680 | BIT(8) | BIT(9) | BIT(10)|\ | 680 | s2BIT(8) | s2BIT(9) | s2BIT(10)|\ |
681 | BIT(11)) | 681 | s2BIT(11)) |
682 | #define RMAC_DOUBLE_ECC_ERR (BIT(13) | BIT(14) | BIT(15) |\ | 682 | #define RMAC_DOUBLE_ECC_ERR (s2BIT(13) | s2BIT(14) | s2BIT(15) |\ |
683 | BIT(16) | BIT(17) | BIT(18)|\ | 683 | s2BIT(16) | s2BIT(17) | s2BIT(18)|\ |
684 | BIT(19)) | 684 | s2BIT(19)) |
685 | u64 mac_rmac_err_mask; | 685 | u64 mac_rmac_err_mask; |
686 | u64 mac_rmac_err_alarm; | 686 | u64 mac_rmac_err_alarm; |
687 | 687 | ||
688 | u8 unused14[0x100 - 0x40]; | 688 | u8 unused14[0x100 - 0x40]; |
689 | 689 | ||
690 | u64 mac_cfg; | 690 | u64 mac_cfg; |
691 | #define MAC_CFG_TMAC_ENABLE BIT(0) | 691 | #define MAC_CFG_TMAC_ENABLE s2BIT(0) |
692 | #define MAC_CFG_RMAC_ENABLE BIT(1) | 692 | #define MAC_CFG_RMAC_ENABLE s2BIT(1) |
693 | #define MAC_CFG_LAN_NOT_WAN BIT(2) | 693 | #define MAC_CFG_LAN_NOT_WAN s2BIT(2) |
694 | #define MAC_CFG_TMAC_LOOPBACK BIT(3) | 694 | #define MAC_CFG_TMAC_LOOPBACK s2BIT(3) |
695 | #define MAC_CFG_TMAC_APPEND_PAD BIT(4) | 695 | #define MAC_CFG_TMAC_APPEND_PAD s2BIT(4) |
696 | #define MAC_CFG_RMAC_STRIP_FCS BIT(5) | 696 | #define MAC_CFG_RMAC_STRIP_FCS s2BIT(5) |
697 | #define MAC_CFG_RMAC_STRIP_PAD BIT(6) | 697 | #define MAC_CFG_RMAC_STRIP_PAD s2BIT(6) |
698 | #define MAC_CFG_RMAC_PROM_ENABLE BIT(7) | 698 | #define MAC_CFG_RMAC_PROM_ENABLE s2BIT(7) |
699 | #define MAC_RMAC_DISCARD_PFRM BIT(8) | 699 | #define MAC_RMAC_DISCARD_PFRM s2BIT(8) |
700 | #define MAC_RMAC_BCAST_ENABLE BIT(9) | 700 | #define MAC_RMAC_BCAST_ENABLE s2BIT(9) |
701 | #define MAC_RMAC_ALL_ADDR_ENABLE BIT(10) | 701 | #define MAC_RMAC_ALL_ADDR_ENABLE s2BIT(10) |
702 | #define MAC_RMAC_INVLD_IPG_THR(val) vBIT(val,16,8) | 702 | #define MAC_RMAC_INVLD_IPG_THR(val) vBIT(val,16,8) |
703 | 703 | ||
704 | u64 tmac_avg_ipg; | 704 | u64 tmac_avg_ipg; |
@@ -710,14 +710,14 @@ struct XENA_dev_config { | |||
710 | #define RMAC_MAX_PYLD_LEN_JUMBO_DEF vBIT(9600,2,14) | 710 | #define RMAC_MAX_PYLD_LEN_JUMBO_DEF vBIT(9600,2,14) |
711 | 711 | ||
712 | u64 rmac_err_cfg; | 712 | u64 rmac_err_cfg; |
713 | #define RMAC_ERR_FCS BIT(0) | 713 | #define RMAC_ERR_FCS s2BIT(0) |
714 | #define RMAC_ERR_FCS_ACCEPT BIT(1) | 714 | #define RMAC_ERR_FCS_ACCEPT s2BIT(1) |
715 | #define RMAC_ERR_TOO_LONG BIT(1) | 715 | #define RMAC_ERR_TOO_LONG s2BIT(1) |
716 | #define RMAC_ERR_TOO_LONG_ACCEPT BIT(1) | 716 | #define RMAC_ERR_TOO_LONG_ACCEPT s2BIT(1) |
717 | #define RMAC_ERR_RUNT BIT(2) | 717 | #define RMAC_ERR_RUNT s2BIT(2) |
718 | #define RMAC_ERR_RUNT_ACCEPT BIT(2) | 718 | #define RMAC_ERR_RUNT_ACCEPT s2BIT(2) |
719 | #define RMAC_ERR_LEN_MISMATCH BIT(3) | 719 | #define RMAC_ERR_LEN_MISMATCH s2BIT(3) |
720 | #define RMAC_ERR_LEN_MISMATCH_ACCEPT BIT(3) | 720 | #define RMAC_ERR_LEN_MISMATCH_ACCEPT s2BIT(3) |
721 | 721 | ||
722 | u64 rmac_cfg_key; | 722 | u64 rmac_cfg_key; |
723 | #define RMAC_CFG_KEY(val) vBIT(val,0,16) | 723 | #define RMAC_CFG_KEY(val) vBIT(val,0,16) |
@@ -728,15 +728,15 @@ struct XENA_dev_config { | |||
728 | #define MAC_MC_ADDR_START_OFFSET 16 | 728 | #define MAC_MC_ADDR_START_OFFSET 16 |
729 | #define MAC_MC_ALL_MC_ADDR_OFFSET 63 /* enables all multicast pkts */ | 729 | #define MAC_MC_ALL_MC_ADDR_OFFSET 63 /* enables all multicast pkts */ |
730 | u64 rmac_addr_cmd_mem; | 730 | u64 rmac_addr_cmd_mem; |
731 | #define RMAC_ADDR_CMD_MEM_WE BIT(7) | 731 | #define RMAC_ADDR_CMD_MEM_WE s2BIT(7) |
732 | #define RMAC_ADDR_CMD_MEM_RD 0 | 732 | #define RMAC_ADDR_CMD_MEM_RD 0 |
733 | #define RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD BIT(15) | 733 | #define RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD s2BIT(15) |
734 | #define RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING BIT(15) | 734 | #define RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING s2BIT(15) |
735 | #define RMAC_ADDR_CMD_MEM_OFFSET(n) vBIT(n,26,6) | 735 | #define RMAC_ADDR_CMD_MEM_OFFSET(n) vBIT(n,26,6) |
736 | 736 | ||
737 | u64 rmac_addr_data0_mem; | 737 | u64 rmac_addr_data0_mem; |
738 | #define RMAC_ADDR_DATA0_MEM_ADDR(n) vBIT(n,0,48) | 738 | #define RMAC_ADDR_DATA0_MEM_ADDR(n) vBIT(n,0,48) |
739 | #define RMAC_ADDR_DATA0_MEM_USER BIT(48) | 739 | #define RMAC_ADDR_DATA0_MEM_USER s2BIT(48) |
740 | 740 | ||
741 | u64 rmac_addr_data1_mem; | 741 | u64 rmac_addr_data1_mem; |
742 | #define RMAC_ADDR_DATA1_MEM_MASK(n) vBIT(n,0,48) | 742 | #define RMAC_ADDR_DATA1_MEM_MASK(n) vBIT(n,0,48) |
@@ -753,10 +753,10 @@ struct XENA_dev_config { | |||
753 | u64 tmac_ipg_cfg; | 753 | u64 tmac_ipg_cfg; |
754 | 754 | ||
755 | u64 rmac_pause_cfg; | 755 | u64 rmac_pause_cfg; |
756 | #define RMAC_PAUSE_GEN BIT(0) | 756 | #define RMAC_PAUSE_GEN s2BIT(0) |
757 | #define RMAC_PAUSE_GEN_ENABLE BIT(0) | 757 | #define RMAC_PAUSE_GEN_ENABLE s2BIT(0) |
758 | #define RMAC_PAUSE_RX BIT(1) | 758 | #define RMAC_PAUSE_RX s2BIT(1) |
759 | #define RMAC_PAUSE_RX_ENABLE BIT(1) | 759 | #define RMAC_PAUSE_RX_ENABLE s2BIT(1) |
760 | #define RMAC_PAUSE_HG_PTIME_DEF vBIT(0xFFFF,16,16) | 760 | #define RMAC_PAUSE_HG_PTIME_DEF vBIT(0xFFFF,16,16) |
761 | #define RMAC_PAUSE_HG_PTIME(val) vBIT(val,16,16) | 761 | #define RMAC_PAUSE_HG_PTIME(val) vBIT(val,16,16) |
762 | 762 | ||
@@ -787,29 +787,29 @@ struct XENA_dev_config { | |||
787 | #define MAX_DIX_MAP 4 | 787 | #define MAX_DIX_MAP 4 |
788 | u64 rts_dix_map_n[MAX_DIX_MAP]; | 788 | u64 rts_dix_map_n[MAX_DIX_MAP]; |
789 | #define RTS_DIX_MAP_ETYPE(val) vBIT(val,0,16) | 789 | #define RTS_DIX_MAP_ETYPE(val) vBIT(val,0,16) |
790 | #define RTS_DIX_MAP_SCW(val) BIT(val,21) | 790 | #define RTS_DIX_MAP_SCW(val) s2BIT(val,21) |
791 | 791 | ||
792 | u64 rts_q_alternates; | 792 | u64 rts_q_alternates; |
793 | u64 rts_default_q; | 793 | u64 rts_default_q; |
794 | 794 | ||
795 | u64 rts_ctrl; | 795 | u64 rts_ctrl; |
796 | #define RTS_CTRL_IGNORE_SNAP_OUI BIT(2) | 796 | #define RTS_CTRL_IGNORE_SNAP_OUI s2BIT(2) |
797 | #define RTS_CTRL_IGNORE_LLC_CTRL BIT(3) | 797 | #define RTS_CTRL_IGNORE_LLC_CTRL s2BIT(3) |
798 | 798 | ||
799 | u64 rts_pn_cam_ctrl; | 799 | u64 rts_pn_cam_ctrl; |
800 | #define RTS_PN_CAM_CTRL_WE BIT(7) | 800 | #define RTS_PN_CAM_CTRL_WE s2BIT(7) |
801 | #define RTS_PN_CAM_CTRL_STROBE_NEW_CMD BIT(15) | 801 | #define RTS_PN_CAM_CTRL_STROBE_NEW_CMD s2BIT(15) |
802 | #define RTS_PN_CAM_CTRL_STROBE_BEING_EXECUTED BIT(15) | 802 | #define RTS_PN_CAM_CTRL_STROBE_BEING_EXECUTED s2BIT(15) |
803 | #define RTS_PN_CAM_CTRL_OFFSET(n) vBIT(n,24,8) | 803 | #define RTS_PN_CAM_CTRL_OFFSET(n) vBIT(n,24,8) |
804 | u64 rts_pn_cam_data; | 804 | u64 rts_pn_cam_data; |
805 | #define RTS_PN_CAM_DATA_TCP_SELECT BIT(7) | 805 | #define RTS_PN_CAM_DATA_TCP_SELECT s2BIT(7) |
806 | #define RTS_PN_CAM_DATA_PORT(val) vBIT(val,8,16) | 806 | #define RTS_PN_CAM_DATA_PORT(val) vBIT(val,8,16) |
807 | #define RTS_PN_CAM_DATA_SCW(val) vBIT(val,24,8) | 807 | #define RTS_PN_CAM_DATA_SCW(val) vBIT(val,24,8) |
808 | 808 | ||
809 | u64 rts_ds_mem_ctrl; | 809 | u64 rts_ds_mem_ctrl; |
810 | #define RTS_DS_MEM_CTRL_WE BIT(7) | 810 | #define RTS_DS_MEM_CTRL_WE s2BIT(7) |
811 | #define RTS_DS_MEM_CTRL_STROBE_NEW_CMD BIT(15) | 811 | #define RTS_DS_MEM_CTRL_STROBE_NEW_CMD s2BIT(15) |
812 | #define RTS_DS_MEM_CTRL_STROBE_CMD_BEING_EXECUTED BIT(15) | 812 | #define RTS_DS_MEM_CTRL_STROBE_CMD_BEING_EXECUTED s2BIT(15) |
813 | #define RTS_DS_MEM_CTRL_OFFSET(n) vBIT(n,26,6) | 813 | #define RTS_DS_MEM_CTRL_OFFSET(n) vBIT(n,26,6) |
814 | u64 rts_ds_mem_data; | 814 | u64 rts_ds_mem_data; |
815 | #define RTS_DS_MEM_DATA(n) vBIT(n,0,8) | 815 | #define RTS_DS_MEM_DATA(n) vBIT(n,0,8) |
@@ -823,23 +823,23 @@ struct XENA_dev_config { | |||
823 | 823 | ||
824 | /* memory controller registers */ | 824 | /* memory controller registers */ |
825 | u64 mc_int_status; | 825 | u64 mc_int_status; |
826 | #define MC_INT_STATUS_MC_INT BIT(0) | 826 | #define MC_INT_STATUS_MC_INT s2BIT(0) |
827 | u64 mc_int_mask; | 827 | u64 mc_int_mask; |
828 | #define MC_INT_MASK_MC_INT BIT(0) | 828 | #define MC_INT_MASK_MC_INT s2BIT(0) |
829 | 829 | ||
830 | u64 mc_err_reg; | 830 | u64 mc_err_reg; |
831 | #define MC_ERR_REG_ECC_DB_ERR_L BIT(14) | 831 | #define MC_ERR_REG_ECC_DB_ERR_L s2BIT(14) |
832 | #define MC_ERR_REG_ECC_DB_ERR_U BIT(15) | 832 | #define MC_ERR_REG_ECC_DB_ERR_U s2BIT(15) |
833 | #define MC_ERR_REG_MIRI_ECC_DB_ERR_0 BIT(18) | 833 | #define MC_ERR_REG_MIRI_ECC_DB_ERR_0 s2BIT(18) |
834 | #define MC_ERR_REG_MIRI_ECC_DB_ERR_1 BIT(20) | 834 | #define MC_ERR_REG_MIRI_ECC_DB_ERR_1 s2BIT(20) |
835 | #define MC_ERR_REG_MIRI_CRI_ERR_0 BIT(22) | 835 | #define MC_ERR_REG_MIRI_CRI_ERR_0 s2BIT(22) |
836 | #define MC_ERR_REG_MIRI_CRI_ERR_1 BIT(23) | 836 | #define MC_ERR_REG_MIRI_CRI_ERR_1 s2BIT(23) |
837 | #define MC_ERR_REG_SM_ERR BIT(31) | 837 | #define MC_ERR_REG_SM_ERR s2BIT(31) |
838 | #define MC_ERR_REG_ECC_ALL_SNG (BIT(2) | BIT(3) | BIT(4) | BIT(5) |\ | 838 | #define MC_ERR_REG_ECC_ALL_SNG (s2BIT(2) | s2BIT(3) | s2BIT(4) | s2BIT(5) |\ |
839 | BIT(17) | BIT(19)) | 839 | s2BIT(17) | s2BIT(19)) |
840 | #define MC_ERR_REG_ECC_ALL_DBL (BIT(10) | BIT(11) | BIT(12) |\ | 840 | #define MC_ERR_REG_ECC_ALL_DBL (s2BIT(10) | s2BIT(11) | s2BIT(12) |\ |
841 | BIT(13) | BIT(18) | BIT(20)) | 841 | s2BIT(13) | s2BIT(18) | s2BIT(20)) |
842 | #define PLL_LOCK_N BIT(39) | 842 | #define PLL_LOCK_N s2BIT(39) |
843 | u64 mc_err_mask; | 843 | u64 mc_err_mask; |
844 | u64 mc_err_alarm; | 844 | u64 mc_err_alarm; |
845 | 845 | ||
@@ -857,8 +857,8 @@ struct XENA_dev_config { | |||
857 | #define RX_QUEUE_CFG_Q7_SZ(n) vBIT(n,56,8) | 857 | #define RX_QUEUE_CFG_Q7_SZ(n) vBIT(n,56,8) |
858 | 858 | ||
859 | u64 mc_rldram_mrs; | 859 | u64 mc_rldram_mrs; |
860 | #define MC_RLDRAM_QUEUE_SIZE_ENABLE BIT(39) | 860 | #define MC_RLDRAM_QUEUE_SIZE_ENABLE s2BIT(39) |
861 | #define MC_RLDRAM_MRS_ENABLE BIT(47) | 861 | #define MC_RLDRAM_MRS_ENABLE s2BIT(47) |
862 | 862 | ||
863 | u64 mc_rldram_interleave; | 863 | u64 mc_rldram_interleave; |
864 | 864 | ||
@@ -871,11 +871,11 @@ struct XENA_dev_config { | |||
871 | u64 mc_rldram_ref_per; | 871 | u64 mc_rldram_ref_per; |
872 | u8 unused20[0x220 - 0x208]; | 872 | u8 unused20[0x220 - 0x208]; |
873 | u64 mc_rldram_test_ctrl; | 873 | u64 mc_rldram_test_ctrl; |
874 | #define MC_RLDRAM_TEST_MODE BIT(47) | 874 | #define MC_RLDRAM_TEST_MODE s2BIT(47) |
875 | #define MC_RLDRAM_TEST_WRITE BIT(7) | 875 | #define MC_RLDRAM_TEST_WRITE s2BIT(7) |
876 | #define MC_RLDRAM_TEST_GO BIT(15) | 876 | #define MC_RLDRAM_TEST_GO s2BIT(15) |
877 | #define MC_RLDRAM_TEST_DONE BIT(23) | 877 | #define MC_RLDRAM_TEST_DONE s2BIT(23) |
878 | #define MC_RLDRAM_TEST_PASS BIT(31) | 878 | #define MC_RLDRAM_TEST_PASS s2BIT(31) |
879 | 879 | ||
880 | u8 unused21[0x240 - 0x228]; | 880 | u8 unused21[0x240 - 0x228]; |
881 | u64 mc_rldram_test_add; | 881 | u64 mc_rldram_test_add; |
@@ -888,7 +888,7 @@ struct XENA_dev_config { | |||
888 | 888 | ||
889 | u8 unused24_1[0x360 - 0x308]; | 889 | u8 unused24_1[0x360 - 0x308]; |
890 | u64 mc_rldram_ctrl; | 890 | u64 mc_rldram_ctrl; |
891 | #define MC_RLDRAM_ENABLE_ODT BIT(7) | 891 | #define MC_RLDRAM_ENABLE_ODT s2BIT(7) |
892 | 892 | ||
893 | u8 unused24_2[0x640 - 0x368]; | 893 | u8 unused24_2[0x640 - 0x368]; |
894 | u64 mc_rldram_ref_per_herc; | 894 | u64 mc_rldram_ref_per_herc; |
@@ -906,24 +906,24 @@ struct XENA_dev_config { | |||
906 | /* XGXS control registers */ | 906 | /* XGXS control registers */ |
907 | 907 | ||
908 | u64 xgxs_int_status; | 908 | u64 xgxs_int_status; |
909 | #define XGXS_INT_STATUS_TXGXS BIT(0) | 909 | #define XGXS_INT_STATUS_TXGXS s2BIT(0) |
910 | #define XGXS_INT_STATUS_RXGXS BIT(1) | 910 | #define XGXS_INT_STATUS_RXGXS s2BIT(1) |
911 | u64 xgxs_int_mask; | 911 | u64 xgxs_int_mask; |
912 | #define XGXS_INT_MASK_TXGXS BIT(0) | 912 | #define XGXS_INT_MASK_TXGXS s2BIT(0) |
913 | #define XGXS_INT_MASK_RXGXS BIT(1) | 913 | #define XGXS_INT_MASK_RXGXS s2BIT(1) |
914 | 914 | ||
915 | u64 xgxs_txgxs_err_reg; | 915 | u64 xgxs_txgxs_err_reg; |
916 | #define TXGXS_ECC_SG_ERR BIT(7) | 916 | #define TXGXS_ECC_SG_ERR s2BIT(7) |
917 | #define TXGXS_ECC_DB_ERR BIT(15) | 917 | #define TXGXS_ECC_DB_ERR s2BIT(15) |
918 | #define TXGXS_ESTORE_UFLOW BIT(31) | 918 | #define TXGXS_ESTORE_UFLOW s2BIT(31) |
919 | #define TXGXS_TX_SM_ERR BIT(39) | 919 | #define TXGXS_TX_SM_ERR s2BIT(39) |
920 | 920 | ||
921 | u64 xgxs_txgxs_err_mask; | 921 | u64 xgxs_txgxs_err_mask; |
922 | u64 xgxs_txgxs_err_alarm; | 922 | u64 xgxs_txgxs_err_alarm; |
923 | 923 | ||
924 | u64 xgxs_rxgxs_err_reg; | 924 | u64 xgxs_rxgxs_err_reg; |
925 | #define RXGXS_ESTORE_OFLOW BIT(7) | 925 | #define RXGXS_ESTORE_OFLOW s2BIT(7) |
926 | #define RXGXS_RX_SM_ERR BIT(39) | 926 | #define RXGXS_RX_SM_ERR s2BIT(39) |
927 | u64 xgxs_rxgxs_err_mask; | 927 | u64 xgxs_rxgxs_err_mask; |
928 | u64 xgxs_rxgxs_err_alarm; | 928 | u64 xgxs_rxgxs_err_alarm; |
929 | 929 | ||
@@ -942,10 +942,10 @@ struct XENA_dev_config { | |||
942 | #define SPI_CONTROL_BYTECNT(cnt) vBIT(cnt,29,3) | 942 | #define SPI_CONTROL_BYTECNT(cnt) vBIT(cnt,29,3) |
943 | #define SPI_CONTROL_CMD(cmd) vBIT(cmd,32,8) | 943 | #define SPI_CONTROL_CMD(cmd) vBIT(cmd,32,8) |
944 | #define SPI_CONTROL_ADDR(addr) vBIT(addr,40,24) | 944 | #define SPI_CONTROL_ADDR(addr) vBIT(addr,40,24) |
945 | #define SPI_CONTROL_SEL1 BIT(4) | 945 | #define SPI_CONTROL_SEL1 s2BIT(4) |
946 | #define SPI_CONTROL_REQ BIT(7) | 946 | #define SPI_CONTROL_REQ s2BIT(7) |
947 | #define SPI_CONTROL_NACK BIT(5) | 947 | #define SPI_CONTROL_NACK s2BIT(5) |
948 | #define SPI_CONTROL_DONE BIT(6) | 948 | #define SPI_CONTROL_DONE s2BIT(6) |
949 | u64 spi_data; | 949 | u64 spi_data; |
950 | #define SPI_DATA_WRITE(data,len) vBIT(data,0,len) | 950 | #define SPI_DATA_WRITE(data,len) vBIT(data,0,len) |
951 | }; | 951 | }; |
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 22e4054d4fcb..b8c0e7b4ca1c 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -1716,7 +1716,7 @@ static int init_nic(struct s2io_nic *nic) | |||
1716 | MISC_LINK_STABILITY_PRD(3); | 1716 | MISC_LINK_STABILITY_PRD(3); |
1717 | writeq(val64, &bar0->misc_control); | 1717 | writeq(val64, &bar0->misc_control); |
1718 | val64 = readq(&bar0->pic_control2); | 1718 | val64 = readq(&bar0->pic_control2); |
1719 | val64 &= ~(BIT(13)|BIT(14)|BIT(15)); | 1719 | val64 &= ~(s2BIT(13)|s2BIT(14)|s2BIT(15)); |
1720 | writeq(val64, &bar0->pic_control2); | 1720 | writeq(val64, &bar0->pic_control2); |
1721 | } | 1721 | } |
1722 | if (strstr(nic->product_name, "CX4")) { | 1722 | if (strstr(nic->product_name, "CX4")) { |
@@ -2427,7 +2427,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2427 | } | 2427 | } |
2428 | if ((rxdp->Control_1 & RXD_OWN_XENA) && | 2428 | if ((rxdp->Control_1 & RXD_OWN_XENA) && |
2429 | ((nic->rxd_mode == RXD_MODE_3B) && | 2429 | ((nic->rxd_mode == RXD_MODE_3B) && |
2430 | (rxdp->Control_2 & BIT(0)))) { | 2430 | (rxdp->Control_2 & s2BIT(0)))) { |
2431 | mac_control->rings[ring_no].rx_curr_put_info. | 2431 | mac_control->rings[ring_no].rx_curr_put_info. |
2432 | offset = off; | 2432 | offset = off; |
2433 | goto end; | 2433 | goto end; |
@@ -2540,7 +2540,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) | |||
2540 | rxdp->Control_2 |= SET_BUFFER2_SIZE_3 | 2540 | rxdp->Control_2 |= SET_BUFFER2_SIZE_3 |
2541 | (dev->mtu + 4); | 2541 | (dev->mtu + 4); |
2542 | } | 2542 | } |
2543 | rxdp->Control_2 |= BIT(0); | 2543 | rxdp->Control_2 |= s2BIT(0); |
2544 | } | 2544 | } |
2545 | rxdp->Host_Control = (unsigned long) (skb); | 2545 | rxdp->Host_Control = (unsigned long) (skb); |
2546 | if (alloc_tab & ((1 << rxsync_frequency) - 1)) | 2546 | if (alloc_tab & ((1 << rxsync_frequency) - 1)) |
@@ -3377,7 +3377,7 @@ static void s2io_reset(struct s2io_nic * sp) | |||
3377 | pci_write_config_dword(sp->pdev, 0x68, 0x7C); | 3377 | pci_write_config_dword(sp->pdev, 0x68, 0x7C); |
3378 | 3378 | ||
3379 | /* Clearing PCI_STATUS error reflected here */ | 3379 | /* Clearing PCI_STATUS error reflected here */ |
3380 | writeq(BIT(62), &bar0->txpic_int_reg); | 3380 | writeq(s2BIT(62), &bar0->txpic_int_reg); |
3381 | } | 3381 | } |
3382 | 3382 | ||
3383 | /* Reset device statistics maintained by OS */ | 3383 | /* Reset device statistics maintained by OS */ |
@@ -3575,7 +3575,7 @@ static int wait_for_msix_trans(struct s2io_nic *nic, int i) | |||
3575 | 3575 | ||
3576 | do { | 3576 | do { |
3577 | val64 = readq(&bar0->xmsi_access); | 3577 | val64 = readq(&bar0->xmsi_access); |
3578 | if (!(val64 & BIT(15))) | 3578 | if (!(val64 & s2BIT(15))) |
3579 | break; | 3579 | break; |
3580 | mdelay(1); | 3580 | mdelay(1); |
3581 | cnt++; | 3581 | cnt++; |
@@ -3597,7 +3597,7 @@ static void restore_xmsi_data(struct s2io_nic *nic) | |||
3597 | for (i=0; i < MAX_REQUESTED_MSI_X; i++) { | 3597 | for (i=0; i < MAX_REQUESTED_MSI_X; i++) { |
3598 | writeq(nic->msix_info[i].addr, &bar0->xmsi_address); | 3598 | writeq(nic->msix_info[i].addr, &bar0->xmsi_address); |
3599 | writeq(nic->msix_info[i].data, &bar0->xmsi_data); | 3599 | writeq(nic->msix_info[i].data, &bar0->xmsi_data); |
3600 | val64 = (BIT(7) | BIT(15) | vBIT(i, 26, 6)); | 3600 | val64 = (s2BIT(7) | s2BIT(15) | vBIT(i, 26, 6)); |
3601 | writeq(val64, &bar0->xmsi_access); | 3601 | writeq(val64, &bar0->xmsi_access); |
3602 | if (wait_for_msix_trans(nic, i)) { | 3602 | if (wait_for_msix_trans(nic, i)) { |
3603 | DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__); | 3603 | DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__); |
@@ -3614,7 +3614,7 @@ static void store_xmsi_data(struct s2io_nic *nic) | |||
3614 | 3614 | ||
3615 | /* Store and display */ | 3615 | /* Store and display */ |
3616 | for (i=0; i < MAX_REQUESTED_MSI_X; i++) { | 3616 | for (i=0; i < MAX_REQUESTED_MSI_X; i++) { |
3617 | val64 = (BIT(15) | vBIT(i, 26, 6)); | 3617 | val64 = (s2BIT(15) | vBIT(i, 26, 6)); |
3618 | writeq(val64, &bar0->xmsi_access); | 3618 | writeq(val64, &bar0->xmsi_access); |
3619 | if (wait_for_msix_trans(nic, i)) { | 3619 | if (wait_for_msix_trans(nic, i)) { |
3620 | DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__); | 3620 | DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__); |
@@ -4634,7 +4634,7 @@ static void s2io_updt_stats(struct s2io_nic *sp) | |||
4634 | do { | 4634 | do { |
4635 | udelay(100); | 4635 | udelay(100); |
4636 | val64 = readq(&bar0->stat_cfg); | 4636 | val64 = readq(&bar0->stat_cfg); |
4637 | if (!(val64 & BIT(0))) | 4637 | if (!(val64 & s2BIT(0))) |
4638 | break; | 4638 | break; |
4639 | cnt++; | 4639 | cnt++; |
4640 | if (cnt == 5) | 4640 | if (cnt == 5) |
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h index f6b45565304f..cc1797a071aa 100644 --- a/drivers/net/s2io.h +++ b/drivers/net/s2io.h | |||
@@ -14,7 +14,7 @@ | |||
14 | #define _S2IO_H | 14 | #define _S2IO_H |
15 | 15 | ||
16 | #define TBD 0 | 16 | #define TBD 0 |
17 | #define BIT(loc) (0x8000000000000000ULL >> (loc)) | 17 | #define s2BIT(loc) (0x8000000000000000ULL >> (loc)) |
18 | #define vBIT(val, loc, sz) (((u64)val) << (64-loc-sz)) | 18 | #define vBIT(val, loc, sz) (((u64)val) << (64-loc-sz)) |
19 | #define INV(d) ((d&0xff)<<24) | (((d>>8)&0xff)<<16) | (((d>>16)&0xff)<<8)| ((d>>24)&0xff) | 19 | #define INV(d) ((d&0xff)<<24) | (((d>>8)&0xff)<<16) | (((d>>16)&0xff)<<8)| ((d>>24)&0xff) |
20 | 20 | ||
@@ -473,42 +473,42 @@ struct TxFIFO_element { | |||
473 | 473 | ||
474 | u64 List_Control; | 474 | u64 List_Control; |
475 | #define TX_FIFO_LAST_TXD_NUM( val) vBIT(val,0,8) | 475 | #define TX_FIFO_LAST_TXD_NUM( val) vBIT(val,0,8) |
476 | #define TX_FIFO_FIRST_LIST BIT(14) | 476 | #define TX_FIFO_FIRST_LIST s2BIT(14) |
477 | #define TX_FIFO_LAST_LIST BIT(15) | 477 | #define TX_FIFO_LAST_LIST s2BIT(15) |
478 | #define TX_FIFO_FIRSTNLAST_LIST vBIT(3,14,2) | 478 | #define TX_FIFO_FIRSTNLAST_LIST vBIT(3,14,2) |
479 | #define TX_FIFO_SPECIAL_FUNC BIT(23) | 479 | #define TX_FIFO_SPECIAL_FUNC s2BIT(23) |
480 | #define TX_FIFO_DS_NO_SNOOP BIT(31) | 480 | #define TX_FIFO_DS_NO_SNOOP s2BIT(31) |
481 | #define TX_FIFO_BUFF_NO_SNOOP BIT(30) | 481 | #define TX_FIFO_BUFF_NO_SNOOP s2BIT(30) |
482 | }; | 482 | }; |
483 | 483 | ||
484 | /* Tx descriptor structure */ | 484 | /* Tx descriptor structure */ |
485 | struct TxD { | 485 | struct TxD { |
486 | u64 Control_1; | 486 | u64 Control_1; |
487 | /* bit mask */ | 487 | /* bit mask */ |
488 | #define TXD_LIST_OWN_XENA BIT(7) | 488 | #define TXD_LIST_OWN_XENA s2BIT(7) |
489 | #define TXD_T_CODE (BIT(12)|BIT(13)|BIT(14)|BIT(15)) | 489 | #define TXD_T_CODE (s2BIT(12)|s2BIT(13)|s2BIT(14)|s2BIT(15)) |
490 | #define TXD_T_CODE_OK(val) (|(val & TXD_T_CODE)) | 490 | #define TXD_T_CODE_OK(val) (|(val & TXD_T_CODE)) |
491 | #define GET_TXD_T_CODE(val) ((val & TXD_T_CODE)<<12) | 491 | #define GET_TXD_T_CODE(val) ((val & TXD_T_CODE)<<12) |
492 | #define TXD_GATHER_CODE (BIT(22) | BIT(23)) | 492 | #define TXD_GATHER_CODE (s2BIT(22) | s2BIT(23)) |
493 | #define TXD_GATHER_CODE_FIRST BIT(22) | 493 | #define TXD_GATHER_CODE_FIRST s2BIT(22) |
494 | #define TXD_GATHER_CODE_LAST BIT(23) | 494 | #define TXD_GATHER_CODE_LAST s2BIT(23) |
495 | #define TXD_TCP_LSO_EN BIT(30) | 495 | #define TXD_TCP_LSO_EN s2BIT(30) |
496 | #define TXD_UDP_COF_EN BIT(31) | 496 | #define TXD_UDP_COF_EN s2BIT(31) |
497 | #define TXD_UFO_EN BIT(31) | BIT(30) | 497 | #define TXD_UFO_EN s2BIT(31) | s2BIT(30) |
498 | #define TXD_TCP_LSO_MSS(val) vBIT(val,34,14) | 498 | #define TXD_TCP_LSO_MSS(val) vBIT(val,34,14) |
499 | #define TXD_UFO_MSS(val) vBIT(val,34,14) | 499 | #define TXD_UFO_MSS(val) vBIT(val,34,14) |
500 | #define TXD_BUFFER0_SIZE(val) vBIT(val,48,16) | 500 | #define TXD_BUFFER0_SIZE(val) vBIT(val,48,16) |
501 | 501 | ||
502 | u64 Control_2; | 502 | u64 Control_2; |
503 | #define TXD_TX_CKO_CONTROL (BIT(5)|BIT(6)|BIT(7)) | 503 | #define TXD_TX_CKO_CONTROL (s2BIT(5)|s2BIT(6)|s2BIT(7)) |
504 | #define TXD_TX_CKO_IPV4_EN BIT(5) | 504 | #define TXD_TX_CKO_IPV4_EN s2BIT(5) |
505 | #define TXD_TX_CKO_TCP_EN BIT(6) | 505 | #define TXD_TX_CKO_TCP_EN s2BIT(6) |
506 | #define TXD_TX_CKO_UDP_EN BIT(7) | 506 | #define TXD_TX_CKO_UDP_EN s2BIT(7) |
507 | #define TXD_VLAN_ENABLE BIT(15) | 507 | #define TXD_VLAN_ENABLE s2BIT(15) |
508 | #define TXD_VLAN_TAG(val) vBIT(val,16,16) | 508 | #define TXD_VLAN_TAG(val) vBIT(val,16,16) |
509 | #define TXD_INT_NUMBER(val) vBIT(val,34,6) | 509 | #define TXD_INT_NUMBER(val) vBIT(val,34,6) |
510 | #define TXD_INT_TYPE_PER_LIST BIT(47) | 510 | #define TXD_INT_TYPE_PER_LIST s2BIT(47) |
511 | #define TXD_INT_TYPE_UTILZ BIT(46) | 511 | #define TXD_INT_TYPE_UTILZ s2BIT(46) |
512 | #define TXD_SET_MARKER vBIT(0x6,0,4) | 512 | #define TXD_SET_MARKER vBIT(0x6,0,4) |
513 | 513 | ||
514 | u64 Buffer_Pointer; | 514 | u64 Buffer_Pointer; |
@@ -525,14 +525,14 @@ struct list_info_hold { | |||
525 | struct RxD_t { | 525 | struct RxD_t { |
526 | u64 Host_Control; /* reserved for host */ | 526 | u64 Host_Control; /* reserved for host */ |
527 | u64 Control_1; | 527 | u64 Control_1; |
528 | #define RXD_OWN_XENA BIT(7) | 528 | #define RXD_OWN_XENA s2BIT(7) |
529 | #define RXD_T_CODE (BIT(12)|BIT(13)|BIT(14)|BIT(15)) | 529 | #define RXD_T_CODE (s2BIT(12)|s2BIT(13)|s2BIT(14)|s2BIT(15)) |
530 | #define RXD_FRAME_PROTO vBIT(0xFFFF,24,8) | 530 | #define RXD_FRAME_PROTO vBIT(0xFFFF,24,8) |
531 | #define RXD_FRAME_PROTO_IPV4 BIT(27) | 531 | #define RXD_FRAME_PROTO_IPV4 s2BIT(27) |
532 | #define RXD_FRAME_PROTO_IPV6 BIT(28) | 532 | #define RXD_FRAME_PROTO_IPV6 s2BIT(28) |
533 | #define RXD_FRAME_IP_FRAG BIT(29) | 533 | #define RXD_FRAME_IP_FRAG s2BIT(29) |
534 | #define RXD_FRAME_PROTO_TCP BIT(30) | 534 | #define RXD_FRAME_PROTO_TCP s2BIT(30) |
535 | #define RXD_FRAME_PROTO_UDP BIT(31) | 535 | #define RXD_FRAME_PROTO_UDP s2BIT(31) |
536 | #define TCP_OR_UDP_FRAME (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP) | 536 | #define TCP_OR_UDP_FRAME (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP) |
537 | #define RXD_GET_L3_CKSUM(val) ((u16)(val>> 16) & 0xFFFF) | 537 | #define RXD_GET_L3_CKSUM(val) ((u16)(val>> 16) & 0xFFFF) |
538 | #define RXD_GET_L4_CKSUM(val) ((u16)(val) & 0xFFFF) | 538 | #define RXD_GET_L4_CKSUM(val) ((u16)(val) & 0xFFFF) |
@@ -998,26 +998,26 @@ static inline void SPECIAL_REG_WRITE(u64 val, void __iomem *addr, int order) | |||
998 | /* Interrupt masks for the general interrupt mask register */ | 998 | /* Interrupt masks for the general interrupt mask register */ |
999 | #define DISABLE_ALL_INTRS 0xFFFFFFFFFFFFFFFFULL | 999 | #define DISABLE_ALL_INTRS 0xFFFFFFFFFFFFFFFFULL |
1000 | 1000 | ||
1001 | #define TXPIC_INT_M BIT(0) | 1001 | #define TXPIC_INT_M s2BIT(0) |
1002 | #define TXDMA_INT_M BIT(1) | 1002 | #define TXDMA_INT_M s2BIT(1) |
1003 | #define TXMAC_INT_M BIT(2) | 1003 | #define TXMAC_INT_M s2BIT(2) |
1004 | #define TXXGXS_INT_M BIT(3) | 1004 | #define TXXGXS_INT_M s2BIT(3) |
1005 | #define TXTRAFFIC_INT_M BIT(8) | 1005 | #define TXTRAFFIC_INT_M s2BIT(8) |
1006 | #define PIC_RX_INT_M BIT(32) | 1006 | #define PIC_RX_INT_M s2BIT(32) |
1007 | #define RXDMA_INT_M BIT(33) | 1007 | #define RXDMA_INT_M s2BIT(33) |
1008 | #define RXMAC_INT_M BIT(34) | 1008 | #define RXMAC_INT_M s2BIT(34) |
1009 | #define MC_INT_M BIT(35) | 1009 | #define MC_INT_M s2BIT(35) |
1010 | #define RXXGXS_INT_M BIT(36) | 1010 | #define RXXGXS_INT_M s2BIT(36) |
1011 | #define RXTRAFFIC_INT_M BIT(40) | 1011 | #define RXTRAFFIC_INT_M s2BIT(40) |
1012 | 1012 | ||
1013 | /* PIC level Interrupts TODO*/ | 1013 | /* PIC level Interrupts TODO*/ |
1014 | 1014 | ||
1015 | /* DMA level Inressupts */ | 1015 | /* DMA level Inressupts */ |
1016 | #define TXDMA_PFC_INT_M BIT(0) | 1016 | #define TXDMA_PFC_INT_M s2BIT(0) |
1017 | #define TXDMA_PCC_INT_M BIT(2) | 1017 | #define TXDMA_PCC_INT_M s2BIT(2) |
1018 | 1018 | ||
1019 | /* PFC block interrupts */ | 1019 | /* PFC block interrupts */ |
1020 | #define PFC_MISC_ERR_1 BIT(0) /* Interrupt to indicate FIFO full */ | 1020 | #define PFC_MISC_ERR_1 s2BIT(0) /* Interrupt to indicate FIFO full */ |
1021 | 1021 | ||
1022 | /* PCC block interrupts. */ | 1022 | /* PCC block interrupts. */ |
1023 | #define PCC_FB_ECC_ERR vBIT(0xff, 16, 8) /* Interrupt to indicate | 1023 | #define PCC_FB_ECC_ERR vBIT(0xff, 16, 8) /* Interrupt to indicate |
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index fab055ffcc90..571060a3c91e 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/vmalloc.h> | 46 | #include <linux/vmalloc.h> |
47 | #include <linux/wait.h> | 47 | #include <linux/wait.h> |
48 | #include <linux/workqueue.h> | 48 | #include <linux/workqueue.h> |
49 | #include <asm/bitops.h> | 49 | #include <linux/bitops.h> |
50 | #include <asm/pci-bridge.h> | 50 | #include <asm/pci-bridge.h> |
51 | #include <net/checksum.h> | 51 | #include <net/checksum.h> |
52 | 52 | ||
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c index 76e55612430b..a7afeea156bd 100644 --- a/drivers/net/tulip/uli526x.c +++ b/drivers/net/tulip/uli526x.c | |||
@@ -34,9 +34,9 @@ | |||
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
36 | #include <linux/dma-mapping.h> | 36 | #include <linux/dma-mapping.h> |
37 | #include <linux/bitops.h> | ||
37 | 38 | ||
38 | #include <asm/processor.h> | 39 | #include <asm/processor.h> |
39 | #include <asm/bitops.h> | ||
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | #include <asm/dma.h> | 41 | #include <asm/dma.h> |
42 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c index 8f198befba39..cb51dc51cce6 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "bcm43xx_radio.h" | 29 | #include "bcm43xx_radio.h" |
30 | #include "bcm43xx.h" | 30 | #include "bcm43xx.h" |
31 | 31 | ||
32 | #include <asm/bitops.h> | 32 | #include <linux/bitops.h> |
33 | 33 | ||
34 | 34 | ||
35 | static void bcm43xx_led_changestate(struct bcm43xx_led *led) | 35 | static void bcm43xx_led_changestate(struct bcm43xx_led *led) |
diff --git a/drivers/net/wireless/hostap/hostap_common.h b/drivers/net/wireless/hostap/hostap_common.h index ceb7f1e5e9e0..517f89845144 100644 --- a/drivers/net/wireless/hostap/hostap_common.h +++ b/drivers/net/wireless/hostap/hostap_common.h | |||
@@ -4,9 +4,6 @@ | |||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <linux/if_ether.h> | 5 | #include <linux/if_ether.h> |
6 | 6 | ||
7 | #define BIT(x) (1 << (x)) | ||
8 | |||
9 | |||
10 | /* IEEE 802.11 defines */ | 7 | /* IEEE 802.11 defines */ |
11 | 8 | ||
12 | /* Information Element IDs */ | 9 | /* Information Element IDs */ |
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index 40f516d42c5e..d8f5efcfcab9 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c | |||
@@ -2920,7 +2920,7 @@ static int prism2_ioctl_priv_monitor(struct net_device *dev, int *i) | |||
2920 | 2920 | ||
2921 | printk(KERN_DEBUG "%s: process %d (%s) used deprecated iwpriv monitor " | 2921 | printk(KERN_DEBUG "%s: process %d (%s) used deprecated iwpriv monitor " |
2922 | "- update software to use iwconfig mode monitor\n", | 2922 | "- update software to use iwconfig mode monitor\n", |
2923 | dev->name, current->pid, current->comm); | 2923 | dev->name, task_pid_nr(current), current->comm); |
2924 | 2924 | ||
2925 | /* Backward compatibility code - this can be removed at some point */ | 2925 | /* Backward compatibility code - this can be removed at some point */ |
2926 | 2926 | ||
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index 2fa8eed86dc1..7a7797560a23 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c | |||
@@ -1858,14 +1858,6 @@ static void ipw2100_down(struct ipw2100_priv *priv) | |||
1858 | 1858 | ||
1859 | modify_acceptable_latency("ipw2100", INFINITE_LATENCY); | 1859 | modify_acceptable_latency("ipw2100", INFINITE_LATENCY); |
1860 | 1860 | ||
1861 | #ifdef ACPI_CSTATE_LIMIT_DEFINED | ||
1862 | if (priv->config & CFG_C3_DISABLED) { | ||
1863 | IPW_DEBUG_INFO(": Resetting C3 transitions.\n"); | ||
1864 | acpi_set_cstate_limit(priv->cstate_limit); | ||
1865 | priv->config &= ~CFG_C3_DISABLED; | ||
1866 | } | ||
1867 | #endif | ||
1868 | |||
1869 | /* We have to signal any supplicant if we are disassociating */ | 1861 | /* We have to signal any supplicant if we are disassociating */ |
1870 | if (associated) | 1862 | if (associated) |
1871 | wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); | 1863 | wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); |
@@ -2091,14 +2083,6 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) | |||
2091 | /* RF_KILL is now enabled (else we wouldn't be here) */ | 2083 | /* RF_KILL is now enabled (else we wouldn't be here) */ |
2092 | priv->status |= STATUS_RF_KILL_HW; | 2084 | priv->status |= STATUS_RF_KILL_HW; |
2093 | 2085 | ||
2094 | #ifdef ACPI_CSTATE_LIMIT_DEFINED | ||
2095 | if (priv->config & CFG_C3_DISABLED) { | ||
2096 | IPW_DEBUG_INFO(": Resetting C3 transitions.\n"); | ||
2097 | acpi_set_cstate_limit(priv->cstate_limit); | ||
2098 | priv->config &= ~CFG_C3_DISABLED; | ||
2099 | } | ||
2100 | #endif | ||
2101 | |||
2102 | /* Make sure the RF Kill check timer is running */ | 2086 | /* Make sure the RF Kill check timer is running */ |
2103 | priv->stop_rf_kill = 0; | 2087 | priv->stop_rf_kill = 0; |
2104 | cancel_delayed_work(&priv->rf_kill); | 2088 | cancel_delayed_work(&priv->rf_kill); |
@@ -2363,23 +2347,10 @@ static void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i) | |||
2363 | u32 match, reg; | 2347 | u32 match, reg; |
2364 | int j; | 2348 | int j; |
2365 | #endif | 2349 | #endif |
2366 | #ifdef ACPI_CSTATE_LIMIT_DEFINED | ||
2367 | int limit; | ||
2368 | #endif | ||
2369 | 2350 | ||
2370 | IPW_DEBUG_INFO(": PCI latency error detected at 0x%04zX.\n", | 2351 | IPW_DEBUG_INFO(": PCI latency error detected at 0x%04zX.\n", |
2371 | i * sizeof(struct ipw2100_status)); | 2352 | i * sizeof(struct ipw2100_status)); |
2372 | 2353 | ||
2373 | #ifdef ACPI_CSTATE_LIMIT_DEFINED | ||
2374 | IPW_DEBUG_INFO(": Disabling C3 transitions.\n"); | ||
2375 | limit = acpi_get_cstate_limit(); | ||
2376 | if (limit > 2) { | ||
2377 | priv->cstate_limit = limit; | ||
2378 | acpi_set_cstate_limit(2); | ||
2379 | priv->config |= CFG_C3_DISABLED; | ||
2380 | } | ||
2381 | #endif | ||
2382 | |||
2383 | #ifdef IPW2100_DEBUG_C3 | 2354 | #ifdef IPW2100_DEBUG_C3 |
2384 | /* Halt the fimrware so we can get a good image */ | 2355 | /* Halt the fimrware so we can get a good image */ |
2385 | write_register(priv->net_dev, IPW_REG_RESET_REG, | 2356 | write_register(priv->net_dev, IPW_REG_RESET_REG, |
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h index 1ee3348aedd9..bbf1ddcafba8 100644 --- a/drivers/net/wireless/ipw2100.h +++ b/drivers/net/wireless/ipw2100.h | |||
@@ -479,7 +479,6 @@ enum { | |||
479 | #define CFG_ASSOCIATE (1<<6) | 479 | #define CFG_ASSOCIATE (1<<6) |
480 | #define CFG_FIXED_RATE (1<<7) | 480 | #define CFG_FIXED_RATE (1<<7) |
481 | #define CFG_ADHOC_CREATE (1<<8) | 481 | #define CFG_ADHOC_CREATE (1<<8) |
482 | #define CFG_C3_DISABLED (1<<9) | ||
483 | #define CFG_PASSIVE_SCAN (1<<10) | 482 | #define CFG_PASSIVE_SCAN (1<<10) |
484 | #ifdef CONFIG_IPW2100_MONITOR | 483 | #ifdef CONFIG_IPW2100_MONITOR |
485 | #define CFG_CRC_CHECK (1<<11) | 484 | #define CFG_CRC_CHECK (1<<11) |
@@ -508,7 +507,6 @@ struct ipw2100_priv { | |||
508 | u8 bssid[ETH_ALEN]; | 507 | u8 bssid[ETH_ALEN]; |
509 | u8 channel; | 508 | u8 channel; |
510 | int last_mode; | 509 | int last_mode; |
511 | int cstate_limit; | ||
512 | 510 | ||
513 | unsigned long connect_start; | 511 | unsigned long connect_start; |
514 | unsigned long last_reset; | 512 | unsigned long last_reset; |
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c index 67d28ee80f22..c5e0d89c3ece 100644 --- a/drivers/pcmcia/m32r_pcc.c +++ b/drivers/pcmcia/m32r_pcc.c | |||
@@ -22,9 +22,9 @@ | |||
22 | #include <linux/workqueue.h> | 22 | #include <linux/workqueue.h> |
23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/bitops.h> | ||
25 | #include <asm/irq.h> | 26 | #include <asm/irq.h> |
26 | #include <asm/io.h> | 27 | #include <asm/io.h> |
27 | #include <asm/bitops.h> | ||
28 | #include <asm/system.h> | 28 | #include <asm/system.h> |
29 | #include <asm/addrspace.h> | 29 | #include <asm/addrspace.h> |
30 | 30 | ||
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c index b01985498460..d182760f035b 100644 --- a/drivers/pcmcia/m8xx_pcmcia.c +++ b/drivers/pcmcia/m8xx_pcmcia.c | |||
@@ -48,9 +48,9 @@ | |||
48 | #include <linux/delay.h> | 48 | #include <linux/delay.h> |
49 | #include <linux/interrupt.h> | 49 | #include <linux/interrupt.h> |
50 | #include <linux/fsl_devices.h> | 50 | #include <linux/fsl_devices.h> |
51 | #include <linux/bitops.h> | ||
51 | 52 | ||
52 | #include <asm/io.h> | 53 | #include <asm/io.h> |
53 | #include <asm/bitops.h> | ||
54 | #include <asm/system.h> | 54 | #include <asm/system.h> |
55 | #include <asm/time.h> | 55 | #include <asm/time.h> |
56 | #include <asm/mpc8xx.h> | 56 | #include <asm/mpc8xx.h> |
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c index 397f4ce849dc..87b3493d88e5 100644 --- a/drivers/ps3/ps3av.c +++ b/drivers/ps3/ps3av.c | |||
@@ -729,7 +729,7 @@ static void ps3av_monitor_info_dump(const struct ps3av_pkt_av_get_monitor_info * | |||
729 | 729 | ||
730 | static const struct ps3av_monitor_quirk { | 730 | static const struct ps3av_monitor_quirk { |
731 | const char *monitor_name; | 731 | const char *monitor_name; |
732 | u32 clear_60, clear_50, clear_vesa; | 732 | u32 clear_60; |
733 | } ps3av_monitor_quirks[] = { | 733 | } ps3av_monitor_quirks[] = { |
734 | { | 734 | { |
735 | .monitor_name = "DELL 2007WFP", | 735 | .monitor_name = "DELL 2007WFP", |
@@ -757,10 +757,6 @@ static void ps3av_fixup_monitor_info(struct ps3av_info_monitor *info) | |||
757 | quirk->monitor_name); | 757 | quirk->monitor_name); |
758 | info->res_60.res_bits &= ~quirk->clear_60; | 758 | info->res_60.res_bits &= ~quirk->clear_60; |
759 | info->res_60.native &= ~quirk->clear_60; | 759 | info->res_60.native &= ~quirk->clear_60; |
760 | info->res_50.res_bits &= ~quirk->clear_50; | ||
761 | info->res_50.native &= ~quirk->clear_50; | ||
762 | info->res_vesa.res_bits &= ~quirk->clear_vesa; | ||
763 | info->res_vesa.native &= ~quirk->clear_vesa; | ||
764 | break; | 760 | break; |
765 | } | 761 | } |
766 | } | 762 | } |
diff --git a/drivers/ps3/vuart.c b/drivers/ps3/vuart.c index bea25a1391ee..9dea585ef806 100644 --- a/drivers/ps3/vuart.c +++ b/drivers/ps3/vuart.c | |||
@@ -22,11 +22,11 @@ | |||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
25 | #include <linux/bitops.h> | ||
25 | #include <asm/ps3.h> | 26 | #include <asm/ps3.h> |
26 | 27 | ||
27 | #include <asm/firmware.h> | 28 | #include <asm/firmware.h> |
28 | #include <asm/lv1call.h> | 29 | #include <asm/lv1call.h> |
29 | #include <asm/bitops.h> | ||
30 | 30 | ||
31 | #include "vuart.h" | 31 | #include "vuart.h" |
32 | 32 | ||
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index e4bf68ca96f7..2fd49edcc712 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -21,11 +21,11 @@ | |||
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/string.h> | 22 | #include <linux/string.h> |
23 | #include <linux/pm.h> | 23 | #include <linux/pm.h> |
24 | #include <linux/bitops.h> | ||
24 | 25 | ||
25 | #include <linux/amba/bus.h> | 26 | #include <linux/amba/bus.h> |
26 | 27 | ||
27 | #include <asm/io.h> | 28 | #include <asm/io.h> |
28 | #include <asm/bitops.h> | ||
29 | #include <asm/hardware.h> | 29 | #include <asm/hardware.h> |
30 | #include <asm/irq.h> | 30 | #include <asm/irq.h> |
31 | #include <asm/rtc.h> | 31 | #include <asm/rtc.h> |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 0918b787c4dd..6f1e9a9804bc 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -29,8 +29,8 @@ | |||
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/string.h> | 30 | #include <linux/string.h> |
31 | #include <linux/pm.h> | 31 | #include <linux/pm.h> |
32 | #include <linux/bitops.h> | ||
32 | 33 | ||
33 | #include <asm/bitops.h> | ||
34 | #include <asm/hardware.h> | 34 | #include <asm/hardware.h> |
35 | #include <asm/irq.h> | 35 | #include <asm/irq.h> |
36 | #include <asm/rtc.h> | 36 | #include <asm/rtc.h> |
diff --git a/drivers/s390/cio/idset.c b/drivers/s390/cio/idset.c index 16ea828e99f7..ef7bc0a125ef 100644 --- a/drivers/s390/cio/idset.c +++ b/drivers/s390/cio/idset.c | |||
@@ -6,7 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
9 | #include <asm/bitops.h> | 9 | #include <linux/bitops.h> |
10 | #include "idset.h" | 10 | #include "idset.h" |
11 | #include "css.h" | 11 | #include "css.h" |
12 | 12 | ||
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c index 399695f7b1af..3561982749e3 100644 --- a/drivers/s390/net/claw.c +++ b/drivers/s390/net/claw.c | |||
@@ -59,13 +59,13 @@ | |||
59 | * 1.15 Changed for 2.6 Kernel No longer compiles on 2.4 or lower | 59 | * 1.15 Changed for 2.6 Kernel No longer compiles on 2.4 or lower |
60 | * 1.25 Added Packing support | 60 | * 1.25 Added Packing support |
61 | */ | 61 | */ |
62 | #include <asm/bitops.h> | ||
63 | #include <asm/ccwdev.h> | 62 | #include <asm/ccwdev.h> |
64 | #include <asm/ccwgroup.h> | 63 | #include <asm/ccwgroup.h> |
65 | #include <asm/debug.h> | 64 | #include <asm/debug.h> |
66 | #include <asm/idals.h> | 65 | #include <asm/idals.h> |
67 | #include <asm/io.h> | 66 | #include <asm/io.h> |
68 | 67 | ||
68 | #include <linux/bitops.h> | ||
69 | #include <linux/ctype.h> | 69 | #include <linux/ctype.h> |
70 | #include <linux/delay.h> | 70 | #include <linux/delay.h> |
71 | #include <linux/errno.h> | 71 | #include <linux/errno.h> |
diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c index a7f916c0c9cd..1c9078191d9e 100644 --- a/drivers/scsi/FlashPoint.c +++ b/drivers/scsi/FlashPoint.c | |||
@@ -25,9 +25,6 @@ | |||
25 | 25 | ||
26 | #define FAILURE 0xFFFFFFFFL | 26 | #define FAILURE 0xFFFFFFFFL |
27 | 27 | ||
28 | #define BIT(x) ((unsigned char)(1<<(x))) /* single-bit mask in bit position x */ | ||
29 | #define BITW(x) ((unsigned short)(1<<(x))) /* single-bit mask in bit position x */ | ||
30 | |||
31 | struct sccb; | 28 | struct sccb; |
32 | typedef void (*CALL_BK_FN) (struct sccb *); | 29 | typedef void (*CALL_BK_FN) (struct sccb *); |
33 | 30 | ||
@@ -374,9 +371,9 @@ typedef struct SCCBscam_info { | |||
374 | #define SCAM_ENABLED BIT(2) | 371 | #define SCAM_ENABLED BIT(2) |
375 | #define SCAM_LEVEL2 BIT(3) | 372 | #define SCAM_LEVEL2 BIT(3) |
376 | 373 | ||
377 | #define RENEGO_ENA BITW(10) | 374 | #define RENEGO_ENA BIT(10) |
378 | #define CONNIO_ENA BITW(11) | 375 | #define CONNIO_ENA BIT(11) |
379 | #define GREEN_PC_ENA BITW(12) | 376 | #define GREEN_PC_ENA BIT(12) |
380 | 377 | ||
381 | #define AUTO_RATE_00 00 | 378 | #define AUTO_RATE_00 00 |
382 | #define AUTO_RATE_05 01 | 379 | #define AUTO_RATE_05 01 |
@@ -511,23 +508,23 @@ typedef struct SCCBscam_info { | |||
511 | 508 | ||
512 | #define hp_intena 0x40 | 509 | #define hp_intena 0x40 |
513 | 510 | ||
514 | #define RESET BITW(7) | 511 | #define RESET BIT(7) |
515 | #define PROG_HLT BITW(6) | 512 | #define PROG_HLT BIT(6) |
516 | #define PARITY BITW(5) | 513 | #define PARITY BIT(5) |
517 | #define FIFO BITW(4) | 514 | #define FIFO BIT(4) |
518 | #define SEL BITW(3) | 515 | #define SEL BIT(3) |
519 | #define SCAM_SEL BITW(2) | 516 | #define SCAM_SEL BIT(2) |
520 | #define RSEL BITW(1) | 517 | #define RSEL BIT(1) |
521 | #define TIMEOUT BITW(0) | 518 | #define TIMEOUT BIT(0) |
522 | #define BUS_FREE BITW(15) | 519 | #define BUS_FREE BIT(15) |
523 | #define XFER_CNT_0 BITW(14) | 520 | #define XFER_CNT_0 BIT(14) |
524 | #define PHASE BITW(13) | 521 | #define PHASE BIT(13) |
525 | #define IUNKWN BITW(12) | 522 | #define IUNKWN BIT(12) |
526 | #define ICMD_COMP BITW(11) | 523 | #define ICMD_COMP BIT(11) |
527 | #define ITICKLE BITW(10) | 524 | #define ITICKLE BIT(10) |
528 | #define IDO_STRT BITW(9) | 525 | #define IDO_STRT BIT(9) |
529 | #define ITAR_DISC BITW(8) | 526 | #define ITAR_DISC BIT(8) |
530 | #define AUTO_INT (BITW(12)+BITW(11)+BITW(10)+BITW(9)+BITW(8)) | 527 | #define AUTO_INT (BIT(12)+BIT(11)+BIT(10)+BIT(9)+BIT(8)) |
531 | #define CLR_ALL_INT 0xFFFF | 528 | #define CLR_ALL_INT 0xFFFF |
532 | #define CLR_ALL_INT_1 0xFF00 | 529 | #define CLR_ALL_INT_1 0xFF00 |
533 | 530 | ||
@@ -674,37 +671,37 @@ typedef struct SCCBscam_info { | |||
674 | #define BIOS_DATA_OFFSET 0x60 | 671 | #define BIOS_DATA_OFFSET 0x60 |
675 | #define BIOS_RELATIVE_CARD 0x64 | 672 | #define BIOS_RELATIVE_CARD 0x64 |
676 | 673 | ||
677 | #define AR3 (BITW(9) + BITW(8)) | 674 | #define AR3 (BIT(9) + BIT(8)) |
678 | #define SDATA BITW(10) | 675 | #define SDATA BIT(10) |
679 | 676 | ||
680 | #define CRD_OP BITW(11) /* Cmp Reg. w/ Data */ | 677 | #define CRD_OP BIT(11) /* Cmp Reg. w/ Data */ |
681 | 678 | ||
682 | #define CRR_OP BITW(12) /* Cmp Reg. w. Reg. */ | 679 | #define CRR_OP BIT(12) /* Cmp Reg. w. Reg. */ |
683 | 680 | ||
684 | #define CPE_OP (BITW(14)+BITW(11)) /* Cmp SCSI phs & Branch EQ */ | 681 | #define CPE_OP (BIT(14)+BIT(11)) /* Cmp SCSI phs & Branch EQ */ |
685 | 682 | ||
686 | #define CPN_OP (BITW(14)+BITW(12)) /* Cmp SCSI phs & Branch NOT EQ */ | 683 | #define CPN_OP (BIT(14)+BIT(12)) /* Cmp SCSI phs & Branch NOT EQ */ |
687 | 684 | ||
688 | #define ADATA_OUT 0x00 | 685 | #define ADATA_OUT 0x00 |
689 | #define ADATA_IN BITW(8) | 686 | #define ADATA_IN BIT(8) |
690 | #define ACOMMAND BITW(10) | 687 | #define ACOMMAND BIT(10) |
691 | #define ASTATUS (BITW(10)+BITW(8)) | 688 | #define ASTATUS (BIT(10)+BIT(8)) |
692 | #define AMSG_OUT (BITW(10)+BITW(9)) | 689 | #define AMSG_OUT (BIT(10)+BIT(9)) |
693 | #define AMSG_IN (BITW(10)+BITW(9)+BITW(8)) | 690 | #define AMSG_IN (BIT(10)+BIT(9)+BIT(8)) |
694 | 691 | ||
695 | #define BRH_OP BITW(13) /* Branch */ | 692 | #define BRH_OP BIT(13) /* Branch */ |
696 | 693 | ||
697 | #define ALWAYS 0x00 | 694 | #define ALWAYS 0x00 |
698 | #define EQUAL BITW(8) | 695 | #define EQUAL BIT(8) |
699 | #define NOT_EQ BITW(9) | 696 | #define NOT_EQ BIT(9) |
700 | 697 | ||
701 | #define TCB_OP (BITW(13)+BITW(11)) /* Test condition & branch */ | 698 | #define TCB_OP (BIT(13)+BIT(11)) /* Test condition & branch */ |
702 | 699 | ||
703 | #define FIFO_0 BITW(10) | 700 | #define FIFO_0 BIT(10) |
704 | 701 | ||
705 | #define MPM_OP BITW(15) /* Match phase and move data */ | 702 | #define MPM_OP BIT(15) /* Match phase and move data */ |
706 | 703 | ||
707 | #define MRR_OP BITW(14) /* Move DReg. to Reg. */ | 704 | #define MRR_OP BIT(14) /* Move DReg. to Reg. */ |
708 | 705 | ||
709 | #define S_IDREG (BIT(2)+BIT(1)+BIT(0)) | 706 | #define S_IDREG (BIT(2)+BIT(1)+BIT(0)) |
710 | 707 | ||
@@ -712,9 +709,9 @@ typedef struct SCCBscam_info { | |||
712 | #define D_AR1 BIT(0) | 709 | #define D_AR1 BIT(0) |
713 | #define D_BUCKET (BIT(2) + BIT(1) + BIT(0)) | 710 | #define D_BUCKET (BIT(2) + BIT(1) + BIT(0)) |
714 | 711 | ||
715 | #define RAT_OP (BITW(14)+BITW(13)+BITW(11)) | 712 | #define RAT_OP (BIT(14)+BIT(13)+BIT(11)) |
716 | 713 | ||
717 | #define SSI_OP (BITW(15)+BITW(11)) | 714 | #define SSI_OP (BIT(15)+BIT(11)) |
718 | 715 | ||
719 | #define SSI_ITAR_DISC (ITAR_DISC >> 8) | 716 | #define SSI_ITAR_DISC (ITAR_DISC >> 8) |
720 | #define SSI_IDO_STRT (IDO_STRT >> 8) | 717 | #define SSI_IDO_STRT (IDO_STRT >> 8) |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 30905cebefbb..a5763c6e9362 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -521,7 +521,7 @@ config SCSI_DPT_I2O | |||
521 | 521 | ||
522 | config SCSI_ADVANSYS | 522 | config SCSI_ADVANSYS |
523 | tristate "AdvanSys SCSI support" | 523 | tristate "AdvanSys SCSI support" |
524 | depends on SCSI | 524 | depends on SCSI && VIRT_TO_BUS |
525 | depends on ISA || EISA || PCI | 525 | depends on ISA || EISA || PCI |
526 | help | 526 | help |
527 | This is a driver for all SCSI host adapters manufactured by | 527 | This is a driver for all SCSI host adapters manufactured by |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index fa7ba64483fb..252d1806467f 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -47,9 +47,9 @@ | |||
47 | #include <linux/scatterlist.h> | 47 | #include <linux/scatterlist.h> |
48 | #include <linux/delay.h> | 48 | #include <linux/delay.h> |
49 | #include <linux/mutex.h> | 49 | #include <linux/mutex.h> |
50 | #include <linux/bitops.h> | ||
50 | 51 | ||
51 | #include <asm/io.h> | 52 | #include <asm/io.h> |
52 | #include <asm/bitops.h> | ||
53 | #include <asm/uaccess.h> | 53 | #include <asm/uaccess.h> |
54 | 54 | ||
55 | #include <scsi/scsi.h> | 55 | #include <scsi/scsi.h> |
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index 7ef0afc3cd68..5f3a0d7b18de 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c | |||
@@ -285,7 +285,7 @@ static void sas_discover_domain(struct work_struct *work) | |||
285 | dev = port->port_dev; | 285 | dev = port->port_dev; |
286 | 286 | ||
287 | SAS_DPRINTK("DOING DISCOVERY on port %d, pid:%d\n", port->id, | 287 | SAS_DPRINTK("DOING DISCOVERY on port %d, pid:%d\n", port->id, |
288 | current->pid); | 288 | task_pid_nr(current)); |
289 | 289 | ||
290 | switch (dev->dev_type) { | 290 | switch (dev->dev_type) { |
291 | case SAS_END_DEV: | 291 | case SAS_END_DEV: |
@@ -320,7 +320,7 @@ static void sas_discover_domain(struct work_struct *work) | |||
320 | } | 320 | } |
321 | 321 | ||
322 | SAS_DPRINTK("DONE DISCOVERY on port %d, pid:%d, result:%d\n", port->id, | 322 | SAS_DPRINTK("DONE DISCOVERY on port %d, pid:%d, result:%d\n", port->id, |
323 | current->pid, error); | 323 | task_pid_nr(current), error); |
324 | } | 324 | } |
325 | 325 | ||
326 | static void sas_revalidate_domain(struct work_struct *work) | 326 | static void sas_revalidate_domain(struct work_struct *work) |
@@ -334,12 +334,12 @@ static void sas_revalidate_domain(struct work_struct *work) | |||
334 | &port->disc.pending); | 334 | &port->disc.pending); |
335 | 335 | ||
336 | SAS_DPRINTK("REVALIDATING DOMAIN on port %d, pid:%d\n", port->id, | 336 | SAS_DPRINTK("REVALIDATING DOMAIN on port %d, pid:%d\n", port->id, |
337 | current->pid); | 337 | task_pid_nr(current)); |
338 | if (port->port_dev) | 338 | if (port->port_dev) |
339 | res = sas_ex_revalidate_domain(port->port_dev); | 339 | res = sas_ex_revalidate_domain(port->port_dev); |
340 | 340 | ||
341 | SAS_DPRINTK("done REVALIDATING DOMAIN on port %d, pid:%d, res 0x%x\n", | 341 | SAS_DPRINTK("done REVALIDATING DOMAIN on port %d, pid:%d, res 0x%x\n", |
342 | port->id, current->pid, res); | 342 | port->id, task_pid_nr(current), res); |
343 | } | 343 | } |
344 | 344 | ||
345 | /* ---------- Events ---------- */ | 345 | /* ---------- Events ---------- */ |
diff --git a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h index a976e8193d16..6715ecb3bfca 100644 --- a/drivers/scsi/nsp32.h +++ b/drivers/scsi/nsp32.h | |||
@@ -69,11 +69,6 @@ typedef u32 u32_le; | |||
69 | typedef u16 u16_le; | 69 | typedef u16 u16_le; |
70 | 70 | ||
71 | /* | 71 | /* |
72 | * MACRO | ||
73 | */ | ||
74 | #define BIT(x) (1UL << (x)) | ||
75 | |||
76 | /* | ||
77 | * BASIC Definitions | 72 | * BASIC Definitions |
78 | */ | 73 | */ |
79 | #ifndef TRUE | 74 | #ifndef TRUE |
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index b7f0fa246413..98397559c53b 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h | |||
@@ -24,7 +24,6 @@ | |||
24 | /************************************ | 24 | /************************************ |
25 | * Some useful macros... | 25 | * Some useful macros... |
26 | */ | 26 | */ |
27 | #define BIT(x) (1L << (x)) | ||
28 | 27 | ||
29 | /* SCSI initiator must be ID 7 */ | 28 | /* SCSI initiator must be ID 7 */ |
30 | #define NSP_INITIATOR_ID 7 | 29 | #define NSP_INITIATOR_ID 7 |
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h index 9bb3d1d2a925..fe415ec85655 100644 --- a/drivers/scsi/qla4xxx/ql4_fw.h +++ b/drivers/scsi/qla4xxx/ql4_fw.h | |||
@@ -671,7 +671,7 @@ struct continuation_t1_entry { | |||
671 | #define ET_CONTINUE ET_CONT_T1 | 671 | #define ET_CONTINUE ET_CONT_T1 |
672 | 672 | ||
673 | /* Marker entry structure*/ | 673 | /* Marker entry structure*/ |
674 | struct marker_entry { | 674 | struct qla4_marker_entry { |
675 | struct qla4_header hdr; /* 00-03 */ | 675 | struct qla4_header hdr; /* 00-03 */ |
676 | 676 | ||
677 | uint32_t system_defined; /* 04-07 */ | 677 | uint32_t system_defined; /* 04-07 */ |
diff --git a/drivers/scsi/qla4xxx/ql4_iocb.c b/drivers/scsi/qla4xxx/ql4_iocb.c index 5006ecb3ef5e..e4461b5d767a 100644 --- a/drivers/scsi/qla4xxx/ql4_iocb.c +++ b/drivers/scsi/qla4xxx/ql4_iocb.c | |||
@@ -69,7 +69,7 @@ static int qla4xxx_get_req_pkt(struct scsi_qla_host *ha, | |||
69 | static int qla4xxx_send_marker_iocb(struct scsi_qla_host *ha, | 69 | static int qla4xxx_send_marker_iocb(struct scsi_qla_host *ha, |
70 | struct ddb_entry *ddb_entry, int lun) | 70 | struct ddb_entry *ddb_entry, int lun) |
71 | { | 71 | { |
72 | struct marker_entry *marker_entry; | 72 | struct qla4_marker_entry *marker_entry; |
73 | unsigned long flags = 0; | 73 | unsigned long flags = 0; |
74 | uint8_t status = QLA_SUCCESS; | 74 | uint8_t status = QLA_SUCCESS; |
75 | 75 | ||
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 72229df9dc11..40604a092921 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c | |||
@@ -263,15 +263,15 @@ static unsigned int pl01x_get_mctrl(struct uart_port *port) | |||
263 | unsigned int result = 0; | 263 | unsigned int result = 0; |
264 | unsigned int status = readw(uap->port.membase + UART01x_FR); | 264 | unsigned int status = readw(uap->port.membase + UART01x_FR); |
265 | 265 | ||
266 | #define BIT(uartbit, tiocmbit) \ | 266 | #define TIOCMBIT(uartbit, tiocmbit) \ |
267 | if (status & uartbit) \ | 267 | if (status & uartbit) \ |
268 | result |= tiocmbit | 268 | result |= tiocmbit |
269 | 269 | ||
270 | BIT(UART01x_FR_DCD, TIOCM_CAR); | 270 | TIOCMBIT(UART01x_FR_DCD, TIOCM_CAR); |
271 | BIT(UART01x_FR_DSR, TIOCM_DSR); | 271 | TIOCMBIT(UART01x_FR_DSR, TIOCM_DSR); |
272 | BIT(UART01x_FR_CTS, TIOCM_CTS); | 272 | TIOCMBIT(UART01x_FR_CTS, TIOCM_CTS); |
273 | BIT(UART011_FR_RI, TIOCM_RNG); | 273 | TIOCMBIT(UART011_FR_RI, TIOCM_RNG); |
274 | #undef BIT | 274 | #undef TIOCMBIT |
275 | return result; | 275 | return result; |
276 | } | 276 | } |
277 | 277 | ||
@@ -282,18 +282,18 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl) | |||
282 | 282 | ||
283 | cr = readw(uap->port.membase + UART011_CR); | 283 | cr = readw(uap->port.membase + UART011_CR); |
284 | 284 | ||
285 | #define BIT(tiocmbit, uartbit) \ | 285 | #define TIOCMBIT(tiocmbit, uartbit) \ |
286 | if (mctrl & tiocmbit) \ | 286 | if (mctrl & tiocmbit) \ |
287 | cr |= uartbit; \ | 287 | cr |= uartbit; \ |
288 | else \ | 288 | else \ |
289 | cr &= ~uartbit | 289 | cr &= ~uartbit |
290 | 290 | ||
291 | BIT(TIOCM_RTS, UART011_CR_RTS); | 291 | TIOCMBIT(TIOCM_RTS, UART011_CR_RTS); |
292 | BIT(TIOCM_DTR, UART011_CR_DTR); | 292 | TIOCMBIT(TIOCM_DTR, UART011_CR_DTR); |
293 | BIT(TIOCM_OUT1, UART011_CR_OUT1); | 293 | TIOCMBIT(TIOCM_OUT1, UART011_CR_OUT1); |
294 | BIT(TIOCM_OUT2, UART011_CR_OUT2); | 294 | TIOCMBIT(TIOCM_OUT2, UART011_CR_OUT2); |
295 | BIT(TIOCM_LOOP, UART011_CR_LBE); | 295 | TIOCMBIT(TIOCM_LOOP, UART011_CR_LBE); |
296 | #undef BIT | 296 | #undef TIOCMBIT |
297 | 297 | ||
298 | writew(cr, uap->port.membase + UART011_CR); | 298 | writew(cr, uap->port.membase + UART011_CR); |
299 | } | 299 | } |
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index 7e8724d3571f..f523cdf4b02b 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c | |||
@@ -442,11 +442,11 @@ static char *serial_version = "$Revision: 1.25 $"; | |||
442 | #include <asm/uaccess.h> | 442 | #include <asm/uaccess.h> |
443 | #include <linux/kernel.h> | 443 | #include <linux/kernel.h> |
444 | #include <linux/mutex.h> | 444 | #include <linux/mutex.h> |
445 | #include <linux/bitops.h> | ||
445 | 446 | ||
446 | #include <asm/io.h> | 447 | #include <asm/io.h> |
447 | #include <asm/irq.h> | 448 | #include <asm/irq.h> |
448 | #include <asm/system.h> | 449 | #include <asm/system.h> |
449 | #include <asm/bitops.h> | ||
450 | #include <linux/delay.h> | 450 | #include <linux/delay.h> |
451 | 451 | ||
452 | #include <asm/arch/svinto.h> | 452 | #include <asm/arch/svinto.h> |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index f013b4012c9a..1f4f6d02fe25 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -460,7 +460,7 @@ static int checkintf(struct dev_state *ps, unsigned int ifnum) | |||
460 | return 0; | 460 | return 0; |
461 | /* if not yet claimed, claim it for the driver */ | 461 | /* if not yet claimed, claim it for the driver */ |
462 | dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim interface %u before use\n", | 462 | dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim interface %u before use\n", |
463 | current->pid, current->comm, ifnum); | 463 | task_pid_nr(current), current->comm, ifnum); |
464 | return claimintf(ps, ifnum); | 464 | return claimintf(ps, ifnum); |
465 | } | 465 | } |
466 | 466 | ||
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 73726c570a6e..1d174dcb3ac9 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -4006,7 +4006,7 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
4006 | DBG(fsg, "removable=%d, stall=%d, buflen=%u\n", | 4006 | DBG(fsg, "removable=%d, stall=%d, buflen=%u\n", |
4007 | mod_data.removable, mod_data.can_stall, | 4007 | mod_data.removable, mod_data.can_stall, |
4008 | mod_data.buflen); | 4008 | mod_data.buflen); |
4009 | DBG(fsg, "I/O thread pid: %d\n", fsg->thread_task->pid); | 4009 | DBG(fsg, "I/O thread pid: %d\n", task_pid_nr(fsg->thread_task)); |
4010 | 4010 | ||
4011 | set_bit(REGISTERED, &fsg->atomic_bitflags); | 4011 | set_bit(REGISTERED, &fsg->atomic_bitflags); |
4012 | 4012 | ||
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c index 9bb2cbfe4a3d..5fb8675e0d6b 100644 --- a/drivers/video/cyber2000fb.c +++ b/drivers/video/cyber2000fb.c | |||
@@ -62,7 +62,7 @@ struct cfb_info { | |||
62 | struct display_switch *dispsw; | 62 | struct display_switch *dispsw; |
63 | struct display *display; | 63 | struct display *display; |
64 | struct pci_dev *dev; | 64 | struct pci_dev *dev; |
65 | unsigned char __iomem *region; | 65 | unsigned char __iomem *region; |
66 | unsigned char __iomem *regs; | 66 | unsigned char __iomem *regs; |
67 | u_int id; | 67 | u_int id; |
68 | int func_use_count; | 68 | int func_use_count; |
@@ -97,11 +97,11 @@ MODULE_PARM_DESC(default_font, "Default font name"); | |||
97 | /* | 97 | /* |
98 | * Our access methods. | 98 | * Our access methods. |
99 | */ | 99 | */ |
100 | #define cyber2000fb_writel(val,reg,cfb) writel(val, (cfb)->regs + (reg)) | 100 | #define cyber2000fb_writel(val, reg, cfb) writel(val, (cfb)->regs + (reg)) |
101 | #define cyber2000fb_writew(val,reg,cfb) writew(val, (cfb)->regs + (reg)) | 101 | #define cyber2000fb_writew(val, reg, cfb) writew(val, (cfb)->regs + (reg)) |
102 | #define cyber2000fb_writeb(val,reg,cfb) writeb(val, (cfb)->regs + (reg)) | 102 | #define cyber2000fb_writeb(val, reg, cfb) writeb(val, (cfb)->regs + (reg)) |
103 | 103 | ||
104 | #define cyber2000fb_readb(reg,cfb) readb((cfb)->regs + (reg)) | 104 | #define cyber2000fb_readb(reg, cfb) readb((cfb)->regs + (reg)) |
105 | 105 | ||
106 | static inline void | 106 | static inline void |
107 | cyber2000_crtcw(unsigned int reg, unsigned int val, struct cfb_info *cfb) | 107 | cyber2000_crtcw(unsigned int reg, unsigned int val, struct cfb_info *cfb) |
@@ -221,12 +221,8 @@ cyber2000fb_copyarea(struct fb_info *info, const struct fb_copyarea *region) | |||
221 | static void | 221 | static void |
222 | cyber2000fb_imageblit(struct fb_info *info, const struct fb_image *image) | 222 | cyber2000fb_imageblit(struct fb_info *info, const struct fb_image *image) |
223 | { | 223 | { |
224 | // struct cfb_info *cfb = (struct cfb_info *)info; | 224 | cfb_imageblit(info, image); |
225 | 225 | return; | |
226 | // if (!(cfb->fb.var.accel_flags & FB_ACCELF_TEXT)) { | ||
227 | cfb_imageblit(info, image); | ||
228 | return; | ||
229 | // } | ||
230 | } | 226 | } |
231 | 227 | ||
232 | static int cyber2000fb_sync(struct fb_info *info) | 228 | static int cyber2000fb_sync(struct fb_info *info) |
@@ -277,12 +273,12 @@ cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
277 | 273 | ||
278 | /* | 274 | /* |
279 | * Pseudocolour: | 275 | * Pseudocolour: |
280 | * 8 8 | 276 | * 8 8 |
281 | * pixel --/--+--/--> red lut --> red dac | 277 | * pixel --/--+--/--> red lut --> red dac |
282 | * | 8 | 278 | * | 8 |
283 | * +--/--> green lut --> green dac | 279 | * +--/--> green lut --> green dac |
284 | * | 8 | 280 | * | 8 |
285 | * +--/--> blue lut --> blue dac | 281 | * +--/--> blue lut --> blue dac |
286 | */ | 282 | */ |
287 | case FB_VISUAL_PSEUDOCOLOR: | 283 | case FB_VISUAL_PSEUDOCOLOR: |
288 | if (regno >= NR_PALETTE) | 284 | if (regno >= NR_PALETTE) |
@@ -292,9 +288,9 @@ cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
292 | green >>= 8; | 288 | green >>= 8; |
293 | blue >>= 8; | 289 | blue >>= 8; |
294 | 290 | ||
295 | cfb->palette[regno].red = red; | 291 | cfb->palette[regno].red = red; |
296 | cfb->palette[regno].green = green; | 292 | cfb->palette[regno].green = green; |
297 | cfb->palette[regno].blue = blue; | 293 | cfb->palette[regno].blue = blue; |
298 | 294 | ||
299 | cyber2000fb_writeb(regno, 0x3c8, cfb); | 295 | cyber2000fb_writeb(regno, 0x3c8, cfb); |
300 | cyber2000fb_writeb(red, 0x3c9, cfb); | 296 | cyber2000fb_writeb(red, 0x3c9, cfb); |
@@ -304,12 +300,12 @@ cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
304 | 300 | ||
305 | /* | 301 | /* |
306 | * Direct colour: | 302 | * Direct colour: |
307 | * n rl | 303 | * n rl |
308 | * pixel --/--+--/--> red lut --> red dac | 304 | * pixel --/--+--/--> red lut --> red dac |
309 | * | gl | 305 | * | gl |
310 | * +--/--> green lut --> green dac | 306 | * +--/--> green lut --> green dac |
311 | * | bl | 307 | * | bl |
312 | * +--/--> blue lut --> blue dac | 308 | * +--/--> blue lut --> blue dac |
313 | * n = bpp, rl = red length, gl = green length, bl = blue length | 309 | * n = bpp, rl = red length, gl = green length, bl = blue length |
314 | */ | 310 | */ |
315 | case FB_VISUAL_DIRECTCOLOR: | 311 | case FB_VISUAL_DIRECTCOLOR: |
@@ -325,9 +321,11 @@ cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
325 | * to the high 6 bits of the LUT. | 321 | * to the high 6 bits of the LUT. |
326 | */ | 322 | */ |
327 | cyber2000fb_writeb(regno << 2, 0x3c8, cfb); | 323 | cyber2000fb_writeb(regno << 2, 0x3c8, cfb); |
328 | cyber2000fb_writeb(cfb->palette[regno >> 1].red, 0x3c9, cfb); | 324 | cyber2000fb_writeb(cfb->palette[regno >> 1].red, |
325 | 0x3c9, cfb); | ||
329 | cyber2000fb_writeb(green, 0x3c9, cfb); | 326 | cyber2000fb_writeb(green, 0x3c9, cfb); |
330 | cyber2000fb_writeb(cfb->palette[regno >> 1].blue, 0x3c9, cfb); | 327 | cyber2000fb_writeb(cfb->palette[regno >> 1].blue, |
328 | 0x3c9, cfb); | ||
331 | 329 | ||
332 | green = cfb->palette[regno << 3].green; | 330 | green = cfb->palette[regno << 3].green; |
333 | 331 | ||
@@ -335,9 +333,9 @@ cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
335 | } | 333 | } |
336 | 334 | ||
337 | if (var->green.length >= 5 && regno < 32) { | 335 | if (var->green.length >= 5 && regno < 32) { |
338 | cfb->palette[regno << 3].red = red; | 336 | cfb->palette[regno << 3].red = red; |
339 | cfb->palette[regno << 3].green = green; | 337 | cfb->palette[regno << 3].green = green; |
340 | cfb->palette[regno << 3].blue = blue; | 338 | cfb->palette[regno << 3].blue = blue; |
341 | 339 | ||
342 | /* | 340 | /* |
343 | * The 5 bits of each colour component are | 341 | * The 5 bits of each colour component are |
@@ -351,9 +349,9 @@ cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
351 | } | 349 | } |
352 | 350 | ||
353 | if (var->green.length == 4 && regno < 16) { | 351 | if (var->green.length == 4 && regno < 16) { |
354 | cfb->palette[regno << 4].red = red; | 352 | cfb->palette[regno << 4].red = red; |
355 | cfb->palette[regno << 4].green = green; | 353 | cfb->palette[regno << 4].green = green; |
356 | cfb->palette[regno << 4].blue = blue; | 354 | cfb->palette[regno << 4].blue = blue; |
357 | 355 | ||
358 | /* | 356 | /* |
359 | * The 5 bits of each colour component are | 357 | * The 5 bits of each colour component are |
@@ -377,12 +375,12 @@ cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
377 | 375 | ||
378 | /* | 376 | /* |
379 | * True colour: | 377 | * True colour: |
380 | * n rl | 378 | * n rl |
381 | * pixel --/--+--/--> red dac | 379 | * pixel --/--+--/--> red dac |
382 | * | gl | 380 | * | gl |
383 | * +--/--> green dac | 381 | * +--/--> green dac |
384 | * | bl | 382 | * | bl |
385 | * +--/--> blue dac | 383 | * +--/--> blue dac |
386 | * n = bpp, rl = red length, gl = green length, bl = blue length | 384 | * n = bpp, rl = red length, gl = green length, bl = blue length |
387 | */ | 385 | */ |
388 | case FB_VISUAL_TRUECOLOR: | 386 | case FB_VISUAL_TRUECOLOR: |
@@ -494,9 +492,9 @@ static void cyber2000fb_set_timing(struct cfb_info *cfb, struct par_info *hw) | |||
494 | 492 | ||
495 | /* PLL registers */ | 493 | /* PLL registers */ |
496 | cyber2000_grphw(EXT_DCLK_MULT, hw->clock_mult, cfb); | 494 | cyber2000_grphw(EXT_DCLK_MULT, hw->clock_mult, cfb); |
497 | cyber2000_grphw(EXT_DCLK_DIV, hw->clock_div, cfb); | 495 | cyber2000_grphw(EXT_DCLK_DIV, hw->clock_div, cfb); |
498 | cyber2000_grphw(EXT_MCLK_MULT, cfb->mclk_mult, cfb); | 496 | cyber2000_grphw(EXT_MCLK_MULT, cfb->mclk_mult, cfb); |
499 | cyber2000_grphw(EXT_MCLK_DIV, cfb->mclk_div, cfb); | 497 | cyber2000_grphw(EXT_MCLK_DIV, cfb->mclk_div, cfb); |
500 | cyber2000_grphw(0x90, 0x01, cfb); | 498 | cyber2000_grphw(0x90, 0x01, cfb); |
501 | cyber2000_grphw(0xb9, 0x80, cfb); | 499 | cyber2000_grphw(0xb9, 0x80, cfb); |
502 | cyber2000_grphw(0xb9, 0x00, cfb); | 500 | cyber2000_grphw(0xb9, 0x00, cfb); |
@@ -515,8 +513,8 @@ static void cyber2000fb_set_timing(struct cfb_info *cfb, struct par_info *hw) | |||
515 | /* | 513 | /* |
516 | * Set up accelerator registers | 514 | * Set up accelerator registers |
517 | */ | 515 | */ |
518 | cyber2000fb_writew(hw->width, CO_REG_SRC_WIDTH, cfb); | 516 | cyber2000fb_writew(hw->width, CO_REG_SRC_WIDTH, cfb); |
519 | cyber2000fb_writew(hw->width, CO_REG_DEST_WIDTH, cfb); | 517 | cyber2000fb_writew(hw->width, CO_REG_DEST_WIDTH, cfb); |
520 | cyber2000fb_writeb(hw->co_pixfmt, CO_REG_PIXFMT, cfb); | 518 | cyber2000fb_writeb(hw->co_pixfmt, CO_REG_PIXFMT, cfb); |
521 | } | 519 | } |
522 | 520 | ||
@@ -549,15 +547,15 @@ cyber2000fb_decode_crtc(struct par_info *hw, struct cfb_info *cfb, | |||
549 | { | 547 | { |
550 | u_int Htotal, Hblankend, Hsyncend; | 548 | u_int Htotal, Hblankend, Hsyncend; |
551 | u_int Vtotal, Vdispend, Vblankstart, Vblankend, Vsyncstart, Vsyncend; | 549 | u_int Vtotal, Vdispend, Vblankstart, Vblankend, Vsyncstart, Vsyncend; |
552 | #define BIT(v,b1,m,b2) (((v >> b1) & m) << b2) | 550 | #define ENCODE_BIT(v, b1, m, b2) ((((v) >> (b1)) & (m)) << (b2)) |
553 | 551 | ||
554 | hw->crtc[13] = hw->pitch; | 552 | hw->crtc[13] = hw->pitch; |
555 | hw->crtc[17] = 0xe3; | 553 | hw->crtc[17] = 0xe3; |
556 | hw->crtc[14] = 0; | 554 | hw->crtc[14] = 0; |
557 | hw->crtc[8] = 0; | 555 | hw->crtc[8] = 0; |
558 | 556 | ||
559 | Htotal = var->xres + var->right_margin + | 557 | Htotal = var->xres + var->right_margin + |
560 | var->hsync_len + var->left_margin; | 558 | var->hsync_len + var->left_margin; |
561 | 559 | ||
562 | if (Htotal > 2080) | 560 | if (Htotal > 2080) |
563 | return -EINVAL; | 561 | return -EINVAL; |
@@ -567,15 +565,15 @@ cyber2000fb_decode_crtc(struct par_info *hw, struct cfb_info *cfb, | |||
567 | hw->crtc[2] = var->xres >> 3; | 565 | hw->crtc[2] = var->xres >> 3; |
568 | hw->crtc[4] = (var->xres + var->right_margin) >> 3; | 566 | hw->crtc[4] = (var->xres + var->right_margin) >> 3; |
569 | 567 | ||
570 | Hblankend = (Htotal - 4*8) >> 3; | 568 | Hblankend = (Htotal - 4 * 8) >> 3; |
571 | 569 | ||
572 | hw->crtc[3] = BIT(Hblankend, 0, 0x1f, 0) | | 570 | hw->crtc[3] = ENCODE_BIT(Hblankend, 0, 0x1f, 0) | |
573 | BIT(1, 0, 0x01, 7); | 571 | ENCODE_BIT(1, 0, 0x01, 7); |
574 | 572 | ||
575 | Hsyncend = (var->xres + var->right_margin + var->hsync_len) >> 3; | 573 | Hsyncend = (var->xres + var->right_margin + var->hsync_len) >> 3; |
576 | 574 | ||
577 | hw->crtc[5] = BIT(Hsyncend, 0, 0x1f, 0) | | 575 | hw->crtc[5] = ENCODE_BIT(Hsyncend, 0, 0x1f, 0) | |
578 | BIT(Hblankend, 5, 0x01, 7); | 576 | ENCODE_BIT(Hblankend, 5, 0x01, 7); |
579 | 577 | ||
580 | Vdispend = var->yres - 1; | 578 | Vdispend = var->yres - 1; |
581 | Vsyncstart = var->yres + var->lower_margin; | 579 | Vsyncstart = var->yres + var->lower_margin; |
@@ -590,20 +588,20 @@ cyber2000fb_decode_crtc(struct par_info *hw, struct cfb_info *cfb, | |||
590 | Vblankend = Vtotal - 10; | 588 | Vblankend = Vtotal - 10; |
591 | 589 | ||
592 | hw->crtc[6] = Vtotal; | 590 | hw->crtc[6] = Vtotal; |
593 | hw->crtc[7] = BIT(Vtotal, 8, 0x01, 0) | | 591 | hw->crtc[7] = ENCODE_BIT(Vtotal, 8, 0x01, 0) | |
594 | BIT(Vdispend, 8, 0x01, 1) | | 592 | ENCODE_BIT(Vdispend, 8, 0x01, 1) | |
595 | BIT(Vsyncstart, 8, 0x01, 2) | | 593 | ENCODE_BIT(Vsyncstart, 8, 0x01, 2) | |
596 | BIT(Vblankstart,8, 0x01, 3) | | 594 | ENCODE_BIT(Vblankstart, 8, 0x01, 3) | |
597 | BIT(1, 0, 0x01, 4) | | 595 | ENCODE_BIT(1, 0, 0x01, 4) | |
598 | BIT(Vtotal, 9, 0x01, 5) | | 596 | ENCODE_BIT(Vtotal, 9, 0x01, 5) | |
599 | BIT(Vdispend, 9, 0x01, 6) | | 597 | ENCODE_BIT(Vdispend, 9, 0x01, 6) | |
600 | BIT(Vsyncstart, 9, 0x01, 7); | 598 | ENCODE_BIT(Vsyncstart, 9, 0x01, 7); |
601 | hw->crtc[9] = BIT(0, 0, 0x1f, 0) | | 599 | hw->crtc[9] = ENCODE_BIT(0, 0, 0x1f, 0) | |
602 | BIT(Vblankstart,9, 0x01, 5) | | 600 | ENCODE_BIT(Vblankstart, 9, 0x01, 5) | |
603 | BIT(1, 0, 0x01, 6); | 601 | ENCODE_BIT(1, 0, 0x01, 6); |
604 | hw->crtc[10] = Vsyncstart; | 602 | hw->crtc[10] = Vsyncstart; |
605 | hw->crtc[11] = BIT(Vsyncend, 0, 0x0f, 0) | | 603 | hw->crtc[11] = ENCODE_BIT(Vsyncend, 0, 0x0f, 0) | |
606 | BIT(1, 0, 0x01, 7); | 604 | ENCODE_BIT(1, 0, 0x01, 7); |
607 | hw->crtc[12] = Vdispend; | 605 | hw->crtc[12] = Vdispend; |
608 | hw->crtc[15] = Vblankstart; | 606 | hw->crtc[15] = Vblankstart; |
609 | hw->crtc[16] = Vblankend; | 607 | hw->crtc[16] = Vblankend; |
@@ -615,10 +613,10 @@ cyber2000fb_decode_crtc(struct par_info *hw, struct cfb_info *cfb, | |||
615 | * 4=LINECOMP:10 5-IVIDEO 6=FIXCNT | 613 | * 4=LINECOMP:10 5-IVIDEO 6=FIXCNT |
616 | */ | 614 | */ |
617 | hw->crtc_ofl = | 615 | hw->crtc_ofl = |
618 | BIT(Vtotal, 10, 0x01, 0) | | 616 | ENCODE_BIT(Vtotal, 10, 0x01, 0) | |
619 | BIT(Vdispend, 10, 0x01, 1) | | 617 | ENCODE_BIT(Vdispend, 10, 0x01, 1) | |
620 | BIT(Vsyncstart, 10, 0x01, 2) | | 618 | ENCODE_BIT(Vsyncstart, 10, 0x01, 2) | |
621 | BIT(Vblankstart,10, 0x01, 3) | | 619 | ENCODE_BIT(Vblankstart, 10, 0x01, 3) | |
622 | EXT_CRT_VRTOFL_LINECOMP10; | 620 | EXT_CRT_VRTOFL_LINECOMP10; |
623 | 621 | ||
624 | /* woody: set the interlaced bit... */ | 622 | /* woody: set the interlaced bit... */ |
@@ -750,11 +748,11 @@ cyber2000fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
750 | var->red.msb_right = 0; | 748 | var->red.msb_right = 0; |
751 | var->green.msb_right = 0; | 749 | var->green.msb_right = 0; |
752 | var->blue.msb_right = 0; | 750 | var->blue.msb_right = 0; |
751 | var->transp.offset = 0; | ||
752 | var->transp.length = 0; | ||
753 | 753 | ||
754 | switch (var->bits_per_pixel) { | 754 | switch (var->bits_per_pixel) { |
755 | case 8: /* PSEUDOCOLOUR, 256 */ | 755 | case 8: /* PSEUDOCOLOUR, 256 */ |
756 | var->transp.offset = 0; | ||
757 | var->transp.length = 0; | ||
758 | var->red.offset = 0; | 756 | var->red.offset = 0; |
759 | var->red.length = 8; | 757 | var->red.length = 8; |
760 | var->green.offset = 0; | 758 | var->green.offset = 0; |
@@ -766,8 +764,6 @@ cyber2000fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
766 | case 16:/* DIRECTCOLOUR, 64k or 32k */ | 764 | case 16:/* DIRECTCOLOUR, 64k or 32k */ |
767 | switch (var->green.length) { | 765 | switch (var->green.length) { |
768 | case 6: /* RGB565, 64k */ | 766 | case 6: /* RGB565, 64k */ |
769 | var->transp.offset = 0; | ||
770 | var->transp.length = 0; | ||
771 | var->red.offset = 11; | 767 | var->red.offset = 11; |
772 | var->red.length = 5; | 768 | var->red.length = 5; |
773 | var->green.offset = 5; | 769 | var->green.offset = 5; |
@@ -778,8 +774,6 @@ cyber2000fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
778 | 774 | ||
779 | default: | 775 | default: |
780 | case 5: /* RGB555, 32k */ | 776 | case 5: /* RGB555, 32k */ |
781 | var->transp.offset = 0; | ||
782 | var->transp.length = 0; | ||
783 | var->red.offset = 10; | 777 | var->red.offset = 10; |
784 | var->red.length = 5; | 778 | var->red.length = 5; |
785 | var->green.offset = 5; | 779 | var->green.offset = 5; |
@@ -802,8 +796,6 @@ cyber2000fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
802 | break; | 796 | break; |
803 | 797 | ||
804 | case 24:/* TRUECOLOUR, 16m */ | 798 | case 24:/* TRUECOLOUR, 16m */ |
805 | var->transp.offset = 0; | ||
806 | var->transp.length = 0; | ||
807 | var->red.offset = 16; | 799 | var->red.offset = 16; |
808 | var->red.length = 8; | 800 | var->red.length = 8; |
809 | var->green.offset = 8; | 801 | var->green.offset = 8; |
@@ -830,7 +822,7 @@ cyber2000fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
830 | mem = var->xres_virtual * var->yres_virtual * (var->bits_per_pixel / 8); | 822 | mem = var->xres_virtual * var->yres_virtual * (var->bits_per_pixel / 8); |
831 | if (mem > cfb->fb.fix.smem_len) | 823 | if (mem > cfb->fb.fix.smem_len) |
832 | var->yres_virtual = cfb->fb.fix.smem_len * 8 / | 824 | var->yres_virtual = cfb->fb.fix.smem_len * 8 / |
833 | (var->bits_per_pixel * var->xres_virtual); | 825 | (var->bits_per_pixel * var->xres_virtual); |
834 | 826 | ||
835 | if (var->yres > var->yres_virtual) | 827 | if (var->yres > var->yres_virtual) |
836 | var->yres = var->yres_virtual; | 828 | var->yres = var->yres_virtual; |
@@ -921,7 +913,7 @@ static int cyber2000fb_set_par(struct fb_info *info) | |||
921 | hw.fetch <<= 1; | 913 | hw.fetch <<= 1; |
922 | hw.fetch += 1; | 914 | hw.fetch += 1; |
923 | 915 | ||
924 | cfb->fb.fix.line_length = var->xres_virtual * var->bits_per_pixel / 8; | 916 | cfb->fb.fix.line_length = var->xres_virtual * var->bits_per_pixel / 8; |
925 | 917 | ||
926 | /* | 918 | /* |
927 | * Same here - if the size of the video mode exceeds the | 919 | * Same here - if the size of the video mode exceeds the |
@@ -952,7 +944,6 @@ static int cyber2000fb_set_par(struct fb_info *info) | |||
952 | return 0; | 944 | return 0; |
953 | } | 945 | } |
954 | 946 | ||
955 | |||
956 | /* | 947 | /* |
957 | * Pan or Wrap the Display | 948 | * Pan or Wrap the Display |
958 | */ | 949 | */ |
@@ -1002,15 +993,15 @@ static int cyber2000fb_blank(int blank, struct fb_info *info) | |||
1002 | switch (blank) { | 993 | switch (blank) { |
1003 | case FB_BLANK_POWERDOWN: /* powerdown - both sync lines down */ | 994 | case FB_BLANK_POWERDOWN: /* powerdown - both sync lines down */ |
1004 | sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_0; | 995 | sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_0; |
1005 | break; | 996 | break; |
1006 | case FB_BLANK_HSYNC_SUSPEND: /* hsync off */ | 997 | case FB_BLANK_HSYNC_SUSPEND: /* hsync off */ |
1007 | sync = EXT_SYNC_CTL_VS_NORMAL | EXT_SYNC_CTL_HS_0; | 998 | sync = EXT_SYNC_CTL_VS_NORMAL | EXT_SYNC_CTL_HS_0; |
1008 | break; | 999 | break; |
1009 | case FB_BLANK_VSYNC_SUSPEND: /* vsync off */ | 1000 | case FB_BLANK_VSYNC_SUSPEND: /* vsync off */ |
1010 | sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_NORMAL; | 1001 | sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_NORMAL; |
1011 | break; | 1002 | break; |
1012 | case FB_BLANK_NORMAL: /* soft blank */ | 1003 | case FB_BLANK_NORMAL: /* soft blank */ |
1013 | default: /* unblank */ | 1004 | default: /* unblank */ |
1014 | break; | 1005 | break; |
1015 | } | 1006 | } |
1016 | 1007 | ||
@@ -1018,7 +1009,8 @@ static int cyber2000fb_blank(int blank, struct fb_info *info) | |||
1018 | 1009 | ||
1019 | if (blank <= 1) { | 1010 | if (blank <= 1) { |
1020 | /* turn on ramdacs */ | 1011 | /* turn on ramdacs */ |
1021 | cfb->ramdac_powerdown &= ~(RAMDAC_DACPWRDN | RAMDAC_BYPASS | RAMDAC_RAMPWRDN); | 1012 | cfb->ramdac_powerdown &= ~(RAMDAC_DACPWRDN | RAMDAC_BYPASS | |
1013 | RAMDAC_RAMPWRDN); | ||
1022 | cyber2000fb_write_ramdac_ctrl(cfb); | 1014 | cyber2000fb_write_ramdac_ctrl(cfb); |
1023 | } | 1015 | } |
1024 | 1016 | ||
@@ -1043,7 +1035,8 @@ static int cyber2000fb_blank(int blank, struct fb_info *info) | |||
1043 | 1035 | ||
1044 | if (blank >= 2) { | 1036 | if (blank >= 2) { |
1045 | /* turn off ramdacs */ | 1037 | /* turn off ramdacs */ |
1046 | cfb->ramdac_powerdown |= RAMDAC_DACPWRDN | RAMDAC_BYPASS | RAMDAC_RAMPWRDN; | 1038 | cfb->ramdac_powerdown |= RAMDAC_DACPWRDN | RAMDAC_BYPASS | |
1039 | RAMDAC_RAMPWRDN; | ||
1047 | cyber2000fb_write_ramdac_ctrl(cfb); | 1040 | cyber2000fb_write_ramdac_ctrl(cfb); |
1048 | } | 1041 | } |
1049 | 1042 | ||
@@ -1068,7 +1061,7 @@ static struct fb_ops cyber2000fb_ops = { | |||
1068 | * of this driver. It is here solely at the moment to support the other | 1061 | * of this driver. It is here solely at the moment to support the other |
1069 | * CyberPro modules external to this driver. | 1062 | * CyberPro modules external to this driver. |
1070 | */ | 1063 | */ |
1071 | static struct cfb_info *int_cfb_info; | 1064 | static struct cfb_info *int_cfb_info; |
1072 | 1065 | ||
1073 | /* | 1066 | /* |
1074 | * Enable access to the extended registers | 1067 | * Enable access to the extended registers |
@@ -1085,6 +1078,7 @@ void cyber2000fb_enable_extregs(struct cfb_info *cfb) | |||
1085 | cyber2000_grphw(EXT_FUNC_CTL, old, cfb); | 1078 | cyber2000_grphw(EXT_FUNC_CTL, old, cfb); |
1086 | } | 1079 | } |
1087 | } | 1080 | } |
1081 | EXPORT_SYMBOL(cyber2000fb_enable_extregs); | ||
1088 | 1082 | ||
1089 | /* | 1083 | /* |
1090 | * Disable access to the extended registers | 1084 | * Disable access to the extended registers |
@@ -1104,11 +1098,13 @@ void cyber2000fb_disable_extregs(struct cfb_info *cfb) | |||
1104 | else | 1098 | else |
1105 | cfb->func_use_count -= 1; | 1099 | cfb->func_use_count -= 1; |
1106 | } | 1100 | } |
1101 | EXPORT_SYMBOL(cyber2000fb_disable_extregs); | ||
1107 | 1102 | ||
1108 | void cyber2000fb_get_fb_var(struct cfb_info *cfb, struct fb_var_screeninfo *var) | 1103 | void cyber2000fb_get_fb_var(struct cfb_info *cfb, struct fb_var_screeninfo *var) |
1109 | { | 1104 | { |
1110 | memcpy(var, &cfb->fb.var, sizeof(struct fb_var_screeninfo)); | 1105 | memcpy(var, &cfb->fb.var, sizeof(struct fb_var_screeninfo)); |
1111 | } | 1106 | } |
1107 | EXPORT_SYMBOL(cyber2000fb_get_fb_var); | ||
1112 | 1108 | ||
1113 | /* | 1109 | /* |
1114 | * Attach a capture/tv driver to the core CyberX0X0 driver. | 1110 | * Attach a capture/tv driver to the core CyberX0X0 driver. |
@@ -1122,13 +1118,15 @@ int cyber2000fb_attach(struct cyberpro_info *info, int idx) | |||
1122 | info->fb_size = int_cfb_info->fb.fix.smem_len; | 1118 | info->fb_size = int_cfb_info->fb.fix.smem_len; |
1123 | info->enable_extregs = cyber2000fb_enable_extregs; | 1119 | info->enable_extregs = cyber2000fb_enable_extregs; |
1124 | info->disable_extregs = cyber2000fb_disable_extregs; | 1120 | info->disable_extregs = cyber2000fb_disable_extregs; |
1125 | info->info = int_cfb_info; | 1121 | info->info = int_cfb_info; |
1126 | 1122 | ||
1127 | strlcpy(info->dev_name, int_cfb_info->fb.fix.id, sizeof(info->dev_name)); | 1123 | strlcpy(info->dev_name, int_cfb_info->fb.fix.id, |
1124 | sizeof(info->dev_name)); | ||
1128 | } | 1125 | } |
1129 | 1126 | ||
1130 | return int_cfb_info != NULL; | 1127 | return int_cfb_info != NULL; |
1131 | } | 1128 | } |
1129 | EXPORT_SYMBOL(cyber2000fb_attach); | ||
1132 | 1130 | ||
1133 | /* | 1131 | /* |
1134 | * Detach a capture/tv driver from the core CyberX0X0 driver. | 1132 | * Detach a capture/tv driver from the core CyberX0X0 driver. |
@@ -1136,12 +1134,7 @@ int cyber2000fb_attach(struct cyberpro_info *info, int idx) | |||
1136 | void cyber2000fb_detach(int idx) | 1134 | void cyber2000fb_detach(int idx) |
1137 | { | 1135 | { |
1138 | } | 1136 | } |
1139 | |||
1140 | EXPORT_SYMBOL(cyber2000fb_attach); | ||
1141 | EXPORT_SYMBOL(cyber2000fb_detach); | 1137 | EXPORT_SYMBOL(cyber2000fb_detach); |
1142 | EXPORT_SYMBOL(cyber2000fb_enable_extregs); | ||
1143 | EXPORT_SYMBOL(cyber2000fb_disable_extregs); | ||
1144 | EXPORT_SYMBOL(cyber2000fb_get_fb_var); | ||
1145 | 1138 | ||
1146 | /* | 1139 | /* |
1147 | * These parameters give | 1140 | * These parameters give |
@@ -1205,7 +1198,7 @@ static void cyberpro_init_hw(struct cfb_info *cfb) | |||
1205 | int i; | 1198 | int i; |
1206 | 1199 | ||
1207 | for (i = 0; i < sizeof(igs_regs); i += 2) | 1200 | for (i = 0; i < sizeof(igs_regs); i += 2) |
1208 | cyber2000_grphw(igs_regs[i], igs_regs[i+1], cfb); | 1201 | cyber2000_grphw(igs_regs[i], igs_regs[i + 1], cfb); |
1209 | 1202 | ||
1210 | if (cfb->id == ID_CYBERPRO_5000) { | 1203 | if (cfb->id == ID_CYBERPRO_5000) { |
1211 | unsigned char val; | 1204 | unsigned char val; |
@@ -1215,8 +1208,8 @@ static void cyberpro_init_hw(struct cfb_info *cfb) | |||
1215 | } | 1208 | } |
1216 | } | 1209 | } |
1217 | 1210 | ||
1218 | static struct cfb_info * __devinit | 1211 | static struct cfb_info __devinit *cyberpro_alloc_fb_info(unsigned int id, |
1219 | cyberpro_alloc_fb_info(unsigned int id, char *name) | 1212 | char *name) |
1220 | { | 1213 | { |
1221 | struct cfb_info *cfb; | 1214 | struct cfb_info *cfb; |
1222 | 1215 | ||
@@ -1228,9 +1221,9 @@ cyberpro_alloc_fb_info(unsigned int id, char *name) | |||
1228 | cfb->id = id; | 1221 | cfb->id = id; |
1229 | 1222 | ||
1230 | if (id == ID_CYBERPRO_5000) | 1223 | if (id == ID_CYBERPRO_5000) |
1231 | cfb->ref_ps = 40690; // 24.576 MHz | 1224 | cfb->ref_ps = 40690; /* 24.576 MHz */ |
1232 | else | 1225 | else |
1233 | cfb->ref_ps = 69842; // 14.31818 MHz (69841?) | 1226 | cfb->ref_ps = 69842; /* 14.31818 MHz (69841?) */ |
1234 | 1227 | ||
1235 | cfb->divisors[0] = 1; | 1228 | cfb->divisors[0] = 1; |
1236 | cfb->divisors[1] = 2; | 1229 | cfb->divisors[1] = 2; |
@@ -1282,8 +1275,7 @@ cyberpro_alloc_fb_info(unsigned int id, char *name) | |||
1282 | return cfb; | 1275 | return cfb; |
1283 | } | 1276 | } |
1284 | 1277 | ||
1285 | static void | 1278 | static void cyberpro_free_fb_info(struct cfb_info *cfb) |
1286 | cyberpro_free_fb_info(struct cfb_info *cfb) | ||
1287 | { | 1279 | { |
1288 | if (cfb) { | 1280 | if (cfb) { |
1289 | /* | 1281 | /* |
@@ -1300,8 +1292,7 @@ cyberpro_free_fb_info(struct cfb_info *cfb) | |||
1300 | * video=cyber2000:font:fontname | 1292 | * video=cyber2000:font:fontname |
1301 | */ | 1293 | */ |
1302 | #ifndef MODULE | 1294 | #ifndef MODULE |
1303 | static int | 1295 | static int cyber2000fb_setup(char *options) |
1304 | cyber2000fb_setup(char *options) | ||
1305 | { | 1296 | { |
1306 | char *opt; | 1297 | char *opt; |
1307 | 1298 | ||
@@ -1315,7 +1306,8 @@ cyber2000fb_setup(char *options) | |||
1315 | if (strncmp(opt, "font:", 5) == 0) { | 1306 | if (strncmp(opt, "font:", 5) == 0) { |
1316 | static char default_font_storage[40]; | 1307 | static char default_font_storage[40]; |
1317 | 1308 | ||
1318 | strlcpy(default_font_storage, opt + 5, sizeof(default_font_storage)); | 1309 | strlcpy(default_font_storage, opt + 5, |
1310 | sizeof(default_font_storage)); | ||
1319 | default_font = default_font_storage; | 1311 | default_font = default_font_storage; |
1320 | continue; | 1312 | continue; |
1321 | } | 1313 | } |
@@ -1354,10 +1346,18 @@ static int __devinit cyberpro_common_probe(struct cfb_info *cfb) | |||
1354 | * Determine the size of the memory. | 1346 | * Determine the size of the memory. |
1355 | */ | 1347 | */ |
1356 | switch (cfb->mem_ctl2 & MEM_CTL2_SIZE_MASK) { | 1348 | switch (cfb->mem_ctl2 & MEM_CTL2_SIZE_MASK) { |
1357 | case MEM_CTL2_SIZE_4MB: smem_size = 0x00400000; break; | 1349 | case MEM_CTL2_SIZE_4MB: |
1358 | case MEM_CTL2_SIZE_2MB: smem_size = 0x00200000; break; | 1350 | smem_size = 0x00400000; |
1359 | case MEM_CTL2_SIZE_1MB: smem_size = 0x00100000; break; | 1351 | break; |
1360 | default: smem_size = 0x00100000; break; | 1352 | case MEM_CTL2_SIZE_2MB: |
1353 | smem_size = 0x00200000; | ||
1354 | break; | ||
1355 | case MEM_CTL2_SIZE_1MB: | ||
1356 | smem_size = 0x00100000; | ||
1357 | break; | ||
1358 | default: | ||
1359 | smem_size = 0x00100000; | ||
1360 | break; | ||
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | cfb->fb.fix.smem_len = smem_size; | 1363 | cfb->fb.fix.smem_len = smem_size; |
@@ -1366,8 +1366,8 @@ static int __devinit cyberpro_common_probe(struct cfb_info *cfb) | |||
1366 | 1366 | ||
1367 | err = -EINVAL; | 1367 | err = -EINVAL; |
1368 | if (!fb_find_mode(&cfb->fb.var, &cfb->fb, NULL, NULL, 0, | 1368 | if (!fb_find_mode(&cfb->fb.var, &cfb->fb, NULL, NULL, 0, |
1369 | &cyber2000fb_default_mode, 8)) { | 1369 | &cyber2000fb_default_mode, 8)) { |
1370 | printk("%s: no valid mode found\n", cfb->fb.fix.id); | 1370 | printk(KERN_ERR "%s: no valid mode found\n", cfb->fb.fix.id); |
1371 | goto failed; | 1371 | goto failed; |
1372 | } | 1372 | } |
1373 | 1373 | ||
@@ -1377,7 +1377,7 @@ static int __devinit cyberpro_common_probe(struct cfb_info *cfb) | |||
1377 | if (cfb->fb.var.yres_virtual < cfb->fb.var.yres) | 1377 | if (cfb->fb.var.yres_virtual < cfb->fb.var.yres) |
1378 | cfb->fb.var.yres_virtual = cfb->fb.var.yres; | 1378 | cfb->fb.var.yres_virtual = cfb->fb.var.yres; |
1379 | 1379 | ||
1380 | // fb_set_var(&cfb->fb.var, -1, &cfb->fb); | 1380 | /* fb_set_var(&cfb->fb.var, -1, &cfb->fb); */ |
1381 | 1381 | ||
1382 | /* | 1382 | /* |
1383 | * Calculate the hsync and vsync frequencies. Note that | 1383 | * Calculate the hsync and vsync frequencies. Note that |
@@ -1425,20 +1425,20 @@ static void cyberpro_common_resume(struct cfb_info *cfb) | |||
1425 | 1425 | ||
1426 | #include <asm/arch/hardware.h> | 1426 | #include <asm/arch/hardware.h> |
1427 | 1427 | ||
1428 | static int __devinit | 1428 | static int __devinit cyberpro_vl_probe(void) |
1429 | cyberpro_vl_probe(void) | ||
1430 | { | 1429 | { |
1431 | struct cfb_info *cfb; | 1430 | struct cfb_info *cfb; |
1432 | int err = -ENOMEM; | 1431 | int err = -ENOMEM; |
1433 | 1432 | ||
1434 | if (!request_mem_region(FB_START,FB_SIZE,"CyberPro2010")) return err; | 1433 | if (!request_mem_region(FB_START, FB_SIZE, "CyberPro2010")) |
1434 | return err; | ||
1435 | 1435 | ||
1436 | cfb = cyberpro_alloc_fb_info(ID_CYBERPRO_2010, "CyberPro2010"); | 1436 | cfb = cyberpro_alloc_fb_info(ID_CYBERPRO_2010, "CyberPro2010"); |
1437 | if (!cfb) | 1437 | if (!cfb) |
1438 | goto failed_release; | 1438 | goto failed_release; |
1439 | 1439 | ||
1440 | cfb->dev = NULL; | 1440 | cfb->dev = NULL; |
1441 | cfb->region = ioremap(FB_START,FB_SIZE); | 1441 | cfb->region = ioremap(FB_START, FB_SIZE); |
1442 | if (!cfb->region) | 1442 | if (!cfb->region) |
1443 | goto failed_ioremap; | 1443 | goto failed_ioremap; |
1444 | 1444 | ||
@@ -1475,7 +1475,7 @@ failed: | |||
1475 | failed_ioremap: | 1475 | failed_ioremap: |
1476 | cyberpro_free_fb_info(cfb); | 1476 | cyberpro_free_fb_info(cfb); |
1477 | failed_release: | 1477 | failed_release: |
1478 | release_mem_region(FB_START,FB_SIZE); | 1478 | release_mem_region(FB_START, FB_SIZE); |
1479 | 1479 | ||
1480 | return err; | 1480 | return err; |
1481 | } | 1481 | } |
@@ -1538,7 +1538,8 @@ static int cyberpro_pci_enable_mmio(struct cfb_info *cfb) | |||
1538 | * Allow the CyberPro to accept PCI burst accesses | 1538 | * Allow the CyberPro to accept PCI burst accesses |
1539 | */ | 1539 | */ |
1540 | if (cfb->id == ID_CYBERPRO_2010) { | 1540 | if (cfb->id == ID_CYBERPRO_2010) { |
1541 | printk(KERN_INFO "%s: NOT enabling PCI bursts\n", cfb->fb.fix.id); | 1541 | printk(KERN_INFO "%s: NOT enabling PCI bursts\n", |
1542 | cfb->fb.fix.id); | ||
1542 | } else { | 1543 | } else { |
1543 | val = cyber2000_grphr(EXT_BUS_CTL, cfb); | 1544 | val = cyber2000_grphr(EXT_BUS_CTL, cfb); |
1544 | if (!(val & EXT_BUS_CTL_PCIBURST_WRITE)) { | 1545 | if (!(val & EXT_BUS_CTL_PCIBURST_WRITE)) { |
@@ -1688,9 +1689,10 @@ static int cyberpro_pci_resume(struct pci_dev *dev) | |||
1688 | } | 1689 | } |
1689 | 1690 | ||
1690 | static struct pci_device_id cyberpro_pci_table[] = { | 1691 | static struct pci_device_id cyberpro_pci_table[] = { |
1691 | // Not yet | 1692 | /* Not yet |
1692 | // { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682, | 1693 | * { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682, |
1693 | // PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_IGA_1682 }, | 1694 | * PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_IGA_1682 }, |
1695 | */ | ||
1694 | { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2000, | 1696 | { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2000, |
1695 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_CYBERPRO_2000 }, | 1697 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_CYBERPRO_2000 }, |
1696 | { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2010, | 1698 | { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2010, |
@@ -1700,7 +1702,7 @@ static struct pci_device_id cyberpro_pci_table[] = { | |||
1700 | { 0, } | 1702 | { 0, } |
1701 | }; | 1703 | }; |
1702 | 1704 | ||
1703 | MODULE_DEVICE_TABLE(pci,cyberpro_pci_table); | 1705 | MODULE_DEVICE_TABLE(pci, cyberpro_pci_table); |
1704 | 1706 | ||
1705 | static struct pci_driver cyberpro_driver = { | 1707 | static struct pci_driver cyberpro_driver = { |
1706 | .name = "CyberPro", | 1708 | .name = "CyberPro", |
diff --git a/drivers/video/geode/video_gx.c b/drivers/video/geode/video_gx.c index 7f3f18d06718..febf09c63492 100644 --- a/drivers/video/geode/video_gx.c +++ b/drivers/video/geode/video_gx.c | |||
@@ -127,7 +127,7 @@ static void gx_set_dclk_frequency(struct fb_info *info) | |||
127 | int timeout = 1000; | 127 | int timeout = 1000; |
128 | 128 | ||
129 | /* Rev. 1 Geode GXs use a 14 MHz reference clock instead of 48 MHz. */ | 129 | /* Rev. 1 Geode GXs use a 14 MHz reference clock instead of 48 MHz. */ |
130 | if (cpu_data->x86_mask == 1) { | 130 | if (cpu_data(0).x86_mask == 1) { |
131 | pll_table = gx_pll_table_14MHz; | 131 | pll_table = gx_pll_table_14MHz; |
132 | pll_table_len = ARRAY_SIZE(gx_pll_table_14MHz); | 132 | pll_table_len = ARRAY_SIZE(gx_pll_table_14MHz); |
133 | } else { | 133 | } else { |
diff --git a/drivers/video/pnx4008/sdum.h b/drivers/video/pnx4008/sdum.h index e8c5dcdd8813..189c3d641383 100644 --- a/drivers/video/pnx4008/sdum.h +++ b/drivers/video/pnx4008/sdum.h | |||
@@ -77,9 +77,6 @@ | |||
77 | #define CONF_DIRTYDETECTION_OFF (0x600) | 77 | #define CONF_DIRTYDETECTION_OFF (0x600) |
78 | #define CONF_DIRTYDETECTION_ON (0x601) | 78 | #define CONF_DIRTYDETECTION_ON (0x601) |
79 | 79 | ||
80 | /* Set the corresponding bit. */ | ||
81 | #define BIT(n) (0x1U << (n)) | ||
82 | |||
83 | struct dumchannel_uf { | 80 | struct dumchannel_uf { |
84 | int channelnr; | 81 | int channelnr; |
85 | u32 *dirty; | 82 | u32 *dirty; |
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c index 38bd37372599..a684b1e87372 100644 --- a/drivers/watchdog/at91rm9200_wdt.c +++ b/drivers/watchdog/at91rm9200_wdt.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * 2 of the License, or (at your option) any later version. | 9 | * 2 of the License, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/bitops.h> | ||
12 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
13 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
14 | #include <linux/init.h> | 15 | #include <linux/init.h> |
@@ -19,7 +20,6 @@ | |||
19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
20 | #include <linux/types.h> | 21 | #include <linux/types.h> |
21 | #include <linux/watchdog.h> | 22 | #include <linux/watchdog.h> |
22 | #include <asm/bitops.h> | ||
23 | #include <asm/uaccess.h> | 23 | #include <asm/uaccess.h> |
24 | #include <asm/arch/at91_st.h> | 24 | #include <asm/arch/at91_st.h> |
25 | 25 | ||
diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c index 7150fb945eaf..e3a29c302309 100644 --- a/drivers/watchdog/ks8695_wdt.c +++ b/drivers/watchdog/ks8695_wdt.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/bitops.h> | ||
11 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
12 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
@@ -18,7 +19,6 @@ | |||
18 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
19 | #include <linux/types.h> | 20 | #include <linux/types.h> |
20 | #include <linux/watchdog.h> | 21 | #include <linux/watchdog.h> |
21 | #include <asm/bitops.h> | ||
22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
23 | #include <asm/uaccess.h> | 23 | #include <asm/uaccess.h> |
24 | #include <asm/arch/regs-timer.h> | 24 | #include <asm/arch/regs-timer.h> |
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index 719b066f73c4..635ca454f56b 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c | |||
@@ -39,11 +39,11 @@ | |||
39 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
40 | #include <linux/moduleparam.h> | 40 | #include <linux/moduleparam.h> |
41 | #include <linux/clk.h> | 41 | #include <linux/clk.h> |
42 | #include <linux/bitops.h> | ||
42 | 43 | ||
43 | #include <asm/io.h> | 44 | #include <asm/io.h> |
44 | #include <asm/uaccess.h> | 45 | #include <asm/uaccess.h> |
45 | #include <asm/hardware.h> | 46 | #include <asm/hardware.h> |
46 | #include <asm/bitops.h> | ||
47 | 47 | ||
48 | #include <asm/arch/prcm.h> | 48 | #include <asm/arch/prcm.h> |
49 | 49 | ||
diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c index 3475f47aaa45..34a2b3b81800 100644 --- a/drivers/watchdog/sa1100_wdt.c +++ b/drivers/watchdog/sa1100_wdt.c | |||
@@ -25,13 +25,13 @@ | |||
25 | #include <linux/miscdevice.h> | 25 | #include <linux/miscdevice.h> |
26 | #include <linux/watchdog.h> | 26 | #include <linux/watchdog.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/bitops.h> | ||
28 | 29 | ||
29 | #ifdef CONFIG_ARCH_PXA | 30 | #ifdef CONFIG_ARCH_PXA |
30 | #include <asm/arch/pxa-regs.h> | 31 | #include <asm/arch/pxa-regs.h> |
31 | #endif | 32 | #endif |
32 | 33 | ||
33 | #include <asm/hardware.h> | 34 | #include <asm/hardware.h> |
34 | #include <asm/bitops.h> | ||
35 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
36 | 36 | ||
37 | #define OSCR_FREQ CLOCK_TICK_RATE | 37 | #define OSCR_FREQ CLOCK_TICK_RATE |