Commit 54bf0894 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: synaptics-rmi4 - when registering sensors do not call them "drivers"

We are not registering drivers, but transport devices (AKA sensors), so
let's call them that.

Also let's rename "retval" to "error" in probe() functions as the variables
are used to store error codes.
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 8a7c71ae
...@@ -204,7 +204,7 @@ static int rmi_i2c_probe(struct i2c_client *client, ...@@ -204,7 +204,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
struct rmi_device_platform_data *client_pdata = struct rmi_device_platform_data *client_pdata =
dev_get_platdata(&client->dev); dev_get_platdata(&client->dev);
struct rmi_i2c_xport *rmi_i2c; struct rmi_i2c_xport *rmi_i2c;
int retval; int error;
rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport), rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport),
GFP_KERNEL); GFP_KERNEL);
...@@ -220,30 +220,31 @@ static int rmi_i2c_probe(struct i2c_client *client, ...@@ -220,30 +220,31 @@ static int rmi_i2c_probe(struct i2c_client *client,
rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s.\n", rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s.\n",
dev_name(&client->dev)); dev_name(&client->dev));
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, dev_err(&client->dev,
"adapter does not support required functionality.\n"); "adapter does not support required functionality\n");
return -ENODEV; return -ENODEV;
} }
rmi_i2c->supplies[0].supply = "vdd"; rmi_i2c->supplies[0].supply = "vdd";
rmi_i2c->supplies[1].supply = "vio"; 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), ARRAY_SIZE(rmi_i2c->supplies),
rmi_i2c->supplies); rmi_i2c->supplies);
if (retval < 0) if (error < 0)
return retval; return error;
retval = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), error = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies),
rmi_i2c->supplies); rmi_i2c->supplies);
if (retval < 0) if (error < 0)
return retval; 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_regulator_bulk_disable,
rmi_i2c); rmi_i2c);
if (retval) if (error)
return retval; return error;
of_property_read_u32(client->dev.of_node, "syna,startup-delay-ms", of_property_read_u32(client->dev.of_node, "syna,startup-delay-ms",
&rmi_i2c->startup_delay); &rmi_i2c->startup_delay);
...@@ -263,26 +264,26 @@ static int rmi_i2c_probe(struct i2c_client *client, ...@@ -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 * 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. * known state, and (b) make sure we can talk to the device.
*/ */
retval = rmi_set_page(rmi_i2c, 0); error = rmi_set_page(rmi_i2c, 0);
if (retval) { if (error) {
dev_err(&client->dev, "Failed to set page select to 0.\n"); dev_err(&client->dev, "Failed to set page select to 0\n");
return retval; return error;
} }
retval = rmi_register_transport_device(&rmi_i2c->xport); dev_info(&client->dev, "registering I2C-connected sensor\n");
if (retval) {
dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n", error = rmi_register_transport_device(&rmi_i2c->xport);
client->addr); if (error) {
return retval; 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_unregister_transport,
rmi_i2c); rmi_i2c);
if (retval) if (error)
return retval; return error;
dev_info(&client->dev, "registered rmi i2c driver at %#04x.\n",
client->addr);
return 0; return 0;
} }
......
...@@ -53,6 +53,7 @@ static int rmi_smb_get_version(struct rmi_smb_xport *rmi_smb) ...@@ -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"); dev_err(&client->dev, "failed to get SMBus version number!\n");
return retval; return retval;
} }
return retval + 1; return retval + 1;
} }
...@@ -275,19 +276,24 @@ static int rmi_smb_probe(struct i2c_client *client, ...@@ -275,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_device_platform_data *pdata = dev_get_platdata(&client->dev);
struct rmi_smb_xport *rmi_smb; struct rmi_smb_xport *rmi_smb;
int retval;
int smbus_version; int smbus_version;
int error;
if (!pdata) {
dev_err(&client->dev, "no platform data, aborting\n");
return -ENOMEM;
}
if (!i2c_check_functionality(client->adapter, if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_READ_BLOCK_DATA |
I2C_FUNC_SMBUS_HOST_NOTIFY)) { I2C_FUNC_SMBUS_HOST_NOTIFY)) {
dev_err(&client->dev, dev_err(&client->dev,
"adapter does not support required functionality.\n"); "adapter does not support required functionality\n");
return -ENODEV; return -ENODEV;
} }
if (client->irq <= 0) { 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; return client->irq ? client->irq : -ENODEV;
} }
...@@ -296,12 +302,7 @@ static int rmi_smb_probe(struct i2c_client *client, ...@@ -296,12 +302,7 @@ static int rmi_smb_probe(struct i2c_client *client,
if (!rmi_smb) if (!rmi_smb)
return -ENOMEM; return -ENOMEM;
if (!pdata) { rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s\n",
dev_err(&client->dev, "no platform data, aborting\n");
return -ENOMEM;
}
rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s.\n",
dev_name(&client->dev)); dev_name(&client->dev));
rmi_smb->client = client; rmi_smb->client = client;
...@@ -314,34 +315,30 @@ static int rmi_smb_probe(struct i2c_client *client, ...@@ -314,34 +315,30 @@ static int rmi_smb_probe(struct i2c_client *client,
rmi_smb->xport.proto_name = "smb2"; rmi_smb->xport.proto_name = "smb2";
rmi_smb->xport.ops = &rmi_smb_ops; rmi_smb->xport.ops = &rmi_smb_ops;
retval = rmi_smb_get_version(rmi_smb); smbus_version = rmi_smb_get_version(rmi_smb);
if (retval < 0) if (smbus_version < 0)
return retval; return smbus_version;
smbus_version = retval;
rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Smbus version is %d", rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Smbus version is %d",
smbus_version); smbus_version);
if (smbus_version != 2) { if (smbus_version != 2) {
dev_err(&client->dev, "Unrecognized SMB version %d.\n", dev_err(&client->dev, "Unrecognized SMB version %d\n",
smbus_version); smbus_version);
return -ENODEV; return -ENODEV;
} }
i2c_set_clientdata(client, rmi_smb); i2c_set_clientdata(client, rmi_smb);
retval = rmi_register_transport_device(&rmi_smb->xport); dev_info(&client->dev, "registering SMbus-connected sensor\n");
if (retval) {
dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n", error = rmi_register_transport_device(&rmi_smb->xport);
client->addr); if (error) {
i2c_set_clientdata(client, NULL); dev_err(&client->dev, "failed to register sensor: %d\n", error);
return retval; return error;
} }
dev_info(&client->dev, "registered rmi smb driver at %#04x.\n",
client->addr);
return 0; return 0;
} }
static int rmi_smb_remove(struct i2c_client *client) static int rmi_smb_remove(struct i2c_client *client)
......
...@@ -370,7 +370,7 @@ static int rmi_spi_probe(struct spi_device *spi) ...@@ -370,7 +370,7 @@ static int rmi_spi_probe(struct spi_device *spi)
struct rmi_spi_xport *rmi_spi; struct rmi_spi_xport *rmi_spi;
struct rmi_device_platform_data *pdata; struct rmi_device_platform_data *pdata;
struct rmi_device_platform_data *spi_pdata = spi->dev.platform_data; struct rmi_device_platform_data *spi_pdata = spi->dev.platform_data;
int retval; int error;
if (spi->master->flags & SPI_MASTER_HALF_DUPLEX) if (spi->master->flags & SPI_MASTER_HALF_DUPLEX)
return -EINVAL; return -EINVAL;
...@@ -383,9 +383,9 @@ static int rmi_spi_probe(struct spi_device *spi) ...@@ -383,9 +383,9 @@ static int rmi_spi_probe(struct spi_device *spi)
pdata = &rmi_spi->xport.pdata; pdata = &rmi_spi->xport.pdata;
if (spi->dev.of_node) { if (spi->dev.of_node) {
retval = rmi_spi_of_probe(spi, pdata); error = rmi_spi_of_probe(spi, pdata);
if (retval) if (error)
return retval; return error;
} else if (spi_pdata) { } else if (spi_pdata) {
*pdata = *spi_pdata; *pdata = *spi_pdata;
} }
...@@ -396,10 +396,10 @@ static int rmi_spi_probe(struct spi_device *spi) ...@@ -396,10 +396,10 @@ static int rmi_spi_probe(struct spi_device *spi)
if (pdata->spi_data.mode) if (pdata->spi_data.mode)
spi->mode = pdata->spi_data.mode; spi->mode = pdata->spi_data.mode;
retval = spi_setup(spi); error = spi_setup(spi);
if (retval < 0) { if (error < 0) {
dev_err(&spi->dev, "spi_setup failed!\n"); dev_err(&spi->dev, "spi_setup failed!\n");
return retval; return error;
} }
pdata->irq = spi->irq; pdata->irq = spi->irq;
...@@ -413,32 +413,34 @@ static int rmi_spi_probe(struct spi_device *spi) ...@@ -413,32 +413,34 @@ static int rmi_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, rmi_spi); spi_set_drvdata(spi, rmi_spi);
retval = rmi_spi_manage_pools(rmi_spi, RMI_SPI_DEFAULT_XFER_BUF_SIZE); error = rmi_spi_manage_pools(rmi_spi, RMI_SPI_DEFAULT_XFER_BUF_SIZE);
if (retval) if (error)
return retval; return error;
/* /*
* Setting the page to zero will (a) make sure the PSR is in a * 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. * known state, and (b) make sure we can talk to the device.
*/ */
retval = rmi_set_page(rmi_spi, 0); error = rmi_set_page(rmi_spi, 0);
if (retval) { if (error) {
dev_err(&spi->dev, "Failed to set page select to 0.\n"); dev_err(&spi->dev, "Failed to set page select to 0.\n");
return retval; return error;
} }
retval = rmi_register_transport_device(&rmi_spi->xport); dev_info(&spi->dev, "registering SPI-connected sensor\n");
if (retval) {
dev_err(&spi->dev, "failed to register transport.\n"); error = rmi_register_transport_device(&rmi_spi->xport);
return retval; 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_unregister_transport,
rmi_spi); rmi_spi);
if (retval) if (error)
return retval; return error;
dev_info(&spi->dev, "registered RMI SPI driver\n");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment