Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 9ea370f

Browse files
committed
Merge tag 'input-for-v6.10-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov: - a change to input core to trim amount of keys data in modalias string in case when a device declares too many keys and they do not fit in uevent buffer instead of reporting an error which results in uevent not being generated at all - support for Machenike G5 Pro Controller added to xpad driver - support for FocalTech FT5452 and FT8719 added to edt-ft5x06 - support for new SPMI vibrator added to pm8xxx-vibrator driver - missing locking added to cyapa touchpad driver - removal of unused fields in various driver structures - explicit initialization of i2c_device_id::driver_data to 0 dropped from input drivers - other assorted fixes and cleanups. * tag 'input-for-v6.10-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (24 commits) Input: edt-ft5x06 - add support for FocalTech FT5452 and FT8719 dt-bindings: input: touchscreen: edt-ft5x06: Document FT5452 and FT8719 support Input: xpad - add support for Machenike G5 Pro Controller Input: try trimming too long modalias strings Input: drop explicit initialization of struct i2c_device_id::driver_data to 0 Input: zet6223 - remove an unused field in struct zet6223_ts Input: chipone_icn8505 - remove an unused field in struct icn8505_data Input: cros_ec_keyb - remove an unused field in struct cros_ec_keyb Input: lpc32xx-keys - remove an unused field in struct lpc32xx_kscan_drv Input: matrix_keypad - remove an unused field in struct matrix_keypad Input: tca6416-keypad - remove unused struct tca6416_drv_data Input: tca6416-keypad - remove an unused field in struct tca6416_keypad_chip Input: da7280 - remove an unused field in struct da7280_haptic Input: ff-core - prefer struct_size over open coded arithmetic Input: cyapa - add missing input core locking to suspend/resume functions input: pm8xxx-vibrator: add new SPMI vibrator support dt-bindings: input: qcom,pm8xxx-vib: add new SPMI vibrator module input: pm8xxx-vibrator: refactor to support new SPMI vibrator Input: pm8xxx-vibrator - correct VIB_MAX_LEVELS calculation Input: sur40 - convert le16 to cpu before use ...
2 parents 041c9f7 + 2ec0028 commit 9ea370f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+328
-168
lines changed

Documentation/devicetree/bindings/input/qcom,pm8xxx-vib.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ maintainers:
1111

1212
properties:
1313
compatible:
14-
enum:
15-
- qcom,pm8058-vib
16-
- qcom,pm8916-vib
17-
- qcom,pm8921-vib
14+
oneOf:
15+
- enum:
16+
- qcom,pm8058-vib
17+
- qcom,pm8916-vib
18+
- qcom,pm8921-vib
19+
- qcom,pmi632-vib
20+
- items:
21+
- enum:
22+
- qcom,pm7250b-vib
23+
- qcom,pm7325b-vib
24+
- qcom,pm7550ba-vib
25+
- const: qcom,pmi632-vib
1826

1927
reg:
2028
maxItems: 1

Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ properties:
3939
- edt,edt-ft5406
4040
- edt,edt-ft5506
4141
- evervision,ev-ft5726
42+
- focaltech,ft5452
4243
- focaltech,ft6236
44+
- focaltech,ft8719
4345

4446
reg:
4547
maxItems: 1

drivers/input/ff-core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
/* #define DEBUG */
1010

1111
#include <linux/input.h>
12+
#include <linux/limits.h>
1213
#include <linux/module.h>
1314
#include <linux/mutex.h>
15+
#include <linux/overflow.h>
1416
#include <linux/sched.h>
1517
#include <linux/slab.h>
1618

@@ -315,9 +317,8 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects)
315317
return -EINVAL;
316318
}
317319

318-
ff_dev_size = sizeof(struct ff_device) +
319-
max_effects * sizeof(struct file *);
320-
if (ff_dev_size < max_effects) /* overflow */
320+
ff_dev_size = struct_size(ff, effect_owners, max_effects);
321+
if (ff_dev_size == SIZE_MAX) /* overflow */
321322
return -EINVAL;
322323

323324
ff = kzalloc(ff_dev_size, GFP_KERNEL);

drivers/input/input.c

Lines changed: 89 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,19 +1378,19 @@ static int input_print_modalias_bits(char *buf, int size,
13781378
char name, const unsigned long *bm,
13791379
unsigned int min_bit, unsigned int max_bit)
13801380
{
1381-
int len = 0, i;
1381+
int bit = min_bit;
1382+
int len = 0;
13821383

13831384
len += snprintf(buf, max(size, 0), "%c", name);
1384-
for (i = min_bit; i < max_bit; i++)
1385-
if (bm[BIT_WORD(i)] & BIT_MASK(i))
1386-
len += snprintf(buf + len, max(size - len, 0), "%X,", i);
1385+
for_each_set_bit_from(bit, bm, max_bit)
1386+
len += snprintf(buf + len, max(size - len, 0), "%X,", bit);
13871387
return len;
13881388
}
13891389

1390-
static int input_print_modalias(char *buf, int size, const struct input_dev *id,
1391-
int add_cr)
1390+
static int input_print_modalias_parts(char *buf, int size, int full_len,
1391+
const struct input_dev *id)
13921392
{
1393-
int len;
1393+
int len, klen, remainder, space;
13941394

13951395
len = snprintf(buf, max(size, 0),
13961396
"input:b%04Xv%04Xp%04Xe%04X-",
@@ -1399,8 +1399,48 @@ static int input_print_modalias(char *buf, int size, const struct input_dev *id,
13991399

14001400
len += input_print_modalias_bits(buf + len, size - len,
14011401
'e', id->evbit, 0, EV_MAX);
1402-
len += input_print_modalias_bits(buf + len, size - len,
1402+
1403+
/*
1404+
* Calculate the remaining space in the buffer making sure we
1405+
* have place for the terminating 0.
1406+
*/
1407+
space = max(size - (len + 1), 0);
1408+
1409+
klen = input_print_modalias_bits(buf + len, size - len,
14031410
'k', id->keybit, KEY_MIN_INTERESTING, KEY_MAX);
1411+
len += klen;
1412+
1413+
/*
1414+
* If we have more data than we can fit in the buffer, check
1415+
* if we can trim key data to fit in the rest. We will indicate
1416+
* that key data is incomplete by adding "+" sign at the end, like
1417+
* this: * "k1,2,3,45,+,".
1418+
*
1419+
* Note that we shortest key info (if present) is "k+," so we
1420+
* can only try to trim if key data is longer than that.
1421+
*/
1422+
if (full_len && size < full_len + 1 && klen > 3) {
1423+
remainder = full_len - len;
1424+
/*
1425+
* We can only trim if we have space for the remainder
1426+
* and also for at least "k+," which is 3 more characters.
1427+
*/
1428+
if (remainder <= space - 3) {
1429+
/*
1430+
* We are guaranteed to have 'k' in the buffer, so
1431+
* we need at least 3 additional bytes for storing
1432+
* "+," in addition to the remainder.
1433+
*/
1434+
for (int i = size - 1 - remainder - 3; i >= 0; i--) {
1435+
if (buf[i] == 'k' || buf[i] == ',') {
1436+
strcpy(buf + i + 1, "+,");
1437+
len = i + 3; /* Not counting '\0' */
1438+
break;
1439+
}
1440+
}
1441+
}
1442+
}
1443+
14041444
len += input_print_modalias_bits(buf + len, size - len,
14051445
'r', id->relbit, 0, REL_MAX);
14061446
len += input_print_modalias_bits(buf + len, size - len,
@@ -1416,20 +1456,35 @@ static int input_print_modalias(char *buf, int size, const struct input_dev *id,
14161456
len += input_print_modalias_bits(buf + len, size - len,
14171457
'w', id->swbit, 0, SW_MAX);
14181458

1419-
if (add_cr)
1420-
len += snprintf(buf + len, max(size - len, 0), "\n");
1421-
14221459
return len;
14231460
}
14241461

1462+
static int input_print_modalias(char *buf, int size, const struct input_dev *id)
1463+
{
1464+
int full_len;
1465+
1466+
/*
1467+
* Printing is done in 2 passes: first one figures out total length
1468+
* needed for the modalias string, second one will try to trim key
1469+
* data in case when buffer is too small for the entire modalias.
1470+
* If the buffer is too small regardless, it will fill as much as it
1471+
* can (without trimming key data) into the buffer and leave it to
1472+
* the caller to figure out what to do with the result.
1473+
*/
1474+
full_len = input_print_modalias_parts(NULL, 0, 0, id);
1475+
return input_print_modalias_parts(buf, size, full_len, id);
1476+
}
1477+
14251478
static ssize_t input_dev_show_modalias(struct device *dev,
14261479
struct device_attribute *attr,
14271480
char *buf)
14281481
{
14291482
struct input_dev *id = to_input_dev(dev);
14301483
ssize_t len;
14311484

1432-
len = input_print_modalias(buf, PAGE_SIZE, id, 1);
1485+
len = input_print_modalias(buf, PAGE_SIZE, id);
1486+
if (len < PAGE_SIZE - 2)
1487+
len += snprintf(buf + len, PAGE_SIZE - len, "\n");
14331488

14341489
return min_t(int, len, PAGE_SIZE);
14351490
}
@@ -1641,6 +1696,23 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env,
16411696
return 0;
16421697
}
16431698

1699+
/*
1700+
* This is a pretty gross hack. When building uevent data the driver core
1701+
* may try adding more environment variables to kobj_uevent_env without
1702+
* telling us, so we have no idea how much of the buffer we can use to
1703+
* avoid overflows/-ENOMEM elsewhere. To work around this let's artificially
1704+
* reduce amount of memory we will use for the modalias environment variable.
1705+
*
1706+
* The potential additions are:
1707+
*
1708+
* SEQNUM=18446744073709551615 - (%llu - 28 bytes)
1709+
* HOME=/ (6 bytes)
1710+
* PATH=/sbin:/bin:/usr/sbin:/usr/bin (34 bytes)
1711+
*
1712+
* 68 bytes total. Allow extra buffer - 96 bytes
1713+
*/
1714+
#define UEVENT_ENV_EXTRA_LEN 96
1715+
16441716
static int input_add_uevent_modalias_var(struct kobj_uevent_env *env,
16451717
const struct input_dev *dev)
16461718
{
@@ -1650,9 +1722,11 @@ static int input_add_uevent_modalias_var(struct kobj_uevent_env *env,
16501722
return -ENOMEM;
16511723

16521724
len = input_print_modalias(&env->buf[env->buflen - 1],
1653-
sizeof(env->buf) - env->buflen,
1654-
dev, 0);
1655-
if (len >= (sizeof(env->buf) - env->buflen))
1725+
(int)sizeof(env->buf) - env->buflen -
1726+
UEVENT_ENV_EXTRA_LEN,
1727+
dev);
1728+
if (len >= ((int)sizeof(env->buf) - env->buflen -
1729+
UEVENT_ENV_EXTRA_LEN))
16561730
return -ENOMEM;
16571731

16581732
env->buflen += len;

drivers/input/joystick/adafruit-seesaw.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@
5656
#define SEESAW_GAMEPAD_POLL_MIN 8
5757
#define SEESAW_GAMEPAD_POLL_MAX 32
5858

59-
static const unsigned long SEESAW_BUTTON_MASK =
59+
static const u32 SEESAW_BUTTON_MASK =
6060
BIT(SEESAW_BUTTON_A) | BIT(SEESAW_BUTTON_B) | BIT(SEESAW_BUTTON_X) |
6161
BIT(SEESAW_BUTTON_Y) | BIT(SEESAW_BUTTON_START) |
6262
BIT(SEESAW_BUTTON_SELECT);
6363

6464
struct seesaw_gamepad {
6565
struct input_dev *input_dev;
6666
struct i2c_client *i2c_client;
67+
u32 button_state;
6768
};
6869

6970
struct seesaw_data {
@@ -178,10 +179,20 @@ static int seesaw_read_data(struct i2c_client *client, struct seesaw_data *data)
178179
return 0;
179180
}
180181

182+
static int seesaw_open(struct input_dev *input)
183+
{
184+
struct seesaw_gamepad *private = input_get_drvdata(input);
185+
186+
private->button_state = 0;
187+
188+
return 0;
189+
}
190+
181191
static void seesaw_poll(struct input_dev *input)
182192
{
183193
struct seesaw_gamepad *private = input_get_drvdata(input);
184194
struct seesaw_data data;
195+
unsigned long changed;
185196
int err, i;
186197

187198
err = seesaw_read_data(private->i2c_client, &data);
@@ -194,8 +205,11 @@ static void seesaw_poll(struct input_dev *input)
194205
input_report_abs(input, ABS_X, data.x);
195206
input_report_abs(input, ABS_Y, data.y);
196207

197-
for_each_set_bit(i, &SEESAW_BUTTON_MASK,
198-
BITS_PER_TYPE(SEESAW_BUTTON_MASK)) {
208+
data.button_state &= SEESAW_BUTTON_MASK;
209+
changed = private->button_state ^ data.button_state;
210+
private->button_state = data.button_state;
211+
212+
for_each_set_bit(i, &changed, fls(SEESAW_BUTTON_MASK)) {
199213
if (!sparse_keymap_report_event(input, i,
200214
data.button_state & BIT(i),
201215
false))
@@ -253,6 +267,7 @@ static int seesaw_probe(struct i2c_client *client)
253267
seesaw->input_dev->id.bustype = BUS_I2C;
254268
seesaw->input_dev->name = "Adafruit Seesaw Gamepad";
255269
seesaw->input_dev->phys = "i2c/" SEESAW_DEVICE_NAME;
270+
seesaw->input_dev->open = seesaw_open;
256271
input_set_drvdata(seesaw->input_dev, seesaw);
257272
input_set_abs_params(seesaw->input_dev, ABS_X,
258273
0, SEESAW_JOYSTICK_MAX_AXIS,

drivers/input/joystick/as5011.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static void as5011_remove(struct i2c_client *client)
337337
}
338338

339339
static const struct i2c_device_id as5011_id[] = {
340-
{ MODULE_DEVICE_ALIAS, 0 },
340+
{ MODULE_DEVICE_ALIAS },
341341
{ }
342342
};
343343
MODULE_DEVICE_TABLE(i2c, as5011_id);

drivers/input/joystick/qwiic-joystick.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ MODULE_DEVICE_TABLE(of, of_qwiic_match);
126126
#endif /* CONFIG_OF */
127127

128128
static const struct i2c_device_id qwiic_id_table[] = {
129-
{ KBUILD_MODNAME, 0 },
130-
{ },
129+
{ KBUILD_MODNAME },
130+
{ }
131131
};
132132
MODULE_DEVICE_TABLE(i2c, qwiic_id_table);
133133

drivers/input/joystick/xpad.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ static const struct xpad_device {
342342
{ 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE },
343343
{ 0x20d6, 0x2009, "PowerA Enhanced Wired Controller for Xbox Series X|S", 0, XTYPE_XBOXONE },
344344
{ 0x20d6, 0x281f, "PowerA Wired Controller For Xbox 360", 0, XTYPE_XBOX360 },
345+
{ 0x2345, 0xe00b, "Machenike G5 Pro Controller", 0, XTYPE_XBOX360 },
345346
{ 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
346347
{ 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
347348
{ 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
@@ -512,6 +513,7 @@ static const struct usb_device_id xpad_table[] = {
512513
XPAD_XBOX360_VENDOR(0x1bad), /* Harmonix Rock Band guitar and drums */
513514
XPAD_XBOX360_VENDOR(0x20d6), /* PowerA controllers */
514515
XPAD_XBOXONE_VENDOR(0x20d6), /* PowerA controllers */
516+
XPAD_XBOX360_VENDOR(0x2345), /* Machenike Controllers */
515517
XPAD_XBOX360_VENDOR(0x24c6), /* PowerA controllers */
516518
XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA controllers */
517519
XPAD_XBOX360_VENDOR(0x2563), /* OneXPlayer Gamepad */

drivers/input/keyboard/adp5588-keys.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ static int adp5588_resume(struct device *dev)
832832
static DEFINE_SIMPLE_DEV_PM_OPS(adp5588_dev_pm_ops, adp5588_suspend, adp5588_resume);
833833

834834
static const struct i2c_device_id adp5588_id[] = {
835-
{ "adp5588-keys", 0 },
836-
{ "adp5587-keys", 0 },
835+
{ "adp5588-keys" },
836+
{ "adp5587-keys" },
837837
{ }
838838
};
839839
MODULE_DEVICE_TABLE(i2c, adp5588_id);

drivers/input/keyboard/cros_ec_keyb.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* @rows: Number of rows in the keypad
3636
* @cols: Number of columns in the keypad
3737
* @row_shift: log2 or number of rows, rounded up
38-
* @keymap_data: Matrix keymap data used to convert to keyscan values
3938
* @ghost_filter: true to enable the matrix key-ghosting filter
4039
* @valid_keys: bitmap of existing keys for each matrix column
4140
* @old_kb_state: bitmap of keys pressed last scan
@@ -50,7 +49,6 @@ struct cros_ec_keyb {
5049
unsigned int rows;
5150
unsigned int cols;
5251
int row_shift;
53-
const struct matrix_keymap_data *keymap_data;
5452
bool ghost_filter;
5553
uint8_t *valid_keys;
5654
uint8_t *old_kb_state;

0 commit comments

Comments
 (0)