From: Jongpil Jung <jongpil19.jung@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> To maintain mxt_info easiler, use structure type mxt_info instead of pointer. Change-Id: I89f19a45b395a071d2ea01efa1d80f15fc3ed461 --- drivers/input/touchscreen/atmel_mxt_ts.c | 35 ++++++++++++------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index f5eb81ff2fd3..723ff75e798a 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -281,7 +281,7 @@ struct mxt_data { struct input_dev *input_dev; char phys[64]; /* device physical location */ struct mxt_object *object_table; - struct mxt_info *info; + struct mxt_info info; void *raw_info_block; unsigned int irq; unsigned int max_x; @@ -464,7 +464,7 @@ static int mxt_lookup_bootloader_address(struct mxt_data *data, bool retry) { u8 appmode = data->client->addr; u8 bootloader; - u8 family_id = data->info ? data->info->family_id : 0; + u8 family_id = data->info.family_id; switch (appmode) { case 0x4a: @@ -697,7 +697,7 @@ mxt_get_object(struct mxt_data *data, u8 type) struct mxt_object *object; int i; - for (i = 0; i < data->info->object_num; i++) { + for (i = 0; i < data->info.object_num; i++) { object = data->object_table + i; if (object->type == type) return object; @@ -1486,13 +1486,13 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) cfg.raw_pos += offset; } - if (cfg.info.family_id != data->info->family_id) { + if (cfg.info.family_id != data->info.family_id) { dev_err(dev, "Family ID mismatch!\n"); ret = -EINVAL; goto release_raw; } - if (cfg.info.variant_id != data->info->variant_id) { + if (cfg.info.variant_id != data->info.variant_id) { dev_err(dev, "Variant ID mismatch!\n"); ret = -EINVAL; goto release_raw; @@ -1541,7 +1541,7 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) /* Malloc memory to store configuration */ cfg.start_ofs = MXT_OBJECT_START + - data->info->object_num * sizeof(struct mxt_object) + + data->info.object_num * sizeof(struct mxt_object) + MXT_INFO_CHECKSUM_SIZE; cfg.mem_size = data->mem_size - cfg.start_ofs; cfg.mem = kzalloc(cfg.mem_size, GFP_KERNEL); @@ -1609,7 +1609,6 @@ static void mxt_free_object_table(struct mxt_data *data) v4l2_device_unregister(&data->dbg.v4l2); #endif data->object_table = NULL; - data->info = NULL; kfree(data->raw_info_block); data->raw_info_block = NULL; kfree(data->msg_buf); @@ -1639,7 +1638,7 @@ static int mxt_parse_object_table(struct mxt_data *data, /* Valid Report IDs start counting from 1 */ reportid = 1; data->mem_size = 0; - for (i = 0; i < data->info->object_num; i++) { + for (i = 0; i < data->info.object_num; i++) { struct mxt_object *object = object_table + i; u8 min_id, max_id; @@ -1663,8 +1662,8 @@ static int mxt_parse_object_table(struct mxt_data *data, switch (object->type) { case MXT_GEN_MESSAGE_T5: - if (data->info->family_id == 0x80 && - data->info->version < 0x20) { + if (data->info.family_id == 0x80 && + data->info.version < 0x20) { /* * On mXT224 firmware versions prior to V2.0 * read and discard unused CRC byte otherwise @@ -1797,13 +1796,13 @@ static int mxt_read_info_block(struct mxt_data *data) } data->raw_info_block = id_buf; - data->info = (struct mxt_info *)id_buf; + memcpy(&data->info, id_buf, sizeof(struct mxt_info)); dev_info(&client->dev, "Family: %u Variant: %u Firmware V%u.%u.%02X Objects: %u\n", - data->info->family_id, data->info->variant_id, - data->info->version >> 4, data->info->version & 0xf, - data->info->build, data->info->object_num); + data->info.family_id, data->info.variant_id, + data->info.version >> 4, data->info.version & 0xf, + data->info.build, data->info.object_num); /* Parse object table information */ error = mxt_parse_object_table(data, id_buf + MXT_OBJECT_START); @@ -2721,7 +2720,7 @@ static ssize_t mxt_fw_version_show(struct device *dev, struct device_attribute *attr, char *buf) { struct mxt_data *data = dev_get_drvdata(dev); - struct mxt_info *info = data->info; + struct mxt_info *info = &data->info; return scnprintf(buf, PAGE_SIZE, "%u.%u.%02X\n", info->version >> 4, info->version & 0xf, info->build); } @@ -2731,7 +2730,7 @@ static ssize_t mxt_hw_version_show(struct device *dev, struct device_attribute *attr, char *buf) { struct mxt_data *data = dev_get_drvdata(dev); - struct mxt_info *info = data->info; + struct mxt_info *info = &data->info; return scnprintf(buf, PAGE_SIZE, "%u.%u\n", info->family_id, info->variant_id); } @@ -2748,7 +2747,7 @@ static ssize_t mxt_matrix_size_show(struct device *dev, struct device_attribute *attr, char *buf) { struct mxt_data *data = dev_get_drvdata(dev); - struct mxt_info *info = data->info; + struct mxt_info *info = &data->info; return scnprintf(buf, PAGE_SIZE, "%u %u\n", info->matrix_xsize, info->matrix_ysize); } @@ -2787,7 +2786,7 @@ static ssize_t mxt_object_show(struct device *dev, return -ENOMEM; error = 0; - for (i = 0; i < data->info->object_num; i++) { + for (i = 0; i < data->info.object_num; i++) { object = data->object_table + i; if (!mxt_object_readable(object->type)) -- 2.17.1