Input: MT - fix null pointer warning

Fixes the following sparse warning:
drivers/input/input-mt.c:138:40: warning: Using plain integer as NULL pointer

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: fix input.h kernel-doc warning

Fix kernel-doc warning in input.h:

Warning(include/linux/input.h:140): No description found for parameter 'len'

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Input: wacom - fix retrieving touch_max bug

rep_data is not an array anymore, so taking it's address when passing to
wacom_get_report() is wrong.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Tested-by: Rafi Rubin <rafi@seas.upenn.edu>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Input: wacom - don't retrieve touch_max when it is predefined

Some models, such as 0xE6, report more fingers than we process.

Reported-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ping Cheng <pingc@wacom.com>
Tested-by: Nils Kanning <nils@kanning.de>
Tested-by: Rafi Rubin <rafi@seas.upenn.edu>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Input: atmel_mxt_ts - derive phys from i2c client adapter

This allows userspace to more easily distinguish which bus a particular
atmel_mxt_ts device is attached to.

The resulting phys will be something like:
 i2c-1-0067/input0

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - use client name for irq

The atmel_mxt_ts driver can support multiple devices simultaneously.
Use the i2c_client name instead of the driver name when requesting an
interrupt to make the different interrupts distinguishable in
/proc/interrupts and top.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - detect OOM when creating mt slots

Hopefully this new code path will never be used, but better safe than
sorry...

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - warn if sysfs could not be created

If sysfs entry creation fails, the driver is still usable, so don't
just abort probe.  Just warn and continue.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - don't read T5 when dumping objects

T5 is the message processor object.  Reading it will only have two
outcomes, neither of which is particularly useful:
 1) the message count decrements, and a valid message will be lost
 2) an invalid message will be read (reportid == 0xff)

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - use scnprintf for object sysfs entry

Using scnprintf() is a cleaner way to ensure that we don't overwrite the
PAGE_SIZE sysfs output buffer.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - optimize reading objects in object sysfs entry

Read each object in a single i2c transaction instead of byte-by-byte

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - print less overhead when dumping objects

Conserve limited (PAGE_SIZE) sysfs output buffer space by only showing
readable objects and not printing the object's index, which is not useful
to userspace.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - print all instances when dumping objects

For objects with multiple instances, dump them all, prepending each with
its "Instance #".

[rydberg@euromail.se: break out mxt_show_instance()]
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - return errors from i2c layer

The i2c layer can report a variety of errors, including -ENXIO for an i2c
NAK.  Instead of treating them all as -EIO, pass the actual i2c layer
error up to the caller.

However, still report as -EIO the unlikely case that a transaction was
partially completed, and no error message was returned from i2c_*().

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - add variable length __mxt_write_reg

The i2c bus requires 4 bytes to do a 1-byte write
(1 byte i2c address + 2 byte offset + 1 byte data).

By taking a length with writes, the driver can amortize transaction
overhead by performing larger transactions where appropriate.

This patch just sets up the new API.  Later patches refactor writes
to take advantage of the larger transactions.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - optimize writing of object table entries

Write each object using a single bulk i2c write transfer.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - read ID information block in one i2c transaction

Reading the whole info block in one i2c transaction speeds up driver
probe significantly, especially on slower i2c busses.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - update driver ID info logging

Print unsigned values as '%u'.
Also, parse and print the firmware version in its canonical format, as
suggested by Nick Dyer.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - add sysfs entries to read fw and hw version

Make firmware and hardware version strings available to userspace.
This is useful, for example, to allow a userspace program to implement
a firwmare update policy.

Change-Id: I1eddb4bbf5f3f9ae6947a8528598973ddead18cf
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Input: atmel_mxt_ts - simplify event reporting

Instead of carrying around per-finger state in the driver instance, just
report each finger as it arrives to the input layer, and let the input
layer (evdev) hold the event state (which it does anyway).

Note: this driver does not really do MT-B properly. Each input report
(a group of input events followed by a SYN_REPORT) only contains data for
a single contact.  When multiple fingers are present on a device, each is
properly reported in its own MT_SLOT.  However, there is only ever one
MT_SLOT per SYN_REPORT.  This is fixed in a subsequent patch.

This patch was tested with an mXT224E.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>