Input: iqs5xx - eliminate unnecessary register read
Instead of relying on firmware to enable important register fields and performing read-modify-write operations to additionally enable the fields the driver cares about, it's much simpler just to write all of the pertinent fields explicitly. This avoids an unnecessary register read operation at start-up and makes way for the iqs5xx_read_byte() helper to be dropped. Signed-off-by: Jeff LaBundy <jeff@labundy.com> Link: https://lore.kernel.org/r/1611002626-5889-8-git-send-email-jeff@labundy.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
Родитель
4a76d861d9
Коммит
050fac7f05
|
@ -47,10 +47,13 @@
|
||||||
#define IQS5XX_SUSPEND BIT(0)
|
#define IQS5XX_SUSPEND BIT(0)
|
||||||
#define IQS5XX_RESUME 0
|
#define IQS5XX_RESUME 0
|
||||||
|
|
||||||
#define IQS5XX_SW_INPUT_EVENT 0x10
|
#define IQS5XX_SETUP_COMPLETE BIT(6)
|
||||||
#define IQS5XX_SETUP_COMPLETE 0x40
|
#define IQS5XX_WDT BIT(5)
|
||||||
#define IQS5XX_EVENT_MODE 0x01
|
#define IQS5XX_ALP_REATI BIT(3)
|
||||||
#define IQS5XX_TP_EVENT 0x04
|
#define IQS5XX_REATI BIT(2)
|
||||||
|
|
||||||
|
#define IQS5XX_TP_EVENT BIT(2)
|
||||||
|
#define IQS5XX_EVENT_MODE BIT(0)
|
||||||
|
|
||||||
#define IQS5XX_PROD_NUM 0x0000
|
#define IQS5XX_PROD_NUM 0x0000
|
||||||
#define IQS5XX_SYS_INFO0 0x000F
|
#define IQS5XX_SYS_INFO0 0x000F
|
||||||
|
@ -187,11 +190,6 @@ static int iqs5xx_read_word(struct i2c_client *client, u16 reg, u16 *val)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int iqs5xx_read_byte(struct i2c_client *client, u16 reg, u8 *val)
|
|
||||||
{
|
|
||||||
return iqs5xx_read_burst(client, reg, val, sizeof(*val));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int iqs5xx_write_burst(struct i2c_client *client,
|
static int iqs5xx_write_burst(struct i2c_client *client,
|
||||||
u16 reg, const void *val, u16 len)
|
u16 reg, const void *val, u16 len)
|
||||||
{
|
{
|
||||||
|
@ -561,7 +559,6 @@ static int iqs5xx_dev_init(struct i2c_client *client)
|
||||||
struct iqs5xx_private *iqs5xx = i2c_get_clientdata(client);
|
struct iqs5xx_private *iqs5xx = i2c_get_clientdata(client);
|
||||||
struct iqs5xx_dev_id_info *dev_id_info;
|
struct iqs5xx_dev_id_info *dev_id_info;
|
||||||
int error;
|
int error;
|
||||||
u8 val;
|
|
||||||
u8 buf[sizeof(*dev_id_info) + 1];
|
u8 buf[sizeof(*dev_id_info) + 1];
|
||||||
|
|
||||||
error = iqs5xx_read_burst(client, IQS5XX_PROD_NUM,
|
error = iqs5xx_read_burst(client, IQS5XX_PROD_NUM,
|
||||||
|
@ -628,18 +625,14 @@ static int iqs5xx_dev_init(struct i2c_client *client)
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error = iqs5xx_read_byte(client, IQS5XX_SYS_CFG0, &val);
|
error = iqs5xx_write_byte(client, IQS5XX_SYS_CFG0,
|
||||||
|
IQS5XX_SETUP_COMPLETE | IQS5XX_WDT |
|
||||||
|
IQS5XX_ALP_REATI | IQS5XX_REATI);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
val |= IQS5XX_SETUP_COMPLETE;
|
error = iqs5xx_write_byte(client, IQS5XX_SYS_CFG1,
|
||||||
val &= ~IQS5XX_SW_INPUT_EVENT;
|
IQS5XX_TP_EVENT | IQS5XX_EVENT_MODE);
|
||||||
error = iqs5xx_write_byte(client, IQS5XX_SYS_CFG0, val);
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
val = IQS5XX_TP_EVENT | IQS5XX_EVENT_MODE;
|
|
||||||
error = iqs5xx_write_byte(client, IQS5XX_SYS_CFG1, val);
|
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче