[PATCH 16/20] Input: atmel_mxt_ts - refactor get info

From: Daniel Kurtz
Date: Tue Mar 13 2012 - 08:06:37 EST


Read whole info block in one i2c transaction.
And then re-read the matrix size after applying pdata config, since
it may have changed.
Note, however, that the matrix x & y size are just displayed for
information purposes. They aren't actually used by the driver itself.

Also, parse and info print the firmware major and minor version numbers.

Signed-off-by: Daniel Kurtz <djkurtz@xxxxxxxxxxxx>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 63 +++++-------------------------
1 files changed, 10 insertions(+), 53 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 0277381..1a9ed26 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -711,41 +711,6 @@ static void mxt_handle_pdata(struct mxt_data *data)
}
}

-static int mxt_get_info(struct mxt_data *data)
-{
- struct i2c_client *client = data->client;
- struct mxt_info *info = &data->info;
- int error;
- u8 val;
-
- error = mxt_read_reg(client, MXT_FAMILY_ID, 1, &val);
- if (error)
- return error;
- info->family_id = val;
-
- error = mxt_read_reg(client, MXT_VARIANT_ID, 1, &val);
- if (error)
- return error;
- info->variant_id = val;
-
- error = mxt_read_reg(client, MXT_VERSION, 1, &val);
- if (error)
- return error;
- info->version = val;
-
- error = mxt_read_reg(client, MXT_BUILD, 1, &val);
- if (error)
- return error;
- info->build = val;
-
- error = mxt_read_reg(client, MXT_OBJECT_NUM, 1, &val);
- if (error)
- return error;
- info->object_num = val;
-
- return 0;
-}
-
static int mxt_get_object_table(struct mxt_data *data)
{
struct i2c_client *client = data->client;
@@ -787,11 +752,11 @@ static int mxt_get_object_table(struct mxt_data *data)
static int mxt_initialize(struct mxt_data *data)
{
struct i2c_client *client = data->client;
+ struct device *dev = &client->dev;
struct mxt_info *info = &data->info;
int error;
- u8 val;

- error = mxt_get_info(data);
+ error = mxt_read_reg(client, MXT_FAMILY_ID, sizeof(*info), info);
if (error)
return error;

@@ -818,26 +783,18 @@ static int mxt_initialize(struct mxt_data *data)
MXT_COMMAND_RESET, 1);
msleep(MXT_RESET_TIME);

- /* Update matrix size at info struct */
- error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, 1, &val);
- if (error)
- return error;
- info->matrix_xsize = val;
-
- error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, 1, &val);
+ /* Update matrix size, since it may have been modified by pdata */
+ error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, 2,
+ &info->matrix_xsize);
if (error)
return error;
- info->matrix_ysize = val;

- dev_info(&client->dev,
- "Family ID: %d Variant ID: %d Version: %d Build: %d\n",
- info->family_id, info->variant_id, info->version,
- info->build);
+ dev_info(dev, "Family ID: %d Variant ID: %d Major.Minor.Build: %d.%d.%d\n",
+ info->family_id, info->variant_id, info->version >> 4,
+ info->version & 0xf, info->build);

- dev_info(&client->dev,
- "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
- info->matrix_xsize, info->matrix_ysize,
- info->object_num);
+ dev_info(dev, "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
+ info->matrix_xsize, info->matrix_ysize, info->object_num);

return 0;
}
--
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/