aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/acpica/accommon.h2
-rw-r--r--drivers/acpi/acpica/acconfig.h2
-rw-r--r--drivers/acpi/acpica/acdebug.h2
-rw-r--r--drivers/acpi/acpica/acdispat.h2
-rw-r--r--drivers/acpi/acpica/acevents.h5
-rw-r--r--drivers/acpi/acpica/acglobal.h2
-rw-r--r--drivers/acpi/acpica/achware.h2
-rw-r--r--drivers/acpi/acpica/acinterp.h44
-rw-r--r--drivers/acpi/acpica/aclocal.h6
-rw-r--r--drivers/acpi/acpica/acmacros.h14
-rw-r--r--drivers/acpi/acpica/acnamesp.h18
-rw-r--r--drivers/acpi/acpica/acobject.h4
-rw-r--r--drivers/acpi/acpica/acopcode.h2
-rw-r--r--drivers/acpi/acpica/acparser.h2
-rw-r--r--drivers/acpi/acpica/acpredef.h2
-rw-r--r--drivers/acpi/acpica/acresrc.h2
-rw-r--r--drivers/acpi/acpica/acstruct.h2
-rw-r--r--drivers/acpi/acpica/actables.h2
-rw-r--r--drivers/acpi/acpica/acutils.h22
-rw-r--r--drivers/acpi/acpica/amlcode.h2
-rw-r--r--drivers/acpi/acpica/amlresrc.h2
-rw-r--r--drivers/acpi/acpica/dsfield.c12
-rw-r--r--drivers/acpi/acpica/dsinit.c2
-rw-r--r--drivers/acpi/acpica/dsmethod.c2
-rw-r--r--drivers/acpi/acpica/dsmthdat.c2
-rw-r--r--drivers/acpi/acpica/dsobject.c4
-rw-r--r--drivers/acpi/acpica/dsopcode.c2
-rw-r--r--drivers/acpi/acpica/dsutils.c2
-rw-r--r--drivers/acpi/acpica/dswexec.c2
-rw-r--r--drivers/acpi/acpica/dswload.c2
-rw-r--r--drivers/acpi/acpica/dswscope.c2
-rw-r--r--drivers/acpi/acpica/dswstate.c2
-rw-r--r--drivers/acpi/acpica/evevent.c2
-rw-r--r--drivers/acpi/acpica/evgpe.c2
-rw-r--r--drivers/acpi/acpica/evgpeblk.c2
-rw-r--r--drivers/acpi/acpica/evmisc.c2
-rw-r--r--drivers/acpi/acpica/evregion.c7
-rw-r--r--drivers/acpi/acpica/evrgnini.c4
-rw-r--r--drivers/acpi/acpica/evsci.c2
-rw-r--r--drivers/acpi/acpica/evxface.c2
-rw-r--r--drivers/acpi/acpica/evxfevnt.c2
-rw-r--r--drivers/acpi/acpica/evxfregn.c2
-rw-r--r--drivers/acpi/acpica/exconfig.c17
-rw-r--r--drivers/acpi/acpica/exconvrt.c21
-rw-r--r--drivers/acpi/acpica/excreate.c2
-rw-r--r--drivers/acpi/acpica/exdump.c2
-rw-r--r--drivers/acpi/acpica/exfield.c9
-rw-r--r--drivers/acpi/acpica/exfldio.c59
-rw-r--r--drivers/acpi/acpica/exmisc.c12
-rw-r--r--drivers/acpi/acpica/exmutex.c2
-rw-r--r--drivers/acpi/acpica/exnames.c2
-rw-r--r--drivers/acpi/acpica/exoparg1.c16
-rw-r--r--drivers/acpi/acpica/exoparg2.c6
-rw-r--r--drivers/acpi/acpica/exoparg3.c4
-rw-r--r--drivers/acpi/acpica/exoparg6.c10
-rw-r--r--drivers/acpi/acpica/exprep.c2
-rw-r--r--drivers/acpi/acpica/exregion.c35
-rw-r--r--drivers/acpi/acpica/exresnte.c2
-rw-r--r--drivers/acpi/acpica/exresolv.c2
-rw-r--r--drivers/acpi/acpica/exresop.c2
-rw-r--r--drivers/acpi/acpica/exstore.c2
-rw-r--r--drivers/acpi/acpica/exstoren.c2
-rw-r--r--drivers/acpi/acpica/exstorob.c2
-rw-r--r--drivers/acpi/acpica/exsystem.c4
-rw-r--r--drivers/acpi/acpica/exutils.c24
-rw-r--r--drivers/acpi/acpica/hwacpi.c2
-rw-r--r--drivers/acpi/acpica/hwgpe.c8
-rw-r--r--drivers/acpi/acpica/hwregs.c2
-rw-r--r--drivers/acpi/acpica/hwsleep.c2
-rw-r--r--drivers/acpi/acpica/hwtimer.c4
-rw-r--r--drivers/acpi/acpica/hwvalid.c2
-rw-r--r--drivers/acpi/acpica/hwxface.c2
-rw-r--r--drivers/acpi/acpica/nsaccess.c2
-rw-r--r--drivers/acpi/acpica/nsalloc.c2
-rw-r--r--drivers/acpi/acpica/nsdump.c2
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c2
-rw-r--r--drivers/acpi/acpica/nseval.c2
-rw-r--r--drivers/acpi/acpica/nsinit.c2
-rw-r--r--drivers/acpi/acpica/nsload.c2
-rw-r--r--drivers/acpi/acpica/nsnames.c2
-rw-r--r--drivers/acpi/acpica/nsobject.c2
-rw-r--r--drivers/acpi/acpica/nsparse.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c53
-rw-r--r--drivers/acpi/acpica/nsrepair.c175
-rw-r--r--drivers/acpi/acpica/nsrepair2.c110
-rw-r--r--drivers/acpi/acpica/nssearch.c2
-rw-r--r--drivers/acpi/acpica/nsutils.c2
-rw-r--r--drivers/acpi/acpica/nswalk.c2
-rw-r--r--drivers/acpi/acpica/nsxfeval.c54
-rw-r--r--drivers/acpi/acpica/nsxfname.c2
-rw-r--r--drivers/acpi/acpica/nsxfobj.c2
-rw-r--r--drivers/acpi/acpica/psargs.c4
-rw-r--r--drivers/acpi/acpica/psloop.c2
-rw-r--r--drivers/acpi/acpica/psopcode.c2
-rw-r--r--drivers/acpi/acpica/psparse.c2
-rw-r--r--drivers/acpi/acpica/psscope.c2
-rw-r--r--drivers/acpi/acpica/pstree.c2
-rw-r--r--drivers/acpi/acpica/psutils.c2
-rw-r--r--drivers/acpi/acpica/pswalk.c2
-rw-r--r--drivers/acpi/acpica/psxface.c2
-rw-r--r--drivers/acpi/acpica/rsaddr.c2
-rw-r--r--drivers/acpi/acpica/rscalc.c2
-rw-r--r--drivers/acpi/acpica/rscreate.c4
-rw-r--r--drivers/acpi/acpica/rsdump.c2
-rw-r--r--drivers/acpi/acpica/rsinfo.c2
-rw-r--r--drivers/acpi/acpica/rsio.c2
-rw-r--r--drivers/acpi/acpica/rsirq.c2
-rw-r--r--drivers/acpi/acpica/rslist.c2
-rw-r--r--drivers/acpi/acpica/rsmemory.c2
-rw-r--r--drivers/acpi/acpica/rsmisc.c2
-rw-r--r--drivers/acpi/acpica/rsutils.c2
-rw-r--r--drivers/acpi/acpica/rsxface.c2
-rw-r--r--drivers/acpi/acpica/tbfadt.c2
-rw-r--r--drivers/acpi/acpica/tbfind.c2
-rw-r--r--drivers/acpi/acpica/tbinstal.c2
-rw-r--r--drivers/acpi/acpica/tbutils.c2
-rw-r--r--drivers/acpi/acpica/tbxface.c2
-rw-r--r--drivers/acpi/acpica/tbxfroot.c2
-rw-r--r--drivers/acpi/acpica/utalloc.c2
-rw-r--r--drivers/acpi/acpica/utcopy.c2
-rw-r--r--drivers/acpi/acpica/utdebug.c5
-rw-r--r--drivers/acpi/acpica/utdelete.c2
-rw-r--r--drivers/acpi/acpica/uteval.c4
-rw-r--r--drivers/acpi/acpica/utglobal.c4
-rw-r--r--drivers/acpi/acpica/utids.c2
-rw-r--r--drivers/acpi/acpica/utinit.c2
-rw-r--r--drivers/acpi/acpica/utlock.c2
-rw-r--r--drivers/acpi/acpica/utmath.c27
-rw-r--r--drivers/acpi/acpica/utmisc.c16
-rw-r--r--drivers/acpi/acpica/utmutex.c18
-rw-r--r--drivers/acpi/acpica/utobject.c2
-rw-r--r--drivers/acpi/acpica/utresrc.c2
-rw-r--r--drivers/acpi/acpica/utstate.c2
-rw-r--r--drivers/acpi/acpica/utxface.c2
-rw-r--r--drivers/acpi/battery.c4
-rw-r--r--drivers/acpi/ec.c4
-rw-r--r--drivers/acpi/glue.c4
-rw-r--r--drivers/acpi/osl.c4
-rw-r--r--drivers/acpi/power_meter.c30
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/acpi/processor_throttling.c24
-rw-r--r--drivers/acpi/utils.c16
-rw-r--r--drivers/acpi/video.c2
-rw-r--r--drivers/ata/libata-acpi.c4
-rw-r--r--drivers/char/keyboard.c29
-rw-r--r--drivers/ide/ide-acpi.c8
-rw-r--r--drivers/input/evdev.c2
-rw-r--r--drivers/input/gameport/emu10k1-gp.c2
-rw-r--r--drivers/input/gameport/fm801-gp.c2
-rw-r--r--drivers/input/gameport/gameport.c98
-rw-r--r--drivers/input/gameport/ns558.c2
-rw-r--r--drivers/input/input-compat.h2
-rw-r--r--drivers/input/input.c90
-rw-r--r--drivers/input/joydev.c34
-rw-r--r--drivers/input/joystick/Kconfig1
-rw-r--r--drivers/input/joystick/gamecon.c664
-rw-r--r--drivers/input/joystick/xpad.c253
-rw-r--r--drivers/input/keyboard/Kconfig33
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/adp5588-keys.c6
-rw-r--r--drivers/input/keyboard/atkbd.c309
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c40
-rw-r--r--drivers/input/keyboard/gpio_keys.c318
-rw-r--r--drivers/input/keyboard/imx_keypad.c594
-rw-r--r--drivers/input/keyboard/qt2160.c2
-rw-r--r--drivers/input/keyboard/sh_keysc.c145
-rw-r--r--drivers/input/misc/apanel.c2
-rw-r--r--drivers/input/misc/atlas_btns.c2
-rw-r--r--drivers/input/misc/rotary_encoder.c14
-rw-r--r--drivers/input/misc/uinput.c4
-rw-r--r--drivers/input/misc/winbond-cir.c213
-rw-r--r--drivers/input/mouse/hgpk.c4
-rw-r--r--drivers/input/serio/pcips2.c2
-rw-r--r--drivers/input/serio/serio.c131
-rw-r--r--drivers/input/serio/xilinx_ps2.c6
-rw-r--r--drivers/input/tablet/gtco.c2
-rw-r--r--drivers/input/tablet/wacom.h5
-rw-r--r--drivers/input/tablet/wacom_sys.c70
-rw-r--r--drivers/input/tablet/wacom_wac.c408
-rw-r--r--drivers/input/tablet/wacom_wac.h17
-rw-r--r--drivers/input/touchscreen/Kconfig6
-rw-r--r--drivers/input/touchscreen/ads7846.c28
-rw-r--r--drivers/input/touchscreen/elo.c225
-rw-r--r--drivers/input/touchscreen/mainstone-wm97xx.c3
-rw-r--r--drivers/input/touchscreen/s3c2410_ts.c31
-rw-r--r--drivers/input/touchscreen/tsc2007.c2
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c317
-rw-r--r--drivers/input/touchscreen/zylonite-wm97xx.c3
-rw-r--r--drivers/input/xen-kbdfront.c2
-rw-r--r--drivers/macintosh/Kconfig7
-rw-r--r--drivers/macintosh/mac_hid.c266
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/platform/x86/toshiba_bluetooth.c4
-rw-r--r--drivers/platform/x86/wmi.c4
194 files changed, 3705 insertions, 1841 deletions
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
index 3b20786cbb0..3e50c74ed4a 100644
--- a/drivers/acpi/acpica/accommon.h
+++ b/drivers/acpi/acpica/accommon.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
index a4471e3d385..33181ad350d 100644
--- a/drivers/acpi/acpica/acconfig.h
+++ b/drivers/acpi/acpica/acconfig.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index a4fb001d96f..48faf3eba9f 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 6291904be01..894a0ff2a94 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 4ced54f7a5d..3e6ba99e405 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -133,8 +133,7 @@ acpi_status acpi_ev_initialize_op_regions(void);
133acpi_status 133acpi_status
134acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, 134acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
135 u32 function, 135 u32 function,
136 u32 region_offset, 136 u32 region_offset, u32 bit_width, u64 *value);
137 u32 bit_width, acpi_integer * value);
138 137
139acpi_status 138acpi_status
140acpi_ev_attach_region(union acpi_operand_object *handler_obj, 139acpi_ev_attach_region(union acpi_operand_object *handler_obj,
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 29ba66d5a79..f8dd8f250ac 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 36192f142fb..5900f135dc6 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index 5db9f2916f7..6df3f842816 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -129,18 +129,17 @@ acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc,
129 129
130acpi_status 130acpi_status
131acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, 131acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
132 acpi_integer mask, 132 u64 mask,
133 acpi_integer field_value, 133 u64 field_value, u32 field_datum_byte_offset);
134 u32 field_datum_byte_offset);
135 134
136void 135void
137acpi_ex_get_buffer_datum(acpi_integer * datum, 136acpi_ex_get_buffer_datum(u64 *datum,
138 void *buffer, 137 void *buffer,
139 u32 buffer_length, 138 u32 buffer_length,
140 u32 byte_granularity, u32 buffer_offset); 139 u32 byte_granularity, u32 buffer_offset);
141 140
142void 141void
143acpi_ex_set_buffer_datum(acpi_integer merged_datum, 142acpi_ex_set_buffer_datum(u64 merged_datum,
144 void *buffer, 143 void *buffer,
145 u32 buffer_length, 144 u32 buffer_length,
146 u32 byte_granularity, u32 buffer_offset); 145 u32 byte_granularity, u32 buffer_offset);
@@ -168,8 +167,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
168 167
169acpi_status 168acpi_status
170acpi_ex_access_region(union acpi_operand_object *obj_desc, 169acpi_ex_access_region(union acpi_operand_object *obj_desc,
171 u32 field_datum_byte_offset, 170 u32 field_datum_byte_offset, u64 *value, u32 read_write);
172 acpi_integer * value, u32 read_write);
173 171
174/* 172/*
175 * exmisc - misc support routines 173 * exmisc - misc support routines
@@ -193,16 +191,14 @@ acpi_ex_do_concatenate(union acpi_operand_object *obj_desc,
193 191
194acpi_status 192acpi_status
195acpi_ex_do_logical_numeric_op(u16 opcode, 193acpi_ex_do_logical_numeric_op(u16 opcode,
196 acpi_integer integer0, 194 u64 integer0, u64 integer1, u8 *logical_result);
197 acpi_integer integer1, u8 * logical_result);
198 195
199acpi_status 196acpi_status
200acpi_ex_do_logical_op(u16 opcode, 197acpi_ex_do_logical_op(u16 opcode,
201 union acpi_operand_object *operand0, 198 union acpi_operand_object *operand0,
202 union acpi_operand_object *operand1, u8 * logical_result); 199 union acpi_operand_object *operand1, u8 *logical_result);
203 200
204acpi_integer 201u64 acpi_ex_do_math_op(u16 opcode, u64 operand0, u64 operand1);
205acpi_ex_do_math_op(u16 opcode, acpi_integer operand0, acpi_integer operand1);
206 202
207acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state); 203acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state);
208 204
@@ -278,7 +274,7 @@ acpi_status
278acpi_ex_system_do_notify_op(union acpi_operand_object *value, 274acpi_ex_system_do_notify_op(union acpi_operand_object *value,
279 union acpi_operand_object *obj_desc); 275 union acpi_operand_object *obj_desc);
280 276
281acpi_status acpi_ex_system_do_suspend(acpi_integer time); 277acpi_status acpi_ex_system_do_suspend(u64 time);
282 278
283acpi_status acpi_ex_system_do_stall(u32 time); 279acpi_status acpi_ex_system_do_stall(u32 time);
284 280
@@ -461,9 +457,9 @@ void acpi_ex_acquire_global_lock(u32 rule);
461 457
462void acpi_ex_release_global_lock(u32 rule); 458void acpi_ex_release_global_lock(u32 rule);
463 459
464void acpi_ex_eisa_id_to_string(char *dest, acpi_integer compressed_id); 460void acpi_ex_eisa_id_to_string(char *dest, u64 compressed_id);
465 461
466void acpi_ex_integer_to_string(char *dest, acpi_integer value); 462void acpi_ex_integer_to_string(char *dest, u64 value);
467 463
468/* 464/*
469 * exregion - default op_region handlers 465 * exregion - default op_region handlers
@@ -472,7 +468,7 @@ acpi_status
472acpi_ex_system_memory_space_handler(u32 function, 468acpi_ex_system_memory_space_handler(u32 function,
473 acpi_physical_address address, 469 acpi_physical_address address,
474 u32 bit_width, 470 u32 bit_width,
475 acpi_integer * value, 471 u64 *value,
476 void *handler_context, 472 void *handler_context,
477 void *region_context); 473 void *region_context);
478 474
@@ -480,35 +476,35 @@ acpi_status
480acpi_ex_system_io_space_handler(u32 function, 476acpi_ex_system_io_space_handler(u32 function,
481 acpi_physical_address address, 477 acpi_physical_address address,
482 u32 bit_width, 478 u32 bit_width,
483 acpi_integer * value, 479 u64 *value,
484 void *handler_context, void *region_context); 480 void *handler_context, void *region_context);
485 481
486acpi_status 482acpi_status
487acpi_ex_pci_config_space_handler(u32 function, 483acpi_ex_pci_config_space_handler(u32 function,
488 acpi_physical_address address, 484 acpi_physical_address address,
489 u32 bit_width, 485 u32 bit_width,
490 acpi_integer * value, 486 u64 *value,
491 void *handler_context, void *region_context); 487 void *handler_context, void *region_context);
492 488
493acpi_status 489acpi_status
494acpi_ex_cmos_space_handler(u32 function, 490acpi_ex_cmos_space_handler(u32 function,
495 acpi_physical_address address, 491 acpi_physical_address address,
496 u32 bit_width, 492 u32 bit_width,
497 acpi_integer * value, 493 u64 *value,
498 void *handler_context, void *region_context); 494 void *handler_context, void *region_context);
499 495
500acpi_status 496acpi_status
501acpi_ex_pci_bar_space_handler(u32 function, 497acpi_ex_pci_bar_space_handler(u32 function,
502 acpi_physical_address address, 498 acpi_physical_address address,
503 u32 bit_width, 499 u32 bit_width,
504 acpi_integer * value, 500 u64 *value,
505 void *handler_context, void *region_context); 501 void *handler_context, void *region_context);
506 502
507acpi_status 503acpi_status
508acpi_ex_embedded_controller_space_handler(u32 function, 504acpi_ex_embedded_controller_space_handler(u32 function,
509 acpi_physical_address address, 505 acpi_physical_address address,
510 u32 bit_width, 506 u32 bit_width,
511 acpi_integer * value, 507 u64 *value,
512 void *handler_context, 508 void *handler_context,
513 void *region_context); 509 void *region_context);
514 510
@@ -516,14 +512,14 @@ acpi_status
516acpi_ex_sm_bus_space_handler(u32 function, 512acpi_ex_sm_bus_space_handler(u32 function,
517 acpi_physical_address address, 513 acpi_physical_address address,
518 u32 bit_width, 514 u32 bit_width,
519 acpi_integer * value, 515 u64 *value,
520 void *handler_context, void *region_context); 516 void *handler_context, void *region_context);
521 517
522acpi_status 518acpi_status
523acpi_ex_data_table_space_handler(u32 function, 519acpi_ex_data_table_space_handler(u32 function,
524 acpi_physical_address address, 520 acpi_physical_address address,
525 u32 bit_width, 521 u32 bit_width,
526 acpi_integer * value, 522 u64 *value,
527 void *handler_context, void *region_context); 523 void *handler_context, void *region_context);
528 524
529#endif /* __INTERP_H__ */ 525#endif /* __INTERP_H__ */
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 13cb80caacd..24b8faa5c39 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -374,6 +374,7 @@ union acpi_predefined_info {
374struct acpi_predefined_data { 374struct acpi_predefined_data {
375 char *pathname; 375 char *pathname;
376 const union acpi_predefined_info *predefined; 376 const union acpi_predefined_info *predefined;
377 union acpi_operand_object *parent_package;
377 u32 flags; 378 u32 flags;
378 u8 node_flags; 379 u8 node_flags;
379}; 380};
@@ -651,8 +652,7 @@ struct acpi_opcode_info {
651}; 652};
652 653
653union acpi_parse_value { 654union acpi_parse_value {
654 acpi_integer integer; /* Integer constant (Up to 64 bits) */ 655 u64 integer; /* Integer constant (Up to 64 bits) */
655 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
656 u32 size; /* bytelist or field size */ 656 u32 size; /* bytelist or field size */
657 char *string; /* NULL terminated string */ 657 char *string; /* NULL terminated string */
658 u8 *buffer; /* buffer or string */ 658 u8 *buffer; /* buffer or string */
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 7d9ba6e5755..9894929a2ab 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -272,8 +272,8 @@
272 * MASK_BITS_ABOVE creates a mask starting AT the position and above 272 * MASK_BITS_ABOVE creates a mask starting AT the position and above
273 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position 273 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
274 */ 274 */
275#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position)))) 275#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((u32) (position))))
276#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position))) 276#define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((u32) (position)))
277 277
278/* Bitfields within ACPI registers */ 278/* Bitfields within ACPI registers */
279 279
@@ -414,16 +414,16 @@
414 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \ 414 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \
415 return (_s); }) 415 return (_s); })
416#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ 416#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
417 register acpi_integer _s = (s); \ 417 register u64 _s = (s); \
418 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ 418 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \
419 return (_s); }) 419 return (_s); })
420#define return_UINT8(s) ACPI_DO_WHILE0 ({ \ 420#define return_UINT8(s) ACPI_DO_WHILE0 ({ \
421 register u8 _s = (u8) (s); \ 421 register u8 _s = (u8) (s); \
422 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \ 422 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \
423 return (_s); }) 423 return (_s); })
424#define return_UINT32(s) ACPI_DO_WHILE0 ({ \ 424#define return_UINT32(s) ACPI_DO_WHILE0 ({ \
425 register u32 _s = (u32) (s); \ 425 register u32 _s = (u32) (s); \
426 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \ 426 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \
427 return (_s); }) 427 return (_s); })
428#else /* Use original less-safe macros */ 428#else /* Use original less-safe macros */
429 429
@@ -434,7 +434,7 @@
434 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \ 434 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \
435 return((s)); }) 435 return((s)); })
436#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ 436#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
437 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) (s)); \ 437 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) (s)); \
438 return((s)); }) 438 return((s)); })
439#define return_UINT8(s) return_VALUE(s) 439#define return_UINT8(s) return_VALUE(s)
440#define return_UINT32(s) return_VALUE(s) 440#define return_UINT32(s) return_VALUE(s)
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 61edb156e8d..258159cfcdf 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -286,6 +286,17 @@ acpi_status
286acpi_ns_repair_package_list(struct acpi_predefined_data *data, 286acpi_ns_repair_package_list(struct acpi_predefined_data *data,
287 union acpi_operand_object **obj_desc_ptr); 287 union acpi_operand_object **obj_desc_ptr);
288 288
289acpi_status
290acpi_ns_repair_null_element(struct acpi_predefined_data *data,
291 u32 expected_btypes,
292 u32 package_index,
293 union acpi_operand_object **return_object_ptr);
294
295void
296acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
297 u8 package_type,
298 union acpi_operand_object *obj_desc);
299
289/* 300/*
290 * nsrepair2 - Return object repair for specific 301 * nsrepair2 - Return object repair for specific
291 * predefined methods/objects 302 * predefined methods/objects
@@ -296,11 +307,6 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
296 acpi_status validate_status, 307 acpi_status validate_status,
297 union acpi_operand_object **return_object_ptr); 308 union acpi_operand_object **return_object_ptr);
298 309
299void
300acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
301 u8 package_type,
302 union acpi_operand_object *obj_desc);
303
304/* 310/*
305 * nssearch - Namespace searching and entry 311 * nssearch - Namespace searching and entry
306 */ 312 */
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index 07f6e2ea2ee..cde18ea8265 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -111,7 +111,7 @@ ACPI_OBJECT_COMMON_HEADER};
111 111
112struct acpi_object_integer { 112struct acpi_object_integer {
113 ACPI_OBJECT_COMMON_HEADER u8 fill[3]; /* Prevent warning on some compilers */ 113 ACPI_OBJECT_COMMON_HEADER u8 fill[3]; /* Prevent warning on some compilers */
114 acpi_integer value; 114 u64 value;
115}; 115};
116 116
117/* 117/*
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index dfdf6332788..8c15ff43f42 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
index 22881e8ce22..d0bb0fd3e57 100644
--- a/drivers/acpi/acpica/acparser.h
+++ b/drivers/acpi/acpica/acparser.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 57bdaf6ffab..97116082cb6 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
index eef5bd7a59f..528bcbaf4ce 100644
--- a/drivers/acpi/acpica/acresrc.h
+++ b/drivers/acpi/acpica/acresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 7980a26bad3..161bc0e3d70 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 01c76b8ea7b..8ff3b741df2 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 3a451a21a3f..35df755251c 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -134,7 +134,7 @@ char *acpi_ut_get_region_name(u8 space_id);
134 134
135char *acpi_ut_get_event_name(u32 event_id); 135char *acpi_ut_get_event_name(u32 event_id);
136 136
137char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position); 137char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
138 138
139u8 acpi_ut_valid_object_type(acpi_object_type type); 139u8 acpi_ut_valid_object_type(acpi_object_type type);
140 140
@@ -279,8 +279,7 @@ acpi_ut_status_exit(u32 line_number,
279void 279void
280acpi_ut_value_exit(u32 line_number, 280acpi_ut_value_exit(u32 line_number,
281 const char *function_name, 281 const char *function_name,
282 const char *module_name, 282 const char *module_name, u32 component_id, u64 value);
283 u32 component_id, acpi_integer value);
284 283
285void 284void
286acpi_ut_ptr_exit(u32 line_number, 285acpi_ut_ptr_exit(u32 line_number,
@@ -324,7 +323,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
324acpi_status 323acpi_status
325acpi_ut_evaluate_numeric_object(char *object_name, 324acpi_ut_evaluate_numeric_object(char *object_name,
326 struct acpi_namespace_node *device_node, 325 struct acpi_namespace_node *device_node,
327 acpi_integer *value); 326 u64 *value);
328 327
329acpi_status 328acpi_status
330acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 *status_flags); 329acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 *status_flags);
@@ -437,14 +436,12 @@ void acpi_ut_delete_generic_state(union acpi_generic_state *state);
437 * utmath 436 * utmath
438 */ 437 */
439acpi_status 438acpi_status
440acpi_ut_divide(acpi_integer in_dividend, 439acpi_ut_divide(u64 in_dividend,
441 acpi_integer in_divisor, 440 u64 in_divisor, u64 *out_quotient, u64 *out_remainder);
442 acpi_integer * out_quotient, acpi_integer * out_remainder);
443 441
444acpi_status 442acpi_status
445acpi_ut_short_divide(acpi_integer in_dividend, 443acpi_ut_short_divide(u64 in_dividend,
446 u32 divisor, 444 u32 divisor, u64 *out_quotient, u32 *out_remainder);
447 acpi_integer * out_quotient, u32 * out_remainder);
448 445
449/* 446/*
450 * utmisc 447 * utmisc
@@ -474,8 +471,7 @@ acpi_name acpi_ut_repair_name(char *name);
474 471
475u8 acpi_ut_valid_acpi_char(char character, u32 position); 472u8 acpi_ut_valid_acpi_char(char character, u32 position);
476 473
477acpi_status 474acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer);
478acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
479 475
480void ACPI_INTERNAL_VAR_XFACE 476void ACPI_INTERNAL_VAR_XFACE
481acpi_ut_predefined_warning(const char *module_name, 477acpi_ut_predefined_warning(const char *module_name,
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index 4940249f252..1f484ba228f 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 7b070e42b7c..0e5798fcbb1 100644
--- a/drivers/acpi/acpica/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index 54a225e56a6..bb13817e0c3 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -220,7 +220,7 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
220 union acpi_parse_object *arg) 220 union acpi_parse_object *arg)
221{ 221{
222 acpi_status status; 222 acpi_status status;
223 acpi_integer position; 223 u64 position;
224 224
225 ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info); 225 ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info);
226 226
@@ -240,8 +240,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
240 switch (arg->common.aml_opcode) { 240 switch (arg->common.aml_opcode) {
241 case AML_INT_RESERVEDFIELD_OP: 241 case AML_INT_RESERVEDFIELD_OP:
242 242
243 position = (acpi_integer) info->field_bit_position 243 position = (u64) info->field_bit_position
244 + (acpi_integer) arg->common.value.size; 244 + (u64) arg->common.value.size;
245 245
246 if (position > ACPI_UINT32_MAX) { 246 if (position > ACPI_UINT32_MAX) {
247 ACPI_ERROR((AE_INFO, 247 ACPI_ERROR((AE_INFO,
@@ -305,8 +305,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
305 305
306 /* Keep track of bit position for the next field */ 306 /* Keep track of bit position for the next field */
307 307
308 position = (acpi_integer) info->field_bit_position 308 position = (u64) info->field_bit_position
309 + (acpi_integer) arg->common.value.size; 309 + (u64) arg->common.value.size;
310 310
311 if (position > ACPI_UINT32_MAX) { 311 if (position > ACPI_UINT32_MAX) {
312 ACPI_ERROR((AE_INFO, 312 ACPI_ERROR((AE_INFO,
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index f23fa0be6fc..abe140318a7 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index e786f9fd767..721039233aa 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index 0ba19f84ad8..cc343b95954 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 9bc1ba07634..891e08bf560 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -684,7 +684,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
684 684
685 case AML_ONES_OP: 685 case AML_ONES_OP:
686 686
687 obj_desc->integer.value = ACPI_INTEGER_MAX; 687 obj_desc->integer.value = ACPI_UINT64_MAX;
688 688
689 /* Truncate value if we are executing from a 32-bit ACPI table */ 689 /* Truncate value if we are executing from a 32-bit ACPI table */
690 690
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index b79978f7bc7..bf980cadb1e 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index dfa10410292..306c62ab2e8 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index f0280856dc0..6b76c486d78 100644
--- a/drivers/acpi/acpica/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index b40513dd6a6..140a9d00295 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswscope.c b/drivers/acpi/acpica/dswscope.c
index 908645e72f0..d1e701709da 100644
--- a/drivers/acpi/acpica/dswscope.c
+++ b/drivers/acpi/acpica/dswscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
index e46c821cf57..050df816416 100644
--- a/drivers/acpi/acpica/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index cd55c774e88..c1e6f472d43 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 0b453467a5a..837de669743 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 3d4c4aca11c..fef721917ea 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 8f0fac6c436..9a3cb7045a3 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 5336d911fbf..98fd210e87b 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -329,7 +329,7 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
329 * region_offset - Where in the region to read or write 329 * region_offset - Where in the region to read or write
330 * bit_width - Field width in bits (8, 16, 32, or 64) 330 * bit_width - Field width in bits (8, 16, 32, or 64)
331 * Value - Pointer to in or out value, must be 331 * Value - Pointer to in or out value, must be
332 * full 64-bit acpi_integer 332 * a full 64-bit integer
333 * 333 *
334 * RETURN: Status 334 * RETURN: Status
335 * 335 *
@@ -341,8 +341,7 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
341acpi_status 341acpi_status
342acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, 342acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
343 u32 function, 343 u32 function,
344 u32 region_offset, 344 u32 region_offset, u32 bit_width, u64 *value)
345 u32 bit_width, acpi_integer * value)
346{ 345{
347 acpi_status status; 346 acpi_status status;
348 acpi_adr_space_handler handler; 347 acpi_adr_space_handler handler;
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index ff168052a33..2e3b0334072 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -168,7 +168,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
168 void *handler_context, void **region_context) 168 void *handler_context, void **region_context)
169{ 169{
170 acpi_status status = AE_OK; 170 acpi_status status = AE_OK;
171 acpi_integer pci_value; 171 u64 pci_value;
172 struct acpi_pci_id *pci_id = *region_context; 172 struct acpi_pci_id *pci_id = *region_context;
173 union acpi_operand_object *handler_obj; 173 union acpi_operand_object *handler_obj;
174 struct acpi_namespace_node *parent_node; 174 struct acpi_namespace_node *parent_node;
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index 567b356c85a..8dfbaa96e42 100644
--- a/drivers/acpi/acpica/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 474e2cab603..b40757955f9 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 124c157215b..5ff32c78ea2 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index c98aa7c2d67..541cbc1544d 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 46adfa541cb..7e8b3bedc37 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -284,7 +284,7 @@ static acpi_status
284acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer) 284acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
285{ 285{
286 acpi_status status; 286 acpi_status status;
287 acpi_integer value; 287 u64 value;
288 u32 region_offset = 0; 288 u32 region_offset = 0;
289 u32 i; 289 u32 i;
290 290
@@ -490,7 +490,11 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
490 490
491 status = acpi_tb_add_table(&table_desc, &table_index); 491 status = acpi_tb_add_table(&table_desc, &table_index);
492 if (ACPI_FAILURE(status)) { 492 if (ACPI_FAILURE(status)) {
493 goto cleanup; 493
494 /* Delete allocated table buffer */
495
496 acpi_tb_delete_table(&table_desc);
497 return_ACPI_STATUS(status);
494 } 498 }
495 499
496 /* 500 /*
@@ -533,13 +537,6 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
533 acpi_gbl_table_handler_context); 537 acpi_gbl_table_handler_context);
534 } 538 }
535 539
536 cleanup:
537 if (ACPI_FAILURE(status)) {
538
539 /* Delete allocated table buffer */
540
541 acpi_tb_delete_table(&table_desc);
542 }
543 return_ACPI_STATUS(status); 540 return_ACPI_STATUS(status);
544} 541}
545 542
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 51d5f224f9f..bda7aed0404 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,8 +51,7 @@ ACPI_MODULE_NAME("exconvrt")
51 51
52/* Local prototypes */ 52/* Local prototypes */
53static u32 53static u32
54acpi_ex_convert_to_ascii(acpi_integer integer, 54acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
55 u16 base, u8 * string, u8 max_length);
56 55
57/******************************************************************************* 56/*******************************************************************************
58 * 57 *
@@ -75,7 +74,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
75{ 74{
76 union acpi_operand_object *return_desc; 75 union acpi_operand_object *return_desc;
77 u8 *pointer; 76 u8 *pointer;
78 acpi_integer result; 77 u64 result;
79 u32 i; 78 u32 i;
80 u32 count; 79 u32 count;
81 acpi_status status; 80 acpi_status status;
@@ -155,7 +154,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
155 * Little endian is used, meaning that the first byte of the buffer 154 * Little endian is used, meaning that the first byte of the buffer
156 * is the LSB of the integer 155 * is the LSB of the integer
157 */ 156 */
158 result |= (((acpi_integer) pointer[i]) << (i * 8)); 157 result |= (((u64) pointer[i]) << (i * 8));
159 } 158 }
160 break; 159 break;
161 160
@@ -285,10 +284,9 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
285 ******************************************************************************/ 284 ******************************************************************************/
286 285
287static u32 286static u32
288acpi_ex_convert_to_ascii(acpi_integer integer, 287acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
289 u16 base, u8 * string, u8 data_width)
290{ 288{
291 acpi_integer digit; 289 u64 digit;
292 u32 i; 290 u32 i;
293 u32 j; 291 u32 j;
294 u32 k = 0; 292 u32 k = 0;
@@ -531,10 +529,9 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
531 * (separated by commas or spaces) 529 * (separated by commas or spaces)
532 */ 530 */
533 for (i = 0; i < obj_desc->buffer.length; i++) { 531 for (i = 0; i < obj_desc->buffer.length; i++) {
534 new_buf += acpi_ex_convert_to_ascii((acpi_integer) 532 new_buf += acpi_ex_convert_to_ascii((u64) obj_desc->
535 obj_desc->buffer. 533 buffer.pointer[i],
536 pointer[i], base, 534 base, new_buf, 1);
537 new_buf, 1);
538 *new_buf++ = separator; /* each separated by a comma or space */ 535 *new_buf++ = separator; /* each separated by a comma or space */
539 } 536 }
540 537
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index 02b25d233d9..0aa57d93869 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index de3446372dd..d39d438ba1e 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index 1588a2d660e..6c79fecbee4 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -130,7 +130,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
130 /* Call the region handler for the read */ 130 /* Call the region handler for the read */
131 131
132 status = acpi_ex_access_region(obj_desc, 0, 132 status = acpi_ex_access_region(obj_desc, 0,
133 ACPI_CAST_PTR(acpi_integer, 133 ACPI_CAST_PTR(u64,
134 buffer_desc-> 134 buffer_desc->
135 buffer.pointer), 135 buffer.pointer),
136 function); 136 function);
@@ -141,7 +141,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
141 /* 141 /*
142 * Allocate a buffer for the contents of the field. 142 * Allocate a buffer for the contents of the field.
143 * 143 *
144 * If the field is larger than the size of an acpi_integer, create 144 * If the field is larger than the current integer width, create
145 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows 145 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
146 * the use of arithmetic operators on the returned value if the 146 * the use of arithmetic operators on the returned value if the
147 * field size is equal or smaller than an Integer. 147 * field size is equal or smaller than an Integer.
@@ -306,8 +306,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
306 * same buffer) 306 * same buffer)
307 */ 307 */
308 status = acpi_ex_access_region(obj_desc, 0, 308 status = acpi_ex_access_region(obj_desc, 0,
309 (acpi_integer *) buffer, 309 (u64 *) buffer, function);
310 function);
311 acpi_ex_release_global_lock(obj_desc->common_field.field_flags); 310 acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
312 311
313 *result_desc = buffer_desc; 312 *result_desc = buffer_desc;
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index d7b3b418fb4..f68a216168b 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -55,11 +55,10 @@ ACPI_MODULE_NAME("exfldio")
55static acpi_status 55static acpi_status
56acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, 56acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
57 u32 field_datum_byte_offset, 57 u32 field_datum_byte_offset,
58 acpi_integer * value, u32 read_write); 58 u64 *value, u32 read_write);
59 59
60static u8 60static u8
61acpi_ex_register_overflow(union acpi_operand_object *obj_desc, 61acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value);
62 acpi_integer value);
63 62
64static acpi_status 63static acpi_status
65acpi_ex_setup_region(union acpi_operand_object *obj_desc, 64acpi_ex_setup_region(union acpi_operand_object *obj_desc,
@@ -212,7 +211,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
212 * field_datum_byte_offset - Byte offset of this datum within the 211 * field_datum_byte_offset - Byte offset of this datum within the
213 * parent field 212 * parent field
214 * Value - Where to store value (must at least 213 * Value - Where to store value (must at least
215 * the size of acpi_integer) 214 * 64 bits)
216 * Function - Read or Write flag plus other region- 215 * Function - Read or Write flag plus other region-
217 * dependent flags 216 * dependent flags
218 * 217 *
@@ -224,8 +223,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
224 223
225acpi_status 224acpi_status
226acpi_ex_access_region(union acpi_operand_object *obj_desc, 225acpi_ex_access_region(union acpi_operand_object *obj_desc,
227 u32 field_datum_byte_offset, 226 u32 field_datum_byte_offset, u64 *value, u32 function)
228 acpi_integer * value, u32 function)
229{ 227{
230 acpi_status status; 228 acpi_status status;
231 union acpi_operand_object *rgn_desc; 229 union acpi_operand_object *rgn_desc;
@@ -317,8 +315,7 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
317 ******************************************************************************/ 315 ******************************************************************************/
318 316
319static u8 317static u8
320acpi_ex_register_overflow(union acpi_operand_object *obj_desc, 318acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
321 acpi_integer value)
322{ 319{
323 320
324 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) { 321 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
@@ -329,7 +326,7 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
329 return (FALSE); 326 return (FALSE);
330 } 327 }
331 328
332 if (value >= ((acpi_integer) 1 << obj_desc->common_field.bit_length)) { 329 if (value >= ((u64) 1 << obj_desc->common_field.bit_length)) {
333 /* 330 /*
334 * The Value is larger than the maximum value that can fit into 331 * The Value is larger than the maximum value that can fit into
335 * the register. 332 * the register.
@@ -362,11 +359,10 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
362 359
363static acpi_status 360static acpi_status
364acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, 361acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
365 u32 field_datum_byte_offset, 362 u32 field_datum_byte_offset, u64 *value, u32 read_write)
366 acpi_integer * value, u32 read_write)
367{ 363{
368 acpi_status status; 364 acpi_status status;
369 acpi_integer local_value; 365 u64 local_value;
370 366
371 ACPI_FUNCTION_TRACE_U32(ex_field_datum_io, field_datum_byte_offset); 367 ACPI_FUNCTION_TRACE_U32(ex_field_datum_io, field_datum_byte_offset);
372 368
@@ -439,8 +435,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
439 * the register 435 * the register
440 */ 436 */
441 if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj, 437 if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj,
442 (acpi_integer) obj_desc-> 438 (u64) obj_desc->bank_field.
443 bank_field.value)) { 439 value)) {
444 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); 440 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
445 } 441 }
446 442
@@ -481,8 +477,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
481 * the register 477 * the register
482 */ 478 */
483 if (acpi_ex_register_overflow(obj_desc->index_field.index_obj, 479 if (acpi_ex_register_overflow(obj_desc->index_field.index_obj,
484 (acpi_integer) obj_desc-> 480 (u64) obj_desc->index_field.
485 index_field.value)) { 481 value)) {
486 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); 482 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
487 } 483 }
488 484
@@ -512,7 +508,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
512 status = 508 status =
513 acpi_ex_extract_from_field(obj_desc->index_field. 509 acpi_ex_extract_from_field(obj_desc->index_field.
514 data_obj, value, 510 data_obj, value,
515 sizeof(acpi_integer)); 511 sizeof(u64));
516 } else { 512 } else {
517 /* Write the datum to the data_register */ 513 /* Write the datum to the data_register */
518 514
@@ -523,7 +519,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
523 status = 519 status =
524 acpi_ex_insert_into_field(obj_desc->index_field. 520 acpi_ex_insert_into_field(obj_desc->index_field.
525 data_obj, value, 521 data_obj, value,
526 sizeof(acpi_integer)); 522 sizeof(u64));
527 } 523 }
528 break; 524 break;
529 525
@@ -571,13 +567,12 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
571 567
572acpi_status 568acpi_status
573acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, 569acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
574 acpi_integer mask, 570 u64 mask,
575 acpi_integer field_value, 571 u64 field_value, u32 field_datum_byte_offset)
576 u32 field_datum_byte_offset)
577{ 572{
578 acpi_status status = AE_OK; 573 acpi_status status = AE_OK;
579 acpi_integer merged_value; 574 u64 merged_value;
580 acpi_integer current_value; 575 u64 current_value;
581 576
582 ACPI_FUNCTION_TRACE_U32(ex_write_with_update_rule, mask); 577 ACPI_FUNCTION_TRACE_U32(ex_write_with_update_rule, mask);
583 578
@@ -587,7 +582,7 @@ acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
587 582
588 /* If the mask is all ones, we don't need to worry about the update rule */ 583 /* If the mask is all ones, we don't need to worry about the update rule */
589 584
590 if (mask != ACPI_INTEGER_MAX) { 585 if (mask != ACPI_UINT64_MAX) {
591 586
592 /* Decode the update rule */ 587 /* Decode the update rule */
593 588
@@ -678,8 +673,8 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
678 void *buffer, u32 buffer_length) 673 void *buffer, u32 buffer_length)
679{ 674{
680 acpi_status status; 675 acpi_status status;
681 acpi_integer raw_datum; 676 u64 raw_datum;
682 acpi_integer merged_datum; 677 u64 merged_datum;
683 u32 field_offset = 0; 678 u32 field_offset = 0;
684 u32 buffer_offset = 0; 679 u32 buffer_offset = 0;
685 u32 buffer_tail_bits; 680 u32 buffer_tail_bits;
@@ -804,10 +799,10 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
804 void *buffer, u32 buffer_length) 799 void *buffer, u32 buffer_length)
805{ 800{
806 acpi_status status; 801 acpi_status status;
807 acpi_integer mask; 802 u64 mask;
808 acpi_integer width_mask; 803 u64 width_mask;
809 acpi_integer merged_datum; 804 u64 merged_datum;
810 acpi_integer raw_datum = 0; 805 u64 raw_datum = 0;
811 u32 field_offset = 0; 806 u32 field_offset = 0;
812 u32 buffer_offset = 0; 807 u32 buffer_offset = 0;
813 u32 buffer_tail_bits; 808 u32 buffer_tail_bits;
@@ -855,7 +850,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
855 * shift operator 850 * shift operator
856 */ 851 */
857 if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) { 852 if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) {
858 width_mask = ACPI_INTEGER_MAX; 853 width_mask = ACPI_UINT64_MAX;
859 } else { 854 } else {
860 width_mask = 855 width_mask =
861 ACPI_MASK_BITS_ABOVE(obj_desc->common_field. 856 ACPI_MASK_BITS_ABOVE(obj_desc->common_field.
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 998eac32993..c5bb1eeed2d 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -409,8 +409,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
409 * 409 *
410 ******************************************************************************/ 410 ******************************************************************************/
411 411
412acpi_integer 412u64 acpi_ex_do_math_op(u16 opcode, u64 integer0, u64 integer1)
413acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
414{ 413{
415 414
416 ACPI_FUNCTION_ENTRY(); 415 ACPI_FUNCTION_ENTRY();
@@ -498,8 +497,7 @@ acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
498 497
499acpi_status 498acpi_status
500acpi_ex_do_logical_numeric_op(u16 opcode, 499acpi_ex_do_logical_numeric_op(u16 opcode,
501 acpi_integer integer0, 500 u64 integer0, u64 integer1, u8 *logical_result)
502 acpi_integer integer1, u8 * logical_result)
503{ 501{
504 acpi_status status = AE_OK; 502 acpi_status status = AE_OK;
505 u8 local_result = FALSE; 503 u8 local_result = FALSE;
@@ -564,8 +562,8 @@ acpi_ex_do_logical_op(u16 opcode,
564 union acpi_operand_object *operand1, u8 * logical_result) 562 union acpi_operand_object *operand1, u8 * logical_result)
565{ 563{
566 union acpi_operand_object *local_operand1 = operand1; 564 union acpi_operand_object *local_operand1 = operand1;
567 acpi_integer integer0; 565 u64 integer0;
568 acpi_integer integer1; 566 u64 integer1;
569 u32 length0; 567 u32 length0;
570 u32 length1; 568 u32 length1;
571 acpi_status status = AE_OK; 569 acpi_status status = AE_OK;
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index 3c456bd575d..cc8a10268f6 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c
index ffdae122d94..679f308c5a8 100644
--- a/drivers/acpi/acpica/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index 752fe48b2d2..99adbab5acb 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -261,8 +261,8 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
261 union acpi_operand_object *return_desc2 = NULL; 261 union acpi_operand_object *return_desc2 = NULL;
262 u32 temp32; 262 u32 temp32;
263 u32 i; 263 u32 i;
264 acpi_integer power_of_ten; 264 u64 power_of_ten;
265 acpi_integer digit; 265 u64 digit;
266 266
267 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_1R, 267 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_1R,
268 acpi_ps_get_opcode_name(walk_state->opcode)); 268 acpi_ps_get_opcode_name(walk_state->opcode));
@@ -362,7 +362,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
362 /* Sum the digit into the result with the current power of 10 */ 362 /* Sum the digit into the result with the current power of 10 */
363 363
364 return_desc->integer.value += 364 return_desc->integer.value +=
365 (((acpi_integer) temp32) * power_of_ten); 365 (((u64) temp32) * power_of_ten);
366 366
367 /* Shift to next BCD digit */ 367 /* Shift to next BCD digit */
368 368
@@ -392,7 +392,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
392 * remainder from above 392 * remainder from above
393 */ 393 */
394 return_desc->integer.value |= 394 return_desc->integer.value |=
395 (((acpi_integer) temp32) << ACPI_MUL_4(i)); 395 (((u64) temp32) << ACPI_MUL_4(i));
396 } 396 }
397 397
398 /* Overflow if there is any data left in Digit */ 398 /* Overflow if there is any data left in Digit */
@@ -439,7 +439,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
439 439
440 /* The object exists in the namespace, return TRUE */ 440 /* The object exists in the namespace, return TRUE */
441 441
442 return_desc->integer.value = ACPI_INTEGER_MAX; 442 return_desc->integer.value = ACPI_UINT64_MAX;
443 goto cleanup; 443 goto cleanup;
444 444
445 default: 445 default:
@@ -589,7 +589,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
589 union acpi_operand_object *return_desc = NULL; 589 union acpi_operand_object *return_desc = NULL;
590 acpi_status status = AE_OK; 590 acpi_status status = AE_OK;
591 u32 type; 591 u32 type;
592 acpi_integer value; 592 u64 value;
593 593
594 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_1R, 594 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_1R,
595 acpi_ps_get_opcode_name(walk_state->opcode)); 595 acpi_ps_get_opcode_name(walk_state->opcode));
@@ -610,7 +610,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
610 * return_desc->Integer.Value is initially == 0 (FALSE) from above. 610 * return_desc->Integer.Value is initially == 0 (FALSE) from above.
611 */ 611 */
612 if (!operand[0]->integer.value) { 612 if (!operand[0]->integer.value) {
613 return_desc->integer.value = ACPI_INTEGER_MAX; 613 return_desc->integer.value = ACPI_UINT64_MAX;
614 } 614 }
615 break; 615 break;
616 616
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index 85d95c92dfd..22841bbbe63 100644
--- a/drivers/acpi/acpica/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -282,7 +282,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
282{ 282{
283 union acpi_operand_object **operand = &walk_state->operands[0]; 283 union acpi_operand_object **operand = &walk_state->operands[0];
284 union acpi_operand_object *return_desc = NULL; 284 union acpi_operand_object *return_desc = NULL;
285 acpi_integer index; 285 u64 index;
286 acpi_status status = AE_OK; 286 acpi_status status = AE_OK;
287 acpi_size length; 287 acpi_size length;
288 288
@@ -584,7 +584,7 @@ acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state)
584 * Default is FALSE (zero) 584 * Default is FALSE (zero)
585 */ 585 */
586 if (logical_result) { 586 if (logical_result) {
587 return_desc->integer.value = ACPI_INTEGER_MAX; 587 return_desc->integer.value = ACPI_UINT64_MAX;
588 } 588 }
589 589
590 cleanup: 590 cleanup:
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 253f9e12258..8bb1012ef44 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -148,7 +148,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
148 union acpi_operand_object *return_desc = NULL; 148 union acpi_operand_object *return_desc = NULL;
149 char *buffer = NULL; 149 char *buffer = NULL;
150 acpi_status status = AE_OK; 150 acpi_status status = AE_OK;
151 acpi_integer index; 151 u64 index;
152 acpi_size length; 152 acpi_size length;
153 153
154 ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_1T_1R, 154 ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_1T_1R,
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index 295542e6bd5..f256b6a25f2 100644
--- a/drivers/acpi/acpica/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -218,7 +218,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
218 union acpi_operand_object **operand = &walk_state->operands[0]; 218 union acpi_operand_object **operand = &walk_state->operands[0];
219 union acpi_operand_object *return_desc = NULL; 219 union acpi_operand_object *return_desc = NULL;
220 acpi_status status = AE_OK; 220 acpi_status status = AE_OK;
221 acpi_integer index; 221 u64 index;
222 union acpi_operand_object *this_element; 222 union acpi_operand_object *this_element;
223 223
224 ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R, 224 ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R,
@@ -253,9 +253,9 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
253 } 253 }
254 254
255 /* Create an integer for the return value */ 255 /* Create an integer for the return value */
256 /* Default return value is ACPI_INTEGER_MAX if no match found */ 256 /* Default return value is ACPI_UINT64_MAX if no match found */
257 257
258 return_desc = acpi_ut_create_integer_object(ACPI_INTEGER_MAX); 258 return_desc = acpi_ut_create_integer_object(ACPI_UINT64_MAX);
259 if (!return_desc) { 259 if (!return_desc) {
260 status = AE_NO_MEMORY; 260 status = AE_NO_MEMORY;
261 goto cleanup; 261 goto cleanup;
@@ -270,7 +270,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
270 * 270 *
271 * Upon finding a match, the loop will terminate via "break" at 271 * Upon finding a match, the loop will terminate via "break" at
272 * the bottom. If it terminates "normally", match_value will be 272 * the bottom. If it terminates "normally", match_value will be
273 * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no 273 * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
274 * match was found. 274 * match was found.
275 */ 275 */
276 for (; index < operand[0]->package.count; index++) { 276 for (; index < operand[0]->package.count; index++) {
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index 52fec07064f..edf62bf5b26 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 2bd83ac57c3..486b2e5661b 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,7 @@ acpi_status
70acpi_ex_system_memory_space_handler(u32 function, 70acpi_ex_system_memory_space_handler(u32 function,
71 acpi_physical_address address, 71 acpi_physical_address address,
72 u32 bit_width, 72 u32 bit_width,
73 acpi_integer * value, 73 u64 *value,
74 void *handler_context, void *region_context) 74 void *handler_context, void *region_context)
75{ 75{
76 acpi_status status = AE_OK; 76 acpi_status status = AE_OK;
@@ -115,8 +115,7 @@ acpi_ex_system_memory_space_handler(u32 function,
115 * Hardware does not support non-aligned data transfers, we must verify 115 * Hardware does not support non-aligned data transfers, we must verify
116 * the request. 116 * the request.
117 */ 117 */
118 (void)acpi_ut_short_divide((acpi_integer) address, length, NULL, 118 (void)acpi_ut_short_divide((u64) address, length, NULL, &remainder);
119 &remainder);
120 if (remainder != 0) { 119 if (remainder != 0) {
121 return_ACPI_STATUS(AE_AML_ALIGNMENT); 120 return_ACPI_STATUS(AE_AML_ALIGNMENT);
122 } 121 }
@@ -128,10 +127,9 @@ acpi_ex_system_memory_space_handler(u32 function,
128 * 2) Address beyond the current mapping? 127 * 2) Address beyond the current mapping?
129 */ 128 */
130 if ((address < mem_info->mapped_physical_address) || 129 if ((address < mem_info->mapped_physical_address) ||
131 (((acpi_integer) address + length) > ((acpi_integer) 130 (((u64) address + length) > ((u64)
132 mem_info-> 131 mem_info->mapped_physical_address +
133 mapped_physical_address + 132 mem_info->mapped_length))) {
134 mem_info->mapped_length))) {
135 /* 133 /*
136 * The request cannot be resolved by the current memory mapping; 134 * The request cannot be resolved by the current memory mapping;
137 * Delete the existing mapping and create a new one. 135 * Delete the existing mapping and create a new one.
@@ -193,8 +191,7 @@ acpi_ex_system_memory_space_handler(u32 function,
193 * access 191 * access
194 */ 192 */
195 logical_addr_ptr = mem_info->mapped_logical_address + 193 logical_addr_ptr = mem_info->mapped_logical_address +
196 ((acpi_integer) address - 194 ((u64) address - (u64) mem_info->mapped_physical_address);
197 (acpi_integer) mem_info->mapped_physical_address);
198 195
199 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 196 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
200 "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", 197 "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n",
@@ -215,19 +212,19 @@ acpi_ex_system_memory_space_handler(u32 function,
215 *value = 0; 212 *value = 0;
216 switch (bit_width) { 213 switch (bit_width) {
217 case 8: 214 case 8:
218 *value = (acpi_integer) ACPI_GET8(logical_addr_ptr); 215 *value = (u64) ACPI_GET8(logical_addr_ptr);
219 break; 216 break;
220 217
221 case 16: 218 case 16:
222 *value = (acpi_integer) ACPI_GET16(logical_addr_ptr); 219 *value = (u64) ACPI_GET16(logical_addr_ptr);
223 break; 220 break;
224 221
225 case 32: 222 case 32:
226 *value = (acpi_integer) ACPI_GET32(logical_addr_ptr); 223 *value = (u64) ACPI_GET32(logical_addr_ptr);
227 break; 224 break;
228 225
229 case 64: 226 case 64:
230 *value = (acpi_integer) ACPI_GET64(logical_addr_ptr); 227 *value = (u64) ACPI_GET64(logical_addr_ptr);
231 break; 228 break;
232 229
233 default: 230 default:
@@ -291,7 +288,7 @@ acpi_status
291acpi_ex_system_io_space_handler(u32 function, 288acpi_ex_system_io_space_handler(u32 function,
292 acpi_physical_address address, 289 acpi_physical_address address,
293 u32 bit_width, 290 u32 bit_width,
294 acpi_integer * value, 291 u64 *value,
295 void *handler_context, void *region_context) 292 void *handler_context, void *region_context)
296{ 293{
297 acpi_status status = AE_OK; 294 acpi_status status = AE_OK;
@@ -350,7 +347,7 @@ acpi_status
350acpi_ex_pci_config_space_handler(u32 function, 347acpi_ex_pci_config_space_handler(u32 function,
351 acpi_physical_address address, 348 acpi_physical_address address,
352 u32 bit_width, 349 u32 bit_width,
353 acpi_integer * value, 350 u64 *value,
354 void *handler_context, void *region_context) 351 void *handler_context, void *region_context)
355{ 352{
356 acpi_status status = AE_OK; 353 acpi_status status = AE_OK;
@@ -425,7 +422,7 @@ acpi_status
425acpi_ex_cmos_space_handler(u32 function, 422acpi_ex_cmos_space_handler(u32 function,
426 acpi_physical_address address, 423 acpi_physical_address address,
427 u32 bit_width, 424 u32 bit_width,
428 acpi_integer * value, 425 u64 *value,
429 void *handler_context, void *region_context) 426 void *handler_context, void *region_context)
430{ 427{
431 acpi_status status = AE_OK; 428 acpi_status status = AE_OK;
@@ -457,7 +454,7 @@ acpi_status
457acpi_ex_pci_bar_space_handler(u32 function, 454acpi_ex_pci_bar_space_handler(u32 function,
458 acpi_physical_address address, 455 acpi_physical_address address,
459 u32 bit_width, 456 u32 bit_width,
460 acpi_integer * value, 457 u64 *value,
461 void *handler_context, void *region_context) 458 void *handler_context, void *region_context)
462{ 459{
463 acpi_status status = AE_OK; 460 acpi_status status = AE_OK;
@@ -489,7 +486,7 @@ acpi_status
489acpi_ex_data_table_space_handler(u32 function, 486acpi_ex_data_table_space_handler(u32 function,
490 acpi_physical_address address, 487 acpi_physical_address address,
491 u32 bit_width, 488 u32 bit_width,
492 acpi_integer * value, 489 u64 *value,
493 void *handler_context, void *region_context) 490 void *handler_context, void *region_context)
494{ 491{
495 ACPI_FUNCTION_TRACE(ex_data_table_space_handler); 492 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 607958ff467..fdc1b27999e 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index c93b54ce7f7..fdd6a7079b9 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index 5c729a9e913..c5ecd615f14 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 6efd07a4f77..702b9ecfd44 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index 608e838d537..d4af684620c 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c
index 257706e7734..e972b667b09 100644
--- a/drivers/acpi/acpica/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c
index 3d00b935723..e11b6cb42a5 100644
--- a/drivers/acpi/acpica/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -193,7 +193,7 @@ acpi_status acpi_ex_system_do_stall(u32 how_long)
193 * 193 *
194 ******************************************************************************/ 194 ******************************************************************************/
195 195
196acpi_status acpi_ex_system_do_suspend(acpi_integer how_long) 196acpi_status acpi_ex_system_do_suspend(u64 how_long)
197{ 197{
198 ACPI_FUNCTION_ENTRY(); 198 ACPI_FUNCTION_ENTRY();
199 199
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 7d41f99f705..74c24d517f8 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,7 @@
67ACPI_MODULE_NAME("exutils") 67ACPI_MODULE_NAME("exutils")
68 68
69/* Local prototypes */ 69/* Local prototypes */
70static u32 acpi_ex_digits_needed(acpi_integer value, u32 base); 70static u32 acpi_ex_digits_needed(u64 value, u32 base);
71 71
72#ifndef ACPI_NO_METHOD_EXECUTION 72#ifndef ACPI_NO_METHOD_EXECUTION
73/******************************************************************************* 73/*******************************************************************************
@@ -230,7 +230,7 @@ void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
230 * We are running a method that exists in a 32-bit ACPI table. 230 * We are running a method that exists in a 32-bit ACPI table.
231 * Truncate the value to 32 bits by zeroing out the upper 32-bit field 231 * Truncate the value to 32 bits by zeroing out the upper 32-bit field
232 */ 232 */
233 obj_desc->integer.value &= (acpi_integer) ACPI_UINT32_MAX; 233 obj_desc->integer.value &= (u64) ACPI_UINT32_MAX;
234 } 234 }
235} 235}
236 236
@@ -327,14 +327,14 @@ void acpi_ex_release_global_lock(u32 field_flags)
327 * 327 *
328 ******************************************************************************/ 328 ******************************************************************************/
329 329
330static u32 acpi_ex_digits_needed(acpi_integer value, u32 base) 330static u32 acpi_ex_digits_needed(u64 value, u32 base)
331{ 331{
332 u32 num_digits; 332 u32 num_digits;
333 acpi_integer current_value; 333 u64 current_value;
334 334
335 ACPI_FUNCTION_TRACE(ex_digits_needed); 335 ACPI_FUNCTION_TRACE(ex_digits_needed);
336 336
337 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 337 /* u64 is unsigned, so we don't worry about a '-' prefix */
338 338
339 if (value == 0) { 339 if (value == 0) {
340 return_UINT32(1); 340 return_UINT32(1);
@@ -370,7 +370,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
370 * 370 *
371 ******************************************************************************/ 371 ******************************************************************************/
372 372
373void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id) 373void acpi_ex_eisa_id_to_string(char *out_string, u64 compressed_id)
374{ 374{
375 u32 swapped_id; 375 u32 swapped_id;
376 376
@@ -394,10 +394,10 @@ void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id)
394 (char)(0x40 + (((unsigned long)swapped_id >> 26) & 0x1F)); 394 (char)(0x40 + (((unsigned long)swapped_id >> 26) & 0x1F));
395 out_string[1] = (char)(0x40 + ((swapped_id >> 21) & 0x1F)); 395 out_string[1] = (char)(0x40 + ((swapped_id >> 21) & 0x1F));
396 out_string[2] = (char)(0x40 + ((swapped_id >> 16) & 0x1F)); 396 out_string[2] = (char)(0x40 + ((swapped_id >> 16) & 0x1F));
397 out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 12); 397 out_string[3] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 12);
398 out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 8); 398 out_string[4] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 8);
399 out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 4); 399 out_string[5] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 4);
400 out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 0); 400 out_string[6] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 0);
401 out_string[7] = 0; 401 out_string[7] = 0;
402} 402}
403 403
@@ -418,7 +418,7 @@ void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id)
418 * 418 *
419 ******************************************************************************/ 419 ******************************************************************************/
420 420
421void acpi_ex_integer_to_string(char *out_string, acpi_integer value) 421void acpi_ex_integer_to_string(char *out_string, u64 value)
422{ 422{
423 u32 count; 423 u32 count;
424 u32 digits_needed; 424 u32 digits_needed;
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 9af361a191e..679a112a7d2 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index c28c41b3180..bd72319a38f 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -224,7 +224,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
224 224
225 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address); 225 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
226 if (ACPI_FAILURE(status)) { 226 if (ACPI_FAILURE(status)) {
227 goto unlock_and_exit; 227 return (status);
228 } 228 }
229 229
230 if (register_bit & in_byte) { 230 if (register_bit & in_byte) {
@@ -234,9 +234,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
234 /* Set return value */ 234 /* Set return value */
235 235
236 (*event_status) = local_event_status; 236 (*event_status) = local_event_status;
237 237 return (AE_OK);
238 unlock_and_exit:
239 return (status);
240} 238}
241 239
242/****************************************************************************** 240/******************************************************************************
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 15c9ed2be85..ec7fc227b33 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -7,7 +7,7 @@
7 ******************************************************************************/ 7 ******************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index cc22f9a585b..5e6d4dbb802 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index 6b282e85d03..1ef8e0bb250 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -140,7 +140,7 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
140{ 140{
141 acpi_status status; 141 acpi_status status;
142 u32 delta_ticks; 142 u32 delta_ticks;
143 acpi_integer quotient; 143 u64 quotient;
144 144
145 ACPI_FUNCTION_TRACE(acpi_get_timer_duration); 145 ACPI_FUNCTION_TRACE(acpi_get_timer_duration);
146 146
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
index ec33f270c5b..e26c17d4b71 100644
--- a/drivers/acpi/acpica/hwvalid.c
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2009, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 647c7b6e675..50cc3be7772 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index d622ba77000..aa2b80132d0 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 8a58a1b85aa..982269c1fa4 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index e37836e27e2..0689d36638d 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 36be7f0e97e..d2a97921e24 100644
--- a/drivers/acpi/acpica/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index af9fe910373..f52829cc294 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 4f8abac231d..9bd6f050f29 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index a7234e60e98..df18be94fef 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index 8f9a4875ce2..95937245163 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index 60f3af08d28..41a9213dd5a 100644
--- a/drivers/acpi/acpica/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 662a4bd5b62..27cda52c76b 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index d34fa59548f..7096bcda0c7 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -231,6 +231,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
231 * Note: Package may have been newly created by call above. 231 * Note: Package may have been newly created by call above.
232 */ 232 */
233 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { 233 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) {
234 data->parent_package = *return_object_ptr;
234 status = acpi_ns_check_package(data, return_object_ptr); 235 status = acpi_ns_check_package(data, return_object_ptr);
235 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
236 goto exit; 237 goto exit;
@@ -710,6 +711,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
710 for (i = 0; i < count; i++) { 711 for (i = 0; i < count; i++) {
711 sub_package = *elements; 712 sub_package = *elements;
712 sub_elements = sub_package->package.elements; 713 sub_elements = sub_package->package.elements;
714 data->parent_package = sub_package;
713 715
714 /* Each sub-object must be of type Package */ 716 /* Each sub-object must be of type Package */
715 717
@@ -721,6 +723,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
721 723
722 /* Examine the different types of expected sub-packages */ 724 /* Examine the different types of expected sub-packages */
723 725
726 data->parent_package = sub_package;
724 switch (package->ret_info.type) { 727 switch (package->ret_info.type) {
725 case ACPI_PTYPE2: 728 case ACPI_PTYPE2:
726 case ACPI_PTYPE2_PKG_COUNT: 729 case ACPI_PTYPE2_PKG_COUNT:
@@ -800,7 +803,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
800 803
801 /* 804 /*
802 * First element is the (Integer) count of elements, including 805 * First element is the (Integer) count of elements, including
803 * the count field. 806 * the count field (the ACPI name is num_elements)
804 */ 807 */
805 status = acpi_ns_check_object_type(data, sub_elements, 808 status = acpi_ns_check_object_type(data, sub_elements,
806 ACPI_RTYPE_INTEGER, 809 ACPI_RTYPE_INTEGER,
@@ -822,6 +825,16 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
822 expected_count = package->ret_info.count1; 825 expected_count = package->ret_info.count1;
823 goto package_too_small; 826 goto package_too_small;
824 } 827 }
828 if (expected_count == 0) {
829 /*
830 * Either the num_entries element was originally zero or it was
831 * a NULL element and repaired to an Integer of value zero.
832 * In either case, repair it by setting num_entries to be the
833 * actual size of the subpackage.
834 */
835 expected_count = sub_package->package.count;
836 (*sub_elements)->integer.value = expected_count;
837 }
825 838
826 /* Check the type of each sub-package element */ 839 /* Check the type of each sub-package element */
827 840
@@ -945,10 +958,18 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
945 char type_buffer[48]; /* Room for 5 types */ 958 char type_buffer[48]; /* Room for 5 types */
946 959
947 /* 960 /*
948 * If we get a NULL return_object here, it is a NULL package element, 961 * If we get a NULL return_object here, it is a NULL package element.
949 * and this is always an error. 962 * Since all extraneous NULL package elements were removed earlier by a
963 * call to acpi_ns_remove_null_elements, this is an unexpected NULL element.
964 * We will attempt to repair it.
950 */ 965 */
951 if (!return_object) { 966 if (!return_object) {
967 status = acpi_ns_repair_null_element(data, expected_btypes,
968 package_index,
969 return_object_ptr);
970 if (ACPI_SUCCESS(status)) {
971 return (AE_OK); /* Repair was successful */
972 }
952 goto type_error_exit; 973 goto type_error_exit;
953 } 974 }
954 975
@@ -1000,27 +1021,25 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
1000 1021
1001 /* Is the object one of the expected types? */ 1022 /* Is the object one of the expected types? */
1002 1023
1003 if (!(return_btype & expected_btypes)) { 1024 if (return_btype & expected_btypes) {
1004 1025
1005 /* Type mismatch -- attempt repair of the returned object */ 1026 /* For reference objects, check that the reference type is correct */
1006 1027
1007 status = acpi_ns_repair_object(data, expected_btypes, 1028 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
1008 package_index, 1029 status = acpi_ns_check_reference(data, return_object);
1009 return_object_ptr);
1010 if (ACPI_SUCCESS(status)) {
1011 return (AE_OK); /* Repair was successful */
1012 } 1030 }
1013 goto type_error_exit; 1031
1032 return (status);
1014 } 1033 }
1015 1034
1016 /* For reference objects, check that the reference type is correct */ 1035 /* Type mismatch -- attempt repair of the returned object */
1017 1036
1018 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { 1037 status = acpi_ns_repair_object(data, expected_btypes,
1019 status = acpi_ns_check_reference(data, return_object); 1038 package_index, return_object_ptr);
1039 if (ACPI_SUCCESS(status)) {
1040 return (AE_OK); /* Repair was successful */
1020 } 1041 }
1021 1042
1022 return (status);
1023
1024 type_error_exit: 1043 type_error_exit:
1025 1044
1026 /* Create a string with all expected types for this predefined object */ 1045 /* Create a string with all expected types for this predefined object */
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index 4fd1bdb056b..d4be37751be 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
45#include "accommon.h" 45#include "accommon.h"
46#include "acnamesp.h" 46#include "acnamesp.h"
47#include "acinterp.h" 47#include "acinterp.h"
48#include "acpredef.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsrepair") 51ACPI_MODULE_NAME("nsrepair")
@@ -71,6 +72,12 @@ ACPI_MODULE_NAME("nsrepair")
71 * Buffer -> Package of Integers 72 * Buffer -> Package of Integers
72 * Package -> Package of one Package 73 * Package -> Package of one Package
73 * 74 *
75 * Additional possible repairs:
76 *
77 * Optional/unnecessary NULL package elements removed
78 * Required package elements that are NULL replaced by Integer/String/Buffer
79 * Incorrect standalone package wrapped with required outer package
80 *
74 ******************************************************************************/ 81 ******************************************************************************/
75/* Local prototypes */ 82/* Local prototypes */
76static acpi_status 83static acpi_status
@@ -506,6 +513,172 @@ acpi_ns_convert_to_package(union acpi_operand_object *original_object,
506 513
507/******************************************************************************* 514/*******************************************************************************
508 * 515 *
516 * FUNCTION: acpi_ns_repair_null_element
517 *
518 * PARAMETERS: Data - Pointer to validation data structure
519 * expected_btypes - Object types expected
520 * package_index - Index of object within parent package (if
521 * applicable - ACPI_NOT_PACKAGE_ELEMENT
522 * otherwise)
523 * return_object_ptr - Pointer to the object returned from the
524 * evaluation of a method or object
525 *
526 * RETURN: Status. AE_OK if repair was successful.
527 *
528 * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
529 *
530 ******************************************************************************/
531
532acpi_status
533acpi_ns_repair_null_element(struct acpi_predefined_data *data,
534 u32 expected_btypes,
535 u32 package_index,
536 union acpi_operand_object **return_object_ptr)
537{
538 union acpi_operand_object *return_object = *return_object_ptr;
539 union acpi_operand_object *new_object;
540
541 ACPI_FUNCTION_NAME(ns_repair_null_element);
542
543 /* No repair needed if return object is non-NULL */
544
545 if (return_object) {
546 return (AE_OK);
547 }
548
549 /*
550 * Attempt to repair a NULL element of a Package object. This applies to
551 * predefined names that return a fixed-length package and each element
552 * is required. It does not apply to variable-length packages where NULL
553 * elements are allowed, especially at the end of the package.
554 */
555 if (expected_btypes & ACPI_RTYPE_INTEGER) {
556
557 /* Need an Integer - create a zero-value integer */
558
559 new_object = acpi_ut_create_integer_object(0);
560 } else if (expected_btypes & ACPI_RTYPE_STRING) {
561
562 /* Need a String - create a NULL string */
563
564 new_object = acpi_ut_create_string_object(0);
565 } else if (expected_btypes & ACPI_RTYPE_BUFFER) {
566
567 /* Need a Buffer - create a zero-length buffer */
568
569 new_object = acpi_ut_create_buffer_object(0);
570 } else {
571 /* Error for all other expected types */
572
573 return (AE_AML_OPERAND_TYPE);
574 }
575
576 if (!new_object) {
577 return (AE_NO_MEMORY);
578 }
579
580 /* Set the reference count according to the parent Package object */
581
582 new_object->common.reference_count =
583 data->parent_package->common.reference_count;
584
585 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
586 "%s: Converted NULL package element to expected %s at index %u\n",
587 data->pathname,
588 acpi_ut_get_object_type_name(new_object),
589 package_index));
590
591 *return_object_ptr = new_object;
592 data->flags |= ACPI_OBJECT_REPAIRED;
593 return (AE_OK);
594}
595
596/******************************************************************************
597 *
598 * FUNCTION: acpi_ns_remove_null_elements
599 *
600 * PARAMETERS: Data - Pointer to validation data structure
601 * package_type - An acpi_return_package_types value
602 * obj_desc - A Package object
603 *
604 * RETURN: None.
605 *
606 * DESCRIPTION: Remove all NULL package elements from packages that contain
607 * a variable number of sub-packages. For these types of
608 * packages, NULL elements can be safely removed.
609 *
610 *****************************************************************************/
611
612void
613acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
614 u8 package_type,
615 union acpi_operand_object *obj_desc)
616{
617 union acpi_operand_object **source;
618 union acpi_operand_object **dest;
619 u32 count;
620 u32 new_count;
621 u32 i;
622
623 ACPI_FUNCTION_NAME(ns_remove_null_elements);
624
625 /*
626 * PTYPE1 packages contain no subpackages.
627 * PTYPE2 packages contain a variable number of sub-packages. We can
628 * safely remove all NULL elements from the PTYPE2 packages.
629 */
630 switch (package_type) {
631 case ACPI_PTYPE1_FIXED:
632 case ACPI_PTYPE1_VAR:
633 case ACPI_PTYPE1_OPTION:
634 return;
635
636 case ACPI_PTYPE2:
637 case ACPI_PTYPE2_COUNT:
638 case ACPI_PTYPE2_PKG_COUNT:
639 case ACPI_PTYPE2_FIXED:
640 case ACPI_PTYPE2_MIN:
641 case ACPI_PTYPE2_REV_FIXED:
642 break;
643
644 default:
645 return;
646 }
647
648 count = obj_desc->package.count;
649 new_count = count;
650
651 source = obj_desc->package.elements;
652 dest = source;
653
654 /* Examine all elements of the package object, remove nulls */
655
656 for (i = 0; i < count; i++) {
657 if (!*source) {
658 new_count--;
659 } else {
660 *dest = *source;
661 dest++;
662 }
663 source++;
664 }
665
666 /* Update parent package if any null elements were removed */
667
668 if (new_count < count) {
669 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
670 "%s: Found and removed %u NULL elements\n",
671 data->pathname, (count - new_count)));
672
673 /* NULL terminate list and update the package count */
674
675 *dest = NULL;
676 obj_desc->package.count = new_count;
677 }
678}
679
680/*******************************************************************************
681 *
509 * FUNCTION: acpi_ns_repair_package_list 682 * FUNCTION: acpi_ns_repair_package_list
510 * 683 *
511 * PARAMETERS: Data - Pointer to validation data structure 684 * PARAMETERS: Data - Pointer to validation data structure
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index f13691c1cca..61bd0f6755d 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2009, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,6 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
48#include "acpredef.h"
49 48
50#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nsrepair2") 50ACPI_MODULE_NAME("nsrepair2")
@@ -93,7 +92,7 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
93 u32 sort_index, 92 u32 sort_index,
94 u8 sort_direction, char *sort_key_name); 93 u8 sort_direction, char *sort_key_name);
95 94
96static acpi_status 95static void
97acpi_ns_sort_list(union acpi_operand_object **elements, 96acpi_ns_sort_list(union acpi_operand_object **elements,
98 u32 count, u32 index, u8 sort_direction); 97 u32 count, u32 index, u8 sort_direction);
99 98
@@ -443,7 +442,6 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
443 union acpi_operand_object *obj_desc; 442 union acpi_operand_object *obj_desc;
444 u32 i; 443 u32 i;
445 u32 previous_value; 444 u32 previous_value;
446 acpi_status status;
447 445
448 ACPI_FUNCTION_NAME(ns_check_sorted_list); 446 ACPI_FUNCTION_NAME(ns_check_sorted_list);
449 447
@@ -494,19 +492,15 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
494 492
495 /* 493 /*
496 * The list must be sorted in the specified order. If we detect a 494 * The list must be sorted in the specified order. If we detect a
497 * discrepancy, issue a warning and sort the entire list 495 * discrepancy, sort the entire list.
498 */ 496 */
499 if (((sort_direction == ACPI_SORT_ASCENDING) && 497 if (((sort_direction == ACPI_SORT_ASCENDING) &&
500 (obj_desc->integer.value < previous_value)) || 498 (obj_desc->integer.value < previous_value)) ||
501 ((sort_direction == ACPI_SORT_DESCENDING) && 499 ((sort_direction == ACPI_SORT_DESCENDING) &&
502 (obj_desc->integer.value > previous_value))) { 500 (obj_desc->integer.value > previous_value))) {
503 status = 501 acpi_ns_sort_list(return_object->package.elements,
504 acpi_ns_sort_list(return_object->package.elements, 502 outer_element_count, sort_index,
505 outer_element_count, sort_index, 503 sort_direction);
506 sort_direction);
507 if (ACPI_FAILURE(status)) {
508 return (status);
509 }
510 504
511 data->flags |= ACPI_OBJECT_REPAIRED; 505 data->flags |= ACPI_OBJECT_REPAIRED;
512 506
@@ -525,89 +519,6 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
525 519
526/****************************************************************************** 520/******************************************************************************
527 * 521 *
528 * FUNCTION: acpi_ns_remove_null_elements
529 *
530 * PARAMETERS: Data - Pointer to validation data structure
531 * package_type - An acpi_return_package_types value
532 * obj_desc - A Package object
533 *
534 * RETURN: None.
535 *
536 * DESCRIPTION: Remove all NULL package elements from packages that contain
537 * a variable number of sub-packages.
538 *
539 *****************************************************************************/
540
541void
542acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
543 u8 package_type,
544 union acpi_operand_object *obj_desc)
545{
546 union acpi_operand_object **source;
547 union acpi_operand_object **dest;
548 u32 count;
549 u32 new_count;
550 u32 i;
551
552 ACPI_FUNCTION_NAME(ns_remove_null_elements);
553
554 /*
555 * PTYPE1 packages contain no subpackages.
556 * PTYPE2 packages contain a variable number of sub-packages. We can
557 * safely remove all NULL elements from the PTYPE2 packages.
558 */
559 switch (package_type) {
560 case ACPI_PTYPE1_FIXED:
561 case ACPI_PTYPE1_VAR:
562 case ACPI_PTYPE1_OPTION:
563 return;
564
565 case ACPI_PTYPE2:
566 case ACPI_PTYPE2_COUNT:
567 case ACPI_PTYPE2_PKG_COUNT:
568 case ACPI_PTYPE2_FIXED:
569 case ACPI_PTYPE2_MIN:
570 case ACPI_PTYPE2_REV_FIXED:
571 break;
572
573 default:
574 return;
575 }
576
577 count = obj_desc->package.count;
578 new_count = count;
579
580 source = obj_desc->package.elements;
581 dest = source;
582
583 /* Examine all elements of the package object, remove nulls */
584
585 for (i = 0; i < count; i++) {
586 if (!*source) {
587 new_count--;
588 } else {
589 *dest = *source;
590 dest++;
591 }
592 source++;
593 }
594
595 /* Update parent package if any null elements were removed */
596
597 if (new_count < count) {
598 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
599 "%s: Found and removed %u NULL elements\n",
600 data->pathname, (count - new_count)));
601
602 /* NULL terminate list and update the package count */
603
604 *dest = NULL;
605 obj_desc->package.count = new_count;
606 }
607}
608
609/******************************************************************************
610 *
611 * FUNCTION: acpi_ns_sort_list 522 * FUNCTION: acpi_ns_sort_list
612 * 523 *
613 * PARAMETERS: Elements - Package object element list 524 * PARAMETERS: Elements - Package object element list
@@ -615,15 +526,16 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
615 * Index - Sort by which package element 526 * Index - Sort by which package element
616 * sort_direction - Ascending or Descending sort 527 * sort_direction - Ascending or Descending sort
617 * 528 *
618 * RETURN: Status 529 * RETURN: None
619 * 530 *
620 * DESCRIPTION: Sort the objects that are in a package element list. 531 * DESCRIPTION: Sort the objects that are in a package element list.
621 * 532 *
622 * NOTE: Assumes that all NULL elements have been removed from the package. 533 * NOTE: Assumes that all NULL elements have been removed from the package,
534 * and that all elements have been verified to be of type Integer.
623 * 535 *
624 *****************************************************************************/ 536 *****************************************************************************/
625 537
626static acpi_status 538static void
627acpi_ns_sort_list(union acpi_operand_object **elements, 539acpi_ns_sort_list(union acpi_operand_object **elements,
628 u32 count, u32 index, u8 sort_direction) 540 u32 count, u32 index, u8 sort_direction)
629{ 541{
@@ -652,6 +564,4 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
652 } 564 }
653 } 565 }
654 } 566 }
655
656 return (AE_OK);
657} 567}
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index 7e865639a92..08f8b3f5cca 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index 47d91e668a1..24d05a87a2a 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index d7e6b52b448..00e79fb2602 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index f0c0892bc7e..ebef8a7fd70 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -562,25 +562,20 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
562 return (AE_BAD_PARAMETER); 562 return (AE_BAD_PARAMETER);
563 } 563 }
564 564
565 /* Run _STA to determine if device is present */ 565 /*
566 566 * First, filter based on the device HID and CID.
567 status = acpi_ut_execute_STA(node, &flags); 567 *
568 if (ACPI_FAILURE(status)) { 568 * 01/2010: For this case where a specific HID is requested, we don't
569 return (AE_CTRL_DEPTH); 569 * want to run _STA until we have an actual HID match. Thus, we will
570 } 570 * not unnecessarily execute _STA on devices for which the caller
571 571 * doesn't care about. Previously, _STA was executed unconditionally
572 if (!(flags & ACPI_STA_DEVICE_PRESENT) && 572 * on all devices found here.
573 !(flags & ACPI_STA_DEVICE_FUNCTIONING)) { 573 *
574 /* 574 * A side-effect of this change is that now we will continue to search
575 * Don't examine the children of the device only when the 575 * for a matching HID even under device trees where the parent device
576 * device is neither present nor functional. See ACPI spec, 576 * would have returned a _STA that indicates it is not present or
577 * description of _STA for more information. 577 * not functioning (thus aborting the search on that branch).
578 */ 578 */
579 return (AE_CTRL_DEPTH);
580 }
581
582 /* Filter based on device HID & CID */
583
584 if (info->hid != NULL) { 579 if (info->hid != NULL) {
585 status = acpi_ut_execute_HID(node, &hid); 580 status = acpi_ut_execute_HID(node, &hid);
586 if (status == AE_NOT_FOUND) { 581 if (status == AE_NOT_FOUND) {
@@ -620,6 +615,25 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
620 } 615 }
621 } 616 }
622 617
618 /* Run _STA to determine if device is present */
619
620 status = acpi_ut_execute_STA(node, &flags);
621 if (ACPI_FAILURE(status)) {
622 return (AE_CTRL_DEPTH);
623 }
624
625 if (!(flags & ACPI_STA_DEVICE_PRESENT) &&
626 !(flags & ACPI_STA_DEVICE_FUNCTIONING)) {
627 /*
628 * Don't examine the children of the device only when the
629 * device is neither present nor functional. See ACPI spec,
630 * description of _STA for more information.
631 */
632 return (AE_CTRL_DEPTH);
633 }
634
635 /* We have a valid device, invoke the user function */
636
623 status = info->user_function(obj_handle, nesting_level, info->context, 637 status = info->user_function(obj_handle, nesting_level, info->context,
624 return_value); 638 return_value);
625 return (status); 639 return (status);
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index e611dd961b2..b01e45a415e 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 0cc6ba01a49..eafef24ea44 100644
--- a/drivers/acpi/acpica/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index b161f3544b5..00493e108a0 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -403,7 +403,7 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
403 /* Get 1 byte from the AML stream */ 403 /* Get 1 byte from the AML stream */
404 404
405 opcode = AML_BYTE_OP; 405 opcode = AML_BYTE_OP;
406 arg->common.value.integer = (acpi_integer) * aml; 406 arg->common.value.integer = (u64) *aml;
407 length = 1; 407 length = 1;
408 break; 408 break;
409 409
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index 0988e4a8901..59aabaeab1d 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c
index 3bc3a60194d..2b0c3be2b1b 100644
--- a/drivers/acpi/acpica/psopcode.c
+++ b/drivers/acpi/acpica/psopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c
index 4df8f139026..8d81542194d 100644
--- a/drivers/acpi/acpica/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psscope.c b/drivers/acpi/acpica/psscope.c
index 2feca5ca958..40e2b279ea1 100644
--- a/drivers/acpi/acpica/psscope.c
+++ b/drivers/acpi/acpica/psscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c
index 4d3389118ec..d4b970c3630 100644
--- a/drivers/acpi/acpica/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c
index e636e078ad3..fe29eee5adb 100644
--- a/drivers/acpi/acpica/psutils.c
+++ b/drivers/acpi/acpica/psutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pswalk.c b/drivers/acpi/acpica/pswalk.c
index 78b8b791f2a..8abb9629443 100644
--- a/drivers/acpi/acpica/pswalk.c
+++ b/drivers/acpi/acpica/pswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index d0c1b91eb8c..6064dd4e94c 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index 1e437bfd8db..226c806ae98 100644
--- a/drivers/acpi/acpica/rsaddr.c
+++ b/drivers/acpi/acpica/rsaddr.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 3c4dcc3d106..d6ebf7ec622 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index a3c23d686d5..f2ee3b54860 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -182,7 +182,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
182 182
183 /* 183 /*
184 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a 184 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
185 * package that in turn contains an acpi_integer Address, a u8 Pin, 185 * package that in turn contains an u64 Address, a u8 Pin,
186 * a Name, and a u8 source_index. 186 * a Name, and a u8 source_index.
187 */ 187 */
188 top_object_list = package_object->package.elements; 188 top_object_list = package_object->package.elements;
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 3f0ca5a12d3..f859b0386fe 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index 77b25fdb459..1fd868b964f 100644
--- a/drivers/acpi/acpica/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsio.c b/drivers/acpi/acpica/rsio.c
index 35a49aa9560..33bff17c0bb 100644
--- a/drivers/acpi/acpica/rsio.c
+++ b/drivers/acpi/acpica/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsirq.c b/drivers/acpi/acpica/rsirq.c
index 2e0256983aa..545da40d7fa 100644
--- a/drivers/acpi/acpica/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index 1b1dbc69f08..fd057c72d25 100644
--- a/drivers/acpi/acpica/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index ddc76cebdc9..887b8ba8c43 100644
--- a/drivers/acpi/acpica/rsmemory.c
+++ b/drivers/acpi/acpica/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index 5bc49a55328..07de352fa44 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index bc03d596682..22cfcfbd9ff 100644
--- a/drivers/acpi/acpica/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index f27feb4772f..9f6a6e7e1c8 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index c016335fb75..f43fbe0fc3f 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 1054dfd4920..e252180ce61 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 63e82329a9e..7ec02b0f69e 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 1f15497f00d..02723a9fb10 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index a88f02bd6c9..5217a6159a3 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index 85ea834199e..dda6e8c497d 100644
--- a/drivers/acpi/acpica/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 7580f6b3069..3d706b8fd44 100644
--- a/drivers/acpi/acpica/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index f857c5efb79..97ec3621e71 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 527d729f681..98351064005 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -460,8 +460,7 @@ ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
460void 460void
461acpi_ut_value_exit(u32 line_number, 461acpi_ut_value_exit(u32 line_number,
462 const char *function_name, 462 const char *function_name,
463 const char *module_name, 463 const char *module_name, u32 component_id, u64 value)
464 u32 component_id, acpi_integer value)
465{ 464{
466 465
467 acpi_debug_print(ACPI_LV_FUNCTIONS, 466 acpi_debug_print(ACPI_LV_FUNCTIONS,
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index 96e26e70c63..16b51c69606 100644
--- a/drivers/acpi/acpica/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index 5d54e36ab45..7f5e734ce7f 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -348,7 +348,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
348acpi_status 348acpi_status
349acpi_ut_evaluate_numeric_object(char *object_name, 349acpi_ut_evaluate_numeric_object(char *object_name,
350 struct acpi_namespace_node *device_node, 350 struct acpi_namespace_node *device_node,
351 acpi_integer *value) 351 u64 *value)
352{ 352{
353 union acpi_operand_object *obj_desc; 353 union acpi_operand_object *obj_desc;
354 acpi_status status; 354 acpi_status status;
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 3f2c68f4e95..eda3e656c4a 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -234,7 +234,7 @@ static const char acpi_gbl_hex_to_ascii[] = {
234 * 234 *
235 ******************************************************************************/ 235 ******************************************************************************/
236 236
237char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position) 237char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
238{ 238{
239 239
240 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); 240 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
index 52eaae40455..1397fadd0d4 100644
--- a/drivers/acpi/acpica/utids.c
+++ b/drivers/acpi/acpica/utids.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index 9d0919ebf7b..a39c93dac71 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c
index 25e03120686..b081cd46a15 100644
--- a/drivers/acpi/acpica/utlock.c
+++ b/drivers/acpi/acpica/utlock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c
index c9f682d640e..35059a14eb7 100644
--- a/drivers/acpi/acpica/utmath.c
+++ b/drivers/acpi/acpica/utmath.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -70,9 +70,8 @@ ACPI_MODULE_NAME("utmath")
70 * 70 *
71 ******************************************************************************/ 71 ******************************************************************************/
72acpi_status 72acpi_status
73acpi_ut_short_divide(acpi_integer dividend, 73acpi_ut_short_divide(u64 dividend,
74 u32 divisor, 74 u32 divisor, u64 *out_quotient, u32 *out_remainder)
75 acpi_integer * out_quotient, u32 * out_remainder)
76{ 75{
77 union uint64_overlay dividend_ovl; 76 union uint64_overlay dividend_ovl;
78 union uint64_overlay quotient; 77 union uint64_overlay quotient;
@@ -126,9 +125,8 @@ acpi_ut_short_divide(acpi_integer dividend,
126 ******************************************************************************/ 125 ******************************************************************************/
127 126
128acpi_status 127acpi_status
129acpi_ut_divide(acpi_integer in_dividend, 128acpi_ut_divide(u64 in_dividend,
130 acpi_integer in_divisor, 129 u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
131 acpi_integer * out_quotient, acpi_integer * out_remainder)
132{ 130{
133 union uint64_overlay dividend; 131 union uint64_overlay dividend;
134 union uint64_overlay divisor; 132 union uint64_overlay divisor;
@@ -199,9 +197,8 @@ acpi_ut_divide(acpi_integer in_dividend,
199 * The 64-bit remainder must be generated. 197 * The 64-bit remainder must be generated.
200 */ 198 */
201 partial1 = quotient.part.lo * divisor.part.hi; 199 partial1 = quotient.part.lo * divisor.part.hi;
202 partial2.full = 200 partial2.full = (u64) quotient.part.lo * divisor.part.lo;
203 (acpi_integer) quotient.part.lo * divisor.part.lo; 201 partial3.full = (u64) partial2.part.hi + partial1;
204 partial3.full = (acpi_integer) partial2.part.hi + partial1;
205 202
206 remainder.part.hi = partial3.part.lo; 203 remainder.part.hi = partial3.part.lo;
207 remainder.part.lo = partial2.part.lo; 204 remainder.part.lo = partial2.part.lo;
@@ -257,9 +254,8 @@ acpi_ut_divide(acpi_integer in_dividend,
257 * 254 *
258 ******************************************************************************/ 255 ******************************************************************************/
259acpi_status 256acpi_status
260acpi_ut_short_divide(acpi_integer in_dividend, 257acpi_ut_short_divide(u64 in_dividend,
261 u32 divisor, 258 u32 divisor, u64 *out_quotient, u32 *out_remainder)
262 acpi_integer * out_quotient, u32 * out_remainder)
263{ 259{
264 260
265 ACPI_FUNCTION_TRACE(ut_short_divide); 261 ACPI_FUNCTION_TRACE(ut_short_divide);
@@ -284,9 +280,8 @@ acpi_ut_short_divide(acpi_integer in_dividend,
284} 280}
285 281
286acpi_status 282acpi_status
287acpi_ut_divide(acpi_integer in_dividend, 283acpi_ut_divide(u64 in_dividend,
288 acpi_integer in_divisor, 284 u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
289 acpi_integer * out_quotient, acpi_integer * out_remainder)
290{ 285{
291 ACPI_FUNCTION_TRACE(ut_divide); 286 ACPI_FUNCTION_TRACE(ut_divide);
292 287
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 6c6a5137b72..32982e2ac38 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -724,13 +724,12 @@ acpi_name acpi_ut_repair_name(char *name)
724 * 724 *
725 ******************************************************************************/ 725 ******************************************************************************/
726 726
727acpi_status 727acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer)
728acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
729{ 728{
730 u32 this_digit = 0; 729 u32 this_digit = 0;
731 acpi_integer return_value = 0; 730 u64 return_value = 0;
732 acpi_integer quotient; 731 u64 quotient;
733 acpi_integer dividend; 732 u64 dividend;
734 u32 to_integer_op = (base == ACPI_ANY_BASE); 733 u32 to_integer_op = (base == ACPI_ANY_BASE);
735 u32 mode32 = (acpi_gbl_integer_byte_width == 4); 734 u32 mode32 = (acpi_gbl_integer_byte_width == 4);
736 u8 valid_digits = 0; 735 u8 valid_digits = 0;
@@ -844,9 +843,8 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
844 843
845 /* Divide the digit into the correct position */ 844 /* Divide the digit into the correct position */
846 845
847 (void) 846 (void)acpi_ut_short_divide((dividend - (u64) this_digit),
848 acpi_ut_short_divide((dividend - (acpi_integer) this_digit), 847 base, &quotient, NULL);
849 base, &quotient, NULL);
850 848
851 if (return_value > quotient) { 849 if (return_value > quotient) {
852 if (to_integer_op) { 850 if (to_integer_op) {
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 80bb6515411..55d014ed6d5 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@ ACPI_MODULE_NAME("utmutex")
50/* Local prototypes */ 50/* Local prototypes */
51static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id); 51static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id);
52 52
53static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id); 53static void acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
54 54
55/******************************************************************************* 55/*******************************************************************************
56 * 56 *
@@ -114,7 +114,7 @@ void acpi_ut_mutex_terminate(void)
114 /* Delete each predefined mutex object */ 114 /* Delete each predefined mutex object */
115 115
116 for (i = 0; i < ACPI_NUM_MUTEX; i++) { 116 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
117 (void)acpi_ut_delete_mutex(i); 117 acpi_ut_delete_mutex(i);
118 } 118 }
119 119
120 /* Delete the spinlocks */ 120 /* Delete the spinlocks */
@@ -146,10 +146,6 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
146 146
147 ACPI_FUNCTION_TRACE_U32(ut_create_mutex, mutex_id); 147 ACPI_FUNCTION_TRACE_U32(ut_create_mutex, mutex_id);
148 148
149 if (mutex_id > ACPI_MAX_MUTEX) {
150 return_ACPI_STATUS(AE_BAD_PARAMETER);
151 }
152
153 if (!acpi_gbl_mutex_info[mutex_id].mutex) { 149 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
154 status = 150 status =
155 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex); 151 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex);
@@ -173,21 +169,15 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
173 * 169 *
174 ******************************************************************************/ 170 ******************************************************************************/
175 171
176static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) 172static void acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
177{ 173{
178 174
179 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id); 175 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id);
180 176
181 if (mutex_id > ACPI_MAX_MUTEX) {
182 return_ACPI_STATUS(AE_BAD_PARAMETER);
183 }
184
185 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex); 177 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
186 178
187 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 179 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
188 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 180 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
189
190 return_ACPI_STATUS(AE_OK);
191} 181}
192 182
193/******************************************************************************* 183/*******************************************************************************
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index 42e658b543f..3356f0cb074 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index 91b7c00236f..7965919000b 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c
index 0440c958f5a..d35d109b8da 100644
--- a/drivers/acpi/acpica/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index b1f5f680bc7..db9d8ca5798 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index cada73ffdfa..58d2c91ba62 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -324,8 +324,8 @@ static int extract_package(struct acpi_battery *battery,
324 strncpy(ptr, element->string.pointer, 32); 324 strncpy(ptr, element->string.pointer, 32);
325 else if (element->type == ACPI_TYPE_INTEGER) { 325 else if (element->type == ACPI_TYPE_INTEGER) {
326 strncpy(ptr, (u8 *)&element->integer.value, 326 strncpy(ptr, (u8 *)&element->integer.value,
327 sizeof(acpi_integer)); 327 sizeof(u64));
328 ptr[sizeof(acpi_integer)] = 0; 328 ptr[sizeof(u64)] = 0;
329 } else 329 } else
330 *ptr = 0; /* don't have value */ 330 *ptr = 0; /* don't have value */
331 } else { 331 } else {
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 27e0b92b2e3..d7a6bbbb834 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -597,7 +597,7 @@ static u32 acpi_ec_gpe_handler(void *data)
597 597
598static acpi_status 598static acpi_status
599acpi_ec_space_handler(u32 function, acpi_physical_address address, 599acpi_ec_space_handler(u32 function, acpi_physical_address address,
600 u32 bits, acpi_integer *value, 600 u32 bits, u64 *value,
601 void *handler_context, void *region_context) 601 void *handler_context, void *region_context)
602{ 602{
603 struct acpi_ec *ec = handler_context; 603 struct acpi_ec *ec = handler_context;
@@ -628,7 +628,7 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
628 ++address; 628 ++address;
629 if (function == ACPI_READ) { 629 if (function == ACPI_READ) {
630 result = acpi_ec_read(ec, address, &temp); 630 result = acpi_ec_read(ec, address, &temp);
631 (*value) |= ((acpi_integer)temp) << i; 631 (*value) |= ((u64)temp) << i;
632 } else { 632 } else {
633 temp = 0xff & ((*value) >> i); 633 temp = 0xff & ((*value) >> i);
634 result = acpi_ec_write(ec, address, temp); 634 result = acpi_ec_write(ec, address, temp);
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 4c8fcff662c..6d5b64b7d52 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -87,7 +87,7 @@ static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
87/* Get device's handler per its address under its parent */ 87/* Get device's handler per its address under its parent */
88struct acpi_find_child { 88struct acpi_find_child {
89 acpi_handle handle; 89 acpi_handle handle;
90 acpi_integer address; 90 u64 address;
91}; 91};
92 92
93static acpi_status 93static acpi_status
@@ -106,7 +106,7 @@ do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
106 return AE_OK; 106 return AE_OK;
107} 107}
108 108
109acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address) 109acpi_handle acpi_get_child(acpi_handle parent, u64 address)
110{ 110{
111 struct acpi_find_child find = { NULL, address }; 111 struct acpi_find_child find = { NULL, address };
112 112
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 02e8464e480..8e6d8665f0a 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -436,7 +436,7 @@ acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
436 * Running in interpreter thread context, safe to sleep 436 * Running in interpreter thread context, safe to sleep
437 */ 437 */
438 438
439void acpi_os_sleep(acpi_integer ms) 439void acpi_os_sleep(u64 ms)
440{ 440{
441 schedule_timeout_interruptible(msecs_to_jiffies(ms)); 441 schedule_timeout_interruptible(msecs_to_jiffies(ms));
442} 442}
@@ -603,7 +603,7 @@ acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
603 603
604acpi_status 604acpi_status
605acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, 605acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
606 acpi_integer value, u32 width) 606 u64 value, u32 width)
607{ 607{
608 int result, size; 608 int result, size;
609 609
diff --git a/drivers/acpi/power_meter.c b/drivers/acpi/power_meter.c
index dc4ffadf812..834c5af0de4 100644
--- a/drivers/acpi/power_meter.c
+++ b/drivers/acpi/power_meter.c
@@ -71,17 +71,17 @@ static const struct acpi_device_id power_meter_ids[] = {
71MODULE_DEVICE_TABLE(acpi, power_meter_ids); 71MODULE_DEVICE_TABLE(acpi, power_meter_ids);
72 72
73struct acpi_power_meter_capabilities { 73struct acpi_power_meter_capabilities {
74 acpi_integer flags; 74 u64 flags;
75 acpi_integer units; 75 u64 units;
76 acpi_integer type; 76 u64 type;
77 acpi_integer accuracy; 77 u64 accuracy;
78 acpi_integer sampling_time; 78 u64 sampling_time;
79 acpi_integer min_avg_interval; 79 u64 min_avg_interval;
80 acpi_integer max_avg_interval; 80 u64 max_avg_interval;
81 acpi_integer hysteresis; 81 u64 hysteresis;
82 acpi_integer configurable_cap; 82 u64 configurable_cap;
83 acpi_integer min_cap; 83 u64 min_cap;
84 acpi_integer max_cap; 84 u64 max_cap;
85}; 85};
86 86
87struct acpi_power_meter_resource { 87struct acpi_power_meter_resource {
@@ -93,9 +93,9 @@ struct acpi_power_meter_resource {
93 acpi_string model_number; 93 acpi_string model_number;
94 acpi_string serial_number; 94 acpi_string serial_number;
95 acpi_string oem_info; 95 acpi_string oem_info;
96 acpi_integer power; 96 u64 power;
97 acpi_integer cap; 97 u64 cap;
98 acpi_integer avg_interval; 98 u64 avg_interval;
99 int sensors_valid; 99 int sensors_valid;
100 unsigned long sensors_last_updated; 100 unsigned long sensors_last_updated;
101 struct sensor_device_attribute sensors[NUM_SENSORS]; 101 struct sensor_device_attribute sensors[NUM_SENSORS];
@@ -402,7 +402,7 @@ static ssize_t show_val(struct device *dev,
402 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 402 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
403 struct acpi_device *acpi_dev = to_acpi_device(dev); 403 struct acpi_device *acpi_dev = to_acpi_device(dev);
404 struct acpi_power_meter_resource *resource = acpi_dev->driver_data; 404 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
405 acpi_integer val = 0; 405 u64 val = 0;
406 406
407 switch (attr->index) { 407 switch (attr->index) {
408 case 0: 408 case 0:
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index cc978a8c00b..37dfce74939 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -360,7 +360,7 @@ static int acpi_processor_get_power_info_default(struct acpi_processor *pr)
360static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) 360static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
361{ 361{
362 acpi_status status = 0; 362 acpi_status status = 0;
363 acpi_integer count; 363 u64 count;
364 int current_count; 364 int current_count;
365 int i; 365 int i;
366 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 366 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1c5d7a8b2fd..7ded7542fc9 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -660,7 +660,7 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
660 660
661#ifdef CONFIG_X86 661#ifdef CONFIG_X86
662static int acpi_throttling_rdmsr(struct acpi_processor *pr, 662static int acpi_throttling_rdmsr(struct acpi_processor *pr,
663 acpi_integer * value) 663 u64 *value)
664{ 664{
665 struct cpuinfo_x86 *c; 665 struct cpuinfo_x86 *c;
666 u64 msr_high, msr_low; 666 u64 msr_high, msr_low;
@@ -681,13 +681,13 @@ static int acpi_throttling_rdmsr(struct acpi_processor *pr,
681 rdmsr_safe(MSR_IA32_THERM_CONTROL, 681 rdmsr_safe(MSR_IA32_THERM_CONTROL,
682 (u32 *)&msr_low , (u32 *) &msr_high); 682 (u32 *)&msr_low , (u32 *) &msr_high);
683 msr = (msr_high << 32) | msr_low; 683 msr = (msr_high << 32) | msr_low;
684 *value = (acpi_integer) msr; 684 *value = (u64) msr;
685 ret = 0; 685 ret = 0;
686 } 686 }
687 return ret; 687 return ret;
688} 688}
689 689
690static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) 690static int acpi_throttling_wrmsr(struct acpi_processor *pr, u64 value)
691{ 691{
692 struct cpuinfo_x86 *c; 692 struct cpuinfo_x86 *c;
693 unsigned int cpu; 693 unsigned int cpu;
@@ -711,14 +711,14 @@ static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
711} 711}
712#else 712#else
713static int acpi_throttling_rdmsr(struct acpi_processor *pr, 713static int acpi_throttling_rdmsr(struct acpi_processor *pr,
714 acpi_integer * value) 714 u64 *value)
715{ 715{
716 printk(KERN_ERR PREFIX 716 printk(KERN_ERR PREFIX
717 "HARDWARE addr space,NOT supported yet\n"); 717 "HARDWARE addr space,NOT supported yet\n");
718 return -1; 718 return -1;
719} 719}
720 720
721static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) 721static int acpi_throttling_wrmsr(struct acpi_processor *pr, u64 value)
722{ 722{
723 printk(KERN_ERR PREFIX 723 printk(KERN_ERR PREFIX
724 "HARDWARE addr space,NOT supported yet\n"); 724 "HARDWARE addr space,NOT supported yet\n");
@@ -727,7 +727,7 @@ static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
727#endif 727#endif
728 728
729static int acpi_read_throttling_status(struct acpi_processor *pr, 729static int acpi_read_throttling_status(struct acpi_processor *pr,
730 acpi_integer *value) 730 u64 *value)
731{ 731{
732 u32 bit_width, bit_offset; 732 u32 bit_width, bit_offset;
733 u64 ptc_value; 733 u64 ptc_value;
@@ -746,7 +746,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
746 address, (u32 *) &ptc_value, 746 address, (u32 *) &ptc_value,
747 (u32) (bit_width + bit_offset)); 747 (u32) (bit_width + bit_offset));
748 ptc_mask = (1 << bit_width) - 1; 748 ptc_mask = (1 << bit_width) - 1;
749 *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask); 749 *value = (u64) ((ptc_value >> bit_offset) & ptc_mask);
750 ret = 0; 750 ret = 0;
751 break; 751 break;
752 case ACPI_ADR_SPACE_FIXED_HARDWARE: 752 case ACPI_ADR_SPACE_FIXED_HARDWARE:
@@ -760,7 +760,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
760} 760}
761 761
762static int acpi_write_throttling_state(struct acpi_processor *pr, 762static int acpi_write_throttling_state(struct acpi_processor *pr,
763 acpi_integer value) 763 u64 value)
764{ 764{
765 u32 bit_width, bit_offset; 765 u32 bit_width, bit_offset;
766 u64 ptc_value; 766 u64 ptc_value;
@@ -793,7 +793,7 @@ static int acpi_write_throttling_state(struct acpi_processor *pr,
793} 793}
794 794
795static int acpi_get_throttling_state(struct acpi_processor *pr, 795static int acpi_get_throttling_state(struct acpi_processor *pr,
796 acpi_integer value) 796 u64 value)
797{ 797{
798 int i; 798 int i;
799 799
@@ -808,7 +808,7 @@ static int acpi_get_throttling_state(struct acpi_processor *pr,
808} 808}
809 809
810static int acpi_get_throttling_value(struct acpi_processor *pr, 810static int acpi_get_throttling_value(struct acpi_processor *pr,
811 int state, acpi_integer *value) 811 int state, u64 *value)
812{ 812{
813 int ret = -1; 813 int ret = -1;
814 814
@@ -826,7 +826,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
826{ 826{
827 int state = 0; 827 int state = 0;
828 int ret; 828 int ret;
829 acpi_integer value; 829 u64 value;
830 830
831 if (!pr) 831 if (!pr)
832 return -EINVAL; 832 return -EINVAL;
@@ -993,7 +993,7 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
993 int state, bool force) 993 int state, bool force)
994{ 994{
995 int ret; 995 int ret;
996 acpi_integer value; 996 u64 value;
997 997
998 if (!pr) 998 if (!pr)
999 return -EINVAL; 999 return -EINVAL;
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 811fec10462..11882dbe209 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -107,12 +107,12 @@ acpi_extract_package(union acpi_object *package,
107 case ACPI_TYPE_INTEGER: 107 case ACPI_TYPE_INTEGER:
108 switch (format_string[i]) { 108 switch (format_string[i]) {
109 case 'N': 109 case 'N':
110 size_required += sizeof(acpi_integer); 110 size_required += sizeof(u64);
111 tail_offset += sizeof(acpi_integer); 111 tail_offset += sizeof(u64);
112 break; 112 break;
113 case 'S': 113 case 'S':
114 size_required += 114 size_required +=
115 sizeof(char *) + sizeof(acpi_integer) + 115 sizeof(char *) + sizeof(u64) +
116 sizeof(char); 116 sizeof(char);
117 tail_offset += sizeof(char *); 117 tail_offset += sizeof(char *);
118 break; 118 break;
@@ -193,17 +193,17 @@ acpi_extract_package(union acpi_object *package,
193 case ACPI_TYPE_INTEGER: 193 case ACPI_TYPE_INTEGER:
194 switch (format_string[i]) { 194 switch (format_string[i]) {
195 case 'N': 195 case 'N':
196 *((acpi_integer *) head) = 196 *((u64 *) head) =
197 element->integer.value; 197 element->integer.value;
198 head += sizeof(acpi_integer); 198 head += sizeof(u64);
199 break; 199 break;
200 case 'S': 200 case 'S':
201 pointer = (u8 **) head; 201 pointer = (u8 **) head;
202 *pointer = tail; 202 *pointer = tail;
203 *((acpi_integer *) tail) = 203 *((u64 *) tail) =
204 element->integer.value; 204 element->integer.value;
205 head += sizeof(acpi_integer *); 205 head += sizeof(u64 *);
206 tail += sizeof(acpi_integer); 206 tail += sizeof(u64);
207 /* NULL terminate string */ 207 /* NULL terminate string */
208 *tail = (char)0; 208 *tail = (char)0;
209 tail += sizeof(char); 209 tail += sizeof(char);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index b765790b32b..6e9b49149fc 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -759,7 +759,7 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video,
759static int 759static int
760acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) 760acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
761{ 761{
762 acpi_integer status = 0; 762 u64 status = 0;
763 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 763 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
764 struct acpi_object_list args = { 1, &arg0 }; 764 struct acpi_object_list args = { 1, &arg0 };
765 765
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 1245838ac13..292fdbc0431 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -64,7 +64,7 @@ void ata_acpi_associate_sata_port(struct ata_port *ap)
64 WARN_ON(!(ap->flags & ATA_FLAG_ACPI_SATA)); 64 WARN_ON(!(ap->flags & ATA_FLAG_ACPI_SATA));
65 65
66 if (!sata_pmp_attached(ap)) { 66 if (!sata_pmp_attached(ap)) {
67 acpi_integer adr = SATA_ADR(ap->port_no, NO_PORT_MULT); 67 u64 adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
68 68
69 ap->link.device->acpi_handle = 69 ap->link.device->acpi_handle =
70 acpi_get_child(ap->host->acpi_handle, adr); 70 acpi_get_child(ap->host->acpi_handle, adr);
@@ -74,7 +74,7 @@ void ata_acpi_associate_sata_port(struct ata_port *ap)
74 ap->link.device->acpi_handle = NULL; 74 ap->link.device->acpi_handle = NULL;
75 75
76 ata_for_each_link(link, ap, EDGE) { 76 ata_for_each_link(link, ap, EDGE) {
77 acpi_integer adr = SATA_ADR(ap->port_no, link->pmp); 77 u64 adr = SATA_ADR(ap->port_no, link->pmp);
78 78
79 link->device->acpi_handle = 79 link->device->acpi_handle =
80 acpi_get_child(ap->host->acpi_handle, adr); 80 acpi_get_child(ap->host->acpi_handle, adr);
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index f706b1dffdb..ada25bb8941 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1185,11 +1185,6 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1185 1185
1186 rep = (down == 2); 1186 rep = (down == 2);
1187 1187
1188#ifdef CONFIG_MAC_EMUMOUSEBTN
1189 if (mac_hid_mouse_emulate_buttons(1, keycode, down))
1190 return;
1191#endif /* CONFIG_MAC_EMUMOUSEBTN */
1192
1193 if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw) 1188 if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw)
1194 if (emulate_raw(vc, keycode, !down << 7)) 1189 if (emulate_raw(vc, keycode, !down << 7))
1195 if (keycode < BTN_MISC && printk_ratelimit()) 1190 if (keycode < BTN_MISC && printk_ratelimit())
@@ -1328,6 +1323,21 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type,
1328 schedule_console_callback(); 1323 schedule_console_callback();
1329} 1324}
1330 1325
1326static bool kbd_match(struct input_handler *handler, struct input_dev *dev)
1327{
1328 int i;
1329
1330 if (test_bit(EV_SND, dev->evbit))
1331 return true;
1332
1333 if (test_bit(EV_KEY, dev->evbit))
1334 for (i = KEY_RESERVED; i < BTN_MISC; i++)
1335 if (test_bit(i, dev->keybit))
1336 return true;
1337
1338 return false;
1339}
1340
1331/* 1341/*
1332 * When a keyboard (or other input device) is found, the kbd_connect 1342 * When a keyboard (or other input device) is found, the kbd_connect
1333 * function is called. The function then looks at the device, and if it 1343 * function is called. The function then looks at the device, and if it
@@ -1339,14 +1349,6 @@ static int kbd_connect(struct input_handler *handler, struct input_dev *dev,
1339{ 1349{
1340 struct input_handle *handle; 1350 struct input_handle *handle;
1341 int error; 1351 int error;
1342 int i;
1343
1344 for (i = KEY_RESERVED; i < BTN_MISC; i++)
1345 if (test_bit(i, dev->keybit))
1346 break;
1347
1348 if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
1349 return -ENODEV;
1350 1352
1351 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); 1353 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
1352 if (!handle) 1354 if (!handle)
@@ -1412,6 +1414,7 @@ MODULE_DEVICE_TABLE(input, kbd_ids);
1412 1414
1413static struct input_handler kbd_handler = { 1415static struct input_handler kbd_handler = {
1414 .event = kbd_event, 1416 .event = kbd_event,
1417 .match = kbd_match,
1415 .connect = kbd_connect, 1418 .connect = kbd_connect,
1416 .disconnect = kbd_disconnect, 1419 .disconnect = kbd_disconnect,
1417 .start = kbd_start, 1420 .start = kbd_start,
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index c0cf45a11b9..5cb01e5c323 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -108,11 +108,11 @@ bool ide_port_acpi(ide_hwif_t *hwif)
108 * Returns 0 on success, <0 on error. 108 * Returns 0 on success, <0 on error.
109 */ 109 */
110static int ide_get_dev_handle(struct device *dev, acpi_handle *handle, 110static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
111 acpi_integer *pcidevfn) 111 u64 *pcidevfn)
112{ 112{
113 struct pci_dev *pdev = to_pci_dev(dev); 113 struct pci_dev *pdev = to_pci_dev(dev);
114 unsigned int bus, devnum, func; 114 unsigned int bus, devnum, func;
115 acpi_integer addr; 115 u64 addr;
116 acpi_handle dev_handle; 116 acpi_handle dev_handle;
117 acpi_status status; 117 acpi_status status;
118 struct acpi_device_info *dinfo = NULL; 118 struct acpi_device_info *dinfo = NULL;
@@ -122,7 +122,7 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
122 devnum = PCI_SLOT(pdev->devfn); 122 devnum = PCI_SLOT(pdev->devfn);
123 func = PCI_FUNC(pdev->devfn); 123 func = PCI_FUNC(pdev->devfn);
124 /* ACPI _ADR encoding for PCI bus: */ 124 /* ACPI _ADR encoding for PCI bus: */
125 addr = (acpi_integer)(devnum << 16 | func); 125 addr = (u64)(devnum << 16 | func);
126 126
127 DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func); 127 DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func);
128 128
@@ -169,7 +169,7 @@ static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif)
169{ 169{
170 struct device *dev = hwif->gendev.parent; 170 struct device *dev = hwif->gendev.parent;
171 acpi_handle uninitialized_var(dev_handle); 171 acpi_handle uninitialized_var(dev_handle);
172 acpi_integer pcidevfn; 172 u64 pcidevfn;
173 acpi_handle chan_handle; 173 acpi_handle chan_handle;
174 int err; 174 int err;
175 175
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 258c639571b..9f9816baeb9 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -278,6 +278,8 @@ static int evdev_open(struct inode *inode, struct file *file)
278 goto err_free_client; 278 goto err_free_client;
279 279
280 file->private_data = client; 280 file->private_data = client;
281 nonseekable_open(inode, file);
282
281 return 0; 283 return 0;
282 284
283 err_free_client: 285 err_free_client:
diff --git a/drivers/input/gameport/emu10k1-gp.c b/drivers/input/gameport/emu10k1-gp.c
index b04930f7ea7..7392992da42 100644
--- a/drivers/input/gameport/emu10k1-gp.c
+++ b/drivers/input/gameport/emu10k1-gp.c
@@ -46,7 +46,7 @@ struct emu {
46 int size; 46 int size;
47}; 47};
48 48
49static struct pci_device_id emu_tbl[] = { 49static const struct pci_device_id emu_tbl[] = {
50 50
51 { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */ 51 { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */
52 { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */ 52 { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index 8a1810f88b9..14d3f3e208a 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -140,7 +140,7 @@ static void __devexit fm801_gp_remove(struct pci_dev *pci)
140 } 140 }
141} 141}
142 142
143static struct pci_device_id fm801_gp_id_table[] = { 143static const struct pci_device_id fm801_gp_id_table[] = {
144 { PCI_VENDOR_ID_FORTEMEDIA, PCI_DEVICE_ID_FM801_GP, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 144 { PCI_VENDOR_ID_FORTEMEDIA, PCI_DEVICE_ID_FM801_GP, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
145 { 0 } 145 { 0 }
146}; 146};
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index ac11be08585..7e18bcf05a6 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -11,6 +11,8 @@
11 * the Free Software Foundation. 11 * the Free Software Foundation.
12 */ 12 */
13 13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
14#include <linux/stddef.h> 16#include <linux/stddef.h>
15#include <linux/module.h> 17#include <linux/module.h>
16#include <linux/ioport.h> 18#include <linux/ioport.h>
@@ -190,9 +192,8 @@ static int gameport_bind_driver(struct gameport *gameport, struct gameport_drive
190 192
191 error = device_bind_driver(&gameport->dev); 193 error = device_bind_driver(&gameport->dev);
192 if (error) { 194 if (error) {
193 printk(KERN_WARNING 195 dev_warn(&gameport->dev,
194 "gameport: device_bind_driver() failed " 196 "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
195 "for %s (%s) and %s, error: %d\n",
196 gameport->phys, gameport->name, 197 gameport->phys, gameport->name,
197 drv->description, error); 198 drv->description, error);
198 drv->disconnect(gameport); 199 drv->disconnect(gameport);
@@ -209,9 +210,9 @@ static void gameport_find_driver(struct gameport *gameport)
209 210
210 error = device_attach(&gameport->dev); 211 error = device_attach(&gameport->dev);
211 if (error < 0) 212 if (error < 0)
212 printk(KERN_WARNING 213 dev_warn(&gameport->dev,
213 "gameport: device_attach() failed for %s (%s), error: %d\n", 214 "device_attach() failed for %s (%s), error: %d\n",
214 gameport->phys, gameport->name, error); 215 gameport->phys, gameport->name, error);
215} 216}
216 217
217 218
@@ -262,17 +263,14 @@ static int gameport_queue_event(void *object, struct module *owner,
262 263
263 event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC); 264 event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC);
264 if (!event) { 265 if (!event) {
265 printk(KERN_ERR 266 pr_err("Not enough memory to queue event %d\n", event_type);
266 "gameport: Not enough memory to queue event %d\n",
267 event_type);
268 retval = -ENOMEM; 267 retval = -ENOMEM;
269 goto out; 268 goto out;
270 } 269 }
271 270
272 if (!try_module_get(owner)) { 271 if (!try_module_get(owner)) {
273 printk(KERN_WARNING 272 pr_warning("Can't get module reference, dropping event %d\n",
274 "gameport: Can't get module reference, dropping event %d\n", 273 event_type);
275 event_type);
276 kfree(event); 274 kfree(event);
277 retval = -EINVAL; 275 retval = -EINVAL;
278 goto out; 276 goto out;
@@ -298,14 +296,12 @@ static void gameport_free_event(struct gameport_event *event)
298 296
299static void gameport_remove_duplicate_events(struct gameport_event *event) 297static void gameport_remove_duplicate_events(struct gameport_event *event)
300{ 298{
301 struct list_head *node, *next; 299 struct gameport_event *e, *next;
302 struct gameport_event *e;
303 unsigned long flags; 300 unsigned long flags;
304 301
305 spin_lock_irqsave(&gameport_event_lock, flags); 302 spin_lock_irqsave(&gameport_event_lock, flags);
306 303
307 list_for_each_safe(node, next, &gameport_event_list) { 304 list_for_each_entry_safe(e, next, &gameport_event_list, node) {
308 e = list_entry(node, struct gameport_event, node);
309 if (event->object == e->object) { 305 if (event->object == e->object) {
310 /* 306 /*
311 * If this event is of different type we should not 307 * If this event is of different type we should not
@@ -315,7 +311,7 @@ static void gameport_remove_duplicate_events(struct gameport_event *event)
315 if (event->type != e->type) 311 if (event->type != e->type)
316 break; 312 break;
317 313
318 list_del_init(node); 314 list_del_init(&e->node);
319 gameport_free_event(e); 315 gameport_free_event(e);
320 } 316 }
321 } 317 }
@@ -325,23 +321,18 @@ static void gameport_remove_duplicate_events(struct gameport_event *event)
325 321
326static struct gameport_event *gameport_get_event(void) 322static struct gameport_event *gameport_get_event(void)
327{ 323{
328 struct gameport_event *event; 324 struct gameport_event *event = NULL;
329 struct list_head *node;
330 unsigned long flags; 325 unsigned long flags;
331 326
332 spin_lock_irqsave(&gameport_event_lock, flags); 327 spin_lock_irqsave(&gameport_event_lock, flags);
333 328
334 if (list_empty(&gameport_event_list)) { 329 if (!list_empty(&gameport_event_list)) {
335 spin_unlock_irqrestore(&gameport_event_lock, flags); 330 event = list_first_entry(&gameport_event_list,
336 return NULL; 331 struct gameport_event, node);
332 list_del_init(&event->node);
337 } 333 }
338 334
339 node = gameport_event_list.next;
340 event = list_entry(node, struct gameport_event, node);
341 list_del_init(node);
342
343 spin_unlock_irqrestore(&gameport_event_lock, flags); 335 spin_unlock_irqrestore(&gameport_event_lock, flags);
344
345 return event; 336 return event;
346} 337}
347 338
@@ -360,16 +351,14 @@ static void gameport_handle_event(void)
360 if ((event = gameport_get_event())) { 351 if ((event = gameport_get_event())) {
361 352
362 switch (event->type) { 353 switch (event->type) {
363 case GAMEPORT_REGISTER_PORT:
364 gameport_add_port(event->object);
365 break;
366 354
367 case GAMEPORT_ATTACH_DRIVER: 355 case GAMEPORT_REGISTER_PORT:
368 gameport_attach_driver(event->object); 356 gameport_add_port(event->object);
369 break; 357 break;
370 358
371 default: 359 case GAMEPORT_ATTACH_DRIVER:
372 break; 360 gameport_attach_driver(event->object);
361 break;
373 } 362 }
374 363
375 gameport_remove_duplicate_events(event); 364 gameport_remove_duplicate_events(event);
@@ -385,16 +374,14 @@ static void gameport_handle_event(void)
385 */ 374 */
386static void gameport_remove_pending_events(void *object) 375static void gameport_remove_pending_events(void *object)
387{ 376{
388 struct list_head *node, *next; 377 struct gameport_event *event, *next;
389 struct gameport_event *event;
390 unsigned long flags; 378 unsigned long flags;
391 379
392 spin_lock_irqsave(&gameport_event_lock, flags); 380 spin_lock_irqsave(&gameport_event_lock, flags);
393 381
394 list_for_each_safe(node, next, &gameport_event_list) { 382 list_for_each_entry_safe(event, next, &gameport_event_list, node) {
395 event = list_entry(node, struct gameport_event, node);
396 if (event->object == object) { 383 if (event->object == object) {
397 list_del_init(node); 384 list_del_init(&event->node);
398 gameport_free_event(event); 385 gameport_free_event(event);
399 } 386 }
400 } 387 }
@@ -441,7 +428,6 @@ static int gameport_thread(void *nothing)
441 kthread_should_stop() || !list_empty(&gameport_event_list)); 428 kthread_should_stop() || !list_empty(&gameport_event_list));
442 } while (!kthread_should_stop()); 429 } while (!kthread_should_stop());
443 430
444 printk(KERN_DEBUG "gameport: kgameportd exiting\n");
445 return 0; 431 return 0;
446} 432}
447 433
@@ -453,6 +439,7 @@ static int gameport_thread(void *nothing)
453static ssize_t gameport_show_description(struct device *dev, struct device_attribute *attr, char *buf) 439static ssize_t gameport_show_description(struct device *dev, struct device_attribute *attr, char *buf)
454{ 440{
455 struct gameport *gameport = to_gameport_port(dev); 441 struct gameport *gameport = to_gameport_port(dev);
442
456 return sprintf(buf, "%s\n", gameport->name); 443 return sprintf(buf, "%s\n", gameport->name);
457} 444}
458 445
@@ -521,7 +508,8 @@ static void gameport_init_port(struct gameport *gameport)
521 508
522 mutex_init(&gameport->drv_mutex); 509 mutex_init(&gameport->drv_mutex);
523 device_initialize(&gameport->dev); 510 device_initialize(&gameport->dev);
524 dev_set_name(&gameport->dev, "gameport%lu", (unsigned long)atomic_inc_return(&gameport_no) - 1); 511 dev_set_name(&gameport->dev, "gameport%lu",
512 (unsigned long)atomic_inc_return(&gameport_no) - 1);
525 gameport->dev.bus = &gameport_bus; 513 gameport->dev.bus = &gameport_bus;
526 gameport->dev.release = gameport_release_port; 514 gameport->dev.release = gameport_release_port;
527 if (gameport->parent) 515 if (gameport->parent)
@@ -550,19 +538,17 @@ static void gameport_add_port(struct gameport *gameport)
550 list_add_tail(&gameport->node, &gameport_list); 538 list_add_tail(&gameport->node, &gameport_list);
551 539
552 if (gameport->io) 540 if (gameport->io)
553 printk(KERN_INFO "gameport: %s is %s, io %#x, speed %dkHz\n", 541 dev_info(&gameport->dev, "%s is %s, io %#x, speed %dkHz\n",
554 gameport->name, gameport->phys, gameport->io, gameport->speed); 542 gameport->name, gameport->phys, gameport->io, gameport->speed);
555 else 543 else
556 printk(KERN_INFO "gameport: %s is %s, speed %dkHz\n", 544 dev_info(&gameport->dev, "%s is %s, speed %dkHz\n",
557 gameport->name, gameport->phys, gameport->speed); 545 gameport->name, gameport->phys, gameport->speed);
558 546
559 error = device_add(&gameport->dev); 547 error = device_add(&gameport->dev);
560 if (error) 548 if (error)
561 printk(KERN_ERR 549 dev_err(&gameport->dev,
562 "gameport: device_add() failed for %s (%s), error: %d\n", 550 "device_add() failed for %s (%s), error: %d\n",
563 gameport->phys, gameport->name, error); 551 gameport->phys, gameport->name, error);
564 else
565 gameport->registered = 1;
566} 552}
567 553
568/* 554/*
@@ -584,10 +570,8 @@ static void gameport_destroy_port(struct gameport *gameport)
584 gameport->parent = NULL; 570 gameport->parent = NULL;
585 } 571 }
586 572
587 if (gameport->registered) { 573 if (device_is_registered(&gameport->dev))
588 device_del(&gameport->dev); 574 device_del(&gameport->dev);
589 gameport->registered = 0;
590 }
591 575
592 list_del_init(&gameport->node); 576 list_del_init(&gameport->node);
593 577
@@ -705,8 +689,7 @@ static void gameport_attach_driver(struct gameport_driver *drv)
705 689
706 error = driver_attach(&drv->driver); 690 error = driver_attach(&drv->driver);
707 if (error) 691 if (error)
708 printk(KERN_ERR 692 pr_err("driver_attach() failed for %s, error: %d\n",
709 "gameport: driver_attach() failed for %s, error: %d\n",
710 drv->driver.name, error); 693 drv->driver.name, error);
711} 694}
712 695
@@ -727,8 +710,7 @@ int __gameport_register_driver(struct gameport_driver *drv, struct module *owner
727 710
728 error = driver_register(&drv->driver); 711 error = driver_register(&drv->driver);
729 if (error) { 712 if (error) {
730 printk(KERN_ERR 713 pr_err("driver_register() failed for %s, error: %d\n",
731 "gameport: driver_register() failed for %s, error: %d\n",
732 drv->driver.name, error); 714 drv->driver.name, error);
733 return error; 715 return error;
734 } 716 }
@@ -828,7 +810,7 @@ static int __init gameport_init(void)
828 810
829 error = bus_register(&gameport_bus); 811 error = bus_register(&gameport_bus);
830 if (error) { 812 if (error) {
831 printk(KERN_ERR "gameport: failed to register gameport bus, error: %d\n", error); 813 pr_err("failed to register gameport bus, error: %d\n", error);
832 return error; 814 return error;
833 } 815 }
834 816
@@ -836,7 +818,7 @@ static int __init gameport_init(void)
836 if (IS_ERR(gameport_task)) { 818 if (IS_ERR(gameport_task)) {
837 bus_unregister(&gameport_bus); 819 bus_unregister(&gameport_bus);
838 error = PTR_ERR(gameport_task); 820 error = PTR_ERR(gameport_task);
839 printk(KERN_ERR "gameport: Failed to start kgameportd, error: %d\n", error); 821 pr_err("Failed to start kgameportd, error: %d\n", error);
840 return error; 822 return error;
841 } 823 }
842 824
diff --git a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c
index db556b71ddd..7c217848613 100644
--- a/drivers/input/gameport/ns558.c
+++ b/drivers/input/gameport/ns558.c
@@ -166,7 +166,7 @@ static int ns558_isa_probe(int io)
166 166
167#ifdef CONFIG_PNP 167#ifdef CONFIG_PNP
168 168
169static struct pnp_device_id pnp_devids[] = { 169static const struct pnp_device_id pnp_devids[] = {
170 { .id = "@P@0001", .driver_data = 0 }, /* ALS 100 */ 170 { .id = "@P@0001", .driver_data = 0 }, /* ALS 100 */
171 { .id = "@P@0020", .driver_data = 0 }, /* ALS 200 */ 171 { .id = "@P@0020", .driver_data = 0 }, /* ALS 200 */
172 { .id = "@P@1001", .driver_data = 0 }, /* ALS 100+ */ 172 { .id = "@P@1001", .driver_data = 0 }, /* ALS 100+ */
diff --git a/drivers/input/input-compat.h b/drivers/input/input-compat.h
index 47cd9eaee66..4d8ea32e8a0 100644
--- a/drivers/input/input-compat.h
+++ b/drivers/input/input-compat.h
@@ -21,8 +21,6 @@
21 you why the ifdefs are needed? Think about it again. -AK */ 21 you why the ifdefs are needed? Think about it again. -AK */
22#ifdef CONFIG_X86_64 22#ifdef CONFIG_X86_64
23# define INPUT_COMPAT_TEST is_compat_task() 23# define INPUT_COMPAT_TEST is_compat_task()
24#elif defined(CONFIG_IA64)
25# define INPUT_COMPAT_TEST IS_IA32_PROCESS(task_pt_regs(current))
26#elif defined(CONFIG_S390) 24#elif defined(CONFIG_S390)
27# define INPUT_COMPAT_TEST test_thread_flag(TIF_31BIT) 25# define INPUT_COMPAT_TEST test_thread_flag(TIF_31BIT)
28#elif defined(CONFIG_MIPS) 26#elif defined(CONFIG_MIPS)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 86cb2d2196f..41168d5f8c1 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -87,12 +87,14 @@ static int input_defuzz_abs_event(int value, int old_val, int fuzz)
87} 87}
88 88
89/* 89/*
90 * Pass event through all open handles. This function is called with 90 * Pass event first through all filters and then, if event has not been
91 * filtered out, through all open handles. This function is called with
91 * dev->event_lock held and interrupts disabled. 92 * dev->event_lock held and interrupts disabled.
92 */ 93 */
93static void input_pass_event(struct input_dev *dev, 94static void input_pass_event(struct input_dev *dev,
94 unsigned int type, unsigned int code, int value) 95 unsigned int type, unsigned int code, int value)
95{ 96{
97 struct input_handler *handler;
96 struct input_handle *handle; 98 struct input_handle *handle;
97 99
98 rcu_read_lock(); 100 rcu_read_lock();
@@ -100,11 +102,25 @@ static void input_pass_event(struct input_dev *dev,
100 handle = rcu_dereference(dev->grab); 102 handle = rcu_dereference(dev->grab);
101 if (handle) 103 if (handle)
102 handle->handler->event(handle, type, code, value); 104 handle->handler->event(handle, type, code, value);
103 else 105 else {
104 list_for_each_entry_rcu(handle, &dev->h_list, d_node) 106 bool filtered = false;
105 if (handle->open) 107
106 handle->handler->event(handle, 108 list_for_each_entry_rcu(handle, &dev->h_list, d_node) {
107 type, code, value); 109 if (!handle->open)
110 continue;
111
112 handler = handle->handler;
113 if (!handler->filter) {
114 if (filtered)
115 break;
116
117 handler->event(handle, type, code, value);
118
119 } else if (handler->filter(handle, type, code, value))
120 filtered = true;
121 }
122 }
123
108 rcu_read_unlock(); 124 rcu_read_unlock();
109} 125}
110 126
@@ -615,12 +631,12 @@ static int input_default_setkeycode(struct input_dev *dev,
615 } 631 }
616 } 632 }
617 633
618 clear_bit(old_keycode, dev->keybit); 634 __clear_bit(old_keycode, dev->keybit);
619 set_bit(keycode, dev->keybit); 635 __set_bit(keycode, dev->keybit);
620 636
621 for (i = 0; i < dev->keycodemax; i++) { 637 for (i = 0; i < dev->keycodemax; i++) {
622 if (input_fetch_keycode(dev, i) == old_keycode) { 638 if (input_fetch_keycode(dev, i) == old_keycode) {
623 set_bit(old_keycode, dev->keybit); 639 __set_bit(old_keycode, dev->keybit);
624 break; /* Setting the bit twice is useless, so break */ 640 break; /* Setting the bit twice is useless, so break */
625 } 641 }
626 } 642 }
@@ -678,6 +694,9 @@ int input_set_keycode(struct input_dev *dev, int scancode, int keycode)
678 if (retval) 694 if (retval)
679 goto out; 695 goto out;
680 696
697 /* Make sure KEY_RESERVED did not get enabled. */
698 __clear_bit(KEY_RESERVED, dev->keybit);
699
681 /* 700 /*
682 * Simulate keyup event if keycode is not present 701 * Simulate keyup event if keycode is not present
683 * in the keymap anymore 702 * in the keymap anymore
@@ -705,12 +724,13 @@ EXPORT_SYMBOL(input_set_keycode);
705 if (i != BITS_TO_LONGS(max)) \ 724 if (i != BITS_TO_LONGS(max)) \
706 continue; 725 continue;
707 726
708static const struct input_device_id *input_match_device(const struct input_device_id *id, 727static const struct input_device_id *input_match_device(struct input_handler *handler,
709 struct input_dev *dev) 728 struct input_dev *dev)
710{ 729{
730 const struct input_device_id *id;
711 int i; 731 int i;
712 732
713 for (; id->flags || id->driver_info; id++) { 733 for (id = handler->id_table; id->flags || id->driver_info; id++) {
714 734
715 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) 735 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
716 if (id->bustype != dev->id.bustype) 736 if (id->bustype != dev->id.bustype)
@@ -738,7 +758,8 @@ static const struct input_device_id *input_match_device(const struct input_devic
738 MATCH_BIT(ffbit, FF_MAX); 758 MATCH_BIT(ffbit, FF_MAX);
739 MATCH_BIT(swbit, SW_MAX); 759 MATCH_BIT(swbit, SW_MAX);
740 760
741 return id; 761 if (!handler->match || handler->match(handler, dev))
762 return id;
742 } 763 }
743 764
744 return NULL; 765 return NULL;
@@ -749,10 +770,7 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han
749 const struct input_device_id *id; 770 const struct input_device_id *id;
750 int error; 771 int error;
751 772
752 if (handler->blacklist && input_match_device(handler->blacklist, dev)) 773 id = input_match_device(handler, dev);
753 return -ENODEV;
754
755 id = input_match_device(handler->id_table, dev);
756 if (!id) 774 if (!id)
757 return -ENODEV; 775 return -ENODEV;
758 776
@@ -988,6 +1006,8 @@ static int input_handlers_seq_show(struct seq_file *seq, void *v)
988 union input_seq_state *state = (union input_seq_state *)&seq->private; 1006 union input_seq_state *state = (union input_seq_state *)&seq->private;
989 1007
990 seq_printf(seq, "N: Number=%u Name=%s", state->pos, handler->name); 1008 seq_printf(seq, "N: Number=%u Name=%s", state->pos, handler->name);
1009 if (handler->filter)
1010 seq_puts(seq, " (filter)");
991 if (handler->fops) 1011 if (handler->fops)
992 seq_printf(seq, " Minor=%d", handler->minor); 1012 seq_printf(seq, " Minor=%d", handler->minor);
993 seq_putc(seq, '\n'); 1013 seq_putc(seq, '\n');
@@ -1551,6 +1571,25 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
1551} 1571}
1552EXPORT_SYMBOL(input_set_capability); 1572EXPORT_SYMBOL(input_set_capability);
1553 1573
1574#define INPUT_CLEANSE_BITMASK(dev, type, bits) \
1575 do { \
1576 if (!test_bit(EV_##type, dev->evbit)) \
1577 memset(dev->bits##bit, 0, \
1578 sizeof(dev->bits##bit)); \
1579 } while (0)
1580
1581static void input_cleanse_bitmasks(struct input_dev *dev)
1582{
1583 INPUT_CLEANSE_BITMASK(dev, KEY, key);
1584 INPUT_CLEANSE_BITMASK(dev, REL, rel);
1585 INPUT_CLEANSE_BITMASK(dev, ABS, abs);
1586 INPUT_CLEANSE_BITMASK(dev, MSC, msc);
1587 INPUT_CLEANSE_BITMASK(dev, LED, led);
1588 INPUT_CLEANSE_BITMASK(dev, SND, snd);
1589 INPUT_CLEANSE_BITMASK(dev, FF, ff);
1590 INPUT_CLEANSE_BITMASK(dev, SW, sw);
1591}
1592
1554/** 1593/**
1555 * input_register_device - register device with input core 1594 * input_register_device - register device with input core
1556 * @dev: device to be registered 1595 * @dev: device to be registered
@@ -1570,13 +1609,19 @@ int input_register_device(struct input_dev *dev)
1570 const char *path; 1609 const char *path;
1571 int error; 1610 int error;
1572 1611
1612 /* Every input device generates EV_SYN/SYN_REPORT events. */
1573 __set_bit(EV_SYN, dev->evbit); 1613 __set_bit(EV_SYN, dev->evbit);
1574 1614
1615 /* KEY_RESERVED is not supposed to be transmitted to userspace. */
1616 __clear_bit(KEY_RESERVED, dev->keybit);
1617
1618 /* Make sure that bitmasks not mentioned in dev->evbit are clean. */
1619 input_cleanse_bitmasks(dev);
1620
1575 /* 1621 /*
1576 * If delay and period are pre-set by the driver, then autorepeating 1622 * If delay and period are pre-set by the driver, then autorepeating
1577 * is handled by the driver itself and we don't do it in input.c. 1623 * is handled by the driver itself and we don't do it in input.c.
1578 */ 1624 */
1579
1580 init_timer(&dev->timer); 1625 init_timer(&dev->timer);
1581 if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) { 1626 if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) {
1582 dev->timer.data = (long) dev; 1627 dev->timer.data = (long) dev;
@@ -1776,7 +1821,16 @@ int input_register_handle(struct input_handle *handle)
1776 error = mutex_lock_interruptible(&dev->mutex); 1821 error = mutex_lock_interruptible(&dev->mutex);
1777 if (error) 1822 if (error)
1778 return error; 1823 return error;
1779 list_add_tail_rcu(&handle->d_node, &dev->h_list); 1824
1825 /*
1826 * Filters go to the head of the list, normal handlers
1827 * to the tail.
1828 */
1829 if (handler->filter)
1830 list_add_rcu(&handle->d_node, &dev->h_list);
1831 else
1832 list_add_tail_rcu(&handle->d_node, &dev->h_list);
1833
1780 mutex_unlock(&dev->mutex); 1834 mutex_unlock(&dev->mutex);
1781 1835
1782 /* 1836 /*
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index b1bd6dd3228..c52bec4d053 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -286,6 +286,8 @@ static int joydev_open(struct inode *inode, struct file *file)
286 goto err_free_client; 286 goto err_free_client;
287 287
288 file->private_data = client; 288 file->private_data = client;
289 nonseekable_open(inode, file);
290
289 return 0; 291 return 0;
290 292
291 err_free_client: 293 err_free_client:
@@ -775,6 +777,20 @@ static void joydev_cleanup(struct joydev *joydev)
775 input_close_device(handle); 777 input_close_device(handle);
776} 778}
777 779
780
781static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
782{
783 /* Avoid touchpads and touchscreens */
784 if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit))
785 return false;
786
787 /* Avoid tablets, digitisers and similar devices */
788 if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit))
789 return false;
790
791 return true;
792}
793
778static int joydev_connect(struct input_handler *handler, struct input_dev *dev, 794static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
779 const struct input_device_id *id) 795 const struct input_device_id *id)
780{ 796{
@@ -894,22 +910,6 @@ static void joydev_disconnect(struct input_handle *handle)
894 put_device(&joydev->dev); 910 put_device(&joydev->dev);
895} 911}
896 912
897static const struct input_device_id joydev_blacklist[] = {
898 {
899 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
900 INPUT_DEVICE_ID_MATCH_KEYBIT,
901 .evbit = { BIT_MASK(EV_KEY) },
902 .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
903 }, /* Avoid itouchpads and touchscreens */
904 {
905 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
906 INPUT_DEVICE_ID_MATCH_KEYBIT,
907 .evbit = { BIT_MASK(EV_KEY) },
908 .keybit = { [BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_DIGI) },
909 }, /* Avoid tablets, digitisers and similar devices */
910 { } /* Terminating entry */
911};
912
913static const struct input_device_id joydev_ids[] = { 913static const struct input_device_id joydev_ids[] = {
914 { 914 {
915 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | 915 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
@@ -936,13 +936,13 @@ MODULE_DEVICE_TABLE(input, joydev_ids);
936 936
937static struct input_handler joydev_handler = { 937static struct input_handler joydev_handler = {
938 .event = joydev_event, 938 .event = joydev_event,
939 .match = joydev_match,
939 .connect = joydev_connect, 940 .connect = joydev_connect,
940 .disconnect = joydev_disconnect, 941 .disconnect = joydev_disconnect,
941 .fops = &joydev_fops, 942 .fops = &joydev_fops,
942 .minor = JOYDEV_MINOR_BASE, 943 .minor = JOYDEV_MINOR_BASE,
943 .name = "joydev", 944 .name = "joydev",
944 .id_table = joydev_ids, 945 .id_table = joydev_ids,
945 .blacklist = joydev_blacklist,
946}; 946};
947 947
948static int __init joydev_init(void) 948static int __init joydev_init(void)
diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
index b11419590cf..5b596165b57 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -221,6 +221,7 @@ config JOYSTICK_DB9
221config JOYSTICK_GAMECON 221config JOYSTICK_GAMECON
222 tristate "Multisystem, NES, SNES, N64, PSX joysticks and gamepads" 222 tristate "Multisystem, NES, SNES, N64, PSX joysticks and gamepads"
223 depends on PARPORT 223 depends on PARPORT
224 select INPUT_FF_MEMLESS
224 ---help--- 225 ---help---
225 Say Y here if you have a Nintendo Entertainment System gamepad, 226 Say Y here if you have a Nintendo Entertainment System gamepad,
226 Super Nintendo Entertainment System gamepad, Nintendo 64 gamepad, 227 Super Nintendo Entertainment System gamepad, Nintendo 64 gamepad,
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 07a32aff5a3..ae998d99a5a 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -30,6 +30,8 @@
30 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 30 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
31 */ 31 */
32 32
33#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34
33#include <linux/kernel.h> 35#include <linux/kernel.h>
34#include <linux/delay.h> 36#include <linux/delay.h>
35#include <linux/module.h> 37#include <linux/module.h>
@@ -61,48 +63,73 @@ MODULE_PARM_DESC(map3, "Describes third set of devices");
61 63
62/* see also gs_psx_delay parameter in PSX support section */ 64/* see also gs_psx_delay parameter in PSX support section */
63 65
64#define GC_SNES 1 66enum gc_type {
65#define GC_NES 2 67 GC_NONE = 0,
66#define GC_NES4 3 68 GC_SNES,
67#define GC_MULTI 4 69 GC_NES,
68#define GC_MULTI2 5 70 GC_NES4,
69#define GC_N64 6 71 GC_MULTI,
70#define GC_PSX 7 72 GC_MULTI2,
71#define GC_DDR 8 73 GC_N64,
72#define GC_SNESMOUSE 9 74 GC_PSX,
73 75 GC_DDR,
74#define GC_MAX 9 76 GC_SNESMOUSE,
77 GC_MAX
78};
75 79
76#define GC_REFRESH_TIME HZ/100 80#define GC_REFRESH_TIME HZ/100
77 81
82struct gc_pad {
83 struct input_dev *dev;
84 enum gc_type type;
85 char phys[32];
86};
87
78struct gc { 88struct gc {
79 struct pardevice *pd; 89 struct pardevice *pd;
90 struct gc_pad pads[GC_MAX_DEVICES];
80 struct input_dev *dev[GC_MAX_DEVICES]; 91 struct input_dev *dev[GC_MAX_DEVICES];
81 struct timer_list timer; 92 struct timer_list timer;
82 unsigned char pads[GC_MAX + 1]; 93 int pad_count[GC_MAX];
83 int used; 94 int used;
84 struct mutex mutex; 95 struct mutex mutex;
85 char phys[GC_MAX_DEVICES][32]; 96};
97
98struct gc_subdev {
99 unsigned int idx;
86}; 100};
87 101
88static struct gc *gc_base[3]; 102static struct gc *gc_base[3];
89 103
90static int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 }; 104static const int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 };
105
106static const char *gc_names[] = {
107 NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick",
108 "Multisystem 2-button joystick", "N64 controller", "PSX controller",
109 "PSX DDR controller", "SNES mouse"
110};
91 111
92static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick",
93 "Multisystem 2-button joystick", "N64 controller", "PSX controller",
94 "PSX DDR controller", "SNES mouse" };
95/* 112/*
96 * N64 support. 113 * N64 support.
97 */ 114 */
98 115
99static unsigned char gc_n64_bytes[] = { 0, 1, 13, 15, 14, 12, 10, 11, 2, 3 }; 116static const unsigned char gc_n64_bytes[] = { 0, 1, 13, 15, 14, 12, 10, 11, 2, 3 };
100static short gc_n64_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TRIGGER, BTN_START }; 117static const short gc_n64_btn[] = {
118 BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z,
119 BTN_TL, BTN_TR, BTN_TRIGGER, BTN_START
120};
101 121
102#define GC_N64_LENGTH 32 /* N64 bit length, not including stop bit */ 122#define GC_N64_LENGTH 32 /* N64 bit length, not including stop bit */
103#define GC_N64_REQUEST_LENGTH 37 /* transmit request sequence is 9 bits long */ 123#define GC_N64_STOP_LENGTH 5 /* Length of encoded stop bit */
124#define GC_N64_CMD_00 0x11111111UL
125#define GC_N64_CMD_01 0xd1111111UL
126#define GC_N64_CMD_03 0xdd111111UL
127#define GC_N64_CMD_1b 0xdd1dd111UL
128#define GC_N64_CMD_c0 0x111111ddUL
129#define GC_N64_CMD_80 0x1111111dUL
130#define GC_N64_STOP_BIT 0x1d /* Encoded stop bit */
131#define GC_N64_REQUEST_DATA GC_N64_CMD_01 /* the request data command */
104#define GC_N64_DELAY 133 /* delay between transmit request, and response ready (us) */ 132#define GC_N64_DELAY 133 /* delay between transmit request, and response ready (us) */
105#define GC_N64_REQUEST 0x1dd1111111ULL /* the request data command (encoded for 000000011) */
106#define GC_N64_DWS 3 /* delay between write segments (required for sound playback because of ISA DMA) */ 133#define GC_N64_DWS 3 /* delay between write segments (required for sound playback because of ISA DMA) */
107 /* GC_N64_DWS > 24 is known to fail */ 134 /* GC_N64_DWS > 24 is known to fail */
108#define GC_N64_POWER_W 0xe2 /* power during write (transmit request) */ 135#define GC_N64_POWER_W 0xe2 /* power during write (transmit request) */
@@ -114,8 +141,40 @@ static short gc_n64_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL,
114#define GC_N64_CLOCK 0x02 /* clock bits for read */ 141#define GC_N64_CLOCK 0x02 /* clock bits for read */
115 142
116/* 143/*
144 * Used for rumble code.
145 */
146
147/* Send encoded command */
148static void gc_n64_send_command(struct gc *gc, unsigned long cmd,
149 unsigned char target)
150{
151 struct parport *port = gc->pd->port;
152 int i;
153
154 for (i = 0; i < GC_N64_LENGTH; i++) {
155 unsigned char data = (cmd >> i) & 1 ? target : 0;
156 parport_write_data(port, GC_N64_POWER_W | data);
157 udelay(GC_N64_DWS);
158 }
159}
160
161/* Send stop bit */
162static void gc_n64_send_stop_bit(struct gc *gc, unsigned char target)
163{
164 struct parport *port = gc->pd->port;
165 int i;
166
167 for (i = 0; i < GC_N64_STOP_LENGTH; i++) {
168 unsigned char data = (GC_N64_STOP_BIT >> i) & 1 ? target : 0;
169 parport_write_data(port, GC_N64_POWER_W | data);
170 udelay(GC_N64_DWS);
171 }
172}
173
174/*
117 * gc_n64_read_packet() reads an N64 packet. 175 * gc_n64_read_packet() reads an N64 packet.
118 * Each pad uses one bit per byte. So all pads connected to this port are read in parallel. 176 * Each pad uses one bit per byte. So all pads connected to this port
177 * are read in parallel.
119 */ 178 */
120 179
121static void gc_n64_read_packet(struct gc *gc, unsigned char *data) 180static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
@@ -128,14 +187,13 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
128 */ 187 */
129 188
130 local_irq_save(flags); 189 local_irq_save(flags);
131 for (i = 0; i < GC_N64_REQUEST_LENGTH; i++) { 190 gc_n64_send_command(gc, GC_N64_REQUEST_DATA, GC_N64_OUT);
132 parport_write_data(gc->pd->port, GC_N64_POWER_W | ((GC_N64_REQUEST >> i) & 1 ? GC_N64_OUT : 0)); 191 gc_n64_send_stop_bit(gc, GC_N64_OUT);
133 udelay(GC_N64_DWS);
134 }
135 local_irq_restore(flags); 192 local_irq_restore(flags);
136 193
137/* 194/*
138 * Wait for the pad response to be loaded into the 33-bit register of the adapter 195 * Wait for the pad response to be loaded into the 33-bit register
196 * of the adapter.
139 */ 197 */
140 198
141 udelay(GC_N64_DELAY); 199 udelay(GC_N64_DELAY);
@@ -146,13 +204,15 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
146 204
147 for (i = 0; i < GC_N64_LENGTH; i++) { 205 for (i = 0; i < GC_N64_LENGTH; i++) {
148 parport_write_data(gc->pd->port, GC_N64_POWER_R); 206 parport_write_data(gc->pd->port, GC_N64_POWER_R);
207 udelay(2);
149 data[i] = parport_read_status(gc->pd->port); 208 data[i] = parport_read_status(gc->pd->port);
150 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK); 209 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK);
151 } 210 }
152 211
153/* 212/*
154 * We must wait 200 ms here for the controller to reinitialize before the next read request. 213 * We must wait 200 ms here for the controller to reinitialize before
155 * No worries as long as gc_read is polled less frequently than this. 214 * the next read request. No worries as long as gc_read is polled less
215 * frequently than this.
156 */ 216 */
157 217
158} 218}
@@ -160,45 +220,112 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
160static void gc_n64_process_packet(struct gc *gc) 220static void gc_n64_process_packet(struct gc *gc)
161{ 221{
162 unsigned char data[GC_N64_LENGTH]; 222 unsigned char data[GC_N64_LENGTH];
163 signed char axes[2];
164 struct input_dev *dev; 223 struct input_dev *dev;
165 int i, j, s; 224 int i, j, s;
225 signed char x, y;
166 226
167 gc_n64_read_packet(gc, data); 227 gc_n64_read_packet(gc, data);
168 228
169 for (i = 0; i < GC_MAX_DEVICES; i++) { 229 for (i = 0; i < GC_MAX_DEVICES; i++) {
170 230
171 dev = gc->dev[i]; 231 if (gc->pads[i].type != GC_N64)
172 if (!dev)
173 continue; 232 continue;
174 233
234 dev = gc->pads[i].dev;
175 s = gc_status_bit[i]; 235 s = gc_status_bit[i];
176 236
177 if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { 237 if (s & ~(data[8] | data[9])) {
178 238
179 axes[0] = axes[1] = 0; 239 x = y = 0;
180 240
181 for (j = 0; j < 8; j++) { 241 for (j = 0; j < 8; j++) {
182 if (data[23 - j] & s) 242 if (data[23 - j] & s)
183 axes[0] |= 1 << j; 243 x |= 1 << j;
184 if (data[31 - j] & s) 244 if (data[31 - j] & s)
185 axes[1] |= 1 << j; 245 y |= 1 << j;
186 } 246 }
187 247
188 input_report_abs(dev, ABS_X, axes[0]); 248 input_report_abs(dev, ABS_X, x);
189 input_report_abs(dev, ABS_Y, -axes[1]); 249 input_report_abs(dev, ABS_Y, -y);
190 250
191 input_report_abs(dev, ABS_HAT0X, !(s & data[6]) - !(s & data[7])); 251 input_report_abs(dev, ABS_HAT0X,
192 input_report_abs(dev, ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); 252 !(s & data[6]) - !(s & data[7]));
253 input_report_abs(dev, ABS_HAT0Y,
254 !(s & data[4]) - !(s & data[5]));
193 255
194 for (j = 0; j < 10; j++) 256 for (j = 0; j < 10; j++)
195 input_report_key(dev, gc_n64_btn[j], s & data[gc_n64_bytes[j]]); 257 input_report_key(dev, gc_n64_btn[j],
258 s & data[gc_n64_bytes[j]]);
196 259
197 input_sync(dev); 260 input_sync(dev);
198 } 261 }
199 } 262 }
200} 263}
201 264
265static int gc_n64_play_effect(struct input_dev *dev, void *data,
266 struct ff_effect *effect)
267{
268 int i;
269 unsigned long flags;
270 struct gc *gc = input_get_drvdata(dev);
271 struct gc_subdev *sdev = data;
272 unsigned char target = 1 << sdev->idx; /* select desired pin */
273
274 if (effect->type == FF_RUMBLE) {
275 struct ff_rumble_effect *rumble = &effect->u.rumble;
276 unsigned int cmd =
277 rumble->strong_magnitude || rumble->weak_magnitude ?
278 GC_N64_CMD_01 : GC_N64_CMD_00;
279
280 local_irq_save(flags);
281
282 /* Init Rumble - 0x03, 0x80, 0x01, (34)0x80 */
283 gc_n64_send_command(gc, GC_N64_CMD_03, target);
284 gc_n64_send_command(gc, GC_N64_CMD_80, target);
285 gc_n64_send_command(gc, GC_N64_CMD_01, target);
286 for (i = 0; i < 32; i++)
287 gc_n64_send_command(gc, GC_N64_CMD_80, target);
288 gc_n64_send_stop_bit(gc, target);
289
290 udelay(GC_N64_DELAY);
291
292 /* Now start or stop it - 0x03, 0xc0, 0zx1b, (32)0x01/0x00 */
293 gc_n64_send_command(gc, GC_N64_CMD_03, target);
294 gc_n64_send_command(gc, GC_N64_CMD_c0, target);
295 gc_n64_send_command(gc, GC_N64_CMD_1b, target);
296 for (i = 0; i < 32; i++)
297 gc_n64_send_command(gc, cmd, target);
298 gc_n64_send_stop_bit(gc, target);
299
300 local_irq_restore(flags);
301
302 }
303
304 return 0;
305}
306
307static int __init gc_n64_init_ff(struct input_dev *dev, int i)
308{
309 struct gc_subdev *sdev;
310 int err;
311
312 sdev = kmalloc(sizeof(*sdev), GFP_KERNEL);
313 if (!sdev)
314 return -ENOMEM;
315
316 sdev->idx = i;
317
318 input_set_capability(dev, EV_FF, FF_RUMBLE);
319
320 err = input_ff_create_memless(dev, sdev, gc_n64_play_effect);
321 if (err) {
322 kfree(sdev);
323 return err;
324 }
325
326 return 0;
327}
328
202/* 329/*
203 * NES/SNES support. 330 * NES/SNES support.
204 */ 331 */
@@ -214,9 +341,11 @@ static void gc_n64_process_packet(struct gc *gc)
214#define GC_NES_CLOCK 0x01 341#define GC_NES_CLOCK 0x01
215#define GC_NES_LATCH 0x02 342#define GC_NES_LATCH 0x02
216 343
217static unsigned char gc_nes_bytes[] = { 0, 1, 2, 3 }; 344static const unsigned char gc_nes_bytes[] = { 0, 1, 2, 3 };
218static unsigned char gc_snes_bytes[] = { 8, 0, 2, 3, 9, 1, 10, 11 }; 345static const unsigned char gc_snes_bytes[] = { 8, 0, 2, 3, 9, 1, 10, 11 };
219static short gc_snes_btn[] = { BTN_A, BTN_B, BTN_SELECT, BTN_START, BTN_X, BTN_Y, BTN_TL, BTN_TR }; 346static const short gc_snes_btn[] = {
347 BTN_A, BTN_B, BTN_SELECT, BTN_START, BTN_X, BTN_Y, BTN_TL, BTN_TR
348};
220 349
221/* 350/*
222 * gc_nes_read_packet() reads a NES/SNES packet. 351 * gc_nes_read_packet() reads a NES/SNES packet.
@@ -244,40 +373,51 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data)
244static void gc_nes_process_packet(struct gc *gc) 373static void gc_nes_process_packet(struct gc *gc)
245{ 374{
246 unsigned char data[GC_SNESMOUSE_LENGTH]; 375 unsigned char data[GC_SNESMOUSE_LENGTH];
376 struct gc_pad *pad;
247 struct input_dev *dev; 377 struct input_dev *dev;
248 int i, j, s, len; 378 int i, j, s, len;
249 char x_rel, y_rel; 379 char x_rel, y_rel;
250 380
251 len = gc->pads[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : 381 len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH :
252 (gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); 382 (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH);
253 383
254 gc_nes_read_packet(gc, len, data); 384 gc_nes_read_packet(gc, len, data);
255 385
256 for (i = 0; i < GC_MAX_DEVICES; i++) { 386 for (i = 0; i < GC_MAX_DEVICES; i++) {
257 387
388 pad = &gc->pads[i];
258 dev = gc->dev[i]; 389 dev = gc->dev[i];
259 if (!dev)
260 continue;
261
262 s = gc_status_bit[i]; 390 s = gc_status_bit[i];
263 391
264 if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { 392 switch (pad->type) {
393
394 case GC_NES:
395
265 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7])); 396 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7]));
266 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5])); 397 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5]));
267 }
268 398
269 if (s & gc->pads[GC_NES])
270 for (j = 0; j < 4; j++) 399 for (j = 0; j < 4; j++)
271 input_report_key(dev, gc_snes_btn[j], s & data[gc_nes_bytes[j]]); 400 input_report_key(dev, gc_snes_btn[j],
401 s & data[gc_nes_bytes[j]]);
402 input_sync(dev);
403 break;
404
405 case GC_SNES:
406
407 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7]));
408 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5]));
272 409
273 if (s & gc->pads[GC_SNES])
274 for (j = 0; j < 8; j++) 410 for (j = 0; j < 8; j++)
275 input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); 411 input_report_key(dev, gc_snes_btn[j],
412 s & data[gc_snes_bytes[j]]);
413 input_sync(dev);
414 break;
276 415
277 if (s & gc->pads[GC_SNESMOUSE]) { 416 case GC_SNESMOUSE:
278 /* 417 /*
279 * The 4 unused bits from SNES controllers appear to be ID bits 418 * The 4 unused bits from SNES controllers appear
280 * so use them to make sure iwe are dealing with a mouse. 419 * to be ID bits so use them to make sure we are
420 * dealing with a mouse.
281 * gamepad is connected. This is important since 421 * gamepad is connected. This is important since
282 * my SNES gamepad sends 1's for bits 16-31, which 422 * my SNES gamepad sends 1's for bits 16-31, which
283 * cause the mouse pointer to quickly move to the 423 * cause the mouse pointer to quickly move to the
@@ -310,9 +450,14 @@ static void gc_nes_process_packet(struct gc *gc)
310 y_rel = -y_rel; 450 y_rel = -y_rel;
311 input_report_rel(dev, REL_Y, y_rel); 451 input_report_rel(dev, REL_Y, y_rel);
312 } 452 }
453
454 input_sync(dev);
313 } 455 }
456 break;
457
458 default:
459 break;
314 } 460 }
315 input_sync(dev);
316 } 461 }
317} 462}
318 463
@@ -340,29 +485,35 @@ static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data)
340static void gc_multi_process_packet(struct gc *gc) 485static void gc_multi_process_packet(struct gc *gc)
341{ 486{
342 unsigned char data[GC_MULTI2_LENGTH]; 487 unsigned char data[GC_MULTI2_LENGTH];
488 int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH;
489 struct gc_pad *pad;
343 struct input_dev *dev; 490 struct input_dev *dev;
344 int i, s; 491 int i, s;
345 492
346 gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data); 493 gc_multi_read_packet(gc, data_len, data);
347 494
348 for (i = 0; i < GC_MAX_DEVICES; i++) { 495 for (i = 0; i < GC_MAX_DEVICES; i++) {
349 496 pad = &gc->pads[i];
350 dev = gc->dev[i]; 497 dev = pad->dev;
351 if (!dev)
352 continue;
353
354 s = gc_status_bit[i]; 498 s = gc_status_bit[i];
355 499
356 if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { 500 switch (pad->type) {
357 input_report_abs(dev, ABS_X, !(s & data[2]) - !(s & data[3])); 501 case GC_MULTI2:
358 input_report_abs(dev, ABS_Y, !(s & data[0]) - !(s & data[1]));
359 input_report_key(dev, BTN_TRIGGER, s & data[4]);
360 }
361
362 if (s & gc->pads[GC_MULTI2])
363 input_report_key(dev, BTN_THUMB, s & data[5]); 502 input_report_key(dev, BTN_THUMB, s & data[5]);
503 /* fall through */
364 504
365 input_sync(dev); 505 case GC_MULTI:
506 input_report_abs(dev, ABS_X,
507 !(s & data[2]) - !(s & data[3]));
508 input_report_abs(dev, ABS_Y,
509 !(s & data[0]) - !(s & data[1]));
510 input_report_key(dev, BTN_TRIGGER, s & data[4]);
511 input_sync(dev);
512 break;
513
514 default:
515 break;
516 }
366 } 517 }
367} 518}
368 519
@@ -398,30 +549,41 @@ static int gc_psx_delay = GC_PSX_DELAY;
398module_param_named(psx_delay, gc_psx_delay, uint, 0); 549module_param_named(psx_delay, gc_psx_delay, uint, 0);
399MODULE_PARM_DESC(psx_delay, "Delay when accessing Sony PSX controller (usecs)"); 550MODULE_PARM_DESC(psx_delay, "Delay when accessing Sony PSX controller (usecs)");
400 551
401static short gc_psx_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y }; 552static const short gc_psx_abs[] = {
402static short gc_psx_btn[] = { BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_A, BTN_B, BTN_X, BTN_Y, 553 ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y
403 BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR }; 554};
404static short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 }; 555static const short gc_psx_btn[] = {
556 BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_A, BTN_B, BTN_X, BTN_Y,
557 BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR
558};
559static const short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 };
405 560
406/* 561/*
407 * gc_psx_command() writes 8bit command and reads 8bit data from 562 * gc_psx_command() writes 8bit command and reads 8bit data from
408 * the psx pad. 563 * the psx pad.
409 */ 564 */
410 565
411static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVICES]) 566static void gc_psx_command(struct gc *gc, int b, unsigned char *data)
412{ 567{
568 struct parport *port = gc->pd->port;
413 int i, j, cmd, read; 569 int i, j, cmd, read;
414 570
415 for (i = 0; i < GC_MAX_DEVICES; i++) 571 memset(data, 0, GC_MAX_DEVICES);
416 data[i] = 0;
417 572
418 for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) { 573 for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) {
419 cmd = (b & 1) ? GC_PSX_COMMAND : 0; 574 cmd = (b & 1) ? GC_PSX_COMMAND : 0;
420 parport_write_data(gc->pd->port, cmd | GC_PSX_POWER); 575 parport_write_data(port, cmd | GC_PSX_POWER);
421 udelay(gc_psx_delay); 576 udelay(gc_psx_delay);
422 read = parport_read_status(gc->pd->port) ^ 0x80; 577
423 for (j = 0; j < GC_MAX_DEVICES; j++) 578 read = parport_read_status(port) ^ 0x80;
424 data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0; 579
580 for (j = 0; j < GC_MAX_DEVICES; j++) {
581 struct gc_pad *pad = &gc->pads[i];
582
583 if (pad->type == GC_PSX || pad->type == GC_DDR)
584 data[j] |= (read & gc_status_bit[j]) ? (1 << i) : 0;
585 }
586
425 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); 587 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER);
426 udelay(gc_psx_delay); 588 udelay(gc_psx_delay);
427 } 589 }
@@ -432,31 +594,40 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVIC
432 * device identifier code. 594 * device identifier code.
433 */ 595 */
434 596
435static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES], 597static void gc_psx_read_packet(struct gc *gc,
598 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES],
436 unsigned char id[GC_MAX_DEVICES]) 599 unsigned char id[GC_MAX_DEVICES])
437{ 600{
438 int i, j, max_len = 0; 601 int i, j, max_len = 0;
439 unsigned long flags; 602 unsigned long flags;
440 unsigned char data2[GC_MAX_DEVICES]; 603 unsigned char data2[GC_MAX_DEVICES];
441 604
442 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */ 605 /* Select pad */
606 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER);
443 udelay(gc_psx_delay); 607 udelay(gc_psx_delay);
444 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); /* Deselect, begin command */ 608 /* Deselect, begin command */
609 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER);
445 udelay(gc_psx_delay); 610 udelay(gc_psx_delay);
446 611
447 local_irq_save(flags); 612 local_irq_save(flags);
448 613
449 gc_psx_command(gc, 0x01, data2); /* Access pad */ 614 gc_psx_command(gc, 0x01, data2); /* Access pad */
450 gc_psx_command(gc, 0x42, id); /* Get device ids */ 615 gc_psx_command(gc, 0x42, id); /* Get device ids */
451 gc_psx_command(gc, 0, data2); /* Dump status */ 616 gc_psx_command(gc, 0, data2); /* Dump status */
617
618 /* Find the longest pad */
619 for (i = 0; i < GC_MAX_DEVICES; i++) {
620 struct gc_pad *pad = &gc->pads[i];
452 621
453 for (i =0; i < GC_MAX_DEVICES; i++) /* Find the longest pad */ 622 if ((pad->type == GC_PSX || pad->type == GC_DDR) &&
454 if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) 623 GC_PSX_LEN(id[i]) > max_len &&
455 && (GC_PSX_LEN(id[i]) > max_len) 624 GC_PSX_LEN(id[i]) <= GC_PSX_BYTES) {
456 && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES))
457 max_len = GC_PSX_LEN(id[i]); 625 max_len = GC_PSX_LEN(id[i]);
626 }
627 }
458 628
459 for (i = 0; i < max_len; i++) { /* Read in all the data */ 629 /* Read in all the data */
630 for (i = 0; i < max_len; i++) {
460 gc_psx_command(gc, 0, data2); 631 gc_psx_command(gc, 0, data2);
461 for (j = 0; j < GC_MAX_DEVICES; j++) 632 for (j = 0; j < GC_MAX_DEVICES; j++)
462 data[j][i] = data2[j]; 633 data[j][i] = data2[j];
@@ -466,86 +637,104 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES]
466 637
467 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); 638 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER);
468 639
469 for(i = 0; i < GC_MAX_DEVICES; i++) /* Set id's to the real value */ 640 /* Set id's to the real value */
641 for (i = 0; i < GC_MAX_DEVICES; i++)
470 id[i] = GC_PSX_ID(id[i]); 642 id[i] = GC_PSX_ID(id[i]);
471} 643}
472 644
473static void gc_psx_process_packet(struct gc *gc) 645static void gc_psx_report_one(struct gc_pad *pad, unsigned char psx_type,
646 unsigned char *data)
474{ 647{
475 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES]; 648 struct input_dev *dev = pad->dev;
476 unsigned char id[GC_MAX_DEVICES]; 649 int i;
477 struct input_dev *dev;
478 int i, j;
479 650
480 gc_psx_read_packet(gc, data, id); 651 switch (psx_type) {
481 652
482 for (i = 0; i < GC_MAX_DEVICES; i++) { 653 case GC_PSX_RUMBLE:
483 654
484 dev = gc->dev[i]; 655 input_report_key(dev, BTN_THUMBL, ~data[0] & 0x04);
485 if (!dev) 656 input_report_key(dev, BTN_THUMBR, ~data[0] & 0x02);
486 continue;
487 657
488 switch (id[i]) { 658 case GC_PSX_NEGCON:
659 case GC_PSX_ANALOG:
489 660
490 case GC_PSX_RUMBLE: 661 if (pad->type == GC_DDR) {
662 for (i = 0; i < 4; i++)
663 input_report_key(dev, gc_psx_ddr_btn[i],
664 ~data[0] & (0x10 << i));
665 } else {
666 for (i = 0; i < 4; i++)
667 input_report_abs(dev, gc_psx_abs[i + 2],
668 data[i + 2]);
491 669
492 input_report_key(dev, BTN_THUMBL, ~data[i][0] & 0x04); 670 input_report_abs(dev, ABS_X,
493 input_report_key(dev, BTN_THUMBR, ~data[i][0] & 0x02); 671 !!(data[0] & 0x80) * 128 + !(data[0] & 0x20) * 127);
672 input_report_abs(dev, ABS_Y,
673 !!(data[0] & 0x10) * 128 + !(data[0] & 0x40) * 127);
674 }
494 675
495 case GC_PSX_NEGCON: 676 for (i = 0; i < 8; i++)
496 case GC_PSX_ANALOG: 677 input_report_key(dev, gc_psx_btn[i], ~data[1] & (1 << i));
497 678
498 if (gc->pads[GC_DDR] & gc_status_bit[i]) { 679 input_report_key(dev, BTN_START, ~data[0] & 0x08);
499 for(j = 0; j < 4; j++) 680 input_report_key(dev, BTN_SELECT, ~data[0] & 0x01);
500 input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j));
501 } else {
502 for (j = 0; j < 4; j++)
503 input_report_abs(dev, gc_psx_abs[j + 2], data[i][j + 2]);
504 681
505 input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); 682 input_sync(dev);
506 input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128);
507 }
508 683
509 for (j = 0; j < 8; j++) 684 break;
510 input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j));
511 685
512 input_report_key(dev, BTN_START, ~data[i][0] & 0x08); 686 case GC_PSX_NORMAL:
513 input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01);
514 687
515 input_sync(dev); 688 if (pad->type == GC_DDR) {
689 for (i = 0; i < 4; i++)
690 input_report_key(dev, gc_psx_ddr_btn[i],
691 ~data[0] & (0x10 << i));
692 } else {
693 input_report_abs(dev, ABS_X,
694 !!(data[0] & 0x80) * 128 + !(data[0] & 0x20) * 127);
695 input_report_abs(dev, ABS_Y,
696 !!(data[0] & 0x10) * 128 + !(data[0] & 0x40) * 127);
516 697
517 break; 698 /*
518 699 * For some reason if the extra axes are left unset
519 case GC_PSX_NORMAL: 700 * they drift.
520 if (gc->pads[GC_DDR] & gc_status_bit[i]) { 701 * for (i = 0; i < 4; i++)
521 for(j = 0; j < 4; j++) 702 input_report_abs(dev, gc_psx_abs[i + 2], 128);
522 input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j)); 703 * This needs to be debugged properly,
523 } else { 704 * maybe fuzz processing needs to be done
524 input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); 705 * in input_sync()
525 input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128); 706 * --vojtech
526 707 */
527 /* for some reason if the extra axes are left unset they drift */ 708 }
528 /* for (j = 0; j < 4; j++)
529 input_report_abs(dev, gc_psx_abs[j + 2], 128);
530 * This needs to be debugged properly,
531 * maybe fuzz processing needs to be done in input_sync()
532 * --vojtech
533 */
534 }
535 709
536 for (j = 0; j < 8; j++) 710 for (i = 0; i < 8; i++)
537 input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j)); 711 input_report_key(dev, gc_psx_btn[i], ~data[1] & (1 << i));
538 712
539 input_report_key(dev, BTN_START, ~data[i][0] & 0x08); 713 input_report_key(dev, BTN_START, ~data[0] & 0x08);
540 input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01); 714 input_report_key(dev, BTN_SELECT, ~data[0] & 0x01);
541 715
542 input_sync(dev); 716 input_sync(dev);
543 717
544 break; 718 break;
545 719
546 case 0: /* not a pad, ignore */ 720 default: /* not a pad, ignore */
547 break; 721 break;
548 } 722 }
723}
724
725static void gc_psx_process_packet(struct gc *gc)
726{
727 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES];
728 unsigned char id[GC_MAX_DEVICES];
729 struct gc_pad *pad;
730 int i;
731
732 gc_psx_read_packet(gc, data, id);
733
734 for (i = 0; i < GC_MAX_DEVICES; i++) {
735 pad = &gc->pads[i];
736 if (pad->type == GC_PSX || pad->type == GC_DDR)
737 gc_psx_report_one(pad, id[i], data[i]);
549 } 738 }
550} 739}
551 740
@@ -561,28 +750,31 @@ static void gc_timer(unsigned long private)
561 * N64 pads - must be read first, any read confuses them for 200 us 750 * N64 pads - must be read first, any read confuses them for 200 us
562 */ 751 */
563 752
564 if (gc->pads[GC_N64]) 753 if (gc->pad_count[GC_N64])
565 gc_n64_process_packet(gc); 754 gc_n64_process_packet(gc);
566 755
567/* 756/*
568 * NES and SNES pads or mouse 757 * NES and SNES pads or mouse
569 */ 758 */
570 759
571 if (gc->pads[GC_NES] || gc->pads[GC_SNES] || gc->pads[GC_SNESMOUSE]) 760 if (gc->pad_count[GC_NES] ||
761 gc->pad_count[GC_SNES] ||
762 gc->pad_count[GC_SNESMOUSE]) {
572 gc_nes_process_packet(gc); 763 gc_nes_process_packet(gc);
764 }
573 765
574/* 766/*
575 * Multi and Multi2 joysticks 767 * Multi and Multi2 joysticks
576 */ 768 */
577 769
578 if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) 770 if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2])
579 gc_multi_process_packet(gc); 771 gc_multi_process_packet(gc);
580 772
581/* 773/*
582 * PSX controllers 774 * PSX controllers
583 */ 775 */
584 776
585 if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) 777 if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR])
586 gc_psx_process_packet(gc); 778 gc_psx_process_packet(gc);
587 779
588 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); 780 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
@@ -622,25 +814,29 @@ static void gc_close(struct input_dev *dev)
622 814
623static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) 815static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
624{ 816{
817 struct gc_pad *pad = &gc->pads[idx];
625 struct input_dev *input_dev; 818 struct input_dev *input_dev;
626 int i; 819 int i;
627 820 int err;
628 if (!pad_type)
629 return 0;
630 821
631 if (pad_type < 1 || pad_type > GC_MAX) { 822 if (pad_type < 1 || pad_type > GC_MAX) {
632 printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", pad_type); 823 pr_err("Pad type %d unknown\n", pad_type);
633 return -EINVAL; 824 return -EINVAL;
634 } 825 }
635 826
636 gc->dev[idx] = input_dev = input_allocate_device(); 827 pad->dev = input_dev = input_allocate_device();
637 if (!input_dev) { 828 if (!input_dev) {
638 printk(KERN_ERR "gamecon.c: Not enough memory for input device\n"); 829 pr_err("Not enough memory for input device\n");
639 return -ENOMEM; 830 return -ENOMEM;
640 } 831 }
641 832
833 pad->type = pad_type;
834
835 snprintf(pad->phys, sizeof(pad->phys),
836 "%s/input%d", gc->pd->port->name, idx);
837
642 input_dev->name = gc_names[pad_type]; 838 input_dev->name = gc_names[pad_type];
643 input_dev->phys = gc->phys[idx]; 839 input_dev->phys = pad->phys;
644 input_dev->id.bustype = BUS_PARPORT; 840 input_dev->id.bustype = BUS_PARPORT;
645 input_dev->id.vendor = 0x0001; 841 input_dev->id.vendor = 0x0001;
646 input_dev->id.product = pad_type; 842 input_dev->id.product = pad_type;
@@ -659,61 +855,76 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
659 } else 855 } else
660 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 856 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
661 857
662 gc->pads[0] |= gc_status_bit[idx]; 858 gc->pad_count[pad_type]++;
663 gc->pads[pad_type] |= gc_status_bit[idx];
664 859
665 switch (pad_type) { 860 switch (pad_type) {
666 861
667 case GC_N64: 862 case GC_N64:
668 for (i = 0; i < 10; i++) 863 for (i = 0; i < 10; i++)
669 set_bit(gc_n64_btn[i], input_dev->keybit); 864 __set_bit(gc_n64_btn[i], input_dev->keybit);
670
671 for (i = 0; i < 2; i++) {
672 input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2);
673 input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
674 }
675
676 break;
677
678 case GC_SNESMOUSE:
679 set_bit(BTN_LEFT, input_dev->keybit);
680 set_bit(BTN_RIGHT, input_dev->keybit);
681 set_bit(REL_X, input_dev->relbit);
682 set_bit(REL_Y, input_dev->relbit);
683 break;
684
685 case GC_SNES:
686 for (i = 4; i < 8; i++)
687 set_bit(gc_snes_btn[i], input_dev->keybit);
688 case GC_NES:
689 for (i = 0; i < 4; i++)
690 set_bit(gc_snes_btn[i], input_dev->keybit);
691 break;
692
693 case GC_MULTI2:
694 set_bit(BTN_THUMB, input_dev->keybit);
695 case GC_MULTI:
696 set_bit(BTN_TRIGGER, input_dev->keybit);
697 break;
698
699 case GC_PSX:
700 for (i = 0; i < 6; i++)
701 input_set_abs_params(input_dev, gc_psx_abs[i], 4, 252, 0, 2);
702 for (i = 0; i < 12; i++)
703 set_bit(gc_psx_btn[i], input_dev->keybit);
704 865
705 break; 866 for (i = 0; i < 2; i++) {
867 input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2);
868 input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
869 }
706 870
707 case GC_DDR: 871 err = gc_n64_init_ff(input_dev, idx);
708 for (i = 0; i < 4; i++) 872 if (err) {
709 set_bit(gc_psx_ddr_btn[i], input_dev->keybit); 873 pr_warning("Failed to initiate rumble for N64 device %d\n", idx);
710 for (i = 0; i < 12; i++) 874 goto err_free_dev;
711 set_bit(gc_psx_btn[i], input_dev->keybit); 875 }
712 876
713 break; 877 break;
878
879 case GC_SNESMOUSE:
880 __set_bit(BTN_LEFT, input_dev->keybit);
881 __set_bit(BTN_RIGHT, input_dev->keybit);
882 __set_bit(REL_X, input_dev->relbit);
883 __set_bit(REL_Y, input_dev->relbit);
884 break;
885
886 case GC_SNES:
887 for (i = 4; i < 8; i++)
888 __set_bit(gc_snes_btn[i], input_dev->keybit);
889 case GC_NES:
890 for (i = 0; i < 4; i++)
891 __set_bit(gc_snes_btn[i], input_dev->keybit);
892 break;
893
894 case GC_MULTI2:
895 __set_bit(BTN_THUMB, input_dev->keybit);
896 case GC_MULTI:
897 __set_bit(BTN_TRIGGER, input_dev->keybit);
898 break;
899
900 case GC_PSX:
901 for (i = 0; i < 6; i++)
902 input_set_abs_params(input_dev,
903 gc_psx_abs[i], 4, 252, 0, 2);
904 for (i = 0; i < 12; i++)
905 __set_bit(gc_psx_btn[i], input_dev->keybit);
906
907 break;
908
909 case GC_DDR:
910 for (i = 0; i < 4; i++)
911 __set_bit(gc_psx_ddr_btn[i], input_dev->keybit);
912 for (i = 0; i < 12; i++)
913 __set_bit(gc_psx_btn[i], input_dev->keybit);
914
915 break;
714 } 916 }
715 917
918 err = input_register_device(pad->dev);
919 if (err)
920 goto err_free_dev;
921
716 return 0; 922 return 0;
923
924err_free_dev:
925 input_free_device(pad->dev);
926 pad->dev = NULL;
927 return err;
717} 928}
718 929
719static struct gc __init *gc_probe(int parport, int *pads, int n_pads) 930static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
@@ -722,52 +933,47 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
722 struct parport *pp; 933 struct parport *pp;
723 struct pardevice *pd; 934 struct pardevice *pd;
724 int i; 935 int i;
936 int count = 0;
725 int err; 937 int err;
726 938
727 pp = parport_find_number(parport); 939 pp = parport_find_number(parport);
728 if (!pp) { 940 if (!pp) {
729 printk(KERN_ERR "gamecon.c: no such parport\n"); 941 pr_err("no such parport %d\n", parport);
730 err = -EINVAL; 942 err = -EINVAL;
731 goto err_out; 943 goto err_out;
732 } 944 }
733 945
734 pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 946 pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
735 if (!pd) { 947 if (!pd) {
736 printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n"); 948 pr_err("parport busy already - lp.o loaded?\n");
737 err = -EBUSY; 949 err = -EBUSY;
738 goto err_put_pp; 950 goto err_put_pp;
739 } 951 }
740 952
741 gc = kzalloc(sizeof(struct gc), GFP_KERNEL); 953 gc = kzalloc(sizeof(struct gc), GFP_KERNEL);
742 if (!gc) { 954 if (!gc) {
743 printk(KERN_ERR "gamecon.c: Not enough memory\n"); 955 pr_err("Not enough memory\n");
744 err = -ENOMEM; 956 err = -ENOMEM;
745 goto err_unreg_pardev; 957 goto err_unreg_pardev;
746 } 958 }
747 959
748 mutex_init(&gc->mutex); 960 mutex_init(&gc->mutex);
749 gc->pd = pd; 961 gc->pd = pd;
750 init_timer(&gc->timer); 962 setup_timer(&gc->timer, gc_timer, (long) gc);
751 gc->timer.data = (long) gc;
752 gc->timer.function = gc_timer;
753 963
754 for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) { 964 for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) {
755 if (!pads[i]) 965 if (!pads[i])
756 continue; 966 continue;
757 967
758 snprintf(gc->phys[i], sizeof(gc->phys[i]),
759 "%s/input%d", gc->pd->port->name, i);
760 err = gc_setup_pad(gc, i, pads[i]); 968 err = gc_setup_pad(gc, i, pads[i]);
761 if (err) 969 if (err)
762 goto err_unreg_devs; 970 goto err_unreg_devs;
763 971
764 err = input_register_device(gc->dev[i]); 972 count++;
765 if (err)
766 goto err_free_dev;
767 } 973 }
768 974
769 if (!gc->pads[0]) { 975 if (count == 0) {
770 printk(KERN_ERR "gamecon.c: No valid devices specified\n"); 976 pr_err("No valid devices specified\n");
771 err = -EINVAL; 977 err = -EINVAL;
772 goto err_free_gc; 978 goto err_free_gc;
773 } 979 }
@@ -775,12 +981,10 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
775 parport_put_port(pp); 981 parport_put_port(pp);
776 return gc; 982 return gc;
777 983
778 err_free_dev:
779 input_free_device(gc->dev[i]);
780 err_unreg_devs: 984 err_unreg_devs:
781 while (--i >= 0) 985 while (--i >= 0)
782 if (gc->dev[i]) 986 if (gc->pads[i].dev)
783 input_unregister_device(gc->dev[i]); 987 input_unregister_device(gc->pads[i].dev);
784 err_free_gc: 988 err_free_gc:
785 kfree(gc); 989 kfree(gc);
786 err_unreg_pardev: 990 err_unreg_pardev:
@@ -796,8 +1000,8 @@ static void gc_remove(struct gc *gc)
796 int i; 1000 int i;
797 1001
798 for (i = 0; i < GC_MAX_DEVICES; i++) 1002 for (i = 0; i < GC_MAX_DEVICES; i++)
799 if (gc->dev[i]) 1003 if (gc->pads[i].dev)
800 input_unregister_device(gc->dev[i]); 1004 input_unregister_device(gc->pads[i].dev);
801 parport_unregister_device(gc->pd); 1005 parport_unregister_device(gc->pd);
802 kfree(gc); 1006 kfree(gc);
803} 1007}
@@ -813,7 +1017,7 @@ static int __init gc_init(void)
813 continue; 1017 continue;
814 1018
815 if (gc_cfg[i].nargs < 2) { 1019 if (gc_cfg[i].nargs < 2) {
816 printk(KERN_ERR "gamecon.c: at least one device must be specified\n"); 1020 pr_err("at least one device must be specified\n");
817 err = -EINVAL; 1021 err = -EINVAL;
818 break; 1022 break;
819 } 1023 }
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 8a28fb7846d..9b3353b404d 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -86,9 +86,8 @@
86 86
87/* xbox d-pads should map to buttons, as is required for DDR pads 87/* xbox d-pads should map to buttons, as is required for DDR pads
88 but we map them to axes when possible to simplify things */ 88 but we map them to axes when possible to simplify things */
89#define MAP_DPAD_TO_BUTTONS 0 89#define MAP_DPAD_TO_BUTTONS (1 << 0)
90#define MAP_DPAD_TO_AXES 1 90#define MAP_TRIGGERS_TO_BUTTONS (1 << 1)
91#define MAP_DPAD_UNKNOWN 2
92 91
93#define XTYPE_XBOX 0 92#define XTYPE_XBOX 0
94#define XTYPE_XBOX360 1 93#define XTYPE_XBOX360 1
@@ -99,57 +98,61 @@ static int dpad_to_buttons;
99module_param(dpad_to_buttons, bool, S_IRUGO); 98module_param(dpad_to_buttons, bool, S_IRUGO);
100MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads"); 99MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
101 100
101static int triggers_to_buttons;
102module_param(triggers_to_buttons, bool, S_IRUGO);
103MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads");
104
102static const struct xpad_device { 105static const struct xpad_device {
103 u16 idVendor; 106 u16 idVendor;
104 u16 idProduct; 107 u16 idProduct;
105 char *name; 108 char *name;
106 u8 dpad_mapping; 109 u8 mapping;
107 u8 xtype; 110 u8 xtype;
108} xpad_device[] = { 111} xpad_device[] = {
109 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 112 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
110 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 113 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
111 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 114 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
112 { 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 115 { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
113 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 116 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
114 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 117 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
115 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 118 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
116 { 0x046d, 0xc242, "Logitech Chillstream Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 119 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
117 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 120 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
118 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 121 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
119 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 122 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
120 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 123 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
121 { 0x0738, 0x4516, "Mad Catz Control Pad", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 124 { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX },
122 { 0x0738, 0x4522, "Mad Catz LumiCON", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 125 { 0x0738, 0x4522, "Mad Catz LumiCON", 0, XTYPE_XBOX },
123 { 0x0738, 0x4526, "Mad Catz Control Pad Pro", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 126 { 0x0738, 0x4526, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX },
124 { 0x0738, 0x4536, "Mad Catz MicroCON", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 127 { 0x0738, 0x4536, "Mad Catz MicroCON", 0, XTYPE_XBOX },
125 { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 128 { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
126 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 129 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX },
127 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 130 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
128 { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 131 { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
129 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 132 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
130 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 133 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
131 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 134 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
132 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 135 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
133 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 136 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
134 { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 137 { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
135 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 138 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
136 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 139 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
137 { 0x0e6f, 0x0005, "Eclipse wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 140 { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX },
138 { 0x0e6f, 0x0006, "Edge wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 141 { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
139 { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 142 { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
140 { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 143 { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX },
141 { 0x0f30, 0x0202, "Joytech Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 144 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
142 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 145 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
143 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 146 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
144 { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 147 { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
145 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 148 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
146 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 149 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
147 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 150 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
148 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 151 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
149 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 152 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
150 { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 153 { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
151 { 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 154 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
152 { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN, XTYPE_UNKNOWN } 155 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
153}; 156};
154 157
155/* buttons shared with xbox and xbox360 */ 158/* buttons shared with xbox and xbox360 */
@@ -165,13 +168,20 @@ static const signed short xpad_btn[] = {
165 -1 /* terminating entry */ 168 -1 /* terminating entry */
166}; 169};
167 170
168/* only used if MAP_DPAD_TO_BUTTONS */ 171/* used when dpad is mapped to nuttons */
169static const signed short xpad_btn_pad[] = { 172static const signed short xpad_btn_pad[] = {
170 BTN_LEFT, BTN_RIGHT, /* d-pad left, right */ 173 BTN_LEFT, BTN_RIGHT, /* d-pad left, right */
171 BTN_0, BTN_1, /* d-pad up, down (XXX names??) */ 174 BTN_0, BTN_1, /* d-pad up, down (XXX names??) */
172 -1 /* terminating entry */ 175 -1 /* terminating entry */
173}; 176};
174 177
178/* used when triggers are mapped to buttons */
179static const signed short xpad_btn_triggers[] = {
180 BTN_TL2, BTN_TR2, /* triggers left/right */
181 -1
182};
183
184
175static const signed short xpad360_btn[] = { /* buttons for x360 controller */ 185static const signed short xpad360_btn[] = { /* buttons for x360 controller */
176 BTN_TL, BTN_TR, /* Button LB/RB */ 186 BTN_TL, BTN_TR, /* Button LB/RB */
177 BTN_MODE, /* The big X button */ 187 BTN_MODE, /* The big X button */
@@ -181,16 +191,21 @@ static const signed short xpad360_btn[] = { /* buttons for x360 controller */
181static const signed short xpad_abs[] = { 191static const signed short xpad_abs[] = {
182 ABS_X, ABS_Y, /* left stick */ 192 ABS_X, ABS_Y, /* left stick */
183 ABS_RX, ABS_RY, /* right stick */ 193 ABS_RX, ABS_RY, /* right stick */
184 ABS_Z, ABS_RZ, /* triggers left/right */
185 -1 /* terminating entry */ 194 -1 /* terminating entry */
186}; 195};
187 196
188/* only used if MAP_DPAD_TO_AXES */ 197/* used when dpad is mapped to axes */
189static const signed short xpad_abs_pad[] = { 198static const signed short xpad_abs_pad[] = {
190 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */ 199 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
191 -1 /* terminating entry */ 200 -1 /* terminating entry */
192}; 201};
193 202
203/* used when triggers are mapped to axes */
204static const signed short xpad_abs_triggers[] = {
205 ABS_Z, ABS_RZ, /* triggers left/right */
206 -1
207};
208
194/* Xbox 360 has a vendor-specific class, so we cannot match it with only 209/* Xbox 360 has a vendor-specific class, so we cannot match it with only
195 * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we 210 * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we
196 * match against vendor id as well. Wired Xbox 360 devices have protocol 1, 211 * match against vendor id as well. Wired Xbox 360 devices have protocol 1,
@@ -246,7 +261,7 @@ struct usb_xpad {
246 261
247 char phys[64]; /* physical device path */ 262 char phys[64]; /* physical device path */
248 263
249 int dpad_mapping; /* map d-pad to buttons or to axes */ 264 int mapping; /* map d-pad to buttons or to axes */
250 int xtype; /* type of xbox device */ 265 int xtype; /* type of xbox device */
251}; 266};
252 267
@@ -277,20 +292,25 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
277 ~(__s16) le16_to_cpup((__le16 *)(data + 18))); 292 ~(__s16) le16_to_cpup((__le16 *)(data + 18)));
278 293
279 /* triggers left/right */ 294 /* triggers left/right */
280 input_report_abs(dev, ABS_Z, data[10]); 295 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
281 input_report_abs(dev, ABS_RZ, data[11]); 296 input_report_key(dev, BTN_TL2, data[10]);
297 input_report_key(dev, BTN_TR2, data[11]);
298 } else {
299 input_report_abs(dev, ABS_Z, data[10]);
300 input_report_abs(dev, ABS_RZ, data[11]);
301 }
282 302
283 /* digital pad */ 303 /* digital pad */
284 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) { 304 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
285 input_report_abs(dev, ABS_HAT0X,
286 !!(data[2] & 0x08) - !!(data[2] & 0x04));
287 input_report_abs(dev, ABS_HAT0Y,
288 !!(data[2] & 0x02) - !!(data[2] & 0x01));
289 } else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ {
290 input_report_key(dev, BTN_LEFT, data[2] & 0x04); 305 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
291 input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 306 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
292 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ 307 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */
293 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ 308 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */
309 } else {
310 input_report_abs(dev, ABS_HAT0X,
311 !!(data[2] & 0x08) - !!(data[2] & 0x04));
312 input_report_abs(dev, ABS_HAT0Y,
313 !!(data[2] & 0x02) - !!(data[2] & 0x01));
294 } 314 }
295 315
296 /* start/back buttons and stick press left/right */ 316 /* start/back buttons and stick press left/right */
@@ -328,17 +348,17 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
328 struct input_dev *dev = xpad->dev; 348 struct input_dev *dev = xpad->dev;
329 349
330 /* digital pad */ 350 /* digital pad */
331 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) { 351 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
332 input_report_abs(dev, ABS_HAT0X,
333 !!(data[2] & 0x08) - !!(data[2] & 0x04));
334 input_report_abs(dev, ABS_HAT0Y,
335 !!(data[2] & 0x02) - !!(data[2] & 0x01));
336 } else if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS) {
337 /* dpad as buttons (right, left, down, up) */ 352 /* dpad as buttons (right, left, down, up) */
338 input_report_key(dev, BTN_LEFT, data[2] & 0x04); 353 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
339 input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 354 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
340 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ 355 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */
341 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ 356 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */
357 } else {
358 input_report_abs(dev, ABS_HAT0X,
359 !!(data[2] & 0x08) - !!(data[2] & 0x04));
360 input_report_abs(dev, ABS_HAT0Y,
361 !!(data[2] & 0x02) - !!(data[2] & 0x01));
342 } 362 }
343 363
344 /* start/back buttons */ 364 /* start/back buttons */
@@ -371,8 +391,13 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
371 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); 391 ~(__s16) le16_to_cpup((__le16 *)(data + 12)));
372 392
373 /* triggers left/right */ 393 /* triggers left/right */
374 input_report_abs(dev, ABS_Z, data[4]); 394 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
375 input_report_abs(dev, ABS_RZ, data[5]); 395 input_report_key(dev, BTN_TL2, data[4]);
396 input_report_key(dev, BTN_TR2, data[5]);
397 } else {
398 input_report_abs(dev, ABS_Z, data[4]);
399 input_report_abs(dev, ABS_RZ, data[5]);
400 }
376 401
377 input_sync(dev); 402 input_sync(dev);
378} 403}
@@ -505,7 +530,7 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
505 struct usb_endpoint_descriptor *ep_irq_out; 530 struct usb_endpoint_descriptor *ep_irq_out;
506 int error = -ENOMEM; 531 int error = -ENOMEM;
507 532
508 if (xpad->xtype != XTYPE_XBOX360) 533 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX)
509 return 0; 534 return 0;
510 535
511 xpad->odata = usb_buffer_alloc(xpad->udev, XPAD_PKT_LEN, 536 xpad->odata = usb_buffer_alloc(xpad->udev, XPAD_PKT_LEN,
@@ -535,13 +560,13 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
535 560
536static void xpad_stop_output(struct usb_xpad *xpad) 561static void xpad_stop_output(struct usb_xpad *xpad)
537{ 562{
538 if (xpad->xtype == XTYPE_XBOX360) 563 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX)
539 usb_kill_urb(xpad->irq_out); 564 usb_kill_urb(xpad->irq_out);
540} 565}
541 566
542static void xpad_deinit_output(struct usb_xpad *xpad) 567static void xpad_deinit_output(struct usb_xpad *xpad)
543{ 568{
544 if (xpad->xtype == XTYPE_XBOX360) { 569 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX) {
545 usb_free_urb(xpad->irq_out); 570 usb_free_urb(xpad->irq_out);
546 usb_buffer_free(xpad->udev, XPAD_PKT_LEN, 571 usb_buffer_free(xpad->udev, XPAD_PKT_LEN,
547 xpad->odata, xpad->odata_dma); 572 xpad->odata, xpad->odata_dma);
@@ -554,24 +579,45 @@ static void xpad_stop_output(struct usb_xpad *xpad) {}
554#endif 579#endif
555 580
556#ifdef CONFIG_JOYSTICK_XPAD_FF 581#ifdef CONFIG_JOYSTICK_XPAD_FF
557static int xpad_play_effect(struct input_dev *dev, void *data, 582static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
558 struct ff_effect *effect)
559{ 583{
560 struct usb_xpad *xpad = input_get_drvdata(dev); 584 struct usb_xpad *xpad = input_get_drvdata(dev);
561 585
562 if (effect->type == FF_RUMBLE) { 586 if (effect->type == FF_RUMBLE) {
563 __u16 strong = effect->u.rumble.strong_magnitude; 587 __u16 strong = effect->u.rumble.strong_magnitude;
564 __u16 weak = effect->u.rumble.weak_magnitude; 588 __u16 weak = effect->u.rumble.weak_magnitude;
565 xpad->odata[0] = 0x00; 589
566 xpad->odata[1] = 0x08; 590 switch (xpad->xtype) {
567 xpad->odata[2] = 0x00; 591
568 xpad->odata[3] = strong / 256; 592 case XTYPE_XBOX:
569 xpad->odata[4] = weak / 256; 593 xpad->odata[0] = 0x00;
570 xpad->odata[5] = 0x00; 594 xpad->odata[1] = 0x06;
571 xpad->odata[6] = 0x00; 595 xpad->odata[2] = 0x00;
572 xpad->odata[7] = 0x00; 596 xpad->odata[3] = strong / 256; /* left actuator */
573 xpad->irq_out->transfer_buffer_length = 8; 597 xpad->odata[4] = 0x00;
574 usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 598 xpad->odata[5] = weak / 256; /* right actuator */
599 xpad->irq_out->transfer_buffer_length = 6;
600
601 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
602
603 case XTYPE_XBOX360:
604 xpad->odata[0] = 0x00;
605 xpad->odata[1] = 0x08;
606 xpad->odata[2] = 0x00;
607 xpad->odata[3] = strong / 256; /* left actuator? */
608 xpad->odata[4] = weak / 256; /* right actuator? */
609 xpad->odata[5] = 0x00;
610 xpad->odata[6] = 0x00;
611 xpad->odata[7] = 0x00;
612 xpad->irq_out->transfer_buffer_length = 8;
613
614 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
615
616 default:
617 dbg("%s - rumble command sent to unsupported xpad type: %d",
618 __func__, xpad->xtype);
619 return -1;
620 }
575 } 621 }
576 622
577 return 0; 623 return 0;
@@ -579,7 +625,7 @@ static int xpad_play_effect(struct input_dev *dev, void *data,
579 625
580static int xpad_init_ff(struct usb_xpad *xpad) 626static int xpad_init_ff(struct usb_xpad *xpad)
581{ 627{
582 if (xpad->xtype != XTYPE_XBOX360) 628 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX)
583 return 0; 629 return 0;
584 630
585 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); 631 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE);
@@ -712,11 +758,11 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
712 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); 758 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128);
713 break; 759 break;
714 case ABS_Z: 760 case ABS_Z:
715 case ABS_RZ: /* the triggers */ 761 case ABS_RZ: /* the triggers (if mapped to axes) */
716 input_set_abs_params(input_dev, abs, 0, 255, 0, 0); 762 input_set_abs_params(input_dev, abs, 0, 255, 0, 0);
717 break; 763 break;
718 case ABS_HAT0X: 764 case ABS_HAT0X:
719 case ABS_HAT0Y: /* the d-pad (only if MAP_DPAD_TO_AXES) */ 765 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
720 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); 766 input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
721 break; 767 break;
722 } 768 }
@@ -752,10 +798,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
752 goto fail2; 798 goto fail2;
753 799
754 xpad->udev = udev; 800 xpad->udev = udev;
755 xpad->dpad_mapping = xpad_device[i].dpad_mapping; 801 xpad->mapping = xpad_device[i].mapping;
756 xpad->xtype = xpad_device[i].xtype; 802 xpad->xtype = xpad_device[i].xtype;
757 if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN) 803
758 xpad->dpad_mapping = !dpad_to_buttons;
759 if (xpad->xtype == XTYPE_UNKNOWN) { 804 if (xpad->xtype == XTYPE_UNKNOWN) {
760 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { 805 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
761 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) 806 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
@@ -764,7 +809,13 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
764 xpad->xtype = XTYPE_XBOX360; 809 xpad->xtype = XTYPE_XBOX360;
765 } else 810 } else
766 xpad->xtype = XTYPE_XBOX; 811 xpad->xtype = XTYPE_XBOX;
812
813 if (dpad_to_buttons)
814 xpad->mapping |= MAP_DPAD_TO_BUTTONS;
815 if (triggers_to_buttons)
816 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;
767 } 817 }
818
768 xpad->dev = input_dev; 819 xpad->dev = input_dev;
769 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); 820 usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
770 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); 821 strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
@@ -781,25 +832,37 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
781 832
782 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 833 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
783 834
784 /* set up buttons */ 835 /* set up standard buttons and axes */
785 for (i = 0; xpad_common_btn[i] >= 0; i++) 836 for (i = 0; xpad_common_btn[i] >= 0; i++)
786 set_bit(xpad_common_btn[i], input_dev->keybit); 837 __set_bit(xpad_common_btn[i], input_dev->keybit);
787 if ((xpad->xtype == XTYPE_XBOX360) || (xpad->xtype == XTYPE_XBOX360W))
788 for (i = 0; xpad360_btn[i] >= 0; i++)
789 set_bit(xpad360_btn[i], input_dev->keybit);
790 else
791 for (i = 0; xpad_btn[i] >= 0; i++)
792 set_bit(xpad_btn[i], input_dev->keybit);
793 if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS)
794 for (i = 0; xpad_btn_pad[i] >= 0; i++)
795 set_bit(xpad_btn_pad[i], input_dev->keybit);
796 838
797 /* set up axes */
798 for (i = 0; xpad_abs[i] >= 0; i++) 839 for (i = 0; xpad_abs[i] >= 0; i++)
799 xpad_set_up_abs(input_dev, xpad_abs[i]); 840 xpad_set_up_abs(input_dev, xpad_abs[i]);
800 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) 841
842 /* Now set up model-specific ones */
843 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
844 for (i = 0; xpad360_btn[i] >= 0; i++)
845 __set_bit(xpad360_btn[i], input_dev->keybit);
846 } else {
847 for (i = 0; xpad_btn[i] >= 0; i++)
848 __set_bit(xpad_btn[i], input_dev->keybit);
849 }
850
851 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
852 for (i = 0; xpad_btn_pad[i] >= 0; i++)
853 __set_bit(xpad_btn_pad[i], input_dev->keybit);
854 } else {
801 for (i = 0; xpad_abs_pad[i] >= 0; i++) 855 for (i = 0; xpad_abs_pad[i] >= 0; i++)
802 xpad_set_up_abs(input_dev, xpad_abs_pad[i]); 856 xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
857 }
858
859 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
860 for (i = 0; xpad_btn_triggers[i] >= 0; i++)
861 __set_bit(xpad_btn_triggers[i], input_dev->keybit);
862 } else {
863 for (i = 0; xpad_abs_triggers[i] >= 0; i++)
864 xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
865 }
803 866
804 error = xpad_init_output(intf, xpad); 867 error = xpad_init_output(intf, xpad);
805 if (error) 868 if (error)
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 02c836e1181..64c102355f5 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -35,10 +35,10 @@ config KEYBOARD_ADP5520
35 be called adp5520-keys. 35 be called adp5520-keys.
36 36
37config KEYBOARD_ADP5588 37config KEYBOARD_ADP5588
38 tristate "ADP5588 I2C QWERTY Keypad and IO Expander" 38 tristate "ADP5588/87 I2C QWERTY Keypad and IO Expander"
39 depends on I2C 39 depends on I2C
40 help 40 help
41 Say Y here if you want to use a ADP5588 attached to your 41 Say Y here if you want to use a ADP5588/87 attached to your
42 system I2C bus. 42 system I2C bus.
43 43
44 To compile this driver as a module, choose M here: the 44 To compile this driver as a module, choose M here: the
@@ -144,13 +144,15 @@ config KEYBOARD_BFIN
144 module will be called bf54x-keys. 144 module will be called bf54x-keys.
145 145
146config KEYBOARD_CORGI 146config KEYBOARD_CORGI
147 tristate "Corgi keyboard" 147 tristate "Corgi keyboard (deprecated)"
148 depends on PXA_SHARPSL 148 depends on PXA_SHARPSL
149 default y
150 help 149 help
151 Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx 150 Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx
152 series of PDAs. 151 series of PDAs.
153 152
153 This driver is now deprecated, use generic GPIO based matrix
154 keyboard driver instead.
155
154 To compile this driver as a module, choose M here: the 156 To compile this driver as a module, choose M here: the
155 module will be called corgikbd. 157 module will be called corgikbd.
156 158
@@ -292,6 +294,15 @@ config KEYBOARD_MAX7359
292 To compile this driver as a module, choose M here: the 294 To compile this driver as a module, choose M here: the
293 module will be called max7359_keypad. 295 module will be called max7359_keypad.
294 296
297config KEYBOARD_IMX
298 tristate "IMX keypad support"
299 depends on ARCH_MXC
300 help
301 Enable support for IMX keypad port.
302
303 To compile this driver as a module, choose M here: the
304 module will be called imx_keypad.
305
295config KEYBOARD_NEWTON 306config KEYBOARD_NEWTON
296 tristate "Newton keyboard" 307 tristate "Newton keyboard"
297 select SERIO 308 select SERIO
@@ -329,13 +340,15 @@ config KEYBOARD_PXA930_ROTARY
329 module will be called pxa930_rotary. 340 module will be called pxa930_rotary.
330 341
331config KEYBOARD_SPITZ 342config KEYBOARD_SPITZ
332 tristate "Spitz keyboard" 343 tristate "Spitz keyboard (deprecated)"
333 depends on PXA_SHARPSL 344 depends on PXA_SHARPSL
334 default y
335 help 345 help
336 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000, 346 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000,
337 SL-C3000 and Sl-C3100 series of PDAs. 347 SL-C3000 and Sl-C3100 series of PDAs.
338 348
349 This driver is now deprecated, use generic GPIO based matrix
350 keyboard driver instead.
351
339 To compile this driver as a module, choose M here: the 352 To compile this driver as a module, choose M here: the
340 module will be called spitzkbd. 353 module will be called spitzkbd.
341 354
@@ -363,7 +376,7 @@ config KEYBOARD_SUNKBD
363 376
364config KEYBOARD_SH_KEYSC 377config KEYBOARD_SH_KEYSC
365 tristate "SuperH KEYSC keypad support" 378 tristate "SuperH KEYSC keypad support"
366 depends on SUPERH 379 depends on SUPERH || ARCH_SHMOBILE
367 help 380 help
368 Say Y here if you want to use a keypad attached to the KEYSC block 381 Say Y here if you want to use a keypad attached to the KEYSC block
369 on SuperH processors such as sh7722 and sh7343. 382 on SuperH processors such as sh7722 and sh7343.
@@ -402,12 +415,14 @@ config KEYBOARD_TWL4030
402 module will be called twl4030_keypad. 415 module will be called twl4030_keypad.
403 416
404config KEYBOARD_TOSA 417config KEYBOARD_TOSA
405 tristate "Tosa keyboard" 418 tristate "Tosa keyboard (deprecated)"
406 depends on MACH_TOSA 419 depends on MACH_TOSA
407 default y
408 help 420 help
409 Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa) 421 Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
410 422
423 This driver is now deprecated, use generic GPIO based matrix
424 keyboard driver instead.
425
411 To compile this driver as a module, choose M here: the 426 To compile this driver as a module, choose M here: the
412 module will be called tosakbd. 427 module will be called tosakbd.
413 428
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 78654ef6520..706c6b5ed5f 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o
17obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 17obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
20obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o
20obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o 21obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
21obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o 22obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
22obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o 23obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index 1edb596d927..b5142d2d511 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * File: drivers/input/keyboard/adp5588_keys.c 2 * File: drivers/input/keyboard/adp5588_keys.c
3 * Description: keypad driver for ADP5588 I2C QWERTY Keypad and IO Expander 3 * Description: keypad driver for ADP5588 and ADP5587
4 * I2C QWERTY Keypad and IO Expander
4 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 5 * Bugs: Enter bugs at http://blackfin.uclinux.org/
5 * 6 *
6 * Copyright (C) 2008-2009 Analog Devices Inc. 7 * Copyright (C) 2008-2009 Analog Devices Inc.
@@ -327,6 +328,7 @@ static const struct dev_pm_ops adp5588_dev_pm_ops = {
327 328
328static const struct i2c_device_id adp5588_id[] = { 329static const struct i2c_device_id adp5588_id[] = {
329 { KBUILD_MODNAME, 0 }, 330 { KBUILD_MODNAME, 0 },
331 { "adp5587-keys", 0 },
330 { } 332 { }
331}; 333};
332MODULE_DEVICE_TABLE(i2c, adp5588_id); 334MODULE_DEVICE_TABLE(i2c, adp5588_id);
@@ -357,5 +359,5 @@ module_exit(adp5588_exit);
357 359
358MODULE_LICENSE("GPL"); 360MODULE_LICENSE("GPL");
359MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 361MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
360MODULE_DESCRIPTION("ADP5588 Keypad driver"); 362MODULE_DESCRIPTION("ADP5588/87 Keypad driver");
361MODULE_ALIAS("platform:adp5588-keys"); 363MODULE_ALIAS("platform:adp5588-keys");
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 7b4056292ea..d358ef8623f 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -40,26 +40,26 @@ module_param_named(set, atkbd_set, int, 0);
40MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3 = PS/2 native)"); 40MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3 = PS/2 native)");
41 41
42#if defined(__i386__) || defined(__x86_64__) || defined(__hppa__) 42#if defined(__i386__) || defined(__x86_64__) || defined(__hppa__)
43static int atkbd_reset; 43static bool atkbd_reset;
44#else 44#else
45static int atkbd_reset = 1; 45static bool atkbd_reset = true;
46#endif 46#endif
47module_param_named(reset, atkbd_reset, bool, 0); 47module_param_named(reset, atkbd_reset, bool, 0);
48MODULE_PARM_DESC(reset, "Reset keyboard during initialization"); 48MODULE_PARM_DESC(reset, "Reset keyboard during initialization");
49 49
50static int atkbd_softrepeat; 50static bool atkbd_softrepeat;
51module_param_named(softrepeat, atkbd_softrepeat, bool, 0); 51module_param_named(softrepeat, atkbd_softrepeat, bool, 0);
52MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat"); 52MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat");
53 53
54static int atkbd_softraw = 1; 54static bool atkbd_softraw = true;
55module_param_named(softraw, atkbd_softraw, bool, 0); 55module_param_named(softraw, atkbd_softraw, bool, 0);
56MODULE_PARM_DESC(softraw, "Use software generated rawmode"); 56MODULE_PARM_DESC(softraw, "Use software generated rawmode");
57 57
58static int atkbd_scroll; 58static bool atkbd_scroll;
59module_param_named(scroll, atkbd_scroll, bool, 0); 59module_param_named(scroll, atkbd_scroll, bool, 0);
60MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); 60MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards");
61 61
62static int atkbd_extra; 62static bool atkbd_extra;
63module_param_named(extra, atkbd_extra, bool, 0); 63module_param_named(extra, atkbd_extra, bool, 0);
64MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards"); 64MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards");
65 65
@@ -153,16 +153,16 @@ static const unsigned short atkbd_unxlate_table[128] = {
153#define ATKBD_RET_HANGEUL 0xf2 153#define ATKBD_RET_HANGEUL 0xf2
154#define ATKBD_RET_ERR 0xff 154#define ATKBD_RET_ERR 0xff
155 155
156#define ATKBD_KEY_UNKNOWN 0 156#define ATKBD_KEY_UNKNOWN 0
157#define ATKBD_KEY_NULL 255 157#define ATKBD_KEY_NULL 255
158 158
159#define ATKBD_SCR_1 254 159#define ATKBD_SCR_1 0xfffe
160#define ATKBD_SCR_2 253 160#define ATKBD_SCR_2 0xfffd
161#define ATKBD_SCR_4 252 161#define ATKBD_SCR_4 0xfffc
162#define ATKBD_SCR_8 251 162#define ATKBD_SCR_8 0xfffb
163#define ATKBD_SCR_CLICK 250 163#define ATKBD_SCR_CLICK 0xfffa
164#define ATKBD_SCR_LEFT 249 164#define ATKBD_SCR_LEFT 0xfff9
165#define ATKBD_SCR_RIGHT 248 165#define ATKBD_SCR_RIGHT 0xfff8
166 166
167#define ATKBD_SPECIAL ATKBD_SCR_RIGHT 167#define ATKBD_SPECIAL ATKBD_SCR_RIGHT
168 168
@@ -177,7 +177,7 @@ static const unsigned short atkbd_unxlate_table[128] = {
177#define ATKBD_XL_HANJA 0x20 177#define ATKBD_XL_HANJA 0x20
178 178
179static const struct { 179static const struct {
180 unsigned char keycode; 180 unsigned short keycode;
181 unsigned char set2; 181 unsigned char set2;
182} atkbd_scroll_keys[] = { 182} atkbd_scroll_keys[] = {
183 { ATKBD_SCR_1, 0xc5 }, 183 { ATKBD_SCR_1, 0xc5 },
@@ -206,18 +206,18 @@ struct atkbd {
206 unsigned short keycode[ATKBD_KEYMAP_SIZE]; 206 unsigned short keycode[ATKBD_KEYMAP_SIZE];
207 DECLARE_BITMAP(force_release_mask, ATKBD_KEYMAP_SIZE); 207 DECLARE_BITMAP(force_release_mask, ATKBD_KEYMAP_SIZE);
208 unsigned char set; 208 unsigned char set;
209 unsigned char translated; 209 bool translated;
210 unsigned char extra; 210 bool extra;
211 unsigned char write; 211 bool write;
212 unsigned char softrepeat; 212 bool softrepeat;
213 unsigned char softraw; 213 bool softraw;
214 unsigned char scroll; 214 bool scroll;
215 unsigned char enabled; 215 bool enabled;
216 216
217 /* Accessed only from interrupt */ 217 /* Accessed only from interrupt */
218 unsigned char emul; 218 unsigned char emul;
219 unsigned char resend; 219 bool resend;
220 unsigned char release; 220 bool release;
221 unsigned long xl_bit; 221 unsigned long xl_bit;
222 unsigned int last; 222 unsigned int last;
223 unsigned long time; 223 unsigned long time;
@@ -301,18 +301,18 @@ static const unsigned int xl_table[] = {
301 * Checks if we should mangle the scancode to extract 'release' bit 301 * Checks if we should mangle the scancode to extract 'release' bit
302 * in translated mode. 302 * in translated mode.
303 */ 303 */
304static int atkbd_need_xlate(unsigned long xl_bit, unsigned char code) 304static bool atkbd_need_xlate(unsigned long xl_bit, unsigned char code)
305{ 305{
306 int i; 306 int i;
307 307
308 if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1) 308 if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1)
309 return 0; 309 return false;
310 310
311 for (i = 0; i < ARRAY_SIZE(xl_table); i++) 311 for (i = 0; i < ARRAY_SIZE(xl_table); i++)
312 if (code == xl_table[i]) 312 if (code == xl_table[i])
313 return test_bit(i, &xl_bit); 313 return test_bit(i, &xl_bit);
314 314
315 return 1; 315 return true;
316} 316}
317 317
318/* 318/*
@@ -359,7 +359,7 @@ static unsigned int atkbd_compat_scancode(struct atkbd *atkbd, unsigned int code
359 */ 359 */
360 360
361static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, 361static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
362 unsigned int flags) 362 unsigned int flags)
363{ 363{
364 struct atkbd *atkbd = serio_get_drvdata(serio); 364 struct atkbd *atkbd = serio_get_drvdata(serio);
365 struct input_dev *dev = atkbd->dev; 365 struct input_dev *dev = atkbd->dev;
@@ -368,20 +368,18 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
368 int value; 368 int value;
369 unsigned short keycode; 369 unsigned short keycode;
370 370
371#ifdef ATKBD_DEBUG 371 dev_dbg(&serio->dev, "Received %02x flags %02x\n", data, flags);
372 printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags);
373#endif
374 372
375#if !defined(__i386__) && !defined (__x86_64__) 373#if !defined(__i386__) && !defined (__x86_64__)
376 if ((flags & (SERIO_FRAME | SERIO_PARITY)) && (~flags & SERIO_TIMEOUT) && !atkbd->resend && atkbd->write) { 374 if ((flags & (SERIO_FRAME | SERIO_PARITY)) && (~flags & SERIO_TIMEOUT) && !atkbd->resend && atkbd->write) {
377 printk(KERN_WARNING "atkbd.c: frame/parity error: %02x\n", flags); 375 dev_warn(&serio->dev, "Frame/parity error: %02x\n", flags);
378 serio_write(serio, ATKBD_CMD_RESEND); 376 serio_write(serio, ATKBD_CMD_RESEND);
379 atkbd->resend = 1; 377 atkbd->resend = true;
380 goto out; 378 goto out;
381 } 379 }
382 380
383 if (!flags && data == ATKBD_RET_ACK) 381 if (!flags && data == ATKBD_RET_ACK)
384 atkbd->resend = 0; 382 atkbd->resend = false;
385#endif 383#endif
386 384
387 if (unlikely(atkbd->ps2dev.flags & PS2_FLAG_ACK)) 385 if (unlikely(atkbd->ps2dev.flags & PS2_FLAG_ACK))
@@ -412,32 +410,32 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
412 } 410 }
413 411
414 switch (code) { 412 switch (code) {
415 case ATKBD_RET_BAT: 413 case ATKBD_RET_BAT:
416 atkbd->enabled = 0; 414 atkbd->enabled = false;
417 serio_reconnect(atkbd->ps2dev.serio); 415 serio_reconnect(atkbd->ps2dev.serio);
418 goto out; 416 goto out;
419 case ATKBD_RET_EMUL0: 417 case ATKBD_RET_EMUL0:
420 atkbd->emul = 1; 418 atkbd->emul = 1;
421 goto out; 419 goto out;
422 case ATKBD_RET_EMUL1: 420 case ATKBD_RET_EMUL1:
423 atkbd->emul = 2; 421 atkbd->emul = 2;
424 goto out; 422 goto out;
425 case ATKBD_RET_RELEASE: 423 case ATKBD_RET_RELEASE:
426 atkbd->release = 1; 424 atkbd->release = true;
427 goto out; 425 goto out;
428 case ATKBD_RET_ACK: 426 case ATKBD_RET_ACK:
429 case ATKBD_RET_NAK: 427 case ATKBD_RET_NAK:
430 if (printk_ratelimit()) 428 if (printk_ratelimit())
431 printk(KERN_WARNING "atkbd.c: Spurious %s on %s. " 429 dev_warn(&serio->dev,
432 "Some program might be trying access hardware directly.\n", 430 "Spurious %s on %s. "
433 data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); 431 "Some program might be trying access hardware directly.\n",
434 goto out; 432 data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys);
435 case ATKBD_RET_ERR: 433 goto out;
436 atkbd->err_count++; 434 case ATKBD_RET_ERR:
437#ifdef ATKBD_DEBUG 435 atkbd->err_count++;
438 printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); 436 dev_dbg(&serio->dev, "Keyboard on %s reports too many keys pressed.\n",
439#endif 437 serio->phys);
440 goto out; 438 goto out;
441 } 439 }
442 440
443 code = atkbd_compat_scancode(atkbd, code); 441 code = atkbd_compat_scancode(atkbd, code);
@@ -451,71 +449,72 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
451 input_event(dev, EV_MSC, MSC_SCAN, code); 449 input_event(dev, EV_MSC, MSC_SCAN, code);
452 450
453 switch (keycode) { 451 switch (keycode) {
454 case ATKBD_KEY_NULL: 452 case ATKBD_KEY_NULL:
455 break; 453 break;
456 case ATKBD_KEY_UNKNOWN: 454 case ATKBD_KEY_UNKNOWN:
457 printk(KERN_WARNING 455 dev_warn(&serio->dev,
458 "atkbd.c: Unknown key %s (%s set %d, code %#x on %s).\n", 456 "Unknown key %s (%s set %d, code %#x on %s).\n",
459 atkbd->release ? "released" : "pressed", 457 atkbd->release ? "released" : "pressed",
460 atkbd->translated ? "translated" : "raw", 458 atkbd->translated ? "translated" : "raw",
461 atkbd->set, code, serio->phys); 459 atkbd->set, code, serio->phys);
462 printk(KERN_WARNING 460 dev_warn(&serio->dev,
463 "atkbd.c: Use 'setkeycodes %s%02x <keycode>' to make it known.\n", 461 "Use 'setkeycodes %s%02x <keycode>' to make it known.\n",
464 code & 0x80 ? "e0" : "", code & 0x7f); 462 code & 0x80 ? "e0" : "", code & 0x7f);
465 input_sync(dev); 463 input_sync(dev);
466 break; 464 break;
467 case ATKBD_SCR_1: 465 case ATKBD_SCR_1:
468 scroll = 1 - atkbd->release * 2; 466 scroll = 1;
469 break; 467 break;
470 case ATKBD_SCR_2: 468 case ATKBD_SCR_2:
471 scroll = 2 - atkbd->release * 4; 469 scroll = 2;
472 break; 470 break;
473 case ATKBD_SCR_4: 471 case ATKBD_SCR_4:
474 scroll = 4 - atkbd->release * 8; 472 scroll = 4;
475 break; 473 break;
476 case ATKBD_SCR_8: 474 case ATKBD_SCR_8:
477 scroll = 8 - atkbd->release * 16; 475 scroll = 8;
478 break; 476 break;
479 case ATKBD_SCR_CLICK: 477 case ATKBD_SCR_CLICK:
480 click = !atkbd->release; 478 click = !atkbd->release;
481 break; 479 break;
482 case ATKBD_SCR_LEFT: 480 case ATKBD_SCR_LEFT:
483 hscroll = -1; 481 hscroll = -1;
484 break; 482 break;
485 case ATKBD_SCR_RIGHT: 483 case ATKBD_SCR_RIGHT:
486 hscroll = 1; 484 hscroll = 1;
487 break; 485 break;
488 default: 486 default:
489 if (atkbd->release) { 487 if (atkbd->release) {
490 value = 0; 488 value = 0;
491 atkbd->last = 0; 489 atkbd->last = 0;
492 } else if (!atkbd->softrepeat && test_bit(keycode, dev->key)) { 490 } else if (!atkbd->softrepeat && test_bit(keycode, dev->key)) {
493 /* Workaround Toshiba laptop multiple keypress */ 491 /* Workaround Toshiba laptop multiple keypress */
494 value = time_before(jiffies, atkbd->time) && atkbd->last == code ? 1 : 2; 492 value = time_before(jiffies, atkbd->time) && atkbd->last == code ? 1 : 2;
495 } else { 493 } else {
496 value = 1; 494 value = 1;
497 atkbd->last = code; 495 atkbd->last = code;
498 atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2; 496 atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2;
499 } 497 }
500 498
501 input_event(dev, EV_KEY, keycode, value); 499 input_event(dev, EV_KEY, keycode, value);
502 input_sync(dev); 500 input_sync(dev);
503 501
504 if (value && test_bit(code, atkbd->force_release_mask)) { 502 if (value && test_bit(code, atkbd->force_release_mask)) {
505 input_report_key(dev, keycode, 0); 503 input_report_key(dev, keycode, 0);
506 input_sync(dev); 504 input_sync(dev);
507 } 505 }
508 } 506 }
509 507
510 if (atkbd->scroll) { 508 if (atkbd->scroll) {
511 if (click != -1) 509 if (click != -1)
512 input_report_key(dev, BTN_MIDDLE, click); 510 input_report_key(dev, BTN_MIDDLE, click);
513 input_report_rel(dev, REL_WHEEL, scroll); 511 input_report_rel(dev, REL_WHEEL,
512 atkbd->release ? -scroll : scroll);
514 input_report_rel(dev, REL_HWHEEL, hscroll); 513 input_report_rel(dev, REL_HWHEEL, hscroll);
515 input_sync(dev); 514 input_sync(dev);
516 } 515 }
517 516
518 atkbd->release = 0; 517 atkbd->release = false;
519out: 518out:
520 return IRQ_HANDLED; 519 return IRQ_HANDLED;
521} 520}
@@ -634,17 +633,18 @@ static int atkbd_event(struct input_dev *dev,
634 633
635 switch (type) { 634 switch (type) {
636 635
637 case EV_LED: 636 case EV_LED:
638 atkbd_schedule_event_work(atkbd, ATKBD_LED_EVENT_BIT); 637 atkbd_schedule_event_work(atkbd, ATKBD_LED_EVENT_BIT);
639 return 0; 638 return 0;
640 639
641 case EV_REP: 640 case EV_REP:
642 if (!atkbd->softrepeat) 641 if (!atkbd->softrepeat)
643 atkbd_schedule_event_work(atkbd, ATKBD_REP_EVENT_BIT); 642 atkbd_schedule_event_work(atkbd, ATKBD_REP_EVENT_BIT);
644 return 0; 643 return 0;
645 }
646 644
647 return -1; 645 default:
646 return -1;
647 }
648} 648}
649 649
650/* 650/*
@@ -655,7 +655,7 @@ static int atkbd_event(struct input_dev *dev,
655static inline void atkbd_enable(struct atkbd *atkbd) 655static inline void atkbd_enable(struct atkbd *atkbd)
656{ 656{
657 serio_pause_rx(atkbd->ps2dev.serio); 657 serio_pause_rx(atkbd->ps2dev.serio);
658 atkbd->enabled = 1; 658 atkbd->enabled = true;
659 serio_continue_rx(atkbd->ps2dev.serio); 659 serio_continue_rx(atkbd->ps2dev.serio);
660} 660}
661 661
@@ -667,7 +667,7 @@ static inline void atkbd_enable(struct atkbd *atkbd)
667static inline void atkbd_disable(struct atkbd *atkbd) 667static inline void atkbd_disable(struct atkbd *atkbd)
668{ 668{
669 serio_pause_rx(atkbd->ps2dev.serio); 669 serio_pause_rx(atkbd->ps2dev.serio);
670 atkbd->enabled = 0; 670 atkbd->enabled = false;
671 serio_continue_rx(atkbd->ps2dev.serio); 671 serio_continue_rx(atkbd->ps2dev.serio);
672} 672}
673 673
@@ -688,7 +688,9 @@ static int atkbd_probe(struct atkbd *atkbd)
688 688
689 if (atkbd_reset) 689 if (atkbd_reset)
690 if (ps2_command(ps2dev, NULL, ATKBD_CMD_RESET_BAT)) 690 if (ps2_command(ps2dev, NULL, ATKBD_CMD_RESET_BAT))
691 printk(KERN_WARNING "atkbd.c: keyboard reset failed on %s\n", ps2dev->serio->phys); 691 dev_warn(&ps2dev->serio->dev,
692 "keyboard reset failed on %s\n",
693 ps2dev->serio->phys);
692 694
693/* 695/*
694 * Then we check the keyboard ID. We should get 0xab83 under normal conditions. 696 * Then we check the keyboard ID. We should get 0xab83 under normal conditions.
@@ -718,8 +720,9 @@ static int atkbd_probe(struct atkbd *atkbd)
718 atkbd->id = (param[0] << 8) | param[1]; 720 atkbd->id = (param[0] << 8) | param[1];
719 721
720 if (atkbd->id == 0xaca1 && atkbd->translated) { 722 if (atkbd->id == 0xaca1 && atkbd->translated) {
721 printk(KERN_ERR "atkbd.c: NCD terminal keyboards are only supported on non-translating\n"); 723 dev_err(&ps2dev->serio->dev,
722 printk(KERN_ERR "atkbd.c: controllers. Use i8042.direct=1 to disable translation.\n"); 724 "NCD terminal keyboards are only supported on non-translating controlelrs. "
725 "Use i8042.direct=1 to disable translation.\n");
723 return -1; 726 return -1;
724 } 727 }
725 728
@@ -737,7 +740,7 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra
737 struct ps2dev *ps2dev = &atkbd->ps2dev; 740 struct ps2dev *ps2dev = &atkbd->ps2dev;
738 unsigned char param[2]; 741 unsigned char param[2];
739 742
740 atkbd->extra = 0; 743 atkbd->extra = false;
741/* 744/*
742 * For known special keyboards we can go ahead and set the correct set. 745 * For known special keyboards we can go ahead and set the correct set.
743 * We check for NCD PS/2 Sun, NorthGate OmniKey 101 and 746 * We check for NCD PS/2 Sun, NorthGate OmniKey 101 and
@@ -756,7 +759,7 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra
756 if (allow_extra) { 759 if (allow_extra) {
757 param[0] = 0x71; 760 param[0] = 0x71;
758 if (!ps2_command(ps2dev, param, ATKBD_CMD_EX_ENABLE)) { 761 if (!ps2_command(ps2dev, param, ATKBD_CMD_EX_ENABLE)) {
759 atkbd->extra = 1; 762 atkbd->extra = true;
760 return 2; 763 return 2;
761 } 764 }
762 } 765 }
@@ -821,7 +824,8 @@ static int atkbd_activate(struct atkbd *atkbd)
821 */ 824 */
822 825
823 if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) { 826 if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) {
824 printk(KERN_ERR "atkbd.c: Failed to enable keyboard on %s\n", 827 dev_err(&ps2dev->serio->dev,
828 "Failed to enable keyboard on %s\n",
825 ps2dev->serio->phys); 829 ps2dev->serio->phys);
826 return -1; 830 return -1;
827 } 831 }
@@ -1070,9 +1074,13 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd)
1070 input_dev->keycodesize = sizeof(unsigned short); 1074 input_dev->keycodesize = sizeof(unsigned short);
1071 input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode); 1075 input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode);
1072 1076
1073 for (i = 0; i < ATKBD_KEYMAP_SIZE; i++) 1077 for (i = 0; i < ATKBD_KEYMAP_SIZE; i++) {
1074 if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL) 1078 if (atkbd->keycode[i] != KEY_RESERVED &&
1079 atkbd->keycode[i] != ATKBD_KEY_NULL &&
1080 atkbd->keycode[i] < ATKBD_SPECIAL) {
1075 __set_bit(atkbd->keycode[i], input_dev->keybit); 1081 __set_bit(atkbd->keycode[i], input_dev->keybit);
1082 }
1083 }
1076} 1084}
1077 1085
1078/* 1086/*
@@ -1100,12 +1108,14 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
1100 1108
1101 switch (serio->id.type) { 1109 switch (serio->id.type) {
1102 1110
1103 case SERIO_8042_XL: 1111 case SERIO_8042_XL:
1104 atkbd->translated = 1; 1112 atkbd->translated = true;
1105 case SERIO_8042: 1113 /* Fall through */
1106 if (serio->write) 1114
1107 atkbd->write = 1; 1115 case SERIO_8042:
1108 break; 1116 if (serio->write)
1117 atkbd->write = true;
1118 break;
1109 } 1119 }
1110 1120
1111 atkbd->softraw = atkbd_softraw; 1121 atkbd->softraw = atkbd_softraw;
@@ -1113,7 +1123,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
1113 atkbd->scroll = atkbd_scroll; 1123 atkbd->scroll = atkbd_scroll;
1114 1124
1115 if (atkbd->softrepeat) 1125 if (atkbd->softrepeat)
1116 atkbd->softraw = 1; 1126 atkbd->softraw = true;
1117 1127
1118 serio_set_drvdata(serio, atkbd); 1128 serio_set_drvdata(serio, atkbd);
1119 1129
@@ -1172,7 +1182,8 @@ static int atkbd_reconnect(struct serio *serio)
1172 int retval = -1; 1182 int retval = -1;
1173 1183
1174 if (!atkbd || !drv) { 1184 if (!atkbd || !drv) {
1175 printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n"); 1185 dev_dbg(&serio->dev,
1186 "reconnect request, but serio is disconnected, ignoring...\n");
1176 return -1; 1187 return -1;
1177 } 1188 }
1178 1189
@@ -1286,7 +1297,8 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
1286 struct input_dev *old_dev, *new_dev; 1297 struct input_dev *old_dev, *new_dev;
1287 unsigned long value; 1298 unsigned long value;
1288 int err; 1299 int err;
1289 unsigned char old_extra, old_set; 1300 bool old_extra;
1301 unsigned char old_set;
1290 1302
1291 if (!atkbd->write) 1303 if (!atkbd->write)
1292 return -EIO; 1304 return -EIO;
@@ -1369,7 +1381,7 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou
1369 struct input_dev *old_dev, *new_dev; 1381 struct input_dev *old_dev, *new_dev;
1370 unsigned long value; 1382 unsigned long value;
1371 int err; 1383 int err;
1372 unsigned char old_scroll; 1384 bool old_scroll;
1373 1385
1374 if (strict_strtoul(buf, 10, &value) || value > 1) 1386 if (strict_strtoul(buf, 10, &value) || value > 1)
1375 return -EINVAL; 1387 return -EINVAL;
@@ -1413,7 +1425,8 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
1413 struct input_dev *old_dev, *new_dev; 1425 struct input_dev *old_dev, *new_dev;
1414 unsigned long value; 1426 unsigned long value;
1415 int err; 1427 int err;
1416 unsigned char old_set, old_extra; 1428 unsigned char old_set;
1429 bool old_extra;
1417 1430
1418 if (!atkbd->write) 1431 if (!atkbd->write)
1419 return -EIO; 1432 return -EIO;
@@ -1463,7 +1476,7 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
1463 struct input_dev *old_dev, *new_dev; 1476 struct input_dev *old_dev, *new_dev;
1464 unsigned long value; 1477 unsigned long value;
1465 int err; 1478 int err;
1466 unsigned char old_softrepeat, old_softraw; 1479 bool old_softrepeat, old_softraw;
1467 1480
1468 if (!atkbd->write) 1481 if (!atkbd->write)
1469 return -EIO; 1482 return -EIO;
@@ -1483,7 +1496,7 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
1483 atkbd->dev = new_dev; 1496 atkbd->dev = new_dev;
1484 atkbd->softrepeat = value; 1497 atkbd->softrepeat = value;
1485 if (atkbd->softrepeat) 1498 if (atkbd->softrepeat)
1486 atkbd->softraw = 1; 1499 atkbd->softraw = true;
1487 atkbd_set_device_attrs(atkbd); 1500 atkbd_set_device_attrs(atkbd);
1488 1501
1489 err = input_register_device(atkbd->dev); 1502 err = input_register_device(atkbd->dev);
@@ -1513,7 +1526,7 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co
1513 struct input_dev *old_dev, *new_dev; 1526 struct input_dev *old_dev, *new_dev;
1514 unsigned long value; 1527 unsigned long value;
1515 int err; 1528 int err;
1516 unsigned char old_softraw; 1529 bool old_softraw;
1517 1530
1518 if (strict_strtoul(buf, 10, &value) || value > 1) 1531 if (strict_strtoul(buf, 10, &value) || value > 1)
1519 return -EINVAL; 1532 return -EINVAL;
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index e45740429f7..bd25a3af166 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -69,7 +69,7 @@ struct ep93xx_keypad {
69 69
70 void __iomem *mmio_base; 70 void __iomem *mmio_base;
71 71
72 unsigned int matrix_keycodes[EP93XX_MATRIX_SIZE]; 72 unsigned short keycodes[EP93XX_MATRIX_SIZE];
73 73
74 int key1; 74 int key1;
75 int key2; 75 int key2;
@@ -79,24 +79,6 @@ struct ep93xx_keypad {
79 bool enabled; 79 bool enabled;
80}; 80};
81 81
82static void ep93xx_keypad_build_keycode(struct ep93xx_keypad *keypad)
83{
84 struct ep93xx_keypad_platform_data *pdata = keypad->pdata;
85 struct input_dev *input_dev = keypad->input_dev;
86 unsigned int *key;
87 int i;
88
89 key = &pdata->matrix_key_map[0];
90 for (i = 0; i < pdata->matrix_key_map_size; i++, key++) {
91 int row = KEY_ROW(*key);
92 int col = KEY_COL(*key);
93 int code = KEY_VAL(*key);
94
95 keypad->matrix_keycodes[(row << 3) + col] = code;
96 __set_bit(code, input_dev->keybit);
97 }
98}
99
100static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id) 82static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id)
101{ 83{
102 struct ep93xx_keypad *keypad = dev_id; 84 struct ep93xx_keypad *keypad = dev_id;
@@ -107,10 +89,10 @@ static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id)
107 status = __raw_readl(keypad->mmio_base + KEY_REG); 89 status = __raw_readl(keypad->mmio_base + KEY_REG);
108 90
109 keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT; 91 keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT;
110 key1 = keypad->matrix_keycodes[keycode]; 92 key1 = keypad->keycodes[keycode];
111 93
112 keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT; 94 keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT;
113 key2 = keypad->matrix_keycodes[keycode]; 95 key2 = keypad->keycodes[keycode];
114 96
115 if (status & KEY_REG_2KEYS) { 97 if (status & KEY_REG_2KEYS) {
116 if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1) 98 if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1)
@@ -256,6 +238,7 @@ static int ep93xx_keypad_resume(struct platform_device *pdev)
256static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) 238static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
257{ 239{
258 struct ep93xx_keypad *keypad; 240 struct ep93xx_keypad *keypad;
241 const struct matrix_keymap_data *keymap_data;
259 struct input_dev *input_dev; 242 struct input_dev *input_dev;
260 struct resource *res; 243 struct resource *res;
261 int err; 244 int err;
@@ -270,6 +253,12 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
270 goto failed_free; 253 goto failed_free;
271 } 254 }
272 255
256 keymap_data = keypad->pdata->keymap_data;
257 if (!keymap_data) {
258 err = -EINVAL;
259 goto failed_free;
260 }
261
273 keypad->irq = platform_get_irq(pdev, 0); 262 keypad->irq = platform_get_irq(pdev, 0);
274 if (!keypad->irq) { 263 if (!keypad->irq) {
275 err = -ENXIO; 264 err = -ENXIO;
@@ -317,9 +306,9 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
317 input_dev->open = ep93xx_keypad_open; 306 input_dev->open = ep93xx_keypad_open;
318 input_dev->close = ep93xx_keypad_close; 307 input_dev->close = ep93xx_keypad_close;
319 input_dev->dev.parent = &pdev->dev; 308 input_dev->dev.parent = &pdev->dev;
320 input_dev->keycode = keypad->matrix_keycodes; 309 input_dev->keycode = keypad->keycodes;
321 input_dev->keycodesize = sizeof(keypad->matrix_keycodes[0]); 310 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
322 input_dev->keycodemax = ARRAY_SIZE(keypad->matrix_keycodes); 311 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
323 312
324 input_set_drvdata(input_dev, keypad); 313 input_set_drvdata(input_dev, keypad);
325 314
@@ -327,7 +316,8 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
327 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) 316 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT)
328 input_dev->evbit[0] |= BIT_MASK(EV_REP); 317 input_dev->evbit[0] |= BIT_MASK(EV_REP);
329 318
330 ep93xx_keypad_build_keycode(keypad); 319 matrix_keypad_build_keymap(keymap_data, 3,
320 input_dev->keycode, input_dev->keybit);
331 platform_set_drvdata(pdev, keypad); 321 platform_set_drvdata(pdev, keypad);
332 322
333 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, 323 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler,
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 1aff3b76eff..2b708aa8555 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -30,13 +30,289 @@ struct gpio_button_data {
30 struct input_dev *input; 30 struct input_dev *input;
31 struct timer_list timer; 31 struct timer_list timer;
32 struct work_struct work; 32 struct work_struct work;
33 bool disabled;
33}; 34};
34 35
35struct gpio_keys_drvdata { 36struct gpio_keys_drvdata {
36 struct input_dev *input; 37 struct input_dev *input;
38 struct mutex disable_lock;
39 unsigned int n_buttons;
37 struct gpio_button_data data[0]; 40 struct gpio_button_data data[0];
38}; 41};
39 42
43/*
44 * SYSFS interface for enabling/disabling keys and switches:
45 *
46 * There are 4 attributes under /sys/devices/platform/gpio-keys/
47 * keys [ro] - bitmap of keys (EV_KEY) which can be
48 * disabled
49 * switches [ro] - bitmap of switches (EV_SW) which can be
50 * disabled
51 * disabled_keys [rw] - bitmap of keys currently disabled
52 * disabled_switches [rw] - bitmap of switches currently disabled
53 *
54 * Userland can change these values and hence disable event generation
55 * for each key (or switch). Disabling a key means its interrupt line
56 * is disabled.
57 *
58 * For example, if we have following switches set up as gpio-keys:
59 * SW_DOCK = 5
60 * SW_CAMERA_LENS_COVER = 9
61 * SW_KEYPAD_SLIDE = 10
62 * SW_FRONT_PROXIMITY = 11
63 * This is read from switches:
64 * 11-9,5
65 * Next we want to disable proximity (11) and dock (5), we write:
66 * 11,5
67 * to file disabled_switches. Now proximity and dock IRQs are disabled.
68 * This can be verified by reading the file disabled_switches:
69 * 11,5
70 * If we now want to enable proximity (11) switch we write:
71 * 5
72 * to disabled_switches.
73 *
74 * We can disable only those keys which don't allow sharing the irq.
75 */
76
77/**
78 * get_n_events_by_type() - returns maximum number of events per @type
79 * @type: type of button (%EV_KEY, %EV_SW)
80 *
81 * Return value of this function can be used to allocate bitmap
82 * large enough to hold all bits for given type.
83 */
84static inline int get_n_events_by_type(int type)
85{
86 BUG_ON(type != EV_SW && type != EV_KEY);
87
88 return (type == EV_KEY) ? KEY_CNT : SW_CNT;
89}
90
91/**
92 * gpio_keys_disable_button() - disables given GPIO button
93 * @bdata: button data for button to be disabled
94 *
95 * Disables button pointed by @bdata. This is done by masking
96 * IRQ line. After this function is called, button won't generate
97 * input events anymore. Note that one can only disable buttons
98 * that don't share IRQs.
99 *
100 * Make sure that @bdata->disable_lock is locked when entering
101 * this function to avoid races when concurrent threads are
102 * disabling buttons at the same time.
103 */
104static void gpio_keys_disable_button(struct gpio_button_data *bdata)
105{
106 if (!bdata->disabled) {
107 /*
108 * Disable IRQ and possible debouncing timer.
109 */
110 disable_irq(gpio_to_irq(bdata->button->gpio));
111 if (bdata->button->debounce_interval)
112 del_timer_sync(&bdata->timer);
113
114 bdata->disabled = true;
115 }
116}
117
118/**
119 * gpio_keys_enable_button() - enables given GPIO button
120 * @bdata: button data for button to be disabled
121 *
122 * Enables given button pointed by @bdata.
123 *
124 * Make sure that @bdata->disable_lock is locked when entering
125 * this function to avoid races with concurrent threads trying
126 * to enable the same button at the same time.
127 */
128static void gpio_keys_enable_button(struct gpio_button_data *bdata)
129{
130 if (bdata->disabled) {
131 enable_irq(gpio_to_irq(bdata->button->gpio));
132 bdata->disabled = false;
133 }
134}
135
136/**
137 * gpio_keys_attr_show_helper() - fill in stringified bitmap of buttons
138 * @ddata: pointer to drvdata
139 * @buf: buffer where stringified bitmap is written
140 * @type: button type (%EV_KEY, %EV_SW)
141 * @only_disabled: does caller want only those buttons that are
142 * currently disabled or all buttons that can be
143 * disabled
144 *
145 * This function writes buttons that can be disabled to @buf. If
146 * @only_disabled is true, then @buf contains only those buttons
147 * that are currently disabled. Returns 0 on success or negative
148 * errno on failure.
149 */
150static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,
151 char *buf, unsigned int type,
152 bool only_disabled)
153{
154 int n_events = get_n_events_by_type(type);
155 unsigned long *bits;
156 ssize_t ret;
157 int i;
158
159 bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL);
160 if (!bits)
161 return -ENOMEM;
162
163 for (i = 0; i < ddata->n_buttons; i++) {
164 struct gpio_button_data *bdata = &ddata->data[i];
165
166 if (bdata->button->type != type)
167 continue;
168
169 if (only_disabled && !bdata->disabled)
170 continue;
171
172 __set_bit(bdata->button->code, bits);
173 }
174
175 ret = bitmap_scnlistprintf(buf, PAGE_SIZE - 2, bits, n_events);
176 buf[ret++] = '\n';
177 buf[ret] = '\0';
178
179 kfree(bits);
180
181 return ret;
182}
183
184/**
185 * gpio_keys_attr_store_helper() - enable/disable buttons based on given bitmap
186 * @ddata: pointer to drvdata
187 * @buf: buffer from userspace that contains stringified bitmap
188 * @type: button type (%EV_KEY, %EV_SW)
189 *
190 * This function parses stringified bitmap from @buf and disables/enables
191 * GPIO buttons accordinly. Returns 0 on success and negative error
192 * on failure.
193 */
194static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
195 const char *buf, unsigned int type)
196{
197 int n_events = get_n_events_by_type(type);
198 unsigned long *bits;
199 ssize_t error;
200 int i;
201
202 bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL);
203 if (!bits)
204 return -ENOMEM;
205
206 error = bitmap_parselist(buf, bits, n_events);
207 if (error)
208 goto out;
209
210 /* First validate */
211 for (i = 0; i < ddata->n_buttons; i++) {
212 struct gpio_button_data *bdata = &ddata->data[i];
213
214 if (bdata->button->type != type)
215 continue;
216
217 if (test_bit(bdata->button->code, bits) &&
218 !bdata->button->can_disable) {
219 error = -EINVAL;
220 goto out;
221 }
222 }
223
224 mutex_lock(&ddata->disable_lock);
225
226 for (i = 0; i < ddata->n_buttons; i++) {
227 struct gpio_button_data *bdata = &ddata->data[i];
228
229 if (bdata->button->type != type)
230 continue;
231
232 if (test_bit(bdata->button->code, bits))
233 gpio_keys_disable_button(bdata);
234 else
235 gpio_keys_enable_button(bdata);
236 }
237
238 mutex_unlock(&ddata->disable_lock);
239
240out:
241 kfree(bits);
242 return error;
243}
244
245#define ATTR_SHOW_FN(name, type, only_disabled) \
246static ssize_t gpio_keys_show_##name(struct device *dev, \
247 struct device_attribute *attr, \
248 char *buf) \
249{ \
250 struct platform_device *pdev = to_platform_device(dev); \
251 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); \
252 \
253 return gpio_keys_attr_show_helper(ddata, buf, \
254 type, only_disabled); \
255}
256
257ATTR_SHOW_FN(keys, EV_KEY, false);
258ATTR_SHOW_FN(switches, EV_SW, false);
259ATTR_SHOW_FN(disabled_keys, EV_KEY, true);
260ATTR_SHOW_FN(disabled_switches, EV_SW, true);
261
262/*
263 * ATTRIBUTES:
264 *
265 * /sys/devices/platform/gpio-keys/keys [ro]
266 * /sys/devices/platform/gpio-keys/switches [ro]
267 */
268static DEVICE_ATTR(keys, S_IRUGO, gpio_keys_show_keys, NULL);
269static DEVICE_ATTR(switches, S_IRUGO, gpio_keys_show_switches, NULL);
270
271#define ATTR_STORE_FN(name, type) \
272static ssize_t gpio_keys_store_##name(struct device *dev, \
273 struct device_attribute *attr, \
274 const char *buf, \
275 size_t count) \
276{ \
277 struct platform_device *pdev = to_platform_device(dev); \
278 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); \
279 ssize_t error; \
280 \
281 error = gpio_keys_attr_store_helper(ddata, buf, type); \
282 if (error) \
283 return error; \
284 \
285 return count; \
286}
287
288ATTR_STORE_FN(disabled_keys, EV_KEY);
289ATTR_STORE_FN(disabled_switches, EV_SW);
290
291/*
292 * ATTRIBUTES:
293 *
294 * /sys/devices/platform/gpio-keys/disabled_keys [rw]
295 * /sys/devices/platform/gpio-keys/disables_switches [rw]
296 */
297static DEVICE_ATTR(disabled_keys, S_IWUSR | S_IRUGO,
298 gpio_keys_show_disabled_keys,
299 gpio_keys_store_disabled_keys);
300static DEVICE_ATTR(disabled_switches, S_IWUSR | S_IRUGO,
301 gpio_keys_show_disabled_switches,
302 gpio_keys_store_disabled_switches);
303
304static struct attribute *gpio_keys_attrs[] = {
305 &dev_attr_keys.attr,
306 &dev_attr_switches.attr,
307 &dev_attr_disabled_keys.attr,
308 &dev_attr_disabled_switches.attr,
309 NULL,
310};
311
312static struct attribute_group gpio_keys_attr_group = {
313 .attrs = gpio_keys_attrs,
314};
315
40static void gpio_keys_report_event(struct gpio_button_data *bdata) 316static void gpio_keys_report_event(struct gpio_button_data *bdata)
41{ 317{
42 struct gpio_keys_button *button = bdata->button; 318 struct gpio_keys_button *button = bdata->button;
@@ -79,11 +355,13 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
79 return IRQ_HANDLED; 355 return IRQ_HANDLED;
80} 356}
81 357
82static int __devinit gpio_keys_setup_key(struct device *dev, 358static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
83 struct gpio_button_data *bdata, 359 struct gpio_button_data *bdata,
84 struct gpio_keys_button *button) 360 struct gpio_keys_button *button)
85{ 361{
86 char *desc = button->desc ? button->desc : "gpio_keys"; 362 char *desc = button->desc ? button->desc : "gpio_keys";
363 struct device *dev = &pdev->dev;
364 unsigned long irqflags;
87 int irq, error; 365 int irq, error;
88 366
89 setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata); 367 setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata);
@@ -112,10 +390,15 @@ static int __devinit gpio_keys_setup_key(struct device *dev,
112 goto fail3; 390 goto fail3;
113 } 391 }
114 392
115 error = request_irq(irq, gpio_keys_isr, 393 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
116 IRQF_SHARED | 394 /*
117 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 395 * If platform has specified that the button can be disabled,
118 desc, bdata); 396 * we don't want it to share the interrupt line.
397 */
398 if (!button->can_disable)
399 irqflags |= IRQF_SHARED;
400
401 error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
119 if (error) { 402 if (error) {
120 dev_err(dev, "Unable to claim irq %d; error %d\n", 403 dev_err(dev, "Unable to claim irq %d; error %d\n",
121 irq, error); 404 irq, error);
@@ -149,6 +432,10 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
149 goto fail1; 432 goto fail1;
150 } 433 }
151 434
435 ddata->input = input;
436 ddata->n_buttons = pdata->nbuttons;
437 mutex_init(&ddata->disable_lock);
438
152 platform_set_drvdata(pdev, ddata); 439 platform_set_drvdata(pdev, ddata);
153 440
154 input->name = pdev->name; 441 input->name = pdev->name;
@@ -164,8 +451,6 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
164 if (pdata->rep) 451 if (pdata->rep)
165 __set_bit(EV_REP, input->evbit); 452 __set_bit(EV_REP, input->evbit);
166 453
167 ddata->input = input;
168
169 for (i = 0; i < pdata->nbuttons; i++) { 454 for (i = 0; i < pdata->nbuttons; i++) {
170 struct gpio_keys_button *button = &pdata->buttons[i]; 455 struct gpio_keys_button *button = &pdata->buttons[i];
171 struct gpio_button_data *bdata = &ddata->data[i]; 456 struct gpio_button_data *bdata = &ddata->data[i];
@@ -174,7 +459,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
174 bdata->input = input; 459 bdata->input = input;
175 bdata->button = button; 460 bdata->button = button;
176 461
177 error = gpio_keys_setup_key(dev, bdata, button); 462 error = gpio_keys_setup_key(pdev, bdata, button);
178 if (error) 463 if (error)
179 goto fail2; 464 goto fail2;
180 465
@@ -184,13 +469,20 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
184 input_set_capability(input, type, button->code); 469 input_set_capability(input, type, button->code);
185 } 470 }
186 471
187 error = input_register_device(input); 472 error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group);
188 if (error) { 473 if (error) {
189 dev_err(dev, "Unable to register input device, " 474 dev_err(dev, "Unable to export keys/switches, error: %d\n",
190 "error: %d\n", error); 475 error);
191 goto fail2; 476 goto fail2;
192 } 477 }
193 478
479 error = input_register_device(input);
480 if (error) {
481 dev_err(dev, "Unable to register input device, error: %d\n",
482 error);
483 goto fail3;
484 }
485
194 /* get current state of buttons */ 486 /* get current state of buttons */
195 for (i = 0; i < pdata->nbuttons; i++) 487 for (i = 0; i < pdata->nbuttons; i++)
196 gpio_keys_report_event(&ddata->data[i]); 488 gpio_keys_report_event(&ddata->data[i]);
@@ -200,6 +492,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
200 492
201 return 0; 493 return 0;
202 494
495 fail3:
496 sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
203 fail2: 497 fail2:
204 while (--i >= 0) { 498 while (--i >= 0) {
205 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 499 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);
@@ -224,6 +518,8 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
224 struct input_dev *input = ddata->input; 518 struct input_dev *input = ddata->input;
225 int i; 519 int i;
226 520
521 sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
522
227 device_init_wakeup(&pdev->dev, 0); 523 device_init_wakeup(&pdev->dev, 0);
228 524
229 for (i = 0; i < pdata->nbuttons; i++) { 525 for (i = 0; i < pdata->nbuttons; i++) {
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
new file mode 100644
index 00000000000..2ee5b798024
--- /dev/null
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -0,0 +1,594 @@
1/*
2 * Driver for the IMX keypad port.
3 * Copyright (C) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * <<Power management needs to be implemented>>.
10 */
11
12#include <linux/clk.h>
13#include <linux/delay.h>
14#include <linux/device.h>
15#include <linux/err.h>
16#include <linux/init.h>
17#include <linux/input/matrix_keypad.h>
18#include <linux/interrupt.h>
19#include <linux/io.h>
20#include <linux/jiffies.h>
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/platform_device.h>
24#include <linux/timer.h>
25
26/*
27 * Keypad Controller registers (halfword)
28 */
29#define KPCR 0x00 /* Keypad Control Register */
30
31#define KPSR 0x02 /* Keypad Status Register */
32#define KBD_STAT_KPKD (0x1 << 0) /* Key Press Interrupt Status bit (w1c) */
33#define KBD_STAT_KPKR (0x1 << 1) /* Key Release Interrupt Status bit (w1c) */
34#define KBD_STAT_KDSC (0x1 << 2) /* Key Depress Synch Chain Status bit (w1c)*/
35#define KBD_STAT_KRSS (0x1 << 3) /* Key Release Synch Status bit (w1c)*/
36#define KBD_STAT_KDIE (0x1 << 8) /* Key Depress Interrupt Enable Status bit */
37#define KBD_STAT_KRIE (0x1 << 9) /* Key Release Interrupt Enable */
38#define KBD_STAT_KPPEN (0x1 << 10) /* Keypad Clock Enable */
39
40#define KDDR 0x04 /* Keypad Data Direction Register */
41#define KPDR 0x06 /* Keypad Data Register */
42
43#define MAX_MATRIX_KEY_ROWS 8
44#define MAX_MATRIX_KEY_COLS 8
45#define MATRIX_ROW_SHIFT 3
46
47#define MAX_MATRIX_KEY_NUM (MAX_MATRIX_KEY_ROWS * MAX_MATRIX_KEY_COLS)
48
49struct imx_keypad {
50
51 struct clk *clk;
52 struct input_dev *input_dev;
53 void __iomem *mmio_base;
54
55 int irq;
56 struct timer_list check_matrix_timer;
57
58 /*
59 * The matrix is stable only if no changes are detected after
60 * IMX_KEYPAD_SCANS_FOR_STABILITY scans
61 */
62#define IMX_KEYPAD_SCANS_FOR_STABILITY 3
63 int stable_count;
64
65 bool enabled;
66
67 /* Masks for enabled rows/cols */
68 unsigned short rows_en_mask;
69 unsigned short cols_en_mask;
70
71 unsigned short keycodes[MAX_MATRIX_KEY_NUM];
72
73 /*
74 * Matrix states:
75 * -stable: achieved after a complete debounce process.
76 * -unstable: used in the debouncing process.
77 */
78 unsigned short matrix_stable_state[MAX_MATRIX_KEY_COLS];
79 unsigned short matrix_unstable_state[MAX_MATRIX_KEY_COLS];
80};
81
82/* Scan the matrix and return the new state in *matrix_volatile_state. */
83static void imx_keypad_scan_matrix(struct imx_keypad *keypad,
84 unsigned short *matrix_volatile_state)
85{
86 int col;
87 unsigned short reg_val;
88
89 for (col = 0; col < MAX_MATRIX_KEY_COLS; col++) {
90 if ((keypad->cols_en_mask & (1 << col)) == 0)
91 continue;
92 /*
93 * Discharge keypad capacitance:
94 * 2. write 1s on column data.
95 * 3. configure columns as totem-pole to discharge capacitance.
96 * 4. configure columns as open-drain.
97 */
98 reg_val = readw(keypad->mmio_base + KPDR);
99 reg_val |= 0xff00;
100 writew(reg_val, keypad->mmio_base + KPDR);
101
102 reg_val = readw(keypad->mmio_base + KPCR);
103 reg_val &= ~((keypad->cols_en_mask & 0xff) << 8);
104 writew(reg_val, keypad->mmio_base + KPCR);
105
106 udelay(2);
107
108 reg_val = readw(keypad->mmio_base + KPCR);
109 reg_val |= (keypad->cols_en_mask & 0xff) << 8;
110 writew(reg_val, keypad->mmio_base + KPCR);
111
112 /*
113 * 5. Write a single column to 0, others to 1.
114 * 6. Sample row inputs and save data.
115 * 7. Repeat steps 2 - 6 for remaining columns.
116 */
117 reg_val = readw(keypad->mmio_base + KPDR);
118 reg_val &= ~(1 << (8 + col));
119 writew(reg_val, keypad->mmio_base + KPDR);
120
121 /*
122 * Delay added to avoid propagating the 0 from column to row
123 * when scanning.
124 */
125 udelay(5);
126
127 /*
128 * 1s in matrix_volatile_state[col] means key pressures
129 * throw data from non enabled rows.
130 */
131 reg_val = readw(keypad->mmio_base + KPDR);
132 matrix_volatile_state[col] = (~reg_val) & keypad->rows_en_mask;
133 }
134
135 /*
136 * Return in standby mode:
137 * 9. write 0s to columns
138 */
139 reg_val = readw(keypad->mmio_base + KPDR);
140 reg_val &= 0x00ff;
141 writew(reg_val, keypad->mmio_base + KPDR);
142}
143
144/*
145 * Compare the new matrix state (volatile) with the stable one stored in
146 * keypad->matrix_stable_state and fire events if changes are detected.
147 */
148static void imx_keypad_fire_events(struct imx_keypad *keypad,
149 unsigned short *matrix_volatile_state)
150{
151 struct input_dev *input_dev = keypad->input_dev;
152 int row, col;
153
154 for (col = 0; col < MAX_MATRIX_KEY_COLS; col++) {
155 unsigned short bits_changed;
156 int code;
157
158 if ((keypad->cols_en_mask & (1 << col)) == 0)
159 continue; /* Column is not enabled */
160
161 bits_changed = keypad->matrix_stable_state[col] ^
162 matrix_volatile_state[col];
163
164 if (bits_changed == 0)
165 continue; /* Column does not contain changes */
166
167 for (row = 0; row < MAX_MATRIX_KEY_ROWS; row++) {
168 if ((keypad->rows_en_mask & (1 << row)) == 0)
169 continue; /* Row is not enabled */
170 if ((bits_changed & (1 << row)) == 0)
171 continue; /* Row does not contain changes */
172
173 code = MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT);
174 input_event(input_dev, EV_MSC, MSC_SCAN, code);
175 input_report_key(input_dev, keypad->keycodes[code],
176 matrix_volatile_state[col] & (1 << row));
177 dev_dbg(&input_dev->dev, "Event code: %d, val: %d",
178 keypad->keycodes[code],
179 matrix_volatile_state[col] & (1 << row));
180 }
181 }
182 input_sync(input_dev);
183}
184
185/*
186 * imx_keypad_check_for_events is the timer handler.
187 */
188static void imx_keypad_check_for_events(unsigned long data)
189{
190 struct imx_keypad *keypad = (struct imx_keypad *) data;
191 unsigned short matrix_volatile_state[MAX_MATRIX_KEY_COLS];
192 unsigned short reg_val;
193 bool state_changed, is_zero_matrix;
194 int i;
195
196 memset(matrix_volatile_state, 0, sizeof(matrix_volatile_state));
197
198 imx_keypad_scan_matrix(keypad, matrix_volatile_state);
199
200 state_changed = false;
201 for (i = 0; i < MAX_MATRIX_KEY_COLS; i++) {
202 if ((keypad->cols_en_mask & (1 << i)) == 0)
203 continue;
204
205 if (keypad->matrix_unstable_state[i] ^ matrix_volatile_state[i]) {
206 state_changed = true;
207 break;
208 }
209 }
210
211 /*
212 * If the matrix state is changed from the previous scan
213 * (Re)Begin the debouncing process, saving the new state in
214 * keypad->matrix_unstable_state.
215 * else
216 * Increase the count of number of scans with a stable state.
217 */
218 if (state_changed) {
219 memcpy(keypad->matrix_unstable_state, matrix_volatile_state,
220 sizeof(matrix_volatile_state));
221 keypad->stable_count = 0;
222 } else
223 keypad->stable_count++;
224
225 /*
226 * If the matrix is not as stable as we want reschedule scan
227 * in the near future.
228 */
229 if (keypad->stable_count < IMX_KEYPAD_SCANS_FOR_STABILITY) {
230 mod_timer(&keypad->check_matrix_timer,
231 jiffies + msecs_to_jiffies(10));
232 return;
233 }
234
235 /*
236 * If the matrix state is stable, fire the events and save the new
237 * stable state. Note, if the matrix is kept stable for longer
238 * (keypad->stable_count > IMX_KEYPAD_SCANS_FOR_STABILITY) all
239 * events have already been generated.
240 */
241 if (keypad->stable_count == IMX_KEYPAD_SCANS_FOR_STABILITY) {
242 imx_keypad_fire_events(keypad, matrix_volatile_state);
243
244 memcpy(keypad->matrix_stable_state, matrix_volatile_state,
245 sizeof(matrix_volatile_state));
246 }
247
248 is_zero_matrix = true;
249 for (i = 0; i < MAX_MATRIX_KEY_COLS; i++) {
250 if (matrix_volatile_state[i] != 0) {
251 is_zero_matrix = false;
252 break;
253 }
254 }
255
256
257 if (is_zero_matrix) {
258 /*
259 * All keys have been released. Enable only the KDI
260 * interrupt for future key presses (clear the KDI
261 * status bit and its sync chain before that).
262 */
263 reg_val = readw(keypad->mmio_base + KPSR);
264 reg_val |= KBD_STAT_KPKD | KBD_STAT_KDSC;
265 writew(reg_val, keypad->mmio_base + KPSR);
266
267 reg_val = readw(keypad->mmio_base + KPSR);
268 reg_val |= KBD_STAT_KDIE;
269 reg_val &= ~KBD_STAT_KRIE;
270 writew(reg_val, keypad->mmio_base + KPSR);
271 } else {
272 /*
273 * Some keys are still pressed. Schedule a rescan in
274 * attempt to detect multiple key presses and enable
275 * the KRI interrupt to react quickly to key release
276 * event.
277 */
278 mod_timer(&keypad->check_matrix_timer,
279 jiffies + msecs_to_jiffies(60));
280
281 reg_val = readw(keypad->mmio_base + KPSR);
282 reg_val |= KBD_STAT_KPKR | KBD_STAT_KRSS;
283 writew(reg_val, keypad->mmio_base + KPSR);
284
285 reg_val = readw(keypad->mmio_base + KPSR);
286 reg_val |= KBD_STAT_KRIE;
287 reg_val &= ~KBD_STAT_KDIE;
288 writew(reg_val, keypad->mmio_base + KPSR);
289 }
290}
291
292static irqreturn_t imx_keypad_irq_handler(int irq, void *dev_id)
293{
294 struct imx_keypad *keypad = dev_id;
295 unsigned short reg_val;
296
297 reg_val = readw(keypad->mmio_base + KPSR);
298
299 /* Disable both interrupt types */
300 reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE);
301 /* Clear interrupts status bits */
302 reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD;
303 writew(reg_val, keypad->mmio_base + KPSR);
304
305 if (keypad->enabled) {
306 /* The matrix is supposed to be changed */
307 keypad->stable_count = 0;
308
309 /* Schedule the scanning procedure near in the future */
310 mod_timer(&keypad->check_matrix_timer,
311 jiffies + msecs_to_jiffies(2));
312 }
313
314 return IRQ_HANDLED;
315}
316
317static void imx_keypad_config(struct imx_keypad *keypad)
318{
319 unsigned short reg_val;
320
321 /*
322 * Include enabled rows in interrupt generation (KPCR[7:0])
323 * Configure keypad columns as open-drain (KPCR[15:8])
324 */
325 reg_val = readw(keypad->mmio_base + KPCR);
326 reg_val |= keypad->rows_en_mask & 0xff; /* rows */
327 reg_val |= (keypad->cols_en_mask & 0xff) << 8; /* cols */
328 writew(reg_val, keypad->mmio_base + KPCR);
329
330 /* Write 0's to KPDR[15:8] (Colums) */
331 reg_val = readw(keypad->mmio_base + KPDR);
332 reg_val &= 0x00ff;
333 writew(reg_val, keypad->mmio_base + KPDR);
334
335 /* Configure columns as output, rows as input (KDDR[15:0]) */
336 writew(0xff00, keypad->mmio_base + KDDR);
337
338 /*
339 * Clear Key Depress and Key Release status bit.
340 * Clear both synchronizer chain.
341 */
342 reg_val = readw(keypad->mmio_base + KPSR);
343 reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD |
344 KBD_STAT_KDSC | KBD_STAT_KRSS;
345 writew(reg_val, keypad->mmio_base + KPSR);
346
347 /* Enable KDI and disable KRI (avoid false release events). */
348 reg_val |= KBD_STAT_KDIE;
349 reg_val &= ~KBD_STAT_KRIE;
350 writew(reg_val, keypad->mmio_base + KPSR);
351}
352
353static void imx_keypad_inhibit(struct imx_keypad *keypad)
354{
355 unsigned short reg_val;
356
357 /* Inhibit KDI and KRI interrupts. */
358 reg_val = readw(keypad->mmio_base + KPSR);
359 reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE);
360 writew(reg_val, keypad->mmio_base + KPSR);
361
362 /* Colums as open drain and disable all rows */
363 writew(0xff00, keypad->mmio_base + KPCR);
364}
365
366static void imx_keypad_close(struct input_dev *dev)
367{
368 struct imx_keypad *keypad = input_get_drvdata(dev);
369
370 dev_dbg(&dev->dev, ">%s\n", __func__);
371
372 /* Mark keypad as being inactive */
373 keypad->enabled = false;
374 synchronize_irq(keypad->irq);
375 del_timer_sync(&keypad->check_matrix_timer);
376
377 imx_keypad_inhibit(keypad);
378
379 /* Disable clock unit */
380 clk_disable(keypad->clk);
381}
382
383static int imx_keypad_open(struct input_dev *dev)
384{
385 struct imx_keypad *keypad = input_get_drvdata(dev);
386
387 dev_dbg(&dev->dev, ">%s\n", __func__);
388
389 /* We became active from now */
390 keypad->enabled = true;
391
392 /* Enable the kpp clock */
393 clk_enable(keypad->clk);
394 imx_keypad_config(keypad);
395
396 /* Sanity control, not all the rows must be actived now. */
397 if ((readw(keypad->mmio_base + KPDR) & keypad->rows_en_mask) == 0) {
398 dev_err(&dev->dev,
399 "too many keys pressed, control pins initialisation\n");
400 goto open_err;
401 }
402
403 return 0;
404
405open_err:
406 imx_keypad_close(dev);
407 return -EIO;
408}
409
410static int __devinit imx_keypad_probe(struct platform_device *pdev)
411{
412 const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data;
413 struct imx_keypad *keypad;
414 struct input_dev *input_dev;
415 struct resource *res;
416 int irq, error, i;
417
418 if (keymap_data == NULL) {
419 dev_err(&pdev->dev, "no keymap defined\n");
420 return -EINVAL;
421 }
422
423 irq = platform_get_irq(pdev, 0);
424 if (irq < 0) {
425 dev_err(&pdev->dev, "no irq defined in platform data\n");
426 return -EINVAL;
427 }
428
429 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
430 if (res == NULL) {
431 dev_err(&pdev->dev, "no I/O memory defined in platform data\n");
432 return -EINVAL;
433 }
434
435 res = request_mem_region(res->start, resource_size(res), pdev->name);
436 if (res == NULL) {
437 dev_err(&pdev->dev, "failed to request I/O memory\n");
438 return -EBUSY;
439 }
440
441 input_dev = input_allocate_device();
442 if (!input_dev) {
443 dev_err(&pdev->dev, "failed to allocate the input device\n");
444 error = -ENOMEM;
445 goto failed_rel_mem;
446 }
447
448 keypad = kzalloc(sizeof(struct imx_keypad), GFP_KERNEL);
449 if (!keypad) {
450 dev_err(&pdev->dev, "not enough memory for driver data\n");
451 error = -ENOMEM;
452 goto failed_free_input;
453 }
454
455 keypad->input_dev = input_dev;
456 keypad->irq = irq;
457 keypad->stable_count = 0;
458
459 setup_timer(&keypad->check_matrix_timer,
460 imx_keypad_check_for_events, (unsigned long) keypad);
461
462 keypad->mmio_base = ioremap(res->start, resource_size(res));
463 if (keypad->mmio_base == NULL) {
464 dev_err(&pdev->dev, "failed to remap I/O memory\n");
465 error = -ENOMEM;
466 goto failed_free_priv;
467 }
468
469 keypad->clk = clk_get(&pdev->dev, "kpp");
470 if (IS_ERR(keypad->clk)) {
471 dev_err(&pdev->dev, "failed to get keypad clock\n");
472 error = PTR_ERR(keypad->clk);
473 goto failed_unmap;
474 }
475
476 /* Search for rows and cols enabled */
477 for (i = 0; i < keymap_data->keymap_size; i++) {
478 keypad->rows_en_mask |= 1 << KEY_ROW(keymap_data->keymap[i]);
479 keypad->cols_en_mask |= 1 << KEY_COL(keymap_data->keymap[i]);
480 }
481
482 if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) ||
483 keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) {
484 dev_err(&pdev->dev,
485 "invalid key data (too many rows or colums)\n");
486 error = -EINVAL;
487 goto failed_clock_put;
488 }
489 dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask);
490 dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask);
491
492 /* Init the Input device */
493 input_dev->name = pdev->name;
494 input_dev->id.bustype = BUS_HOST;
495 input_dev->dev.parent = &pdev->dev;
496 input_dev->open = imx_keypad_open;
497 input_dev->close = imx_keypad_close;
498 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
499 input_dev->keycode = keypad->keycodes;
500 input_dev->keycodesize = sizeof(keypad->keycodes[0]);
501 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
502
503 matrix_keypad_build_keymap(keymap_data, MATRIX_ROW_SHIFT,
504 keypad->keycodes, input_dev->keybit);
505
506 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
507 input_set_drvdata(input_dev, keypad);
508
509 /* Ensure that the keypad will stay dormant until opened */
510 imx_keypad_inhibit(keypad);
511
512 error = request_irq(irq, imx_keypad_irq_handler, IRQF_DISABLED,
513 pdev->name, keypad);
514 if (error) {
515 dev_err(&pdev->dev, "failed to request IRQ\n");
516 goto failed_clock_put;
517 }
518
519 /* Register the input device */
520 error = input_register_device(input_dev);
521 if (error) {
522 dev_err(&pdev->dev, "failed to register input device\n");
523 goto failed_free_irq;
524 }
525
526 platform_set_drvdata(pdev, keypad);
527 device_init_wakeup(&pdev->dev, 1);
528
529 return 0;
530
531failed_free_irq:
532 free_irq(irq, pdev);
533failed_clock_put:
534 clk_put(keypad->clk);
535failed_unmap:
536 iounmap(keypad->mmio_base);
537failed_free_priv:
538 kfree(keypad);
539failed_free_input:
540 input_free_device(input_dev);
541failed_rel_mem:
542 release_mem_region(res->start, resource_size(res));
543 return error;
544}
545
546static int __devexit imx_keypad_remove(struct platform_device *pdev)
547{
548 struct imx_keypad *keypad = platform_get_drvdata(pdev);
549 struct resource *res;
550
551 dev_dbg(&pdev->dev, ">%s\n", __func__);
552
553 platform_set_drvdata(pdev, NULL);
554
555 input_unregister_device(keypad->input_dev);
556
557 free_irq(keypad->irq, keypad);
558 clk_put(keypad->clk);
559
560 iounmap(keypad->mmio_base);
561 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
562 release_mem_region(res->start, resource_size(res));
563
564 kfree(keypad);
565
566 return 0;
567}
568
569static struct platform_driver imx_keypad_driver = {
570 .driver = {
571 .name = "imx-keypad",
572 .owner = THIS_MODULE,
573 },
574 .probe = imx_keypad_probe,
575 .remove = __devexit_p(imx_keypad_remove),
576};
577
578static int __init imx_keypad_init(void)
579{
580 return platform_driver_register(&imx_keypad_driver);
581}
582
583static void __exit imx_keypad_exit(void)
584{
585 platform_driver_unregister(&imx_keypad_driver);
586}
587
588module_init(imx_keypad_init);
589module_exit(imx_keypad_exit);
590
591MODULE_AUTHOR("Alberto Panizzo <maramaopercheseimorto@gmail.com>");
592MODULE_DESCRIPTION("IMX Keypad Port Driver");
593MODULE_LICENSE("GPL v2");
594MODULE_ALIAS("platform:imx-keypad");
diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c
index 191cc51d6cf..31f30087b59 100644
--- a/drivers/input/keyboard/qt2160.c
+++ b/drivers/input/keyboard/qt2160.c
@@ -362,7 +362,7 @@ static int __devexit qt2160_remove(struct i2c_client *client)
362 return 0; 362 return 0;
363} 363}
364 364
365static struct i2c_device_id qt2160_idtable[] = { 365static const struct i2c_device_id qt2160_idtable[] = {
366 { "qt2160", 0, }, 366 { "qt2160", 0, },
367 { } 367 { }
368}; 368};
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index 8e9380bfed4..854e2035cd6 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -19,101 +19,141 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/input/sh_keysc.h> 21#include <linux/input/sh_keysc.h>
22#include <linux/bitmap.h>
22#include <linux/clk.h> 23#include <linux/clk.h>
23#include <linux/io.h> 24#include <linux/io.h>
24 25
25#define KYCR1_OFFS 0x00
26#define KYCR2_OFFS 0x04
27#define KYINDR_OFFS 0x08
28#define KYOUTDR_OFFS 0x0c
29
30#define KYCR2_IRQ_LEVEL 0x10
31#define KYCR2_IRQ_DISABLED 0x00
32
33static const struct { 26static const struct {
34 unsigned char kymd, keyout, keyin; 27 unsigned char kymd, keyout, keyin;
35} sh_keysc_mode[] = { 28} sh_keysc_mode[] = {
36 [SH_KEYSC_MODE_1] = { 0, 6, 5 }, 29 [SH_KEYSC_MODE_1] = { 0, 6, 5 },
37 [SH_KEYSC_MODE_2] = { 1, 5, 6 }, 30 [SH_KEYSC_MODE_2] = { 1, 5, 6 },
38 [SH_KEYSC_MODE_3] = { 2, 4, 7 }, 31 [SH_KEYSC_MODE_3] = { 2, 4, 7 },
32 [SH_KEYSC_MODE_4] = { 3, 6, 6 },
33 [SH_KEYSC_MODE_5] = { 4, 6, 7 },
34 [SH_KEYSC_MODE_6] = { 5, 7, 7 },
39}; 35};
40 36
41struct sh_keysc_priv { 37struct sh_keysc_priv {
42 void __iomem *iomem_base; 38 void __iomem *iomem_base;
43 struct clk *clk; 39 struct clk *clk;
44 unsigned long last_keys; 40 DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS);
45 struct input_dev *input; 41 struct input_dev *input;
46 struct sh_keysc_info pdata; 42 struct sh_keysc_info pdata;
47}; 43};
48 44
45#define KYCR1 0
46#define KYCR2 1
47#define KYINDR 2
48#define KYOUTDR 3
49
50#define KYCR2_IRQ_LEVEL 0x10
51#define KYCR2_IRQ_DISABLED 0x00
52
53static unsigned long sh_keysc_read(struct sh_keysc_priv *p, int reg_nr)
54{
55 return ioread16(p->iomem_base + (reg_nr << 2));
56}
57
58static void sh_keysc_write(struct sh_keysc_priv *p, int reg_nr,
59 unsigned long value)
60{
61 iowrite16(value, p->iomem_base + (reg_nr << 2));
62}
63
64static void sh_keysc_level_mode(struct sh_keysc_priv *p,
65 unsigned long keys_set)
66{
67 struct sh_keysc_info *pdata = &p->pdata;
68
69 sh_keysc_write(p, KYOUTDR, 0);
70 sh_keysc_write(p, KYCR2, KYCR2_IRQ_LEVEL | (keys_set << 8));
71
72 if (pdata->kycr2_delay)
73 udelay(pdata->kycr2_delay);
74}
75
76static void sh_keysc_map_dbg(struct device *dev, unsigned long *map,
77 const char *str)
78{
79 int k;
80
81 for (k = 0; k < BITS_TO_LONGS(SH_KEYSC_MAXKEYS); k++)
82 dev_dbg(dev, "%s[%d] 0x%lx\n", str, k, map[k]);
83}
84
49static irqreturn_t sh_keysc_isr(int irq, void *dev_id) 85static irqreturn_t sh_keysc_isr(int irq, void *dev_id)
50{ 86{
51 struct platform_device *pdev = dev_id; 87 struct platform_device *pdev = dev_id;
52 struct sh_keysc_priv *priv = platform_get_drvdata(pdev); 88 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
53 struct sh_keysc_info *pdata = &priv->pdata; 89 struct sh_keysc_info *pdata = &priv->pdata;
54 unsigned long keys, keys1, keys0, mask; 90 int keyout_nr = sh_keysc_mode[pdata->mode].keyout;
91 int keyin_nr = sh_keysc_mode[pdata->mode].keyin;
92 DECLARE_BITMAP(keys, SH_KEYSC_MAXKEYS);
93 DECLARE_BITMAP(keys0, SH_KEYSC_MAXKEYS);
94 DECLARE_BITMAP(keys1, SH_KEYSC_MAXKEYS);
55 unsigned char keyin_set, tmp; 95 unsigned char keyin_set, tmp;
56 int i, k; 96 int i, k, n;
57 97
58 dev_dbg(&pdev->dev, "isr!\n"); 98 dev_dbg(&pdev->dev, "isr!\n");
59 99
60 keys1 = ~0; 100 bitmap_fill(keys1, SH_KEYSC_MAXKEYS);
61 keys0 = 0; 101 bitmap_zero(keys0, SH_KEYSC_MAXKEYS);
62 102
63 do { 103 do {
64 keys = 0; 104 bitmap_zero(keys, SH_KEYSC_MAXKEYS);
65 keyin_set = 0; 105 keyin_set = 0;
66 106
67 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); 107 sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED);
108
109 for (i = 0; i < keyout_nr; i++) {
110 n = keyin_nr * i;
68 111
69 for (i = 0; i < sh_keysc_mode[pdata->mode].keyout; i++) { 112 /* drive one KEYOUT pin low, read KEYIN pins */
70 iowrite16(0xfff ^ (3 << (i * 2)), 113 sh_keysc_write(priv, KYOUTDR, 0xffff ^ (3 << (i * 2)));
71 priv->iomem_base + KYOUTDR_OFFS);
72 udelay(pdata->delay); 114 udelay(pdata->delay);
73 tmp = ioread16(priv->iomem_base + KYINDR_OFFS); 115 tmp = sh_keysc_read(priv, KYINDR);
74 keys |= tmp << (sh_keysc_mode[pdata->mode].keyin * i);
75 tmp ^= (1 << sh_keysc_mode[pdata->mode].keyin) - 1;
76 keyin_set |= tmp;
77 }
78 116
79 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); 117 /* set bit if key press has been detected */
80 iowrite16(KYCR2_IRQ_LEVEL | (keyin_set << 8), 118 for (k = 0; k < keyin_nr; k++) {
81 priv->iomem_base + KYCR2_OFFS); 119 if (tmp & (1 << k))
120 __set_bit(n + k, keys);
121 }
82 122
83 if (pdata->kycr2_delay) 123 /* keep track of which KEYIN bits that have been set */
84 udelay(pdata->kycr2_delay); 124 keyin_set |= tmp ^ ((1 << keyin_nr) - 1);
125 }
85 126
86 keys ^= ~0; 127 sh_keysc_level_mode(priv, keyin_set);
87 keys &= (1 << (sh_keysc_mode[pdata->mode].keyin *
88 sh_keysc_mode[pdata->mode].keyout)) - 1;
89 keys1 &= keys;
90 keys0 |= keys;
91 128
92 dev_dbg(&pdev->dev, "keys 0x%08lx\n", keys); 129 bitmap_complement(keys, keys, SH_KEYSC_MAXKEYS);
130 bitmap_and(keys1, keys1, keys, SH_KEYSC_MAXKEYS);
131 bitmap_or(keys0, keys0, keys, SH_KEYSC_MAXKEYS);
93 132
94 } while (ioread16(priv->iomem_base + KYCR2_OFFS) & 0x01); 133 sh_keysc_map_dbg(&pdev->dev, keys, "keys");
95 134
96 dev_dbg(&pdev->dev, "last_keys 0x%08lx keys0 0x%08lx keys1 0x%08lx\n", 135 } while (sh_keysc_read(priv, KYCR2) & 0x01);
97 priv->last_keys, keys0, keys1); 136
137 sh_keysc_map_dbg(&pdev->dev, priv->last_keys, "last_keys");
138 sh_keysc_map_dbg(&pdev->dev, keys0, "keys0");
139 sh_keysc_map_dbg(&pdev->dev, keys1, "keys1");
98 140
99 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { 141 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) {
100 k = pdata->keycodes[i]; 142 k = pdata->keycodes[i];
101 if (!k) 143 if (!k)
102 continue; 144 continue;
103 145
104 mask = 1 << i; 146 if (test_bit(i, keys0) == test_bit(i, priv->last_keys))
105
106 if (!((priv->last_keys ^ keys0) & mask))
107 continue; 147 continue;
108 148
109 if ((keys1 | keys0) & mask) { 149 if (test_bit(i, keys1) || test_bit(i, keys0)) {
110 input_event(priv->input, EV_KEY, k, 1); 150 input_event(priv->input, EV_KEY, k, 1);
111 priv->last_keys |= mask; 151 __set_bit(i, priv->last_keys);
112 } 152 }
113 153
114 if (!(keys1 & mask)) { 154 if (!test_bit(i, keys1)) {
115 input_event(priv->input, EV_KEY, k, 0); 155 input_event(priv->input, EV_KEY, k, 0);
116 priv->last_keys &= ~mask; 156 __clear_bit(i, priv->last_keys);
117 } 157 }
118 158
119 } 159 }
@@ -122,8 +162,6 @@ static irqreturn_t sh_keysc_isr(int irq, void *dev_id)
122 return IRQ_HANDLED; 162 return IRQ_HANDLED;
123} 163}
124 164
125#define res_size(res) ((res)->end - (res)->start + 1)
126
127static int __devinit sh_keysc_probe(struct platform_device *pdev) 165static int __devinit sh_keysc_probe(struct platform_device *pdev)
128{ 166{
129 struct sh_keysc_priv *priv; 167 struct sh_keysc_priv *priv;
@@ -164,7 +202,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
164 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); 202 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata));
165 pdata = &priv->pdata; 203 pdata = &priv->pdata;
166 204
167 priv->iomem_base = ioremap_nocache(res->start, res_size(res)); 205 priv->iomem_base = ioremap_nocache(res->start, resource_size(res));
168 if (priv->iomem_base == NULL) { 206 if (priv->iomem_base == NULL) {
169 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 207 dev_err(&pdev->dev, "failed to remap I/O memory\n");
170 error = -ENXIO; 208 error = -ENXIO;
@@ -220,10 +258,9 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
220 258
221 clk_enable(priv->clk); 259 clk_enable(priv->clk);
222 260
223 iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | 261 sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) |
224 pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); 262 pdata->scan_timing);
225 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); 263 sh_keysc_level_mode(priv, 0);
226 iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS);
227 264
228 device_init_wakeup(&pdev->dev, 1); 265 device_init_wakeup(&pdev->dev, 1);
229 266
@@ -248,7 +285,7 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev)
248{ 285{
249 struct sh_keysc_priv *priv = platform_get_drvdata(pdev); 286 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
250 287
251 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); 288 sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED);
252 289
253 input_unregister_device(priv->input); 290 input_unregister_device(priv->input);
254 free_irq(platform_get_irq(pdev, 0), pdev); 291 free_irq(platform_get_irq(pdev, 0), pdev);
@@ -270,7 +307,7 @@ static int sh_keysc_suspend(struct device *dev)
270 int irq = platform_get_irq(pdev, 0); 307 int irq = platform_get_irq(pdev, 0);
271 unsigned short value; 308 unsigned short value;
272 309
273 value = ioread16(priv->iomem_base + KYCR1_OFFS); 310 value = sh_keysc_read(priv, KYCR1);
274 311
275 if (device_may_wakeup(dev)) { 312 if (device_may_wakeup(dev)) {
276 value |= 0x80; 313 value |= 0x80;
@@ -279,7 +316,7 @@ static int sh_keysc_suspend(struct device *dev)
279 value &= ~0x80; 316 value &= ~0x80;
280 } 317 }
281 318
282 iowrite16(value, priv->iomem_base + KYCR1_OFFS); 319 sh_keysc_write(priv, KYCR1, value);
283 320
284 return 0; 321 return 0;
285} 322}
diff --git a/drivers/input/misc/apanel.c b/drivers/input/misc/apanel.c
index 71b82434264..a8d2b8db4e3 100644
--- a/drivers/input/misc/apanel.c
+++ b/drivers/input/misc/apanel.c
@@ -149,7 +149,7 @@ static void apanel_shutdown(struct i2c_client *client)
149 apanel_remove(client); 149 apanel_remove(client);
150} 150}
151 151
152static struct i2c_device_id apanel_id[] = { 152static const struct i2c_device_id apanel_id[] = {
153 { "fujitsu_apanel", 0 }, 153 { "fujitsu_apanel", 0 },
154 { } 154 { }
155}; 155};
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
index 1b871917340..dfaa9a045ed 100644
--- a/drivers/input/misc/atlas_btns.c
+++ b/drivers/input/misc/atlas_btns.c
@@ -47,7 +47,7 @@ static acpi_status acpi_atlas_button_setup(acpi_handle region_handle,
47 47
48static acpi_status acpi_atlas_button_handler(u32 function, 48static acpi_status acpi_atlas_button_handler(u32 function,
49 acpi_physical_address address, 49 acpi_physical_address address,
50 u32 bit_width, acpi_integer *value, 50 u32 bit_width, u64 *value,
51 void *handler_context, void *region_context) 51 void *handler_context, void *region_context)
52{ 52{
53 acpi_status status; 53 acpi_status status;
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 3b9f588fc74..4ae07935985 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -152,6 +152,13 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
152 goto exit_unregister_input; 152 goto exit_unregister_input;
153 } 153 }
154 154
155 err = gpio_direction_input(pdata->gpio_a);
156 if (err) {
157 dev_err(&pdev->dev, "unable to set GPIO %d for input\n",
158 pdata->gpio_a);
159 goto exit_unregister_input;
160 }
161
155 err = gpio_request(pdata->gpio_b, DRV_NAME); 162 err = gpio_request(pdata->gpio_b, DRV_NAME);
156 if (err) { 163 if (err) {
157 dev_err(&pdev->dev, "unable to request GPIO %d\n", 164 dev_err(&pdev->dev, "unable to request GPIO %d\n",
@@ -159,6 +166,13 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
159 goto exit_free_gpio_a; 166 goto exit_free_gpio_a;
160 } 167 }
161 168
169 err = gpio_direction_input(pdata->gpio_b);
170 if (err) {
171 dev_err(&pdev->dev, "unable to set GPIO %d for input\n",
172 pdata->gpio_b);
173 goto exit_free_gpio_a;
174 }
175
162 /* request the IRQs */ 176 /* request the IRQs */
163 err = request_irq(encoder->irq_a, &rotary_encoder_irq, 177 err = request_irq(encoder->irq_a, &rotary_encoder_irq,
164 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE, 178 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index d3f57245420..1477466076a 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -34,7 +34,6 @@
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/smp_lock.h>
38#include <linux/fs.h> 37#include <linux/fs.h>
39#include <linux/miscdevice.h> 38#include <linux/miscdevice.h>
40#include <linux/uinput.h> 39#include <linux/uinput.h>
@@ -284,7 +283,6 @@ static int uinput_open(struct inode *inode, struct file *file)
284 if (!newdev) 283 if (!newdev)
285 return -ENOMEM; 284 return -ENOMEM;
286 285
287 lock_kernel();
288 mutex_init(&newdev->mutex); 286 mutex_init(&newdev->mutex);
289 spin_lock_init(&newdev->requests_lock); 287 spin_lock_init(&newdev->requests_lock);
290 init_waitqueue_head(&newdev->requests_waitq); 288 init_waitqueue_head(&newdev->requests_waitq);
@@ -292,7 +290,7 @@ static int uinput_open(struct inode *inode, struct file *file)
292 newdev->state = UIST_NEW_DEVICE; 290 newdev->state = UIST_NEW_DEVICE;
293 291
294 file->private_data = newdev; 292 file->private_data = newdev;
295 unlock_kernel(); 293 nonseekable_open(inode, file);
296 294
297 return 0; 295 return 0;
298} 296}
diff --git a/drivers/input/misc/winbond-cir.c b/drivers/input/misc/winbond-cir.c
index c8f5a9a3fa1..cbec3dfdd42 100644
--- a/drivers/input/misc/winbond-cir.c
+++ b/drivers/input/misc/winbond-cir.c
@@ -538,6 +538,7 @@ wbcir_reset_irdata(struct wbcir_data *data)
538 data->irdata_count = 0; 538 data->irdata_count = 0;
539 data->irdata_off = 0; 539 data->irdata_off = 0;
540 data->irdata_error = 0; 540 data->irdata_error = 0;
541 data->idle_count = 0;
541} 542}
542 543
543/* Adds one bit of irdata */ 544/* Adds one bit of irdata */
@@ -1006,7 +1007,6 @@ wbcir_irq_handler(int irqno, void *cookie)
1006 } 1007 }
1007 1008
1008 wbcir_reset_irdata(data); 1009 wbcir_reset_irdata(data);
1009 data->idle_count = 0;
1010 } 1010 }
1011 1011
1012out: 1012out:
@@ -1018,7 +1018,7 @@ out:
1018 1018
1019/***************************************************************************** 1019/*****************************************************************************
1020 * 1020 *
1021 * SUSPEND/RESUME FUNCTIONS 1021 * SETUP/INIT/SUSPEND/RESUME FUNCTIONS
1022 * 1022 *
1023 *****************************************************************************/ 1023 *****************************************************************************/
1024 1024
@@ -1197,7 +1197,16 @@ finish:
1197 } 1197 }
1198 1198
1199 /* Disable interrupts */ 1199 /* Disable interrupts */
1200 wbcir_select_bank(data, WBCIR_BANK_0);
1200 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER); 1201 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER);
1202
1203 /*
1204 * ACPI will set the HW disable bit for SP3 which means that the
1205 * output signals are left in an undefined state which may cause
1206 * spurious interrupts which we need to ignore until the hardware
1207 * is reinitialized.
1208 */
1209 disable_irq(data->irq);
1201} 1210}
1202 1211
1203static int 1212static int
@@ -1207,37 +1216,15 @@ wbcir_suspend(struct pnp_dev *device, pm_message_t state)
1207 return 0; 1216 return 0;
1208} 1217}
1209 1218
1210static int
1211wbcir_resume(struct pnp_dev *device)
1212{
1213 struct wbcir_data *data = pnp_get_drvdata(device);
1214
1215 /* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */
1216 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07);
1217
1218 /* Clear CEIR_EN */
1219 wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x00, 0x01);
1220
1221 /* Enable interrupts */
1222 wbcir_reset_irdata(data);
1223 outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER);
1224
1225 return 0;
1226}
1227
1228
1229
1230/*****************************************************************************
1231 *
1232 * SETUP/INIT FUNCTIONS
1233 *
1234 *****************************************************************************/
1235
1236static void 1219static void
1237wbcir_cfg_ceir(struct wbcir_data *data) 1220wbcir_init_hw(struct wbcir_data *data)
1238{ 1221{
1239 u8 tmp; 1222 u8 tmp;
1240 1223
1224 /* Disable interrupts */
1225 wbcir_select_bank(data, WBCIR_BANK_0);
1226 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER);
1227
1241 /* Set PROT_SEL, RX_INV, Clear CEIR_EN (needed for the led) */ 1228 /* Set PROT_SEL, RX_INV, Clear CEIR_EN (needed for the led) */
1242 tmp = protocol << 4; 1229 tmp = protocol << 4;
1243 if (invert) 1230 if (invert)
@@ -1264,6 +1251,93 @@ wbcir_cfg_ceir(struct wbcir_data *data)
1264 * set SP3_IRRX_SW to binary 01, helpfully not documented 1251 * set SP3_IRRX_SW to binary 01, helpfully not documented
1265 */ 1252 */
1266 outb(0x10, data->ebase + WBCIR_REG_ECEIR_CTS); 1253 outb(0x10, data->ebase + WBCIR_REG_ECEIR_CTS);
1254
1255 /* Enable extended mode */
1256 wbcir_select_bank(data, WBCIR_BANK_2);
1257 outb(WBCIR_EXT_ENABLE, data->sbase + WBCIR_REG_SP3_EXCR1);
1258
1259 /*
1260 * Configure baud generator, IR data will be sampled at
1261 * a bitrate of: (24Mhz * prescaler) / (divisor * 16).
1262 *
1263 * The ECIR registers include a flag to change the
1264 * 24Mhz clock freq to 48Mhz.
1265 *
1266 * It's not documented in the specs, but fifo levels
1267 * other than 16 seems to be unsupported.
1268 */
1269
1270 /* prescaler 1.0, tx/rx fifo lvl 16 */
1271 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2);
1272
1273 /* Set baud divisor to generate one byte per bit/cell */
1274 switch (protocol) {
1275 case IR_PROTOCOL_RC5:
1276 outb(0xA7, data->sbase + WBCIR_REG_SP3_BGDL);
1277 break;
1278 case IR_PROTOCOL_RC6:
1279 outb(0x53, data->sbase + WBCIR_REG_SP3_BGDL);
1280 break;
1281 case IR_PROTOCOL_NEC:
1282 outb(0x69, data->sbase + WBCIR_REG_SP3_BGDL);
1283 break;
1284 }
1285 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
1286
1287 /* Set CEIR mode */
1288 wbcir_select_bank(data, WBCIR_BANK_0);
1289 outb(0xC0, data->sbase + WBCIR_REG_SP3_MCR);
1290 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */
1291 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */
1292
1293 /* Disable RX demod, run-length encoding/decoding, set freq span */
1294 wbcir_select_bank(data, WBCIR_BANK_7);
1295 outb(0x10, data->sbase + WBCIR_REG_SP3_RCCFG);
1296
1297 /* Disable timer */
1298 wbcir_select_bank(data, WBCIR_BANK_4);
1299 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR1);
1300
1301 /* Enable MSR interrupt, Clear AUX_IRX */
1302 wbcir_select_bank(data, WBCIR_BANK_5);
1303 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR2);
1304
1305 /* Disable CRC */
1306 wbcir_select_bank(data, WBCIR_BANK_6);
1307 outb(0x20, data->sbase + WBCIR_REG_SP3_IRCR3);
1308
1309 /* Set RX/TX (de)modulation freq, not really used */
1310 wbcir_select_bank(data, WBCIR_BANK_7);
1311 outb(0xF2, data->sbase + WBCIR_REG_SP3_IRRXDC);
1312 outb(0x69, data->sbase + WBCIR_REG_SP3_IRTXMC);
1313
1314 /* Set invert and pin direction */
1315 if (invert)
1316 outb(0x10, data->sbase + WBCIR_REG_SP3_IRCFG4);
1317 else
1318 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCFG4);
1319
1320 /* Set FIFO thresholds (RX = 8, TX = 3), reset RX/TX */
1321 wbcir_select_bank(data, WBCIR_BANK_0);
1322 outb(0x97, data->sbase + WBCIR_REG_SP3_FCR);
1323
1324 /* Clear AUX status bits */
1325 outb(0xE0, data->sbase + WBCIR_REG_SP3_ASCR);
1326
1327 /* Enable interrupts */
1328 wbcir_reset_irdata(data);
1329 outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER);
1330}
1331
1332static int
1333wbcir_resume(struct pnp_dev *device)
1334{
1335 struct wbcir_data *data = pnp_get_drvdata(device);
1336
1337 wbcir_init_hw(data);
1338 enable_irq(data->irq);
1339
1340 return 0;
1267} 1341}
1268 1342
1269static int __devinit 1343static int __devinit
@@ -1393,86 +1467,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1393 1467
1394 device_init_wakeup(&device->dev, 1); 1468 device_init_wakeup(&device->dev, 1);
1395 1469
1396 wbcir_cfg_ceir(data); 1470 wbcir_init_hw(data);
1397
1398 /* Disable interrupts */
1399 wbcir_select_bank(data, WBCIR_BANK_0);
1400 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER);
1401
1402 /* Enable extended mode */
1403 wbcir_select_bank(data, WBCIR_BANK_2);
1404 outb(WBCIR_EXT_ENABLE, data->sbase + WBCIR_REG_SP3_EXCR1);
1405
1406 /*
1407 * Configure baud generator, IR data will be sampled at
1408 * a bitrate of: (24Mhz * prescaler) / (divisor * 16).
1409 *
1410 * The ECIR registers include a flag to change the
1411 * 24Mhz clock freq to 48Mhz.
1412 *
1413 * It's not documented in the specs, but fifo levels
1414 * other than 16 seems to be unsupported.
1415 */
1416
1417 /* prescaler 1.0, tx/rx fifo lvl 16 */
1418 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2);
1419
1420 /* Set baud divisor to generate one byte per bit/cell */
1421 switch (protocol) {
1422 case IR_PROTOCOL_RC5:
1423 outb(0xA7, data->sbase + WBCIR_REG_SP3_BGDL);
1424 break;
1425 case IR_PROTOCOL_RC6:
1426 outb(0x53, data->sbase + WBCIR_REG_SP3_BGDL);
1427 break;
1428 case IR_PROTOCOL_NEC:
1429 outb(0x69, data->sbase + WBCIR_REG_SP3_BGDL);
1430 break;
1431 }
1432 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
1433
1434 /* Set CEIR mode */
1435 wbcir_select_bank(data, WBCIR_BANK_0);
1436 outb(0xC0, data->sbase + WBCIR_REG_SP3_MCR);
1437 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */
1438 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */
1439
1440 /* Disable RX demod, run-length encoding/decoding, set freq span */
1441 wbcir_select_bank(data, WBCIR_BANK_7);
1442 outb(0x10, data->sbase + WBCIR_REG_SP3_RCCFG);
1443
1444 /* Disable timer */
1445 wbcir_select_bank(data, WBCIR_BANK_4);
1446 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR1);
1447
1448 /* Enable MSR interrupt, Clear AUX_IRX */
1449 wbcir_select_bank(data, WBCIR_BANK_5);
1450 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR2);
1451
1452 /* Disable CRC */
1453 wbcir_select_bank(data, WBCIR_BANK_6);
1454 outb(0x20, data->sbase + WBCIR_REG_SP3_IRCR3);
1455
1456 /* Set RX/TX (de)modulation freq, not really used */
1457 wbcir_select_bank(data, WBCIR_BANK_7);
1458 outb(0xF2, data->sbase + WBCIR_REG_SP3_IRRXDC);
1459 outb(0x69, data->sbase + WBCIR_REG_SP3_IRTXMC);
1460
1461 /* Set invert and pin direction */
1462 if (invert)
1463 outb(0x10, data->sbase + WBCIR_REG_SP3_IRCFG4);
1464 else
1465 outb(0x00, data->sbase + WBCIR_REG_SP3_IRCFG4);
1466
1467 /* Set FIFO thresholds (RX = 8, TX = 3), reset RX/TX */
1468 wbcir_select_bank(data, WBCIR_BANK_0);
1469 outb(0x97, data->sbase + WBCIR_REG_SP3_FCR);
1470
1471 /* Clear AUX status bits */
1472 outb(0xE0, data->sbase + WBCIR_REG_SP3_ASCR);
1473
1474 /* Enable interrupts */
1475 outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER);
1476 1471
1477 return 0; 1472 return 0;
1478 1473
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index 90be30e9355..9169d1591c1 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -68,10 +68,6 @@ module_param(post_interrupt_delay, int, 0644);
68MODULE_PARM_DESC(post_interrupt_delay, 68MODULE_PARM_DESC(post_interrupt_delay,
69 "delay (ms) before recal after recal interrupt detected"); 69 "delay (ms) before recal after recal interrupt detected");
70 70
71static int autorecal = 1;
72module_param(autorecal, int, 0644);
73MODULE_PARM_DESC(autorecal, "enable recalibration in the driver");
74
75/* 71/*
76 * When the touchpad gets ultra-sensitive, one can keep their finger 1/2" 72 * When the touchpad gets ultra-sensitive, one can keep their finger 1/2"
77 * above the pad and still have it send packets. This causes a jump cursor 73 * above the pad and still have it send packets. This causes a jump cursor
diff --git a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c
index 1dacbe0d934..797314be7af 100644
--- a/drivers/input/serio/pcips2.c
+++ b/drivers/input/serio/pcips2.c
@@ -186,7 +186,7 @@ static void __devexit pcips2_remove(struct pci_dev *dev)
186 pci_disable_device(dev); 186 pci_disable_device(dev);
187} 187}
188 188
189static struct pci_device_id pcips2_ids[] = { 189static const struct pci_device_id pcips2_ids[] = {
190 { 190 {
191 .vendor = 0x14f2, /* MOBILITY */ 191 .vendor = 0x14f2, /* MOBILITY */
192 .device = 0x0123, /* Keyboard */ 192 .device = 0x0123, /* Keyboard */
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index e0f30186d51..c3b626e9eae 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -26,6 +26,8 @@
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 27 */
28 28
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30
29#include <linux/stddef.h> 31#include <linux/stddef.h>
30#include <linux/module.h> 32#include <linux/module.h>
31#include <linux/serio.h> 33#include <linux/serio.h>
@@ -119,11 +121,10 @@ static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
119 121
120 error = device_bind_driver(&serio->dev); 122 error = device_bind_driver(&serio->dev);
121 if (error) { 123 if (error) {
122 printk(KERN_WARNING 124 dev_warn(&serio->dev,
123 "serio: device_bind_driver() failed " 125 "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
124 "for %s (%s) and %s, error: %d\n", 126 serio->phys, serio->name,
125 serio->phys, serio->name, 127 drv->description, error);
126 drv->description, error);
127 serio_disconnect_driver(serio); 128 serio_disconnect_driver(serio);
128 serio->dev.driver = NULL; 129 serio->dev.driver = NULL;
129 return error; 130 return error;
@@ -138,9 +139,9 @@ static void serio_find_driver(struct serio *serio)
138 139
139 error = device_attach(&serio->dev); 140 error = device_attach(&serio->dev);
140 if (error < 0) 141 if (error < 0)
141 printk(KERN_WARNING 142 dev_warn(&serio->dev,
142 "serio: device_attach() failed for %s (%s), error: %d\n", 143 "device_attach() failed for %s (%s), error: %d\n",
143 serio->phys, serio->name, error); 144 serio->phys, serio->name, error);
144} 145}
145 146
146 147
@@ -194,17 +195,14 @@ static int serio_queue_event(void *object, struct module *owner,
194 195
195 event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC); 196 event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC);
196 if (!event) { 197 if (!event) {
197 printk(KERN_ERR 198 pr_err("Not enough memory to queue event %d\n", event_type);
198 "serio: Not enough memory to queue event %d\n",
199 event_type);
200 retval = -ENOMEM; 199 retval = -ENOMEM;
201 goto out; 200 goto out;
202 } 201 }
203 202
204 if (!try_module_get(owner)) { 203 if (!try_module_get(owner)) {
205 printk(KERN_WARNING 204 pr_warning("Can't get module reference, dropping event %d\n",
206 "serio: Can't get module reference, dropping event %d\n", 205 event_type);
207 event_type);
208 kfree(event); 206 kfree(event);
209 retval = -EINVAL; 207 retval = -EINVAL;
210 goto out; 208 goto out;
@@ -230,14 +228,12 @@ static void serio_free_event(struct serio_event *event)
230 228
231static void serio_remove_duplicate_events(struct serio_event *event) 229static void serio_remove_duplicate_events(struct serio_event *event)
232{ 230{
233 struct list_head *node, *next; 231 struct serio_event *e, *next;
234 struct serio_event *e;
235 unsigned long flags; 232 unsigned long flags;
236 233
237 spin_lock_irqsave(&serio_event_lock, flags); 234 spin_lock_irqsave(&serio_event_lock, flags);
238 235
239 list_for_each_safe(node, next, &serio_event_list) { 236 list_for_each_entry_safe(e, next, &serio_event_list, node) {
240 e = list_entry(node, struct serio_event, node);
241 if (event->object == e->object) { 237 if (event->object == e->object) {
242 /* 238 /*
243 * If this event is of different type we should not 239 * If this event is of different type we should not
@@ -247,7 +243,7 @@ static void serio_remove_duplicate_events(struct serio_event *event)
247 if (event->type != e->type) 243 if (event->type != e->type)
248 break; 244 break;
249 245
250 list_del_init(node); 246 list_del_init(&e->node);
251 serio_free_event(e); 247 serio_free_event(e);
252 } 248 }
253 } 249 }
@@ -258,23 +254,18 @@ static void serio_remove_duplicate_events(struct serio_event *event)
258 254
259static struct serio_event *serio_get_event(void) 255static struct serio_event *serio_get_event(void)
260{ 256{
261 struct serio_event *event; 257 struct serio_event *event = NULL;
262 struct list_head *node;
263 unsigned long flags; 258 unsigned long flags;
264 259
265 spin_lock_irqsave(&serio_event_lock, flags); 260 spin_lock_irqsave(&serio_event_lock, flags);
266 261
267 if (list_empty(&serio_event_list)) { 262 if (!list_empty(&serio_event_list)) {
268 spin_unlock_irqrestore(&serio_event_lock, flags); 263 event = list_first_entry(&serio_event_list,
269 return NULL; 264 struct serio_event, node);
265 list_del_init(&event->node);
270 } 266 }
271 267
272 node = serio_event_list.next;
273 event = list_entry(node, struct serio_event, node);
274 list_del_init(node);
275
276 spin_unlock_irqrestore(&serio_event_lock, flags); 268 spin_unlock_irqrestore(&serio_event_lock, flags);
277
278 return event; 269 return event;
279} 270}
280 271
@@ -287,29 +278,27 @@ static void serio_handle_event(void)
287 while ((event = serio_get_event())) { 278 while ((event = serio_get_event())) {
288 279
289 switch (event->type) { 280 switch (event->type) {
290 case SERIO_REGISTER_PORT:
291 serio_add_port(event->object);
292 break;
293 281
294 case SERIO_RECONNECT_PORT: 282 case SERIO_REGISTER_PORT:
295 serio_reconnect_port(event->object); 283 serio_add_port(event->object);
296 break; 284 break;
297 285
298 case SERIO_RESCAN_PORT: 286 case SERIO_RECONNECT_PORT:
299 serio_disconnect_port(event->object); 287 serio_reconnect_port(event->object);
300 serio_find_driver(event->object); 288 break;
301 break;
302 289
303 case SERIO_RECONNECT_CHAIN: 290 case SERIO_RESCAN_PORT:
304 serio_reconnect_chain(event->object); 291 serio_disconnect_port(event->object);
305 break; 292 serio_find_driver(event->object);
293 break;
306 294
307 case SERIO_ATTACH_DRIVER: 295 case SERIO_RECONNECT_CHAIN:
308 serio_attach_driver(event->object); 296 serio_reconnect_chain(event->object);
309 break; 297 break;
310 298
311 default: 299 case SERIO_ATTACH_DRIVER:
312 break; 300 serio_attach_driver(event->object);
301 break;
313 } 302 }
314 303
315 serio_remove_duplicate_events(event); 304 serio_remove_duplicate_events(event);
@@ -325,16 +314,14 @@ static void serio_handle_event(void)
325 */ 314 */
326static void serio_remove_pending_events(void *object) 315static void serio_remove_pending_events(void *object)
327{ 316{
328 struct list_head *node, *next; 317 struct serio_event *event, *next;
329 struct serio_event *event;
330 unsigned long flags; 318 unsigned long flags;
331 319
332 spin_lock_irqsave(&serio_event_lock, flags); 320 spin_lock_irqsave(&serio_event_lock, flags);
333 321
334 list_for_each_safe(node, next, &serio_event_list) { 322 list_for_each_entry_safe(event, next, &serio_event_list, node) {
335 event = list_entry(node, struct serio_event, node);
336 if (event->object == object) { 323 if (event->object == object) {
337 list_del_init(node); 324 list_del_init(&event->node);
338 serio_free_event(event); 325 serio_free_event(event);
339 } 326 }
340 } 327 }
@@ -380,7 +367,6 @@ static int serio_thread(void *nothing)
380 kthread_should_stop() || !list_empty(&serio_event_list)); 367 kthread_should_stop() || !list_empty(&serio_event_list));
381 } while (!kthread_should_stop()); 368 } while (!kthread_should_stop());
382 369
383 printk(KERN_DEBUG "serio: kseriod exiting\n");
384 return 0; 370 return 0;
385} 371}
386 372
@@ -445,6 +431,11 @@ static struct attribute_group serio_id_attr_group = {
445 .attrs = serio_device_id_attrs, 431 .attrs = serio_device_id_attrs,
446}; 432};
447 433
434static const struct attribute_group *serio_device_attr_groups[] = {
435 &serio_id_attr_group,
436 NULL
437};
438
448static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 439static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
449{ 440{
450 struct serio *serio = to_serio_port(dev); 441 struct serio *serio = to_serio_port(dev);
@@ -532,6 +523,7 @@ static void serio_init_port(struct serio *serio)
532 (long)atomic_inc_return(&serio_no) - 1); 523 (long)atomic_inc_return(&serio_no) - 1);
533 serio->dev.bus = &serio_bus; 524 serio->dev.bus = &serio_bus;
534 serio->dev.release = serio_release_port; 525 serio->dev.release = serio_release_port;
526 serio->dev.groups = serio_device_attr_groups;
535 if (serio->parent) { 527 if (serio->parent) {
536 serio->dev.parent = &serio->parent->dev; 528 serio->dev.parent = &serio->parent->dev;
537 serio->depth = serio->parent->depth + 1; 529 serio->depth = serio->parent->depth + 1;
@@ -555,21 +547,15 @@ static void serio_add_port(struct serio *serio)
555 } 547 }
556 548
557 list_add_tail(&serio->node, &serio_list); 549 list_add_tail(&serio->node, &serio_list);
550
558 if (serio->start) 551 if (serio->start)
559 serio->start(serio); 552 serio->start(serio);
553
560 error = device_add(&serio->dev); 554 error = device_add(&serio->dev);
561 if (error) 555 if (error)
562 printk(KERN_ERR 556 dev_err(&serio->dev,
563 "serio: device_add() failed for %s (%s), error: %d\n", 557 "device_add() failed for %s (%s), error: %d\n",
564 serio->phys, serio->name, error); 558 serio->phys, serio->name, error);
565 else {
566 serio->registered = true;
567 error = sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
568 if (error)
569 printk(KERN_ERR
570 "serio: sysfs_create_group() failed for %s (%s), error: %d\n",
571 serio->phys, serio->name, error);
572 }
573} 559}
574 560
575/* 561/*
@@ -596,11 +582,8 @@ static void serio_destroy_port(struct serio *serio)
596 serio->parent = NULL; 582 serio->parent = NULL;
597 } 583 }
598 584
599 if (serio->registered) { 585 if (device_is_registered(&serio->dev))
600 sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
601 device_del(&serio->dev); 586 device_del(&serio->dev);
602 serio->registered = false;
603 }
604 587
605 list_del_init(&serio->node); 588 list_del_init(&serio->node);
606 serio_remove_pending_events(serio); 589 serio_remove_pending_events(serio);
@@ -798,9 +781,8 @@ static void serio_attach_driver(struct serio_driver *drv)
798 781
799 error = driver_attach(&drv->driver); 782 error = driver_attach(&drv->driver);
800 if (error) 783 if (error)
801 printk(KERN_WARNING 784 pr_warning("driver_attach() failed for %s with error %d\n",
802 "serio: driver_attach() failed for %s with error %d\n", 785 drv->driver.name, error);
803 drv->driver.name, error);
804} 786}
805 787
806int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name) 788int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name)
@@ -820,8 +802,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons
820 802
821 error = driver_register(&drv->driver); 803 error = driver_register(&drv->driver);
822 if (error) { 804 if (error) {
823 printk(KERN_ERR 805 pr_err("driver_register() failed for %s, error: %d\n",
824 "serio: driver_register() failed for %s, error: %d\n",
825 drv->driver.name, error); 806 drv->driver.name, error);
826 return error; 807 return error;
827 } 808 }
@@ -987,7 +968,7 @@ irqreturn_t serio_interrupt(struct serio *serio,
987 968
988 if (likely(serio->drv)) { 969 if (likely(serio->drv)) {
989 ret = serio->drv->interrupt(serio, data, dfl); 970 ret = serio->drv->interrupt(serio, data, dfl);
990 } else if (!dfl && serio->registered) { 971 } else if (!dfl && device_is_registered(&serio->dev)) {
991 serio_rescan(serio); 972 serio_rescan(serio);
992 ret = IRQ_HANDLED; 973 ret = IRQ_HANDLED;
993 } 974 }
@@ -1018,7 +999,7 @@ static int __init serio_init(void)
1018 999
1019 error = bus_register(&serio_bus); 1000 error = bus_register(&serio_bus);
1020 if (error) { 1001 if (error) {
1021 printk(KERN_ERR "serio: failed to register serio bus, error: %d\n", error); 1002 pr_err("Failed to register serio bus, error: %d\n", error);
1022 return error; 1003 return error;
1023 } 1004 }
1024 1005
@@ -1026,7 +1007,7 @@ static int __init serio_init(void)
1026 if (IS_ERR(serio_task)) { 1007 if (IS_ERR(serio_task)) {
1027 bus_unregister(&serio_bus); 1008 bus_unregister(&serio_bus);
1028 error = PTR_ERR(serio_task); 1009 error = PTR_ERR(serio_task);
1029 printk(KERN_ERR "serio: Failed to start kseriod, error: %d\n", error); 1010 pr_err("Failed to start kseriod, error: %d\n", error);
1030 return error; 1011 return error;
1031 } 1012 }
1032 1013
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c
index ebb22f88c84..8298e1f6823 100644
--- a/drivers/input/serio/xilinx_ps2.c
+++ b/drivers/input/serio/xilinx_ps2.c
@@ -270,7 +270,7 @@ static int __devinit xps2_of_probe(struct of_device *ofdev,
270 drvdata->irq = r_irq.start; 270 drvdata->irq = r_irq.start;
271 271
272 phys_addr = r_mem.start; 272 phys_addr = r_mem.start;
273 remap_size = r_mem.end - r_mem.start + 1; 273 remap_size = resource_size(&r_mem);
274 if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) { 274 if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) {
275 dev_err(dev, "Couldn't lock memory region at 0x%08llX\n", 275 dev_err(dev, "Couldn't lock memory region at 0x%08llX\n",
276 (unsigned long long)phys_addr); 276 (unsigned long long)phys_addr);
@@ -344,7 +344,7 @@ static int __devexit xps2_of_remove(struct of_device *of_dev)
344 if (of_address_to_resource(of_dev->node, 0, &r_mem)) 344 if (of_address_to_resource(of_dev->node, 0, &r_mem))
345 dev_err(dev, "invalid address\n"); 345 dev_err(dev, "invalid address\n");
346 else 346 else
347 release_mem_region(r_mem.start, r_mem.end - r_mem.start + 1); 347 release_mem_region(r_mem.start, resource_size(&r_mem));
348 348
349 kfree(drvdata); 349 kfree(drvdata);
350 350
@@ -354,7 +354,7 @@ static int __devexit xps2_of_remove(struct of_device *of_dev)
354} 354}
355 355
356/* Match table for of_platform binding */ 356/* Match table for of_platform binding */
357static struct of_device_id xps2_of_match[] __devinitdata = { 357static const struct of_device_id xps2_of_match[] __devinitconst = {
358 { .compatible = "xlnx,xps-ps2-1.00.a", }, 358 { .compatible = "xlnx,xps-ps2-1.00.a", },
359 { /* end of list */ }, 359 { /* end of list */ },
360}; 360};
diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
index 3d32d3f4e48..866a9ee1af1 100644
--- a/drivers/input/tablet/gtco.c
+++ b/drivers/input/tablet/gtco.c
@@ -92,7 +92,7 @@ Scott Hill shill@gtcocalcomp.com
92/* DATA STRUCTURES */ 92/* DATA STRUCTURES */
93 93
94/* Device table */ 94/* Device table */
95static struct usb_device_id gtco_usbid_table [] = { 95static const struct usb_device_id gtco_usbid_table[] = {
96 { USB_DEVICE(VENDOR_ID_GTCO, PID_400) }, 96 { USB_DEVICE(VENDOR_ID_GTCO, PID_400) },
97 { USB_DEVICE(VENDOR_ID_GTCO, PID_401) }, 97 { USB_DEVICE(VENDOR_ID_GTCO, PID_401) },
98 { USB_DEVICE(VENDOR_ID_GTCO, PID_1000) }, 98 { USB_DEVICE(VENDOR_ID_GTCO, PID_1000) },
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index 16310f368da..8fef1b689c6 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -85,6 +85,7 @@
85#include <linux/kernel.h> 85#include <linux/kernel.h>
86#include <linux/slab.h> 86#include <linux/slab.h>
87#include <linux/module.h> 87#include <linux/module.h>
88#include <linux/mod_devicetable.h>
88#include <linux/init.h> 89#include <linux/init.h>
89#include <linux/usb/input.h> 90#include <linux/usb/input.h>
90#include <asm/unaligned.h> 91#include <asm/unaligned.h>
@@ -120,6 +121,8 @@ struct wacom_combo {
120 struct urb *urb; 121 struct urb *urb;
121}; 122};
122 123
124extern const struct usb_device_id wacom_ids[];
125
123extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 126extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
124extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data); 127extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data);
125extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data); 128extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data);
@@ -142,7 +145,5 @@ extern void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wa
142extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 145extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
143extern __u16 wacom_le16_to_cpu(unsigned char *data); 146extern __u16 wacom_le16_to_cpu(unsigned char *data);
144extern __u16 wacom_be16_to_cpu(unsigned char *data); 147extern __u16 wacom_be16_to_cpu(unsigned char *data);
145extern struct wacom_features *get_wacom_feature(const struct usb_device_id *id);
146extern const struct usb_device_id *get_device_table(void);
147 148
148#endif 149#endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 072f33b3b2b..a1770e6feee 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -211,7 +211,8 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | 211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
212 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | 212 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) |
213 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); 213 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2);
214 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 214 input_set_abs_params(input_dev, ABS_DISTANCE,
215 0, wacom_wac->features.distance_max, 0, 0);
215} 216}
216 217
217void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 218void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -261,7 +262,8 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
261 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) | 262 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) |
262 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) | 263 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) |
263 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2); 264 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2);
264 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 265 input_set_abs_params(input_dev, ABS_DISTANCE,
266 0, wacom_wac->features.distance_max, 0, 0);
265 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); 267 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
266 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); 268 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
267 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); 269 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
@@ -282,17 +284,19 @@ void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
282 284
283void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 285void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
284{ 286{
285 if (wacom_wac->features->device_type == BTN_TOOL_DOUBLETAP || 287 struct wacom_features *features = &wacom_wac->features;
286 wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { 288
287 input_set_abs_params(input_dev, ABS_RX, 0, wacom_wac->features->x_phy, 0, 0); 289 if (features->device_type == BTN_TOOL_DOUBLETAP ||
288 input_set_abs_params(input_dev, ABS_RY, 0, wacom_wac->features->y_phy, 0, 0); 290 features->device_type == BTN_TOOL_TRIPLETAP) {
289 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP); 291 input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0);
292 input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0);
293 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
290 } 294 }
291} 295}
292 296
293void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 297void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
294{ 298{
295 if (wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { 299 if (wacom_wac->features.device_type == BTN_TOOL_TRIPLETAP) {
296 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP); 300 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP);
297 input_dev->evbit[0] |= BIT_MASK(EV_MSC); 301 input_dev->evbit[0] |= BIT_MASK(EV_MSC);
298 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); 302 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
@@ -532,21 +536,38 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
532 struct wacom_wac *wacom_wac; 536 struct wacom_wac *wacom_wac;
533 struct wacom_features *features; 537 struct wacom_features *features;
534 struct input_dev *input_dev; 538 struct input_dev *input_dev;
535 int error = -ENOMEM; 539 int error;
540
541 if (!id->driver_info)
542 return -EINVAL;
536 543
537 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 544 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
538 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); 545 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL);
539 input_dev = input_allocate_device(); 546 input_dev = input_allocate_device();
540 if (!wacom || !input_dev || !wacom_wac) 547 if (!wacom || !input_dev || !wacom_wac) {
548 error = -ENOMEM;
541 goto fail1; 549 goto fail1;
550 }
542 551
543 wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX, GFP_KERNEL, &wacom->data_dma); 552 wacom_wac->features = *((struct wacom_features *)id->driver_info);
544 if (!wacom_wac->data) 553 features = &wacom_wac->features;
554 if (features->pktlen > WACOM_PKGLEN_MAX) {
555 error = -EINVAL;
545 goto fail1; 556 goto fail1;
557 }
558
559 wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX,
560 GFP_KERNEL, &wacom->data_dma);
561 if (!wacom_wac->data) {
562 error = -ENOMEM;
563 goto fail1;
564 }
546 565
547 wacom->irq = usb_alloc_urb(0, GFP_KERNEL); 566 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
548 if (!wacom->irq) 567 if (!wacom->irq) {
568 error = -ENOMEM;
549 goto fail2; 569 goto fail2;
570 }
550 571
551 wacom->usbdev = dev; 572 wacom->usbdev = dev;
552 wacom->dev = input_dev; 573 wacom->dev = input_dev;
@@ -555,11 +576,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
555 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 576 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
556 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 577 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
557 578
558 wacom_wac->features = features = get_wacom_feature(id);
559 BUG_ON(features->pktlen > WACOM_PKGLEN_MAX);
560
561 input_dev->name = wacom_wac->features->name;
562 wacom->wacom_wac = wacom_wac;
563 usb_to_input_id(dev, &input_dev->id); 579 usb_to_input_id(dev, &input_dev->id);
564 580
565 input_dev->dev.parent = &intf->dev; 581 input_dev->dev.parent = &intf->dev;
@@ -576,6 +592,19 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
576 if (error) 592 if (error)
577 goto fail2; 593 goto fail2;
578 594
595 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
596
597 if (features->type == TABLETPC || features->type == TABLETPC2FG) {
598 /* Append the device type to the name */
599 strlcat(wacom_wac->name,
600 features->device_type == BTN_TOOL_PEN ?
601 " Pen" : " Finger",
602 sizeof(wacom_wac->name));
603 }
604
605 input_dev->name = wacom_wac->name;
606 wacom->wacom_wac = wacom_wac;
607
579 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 608 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
580 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH); 609 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH);
581 610
@@ -640,7 +669,7 @@ static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
640static int wacom_resume(struct usb_interface *intf) 669static int wacom_resume(struct usb_interface *intf)
641{ 670{
642 struct wacom *wacom = usb_get_intfdata(intf); 671 struct wacom *wacom = usb_get_intfdata(intf);
643 struct wacom_features *features = wacom->wacom_wac->features; 672 struct wacom_features *features = &wacom->wacom_wac->features;
644 int rv; 673 int rv;
645 674
646 mutex_lock(&wacom->lock); 675 mutex_lock(&wacom->lock);
@@ -663,6 +692,7 @@ static int wacom_reset_resume(struct usb_interface *intf)
663 692
664static struct usb_driver wacom_driver = { 693static struct usb_driver wacom_driver = {
665 .name = "wacom", 694 .name = "wacom",
695 .id_table = wacom_ids,
666 .probe = wacom_probe, 696 .probe = wacom_probe,
667 .disconnect = wacom_disconnect, 697 .disconnect = wacom_disconnect,
668 .suspend = wacom_suspend, 698 .suspend = wacom_suspend,
@@ -674,7 +704,7 @@ static struct usb_driver wacom_driver = {
674static int __init wacom_init(void) 704static int __init wacom_init(void)
675{ 705{
676 int result; 706 int result;
677 wacom_driver.id_table = get_device_table(); 707
678 result = usb_register(&wacom_driver); 708 result = usb_register(&wacom_driver);
679 if (result == 0) 709 if (result == 0)
680 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 710 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 1056f149fe3..3d81443e683 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -55,6 +55,7 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
55 55
56static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo) 56static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
57{ 57{
58 struct wacom_features *features = &wacom->features;
58 unsigned char *data = wacom->data; 59 unsigned char *data = wacom->data;
59 int prox, pressure; 60 int prox, pressure;
60 61
@@ -68,9 +69,9 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
68 if (prox) { 69 if (prox) {
69 wacom->id[0] = ERASER_DEVICE_ID; 70 wacom->id[0] = ERASER_DEVICE_ID;
70 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); 71 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
71 if (wacom->features->pressure_max > 255) 72 if (features->pressure_max > 255)
72 pressure = (pressure << 1) | ((data[4] >> 6) & 1); 73 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
73 pressure += (wacom->features->pressure_max + 1) / 2; 74 pressure += (features->pressure_max + 1) / 2;
74 75
75 /* 76 /*
76 * if going from out of proximity into proximity select between the eraser 77 * if going from out of proximity into proximity select between the eraser
@@ -152,6 +153,7 @@ static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
152 153
153static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo) 154static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
154{ 155{
156 struct wacom_features *features = &wacom->features;
155 unsigned char *data = wacom->data; 157 unsigned char *data = wacom->data;
156 int x, y, rw; 158 int x, y, rw;
157 static int penData = 0; 159 static int penData = 0;
@@ -179,8 +181,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
179 181
180 case 2: /* Mouse with wheel */ 182 case 2: /* Mouse with wheel */
181 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04); 183 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
182 if (wacom->features->type == WACOM_G4 || 184 if (features->type == WACOM_G4 || features->type == WACOM_MO) {
183 wacom->features->type == WACOM_MO) {
184 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03); 185 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
185 wacom_report_rel(wcombo, REL_WHEEL, -rw); 186 wacom_report_rel(wcombo, REL_WHEEL, -rw);
186 } else 187 } else
@@ -192,8 +193,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
192 wacom->id[0] = CURSOR_DEVICE_ID; 193 wacom->id[0] = CURSOR_DEVICE_ID;
193 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); 194 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
194 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); 195 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
195 if (wacom->features->type == WACOM_G4 || 196 if (features->type == WACOM_G4 || features->type == WACOM_MO)
196 wacom->features->type == WACOM_MO)
197 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f); 197 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
198 else 198 else
199 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f); 199 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
@@ -230,7 +230,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
230 } 230 }
231 231
232 /* send pad data */ 232 /* send pad data */
233 switch (wacom->features->type) { 233 switch (features->type) {
234 case WACOM_G4: 234 case WACOM_G4:
235 if (data[7] & 0xf8) { 235 if (data[7] & 0xf8) {
236 if (penData) { 236 if (penData) {
@@ -300,11 +300,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
300 300
301static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo) 301static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
302{ 302{
303 struct wacom_features *features = &wacom->features;
303 unsigned char *data = wacom->data; 304 unsigned char *data = wacom->data;
304 int idx = 0; 305 int idx = 0;
305 306
306 /* tool number */ 307 /* tool number */
307 if (wacom->features->type == INTUOS) 308 if (features->type == INTUOS)
308 idx = data[1] & 0x01; 309 idx = data[1] & 0x01;
309 310
310 /* Enter report */ 311 /* Enter report */
@@ -402,7 +403,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
402 wacom_report_key(wcombo, BTN_STYLUS2, 0); 403 wacom_report_key(wcombo, BTN_STYLUS2, 0);
403 wacom_report_key(wcombo, BTN_TOUCH, 0); 404 wacom_report_key(wcombo, BTN_TOUCH, 0);
404 wacom_report_abs(wcombo, ABS_WHEEL, 0); 405 wacom_report_abs(wcombo, ABS_WHEEL, 0);
405 if (wacom->features->type >= INTUOS3S) 406 if (features->type >= INTUOS3S)
406 wacom_report_abs(wcombo, ABS_Z, 0); 407 wacom_report_abs(wcombo, ABS_Z, 0);
407 } 408 }
408 wacom_report_key(wcombo, wacom->tool[idx], 0); 409 wacom_report_key(wcombo, wacom->tool[idx], 0);
@@ -416,13 +417,14 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
416 417
417static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo) 418static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
418{ 419{
420 struct wacom_features *features = &wacom->features;
419 unsigned char *data = wacom->data; 421 unsigned char *data = wacom->data;
420 unsigned int t; 422 unsigned int t;
421 423
422 /* general pen packet */ 424 /* general pen packet */
423 if ((data[1] & 0xb8) == 0xa0) { 425 if ((data[1] & 0xb8) == 0xa0) {
424 t = (data[6] << 2) | ((data[7] >> 6) & 3); 426 t = (data[6] << 2) | ((data[7] >> 6) & 3);
425 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) 427 if (features->type >= INTUOS4S && features->type <= INTUOS4L)
426 t = (t << 1) | (data[1] & 1); 428 t = (t << 1) | (data[1] & 1);
427 wacom_report_abs(wcombo, ABS_PRESSURE, t); 429 wacom_report_abs(wcombo, ABS_PRESSURE, t);
428 wacom_report_abs(wcombo, ABS_TILT_X, 430 wacom_report_abs(wcombo, ABS_TILT_X,
@@ -446,6 +448,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
446 448
447static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo) 449static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
448{ 450{
451 struct wacom_features *features = &wacom->features;
449 unsigned char *data = wacom->data; 452 unsigned char *data = wacom->data;
450 unsigned int t; 453 unsigned int t;
451 int idx = 0, result; 454 int idx = 0, result;
@@ -457,7 +460,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
457 } 460 }
458 461
459 /* tool number */ 462 /* tool number */
460 if (wacom->features->type == INTUOS) 463 if (features->type == INTUOS)
461 idx = data[1] & 0x01; 464 idx = data[1] & 0x01;
462 465
463 /* pad packets. Works as a second tool and is always in prox */ 466 /* pad packets. Works as a second tool and is always in prox */
@@ -466,7 +469,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
466 if (wacom->tool[1] != BTN_TOOL_FINGER) 469 if (wacom->tool[1] != BTN_TOOL_FINGER)
467 wacom->tool[1] = BTN_TOOL_FINGER; 470 wacom->tool[1] = BTN_TOOL_FINGER;
468 471
469 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) { 472 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
470 wacom_report_key(wcombo, BTN_0, (data[2] & 0x01)); 473 wacom_report_key(wcombo, BTN_0, (data[2] & 0x01));
471 wacom_report_key(wcombo, BTN_1, (data[3] & 0x01)); 474 wacom_report_key(wcombo, BTN_1, (data[3] & 0x01));
472 wacom_report_key(wcombo, BTN_2, (data[3] & 0x02)); 475 wacom_report_key(wcombo, BTN_2, (data[3] & 0x02));
@@ -480,7 +483,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
480 /* Out of proximity, clear wheel value. */ 483 /* Out of proximity, clear wheel value. */
481 wacom_report_abs(wcombo, ABS_WHEEL, 0); 484 wacom_report_abs(wcombo, ABS_WHEEL, 0);
482 } 485 }
483 if (wacom->features->type != INTUOS4S) { 486 if (features->type != INTUOS4S) {
484 wacom_report_key(wcombo, BTN_7, (data[3] & 0x40)); 487 wacom_report_key(wcombo, BTN_7, (data[3] & 0x40));
485 wacom_report_key(wcombo, BTN_8, (data[3] & 0x80)); 488 wacom_report_key(wcombo, BTN_8, (data[3] & 0x80));
486 } 489 }
@@ -528,18 +531,20 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
528 return 0; 531 return 0;
529 532
530 /* Only large Intuos support Lense Cursor */ 533 /* Only large Intuos support Lense Cursor */
531 if ((wacom->tool[idx] == BTN_TOOL_LENS) 534 if (wacom->tool[idx] == BTN_TOOL_LENS &&
532 && ((wacom->features->type == INTUOS3) 535 (features->type == INTUOS3 ||
533 || (wacom->features->type == INTUOS3S) 536 features->type == INTUOS3S ||
534 || (wacom->features->type == INTUOS4) 537 features->type == INTUOS4 ||
535 || (wacom->features->type == INTUOS4S))) 538 features->type == INTUOS4S)) {
539
536 return 0; 540 return 0;
541 }
537 542
538 /* Cintiq doesn't send data when RDY bit isn't set */ 543 /* Cintiq doesn't send data when RDY bit isn't set */
539 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40)) 544 if (features->type == CINTIQ && !(data[1] & 0x40))
540 return 0; 545 return 0;
541 546
542 if (wacom->features->type >= INTUOS3S) { 547 if (features->type >= INTUOS3S) {
543 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); 548 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
544 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); 549 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
545 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); 550 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
@@ -557,7 +562,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
557 562
558 if (data[1] & 0x02) { 563 if (data[1] & 0x02) {
559 /* Rotation packet */ 564 /* Rotation packet */
560 if (wacom->features->type >= INTUOS3S) { 565 if (features->type >= INTUOS3S) {
561 /* I3 marker pen rotation */ 566 /* I3 marker pen rotation */
562 t = (data[6] << 3) | ((data[7] >> 5) & 7); 567 t = (data[6] << 3) | ((data[7] >> 5) & 7);
563 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : 568 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
@@ -570,7 +575,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
570 ((t - 1) / 2) : -t / 2); 575 ((t - 1) / 2) : -t / 2);
571 } 576 }
572 577
573 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) { 578 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
574 /* 4D mouse packet */ 579 /* 4D mouse packet */
575 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 580 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
576 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 581 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -583,7 +588,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
583 588
584 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { 589 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
585 /* I4 mouse */ 590 /* I4 mouse */
586 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) { 591 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
587 wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01); 592 wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01);
588 wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02); 593 wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02);
589 wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04); 594 wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04);
@@ -604,13 +609,13 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
604 - ((data[8] & 0x02) >> 1)); 609 - ((data[8] & 0x02) >> 1));
605 610
606 /* I3 2D mouse side buttons */ 611 /* I3 2D mouse side buttons */
607 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) { 612 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
608 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40); 613 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
609 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20); 614 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
610 } 615 }
611 } 616 }
612 } else if ((wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L || 617 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
613 wacom->features->type == INTUOS4L) && 618 features->type == INTUOS4L) &&
614 wacom->tool[idx] == BTN_TOOL_LENS) { 619 wacom->tool[idx] == BTN_TOOL_LENS) {
615 /* Lens cursor packets */ 620 /* Lens cursor packets */
616 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 621 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
@@ -718,6 +723,7 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
718 723
719static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo) 724static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
720{ 725{
726 struct wacom_features *features = &wacom->features;
721 char *data = wacom->data; 727 char *data = wacom->data;
722 int prox = 0, pressure, idx = -1; 728 int prox = 0, pressure, idx = -1;
723 static int stylusInProx, touchInProx = 1, touchOut; 729 static int stylusInProx, touchInProx = 1, touchOut;
@@ -791,7 +797,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
791 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 797 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
792 pressure = ((data[7] & 0x01) << 8) | data[6]; 798 pressure = ((data[7] & 0x01) << 8) | data[6];
793 if (pressure < 0) 799 if (pressure < 0)
794 pressure = wacom->features->pressure_max + pressure + 1; 800 pressure = features->pressure_max + pressure + 1;
795 wacom_report_abs(wcombo, ABS_PRESSURE, pressure); 801 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
796 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05); 802 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05);
797 } else { 803 } else {
@@ -815,7 +821,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
815 821
816int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo) 822int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
817{ 823{
818 switch (wacom_wac->features->type) { 824 switch (wacom_wac->features.type) {
819 case PENPARTNER: 825 case PENPARTNER:
820 return wacom_penpartner_irq(wacom_wac, wcombo); 826 return wacom_penpartner_irq(wacom_wac, wcombo);
821 827
@@ -853,7 +859,7 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
853 859
854void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 860void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
855{ 861{
856 switch (wacom_wac->features->type) { 862 switch (wacom_wac->features.type) {
857 case WACOM_MO: 863 case WACOM_MO:
858 input_dev_mo(input_dev, wacom_wac); 864 input_dev_mo(input_dev, wacom_wac);
859 case WACOM_G4: 865 case WACOM_G4:
@@ -888,7 +894,7 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
888 /* fall through */ 894 /* fall through */
889 case TABLETPC: 895 case TABLETPC:
890 input_dev_tpc(input_dev, wacom_wac); 896 input_dev_tpc(input_dev, wacom_wac);
891 if (wacom_wac->features->device_type != BTN_TOOL_PEN) 897 if (wacom_wac->features.device_type != BTN_TOOL_PEN)
892 break; /* no need to process stylus stuff */ 898 break; /* no need to process stylus stuff */
893 899
894 /* fall through */ 900 /* fall through */
@@ -903,153 +909,201 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
903 return; 909 return;
904} 910}
905 911
906static struct wacom_features wacom_features[] = { 912static const struct wacom_features wacom_features_0x00 =
907 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER }, 913 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER };
908 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }, 914static const struct wacom_features wacom_features_0x10 =
909 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }, 915 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE };
910 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE }, 916static const struct wacom_features wacom_features_0x11 =
911 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE }, 917 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE };
912 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }, 918static const struct wacom_features wacom_features_0x12 =
913 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 }, 919 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE };
914 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 }, 920static const struct wacom_features wacom_features_0x13 =
915 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }, 921 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE };
916 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO }, 922static const struct wacom_features wacom_features_0x14 =
917 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }, 923 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE };
918 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 924static const struct wacom_features wacom_features_0x15 =
919 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE }, 925 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 };
920 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 926static const struct wacom_features wacom_features_0x16 =
921 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE }, 927 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 };
922 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE }, 928static const struct wacom_features wacom_features_0x17 =
923 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }, 929 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO };
924 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 930static const struct wacom_features wacom_features_0x18 =
925 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }, 931 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO };
926 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 932static const struct wacom_features wacom_features_0x19 =
927 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }, 933 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE };
928 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }, 934static const struct wacom_features wacom_features_0x60 =
929 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }, 935 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
930 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL }, 936static const struct wacom_features wacom_features_0x61 =
931 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL }, 937 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE };
932 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL }, 938static const struct wacom_features wacom_features_0x62 =
933 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL }, 939 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
934 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL }, 940static const struct wacom_features wacom_features_0x63 =
935 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL }, 941 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE };
936 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL }, 942static const struct wacom_features wacom_features_0x64 =
937 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }, 943 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE };
938 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL }, 944static const struct wacom_features wacom_features_0x65 =
939 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }, 945 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO };
940 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }, 946static const struct wacom_features wacom_features_0x69 =
941 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }, 947 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
942 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU }, 948static const struct wacom_features wacom_features_0x20 =
943 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }, 949 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS };
944 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 950static const struct wacom_features wacom_features_0x21 =
945 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }, 951 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
946 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }, 952static const struct wacom_features wacom_features_0x22 =
947 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }, 953 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS };
948 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S }, 954static const struct wacom_features wacom_features_0x23 =
949 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 }, 955 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS };
950 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 }, 956static const struct wacom_features wacom_features_0x24 =
951 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L }, 957 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS };
952 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L }, 958static const struct wacom_features wacom_features_0x30 =
953 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 }, 959 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL };
954 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S }, 960static const struct wacom_features wacom_features_0x31 =
955 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S }, 961 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL };
956 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 }, 962static const struct wacom_features wacom_features_0x32 =
957 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L }, 963 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL };
958 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L }, 964static const struct wacom_features wacom_features_0x33 =
959 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ }, 965 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL };
960 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE }, 966static const struct wacom_features wacom_features_0x34 =
961 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE }, 967 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL };
962 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL }, 968static const struct wacom_features wacom_features_0x35 =
963 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 969 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL };
964 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 970static const struct wacom_features wacom_features_0x37 =
965 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 971 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL };
966 { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC }, 972static const struct wacom_features wacom_features_0x38 =
967 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }, 973 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL };
968 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }, 974static const struct wacom_features wacom_features_0x39 =
969 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 975 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL };
976static const struct wacom_features wacom_features_0xC4 =
977 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL };
978static const struct wacom_features wacom_features_0xC0 =
979 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL };
980static const struct wacom_features wacom_features_0xC2 =
981 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL };
982static const struct wacom_features wacom_features_0x03 =
983 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU };
984static const struct wacom_features wacom_features_0x41 =
985 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS };
986static const struct wacom_features wacom_features_0x42 =
987 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
988static const struct wacom_features wacom_features_0x43 =
989 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS };
990static const struct wacom_features wacom_features_0x44 =
991 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS };
992static const struct wacom_features wacom_features_0x45 =
993 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS };
994static const struct wacom_features wacom_features_0xB0 =
995 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S };
996static const struct wacom_features wacom_features_0xB1 =
997 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 };
998static const struct wacom_features wacom_features_0xB2 =
999 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 };
1000static const struct wacom_features wacom_features_0xB3 =
1001 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L };
1002static const struct wacom_features wacom_features_0xB4 =
1003 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L };
1004static const struct wacom_features wacom_features_0xB5 =
1005 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 };
1006static const struct wacom_features wacom_features_0xB7 =
1007 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S };
1008static const struct wacom_features wacom_features_0xB8 =
1009 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S };
1010static const struct wacom_features wacom_features_0xB9 =
1011 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 };
1012static const struct wacom_features wacom_features_0xBA =
1013 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L };
1014static const struct wacom_features wacom_features_0xBB =
1015 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L };
1016static const struct wacom_features wacom_features_0x3F =
1017 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ };
1018static const struct wacom_features wacom_features_0xC5 =
1019 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE };
1020static const struct wacom_features wacom_features_0xC6 =
1021 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE };
1022static const struct wacom_features wacom_features_0xC7 =
1023 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL };
1024static const struct wacom_features wacom_features_0x90 =
1025 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
1026static const struct wacom_features wacom_features_0x93 =
1027 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
1028static const struct wacom_features wacom_features_0x9A =
1029 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
1030static const struct wacom_features wacom_features_0x9F =
1031 { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC };
1032static const struct wacom_features wacom_features_0xE2 =
1033 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };
1034static const struct wacom_features wacom_features_0xE3 =
1035 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };
1036static const struct wacom_features wacom_features_0x47 =
1037 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
1038
1039#define USB_DEVICE_WACOM(prod) \
1040 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
1041 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1042
1043const struct usb_device_id wacom_ids[] = {
1044 { USB_DEVICE_WACOM(0x00) },
1045 { USB_DEVICE_WACOM(0x10) },
1046 { USB_DEVICE_WACOM(0x11) },
1047 { USB_DEVICE_WACOM(0x12) },
1048 { USB_DEVICE_WACOM(0x13) },
1049 { USB_DEVICE_WACOM(0x14) },
1050 { USB_DEVICE_WACOM(0x15) },
1051 { USB_DEVICE_WACOM(0x16) },
1052 { USB_DEVICE_WACOM(0x17) },
1053 { USB_DEVICE_WACOM(0x18) },
1054 { USB_DEVICE_WACOM(0x19) },
1055 { USB_DEVICE_WACOM(0x60) },
1056 { USB_DEVICE_WACOM(0x61) },
1057 { USB_DEVICE_WACOM(0x62) },
1058 { USB_DEVICE_WACOM(0x63) },
1059 { USB_DEVICE_WACOM(0x64) },
1060 { USB_DEVICE_WACOM(0x65) },
1061 { USB_DEVICE_WACOM(0x69) },
1062 { USB_DEVICE_WACOM(0x20) },
1063 { USB_DEVICE_WACOM(0x21) },
1064 { USB_DEVICE_WACOM(0x22) },
1065 { USB_DEVICE_WACOM(0x23) },
1066 { USB_DEVICE_WACOM(0x24) },
1067 { USB_DEVICE_WACOM(0x30) },
1068 { USB_DEVICE_WACOM(0x31) },
1069 { USB_DEVICE_WACOM(0x32) },
1070 { USB_DEVICE_WACOM(0x33) },
1071 { USB_DEVICE_WACOM(0x34) },
1072 { USB_DEVICE_WACOM(0x35) },
1073 { USB_DEVICE_WACOM(0x37) },
1074 { USB_DEVICE_WACOM(0x38) },
1075 { USB_DEVICE_WACOM(0x39) },
1076 { USB_DEVICE_WACOM(0xC4) },
1077 { USB_DEVICE_WACOM(0xC0) },
1078 { USB_DEVICE_WACOM(0xC2) },
1079 { USB_DEVICE_WACOM(0x03) },
1080 { USB_DEVICE_WACOM(0x41) },
1081 { USB_DEVICE_WACOM(0x42) },
1082 { USB_DEVICE_WACOM(0x43) },
1083 { USB_DEVICE_WACOM(0x44) },
1084 { USB_DEVICE_WACOM(0x45) },
1085 { USB_DEVICE_WACOM(0xB0) },
1086 { USB_DEVICE_WACOM(0xB1) },
1087 { USB_DEVICE_WACOM(0xB2) },
1088 { USB_DEVICE_WACOM(0xB3) },
1089 { USB_DEVICE_WACOM(0xB4) },
1090 { USB_DEVICE_WACOM(0xB5) },
1091 { USB_DEVICE_WACOM(0xB7) },
1092 { USB_DEVICE_WACOM(0xB8) },
1093 { USB_DEVICE_WACOM(0xB9) },
1094 { USB_DEVICE_WACOM(0xBA) },
1095 { USB_DEVICE_WACOM(0xBB) },
1096 { USB_DEVICE_WACOM(0x3F) },
1097 { USB_DEVICE_WACOM(0xC5) },
1098 { USB_DEVICE_WACOM(0xC6) },
1099 { USB_DEVICE_WACOM(0xC7) },
1100 { USB_DEVICE_WACOM(0x90) },
1101 { USB_DEVICE_WACOM(0x93) },
1102 { USB_DEVICE_WACOM(0x9A) },
1103 { USB_DEVICE_WACOM(0x9F) },
1104 { USB_DEVICE_WACOM(0xE2) },
1105 { USB_DEVICE_WACOM(0xE3) },
1106 { USB_DEVICE_WACOM(0x47) },
970 { } 1107 { }
971}; 1108};
972
973static struct usb_device_id wacom_ids[] = {
974 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
975 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
976 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
977 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
978 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
979 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
980 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
981 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
982 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
983 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
984 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x19) },
985 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
986 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
987 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
988 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
989 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
990 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) },
991 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x69) },
992 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
993 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
994 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
995 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
996 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
997 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
998 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
999 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
1000 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
1001 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
1002 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
1003 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
1004 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
1005 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
1006 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
1007 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
1008 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC2) },
1009 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
1010 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
1011 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
1012 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
1013 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
1014 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
1015 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
1016 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
1017 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
1018 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
1019 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
1020 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
1021 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
1022 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB8) },
1023 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB9) },
1024 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBA) },
1025 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBB) },
1026 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
1027 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) },
1028 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
1029 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC7) },
1030 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x90) },
1031 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x93) },
1032 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9A) },
1033 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9F) },
1034 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE2) },
1035 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE3) },
1036 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
1037 { }
1038};
1039
1040const struct usb_device_id *get_device_table(void)
1041{
1042 const struct usb_device_id *id_table = wacom_ids;
1043
1044 return id_table;
1045}
1046
1047struct wacom_features * get_wacom_feature(const struct usb_device_id *id)
1048{
1049 int index = id - wacom_ids;
1050 struct wacom_features *wf = &wacom_features[index];
1051
1052 return wf;
1053}
1054
1055MODULE_DEVICE_TABLE(usb, wacom_ids); 1109MODULE_DEVICE_TABLE(usb, wacom_ids);
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index ee01e190278..8590b1e8ec3 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -15,11 +15,11 @@
15/* packet length for individual models */ 15/* packet length for individual models */
16#define WACOM_PKGLEN_PENPRTN 7 16#define WACOM_PKGLEN_PENPRTN 7
17#define WACOM_PKGLEN_GRAPHIRE 8 17#define WACOM_PKGLEN_GRAPHIRE 8
18#define WACOM_PKGLEN_BBFUN 9 18#define WACOM_PKGLEN_BBFUN 9
19#define WACOM_PKGLEN_INTUOS 10 19#define WACOM_PKGLEN_INTUOS 10
20#define WACOM_PKGLEN_PENABLED 8 20#define WACOM_PKGLEN_PENABLED 8
21#define WACOM_PKGLEN_TPC1FG 5 21#define WACOM_PKGLEN_TPC1FG 5
22#define WACOM_PKGLEN_TPC2FG 14 22#define WACOM_PKGLEN_TPC2FG 14
23 23
24/* device IDs */ 24/* device IDs */
25#define STYLUS_DEVICE_ID 0x02 25#define STYLUS_DEVICE_ID 0x02
@@ -58,7 +58,7 @@ enum {
58}; 58};
59 59
60struct wacom_features { 60struct wacom_features {
61 char *name; 61 const char *name;
62 int pktlen; 62 int pktlen;
63 int x_max; 63 int x_max;
64 int y_max; 64 int y_max;
@@ -73,11 +73,12 @@ struct wacom_features {
73}; 73};
74 74
75struct wacom_wac { 75struct wacom_wac {
76 char name[64];
76 unsigned char *data; 77 unsigned char *data;
77 int tool[2]; 78 int tool[2];
78 int id[2]; 79 int id[2];
79 __u32 serial[2]; 80 __u32 serial[2];
80 struct wacom_features *features; 81 struct wacom_features features;
81}; 82};
82 83
83#endif 84#endif
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index dfafc76da4f..6457e060ae4 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -90,7 +90,6 @@ config TOUCHSCREEN_CORGI
90 tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)" 90 tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)"
91 depends on PXA_SHARPSL 91 depends on PXA_SHARPSL
92 select CORGI_SSP_DEPRECATED 92 select CORGI_SSP_DEPRECATED
93 default y
94 help 93 help
95 Say Y here to enable the driver for the touchscreen on the 94 Say Y here to enable the driver for the touchscreen on the
96 Sharp SL-C7xx and SL-Cxx00 series of PDAs. 95 Sharp SL-C7xx and SL-Cxx00 series of PDAs.
@@ -537,6 +536,11 @@ config TOUCHSCREEN_USB_ETT_TC5UH
537 bool "ET&T TC5UH touchscreen controler support" if EMBEDDED 536 bool "ET&T TC5UH touchscreen controler support" if EMBEDDED
538 depends on TOUCHSCREEN_USB_COMPOSITE 537 depends on TOUCHSCREEN_USB_COMPOSITE
539 538
539config TOUCHSCREEN_USB_NEXIO
540 default y
541 bool "NEXIO/iNexio device support" if EMBEDDED
542 depends on TOUCHSCREEN_USB_COMPOSITE
543
540config TOUCHSCREEN_TOUCHIT213 544config TOUCHSCREEN_TOUCHIT213
541 tristate "Sahara TouchIT-213 touchscreen" 545 tristate "Sahara TouchIT-213 touchscreen"
542 select SERIO 546 select SERIO
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 52d2ca147d8..8b05d8e9754 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -27,6 +27,7 @@
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
29#include <linux/spi/ads7846.h> 29#include <linux/spi/ads7846.h>
30#include <linux/regulator/consumer.h>
30#include <asm/irq.h> 31#include <asm/irq.h>
31 32
32/* 33/*
@@ -85,6 +86,7 @@ struct ads7846 {
85 char name[32]; 86 char name[32];
86 87
87 struct spi_device *spi; 88 struct spi_device *spi;
89 struct regulator *reg;
88 90
89#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) 91#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
90 struct attribute_group *attr_group; 92 struct attribute_group *attr_group;
@@ -788,6 +790,8 @@ static void ads7846_disable(struct ads7846 *ts)
788 } 790 }
789 } 791 }
790 792
793 regulator_disable(ts->reg);
794
791 /* we know the chip's in lowpower mode since we always 795 /* we know the chip's in lowpower mode since we always
792 * leave it that way after every request 796 * leave it that way after every request
793 */ 797 */
@@ -799,6 +803,8 @@ static void ads7846_enable(struct ads7846 *ts)
799 if (!ts->disabled) 803 if (!ts->disabled)
800 return; 804 return;
801 805
806 regulator_enable(ts->reg);
807
802 ts->disabled = 0; 808 ts->disabled = 0;
803 ts->irq_disabled = 0; 809 ts->irq_disabled = 0;
804 enable_irq(ts->spi->irq); 810 enable_irq(ts->spi->irq);
@@ -1139,6 +1145,19 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1139 1145
1140 ts->last_msg = m; 1146 ts->last_msg = m;
1141 1147
1148 ts->reg = regulator_get(&spi->dev, "vcc");
1149 if (IS_ERR(ts->reg)) {
1150 dev_err(&spi->dev, "unable to get regulator: %ld\n",
1151 PTR_ERR(ts->reg));
1152 goto err_free_gpio;
1153 }
1154
1155 err = regulator_enable(ts->reg);
1156 if (err) {
1157 dev_err(&spi->dev, "unable to enable regulator: %d\n", err);
1158 goto err_put_regulator;
1159 }
1160
1142 if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING, 1161 if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING,
1143 spi->dev.driver->name, ts)) { 1162 spi->dev.driver->name, ts)) {
1144 dev_info(&spi->dev, 1163 dev_info(&spi->dev,
@@ -1148,7 +1167,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1148 spi->dev.driver->name, ts); 1167 spi->dev.driver->name, ts);
1149 if (err) { 1168 if (err) {
1150 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1169 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
1151 goto err_free_gpio; 1170 goto err_disable_regulator;
1152 } 1171 }
1153 } 1172 }
1154 1173
@@ -1180,6 +1199,10 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1180 ads784x_hwmon_unregister(spi, ts); 1199 ads784x_hwmon_unregister(spi, ts);
1181 err_free_irq: 1200 err_free_irq:
1182 free_irq(spi->irq, ts); 1201 free_irq(spi->irq, ts);
1202 err_disable_regulator:
1203 regulator_disable(ts->reg);
1204 err_put_regulator:
1205 regulator_put(ts->reg);
1183 err_free_gpio: 1206 err_free_gpio:
1184 if (ts->gpio_pendown != -1) 1207 if (ts->gpio_pendown != -1)
1185 gpio_free(ts->gpio_pendown); 1208 gpio_free(ts->gpio_pendown);
@@ -1208,6 +1231,9 @@ static int __devexit ads7846_remove(struct spi_device *spi)
1208 /* suspend left the IRQ disabled */ 1231 /* suspend left the IRQ disabled */
1209 enable_irq(ts->spi->irq); 1232 enable_irq(ts->spi->irq);
1210 1233
1234 regulator_disable(ts->reg);
1235 regulator_put(ts->reg);
1236
1211 if (ts->gpio_pendown != -1) 1237 if (ts->gpio_pendown != -1)
1212 gpio_free(ts->gpio_pendown); 1238 gpio_free(ts->gpio_pendown);
1213 1239
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index 8f38c5e55ce..486d31ba9c0 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -72,45 +72,49 @@ static void elo_process_data_10(struct elo *elo, unsigned char data)
72 struct input_dev *dev = elo->dev; 72 struct input_dev *dev = elo->dev;
73 73
74 elo->data[elo->idx] = data; 74 elo->data[elo->idx] = data;
75 switch (elo->idx++) {
76 case 0:
77 elo->csum = 0xaa;
78 if (data != ELO10_LEAD_BYTE) {
79 pr_debug("elo: unsynchronized data: 0x%02x\n", data);
80 elo->idx = 0;
81 }
82 break;
83 75
84 case 9: 76 switch (elo->idx++) {
77 case 0:
78 elo->csum = 0xaa;
79 if (data != ELO10_LEAD_BYTE) {
80 dev_dbg(&elo->serio->dev,
81 "unsynchronized data: 0x%02x\n", data);
85 elo->idx = 0; 82 elo->idx = 0;
86 if (data != elo->csum) { 83 }
87 pr_debug("elo: bad checksum: 0x%02x, expected 0x%02x\n", 84 break;
88 data, elo->csum); 85
89 break; 86 case 9:
90 } 87 elo->idx = 0;
91 if (elo->data[1] != elo->expected_packet) { 88 if (data != elo->csum) {
92 if (elo->data[1] != ELO10_TOUCH_PACKET) 89 dev_dbg(&elo->serio->dev,
93 pr_debug("elo: unexpected packet: 0x%02x\n", 90 "bad checksum: 0x%02x, expected 0x%02x\n",
94 elo->data[1]); 91 data, elo->csum);
95 break; 92 break;
96 } 93 }
97 if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) { 94 if (elo->data[1] != elo->expected_packet) {
98 input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); 95 if (elo->data[1] != ELO10_TOUCH_PACKET)
99 input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); 96 dev_dbg(&elo->serio->dev,
100 if (elo->data[2] & ELO10_PRESSURE) 97 "unexpected packet: 0x%02x\n",
101 input_report_abs(dev, ABS_PRESSURE, 98 elo->data[1]);
102 (elo->data[8] << 8) | elo->data[7]);
103 input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH);
104 input_sync(dev);
105 } else if (elo->data[1] == ELO10_ACK_PACKET) {
106 if (elo->data[2] == '0')
107 elo->expected_packet = ELO10_TOUCH_PACKET;
108 complete(&elo->cmd_done);
109 } else {
110 memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN);
111 elo->expected_packet = ELO10_ACK_PACKET;
112 }
113 break; 99 break;
100 }
101 if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) {
102 input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]);
103 input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]);
104 if (elo->data[2] & ELO10_PRESSURE)
105 input_report_abs(dev, ABS_PRESSURE,
106 (elo->data[8] << 8) | elo->data[7]);
107 input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH);
108 input_sync(dev);
109 } else if (elo->data[1] == ELO10_ACK_PACKET) {
110 if (elo->data[2] == '0')
111 elo->expected_packet = ELO10_TOUCH_PACKET;
112 complete(&elo->cmd_done);
113 } else {
114 memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN);
115 elo->expected_packet = ELO10_ACK_PACKET;
116 }
117 break;
114 } 118 }
115 elo->csum += data; 119 elo->csum += data;
116} 120}
@@ -123,42 +127,53 @@ static void elo_process_data_6(struct elo *elo, unsigned char data)
123 127
124 switch (elo->idx++) { 128 switch (elo->idx++) {
125 129
126 case 0: if ((data & 0xc0) != 0xc0) elo->idx = 0; break; 130 case 0:
127 case 1: if ((data & 0xc0) != 0x80) elo->idx = 0; break; 131 if ((data & 0xc0) != 0xc0)
128 case 2: if ((data & 0xc0) != 0x40) elo->idx = 0; break; 132 elo->idx = 0;
129 133 break;
130 case 3:
131 if (data & 0xc0) {
132 elo->idx = 0;
133 break;
134 }
135 134
136 input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f)); 135 case 1:
137 input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f)); 136 if ((data & 0xc0) != 0x80)
137 elo->idx = 0;
138 break;
138 139
139 if (elo->id == 2) { 140 case 2:
140 input_report_key(dev, BTN_TOUCH, 1); 141 if ((data & 0xc0) != 0x40)
141 input_sync(dev); 142 elo->idx = 0;
142 elo->idx = 0; 143 break;
143 }
144 144
145 case 3:
146 if (data & 0xc0) {
147 elo->idx = 0;
145 break; 148 break;
149 }
146 150
147 case 4: 151 input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f));
148 if (data) { 152 input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f));
149 input_sync(dev);
150 elo->idx = 0;
151 }
152 break;
153 153
154 case 5: 154 if (elo->id == 2) {
155 if ((data & 0xf0) == 0) { 155 input_report_key(dev, BTN_TOUCH, 1);
156 input_report_abs(dev, ABS_PRESSURE, elo->data[5]);
157 input_report_key(dev, BTN_TOUCH, !!elo->data[5]);
158 }
159 input_sync(dev); 156 input_sync(dev);
160 elo->idx = 0; 157 elo->idx = 0;
161 break; 158 }
159
160 break;
161
162 case 4:
163 if (data) {
164 input_sync(dev);
165 elo->idx = 0;
166 }
167 break;
168
169 case 5:
170 if ((data & 0xf0) == 0) {
171 input_report_abs(dev, ABS_PRESSURE, elo->data[5]);
172 input_report_key(dev, BTN_TOUCH, !!elo->data[5]);
173 }
174 input_sync(dev);
175 elo->idx = 0;
176 break;
162 } 177 }
163} 178}
164 179
@@ -170,17 +185,17 @@ static void elo_process_data_3(struct elo *elo, unsigned char data)
170 185
171 switch (elo->idx++) { 186 switch (elo->idx++) {
172 187
173 case 0: 188 case 0:
174 if ((data & 0x7f) != 0x01) 189 if ((data & 0x7f) != 0x01)
175 elo->idx = 0;
176 break;
177 case 2:
178 input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80));
179 input_report_abs(dev, ABS_X, elo->data[1]);
180 input_report_abs(dev, ABS_Y, elo->data[2]);
181 input_sync(dev);
182 elo->idx = 0; 190 elo->idx = 0;
183 break; 191 break;
192 case 2:
193 input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80));
194 input_report_abs(dev, ABS_X, elo->data[1]);
195 input_report_abs(dev, ABS_Y, elo->data[2]);
196 input_sync(dev);
197 elo->idx = 0;
198 break;
184 } 199 }
185} 200}
186 201
@@ -189,19 +204,19 @@ static irqreturn_t elo_interrupt(struct serio *serio,
189{ 204{
190 struct elo *elo = serio_get_drvdata(serio); 205 struct elo *elo = serio_get_drvdata(serio);
191 206
192 switch(elo->id) { 207 switch (elo->id) {
193 case 0: 208 case 0:
194 elo_process_data_10(elo, data); 209 elo_process_data_10(elo, data);
195 break; 210 break;
196 211
197 case 1: 212 case 1:
198 case 2: 213 case 2:
199 elo_process_data_6(elo, data); 214 elo_process_data_6(elo, data);
200 break; 215 break;
201 216
202 case 3: 217 case 3:
203 elo_process_data_3(elo, data); 218 elo_process_data_3(elo, data);
204 break; 219 break;
205 } 220 }
206 221
207 return IRQ_HANDLED; 222 return IRQ_HANDLED;
@@ -261,10 +276,10 @@ static int elo_setup_10(struct elo *elo)
261 if (packet[3] & ELO10_PRESSURE) 276 if (packet[3] & ELO10_PRESSURE)
262 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); 277 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
263 278
264 printk(KERN_INFO "elo: %sTouch touchscreen, fw: %02x.%02x, " 279 dev_info(&elo->serio->dev,
265 "features: 0x%02x, controller: 0x%02x\n", 280 "%sTouch touchscreen, fw: %02x.%02x, features: 0x%02x, controller: 0x%02x\n",
266 elo_types[(packet[1] -'0') & 0x03], 281 elo_types[(packet[1] -'0') & 0x03],
267 packet[5], packet[4], packet[3], packet[7]); 282 packet[5], packet[4], packet[3], packet[7]);
268 283
269 return 0; 284 return 0;
270} 285}
@@ -330,24 +345,24 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
330 345
331 switch (elo->id) { 346 switch (elo->id) {
332 347
333 case 0: /* 10-byte protocol */ 348 case 0: /* 10-byte protocol */
334 if (elo_setup_10(elo)) 349 if (elo_setup_10(elo))
335 goto fail3; 350 goto fail3;
336 351
337 break; 352 break;
338 353
339 case 1: /* 6-byte protocol */ 354 case 1: /* 6-byte protocol */
340 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); 355 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0);
341 356
342 case 2: /* 4-byte protocol */ 357 case 2: /* 4-byte protocol */
343 input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); 358 input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0);
344 input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); 359 input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0);
345 break; 360 break;
346 361
347 case 3: /* 3-byte protocol */ 362 case 3: /* 3-byte protocol */
348 input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); 363 input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0);
349 input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); 364 input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0);
350 break; 365 break;
351 } 366 }
352 367
353 err = input_register_device(elo->dev); 368 err = input_register_device(elo->dev);
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index 6cdcf2a6e03..b6b8b1c7ece 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -153,6 +153,9 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm)
153 if (pressure) 153 if (pressure)
154 p = MODR; 154 p = MODR;
155 155
156 dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n",
157 x, y, p);
158
156 /* are samples valid */ 159 /* are samples valid */
157 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || 160 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X ||
158 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y || 161 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y ||
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index 6386b441ef8..3755a47d053 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -128,27 +128,29 @@ static void touch_timer_fire(unsigned long data)
128 128
129 down = get_down(data0, data1); 129 down = get_down(data0, data1);
130 130
131 if (ts.count == (1 << ts.shift)) { 131 if (down) {
132 ts.xp >>= ts.shift; 132 if (ts.count == (1 << ts.shift)) {
133 ts.yp >>= ts.shift; 133 ts.xp >>= ts.shift;
134 ts.yp >>= ts.shift;
134 135
135 dev_dbg(ts.dev, "%s: X=%lu, Y=%lu, count=%d\n", 136 dev_dbg(ts.dev, "%s: X=%lu, Y=%lu, count=%d\n",
136 __func__, ts.xp, ts.yp, ts.count); 137 __func__, ts.xp, ts.yp, ts.count);
137 138
138 input_report_abs(ts.input, ABS_X, ts.xp); 139 input_report_abs(ts.input, ABS_X, ts.xp);
139 input_report_abs(ts.input, ABS_Y, ts.yp); 140 input_report_abs(ts.input, ABS_Y, ts.yp);
140 141
141 input_report_key(ts.input, BTN_TOUCH, 1); 142 input_report_key(ts.input, BTN_TOUCH, 1);
142 input_sync(ts.input); 143 input_sync(ts.input);
143 144
144 ts.xp = 0; 145 ts.xp = 0;
145 ts.yp = 0; 146 ts.yp = 0;
146 ts.count = 0; 147 ts.count = 0;
147 } 148 }
148 149
149 if (down) {
150 s3c_adc_start(ts.client, 0, 1 << ts.shift); 150 s3c_adc_start(ts.client, 0, 1 << ts.shift);
151 } else { 151 } else {
152 ts.xp = 0;
153 ts.yp = 0;
152 ts.count = 0; 154 ts.count = 0;
153 155
154 input_report_key(ts.input, BTN_TOUCH, 0); 156 input_report_key(ts.input, BTN_TOUCH, 0);
@@ -401,6 +403,7 @@ static int s3c2410ts_resume(struct device *dev)
401 struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; 403 struct s3c2410_ts_mach_info *info = pdev->dev.platform_data;
402 404
403 clk_enable(ts.clock); 405 clk_enable(ts.clock);
406 enable_irq(ts.irq_tc);
404 407
405 /* Initialise registers */ 408 /* Initialise registers */
406 if ((info->delay & 0xffff) > 0) 409 if ((info->delay & 0xffff) > 0)
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 7ef0d1420d3..be23780e8a3 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -358,7 +358,7 @@ static int __devexit tsc2007_remove(struct i2c_client *client)
358 return 0; 358 return 0;
359} 359}
360 360
361static struct i2c_device_id tsc2007_idtable[] = { 361static const struct i2c_device_id tsc2007_idtable[] = {
362 { "tsc2007", 0 }, 362 { "tsc2007", 0 },
363 { } 363 { }
364}; 364};
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 5256123a522..99330bbdbac 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -15,6 +15,7 @@
15 * - GoTop Super_Q2/GogoPen/PenPower tablets 15 * - GoTop Super_Q2/GogoPen/PenPower tablets
16 * - JASTEC USB touch controller/DigiTech DTR-02U 16 * - JASTEC USB touch controller/DigiTech DTR-02U
17 * - Zytronic capacitive touchscreen 17 * - Zytronic capacitive touchscreen
18 * - NEXIO/iNexio
18 * 19 *
19 * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch> 20 * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch>
20 * Copyright (C) by Todd E. Johnson (mtouchusb.c) 21 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
@@ -95,6 +96,7 @@ struct usbtouch_device_info {
95 96
96 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); 97 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt);
97 int (*init) (struct usbtouch_usb *usbtouch); 98 int (*init) (struct usbtouch_usb *usbtouch);
99 void (*exit) (struct usbtouch_usb *usbtouch);
98}; 100};
99 101
100/* a usbtouch device */ 102/* a usbtouch device */
@@ -104,11 +106,12 @@ struct usbtouch_usb {
104 unsigned char *buffer; 106 unsigned char *buffer;
105 int buf_len; 107 int buf_len;
106 struct urb *irq; 108 struct urb *irq;
107 struct usb_device *udev; 109 struct usb_interface *interface;
108 struct input_dev *input; 110 struct input_dev *input;
109 struct usbtouch_device_info *type; 111 struct usbtouch_device_info *type;
110 char name[128]; 112 char name[128];
111 char phys[64]; 113 char phys[64];
114 void *priv;
112 115
113 int x, y; 116 int x, y;
114 int touch, press; 117 int touch, press;
@@ -133,6 +136,7 @@ enum {
133 DEVTYPE_E2I, 136 DEVTYPE_E2I,
134 DEVTYPE_ZYTRONIC, 137 DEVTYPE_ZYTRONIC,
135 DEVTYPE_TC5UH, 138 DEVTYPE_TC5UH,
139 DEVTYPE_NEXIO,
136}; 140};
137 141
138#define USB_DEVICE_HID_CLASS(vend, prod) \ 142#define USB_DEVICE_HID_CLASS(vend, prod) \
@@ -144,7 +148,7 @@ enum {
144 .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ 148 .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
145 .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE 149 .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE
146 150
147static struct usb_device_id usbtouch_devices[] = { 151static const struct usb_device_id usbtouch_devices[] = {
148#ifdef CONFIG_TOUCHSCREEN_USB_EGALAX 152#ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
149 /* ignore the HID capable devices, handled by usbhid */ 153 /* ignore the HID capable devices, handled by usbhid */
150 {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE}, 154 {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE},
@@ -222,6 +226,14 @@ static struct usb_device_id usbtouch_devices[] = {
222 {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC5UH}, 226 {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC5UH},
223#endif 227#endif
224 228
229#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
230 /* data interface only */
231 {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00),
232 .driver_info = DEVTYPE_NEXIO},
233 {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00),
234 .driver_info = DEVTYPE_NEXIO},
235#endif
236
225 {} 237 {}
226}; 238};
227 239
@@ -234,8 +246,9 @@ static struct usb_device_id usbtouch_devices[] = {
234static int e2i_init(struct usbtouch_usb *usbtouch) 246static int e2i_init(struct usbtouch_usb *usbtouch)
235{ 247{
236 int ret; 248 int ret;
249 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
237 250
238 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 251 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
239 0x01, 0x02, 0x0000, 0x0081, 252 0x01, 0x02, 0x0000, 0x0081,
240 NULL, 0, USB_CTRL_SET_TIMEOUT); 253 NULL, 0, USB_CTRL_SET_TIMEOUT);
241 254
@@ -344,8 +357,9 @@ static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
344static int mtouch_init(struct usbtouch_usb *usbtouch) 357static int mtouch_init(struct usbtouch_usb *usbtouch)
345{ 358{
346 int ret, i; 359 int ret, i;
360 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
347 361
348 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 362 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
349 MTOUCHUSB_RESET, 363 MTOUCHUSB_RESET,
350 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 364 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
351 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); 365 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
@@ -356,7 +370,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch)
356 msleep(150); 370 msleep(150);
357 371
358 for (i = 0; i < 3; i++) { 372 for (i = 0; i < 3; i++) {
359 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 373 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
360 MTOUCHUSB_ASYNC_REPORT, 374 MTOUCHUSB_ASYNC_REPORT,
361 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 375 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
362 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); 376 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
@@ -489,7 +503,7 @@ static int gunze_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
489 503
490static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) 504static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
491{ 505{
492 struct usb_device *dev = usbtouch->udev; 506 struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
493 int ret = -ENOMEM; 507 int ret = -ENOMEM;
494 unsigned char *buf; 508 unsigned char *buf;
495 509
@@ -690,6 +704,229 @@ static int zytronic_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
690#endif 704#endif
691 705
692/***************************************************************************** 706/*****************************************************************************
707 * NEXIO Part
708 */
709#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
710
711#define NEXIO_TIMEOUT 5000
712#define NEXIO_BUFSIZE 1024
713#define NEXIO_THRESHOLD 50
714
715struct nexio_priv {
716 struct urb *ack;
717 unsigned char *ack_buf;
718};
719
720struct nexio_touch_packet {
721 u8 flags; /* 0xe1 = touch, 0xe1 = release */
722 __be16 data_len; /* total bytes of touch data */
723 __be16 x_len; /* bytes for X axis */
724 __be16 y_len; /* bytes for Y axis */
725 u8 data[];
726} __attribute__ ((packed));
727
728static unsigned char nexio_ack_pkt[2] = { 0xaa, 0x02 };
729static unsigned char nexio_init_pkt[4] = { 0x82, 0x04, 0x0a, 0x0f };
730
731static void nexio_ack_complete(struct urb *urb)
732{
733}
734
735static int nexio_init(struct usbtouch_usb *usbtouch)
736{
737 struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
738 struct usb_host_interface *interface = usbtouch->interface->cur_altsetting;
739 struct nexio_priv *priv;
740 int ret = -ENOMEM;
741 int actual_len, i;
742 unsigned char *buf;
743 char *firmware_ver = NULL, *device_name = NULL;
744 int input_ep = 0, output_ep = 0;
745
746 /* find first input and output endpoint */
747 for (i = 0; i < interface->desc.bNumEndpoints; i++) {
748 if (!input_ep &&
749 usb_endpoint_dir_in(&interface->endpoint[i].desc))
750 input_ep = interface->endpoint[i].desc.bEndpointAddress;
751 if (!output_ep &&
752 usb_endpoint_dir_out(&interface->endpoint[i].desc))
753 output_ep = interface->endpoint[i].desc.bEndpointAddress;
754 }
755 if (!input_ep || !output_ep)
756 return -ENXIO;
757
758 buf = kmalloc(NEXIO_BUFSIZE, GFP_KERNEL);
759 if (!buf)
760 goto out_buf;
761
762 /* two empty reads */
763 for (i = 0; i < 2; i++) {
764 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep),
765 buf, NEXIO_BUFSIZE, &actual_len,
766 NEXIO_TIMEOUT);
767 if (ret < 0)
768 goto out_buf;
769 }
770
771 /* send init command */
772 memcpy(buf, nexio_init_pkt, sizeof(nexio_init_pkt));
773 ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, output_ep),
774 buf, sizeof(nexio_init_pkt), &actual_len,
775 NEXIO_TIMEOUT);
776 if (ret < 0)
777 goto out_buf;
778
779 /* read replies */
780 for (i = 0; i < 3; i++) {
781 memset(buf, 0, NEXIO_BUFSIZE);
782 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep),
783 buf, NEXIO_BUFSIZE, &actual_len,
784 NEXIO_TIMEOUT);
785 if (ret < 0 || actual_len < 1 || buf[1] != actual_len)
786 continue;
787 switch (buf[0]) {
788 case 0x83: /* firmware version */
789 if (!firmware_ver)
790 firmware_ver = kstrdup(&buf[2], GFP_KERNEL);
791 break;
792 case 0x84: /* device name */
793 if (!device_name)
794 device_name = kstrdup(&buf[2], GFP_KERNEL);
795 break;
796 }
797 }
798
799 printk(KERN_INFO "Nexio device: %s, firmware version: %s\n",
800 device_name, firmware_ver);
801
802 kfree(firmware_ver);
803 kfree(device_name);
804
805 /* prepare ACK URB */
806 ret = -ENOMEM;
807
808 usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
809 if (!usbtouch->priv)
810 goto out_buf;
811
812 priv = usbtouch->priv;
813
814 priv->ack_buf = kmalloc(sizeof(nexio_ack_pkt), GFP_KERNEL);
815 if (!priv->ack_buf)
816 goto err_priv;
817
818 memcpy(priv->ack_buf, nexio_ack_pkt, sizeof(nexio_ack_pkt));
819
820 priv->ack = usb_alloc_urb(0, GFP_KERNEL);
821 if (!priv->ack) {
822 dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__);
823 goto err_ack_buf;
824 }
825
826 usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep),
827 priv->ack_buf, sizeof(nexio_ack_pkt),
828 nexio_ack_complete, usbtouch);
829 ret = 0;
830 goto out_buf;
831
832err_ack_buf:
833 kfree(priv->ack_buf);
834err_priv:
835 kfree(priv);
836out_buf:
837 kfree(buf);
838 return ret;
839}
840
841static void nexio_exit(struct usbtouch_usb *usbtouch)
842{
843 struct nexio_priv *priv = usbtouch->priv;
844
845 usb_kill_urb(priv->ack);
846 usb_free_urb(priv->ack);
847 kfree(priv->ack_buf);
848 kfree(priv);
849}
850
851static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
852{
853 int x, y, begin_x, begin_y, end_x, end_y, w, h, ret;
854 struct nexio_touch_packet *packet = (void *) pkt;
855 struct nexio_priv *priv = usbtouch->priv;
856
857 /* got touch data? */
858 if ((pkt[0] & 0xe0) != 0xe0)
859 return 0;
860
861 /* send ACK */
862 ret = usb_submit_urb(priv->ack, GFP_ATOMIC);
863
864 if (!usbtouch->type->max_xc) {
865 usbtouch->type->max_xc = 2 * be16_to_cpu(packet->x_len);
866 input_set_abs_params(usbtouch->input, ABS_X, 0,
867 2 * be16_to_cpu(packet->x_len), 0, 0);
868 usbtouch->type->max_yc = 2 * be16_to_cpu(packet->y_len);
869 input_set_abs_params(usbtouch->input, ABS_Y, 0,
870 2 * be16_to_cpu(packet->y_len), 0, 0);
871 }
872 /*
873 * The device reports state of IR sensors on X and Y axes.
874 * Each byte represents "darkness" percentage (0-100) of one element.
875 * 17" touchscreen reports only 64 x 52 bytes so the resolution is low.
876 * This also means that there's a limited multi-touch capability but
877 * it's disabled (and untested) here as there's no X driver for that.
878 */
879 begin_x = end_x = begin_y = end_y = -1;
880 for (x = 0; x < be16_to_cpu(packet->x_len); x++) {
881 if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) {
882 begin_x = x;
883 continue;
884 }
885 if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) {
886 end_x = x - 1;
887 for (y = be16_to_cpu(packet->x_len);
888 y < be16_to_cpu(packet->data_len); y++) {
889 if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) {
890 begin_y = y - be16_to_cpu(packet->x_len);
891 continue;
892 }
893 if (end_y == -1 &&
894 begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) {
895 end_y = y - 1 - be16_to_cpu(packet->x_len);
896 w = end_x - begin_x;
897 h = end_y - begin_y;
898#if 0
899 /* multi-touch */
900 input_report_abs(usbtouch->input,
901 ABS_MT_TOUCH_MAJOR, max(w,h));
902 input_report_abs(usbtouch->input,
903 ABS_MT_TOUCH_MINOR, min(x,h));
904 input_report_abs(usbtouch->input,
905 ABS_MT_POSITION_X, 2*begin_x+w);
906 input_report_abs(usbtouch->input,
907 ABS_MT_POSITION_Y, 2*begin_y+h);
908 input_report_abs(usbtouch->input,
909 ABS_MT_ORIENTATION, w > h);
910 input_mt_sync(usbtouch->input);
911#endif
912 /* single touch */
913 usbtouch->x = 2 * begin_x + w;
914 usbtouch->y = 2 * begin_y + h;
915 usbtouch->touch = packet->flags & 0x01;
916 begin_y = end_y = -1;
917 return 1;
918 }
919 }
920 begin_x = end_x = -1;
921 }
922
923 }
924 return 0;
925}
926#endif
927
928
929/*****************************************************************************
693 * the different device descriptors 930 * the different device descriptors
694 */ 931 */
695#ifdef MULTI_PACKET 932#ifdef MULTI_PACKET
@@ -873,6 +1110,16 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
873 .read_data = tc5uh_read_data, 1110 .read_data = tc5uh_read_data,
874 }, 1111 },
875#endif 1112#endif
1113
1114#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
1115 [DEVTYPE_NEXIO] = {
1116 .rept_size = 128,
1117 .irq_always = true,
1118 .read_data = nexio_read_data,
1119 .init = nexio_init,
1120 .exit = nexio_exit,
1121 },
1122#endif
876}; 1123};
877 1124
878 1125
@@ -998,6 +1245,7 @@ static void usbtouch_irq(struct urb *urb)
998 case -ECONNRESET: 1245 case -ECONNRESET:
999 case -ENOENT: 1246 case -ENOENT:
1000 case -ESHUTDOWN: 1247 case -ESHUTDOWN:
1248 case -EPIPE:
1001 /* this urb is terminated, clean up */ 1249 /* this urb is terminated, clean up */
1002 dbg("%s - urb shutting down with status: %d", 1250 dbg("%s - urb shutting down with status: %d",
1003 __func__, urb->status); 1251 __func__, urb->status);
@@ -1021,7 +1269,7 @@ static int usbtouch_open(struct input_dev *input)
1021{ 1269{
1022 struct usbtouch_usb *usbtouch = input_get_drvdata(input); 1270 struct usbtouch_usb *usbtouch = input_get_drvdata(input);
1023 1271
1024 usbtouch->irq->dev = usbtouch->udev; 1272 usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface);
1025 1273
1026 if (!usbtouch->type->irq_always) { 1274 if (!usbtouch->type->irq_always) {
1027 if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) 1275 if (usb_submit_urb(usbtouch->irq, GFP_KERNEL))
@@ -1048,13 +1296,23 @@ static void usbtouch_free_buffers(struct usb_device *udev,
1048 kfree(usbtouch->buffer); 1296 kfree(usbtouch->buffer);
1049} 1297}
1050 1298
1299static struct usb_endpoint_descriptor *
1300usbtouch_get_input_endpoint(struct usb_host_interface *interface)
1301{
1302 int i;
1303
1304 for (i = 0; i < interface->desc.bNumEndpoints; i++)
1305 if (usb_endpoint_dir_in(&interface->endpoint[i].desc))
1306 return &interface->endpoint[i].desc;
1307
1308 return NULL;
1309}
1051 1310
1052static int usbtouch_probe(struct usb_interface *intf, 1311static int usbtouch_probe(struct usb_interface *intf,
1053 const struct usb_device_id *id) 1312 const struct usb_device_id *id)
1054{ 1313{
1055 struct usbtouch_usb *usbtouch; 1314 struct usbtouch_usb *usbtouch;
1056 struct input_dev *input_dev; 1315 struct input_dev *input_dev;
1057 struct usb_host_interface *interface;
1058 struct usb_endpoint_descriptor *endpoint; 1316 struct usb_endpoint_descriptor *endpoint;
1059 struct usb_device *udev = interface_to_usbdev(intf); 1317 struct usb_device *udev = interface_to_usbdev(intf);
1060 struct usbtouch_device_info *type; 1318 struct usbtouch_device_info *type;
@@ -1064,8 +1322,9 @@ static int usbtouch_probe(struct usb_interface *intf,
1064 if (id->driver_info == DEVTYPE_IGNORE) 1322 if (id->driver_info == DEVTYPE_IGNORE)
1065 return -ENODEV; 1323 return -ENODEV;
1066 1324
1067 interface = intf->cur_altsetting; 1325 endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting);
1068 endpoint = &interface->endpoint[0].desc; 1326 if (!endpoint)
1327 return -ENXIO;
1069 1328
1070 usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); 1329 usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL);
1071 input_dev = input_allocate_device(); 1330 input_dev = input_allocate_device();
@@ -1094,7 +1353,7 @@ static int usbtouch_probe(struct usb_interface *intf,
1094 goto out_free_buffers; 1353 goto out_free_buffers;
1095 } 1354 }
1096 1355
1097 usbtouch->udev = udev; 1356 usbtouch->interface = intf;
1098 usbtouch->input = input_dev; 1357 usbtouch->input = input_dev;
1099 1358
1100 if (udev->manufacturer) 1359 if (udev->manufacturer)
@@ -1133,12 +1392,18 @@ static int usbtouch_probe(struct usb_interface *intf,
1133 input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press, 1392 input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press,
1134 type->max_press, 0, 0); 1393 type->max_press, 0, 0);
1135 1394
1136 usb_fill_int_urb(usbtouch->irq, usbtouch->udev, 1395 if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT)
1137 usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress), 1396 usb_fill_int_urb(usbtouch->irq, udev,
1397 usb_rcvintpipe(udev, endpoint->bEndpointAddress),
1138 usbtouch->data, type->rept_size, 1398 usbtouch->data, type->rept_size,
1139 usbtouch_irq, usbtouch, endpoint->bInterval); 1399 usbtouch_irq, usbtouch, endpoint->bInterval);
1400 else
1401 usb_fill_bulk_urb(usbtouch->irq, udev,
1402 usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
1403 usbtouch->data, type->rept_size,
1404 usbtouch_irq, usbtouch);
1140 1405
1141 usbtouch->irq->dev = usbtouch->udev; 1406 usbtouch->irq->dev = udev;
1142 usbtouch->irq->transfer_dma = usbtouch->data_dma; 1407 usbtouch->irq->transfer_dma = usbtouch->data_dma;
1143 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1408 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1144 1409
@@ -1147,23 +1412,37 @@ static int usbtouch_probe(struct usb_interface *intf,
1147 err = type->init(usbtouch); 1412 err = type->init(usbtouch);
1148 if (err) { 1413 if (err) {
1149 dbg("%s - type->init() failed, err: %d", __func__, err); 1414 dbg("%s - type->init() failed, err: %d", __func__, err);
1150 goto out_free_buffers; 1415 goto out_free_urb;
1151 } 1416 }
1152 } 1417 }
1153 1418
1154 err = input_register_device(usbtouch->input); 1419 err = input_register_device(usbtouch->input);
1155 if (err) { 1420 if (err) {
1156 dbg("%s - input_register_device failed, err: %d", __func__, err); 1421 dbg("%s - input_register_device failed, err: %d", __func__, err);
1157 goto out_free_buffers; 1422 goto out_do_exit;
1158 } 1423 }
1159 1424
1160 usb_set_intfdata(intf, usbtouch); 1425 usb_set_intfdata(intf, usbtouch);
1161 1426
1162 if (usbtouch->type->irq_always) 1427 if (usbtouch->type->irq_always) {
1163 usb_submit_urb(usbtouch->irq, GFP_KERNEL); 1428 err = usb_submit_urb(usbtouch->irq, GFP_KERNEL);
1429 if (err) {
1430 err("%s - usb_submit_urb failed with result: %d",
1431 __func__, err);
1432 goto out_unregister_input;
1433 }
1434 }
1164 1435
1165 return 0; 1436 return 0;
1166 1437
1438out_unregister_input:
1439 input_unregister_device(input_dev);
1440 input_dev = NULL;
1441out_do_exit:
1442 if (type->exit)
1443 type->exit(usbtouch);
1444out_free_urb:
1445 usb_free_urb(usbtouch->irq);
1167out_free_buffers: 1446out_free_buffers:
1168 usbtouch_free_buffers(udev, usbtouch); 1447 usbtouch_free_buffers(udev, usbtouch);
1169out_free: 1448out_free:
@@ -1186,6 +1465,8 @@ static void usbtouch_disconnect(struct usb_interface *intf)
1186 /* this will stop IO via close */ 1465 /* this will stop IO via close */
1187 input_unregister_device(usbtouch->input); 1466 input_unregister_device(usbtouch->input);
1188 usb_free_urb(usbtouch->irq); 1467 usb_free_urb(usbtouch->irq);
1468 if (usbtouch->type->exit)
1469 usbtouch->type->exit(usbtouch);
1189 usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch); 1470 usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch);
1190 kfree(usbtouch); 1471 kfree(usbtouch);
1191} 1472}
diff --git a/drivers/input/touchscreen/zylonite-wm97xx.c b/drivers/input/touchscreen/zylonite-wm97xx.c
index eca54dbdf49..04884986764 100644
--- a/drivers/input/touchscreen/zylonite-wm97xx.c
+++ b/drivers/input/touchscreen/zylonite-wm97xx.c
@@ -118,6 +118,9 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm)
118 if (pressure) 118 if (pressure)
119 p = MODR; 119 p = MODR;
120 120
121 dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n",
122 x, y, p);
123
121 /* are samples valid */ 124 /* are samples valid */
122 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || 125 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X ||
123 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y || 126 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y ||
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c
index c721c0a23eb..d30436fee47 100644
--- a/drivers/input/xen-kbdfront.c
+++ b/drivers/input/xen-kbdfront.c
@@ -321,7 +321,7 @@ InitWait:
321 } 321 }
322} 322}
323 323
324static struct xenbus_device_id xenkbd_ids[] = { 324static const struct xenbus_device_id xenkbd_ids[] = {
325 { "vkbd" }, 325 { "vkbd" },
326 { "" } 326 { "" }
327}; 327};
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 3d906833948..fd85bde283a 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -171,8 +171,8 @@ config INPUT_ADBHID
171 If unsure, say Y. 171 If unsure, say Y.
172 172
173config MAC_EMUMOUSEBTN 173config MAC_EMUMOUSEBTN
174 bool "Support for mouse button 2+3 emulation" 174 tristate "Support for mouse button 2+3 emulation"
175 select INPUT 175 depends on SYSCTL && INPUT
176 help 176 help
177 This provides generic support for emulating the 2nd and 3rd mouse 177 This provides generic support for emulating the 2nd and 3rd mouse
178 button with keypresses. If you say Y here, the emulation is still 178 button with keypresses. If you say Y here, the emulation is still
@@ -184,6 +184,9 @@ config MAC_EMUMOUSEBTN
184 184
185 If you have an Apple machine with a 1-button mouse, say Y here. 185 If you have an Apple machine with a 1-button mouse, say Y here.
186 186
187 To compile this driver as a module, choose M here: the
188 module will be called mac_hid.
189
187config THERM_WINDTUNNEL 190config THERM_WINDTUNNEL
188 tristate "Support for thermal management on Windtunnel G4s" 191 tristate "Support for thermal management on Windtunnel G4s"
189 depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64 192 depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index 7b4ef5bb556..e943d2a2925 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -13,17 +13,197 @@
13#include <linux/sysctl.h> 13#include <linux/sysctl.h>
14#include <linux/input.h> 14#include <linux/input.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kbd_kern.h>
17 16
17MODULE_LICENSE("GPL");
18 18
19static struct input_dev *emumousebtn;
20static int emumousebtn_input_register(void);
21static int mouse_emulate_buttons; 19static int mouse_emulate_buttons;
22static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ 20static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */
23static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ 21static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */
24static int mouse_last_keycode;
25 22
26#if defined(CONFIG_SYSCTL) 23static struct input_dev *mac_hid_emumouse_dev;
24
25static int mac_hid_create_emumouse(void)
26{
27 static struct lock_class_key mac_hid_emumouse_dev_event_class;
28 static struct lock_class_key mac_hid_emumouse_dev_mutex_class;
29 int err;
30
31 mac_hid_emumouse_dev = input_allocate_device();
32 if (!mac_hid_emumouse_dev)
33 return -ENOMEM;
34
35 lockdep_set_class(&mac_hid_emumouse_dev->event_lock,
36 &mac_hid_emumouse_dev_event_class);
37 lockdep_set_class(&mac_hid_emumouse_dev->mutex,
38 &mac_hid_emumouse_dev_mutex_class);
39
40 mac_hid_emumouse_dev->name = "Macintosh mouse button emulation";
41 mac_hid_emumouse_dev->id.bustype = BUS_ADB;
42 mac_hid_emumouse_dev->id.vendor = 0x0001;
43 mac_hid_emumouse_dev->id.product = 0x0001;
44 mac_hid_emumouse_dev->id.version = 0x0100;
45
46 mac_hid_emumouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
47 mac_hid_emumouse_dev->keybit[BIT_WORD(BTN_MOUSE)] =
48 BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
49 mac_hid_emumouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
50
51 err = input_register_device(mac_hid_emumouse_dev);
52 if (err) {
53 input_free_device(mac_hid_emumouse_dev);
54 mac_hid_emumouse_dev = NULL;
55 return err;
56 }
57
58 return 0;
59}
60
61static void mac_hid_destroy_emumouse(void)
62{
63 input_unregister_device(mac_hid_emumouse_dev);
64 mac_hid_emumouse_dev = NULL;
65}
66
67static bool mac_hid_emumouse_filter(struct input_handle *handle,
68 unsigned int type, unsigned int code,
69 int value)
70{
71 unsigned int btn;
72
73 if (type != EV_KEY)
74 return false;
75
76 if (code == mouse_button2_keycode)
77 btn = BTN_MIDDLE;
78 else if (code == mouse_button3_keycode)
79 btn = BTN_RIGHT;
80 else
81 return false;
82
83 input_report_key(mac_hid_emumouse_dev, btn, value);
84 input_sync(mac_hid_emumouse_dev);
85
86 return true;
87}
88
89static int mac_hid_emumouse_connect(struct input_handler *handler,
90 struct input_dev *dev,
91 const struct input_device_id *id)
92{
93 struct input_handle *handle;
94 int error;
95
96 /* Don't bind to ourselves */
97 if (dev == mac_hid_emumouse_dev)
98 return -ENODEV;
99
100 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
101 if (!handle)
102 return -ENOMEM;
103
104 handle->dev = dev;
105 handle->handler = handler;
106 handle->name = "mac-button-emul";
107
108 error = input_register_handle(handle);
109 if (error) {
110 printk(KERN_ERR
111 "mac_hid: Failed to register button emulation handle, "
112 "error %d\n", error);
113 goto err_free;
114 }
115
116 error = input_open_device(handle);
117 if (error) {
118 printk(KERN_ERR
119 "mac_hid: Failed to open input device, error %d\n",
120 error);
121 goto err_unregister;
122 }
123
124 return 0;
125
126 err_unregister:
127 input_unregister_handle(handle);
128 err_free:
129 kfree(handle);
130 return error;
131}
132
133static void mac_hid_emumouse_disconnect(struct input_handle *handle)
134{
135 input_close_device(handle);
136 input_unregister_handle(handle);
137 kfree(handle);
138}
139
140static const struct input_device_id mac_hid_emumouse_ids[] = {
141 {
142 .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
143 .evbit = { BIT_MASK(EV_KEY) },
144 },
145 { },
146};
147
148MODULE_DEVICE_TABLE(input, mac_hid_emumouse_ids);
149
150static struct input_handler mac_hid_emumouse_handler = {
151 .filter = mac_hid_emumouse_filter,
152 .connect = mac_hid_emumouse_connect,
153 .disconnect = mac_hid_emumouse_disconnect,
154 .name = "mac-button-emul",
155 .id_table = mac_hid_emumouse_ids,
156};
157
158static int mac_hid_start_emulation(void)
159{
160 int err;
161
162 err = mac_hid_create_emumouse();
163 if (err)
164 return err;
165
166 err = input_register_handler(&mac_hid_emumouse_handler);
167 if (err) {
168 mac_hid_destroy_emumouse();
169 return err;
170 }
171
172 return 0;
173}
174
175static void mac_hid_stop_emulation(void)
176{
177 input_unregister_handler(&mac_hid_emumouse_handler);
178 mac_hid_destroy_emumouse();
179}
180
181static int mac_hid_toggle_emumouse(ctl_table *table, int write,
182 void __user *buffer, size_t *lenp,
183 loff_t *ppos)
184{
185 int *valp = table->data;
186 int old_val = *valp;
187 int rc;
188
189 rc = proc_dointvec(table, write, buffer, lenp, ppos);
190
191 if (rc == 0 && write && *valp != old_val) {
192 if (*valp == 1)
193 rc = mac_hid_start_emulation();
194 else if (*valp == 0)
195 mac_hid_stop_emulation();
196 else
197 rc = -EINVAL;
198 }
199
200 /* Restore the old value in case of error */
201 if (rc)
202 *valp = old_val;
203
204 return rc;
205}
206
27/* file(s) in /proc/sys/dev/mac_hid */ 207/* file(s) in /proc/sys/dev/mac_hid */
28static ctl_table mac_hid_files[] = { 208static ctl_table mac_hid_files[] = {
29 { 209 {
@@ -31,7 +211,7 @@ static ctl_table mac_hid_files[] = {
31 .data = &mouse_emulate_buttons, 211 .data = &mouse_emulate_buttons,
32 .maxlen = sizeof(int), 212 .maxlen = sizeof(int),
33 .mode = 0644, 213 .mode = 0644,
34 .proc_handler = proc_dointvec, 214 .proc_handler = mac_hid_toggle_emumouse,
35 }, 215 },
36 { 216 {
37 .procname = "mouse_button2_keycode", 217 .procname = "mouse_button2_keycode",
@@ -74,75 +254,21 @@ static ctl_table mac_hid_root_dir[] = {
74 254
75static struct ctl_table_header *mac_hid_sysctl_header; 255static struct ctl_table_header *mac_hid_sysctl_header;
76 256
77#endif /* endif CONFIG_SYSCTL */ 257static int __init mac_hid_init(void)
78
79int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down)
80{
81 switch (caller) {
82 case 1:
83 /* Called from keyboard.c */
84 if (mouse_emulate_buttons
85 && (keycode == mouse_button2_keycode
86 || keycode == mouse_button3_keycode)) {
87 if (mouse_emulate_buttons == 1) {
88 input_report_key(emumousebtn,
89 keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT,
90 down);
91 input_sync(emumousebtn);
92 return 1;
93 }
94 mouse_last_keycode = down ? keycode : 0;
95 }
96 break;
97 }
98 return 0;
99}
100
101static struct lock_class_key emumousebtn_event_class;
102static struct lock_class_key emumousebtn_mutex_class;
103
104static int emumousebtn_input_register(void)
105{ 258{
106 int ret; 259 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir);
107 260 if (!mac_hid_sysctl_header)
108 emumousebtn = input_allocate_device();
109 if (!emumousebtn)
110 return -ENOMEM; 261 return -ENOMEM;
111 262
112 lockdep_set_class(&emumousebtn->event_lock, &emumousebtn_event_class); 263 return 0;
113 lockdep_set_class(&emumousebtn->mutex, &emumousebtn_mutex_class);
114
115 emumousebtn->name = "Macintosh mouse button emulation";
116 emumousebtn->id.bustype = BUS_ADB;
117 emumousebtn->id.vendor = 0x0001;
118 emumousebtn->id.product = 0x0001;
119 emumousebtn->id.version = 0x0100;
120
121 emumousebtn->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
122 emumousebtn->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
123 BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
124 emumousebtn->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
125
126 ret = input_register_device(emumousebtn);
127 if (ret)
128 input_free_device(emumousebtn);
129
130 return ret;
131} 264}
265module_init(mac_hid_init);
132 266
133static int __init mac_hid_init(void) 267static void __exit mac_hid_exit(void)
134{ 268{
135 int err; 269 unregister_sysctl_table(mac_hid_sysctl_header);
136
137 err = emumousebtn_input_register();
138 if (err)
139 return err;
140
141#if defined(CONFIG_SYSCTL)
142 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir);
143#endif /* CONFIG_SYSCTL */
144 270
145 return 0; 271 if (mouse_emulate_buttons)
272 mac_hid_stop_emulation();
146} 273}
147 274module_exit(mac_hid_exit);
148device_initcall(mac_hid_init);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index c0c73913833..2e7a3bf1382 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -354,7 +354,7 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = {
354static int acpi_pci_find_device(struct device *dev, acpi_handle *handle) 354static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
355{ 355{
356 struct pci_dev * pci_dev; 356 struct pci_dev * pci_dev;
357 acpi_integer addr; 357 u64 addr;
358 358
359 pci_dev = to_pci_dev(dev); 359 pci_dev = to_pci_dev(dev);
360 /* Please ref to ACPI spec for the syntax of _ADR */ 360 /* Please ref to ACPI spec for the syntax of _ADR */
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
index a350418e87e..94406861191 100644
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -57,7 +57,7 @@ static struct acpi_driver toshiba_bt_rfkill_driver = {
57static int toshiba_bluetooth_enable(acpi_handle handle) 57static int toshiba_bluetooth_enable(acpi_handle handle)
58{ 58{
59 acpi_status res1, res2; 59 acpi_status res1, res2;
60 acpi_integer result; 60 u64 result;
61 61
62 /* 62 /*
63 * Query ACPI to verify RFKill switch is set to 'on'. 63 * Query ACPI to verify RFKill switch is set to 'on'.
@@ -95,7 +95,7 @@ static int toshiba_bt_resume(struct acpi_device *device)
95static int toshiba_bt_rfkill_add(struct acpi_device *device) 95static int toshiba_bt_rfkill_add(struct acpi_device *device)
96{ 96{
97 acpi_status status; 97 acpi_status status;
98 acpi_integer bt_present; 98 u64 bt_present;
99 int result = -ENODEV; 99 int result = -ENODEV;
100 100
101 /* 101 /*
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index b104302fea0..09e9918c69c 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -796,7 +796,7 @@ static __init acpi_status parse_wdg(acpi_handle handle)
796 */ 796 */
797static acpi_status 797static acpi_status
798acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, 798acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
799 u32 bits, acpi_integer * value, 799 u32 bits, u64 *value,
800 void *handler_context, void *region_context) 800 void *handler_context, void *region_context)
801{ 801{
802 int result = 0, i = 0; 802 int result = 0, i = 0;
@@ -813,7 +813,7 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
813 813
814 if (function == ACPI_READ) { 814 if (function == ACPI_READ) {
815 result = ec_read(address, &temp); 815 result = ec_read(address, &temp);
816 (*value) |= ((acpi_integer)temp) << i; 816 (*value) |= ((u64)temp) << i;
817 } else { 817 } else {
818 temp = 0xff & ((*value) >> i); 818 temp = 0xff & ((*value) >> i);
819 result = ec_write(address, temp); 819 result = ec_write(address, temp);