Skip to content

Commit

Permalink
Merge tag 'input-for-v6.13-rc0' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:

 - support for NT36672A touchscreen added to novatek-nvt-ts driver

 - a change to ads7846 driver to prevent XPT2046 from locking up

 - a change switching platform input dirves back to using remove()
   method (from remove_new())

 - updates to a number of input drivers to use the new cleanup
   facilities (__free(...), guard(), and scoped-guard()) which ensure
   that the resources and locks are released properly and automatically

 - other assorted driver cleanups and fixes.

* tag 'input-for-v6.13-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (109 commits)
  Input: mpr121 - use devm_regulator_get_enable_read_voltage()
  Input: sun4i-lradc-keys - don't include 'pm_wakeup.h' directly
  Input: spear-keyboard - don't include 'pm_wakeup.h' directly
  Input: cypress-sf - constify struct i2c_device_id
  Input: ads7846 - increase xfer array size in 'struct ser_req'
  Input: fix the input_event struct documentation
  Input: i8042 - fix typo dublicate to duplicate
  Input: ads7846 - add dummy command register clearing cycle
  Input: cs40l50 - fix wrong usage of INIT_WORK()
  Input: introduce notion of passive observers for input handlers
  Input: maple_keyb - use guard notation when acquiring mutex
  Input: locomokbd - use guard notation when acquiring spinlock
  Input: hilkbd - use guard notation when acquiring spinlock
  Input: synaptics-rmi4 - switch to using cleanup functions in F34
  Input: synaptics - fix a typo
  dt-bindings: input: rotary-encoder: Fix "rotary-encoder,rollover" type
  Input: omap-keypad - use guard notation when acquiring mutex
  Input: imagis - fix warning regarding 'imagis_3038_data' being unused
  Input: userio - remove unneeded semicolon
  Input: sparcspkr - use cleanup facility for device_node
  ...
  • Loading branch information
torvalds committed Nov 25, 2024
2 parents 919464d + 0201710 commit 3e51108
Show file tree
Hide file tree
Showing 146 changed files with 1,511 additions and 1,843 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ properties:
- mediatek,mt6331-keys
- mediatek,mt6357-keys
- mediatek,mt6358-keys
- mediatek,mt6359-keys
- mediatek,mt6397-keys

power-off-time-sec: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ properties:
device, hence no steps need to be passed.

rotary-encoder,rollover:
$ref: /schemas/types.yaml#/definitions/int32
$ref: /schemas/types.yaml#/definitions/flag
description:
Automatic rollover when the rotary value becomes
greater than the specified steps or smaller than 0. For absolute axis only.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/input/touchscreen/novatek,nvt-ts.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Novatek NVT Touchscreen Controller

maintainers:
- Hans de Goede <[email protected]>

allOf:
- $ref: touchscreen.yaml#

properties:
compatible:
enum:
- novatek,nt11205-ts
- novatek,nt36672a-ts

reg:
maxItems: 1

interrupts:
maxItems: 1

reset-gpios:
maxItems: 1

vcc-supply: true
iovcc-supply: true

required:
- compatible
- reg
- interrupts

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
touchscreen@1 {
compatible = "novatek,nt36672a-ts";
reg = <0x01>;
interrupts-extended = <&tlmm 31 IRQ_TYPE_EDGE_RISING>;
reset-gpios = <&tlmm 32 GPIO_ACTIVE_LOW>;
vcc-supply = <&vreg_l22a_2p85>;
iovcc-supply = <&vreg_l14a_1p8>;
pinctrl-0 = <&ts_int_default &ts_reset_default>;
pinctrl-1 = <&ts_int_sleep &ts_reset_sleep>;
pinctrl-names = "default", "sleep";
touchscreen-size-x = <1080>;
touchscreen-size-y = <2246>;
};
};
...
2 changes: 1 addition & 1 deletion Documentation/input/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ events on a read. Their layout is::
struct timeval time;
unsigned short type;
unsigned short code;
unsigned int value;
int value;
};

``time`` is the timestamp, it returns the time at which the event happened.
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -16570,6 +16570,7 @@ NOVATEK NVT-TS I2C TOUCHSCREEN DRIVER
M: Hans de Goede <[email protected]>
L: [email protected]
S: Maintained
F: Documentation/devicetree/bindings/input/touchscreen/novatek,nvt-ts.yaml
F: drivers/input/touchscreen/novatek-nvt-ts.c

NSDEPS
Expand Down
15 changes: 10 additions & 5 deletions drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@ int input_open_device(struct input_handle *handle)

handle->open++;

if (handle->handler->passive_observer)
goto out;

if (dev->users++ || dev->inhibited) {
/*
* Device is already opened and/or inhibited,
Expand Down Expand Up @@ -668,11 +671,13 @@ void input_close_device(struct input_handle *handle)

__input_release_device(handle);

if (!--dev->users && !dev->inhibited) {
if (dev->poller)
input_dev_poller_stop(dev->poller);
if (dev->close)
dev->close(dev);
if (!handle->handler->passive_observer) {
if (!--dev->users && !dev->inhibited) {
if (dev->poller)
input_dev_poller_stop(dev->poller);
if (dev->close)
dev->close(dev);
}
}

if (!--handle->open) {
Expand Down
30 changes: 14 additions & 16 deletions drivers/input/joystick/db9.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,39 +505,37 @@ static int db9_open(struct input_dev *dev)
{
struct db9 *db9 = input_get_drvdata(dev);
struct parport *port = db9->pd->port;
int err;

err = mutex_lock_interruptible(&db9->mutex);
if (err)
return err;

if (!db9->used++) {
parport_claim(db9->pd);
parport_write_data(port, 0xff);
if (db9_modes[db9->mode].reverse) {
parport_data_reverse(port);
parport_write_control(port, DB9_NORMAL);
scoped_guard(mutex_intr, &db9->mutex) {
if (!db9->used++) {
parport_claim(db9->pd);
parport_write_data(port, 0xff);
if (db9_modes[db9->mode].reverse) {
parport_data_reverse(port);
parport_write_control(port, DB9_NORMAL);
}
mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME);
}
mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME);

return 0;
}

mutex_unlock(&db9->mutex);
return 0;
return -EINTR;
}

static void db9_close(struct input_dev *dev)
{
struct db9 *db9 = input_get_drvdata(dev);
struct parport *port = db9->pd->port;

mutex_lock(&db9->mutex);
guard(mutex)(&db9->mutex);

if (!--db9->used) {
del_timer_sync(&db9->timer);
parport_write_control(port, 0x00);
parport_data_forward(port);
parport_release(db9->pd);
}
mutex_unlock(&db9->mutex);
}

static void db9_attach(struct parport *pp)
Expand Down
22 changes: 10 additions & 12 deletions drivers/input/joystick/gamecon.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,33 +765,31 @@ static void gc_timer(struct timer_list *t)
static int gc_open(struct input_dev *dev)
{
struct gc *gc = input_get_drvdata(dev);
int err;

err = mutex_lock_interruptible(&gc->mutex);
if (err)
return err;
scoped_guard(mutex_intr, &gc->mutex) {
if (!gc->used++) {
parport_claim(gc->pd);
parport_write_control(gc->pd->port, 0x04);
mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
}

if (!gc->used++) {
parport_claim(gc->pd);
parport_write_control(gc->pd->port, 0x04);
mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
return 0;
}

mutex_unlock(&gc->mutex);
return 0;
return -EINTR;
}

static void gc_close(struct input_dev *dev)
{
struct gc *gc = input_get_drvdata(dev);

mutex_lock(&gc->mutex);
guard(mutex)(&gc->mutex);

if (!--gc->used) {
del_timer_sync(&gc->timer);
parport_write_control(gc->pd->port, 0x00);
parport_release(gc->pd);
}
mutex_unlock(&gc->mutex);
}

static int gc_setup_pad(struct gc *gc, int idx, int pad_type)
Expand Down
48 changes: 22 additions & 26 deletions drivers/input/joystick/iforce/iforce-ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ static int make_magnitude_modifier(struct iforce* iforce,
unsigned char data[3];

if (!no_alloc) {
mutex_lock(&iforce->mem_mutex);
if (allocate_resource(&(iforce->device_memory), mod_chunk, 2,
iforce->device_memory.start, iforce->device_memory.end, 2L,
NULL, NULL)) {
mutex_unlock(&iforce->mem_mutex);
guard(mutex)(&iforce->mem_mutex);

if (allocate_resource(&iforce->device_memory, mod_chunk, 2,
iforce->device_memory.start,
iforce->device_memory.end,
2L, NULL, NULL))
return -ENOSPC;
}
mutex_unlock(&iforce->mem_mutex);
}

data[0] = LO(mod_chunk->start);
Expand All @@ -54,14 +53,13 @@ static int make_period_modifier(struct iforce* iforce,
period = TIME_SCALE(period);

if (!no_alloc) {
mutex_lock(&iforce->mem_mutex);
if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0c,
iforce->device_memory.start, iforce->device_memory.end, 2L,
NULL, NULL)) {
mutex_unlock(&iforce->mem_mutex);
guard(mutex)(&iforce->mem_mutex);

if (allocate_resource(&iforce->device_memory, mod_chunk, 0x0c,
iforce->device_memory.start,
iforce->device_memory.end,
2L, NULL, NULL))
return -ENOSPC;
}
mutex_unlock(&iforce->mem_mutex);
}

data[0] = LO(mod_chunk->start);
Expand Down Expand Up @@ -94,14 +92,13 @@ static int make_envelope_modifier(struct iforce* iforce,
fade_duration = TIME_SCALE(fade_duration);

if (!no_alloc) {
mutex_lock(&iforce->mem_mutex);
guard(mutex)(&iforce->mem_mutex);

if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e,
iforce->device_memory.start, iforce->device_memory.end, 2L,
NULL, NULL)) {
mutex_unlock(&iforce->mem_mutex);
iforce->device_memory.start,
iforce->device_memory.end,
2L, NULL, NULL))
return -ENOSPC;
}
mutex_unlock(&iforce->mem_mutex);
}

data[0] = LO(mod_chunk->start);
Expand Down Expand Up @@ -131,14 +128,13 @@ static int make_condition_modifier(struct iforce* iforce,
unsigned char data[10];

if (!no_alloc) {
mutex_lock(&iforce->mem_mutex);
guard(mutex)(&iforce->mem_mutex);

if (allocate_resource(&(iforce->device_memory), mod_chunk, 8,
iforce->device_memory.start, iforce->device_memory.end, 2L,
NULL, NULL)) {
mutex_unlock(&iforce->mem_mutex);
iforce->device_memory.start,
iforce->device_memory.end,
2L, NULL, NULL))
return -ENOSPC;
}
mutex_unlock(&iforce->mem_mutex);
}

data[0] = LO(mod_chunk->start);
Expand Down
57 changes: 25 additions & 32 deletions drivers/input/joystick/iforce/iforce-packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,49 +31,42 @@ int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data)
int c;
int empty;
int head, tail;
unsigned long flags;

/*
* Update head and tail of xmit buffer
*/
spin_lock_irqsave(&iforce->xmit_lock, flags);

head = iforce->xmit.head;
tail = iforce->xmit.tail;


if (CIRC_SPACE(head, tail, XMIT_SIZE) < n+2) {
dev_warn(&iforce->dev->dev,
"not enough space in xmit buffer to send new packet\n");
spin_unlock_irqrestore(&iforce->xmit_lock, flags);
return -1;
}
scoped_guard(spinlock_irqsave, &iforce->xmit_lock) {
head = iforce->xmit.head;
tail = iforce->xmit.tail;

if (CIRC_SPACE(head, tail, XMIT_SIZE) < n + 2) {
dev_warn(&iforce->dev->dev,
"not enough space in xmit buffer to send new packet\n");
return -1;
}

empty = head == tail;
XMIT_INC(iforce->xmit.head, n+2);
empty = head == tail;
XMIT_INC(iforce->xmit.head, n + 2);

/*
* Store packet in xmit buffer
*/
iforce->xmit.buf[head] = HI(cmd);
XMIT_INC(head, 1);
iforce->xmit.buf[head] = LO(cmd);
XMIT_INC(head, 1);

c = CIRC_SPACE_TO_END(head, tail, XMIT_SIZE);
if (n < c) c=n;

memcpy(&iforce->xmit.buf[head],
data,
c);
if (n != c) {
memcpy(&iforce->xmit.buf[0],
data + c,
n - c);
iforce->xmit.buf[head] = HI(cmd);
XMIT_INC(head, 1);
iforce->xmit.buf[head] = LO(cmd);
XMIT_INC(head, 1);

c = CIRC_SPACE_TO_END(head, tail, XMIT_SIZE);
if (n < c)
c = n;

memcpy(&iforce->xmit.buf[head], data, c);
if (n != c)
memcpy(&iforce->xmit.buf[0], data + c, n - c);

XMIT_INC(head, n);
}
XMIT_INC(head, n);

spin_unlock_irqrestore(&iforce->xmit_lock, flags);
/*
* If necessary, start the transmission
*/
Expand Down
Loading

0 comments on commit 3e51108

Please sign in to comment.