summaryrefslogtreecommitdiffstats
path: root/drivers/input/rmi4
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/rmi4')
-rw-r--r--drivers/input/rmi4/rmi_driver.c13
-rw-r--r--drivers/input/rmi4/rmi_f12.c18
-rw-r--r--drivers/input/rmi4/rmi_f34.c27
-rw-r--r--drivers/input/rmi4/rmi_f34.h7
-rw-r--r--drivers/input/rmi4/rmi_f34v7.c117
-rw-r--r--drivers/input/rmi4/rmi_i2c.c51
-rw-r--r--drivers/input/rmi4/rmi_smbus.c94
-rw-r--r--drivers/input/rmi4/rmi_spi.c44
8 files changed, 190 insertions, 181 deletions
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index d64fc92858f2..4f2bb5947a4e 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -251,7 +251,7 @@ static int rmi_irq_init(struct rmi_device *rmi_dev)
ret = devm_request_threaded_irq(&rmi_dev->dev, pdata->irq, NULL,
rmi_irq_fn, irq_flags | IRQF_ONESHOT,
- dev_name(rmi_dev->xport->dev),
+ dev_driver_string(rmi_dev->xport->dev),
rmi_dev);
if (ret < 0) {
dev_err(&rmi_dev->dev, "Failed to register interrupt %d\n",
@@ -1234,16 +1234,21 @@ static int rmi_driver_probe(struct device *dev)
if (retval < 0)
goto err_destroy_functions;
- if (data->f01_container->dev.driver)
+ if (data->f01_container->dev.driver) {
/* Driver already bound, so enable ATTN now. */
- return rmi_enable_sensor(rmi_dev);
+ retval = rmi_enable_sensor(rmi_dev);
+ if (retval)
+ goto err_disable_irq;
+ }
return 0;
+err_disable_irq:
+ rmi_disable_irq(rmi_dev, false);
err_destroy_functions:
rmi_free_function_list(rmi_dev);
err:
- return retval < 0 ? retval : 0;
+ return retval;
}
static struct rmi_driver rmi_physical_driver = {
diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c
index 07aff4356fe0..8b0db086d68a 100644
--- a/drivers/input/rmi4/rmi_f12.c
+++ b/drivers/input/rmi4/rmi_f12.c
@@ -113,20 +113,16 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12)
}
if (rmi_register_desc_has_subpacket(item, 2)) {
- sensor->axis_align.clip_x_low = buf[offset];
- sensor->axis_align.clip_x_high = sensor->max_x
- - buf[offset + 1];
- sensor->axis_align.clip_y_low = buf[offset + 2];
- sensor->axis_align.clip_y_high = sensor->max_y
- - buf[offset + 3];
+ /* Units 1/128 sensor pitch */
+ rmi_dbg(RMI_DEBUG_FN, &fn->dev,
+ "%s: Inactive Border xlo:%d xhi:%d ylo:%d yhi:%d\n",
+ __func__,
+ buf[offset], buf[offset + 1],
+ buf[offset + 2], buf[offset + 3]);
+
offset += 4;
}
- rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: x low: %d x high: %d y low: %d y high: %d\n",
- __func__,
- sensor->axis_align.clip_x_low, sensor->axis_align.clip_x_high,
- sensor->axis_align.clip_y_low, sensor->axis_align.clip_y_high);
-
if (rmi_register_desc_has_subpacket(item, 3)) {
rx_receivers = buf[offset];
tx_receivers = buf[offset + 1];
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index 425fe140e9df..b8ee78e0d61f 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -105,16 +105,27 @@ static int rmi_f34_attention(struct rmi_function *fn, unsigned long *irq_bits)
{
struct f34_data *f34 = dev_get_drvdata(&fn->dev);
int ret;
+ u8 status;
- if (f34->bl_version != 5)
- return 0;
+ if (f34->bl_version == 5) {
+ ret = rmi_read(f34->fn->rmi_dev, f34->v5.ctrl_address,
+ &status);
+ rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: status: %#02x, ret: %d\n",
+ __func__, status, ret);
- ret = rmi_read(f34->fn->rmi_dev, f34->v5.ctrl_address, &f34->v5.status);
- rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: status: %#02x, ret: %d\n",
- __func__, f34->v5.status, ret);
-
- if (!ret && !(f34->v5.status & 0x7f))
- complete(&f34->v5.cmd_done);
+ if (!ret && !(status & 0x7f))
+ complete(&f34->v5.cmd_done);
+ } else {
+ ret = rmi_read_block(f34->fn->rmi_dev,
+ f34->fn->fd.data_base_addr +
+ f34->v7.off.flash_status,
+ &status, sizeof(status));
+ rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: status: %#02x, ret: %d\n",
+ __func__, status, ret);
+
+ if (!ret && !(status & 0x1f))
+ complete(&f34->v7.cmd_done);
+ }
return 0;
}
diff --git a/drivers/input/rmi4/rmi_f34.h b/drivers/input/rmi4/rmi_f34.h
index 43a91349b28d..32c4e9581c68 100644
--- a/drivers/input/rmi4/rmi_f34.h
+++ b/drivers/input/rmi4/rmi_f34.h
@@ -30,6 +30,7 @@
#define F34_IDLE_WAIT_MS 500
#define F34_ENABLE_WAIT_MS 300
#define F34_ERASE_WAIT_MS 5000
+#define F34_WRITE_WAIT_MS 3000
#define F34_BOOTLOADER_ID_LEN 2
@@ -47,11 +48,6 @@
#define CONFIG_ID_SIZE 32
#define PRODUCT_ID_SIZE 10
-#define ENABLE_WAIT_MS (1 * 1000)
-#define WRITE_WAIT_MS (3 * 1000)
-
-#define MIN_SLEEP_TIME_US 50
-#define MAX_SLEEP_TIME_US 100
#define HAS_BSR BIT(5)
#define HAS_CONFIG_ID BIT(3)
@@ -292,6 +288,7 @@ struct f34v7_data {
const void *config_data;
const void *image;
+ struct completion cmd_done;
};
struct f34_data {
diff --git a/drivers/input/rmi4/rmi_f34v7.c b/drivers/input/rmi4/rmi_f34v7.c
index 56c6c39ad31e..10c0d11b72c9 100644
--- a/drivers/input/rmi4/rmi_f34v7.c
+++ b/drivers/input/rmi4/rmi_f34v7.c
@@ -15,6 +15,7 @@
#include <asm/unaligned.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/jiffies.h>
#include "rmi_driver.h"
#include "rmi_f34.h"
@@ -31,7 +32,7 @@ static int rmi_f34v7_read_flash_status(struct f34_data *f34)
sizeof(status));
if (ret < 0) {
rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev,
- "%s: Failed to read flash status\n", __func__);
+ "%s: Error %d reading flash status\n", __func__, ret);
return ret;
}
@@ -60,28 +61,17 @@ static int rmi_f34v7_read_flash_status(struct f34_data *f34)
static int rmi_f34v7_wait_for_idle(struct f34_data *f34, int timeout_ms)
{
- int count = 0;
- int timeout_count = ((timeout_ms * 1000) / MAX_SLEEP_TIME_US) + 1;
+ unsigned long timeout;
- do {
- usleep_range(MIN_SLEEP_TIME_US, MAX_SLEEP_TIME_US);
-
- count++;
-
- rmi_f34v7_read_flash_status(f34);
-
- if ((f34->v7.command == v7_CMD_IDLE)
- && (f34->v7.flash_status == 0x00)) {
- rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev,
- "Idle status detected\n");
- return 0;
- }
- } while (count < timeout_count);
+ timeout = msecs_to_jiffies(timeout_ms);
- dev_err(&f34->fn->dev,
- "%s: Timed out waiting for idle status\n", __func__);
+ if (!wait_for_completion_timeout(&f34->v7.cmd_done, timeout)) {
+ dev_warn(&f34->fn->dev, "%s: Timed out waiting for idle status\n",
+ __func__);
+ return -ETIMEDOUT;
+ }
- return -ETIMEDOUT;
+ return 0;
}
static int rmi_f34v7_write_command_single_transaction(struct f34_data *f34,
@@ -285,9 +275,10 @@ static int rmi_f34v7_write_partition_id(struct f34_data *f34, u8 cmd)
return 0;
}
-static int rmi_f34v7_read_f34v7_partition_table(struct f34_data *f34)
+static int rmi_f34v7_read_partition_table(struct f34_data *f34)
{
int ret;
+ unsigned long timeout;
u8 base;
__le16 length;
u16 block_number = 0;
@@ -320,6 +311,8 @@ static int rmi_f34v7_read_f34v7_partition_table(struct f34_data *f34)
return ret;
}
+ init_completion(&f34->v7.cmd_done);
+
ret = rmi_f34v7_write_command(f34, v7_CMD_READ_CONFIG);
if (ret < 0) {
dev_err(&f34->fn->dev, "%s: Failed to write command\n",
@@ -327,11 +320,15 @@ static int rmi_f34v7_read_f34v7_partition_table(struct f34_data *f34)
return ret;
}
- ret = rmi_f34v7_wait_for_idle(f34, WRITE_WAIT_MS);
- if (ret < 0) {
- dev_err(&f34->fn->dev, "%s: Failed to wait for idle status\n",
- __func__);
- return ret;
+ timeout = msecs_to_jiffies(F34_WRITE_WAIT_MS);
+ while (time_before(jiffies, timeout)) {
+ usleep_range(5000, 6000);
+ rmi_f34v7_read_flash_status(f34);
+
+ if (f34->v7.command == v7_CMD_IDLE &&
+ f34->v7.flash_status == 0x00) {
+ break;
+ }
}
ret = rmi_read_block(f34->fn->rmi_dev,
@@ -570,7 +567,7 @@ static int rmi_f34v7_read_queries(struct f34_data *f34)
f34->v7.read_config_buf_size = f34->v7.partition_table_bytes;
ptable = f34->v7.read_config_buf;
- ret = rmi_f34v7_read_f34v7_partition_table(f34);
+ ret = rmi_f34v7_read_partition_table(f34);
if (ret < 0) {
dev_err(&f34->fn->dev, "%s: Failed to read partition table\n",
__func__);
@@ -666,6 +663,8 @@ static int rmi_f34v7_erase_config(struct f34_data *f34)
dev_info(&f34->fn->dev, "Erasing config...\n");
+ init_completion(&f34->v7.cmd_done);
+
switch (f34->v7.config_area) {
case v7_UI_CONFIG_AREA:
ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_CONFIG);
@@ -684,11 +683,11 @@ static int rmi_f34v7_erase_config(struct f34_data *f34)
break;
}
- ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS);
+ ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS);
if (ret < 0)
return ret;
- return ret;
+ return 0;
}
static int rmi_f34v7_erase_guest_code(struct f34_data *f34)
@@ -697,11 +696,13 @@ static int rmi_f34v7_erase_guest_code(struct f34_data *f34)
dev_info(&f34->fn->dev, "Erasing guest code...\n");
+ init_completion(&f34->v7.cmd_done);
+
ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_GUEST_CODE);
if (ret < 0)
return ret;
- ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS);
+ ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS);
if (ret < 0)
return ret;
@@ -714,11 +715,13 @@ static int rmi_f34v7_erase_all(struct f34_data *f34)
dev_info(&f34->fn->dev, "Erasing firmware...\n");
+ init_completion(&f34->v7.cmd_done);
+
ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_FIRMWARE);
if (ret < 0)
return ret;
- ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS);
+ ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS);
if (ret < 0)
return ret;
@@ -743,8 +746,8 @@ static int rmi_f34v7_erase_all(struct f34_data *f34)
return 0;
}
-static int rmi_f34v7_read_f34v7_blocks(struct f34_data *f34, u16 block_cnt,
- u8 command)
+static int rmi_f34v7_read_blocks(struct f34_data *f34,
+ u16 block_cnt, u8 command)
{
int ret;
u8 base;
@@ -787,17 +790,15 @@ static int rmi_f34v7_read_f34v7_blocks(struct f34_data *f34, u16 block_cnt,
return ret;
}
+ init_completion(&f34->v7.cmd_done);
+
ret = rmi_f34v7_write_command(f34, command);
if (ret < 0)
return ret;
- ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS);
- if (ret < 0) {
- dev_err(&f34->fn->dev,
- "%s: Wait for idle failed (%d blks remaining)\n",
- __func__, remaining);
+ ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS);
+ if (ret < 0)
return ret;
- }
ret = rmi_read_block(f34->fn->rmi_dev,
base + f34->v7.off.payload,
@@ -853,6 +854,8 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
transfer = min(remaining, max_transfer);
put_unaligned_le16(transfer, &length);
+ init_completion(&f34->v7.cmd_done);
+
ret = rmi_write_block(f34->fn->rmi_dev,
base + f34->v7.off.transfer_length,
&length, sizeof(length));
@@ -877,13 +880,9 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
return ret;
}
- ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS);
- if (ret < 0) {
- dev_err(&f34->fn->dev,
- "%s: Failed wait for idle (%d blks remaining)\n",
- __func__, remaining);
+ ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS);
+ if (ret < 0)
return ret;
- }
block_ptr += (transfer * f34->v7.block_size);
remaining -= transfer;
@@ -945,6 +944,8 @@ static int rmi_f34v7_write_flash_config(struct f34_data *f34)
return -EINVAL;
}
+ init_completion(&f34->v7.cmd_done);
+
ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_FLASH_CONFIG);
if (ret < 0)
return ret;
@@ -952,7 +953,7 @@ static int rmi_f34v7_write_flash_config(struct f34_data *f34)
rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev,
"%s: Erase flash config command written\n", __func__);
- ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS);
+ ret = rmi_f34v7_wait_for_idle(f34, F34_WRITE_WAIT_MS);
if (ret < 0)
return ret;
@@ -981,7 +982,7 @@ static int rmi_f34v7_write_partition_table(struct f34_data *f34)
f34->v7.read_config_buf_size = f34->v7.config_size;
- ret = rmi_f34v7_read_f34v7_blocks(f34, block_count, v7_CMD_READ_CONFIG);
+ ret = rmi_f34v7_read_blocks(f34, block_count, v7_CMD_READ_CONFIG);
if (ret < 0)
return ret;
@@ -1287,6 +1288,8 @@ static int rmi_f34v7_enter_flash_prog(struct f34_data *f34)
{
int ret;
+ f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, f34->fn->irq_mask);
+
ret = rmi_f34v7_read_flash_status(f34);
if (ret < 0)
return ret;
@@ -1294,19 +1297,16 @@ static int rmi_f34v7_enter_flash_prog(struct f34_data *f34)
if (f34->v7.in_bl_mode)
return 0;
+ init_completion(&f34->v7.cmd_done);
+
ret = rmi_f34v7_write_command(f34, v7_CMD_ENABLE_FLASH_PROG);
if (ret < 0)
return ret;
- ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS);
+ ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS);
if (ret < 0)
return ret;
- if (!f34->v7.in_bl_mode) {
- dev_err(&f34->fn->dev, "%s: BL mode not entered\n", __func__);
- return -EINVAL;
- }
-
return 0;
}
@@ -1314,6 +1314,8 @@ int rmi_f34v7_start_reflash(struct f34_data *f34, const struct firmware *fw)
{
int ret = 0;
+ f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, f34->fn->irq_mask);
+
f34->v7.config_area = v7_UI_CONFIG_AREA;
f34->v7.image = fw->data;
@@ -1376,8 +1378,13 @@ int rmi_f34v7_probe(struct f34_data *f34)
memset(&f34->v7.blkcount, 0x00, sizeof(f34->v7.blkcount));
memset(&f34->v7.phyaddr, 0x00, sizeof(f34->v7.phyaddr));
- rmi_f34v7_read_queries(f34);
- f34->v7.force_update = false;
+ init_completion(&f34->v7.cmd_done);
+
+ ret = rmi_f34v7_read_queries(f34);
+ if (ret < 0)
+ return ret;
+
+ f34->v7.force_update = true;
return 0;
}
diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index 082306d7c207..e28663ef9e5a 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -204,7 +204,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
struct rmi_device_platform_data *client_pdata =
dev_get_platdata(&client->dev);
struct rmi_i2c_xport *rmi_i2c;
- int retval;
+ int error;
rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport),
GFP_KERNEL);
@@ -220,30 +220,31 @@ static int rmi_i2c_probe(struct i2c_client *client,
rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s.\n",
dev_name(&client->dev));
+
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev,
- "adapter does not support required functionality.\n");
+ "adapter does not support required functionality\n");
return -ENODEV;
}
rmi_i2c->supplies[0].supply = "vdd";
rmi_i2c->supplies[1].supply = "vio";
- retval = devm_regulator_bulk_get(&client->dev,
+ error = devm_regulator_bulk_get(&client->dev,
ARRAY_SIZE(rmi_i2c->supplies),
rmi_i2c->supplies);
- if (retval < 0)
- return retval;
+ if (error < 0)
+ return error;
- retval = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies),
+ error = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies),
rmi_i2c->supplies);
- if (retval < 0)
- return retval;
+ if (error < 0)
+ return error;
- retval = devm_add_action_or_reset(&client->dev,
+ error = devm_add_action_or_reset(&client->dev,
rmi_i2c_regulator_bulk_disable,
rmi_i2c);
- if (retval)
- return retval;
+ if (error)
+ return error;
of_property_read_u32(client->dev.of_node, "syna,startup-delay-ms",
&rmi_i2c->startup_delay);
@@ -263,26 +264,26 @@ static int rmi_i2c_probe(struct i2c_client *client,
* Setting the page to zero will (a) make sure the PSR is in a
* known state, and (b) make sure we can talk to the device.
*/
- retval = rmi_set_page(rmi_i2c, 0);
- if (retval) {
- dev_err(&client->dev, "Failed to set page select to 0.\n");
- return retval;
+ error = rmi_set_page(rmi_i2c, 0);
+ if (error) {
+ dev_err(&client->dev, "Failed to set page select to 0\n");
+ return error;
}
- retval = rmi_register_transport_device(&rmi_i2c->xport);
- if (retval) {
- dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n",
- client->addr);
- return retval;
+ dev_info(&client->dev, "registering I2C-connected sensor\n");
+
+ error = rmi_register_transport_device(&rmi_i2c->xport);
+ if (error) {
+ dev_err(&client->dev, "failed to register sensor: %d\n", error);
+ return error;
}
- retval = devm_add_action_or_reset(&client->dev,
+
+ error = devm_add_action_or_reset(&client->dev,
rmi_i2c_unregister_transport,
rmi_i2c);
- if (retval)
- return retval;
+ if (error)
+ return error;
- dev_info(&client->dev, "registered rmi i2c driver at %#04x.\n",
- client->addr);
return 0;
}
diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c
index 76752555d809..225025a0940c 100644
--- a/drivers/input/rmi4/rmi_smbus.c
+++ b/drivers/input/rmi4/rmi_smbus.c
@@ -53,6 +53,7 @@ static int rmi_smb_get_version(struct rmi_smb_xport *rmi_smb)
dev_err(&client->dev, "failed to get SMBus version number!\n");
return retval;
}
+
return retval + 1;
}
@@ -83,63 +84,56 @@ static int rmi_smb_get_command_code(struct rmi_transport_dev *xport,
{
struct rmi_smb_xport *rmi_smb =
container_of(xport, struct rmi_smb_xport, xport);
+ struct mapping_table_entry new_map;
int i;
- int retval;
- struct mapping_table_entry mapping_data[1];
+ int retval = 0;
mutex_lock(&rmi_smb->mappingtable_mutex);
+
for (i = 0; i < RMI_SMB2_MAP_SIZE; i++) {
- if (rmi_smb->mapping_table[i].rmiaddr == rmiaddr) {
+ struct mapping_table_entry *entry = &rmi_smb->mapping_table[i];
+
+ if (le16_to_cpu(entry->rmiaddr) == rmiaddr) {
if (isread) {
- if (rmi_smb->mapping_table[i].readcount
- == bytecount) {
- *commandcode = i;
- retval = 0;
+ if (entry->readcount == bytecount)
goto exit;
- }
} else {
- if (rmi_smb->mapping_table[i].flags &
- RMI_SMB2_MAP_FLAGS_WE) {
- *commandcode = i;
- retval = 0;
+ if (entry->flags & RMI_SMB2_MAP_FLAGS_WE) {
goto exit;
}
}
}
}
+
i = rmi_smb->table_index;
rmi_smb->table_index = (i + 1) % RMI_SMB2_MAP_SIZE;
/* constructs mapping table data entry. 4 bytes each entry */
- memset(mapping_data, 0, sizeof(mapping_data));
-
- mapping_data[0].rmiaddr = cpu_to_le16(rmiaddr);
- mapping_data[0].readcount = bytecount;
- mapping_data[0].flags = !isread ? RMI_SMB2_MAP_FLAGS_WE : 0;
-
- retval = smb_block_write(xport, i + 0x80, mapping_data,
- sizeof(mapping_data));
+ memset(&new_map, 0, sizeof(new_map));
+ new_map.rmiaddr = cpu_to_le16(rmiaddr);
+ new_map.readcount = bytecount;
+ new_map.flags = !isread ? RMI_SMB2_MAP_FLAGS_WE : 0;
+ retval = smb_block_write(xport, i + 0x80, &new_map, sizeof(new_map));
if (retval < 0) {
/*
* if not written to device mapping table
* clear the driver mapping table records
*/
- rmi_smb->mapping_table[i].rmiaddr = 0x0000;
- rmi_smb->mapping_table[i].readcount = 0;
- rmi_smb->mapping_table[i].flags = 0;
- goto exit;
+ memset(&new_map, 0, sizeof(new_map));
}
+
/* save to the driver level mapping table */
- rmi_smb->mapping_table[i].rmiaddr = rmiaddr;
- rmi_smb->mapping_table[i].readcount = bytecount;
- rmi_smb->mapping_table[i].flags = !isread ? RMI_SMB2_MAP_FLAGS_WE : 0;
- *commandcode = i;
+ rmi_smb->mapping_table[i] = new_map;
exit:
mutex_unlock(&rmi_smb->mappingtable_mutex);
- return retval;
+ if (retval < 0)
+ return retval;
+
+ *commandcode = i;
+ return 0;
}
static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr,
@@ -282,19 +276,24 @@ static int rmi_smb_probe(struct i2c_client *client,
{
struct rmi_device_platform_data *pdata = dev_get_platdata(&client->dev);
struct rmi_smb_xport *rmi_smb;
- int retval;
int smbus_version;
+ int error;
+
+ if (!pdata) {
+ dev_err(&client->dev, "no platform data, aborting\n");
+ return -ENOMEM;
+ }
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_READ_BLOCK_DATA |
I2C_FUNC_SMBUS_HOST_NOTIFY)) {
dev_err(&client->dev,
- "adapter does not support required functionality.\n");
+ "adapter does not support required functionality\n");
return -ENODEV;
}
if (client->irq <= 0) {
- dev_err(&client->dev, "no IRQ provided, giving up.\n");
+ dev_err(&client->dev, "no IRQ provided, giving up\n");
return client->irq ? client->irq : -ENODEV;
}
@@ -303,12 +302,7 @@ static int rmi_smb_probe(struct i2c_client *client,
if (!rmi_smb)
return -ENOMEM;
- if (!pdata) {
- dev_err(&client->dev, "no platform data, aborting\n");
- return -ENOMEM;
- }
-
- rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s.\n",
+ rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s\n",
dev_name(&client->dev));
rmi_smb->client = client;
@@ -321,34 +315,30 @@ static int rmi_smb_probe(struct i2c_client *client,
rmi_smb->xport.proto_name = "smb2";
rmi_smb->xport.ops = &rmi_smb_ops;
- retval = rmi_smb_get_version(rmi_smb);
- if (retval < 0)
- return retval;
+ smbus_version = rmi_smb_get_version(rmi_smb);
+ if (smbus_version < 0)
+ return smbus_version;
- smbus_version = retval;
rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Smbus version is %d",
smbus_version);
if (smbus_version != 2) {
- dev_err(&client->dev, "Unrecognized SMB version %d.\n",
+ dev_err(&client->dev, "Unrecognized SMB version %d\n",
smbus_version);
return -ENODEV;
}
i2c_set_clientdata(client, rmi_smb);
- retval = rmi_register_transport_device(&rmi_smb->xport);
- if (retval) {
- dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n",
- client->addr);
- i2c_set_clientdata(client, NULL);
- return retval;
+ dev_info(&client->dev, "registering SMbus-connected sensor\n");
+
+ error = rmi_register_transport_device(&rmi_smb->xport);
+ if (error) {
+ dev_err(&client->dev, "failed to register sensor: %d\n", error);
+ return error;
}
- dev_info(&client->dev, "registered rmi smb driver at %#04x.\n",
- client->addr);
return 0;
-
}
static int rmi_smb_remove(struct i2c_client *client)
diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c
index 69548d7d1f10..d97a85907ed6 100644
--- a/drivers/input/rmi4/rmi_spi.c
+++ b/drivers/input/rmi4/rmi_spi.c
@@ -370,7 +370,7 @@ static int rmi_spi_probe(struct spi_device *spi)
struct rmi_spi_xport *rmi_spi;
struct rmi_device_platform_data *pdata;
struct rmi_device_platform_data *spi_pdata = spi->dev.platform_data;
- int retval;
+ int error;
if (spi->master->flags & SPI_MASTER_HALF_DUPLEX)
return -EINVAL;
@@ -383,9 +383,9 @@ static int rmi_spi_probe(struct spi_device *spi)
pdata = &rmi_spi->xport.pdata;
if (spi->dev.of_node) {
- retval = rmi_spi_of_probe(spi, pdata);
- if (retval)
- return retval;
+ error = rmi_spi_of_probe(spi, pdata);
+ if (error)
+ return error;
} else if (spi_pdata) {
*pdata = *spi_pdata;
}
@@ -396,10 +396,10 @@ static int rmi_spi_probe(struct spi_device *spi)
if (pdata->spi_data.mode)
spi->mode = pdata->spi_data.mode;
- retval = spi_setup(spi);
- if (retval < 0) {
+ error = spi_setup(spi);
+ if (error < 0) {
dev_err(&spi->dev, "spi_setup failed!\n");
- return retval;
+ return error;
}
pdata->irq = spi->irq;
@@ -413,32 +413,34 @@ static int rmi_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, rmi_spi);
- retval = rmi_spi_manage_pools(rmi_spi, RMI_SPI_DEFAULT_XFER_BUF_SIZE);
- if (retval)
- return retval;
+ error = rmi_spi_manage_pools(rmi_spi, RMI_SPI_DEFAULT_XFER_BUF_SIZE);
+ if (error)
+ return error;
/*
* Setting the page to zero will (a) make sure the PSR is in a
* known state, and (b) make sure we can talk to the device.
*/
- retval = rmi_set_page(rmi_spi, 0);
- if (retval) {
+ error = rmi_set_page(rmi_spi, 0);
+ if (error) {
dev_err(&spi->dev, "Failed to set page select to 0.\n");
- return retval;
+ return error;
}
- retval = rmi_register_transport_device(&rmi_spi->xport);
- if (retval) {
- dev_err(&spi->dev, "failed to register transport.\n");
- return retval;
+ dev_info(&spi->dev, "registering SPI-connected sensor\n");
+
+ error = rmi_register_transport_device(&rmi_spi->xport);
+ if (error) {
+ dev_err(&spi->dev, "failed to register sensor: %d\n", error);
+ return error;
}
- retval = devm_add_action_or_reset(&spi->dev,
+
+ error = devm_add_action_or_reset(&spi->dev,
rmi_spi_unregister_transport,
rmi_spi);
- if (retval)
- return retval;
+ if (error)
+ return error;
- dev_info(&spi->dev, "registered RMI SPI driver\n");
return 0;
}
OpenPOWER on IntegriCloud