summaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2019-10-21 20:49:19 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2019-10-28 21:01:58 -0700
commitac6b31797925b6f89885987c81d908bad90dea60 (patch)
treea0c31f82521df9a84c833260e75a0235f2fc1711 /drivers/input
parentefd7bb08a762d4f6322054c6824bd942971ac563 (diff)
downloadlinux-ac6b31797925b6f89885987c81d908bad90dea60.tar.bz2
Input: st1232 - do not allocate fingers data separately
The finger structure size is quite small and allocating it together with the main driver structure will not increase likelyhood of allocation failing, but reduces number of objects needing to be tracked by the allocator and devm. Tested-by: Matthias Fend <Matthias.Fend@wolfvision.net> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/st1232.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index bfea02202ded..dfc0c6cb0213 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -50,12 +50,12 @@ struct st1232_ts_data {
const struct st_chip_info *chip_info;
int read_buf_len;
u8 *read_buf;
- struct st1232_ts_finger *finger;
+ struct st1232_ts_finger fingers[];
};
static int st1232_ts_read_data(struct st1232_ts_data *ts)
{
- struct st1232_ts_finger *finger = ts->finger;
+ struct st1232_ts_finger *finger = ts->fingers;
struct i2c_client *client = ts->client;
u8 start_reg = ts->chip_info->start_reg;
struct i2c_msg msg[] = {
@@ -98,7 +98,7 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts)
static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
{
struct st1232_ts_data *ts = dev_id;
- struct st1232_ts_finger *finger = ts->finger;
+ struct st1232_ts_finger *finger = ts->fingers;
struct input_dev *input_dev = ts->input_dev;
int count = 0;
int i, ret;
@@ -177,7 +177,6 @@ static int st1232_ts_probe(struct i2c_client *client,
{
const struct st_chip_info *match;
struct st1232_ts_data *ts;
- struct st1232_ts_finger *finger;
struct input_dev *input_dev;
int error;
@@ -199,16 +198,13 @@ static int st1232_ts_probe(struct i2c_client *client,
return -EINVAL;
}
- ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
+ ts = devm_kzalloc(&client->dev,
+ struct_size(ts, fingers, match->max_fingers),
+ GFP_KERNEL);
if (!ts)
return -ENOMEM;
ts->chip_info = match;
- ts->finger = devm_kcalloc(&client->dev,
- ts->chip_info->max_fingers, sizeof(*finger),
- GFP_KERNEL);
- if (!ts->finger)
- return -ENOMEM;
/* allocate a buffer according to the number of registers to read */
ts->read_buf_len = ts->chip_info->max_fingers * 4;