Input updates for v6.13-rc0

- 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.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQST2eWILY88ieB2DOtAj56VGEWXnAUCZ0PQIAAKCRBAj56VGEWX
 nDFFAQCSj3Va9Y6ZgNFvjmPAoA3RmsrvydXMG6PuyHEEfvTtpgD9GPldve3MRqRr
 VcrLJXMgyX2+RgpKm1W9ZQgK9Nudegs=
 =Ry7d
 -----END PGP SIGNATURE-----

Merge tag 'input-for-v6.13-rc0' of git://git.kernel.org/pub/scm/linux/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
  ...
This commit is contained in:
Linus Torvalds 2024-11-25 10:31:39 -08:00
commit 3e51108c72
146 changed files with 1530 additions and 1862 deletions

View File

@ -28,6 +28,7 @@ properties:
- mediatek,mt6331-keys - mediatek,mt6331-keys
- mediatek,mt6357-keys - mediatek,mt6357-keys
- mediatek,mt6358-keys - mediatek,mt6358-keys
- mediatek,mt6359-keys
- mediatek,mt6397-keys - mediatek,mt6397-keys
power-off-time-sec: true power-off-time-sec: true

View File

@ -41,7 +41,7 @@ properties:
device, hence no steps need to be passed. device, hence no steps need to be passed.
rotary-encoder,rollover: rotary-encoder,rollover:
$ref: /schemas/types.yaml#/definitions/int32 $ref: /schemas/types.yaml#/definitions/flag
description: description:
Automatic rollover when the rotary value becomes Automatic rollover when the rotary value becomes
greater than the specified steps or smaller than 0. For absolute axis only. greater than the specified steps or smaller than 0. For absolute axis only.

View File

@ -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 <hdegoede@redhat.com>
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>;
};
};
...

View File

@ -264,7 +264,7 @@ events on a read. Their layout is::
struct timeval time; struct timeval time;
unsigned short type; unsigned short type;
unsigned short code; unsigned short code;
unsigned int value; int value;
}; };
``time`` is the timestamp, it returns the time at which the event happened. ``time`` is the timestamp, it returns the time at which the event happened.

View File

@ -16570,6 +16570,7 @@ NOVATEK NVT-TS I2C TOUCHSCREEN DRIVER
M: Hans de Goede <hdegoede@redhat.com> M: Hans de Goede <hdegoede@redhat.com>
L: linux-input@vger.kernel.org L: linux-input@vger.kernel.org
S: Maintained S: Maintained
F: Documentation/devicetree/bindings/input/touchscreen/novatek,nvt-ts.yaml
F: drivers/input/touchscreen/novatek-nvt-ts.c F: drivers/input/touchscreen/novatek-nvt-ts.c
NSDEPS NSDEPS

View File

@ -605,6 +605,9 @@ int input_open_device(struct input_handle *handle)
handle->open++; handle->open++;
if (handle->handler->passive_observer)
goto out;
if (dev->users++ || dev->inhibited) { if (dev->users++ || dev->inhibited) {
/* /*
* Device is already opened and/or inhibited, * Device is already opened and/or inhibited,
@ -668,11 +671,13 @@ void input_close_device(struct input_handle *handle)
__input_release_device(handle); __input_release_device(handle);
if (!--dev->users && !dev->inhibited) { if (!handle->handler->passive_observer) {
if (dev->poller) if (!--dev->users && !dev->inhibited) {
input_dev_poller_stop(dev->poller); if (dev->poller)
if (dev->close) input_dev_poller_stop(dev->poller);
dev->close(dev); if (dev->close)
dev->close(dev);
}
} }
if (!--handle->open) { if (!--handle->open) {

View File

@ -505,24 +505,22 @@ static int db9_open(struct input_dev *dev)
{ {
struct db9 *db9 = input_get_drvdata(dev); struct db9 *db9 = input_get_drvdata(dev);
struct parport *port = db9->pd->port; struct parport *port = db9->pd->port;
int err;
err = mutex_lock_interruptible(&db9->mutex); scoped_guard(mutex_intr, &db9->mutex) {
if (err) if (!db9->used++) {
return err; parport_claim(db9->pd);
parport_write_data(port, 0xff);
if (!db9->used++) { if (db9_modes[db9->mode].reverse) {
parport_claim(db9->pd); parport_data_reverse(port);
parport_write_data(port, 0xff); parport_write_control(port, DB9_NORMAL);
if (db9_modes[db9->mode].reverse) { }
parport_data_reverse(port); mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME);
parport_write_control(port, DB9_NORMAL);
} }
mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME);
return 0;
} }
mutex_unlock(&db9->mutex); return -EINTR;
return 0;
} }
static void db9_close(struct input_dev *dev) static void db9_close(struct input_dev *dev)
@ -530,14 +528,14 @@ static void db9_close(struct input_dev *dev)
struct db9 *db9 = input_get_drvdata(dev); struct db9 *db9 = input_get_drvdata(dev);
struct parport *port = db9->pd->port; struct parport *port = db9->pd->port;
mutex_lock(&db9->mutex); guard(mutex)(&db9->mutex);
if (!--db9->used) { if (!--db9->used) {
del_timer_sync(&db9->timer); del_timer_sync(&db9->timer);
parport_write_control(port, 0x00); parport_write_control(port, 0x00);
parport_data_forward(port); parport_data_forward(port);
parport_release(db9->pd); parport_release(db9->pd);
} }
mutex_unlock(&db9->mutex);
} }
static void db9_attach(struct parport *pp) static void db9_attach(struct parport *pp)

View File

@ -765,33 +765,31 @@ static void gc_timer(struct timer_list *t)
static int gc_open(struct input_dev *dev) static int gc_open(struct input_dev *dev)
{ {
struct gc *gc = input_get_drvdata(dev); struct gc *gc = input_get_drvdata(dev);
int err;
err = mutex_lock_interruptible(&gc->mutex); scoped_guard(mutex_intr, &gc->mutex) {
if (err) if (!gc->used++) {
return err; parport_claim(gc->pd);
parport_write_control(gc->pd->port, 0x04);
mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
}
if (!gc->used++) { return 0;
parport_claim(gc->pd);
parport_write_control(gc->pd->port, 0x04);
mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
} }
mutex_unlock(&gc->mutex); return -EINTR;
return 0;
} }
static void gc_close(struct input_dev *dev) static void gc_close(struct input_dev *dev)
{ {
struct gc *gc = input_get_drvdata(dev); struct gc *gc = input_get_drvdata(dev);
mutex_lock(&gc->mutex); guard(mutex)(&gc->mutex);
if (!--gc->used) { if (!--gc->used) {
del_timer_sync(&gc->timer); del_timer_sync(&gc->timer);
parport_write_control(gc->pd->port, 0x00); parport_write_control(gc->pd->port, 0x00);
parport_release(gc->pd); parport_release(gc->pd);
} }
mutex_unlock(&gc->mutex);
} }
static int gc_setup_pad(struct gc *gc, int idx, int pad_type) static int gc_setup_pad(struct gc *gc, int idx, int pad_type)

View File

@ -21,14 +21,13 @@ static int make_magnitude_modifier(struct iforce* iforce,
unsigned char data[3]; unsigned char data[3];
if (!no_alloc) { if (!no_alloc) {
mutex_lock(&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, if (allocate_resource(&iforce->device_memory, mod_chunk, 2,
NULL, NULL)) { iforce->device_memory.start,
mutex_unlock(&iforce->mem_mutex); iforce->device_memory.end,
2L, NULL, NULL))
return -ENOSPC; return -ENOSPC;
}
mutex_unlock(&iforce->mem_mutex);
} }
data[0] = LO(mod_chunk->start); data[0] = LO(mod_chunk->start);
@ -54,14 +53,13 @@ static int make_period_modifier(struct iforce* iforce,
period = TIME_SCALE(period); period = TIME_SCALE(period);
if (!no_alloc) { if (!no_alloc) {
mutex_lock(&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, if (allocate_resource(&iforce->device_memory, mod_chunk, 0x0c,
NULL, NULL)) { iforce->device_memory.start,
mutex_unlock(&iforce->mem_mutex); iforce->device_memory.end,
2L, NULL, NULL))
return -ENOSPC; return -ENOSPC;
}
mutex_unlock(&iforce->mem_mutex);
} }
data[0] = LO(mod_chunk->start); data[0] = LO(mod_chunk->start);
@ -94,14 +92,13 @@ static int make_envelope_modifier(struct iforce* iforce,
fade_duration = TIME_SCALE(fade_duration); fade_duration = TIME_SCALE(fade_duration);
if (!no_alloc) { if (!no_alloc) {
mutex_lock(&iforce->mem_mutex); guard(mutex)(&iforce->mem_mutex);
if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e, if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e,
iforce->device_memory.start, iforce->device_memory.end, 2L, iforce->device_memory.start,
NULL, NULL)) { iforce->device_memory.end,
mutex_unlock(&iforce->mem_mutex); 2L, NULL, NULL))
return -ENOSPC; return -ENOSPC;
}
mutex_unlock(&iforce->mem_mutex);
} }
data[0] = LO(mod_chunk->start); data[0] = LO(mod_chunk->start);
@ -131,14 +128,13 @@ static int make_condition_modifier(struct iforce* iforce,
unsigned char data[10]; unsigned char data[10];
if (!no_alloc) { if (!no_alloc) {
mutex_lock(&iforce->mem_mutex); guard(mutex)(&iforce->mem_mutex);
if (allocate_resource(&(iforce->device_memory), mod_chunk, 8, if (allocate_resource(&(iforce->device_memory), mod_chunk, 8,
iforce->device_memory.start, iforce->device_memory.end, 2L, iforce->device_memory.start,
NULL, NULL)) { iforce->device_memory.end,
mutex_unlock(&iforce->mem_mutex); 2L, NULL, NULL))
return -ENOSPC; return -ENOSPC;
}
mutex_unlock(&iforce->mem_mutex);
} }
data[0] = LO(mod_chunk->start); data[0] = LO(mod_chunk->start);

View File

@ -31,49 +31,42 @@ int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data)
int c; int c;
int empty; int empty;
int head, tail; int head, tail;
unsigned long flags;
/* /*
* Update head and tail of xmit buffer * Update head and tail of xmit buffer
*/ */
spin_lock_irqsave(&iforce->xmit_lock, flags); scoped_guard(spinlock_irqsave, &iforce->xmit_lock) {
head = iforce->xmit.head;
tail = iforce->xmit.tail;
head = iforce->xmit.head; if (CIRC_SPACE(head, tail, XMIT_SIZE) < n + 2) {
tail = iforce->xmit.tail; dev_warn(&iforce->dev->dev,
"not enough space in xmit buffer to send new packet\n");
return -1;
}
empty = head == tail;
if (CIRC_SPACE(head, tail, XMIT_SIZE) < n+2) { XMIT_INC(iforce->xmit.head, 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;
}
empty = head == tail;
XMIT_INC(iforce->xmit.head, n+2);
/* /*
* Store packet in xmit buffer * Store packet in xmit buffer
*/ */
iforce->xmit.buf[head] = HI(cmd); iforce->xmit.buf[head] = HI(cmd);
XMIT_INC(head, 1); XMIT_INC(head, 1);
iforce->xmit.buf[head] = LO(cmd); iforce->xmit.buf[head] = LO(cmd);
XMIT_INC(head, 1); XMIT_INC(head, 1);
c = CIRC_SPACE_TO_END(head, tail, XMIT_SIZE); c = CIRC_SPACE_TO_END(head, tail, XMIT_SIZE);
if (n < c) c=n; if (n < c)
c = n;
memcpy(&iforce->xmit.buf[head], memcpy(&iforce->xmit.buf[head], data, c);
data, if (n != c)
c); memcpy(&iforce->xmit.buf[0], data + c, n - c);
if (n != c) {
memcpy(&iforce->xmit.buf[0], XMIT_INC(head, n);
data + c,
n - c);
} }
XMIT_INC(head, n);
spin_unlock_irqrestore(&iforce->xmit_lock, flags);
/* /*
* If necessary, start the transmission * If necessary, start the transmission
*/ */

View File

@ -28,45 +28,39 @@ static void iforce_serio_xmit(struct iforce *iforce)
iforce); iforce);
unsigned char cs; unsigned char cs;
int i; int i;
unsigned long flags;
if (test_and_set_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags)) { if (test_and_set_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags)) {
set_bit(IFORCE_XMIT_AGAIN, iforce->xmit_flags); set_bit(IFORCE_XMIT_AGAIN, iforce->xmit_flags);
return; return;
} }
spin_lock_irqsave(&iforce->xmit_lock, flags); guard(spinlock_irqsave)(&iforce->xmit_lock);
again: do {
if (iforce->xmit.head == iforce->xmit.tail) { if (iforce->xmit.head == iforce->xmit.tail)
iforce_clear_xmit_and_wake(iforce); break;
spin_unlock_irqrestore(&iforce->xmit_lock, flags);
return;
}
cs = 0x2b; cs = 0x2b;
serio_write(iforce_serio->serio, 0x2b); serio_write(iforce_serio->serio, 0x2b);
serio_write(iforce_serio->serio, iforce->xmit.buf[iforce->xmit.tail]);
cs ^= iforce->xmit.buf[iforce->xmit.tail];
XMIT_INC(iforce->xmit.tail, 1);
for (i=iforce->xmit.buf[iforce->xmit.tail]; i >= 0; --i) {
serio_write(iforce_serio->serio, serio_write(iforce_serio->serio,
iforce->xmit.buf[iforce->xmit.tail]); iforce->xmit.buf[iforce->xmit.tail]);
cs ^= iforce->xmit.buf[iforce->xmit.tail]; cs ^= iforce->xmit.buf[iforce->xmit.tail];
XMIT_INC(iforce->xmit.tail, 1); XMIT_INC(iforce->xmit.tail, 1);
}
serio_write(iforce_serio->serio, cs); for (i = iforce->xmit.buf[iforce->xmit.tail]; i >= 0; --i) {
serio_write(iforce_serio->serio,
iforce->xmit.buf[iforce->xmit.tail]);
cs ^= iforce->xmit.buf[iforce->xmit.tail];
XMIT_INC(iforce->xmit.tail, 1);
}
if (test_and_clear_bit(IFORCE_XMIT_AGAIN, iforce->xmit_flags)) serio_write(iforce_serio->serio, cs);
goto again;
} while (test_and_clear_bit(IFORCE_XMIT_AGAIN, iforce->xmit_flags));
iforce_clear_xmit_and_wake(iforce); iforce_clear_xmit_and_wake(iforce);
spin_unlock_irqrestore(&iforce->xmit_lock, flags);
} }
static int iforce_serio_get_id(struct iforce *iforce, u8 id, static int iforce_serio_get_id(struct iforce *iforce, u8 id,

View File

@ -25,13 +25,11 @@ static void __iforce_usb_xmit(struct iforce *iforce)
struct iforce_usb *iforce_usb = container_of(iforce, struct iforce_usb, struct iforce_usb *iforce_usb = container_of(iforce, struct iforce_usb,
iforce); iforce);
int n, c; int n, c;
unsigned long flags;
spin_lock_irqsave(&iforce->xmit_lock, flags); guard(spinlock_irqsave)(&iforce->xmit_lock);
if (iforce->xmit.head == iforce->xmit.tail) { if (iforce->xmit.head == iforce->xmit.tail) {
iforce_clear_xmit_and_wake(iforce); iforce_clear_xmit_and_wake(iforce);
spin_unlock_irqrestore(&iforce->xmit_lock, flags);
return; return;
} }
@ -45,7 +43,8 @@ static void __iforce_usb_xmit(struct iforce *iforce)
/* Copy rest of data then */ /* Copy rest of data then */
c = CIRC_CNT_TO_END(iforce->xmit.head, iforce->xmit.tail, XMIT_SIZE); c = CIRC_CNT_TO_END(iforce->xmit.head, iforce->xmit.tail, XMIT_SIZE);
if (n < c) c=n; if (n < c)
c = n;
memcpy(iforce_usb->out->transfer_buffer + 1, memcpy(iforce_usb->out->transfer_buffer + 1,
&iforce->xmit.buf[iforce->xmit.tail], &iforce->xmit.buf[iforce->xmit.tail],
@ -53,11 +52,12 @@ static void __iforce_usb_xmit(struct iforce *iforce)
if (n != c) { if (n != c) {
memcpy(iforce_usb->out->transfer_buffer + 1 + c, memcpy(iforce_usb->out->transfer_buffer + 1 + c,
&iforce->xmit.buf[0], &iforce->xmit.buf[0],
n-c); n - c);
} }
XMIT_INC(iforce->xmit.tail, n); XMIT_INC(iforce->xmit.tail, n);
if ( (n=usb_submit_urb(iforce_usb->out, GFP_ATOMIC)) ) { n=usb_submit_urb(iforce_usb->out, GFP_ATOMIC);
if (n) {
dev_warn(&iforce_usb->intf->dev, dev_warn(&iforce_usb->intf->dev,
"usb_submit_urb failed %d\n", n); "usb_submit_urb failed %d\n", n);
iforce_clear_xmit_and_wake(iforce); iforce_clear_xmit_and_wake(iforce);
@ -66,7 +66,6 @@ static void __iforce_usb_xmit(struct iforce *iforce)
/* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended. /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended.
* As long as the urb completion handler is not called, the transmiting * As long as the urb completion handler is not called, the transmiting
* is considered to be running */ * is considered to be running */
spin_unlock_irqrestore(&iforce->xmit_lock, flags);
} }
static void iforce_usb_xmit(struct iforce *iforce) static void iforce_usb_xmit(struct iforce *iforce)

View File

@ -191,35 +191,32 @@ static void n64joy_poll(struct timer_list *t)
static int n64joy_open(struct input_dev *dev) static int n64joy_open(struct input_dev *dev)
{ {
struct n64joy_priv *priv = input_get_drvdata(dev); struct n64joy_priv *priv = input_get_drvdata(dev);
int err;
err = mutex_lock_interruptible(&priv->n64joy_mutex); scoped_guard(mutex_intr, &priv->n64joy_mutex) {
if (err) if (!priv->n64joy_opened) {
return err; /*
* We could use the vblank irq, but it's not important
* if the poll point slightly changes.
*/
timer_setup(&priv->timer, n64joy_poll, 0);
mod_timer(&priv->timer, jiffies + msecs_to_jiffies(16));
}
if (!priv->n64joy_opened) { priv->n64joy_opened++;
/* return 0;
* We could use the vblank irq, but it's not important if
* the poll point slightly changes.
*/
timer_setup(&priv->timer, n64joy_poll, 0);
mod_timer(&priv->timer, jiffies + msecs_to_jiffies(16));
} }
priv->n64joy_opened++; return -EINTR;
mutex_unlock(&priv->n64joy_mutex);
return err;
} }
static void n64joy_close(struct input_dev *dev) static void n64joy_close(struct input_dev *dev)
{ {
struct n64joy_priv *priv = input_get_drvdata(dev); struct n64joy_priv *priv = input_get_drvdata(dev);
mutex_lock(&priv->n64joy_mutex); guard(mutex)(&priv->n64joy_mutex);
if (!--priv->n64joy_opened) if (!--priv->n64joy_opened)
del_timer_sync(&priv->timer); del_timer_sync(&priv->timer);
mutex_unlock(&priv->n64joy_mutex);
} }
static const u64 __initconst scandata[] ____cacheline_aligned = { static const u64 __initconst scandata[] ____cacheline_aligned = {

View File

@ -103,33 +103,31 @@ static void tgfx_timer(struct timer_list *t)
static int tgfx_open(struct input_dev *dev) static int tgfx_open(struct input_dev *dev)
{ {
struct tgfx *tgfx = input_get_drvdata(dev); struct tgfx *tgfx = input_get_drvdata(dev);
int err;
err = mutex_lock_interruptible(&tgfx->sem); scoped_guard(mutex_intr, &tgfx->sem) {
if (err) if (!tgfx->used++) {
return err; parport_claim(tgfx->pd);
parport_write_control(tgfx->pd->port, 0x04);
mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME);
}
if (!tgfx->used++) { return 0;
parport_claim(tgfx->pd);
parport_write_control(tgfx->pd->port, 0x04);
mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME);
} }
mutex_unlock(&tgfx->sem); return -EINTR;
return 0;
} }
static void tgfx_close(struct input_dev *dev) static void tgfx_close(struct input_dev *dev)
{ {
struct tgfx *tgfx = input_get_drvdata(dev); struct tgfx *tgfx = input_get_drvdata(dev);
mutex_lock(&tgfx->sem); guard(mutex)(&tgfx->sem);
if (!--tgfx->used) { if (!--tgfx->used) {
del_timer_sync(&tgfx->timer); del_timer_sync(&tgfx->timer);
parport_write_control(tgfx->pd->port, 0x00); parport_write_control(tgfx->pd->port, 0x00);
parport_release(tgfx->pd); parport_release(tgfx->pd);
} }
mutex_unlock(&tgfx->sem);
} }

View File

@ -1292,9 +1292,8 @@ static void xpad_irq_out(struct urb *urb)
struct device *dev = &xpad->intf->dev; struct device *dev = &xpad->intf->dev;
int status = urb->status; int status = urb->status;
int error; int error;
unsigned long flags;
spin_lock_irqsave(&xpad->odata_lock, flags); guard(spinlock_irqsave)(&xpad->odata_lock);
switch (status) { switch (status) {
case 0: case 0:
@ -1328,8 +1327,6 @@ static void xpad_irq_out(struct urb *urb)
xpad->irq_out_active = false; xpad->irq_out_active = false;
} }
} }
spin_unlock_irqrestore(&xpad->odata_lock, flags);
} }
static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad, static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad,
@ -1394,10 +1391,8 @@ static int xpad_inquiry_pad_presence(struct usb_xpad *xpad)
{ {
struct xpad_output_packet *packet = struct xpad_output_packet *packet =
&xpad->out_packets[XPAD_OUT_CMD_IDX]; &xpad->out_packets[XPAD_OUT_CMD_IDX];
unsigned long flags;
int retval;
spin_lock_irqsave(&xpad->odata_lock, flags); guard(spinlock_irqsave)(&xpad->odata_lock);
packet->data[0] = 0x08; packet->data[0] = 0x08;
packet->data[1] = 0x00; packet->data[1] = 0x00;
@ -1416,17 +1411,12 @@ static int xpad_inquiry_pad_presence(struct usb_xpad *xpad)
/* Reset the sequence so we send out presence first */ /* Reset the sequence so we send out presence first */
xpad->last_out_packet = -1; xpad->last_out_packet = -1;
retval = xpad_try_sending_next_out_packet(xpad); return xpad_try_sending_next_out_packet(xpad);
spin_unlock_irqrestore(&xpad->odata_lock, flags);
return retval;
} }
static int xpad_start_xbox_one(struct usb_xpad *xpad) static int xpad_start_xbox_one(struct usb_xpad *xpad)
{ {
unsigned long flags; int error;
int retval;
if (usb_ifnum_to_if(xpad->udev, GIP_WIRED_INTF_AUDIO)) { if (usb_ifnum_to_if(xpad->udev, GIP_WIRED_INTF_AUDIO)) {
/* /*
@ -1435,15 +1425,15 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad)
* Controller for Series X|S (0x20d6:0x200e) to report the * Controller for Series X|S (0x20d6:0x200e) to report the
* guide button. * guide button.
*/ */
retval = usb_set_interface(xpad->udev, error = usb_set_interface(xpad->udev,
GIP_WIRED_INTF_AUDIO, 0); GIP_WIRED_INTF_AUDIO, 0);
if (retval) if (error)
dev_warn(&xpad->dev->dev, dev_warn(&xpad->dev->dev,
"unable to disable audio interface: %d\n", "unable to disable audio interface: %d\n",
retval); error);
} }
spin_lock_irqsave(&xpad->odata_lock, flags); guard(spinlock_irqsave)(&xpad->odata_lock);
/* /*
* Begin the init sequence by attempting to send a packet. * Begin the init sequence by attempting to send a packet.
@ -1451,16 +1441,11 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad)
* sending any packets from the output ring. * sending any packets from the output ring.
*/ */
xpad->init_seq = 0; xpad->init_seq = 0;
retval = xpad_try_sending_next_out_packet(xpad); return xpad_try_sending_next_out_packet(xpad);
spin_unlock_irqrestore(&xpad->odata_lock, flags);
return retval;
} }
static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num) static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num)
{ {
unsigned long flags;
struct xpad_output_packet *packet = struct xpad_output_packet *packet =
&xpad->out_packets[XPAD_OUT_CMD_IDX]; &xpad->out_packets[XPAD_OUT_CMD_IDX];
static const u8 mode_report_ack[] = { static const u8 mode_report_ack[] = {
@ -1468,7 +1453,7 @@ static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num)
0x00, GIP_CMD_VIRTUAL_KEY, GIP_OPT_INTERNAL, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 0x00, GIP_CMD_VIRTUAL_KEY, GIP_OPT_INTERNAL, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
}; };
spin_lock_irqsave(&xpad->odata_lock, flags); guard(spinlock_irqsave)(&xpad->odata_lock);
packet->len = sizeof(mode_report_ack); packet->len = sizeof(mode_report_ack);
memcpy(packet->data, mode_report_ack, packet->len); memcpy(packet->data, mode_report_ack, packet->len);
@ -1478,8 +1463,6 @@ static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num)
/* Reset the sequence so we send out the ack now */ /* Reset the sequence so we send out the ack now */
xpad->last_out_packet = -1; xpad->last_out_packet = -1;
xpad_try_sending_next_out_packet(xpad); xpad_try_sending_next_out_packet(xpad);
spin_unlock_irqrestore(&xpad->odata_lock, flags);
} }
#ifdef CONFIG_JOYSTICK_XPAD_FF #ifdef CONFIG_JOYSTICK_XPAD_FF
@ -1489,8 +1472,6 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX]; struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX];
__u16 strong; __u16 strong;
__u16 weak; __u16 weak;
int retval;
unsigned long flags;
if (effect->type != FF_RUMBLE) if (effect->type != FF_RUMBLE)
return 0; return 0;
@ -1498,7 +1479,7 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
strong = effect->u.rumble.strong_magnitude; strong = effect->u.rumble.strong_magnitude;
weak = effect->u.rumble.weak_magnitude; weak = effect->u.rumble.weak_magnitude;
spin_lock_irqsave(&xpad->odata_lock, flags); guard(spinlock_irqsave)(&xpad->odata_lock);
switch (xpad->xtype) { switch (xpad->xtype) {
case XTYPE_XBOX: case XTYPE_XBOX:
@ -1564,15 +1545,10 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
dev_dbg(&xpad->dev->dev, dev_dbg(&xpad->dev->dev,
"%s - rumble command sent to unsupported xpad type: %d\n", "%s - rumble command sent to unsupported xpad type: %d\n",
__func__, xpad->xtype); __func__, xpad->xtype);
retval = -EINVAL; return -EINVAL;
goto out;
} }
retval = xpad_try_sending_next_out_packet(xpad); return xpad_try_sending_next_out_packet(xpad);
out:
spin_unlock_irqrestore(&xpad->odata_lock, flags);
return retval;
} }
static int xpad_init_ff(struct usb_xpad *xpad) static int xpad_init_ff(struct usb_xpad *xpad)
@ -1625,11 +1601,10 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
{ {
struct xpad_output_packet *packet = struct xpad_output_packet *packet =
&xpad->out_packets[XPAD_OUT_LED_IDX]; &xpad->out_packets[XPAD_OUT_LED_IDX];
unsigned long flags;
command %= 16; command %= 16;
spin_lock_irqsave(&xpad->odata_lock, flags); guard(spinlock_irqsave)(&xpad->odata_lock);
switch (xpad->xtype) { switch (xpad->xtype) {
case XTYPE_XBOX360: case XTYPE_XBOX360:
@ -1659,8 +1634,6 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
} }
xpad_try_sending_next_out_packet(xpad); xpad_try_sending_next_out_packet(xpad);
spin_unlock_irqrestore(&xpad->odata_lock, flags);
} }
/* /*
@ -1785,11 +1758,10 @@ static void xpad_stop_input(struct usb_xpad *xpad)
static void xpad360w_poweroff_controller(struct usb_xpad *xpad) static void xpad360w_poweroff_controller(struct usb_xpad *xpad)
{ {
unsigned long flags;
struct xpad_output_packet *packet = struct xpad_output_packet *packet =
&xpad->out_packets[XPAD_OUT_CMD_IDX]; &xpad->out_packets[XPAD_OUT_CMD_IDX];
spin_lock_irqsave(&xpad->odata_lock, flags); guard(spinlock_irqsave)(&xpad->odata_lock);
packet->data[0] = 0x00; packet->data[0] = 0x00;
packet->data[1] = 0x00; packet->data[1] = 0x00;
@ -1809,8 +1781,6 @@ static void xpad360w_poweroff_controller(struct usb_xpad *xpad)
/* Reset the sequence so we send out poweroff now */ /* Reset the sequence so we send out poweroff now */
xpad->last_out_packet = -1; xpad->last_out_packet = -1;
xpad_try_sending_next_out_packet(xpad); xpad_try_sending_next_out_packet(xpad);
spin_unlock_irqrestore(&xpad->odata_lock, flags);
} }
static int xpad360w_start_input(struct usb_xpad *xpad) static int xpad360w_start_input(struct usb_xpad *xpad)
@ -2234,10 +2204,10 @@ static int xpad_suspend(struct usb_interface *intf, pm_message_t message)
if (auto_poweroff && xpad->pad_present) if (auto_poweroff && xpad->pad_present)
xpad360w_poweroff_controller(xpad); xpad360w_poweroff_controller(xpad);
} else { } else {
mutex_lock(&input->mutex); guard(mutex)(&input->mutex);
if (input_device_enabled(input)) if (input_device_enabled(input))
xpad_stop_input(xpad); xpad_stop_input(xpad);
mutex_unlock(&input->mutex);
} }
xpad_stop_output(xpad); xpad_stop_output(xpad);
@ -2249,26 +2219,25 @@ static int xpad_resume(struct usb_interface *intf)
{ {
struct usb_xpad *xpad = usb_get_intfdata(intf); struct usb_xpad *xpad = usb_get_intfdata(intf);
struct input_dev *input = xpad->dev; struct input_dev *input = xpad->dev;
int retval = 0;
if (xpad->xtype == XTYPE_XBOX360W) { if (xpad->xtype == XTYPE_XBOX360W)
retval = xpad360w_start_input(xpad); return xpad360w_start_input(xpad);
} else {
mutex_lock(&input->mutex); guard(mutex)(&input->mutex);
if (input_device_enabled(input)) {
retval = xpad_start_input(xpad); if (input_device_enabled(input))
} else if (xpad->xtype == XTYPE_XBOXONE) { return xpad_start_input(xpad);
/*
* Even if there are no users, we'll send Xbox One pads if (xpad->xtype == XTYPE_XBOXONE) {
* the startup sequence so they don't sit there and /*
* blink until somebody opens the input device again. * Even if there are no users, we'll send Xbox One pads
*/ * the startup sequence so they don't sit there and
retval = xpad_start_xbox_one(xpad); * blink until somebody opens the input device again.
} */
mutex_unlock(&input->mutex); return xpad_start_xbox_one(xpad);
} }
return retval; return 0;
} }
static struct usb_driver xpad_driver = { static struct usb_driver xpad_driver = {

View File

@ -181,7 +181,7 @@ static struct platform_driver adp5520_keys_driver = {
.name = "adp5520-keys", .name = "adp5520-keys",
}, },
.probe = adp5520_keys_probe, .probe = adp5520_keys_probe,
.remove_new = adp5520_keys_remove, .remove = adp5520_keys_remove,
}; };
module_platform_driver(adp5520_keys_driver); module_platform_driver(adp5520_keys_driver);

View File

@ -411,7 +411,7 @@ static void adp5589_gpio_set_value(struct gpio_chip *chip,
unsigned int bank = kpad->var->bank(kpad->gpiomap[off]); unsigned int bank = kpad->var->bank(kpad->gpiomap[off]);
unsigned int bit = kpad->var->bit(kpad->gpiomap[off]); unsigned int bit = kpad->var->bit(kpad->gpiomap[off]);
mutex_lock(&kpad->gpio_lock); guard(mutex)(&kpad->gpio_lock);
if (val) if (val)
kpad->dat_out[bank] |= bit; kpad->dat_out[bank] |= bit;
@ -420,8 +420,6 @@ static void adp5589_gpio_set_value(struct gpio_chip *chip,
adp5589_write(kpad->client, kpad->var->reg(ADP5589_GPO_DATA_OUT_A) + adp5589_write(kpad->client, kpad->var->reg(ADP5589_GPO_DATA_OUT_A) +
bank, kpad->dat_out[bank]); bank, kpad->dat_out[bank]);
mutex_unlock(&kpad->gpio_lock);
} }
static int adp5589_gpio_direction_input(struct gpio_chip *chip, unsigned off) static int adp5589_gpio_direction_input(struct gpio_chip *chip, unsigned off)
@ -429,18 +427,13 @@ static int adp5589_gpio_direction_input(struct gpio_chip *chip, unsigned off)
struct adp5589_kpad *kpad = gpiochip_get_data(chip); struct adp5589_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = kpad->var->bank(kpad->gpiomap[off]); unsigned int bank = kpad->var->bank(kpad->gpiomap[off]);
unsigned int bit = kpad->var->bit(kpad->gpiomap[off]); unsigned int bit = kpad->var->bit(kpad->gpiomap[off]);
int ret;
mutex_lock(&kpad->gpio_lock); guard(mutex)(&kpad->gpio_lock);
kpad->dir[bank] &= ~bit; kpad->dir[bank] &= ~bit;
ret = adp5589_write(kpad->client, return adp5589_write(kpad->client,
kpad->var->reg(ADP5589_GPIO_DIRECTION_A) + bank, kpad->var->reg(ADP5589_GPIO_DIRECTION_A) + bank,
kpad->dir[bank]); kpad->dir[bank]);
mutex_unlock(&kpad->gpio_lock);
return ret;
} }
static int adp5589_gpio_direction_output(struct gpio_chip *chip, static int adp5589_gpio_direction_output(struct gpio_chip *chip,
@ -449,9 +442,9 @@ static int adp5589_gpio_direction_output(struct gpio_chip *chip,
struct adp5589_kpad *kpad = gpiochip_get_data(chip); struct adp5589_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = kpad->var->bank(kpad->gpiomap[off]); unsigned int bank = kpad->var->bank(kpad->gpiomap[off]);
unsigned int bit = kpad->var->bit(kpad->gpiomap[off]); unsigned int bit = kpad->var->bit(kpad->gpiomap[off]);
int ret; int error;
mutex_lock(&kpad->gpio_lock); guard(mutex)(&kpad->gpio_lock);
kpad->dir[bank] |= bit; kpad->dir[bank] |= bit;
@ -460,15 +453,19 @@ static int adp5589_gpio_direction_output(struct gpio_chip *chip,
else else
kpad->dat_out[bank] &= ~bit; kpad->dat_out[bank] &= ~bit;
ret = adp5589_write(kpad->client, kpad->var->reg(ADP5589_GPO_DATA_OUT_A) error = adp5589_write(kpad->client,
+ bank, kpad->dat_out[bank]); kpad->var->reg(ADP5589_GPO_DATA_OUT_A) + bank,
ret |= adp5589_write(kpad->client, kpad->dat_out[bank]);
kpad->var->reg(ADP5589_GPIO_DIRECTION_A) + bank, if (error)
kpad->dir[bank]); return error;
mutex_unlock(&kpad->gpio_lock); error = adp5589_write(kpad->client,
kpad->var->reg(ADP5589_GPIO_DIRECTION_A) + bank,
kpad->dir[bank]);
if (error)
return error;
return ret; return 0;
} }
static int adp5589_build_gpiomap(struct adp5589_kpad *kpad, static int adp5589_build_gpiomap(struct adp5589_kpad *kpad,

View File

@ -717,9 +717,7 @@ static int applespi_send_cmd_msg(struct applespi_data *applespi);
static void applespi_msg_complete(struct applespi_data *applespi, static void applespi_msg_complete(struct applespi_data *applespi,
bool is_write_msg, bool is_read_compl) bool is_write_msg, bool is_read_compl)
{ {
unsigned long flags; guard(spinlock_irqsave)(&applespi->cmd_msg_lock);
spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
if (is_read_compl) if (is_read_compl)
applespi->read_active = false; applespi->read_active = false;
@ -733,8 +731,6 @@ static void applespi_msg_complete(struct applespi_data *applespi,
applespi->cmd_msg_queued = 0; applespi->cmd_msg_queued = 0;
applespi_send_cmd_msg(applespi); applespi_send_cmd_msg(applespi);
} }
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
} }
static void applespi_async_write_complete(void *context) static void applespi_async_write_complete(void *context)
@ -888,33 +884,22 @@ static int applespi_send_cmd_msg(struct applespi_data *applespi)
static void applespi_init(struct applespi_data *applespi, bool is_resume) static void applespi_init(struct applespi_data *applespi, bool is_resume)
{ {
unsigned long flags; guard(spinlock_irqsave)(&applespi->cmd_msg_lock);
spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
if (is_resume) if (is_resume)
applespi->want_mt_init_cmd = true; applespi->want_mt_init_cmd = true;
else else
applespi->want_tp_info_cmd = true; applespi->want_tp_info_cmd = true;
applespi_send_cmd_msg(applespi); applespi_send_cmd_msg(applespi);
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
} }
static int applespi_set_capsl_led(struct applespi_data *applespi, static int applespi_set_capsl_led(struct applespi_data *applespi,
bool capslock_on) bool capslock_on)
{ {
unsigned long flags; guard(spinlock_irqsave)(&applespi->cmd_msg_lock);
int sts;
spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
applespi->want_cl_led_on = capslock_on; applespi->want_cl_led_on = capslock_on;
sts = applespi_send_cmd_msg(applespi); return applespi_send_cmd_msg(applespi);
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
return sts;
} }
static void applespi_set_bl_level(struct led_classdev *led_cdev, static void applespi_set_bl_level(struct led_classdev *led_cdev,
@ -922,9 +907,8 @@ static void applespi_set_bl_level(struct led_classdev *led_cdev,
{ {
struct applespi_data *applespi = struct applespi_data *applespi =
container_of(led_cdev, struct applespi_data, backlight_info); container_of(led_cdev, struct applespi_data, backlight_info);
unsigned long flags;
spin_lock_irqsave(&applespi->cmd_msg_lock, flags); guard(spinlock_irqsave)(&applespi->cmd_msg_lock);
if (value == 0) { if (value == 0) {
applespi->want_bl_level = value; applespi->want_bl_level = value;
@ -940,8 +924,6 @@ static void applespi_set_bl_level(struct led_classdev *led_cdev,
} }
applespi_send_cmd_msg(applespi); applespi_send_cmd_msg(applespi);
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
} }
static int applespi_event(struct input_dev *dev, unsigned int type, static int applespi_event(struct input_dev *dev, unsigned int type,
@ -1427,9 +1409,7 @@ static void applespi_got_data(struct applespi_data *applespi)
/* process packet header */ /* process packet header */
if (!applespi_verify_crc(applespi, applespi->rx_buffer, if (!applespi_verify_crc(applespi, applespi->rx_buffer,
APPLESPI_PACKET_SIZE)) { APPLESPI_PACKET_SIZE)) {
unsigned long flags; guard(spinlock_irqsave)(&applespi->cmd_msg_lock);
spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
if (applespi->drain) { if (applespi->drain) {
applespi->read_active = false; applespi->read_active = false;
@ -1438,8 +1418,6 @@ static void applespi_got_data(struct applespi_data *applespi)
wake_up_all(&applespi->drain_complete); wake_up_all(&applespi->drain_complete);
} }
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
return; return;
} }
@ -1572,11 +1550,10 @@ static u32 applespi_notify(acpi_handle gpe_device, u32 gpe, void *context)
{ {
struct applespi_data *applespi = context; struct applespi_data *applespi = context;
int sts; int sts;
unsigned long flags;
trace_applespi_irq_received(ET_RD_IRQ, PT_READ); trace_applespi_irq_received(ET_RD_IRQ, PT_READ);
spin_lock_irqsave(&applespi->cmd_msg_lock, flags); guard(spinlock_irqsave)(&applespi->cmd_msg_lock);
if (!applespi->suspended) { if (!applespi->suspended) {
sts = applespi_async(applespi, &applespi->rd_m, sts = applespi_async(applespi, &applespi->rd_m,
@ -1589,8 +1566,6 @@ static u32 applespi_notify(acpi_handle gpe_device, u32 gpe, void *context)
applespi->read_active = true; applespi->read_active = true;
} }
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
return ACPI_INTERRUPT_HANDLED; return ACPI_INTERRUPT_HANDLED;
} }
@ -1818,29 +1793,21 @@ static int applespi_probe(struct spi_device *spi)
static void applespi_drain_writes(struct applespi_data *applespi) static void applespi_drain_writes(struct applespi_data *applespi)
{ {
unsigned long flags; guard(spinlock_irqsave)(&applespi->cmd_msg_lock);
spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
applespi->drain = true; applespi->drain = true;
wait_event_lock_irq(applespi->drain_complete, !applespi->write_active, wait_event_lock_irq(applespi->drain_complete, !applespi->write_active,
applespi->cmd_msg_lock); applespi->cmd_msg_lock);
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
} }
static void applespi_drain_reads(struct applespi_data *applespi) static void applespi_drain_reads(struct applespi_data *applespi)
{ {
unsigned long flags; guard(spinlock_irqsave)(&applespi->cmd_msg_lock);
spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
wait_event_lock_irq(applespi->drain_complete, !applespi->read_active, wait_event_lock_irq(applespi->drain_complete, !applespi->read_active,
applespi->cmd_msg_lock); applespi->cmd_msg_lock);
applespi->suspended = true; applespi->suspended = true;
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
} }
static void applespi_remove(struct spi_device *spi) static void applespi_remove(struct spi_device *spi)
@ -1907,21 +1874,18 @@ static int applespi_resume(struct device *dev)
struct spi_device *spi = to_spi_device(dev); struct spi_device *spi = to_spi_device(dev);
struct applespi_data *applespi = spi_get_drvdata(spi); struct applespi_data *applespi = spi_get_drvdata(spi);
acpi_status acpi_sts; acpi_status acpi_sts;
unsigned long flags;
/* ensure our flags and state reflect a newly resumed device */ /* ensure our flags and state reflect a newly resumed device */
spin_lock_irqsave(&applespi->cmd_msg_lock, flags); scoped_guard(spinlock_irqsave, &applespi->cmd_msg_lock) {
applespi->drain = false;
applespi->have_cl_led_on = false;
applespi->have_bl_level = 0;
applespi->cmd_msg_queued = 0;
applespi->read_active = false;
applespi->write_active = false;
applespi->drain = false; applespi->suspended = false;
applespi->have_cl_led_on = false; }
applespi->have_bl_level = 0;
applespi->cmd_msg_queued = 0;
applespi->read_active = false;
applespi->write_active = false;
applespi->suspended = false;
spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
/* switch on the SPI interface */ /* switch on the SPI interface */
applespi_enable_spi(applespi); applespi_enable_spi(applespi);

View File

@ -713,9 +713,9 @@ static int atkbd_event(struct input_dev *dev,
static inline void atkbd_enable(struct atkbd *atkbd) static inline void atkbd_enable(struct atkbd *atkbd)
{ {
serio_pause_rx(atkbd->ps2dev.serio); guard(serio_pause_rx)(atkbd->ps2dev.serio);
atkbd->enabled = true; atkbd->enabled = true;
serio_continue_rx(atkbd->ps2dev.serio);
} }
/* /*
@ -725,9 +725,9 @@ static inline void atkbd_enable(struct atkbd *atkbd)
static inline void atkbd_disable(struct atkbd *atkbd) static inline void atkbd_disable(struct atkbd *atkbd)
{ {
serio_pause_rx(atkbd->ps2dev.serio); guard(serio_pause_rx)(atkbd->ps2dev.serio);
atkbd->enabled = false; atkbd->enabled = false;
serio_continue_rx(atkbd->ps2dev.serio);
} }
static int atkbd_activate(struct atkbd *atkbd) static int atkbd_activate(struct atkbd *atkbd)

View File

@ -416,7 +416,7 @@ static int cap11xx_led_set(struct led_classdev *cdev,
static int cap11xx_init_leds(struct device *dev, static int cap11xx_init_leds(struct device *dev,
struct cap11xx_priv *priv, int num_leds) struct cap11xx_priv *priv, int num_leds)
{ {
struct device_node *node = dev->of_node, *child; struct device_node *node = dev->of_node;
struct cap11xx_led *led; struct cap11xx_led *led;
int cnt = of_get_child_count(node); int cnt = of_get_child_count(node);
int error; int error;
@ -445,7 +445,7 @@ static int cap11xx_init_leds(struct device *dev,
if (error) if (error)
return error; return error;
for_each_child_of_node(node, child) { for_each_child_of_node_scoped(node, child) {
u32 reg; u32 reg;
led->cdev.name = led->cdev.name =
@ -458,19 +458,15 @@ static int cap11xx_init_leds(struct device *dev,
led->cdev.brightness = LED_OFF; led->cdev.brightness = LED_OFF;
error = of_property_read_u32(child, "reg", &reg); error = of_property_read_u32(child, "reg", &reg);
if (error != 0 || reg >= num_leds) { if (error != 0 || reg >= num_leds)
of_node_put(child);
return -EINVAL; return -EINVAL;
}
led->reg = reg; led->reg = reg;
led->priv = priv; led->priv = priv;
error = devm_led_classdev_register(dev, &led->cdev); error = devm_led_classdev_register(dev, &led->cdev);
if (error) { if (error)
of_node_put(child);
return error; return error;
}
priv->num_leds++; priv->num_leds++;
led++; led++;

View File

@ -770,7 +770,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(cros_ec_keyb_pm_ops, NULL, cros_ec_keyb_resume);
static struct platform_driver cros_ec_keyb_driver = { static struct platform_driver cros_ec_keyb_driver = {
.probe = cros_ec_keyb_probe, .probe = cros_ec_keyb_probe,
.remove_new = cros_ec_keyb_remove, .remove = cros_ec_keyb_remove,
.driver = { .driver = {
.name = "cros-ec-keyb", .name = "cros-ec-keyb",
.dev_groups = cros_ec_keyb_groups, .dev_groups = cros_ec_keyb_groups,

View File

@ -208,7 +208,7 @@ static int cypress_sf_resume(struct device *dev)
static DEFINE_SIMPLE_DEV_PM_OPS(cypress_sf_pm_ops, static DEFINE_SIMPLE_DEV_PM_OPS(cypress_sf_pm_ops,
cypress_sf_suspend, cypress_sf_resume); cypress_sf_suspend, cypress_sf_resume);
static struct i2c_device_id cypress_sf_id_table[] = { static const struct i2c_device_id cypress_sf_id_table[] = {
{ CYPRESS_SF_DEV_NAME }, { CYPRESS_SF_DEV_NAME },
{ } { }
}; };

View File

@ -168,15 +168,13 @@ static int ep93xx_keypad_suspend(struct device *dev)
struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
struct input_dev *input_dev = keypad->input_dev; struct input_dev *input_dev = keypad->input_dev;
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (keypad->enabled) { if (keypad->enabled) {
clk_disable(keypad->clk); clk_disable(keypad->clk);
keypad->enabled = false; keypad->enabled = false;
} }
mutex_unlock(&input_dev->mutex);
return 0; return 0;
} }
@ -186,7 +184,7 @@ static int ep93xx_keypad_resume(struct device *dev)
struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
struct input_dev *input_dev = keypad->input_dev; struct input_dev *input_dev = keypad->input_dev;
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev)) { if (input_device_enabled(input_dev)) {
if (!keypad->enabled) { if (!keypad->enabled) {
@ -196,8 +194,6 @@ static int ep93xx_keypad_resume(struct device *dev)
} }
} }
mutex_unlock(&input_dev->mutex);
return 0; return 0;
} }
@ -289,7 +285,7 @@ static struct platform_driver ep93xx_keypad_driver = {
.of_match_table = ep93xx_keypad_of_ids, .of_match_table = ep93xx_keypad_of_ids,
}, },
.probe = ep93xx_keypad_probe, .probe = ep93xx_keypad_probe,
.remove_new = ep93xx_keypad_remove, .remove = ep93xx_keypad_remove,
}; };
module_platform_driver(ep93xx_keypad_driver); module_platform_driver(ep93xx_keypad_driver);

View File

@ -180,9 +180,8 @@ static irqreturn_t hil_interrupt(int irq, void *handle)
/* send a command to the HIL */ /* send a command to the HIL */
static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len) static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len)
{ {
unsigned long flags; guard(spinlock_irqsave)(&hil_dev.lock);
spin_lock_irqsave(&hil_dev.lock, flags);
while (hil_busy()) while (hil_busy())
/* wait */; /* wait */;
hil_command(cmd); hil_command(cmd);
@ -191,7 +190,6 @@ static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len)
/* wait */; /* wait */;
hil_write_data(*(data++)); hil_write_data(*(data++));
} }
spin_unlock_irqrestore(&hil_dev.lock, flags);
} }

View File

@ -521,13 +521,11 @@ static int __maybe_unused imx_kbd_noirq_suspend(struct device *dev)
struct input_dev *input_dev = kbd->input_dev; struct input_dev *input_dev = kbd->input_dev;
unsigned short reg_val = readw(kbd->mmio_base + KPSR); unsigned short reg_val = readw(kbd->mmio_base + KPSR);
/* imx kbd can wake up system even clock is disabled */ scoped_guard(mutex, &input_dev->mutex) {
mutex_lock(&input_dev->mutex); /* imx kbd can wake up system even clock is disabled */
if (input_device_enabled(input_dev))
if (input_device_enabled(input_dev)) clk_disable_unprepare(kbd->clk);
clk_disable_unprepare(kbd->clk); }
mutex_unlock(&input_dev->mutex);
if (device_may_wakeup(&pdev->dev)) { if (device_may_wakeup(&pdev->dev)) {
if (reg_val & KBD_STAT_KPKD) if (reg_val & KBD_STAT_KPKD)
@ -547,23 +545,20 @@ static int __maybe_unused imx_kbd_noirq_resume(struct device *dev)
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct imx_keypad *kbd = platform_get_drvdata(pdev); struct imx_keypad *kbd = platform_get_drvdata(pdev);
struct input_dev *input_dev = kbd->input_dev; struct input_dev *input_dev = kbd->input_dev;
int ret = 0; int error;
if (device_may_wakeup(&pdev->dev)) if (device_may_wakeup(&pdev->dev))
disable_irq_wake(kbd->irq); disable_irq_wake(kbd->irq);
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev)) { if (input_device_enabled(input_dev)) {
ret = clk_prepare_enable(kbd->clk); error = clk_prepare_enable(kbd->clk);
if (ret) if (error)
goto err_clk; return error;
} }
err_clk: return 0;
mutex_unlock(&input_dev->mutex);
return ret;
} }
static const struct dev_pm_ops imx_kbd_pm_ops = { static const struct dev_pm_ops imx_kbd_pm_ops = {

View File

@ -54,18 +54,18 @@ static void micro_key_receive(void *data, int len, unsigned char *msg)
static void micro_key_start(struct ipaq_micro_keys *keys) static void micro_key_start(struct ipaq_micro_keys *keys)
{ {
spin_lock(&keys->micro->lock); guard(spinlock)(&keys->micro->lock);
keys->micro->key = micro_key_receive; keys->micro->key = micro_key_receive;
keys->micro->key_data = keys; keys->micro->key_data = keys;
spin_unlock(&keys->micro->lock);
} }
static void micro_key_stop(struct ipaq_micro_keys *keys) static void micro_key_stop(struct ipaq_micro_keys *keys)
{ {
spin_lock(&keys->micro->lock); guard(spinlock)(&keys->micro->lock);
keys->micro->key = NULL; keys->micro->key = NULL;
keys->micro->key_data = NULL; keys->micro->key_data = NULL;
spin_unlock(&keys->micro->lock);
} }
static int micro_key_open(struct input_dev *input) static int micro_key_open(struct input_dev *input)
@ -141,13 +141,11 @@ static int micro_key_resume(struct device *dev)
struct ipaq_micro_keys *keys = dev_get_drvdata(dev); struct ipaq_micro_keys *keys = dev_get_drvdata(dev);
struct input_dev *input = keys->input; struct input_dev *input = keys->input;
mutex_lock(&input->mutex); guard(mutex)(&input->mutex);
if (input_device_enabled(input)) if (input_device_enabled(input))
micro_key_start(keys); micro_key_start(keys);
mutex_unlock(&input->mutex);
return 0; return 0;
} }

View File

@ -323,7 +323,7 @@ static struct platform_driver iqs62x_keys_platform_driver = {
.name = "iqs62x-keys", .name = "iqs62x-keys",
}, },
.probe = iqs62x_keys_probe, .probe = iqs62x_keys_probe,
.remove_new = iqs62x_keys_remove, .remove = iqs62x_keys_remove,
}; };
module_platform_driver(iqs62x_keys_platform_driver); module_platform_driver(iqs62x_keys_platform_driver);

View File

@ -350,11 +350,11 @@ static int lm8323_configure(struct lm8323_chip *lm)
static void pwm_done(struct lm8323_pwm *pwm) static void pwm_done(struct lm8323_pwm *pwm)
{ {
mutex_lock(&pwm->lock); guard(mutex)(&pwm->lock);
pwm->running = false; pwm->running = false;
if (pwm->desired_brightness != pwm->brightness) if (pwm->desired_brightness != pwm->brightness)
schedule_work(&pwm->work); schedule_work(&pwm->work);
mutex_unlock(&pwm->lock);
} }
/* /*
@ -367,7 +367,7 @@ static irqreturn_t lm8323_irq(int irq, void *_lm)
u8 ints; u8 ints;
int i; int i;
mutex_lock(&lm->lock); guard(mutex)(&lm->lock);
while ((lm8323_read(lm, LM8323_CMD_READ_INT, &ints, 1) == 1) && ints) { while ((lm8323_read(lm, LM8323_CMD_READ_INT, &ints, 1) == 1) && ints) {
if (likely(ints & INT_KEYPAD)) if (likely(ints & INT_KEYPAD))
@ -394,8 +394,6 @@ static irqreturn_t lm8323_irq(int irq, void *_lm)
} }
} }
mutex_unlock(&lm->lock);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
@ -445,7 +443,7 @@ static void lm8323_pwm_work(struct work_struct *work)
u16 pwm_cmds[3]; u16 pwm_cmds[3];
int num_cmds = 0; int num_cmds = 0;
mutex_lock(&pwm->lock); guard(mutex)(&pwm->lock);
/* /*
* Do nothing if we're already at the requested level, * Do nothing if we're already at the requested level,
@ -454,7 +452,7 @@ static void lm8323_pwm_work(struct work_struct *work)
* finishes. * finishes.
*/ */
if (pwm->running || pwm->desired_brightness == pwm->brightness) if (pwm->running || pwm->desired_brightness == pwm->brightness)
goto out; return;
kill = (pwm->desired_brightness == 0); kill = (pwm->desired_brightness == 0);
up = (pwm->desired_brightness > pwm->brightness); up = (pwm->desired_brightness > pwm->brightness);
@ -489,9 +487,6 @@ static void lm8323_pwm_work(struct work_struct *work)
lm8323_write_pwm(pwm, kill, num_cmds, pwm_cmds); lm8323_write_pwm(pwm, kill, num_cmds, pwm_cmds);
pwm->brightness = pwm->desired_brightness; pwm->brightness = pwm->desired_brightness;
out:
mutex_unlock(&pwm->lock);
} }
static void lm8323_pwm_set_brightness(struct led_classdev *led_cdev, static void lm8323_pwm_set_brightness(struct led_classdev *led_cdev,
@ -500,9 +495,9 @@ static void lm8323_pwm_set_brightness(struct led_classdev *led_cdev,
struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev); struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
struct lm8323_chip *lm = pwm->chip; struct lm8323_chip *lm = pwm->chip;
mutex_lock(&pwm->lock); scoped_guard(mutex, &pwm->lock) {
pwm->desired_brightness = brightness; pwm->desired_brightness = brightness;
mutex_unlock(&pwm->lock); }
if (in_interrupt()) { if (in_interrupt()) {
schedule_work(&pwm->work); schedule_work(&pwm->work);
@ -510,12 +505,12 @@ static void lm8323_pwm_set_brightness(struct led_classdev *led_cdev,
/* /*
* Schedule PWM work as usual unless we are going into suspend * Schedule PWM work as usual unless we are going into suspend
*/ */
mutex_lock(&lm->lock); scoped_guard(mutex, &lm->lock) {
if (likely(!lm->pm_suspend)) if (likely(!lm->pm_suspend))
schedule_work(&pwm->work); schedule_work(&pwm->work);
else else
lm8323_pwm_work(&pwm->work); lm8323_pwm_work(&pwm->work);
mutex_unlock(&lm->lock); }
} }
} }
@ -608,9 +603,9 @@ static ssize_t lm8323_set_disable(struct device *dev,
if (ret) if (ret)
return ret; return ret;
mutex_lock(&lm->lock); guard(mutex)(&lm->lock);
lm->kp_enabled = !i; lm->kp_enabled = !i;
mutex_unlock(&lm->lock);
return count; return count;
} }
@ -758,9 +753,9 @@ static int lm8323_suspend(struct device *dev)
irq_set_irq_wake(client->irq, 0); irq_set_irq_wake(client->irq, 0);
disable_irq(client->irq); disable_irq(client->irq);
mutex_lock(&lm->lock); scoped_guard(mutex, &lm->lock) {
lm->pm_suspend = true; lm->pm_suspend = true;
mutex_unlock(&lm->lock); }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (lm->pwm[i].enabled) if (lm->pwm[i].enabled)
@ -775,9 +770,9 @@ static int lm8323_resume(struct device *dev)
struct lm8323_chip *lm = i2c_get_clientdata(client); struct lm8323_chip *lm = i2c_get_clientdata(client);
int i; int i;
mutex_lock(&lm->lock); scoped_guard(mutex, &lm->lock) {
lm->pm_suspend = false; lm->pm_suspend = false;
mutex_unlock(&lm->lock); }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (lm->pwm[i].enabled) if (lm->pwm[i].enabled)

View File

@ -112,11 +112,10 @@ static inline void locomokbd_reset_col(unsigned long membase, int col)
static void locomokbd_scankeyboard(struct locomokbd *locomokbd) static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
{ {
unsigned int row, col, rowd; unsigned int row, col, rowd;
unsigned long flags;
unsigned int num_pressed; unsigned int num_pressed;
unsigned long membase = locomokbd->base; unsigned long membase = locomokbd->base;
spin_lock_irqsave(&locomokbd->lock, flags); guard(spinlock_irqsave)(&locomokbd->lock);
locomokbd_charge_all(membase); locomokbd_charge_all(membase);
@ -167,8 +166,6 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL); mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL);
else else
locomokbd->count_cancel = 0; locomokbd->count_cancel = 0;
spin_unlock_irqrestore(&locomokbd->lock, flags);
} }
/* /*

View File

@ -262,7 +262,7 @@ static int lpc32xx_kscan_suspend(struct device *dev)
struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev); struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
struct input_dev *input = kscandat->input; struct input_dev *input = kscandat->input;
mutex_lock(&input->mutex); guard(mutex)(&input->mutex);
if (input_device_enabled(input)) { if (input_device_enabled(input)) {
/* Clear IRQ and disable clock */ /* Clear IRQ and disable clock */
@ -270,7 +270,6 @@ static int lpc32xx_kscan_suspend(struct device *dev)
clk_disable_unprepare(kscandat->clk); clk_disable_unprepare(kscandat->clk);
} }
mutex_unlock(&input->mutex);
return 0; return 0;
} }
@ -279,19 +278,20 @@ static int lpc32xx_kscan_resume(struct device *dev)
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev); struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
struct input_dev *input = kscandat->input; struct input_dev *input = kscandat->input;
int retval = 0; int error;
mutex_lock(&input->mutex); guard(mutex)(&input->mutex);
if (input_device_enabled(input)) { if (input_device_enabled(input)) {
/* Enable clock and clear IRQ */ /* Enable clock and clear IRQ */
retval = clk_prepare_enable(kscandat->clk); error = clk_prepare_enable(kscandat->clk);
if (retval == 0) if (error)
writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); return error;
writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base));
} }
mutex_unlock(&input->mutex); return 0;
return retval;
} }
static DEFINE_SIMPLE_DEV_PM_OPS(lpc32xx_kscan_pm_ops, lpc32xx_kscan_suspend, static DEFINE_SIMPLE_DEV_PM_OPS(lpc32xx_kscan_pm_ops, lpc32xx_kscan_suspend,

View File

@ -132,14 +132,11 @@ static void dc_kbd_callback(struct mapleq *mq)
* We should always get the lock because the only * We should always get the lock because the only
* time it may be locked is if the driver is in the cleanup phase. * time it may be locked is if the driver is in the cleanup phase.
*/ */
if (likely(mutex_trylock(&maple_keyb_mutex))) { scoped_guard(mutex_try, &maple_keyb_mutex) {
if (buf[1] == mapledev->function) { if (buf[1] == mapledev->function) {
memcpy(kbd->new, buf + 2, 8); memcpy(kbd->new, buf + 2, 8);
dc_scan_kbd(kbd); dc_scan_kbd(kbd);
} }
mutex_unlock(&maple_keyb_mutex);
} }
} }
@ -211,14 +208,12 @@ static int remove_maple_kbd(struct device *dev)
struct maple_device *mdev = to_maple_dev(dev); struct maple_device *mdev = to_maple_dev(dev);
struct dc_kbd *kbd = maple_get_drvdata(mdev); struct dc_kbd *kbd = maple_get_drvdata(mdev);
mutex_lock(&maple_keyb_mutex); guard(mutex)(&maple_keyb_mutex);
input_unregister_device(kbd->dev); input_unregister_device(kbd->dev);
kfree(kbd); kfree(kbd);
maple_set_drvdata(mdev, NULL); maple_set_drvdata(mdev, NULL);
mutex_unlock(&maple_keyb_mutex);
return 0; return 0;
} }

View File

@ -17,7 +17,6 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/input/matrix_keypad.h> #include <linux/input/matrix_keypad.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of.h> #include <linux/of.h>
@ -158,18 +157,17 @@ static void matrix_keypad_scan(struct work_struct *work)
activate_all_cols(keypad, true); activate_all_cols(keypad, true);
/* Enable IRQs again */ /* Enable IRQs again */
spin_lock_irq(&keypad->lock); scoped_guard(spinlock_irq, &keypad->lock) {
keypad->scan_pending = false; keypad->scan_pending = false;
enable_row_irqs(keypad); enable_row_irqs(keypad);
spin_unlock_irq(&keypad->lock); }
} }
static irqreturn_t matrix_keypad_interrupt(int irq, void *id) static irqreturn_t matrix_keypad_interrupt(int irq, void *id)
{ {
struct matrix_keypad *keypad = id; struct matrix_keypad *keypad = id;
unsigned long flags;
spin_lock_irqsave(&keypad->lock, flags); guard(spinlock_irqsave)(&keypad->lock);
/* /*
* See if another IRQ beaten us to it and scheduled the * See if another IRQ beaten us to it and scheduled the
@ -185,7 +183,6 @@ static irqreturn_t matrix_keypad_interrupt(int irq, void *id)
msecs_to_jiffies(keypad->debounce_ms)); msecs_to_jiffies(keypad->debounce_ms));
out: out:
spin_unlock_irqrestore(&keypad->lock, flags);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
@ -209,9 +206,9 @@ static void matrix_keypad_stop(struct input_dev *dev)
{ {
struct matrix_keypad *keypad = input_get_drvdata(dev); struct matrix_keypad *keypad = input_get_drvdata(dev);
spin_lock_irq(&keypad->lock); scoped_guard(spinlock_irq, &keypad->lock) {
keypad->stopped = true; keypad->stopped = true;
spin_unlock_irq(&keypad->lock); }
flush_delayed_work(&keypad->work); flush_delayed_work(&keypad->work);
/* /*

View File

@ -82,42 +82,6 @@ static const struct mpr121_init_register init_reg_table[] = {
{ AUTO_CONFIG_CTRL_ADDR, 0x0b }, { AUTO_CONFIG_CTRL_ADDR, 0x0b },
}; };
static void mpr121_vdd_supply_disable(void *data)
{
struct regulator *vdd_supply = data;
regulator_disable(vdd_supply);
}
static struct regulator *mpr121_vdd_supply_init(struct device *dev)
{
struct regulator *vdd_supply;
int err;
vdd_supply = devm_regulator_get(dev, "vdd");
if (IS_ERR(vdd_supply)) {
dev_err(dev, "failed to get vdd regulator: %ld\n",
PTR_ERR(vdd_supply));
return vdd_supply;
}
err = regulator_enable(vdd_supply);
if (err) {
dev_err(dev, "failed to enable vdd regulator: %d\n", err);
return ERR_PTR(err);
}
err = devm_add_action_or_reset(dev, mpr121_vdd_supply_disable,
vdd_supply);
if (err) {
dev_err(dev, "failed to add disable regulator action: %d\n",
err);
return ERR_PTR(err);
}
return vdd_supply;
}
static void mpr_touchkey_report(struct input_dev *dev) static void mpr_touchkey_report(struct input_dev *dev)
{ {
struct mpr121_touchkey *mpr121 = input_get_drvdata(dev); struct mpr121_touchkey *mpr121 = input_get_drvdata(dev);
@ -233,7 +197,6 @@ err_i2c_write:
static int mpr_touchkey_probe(struct i2c_client *client) static int mpr_touchkey_probe(struct i2c_client *client)
{ {
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct regulator *vdd_supply;
int vdd_uv; int vdd_uv;
struct mpr121_touchkey *mpr121; struct mpr121_touchkey *mpr121;
struct input_dev *input_dev; struct input_dev *input_dev;
@ -241,11 +204,9 @@ static int mpr_touchkey_probe(struct i2c_client *client)
int error; int error;
int i; int i;
vdd_supply = mpr121_vdd_supply_init(dev); vdd_uv = devm_regulator_get_enable_read_voltage(dev, "vdd");
if (IS_ERR(vdd_supply)) if (vdd_uv < 0)
return PTR_ERR(vdd_supply); return dev_err_probe(dev, vdd_uv, "failed to get vdd voltage\n");
vdd_uv = regulator_get_voltage(vdd_supply);
mpr121 = devm_kzalloc(dev, sizeof(*mpr121), GFP_KERNEL); mpr121 = devm_kzalloc(dev, sizeof(*mpr121), GFP_KERNEL);
if (!mpr121) if (!mpr121)

View File

@ -307,7 +307,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
int error, index = 0; int error, index = 0;
unsigned int keycount; unsigned int keycount;
struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent); struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent);
struct device_node *node = pdev->dev.of_node, *child; struct device_node *node = pdev->dev.of_node;
static const char *const irqnames[] = { "powerkey", "homekey" }; static const char *const irqnames[] = { "powerkey", "homekey" };
static const char *const irqnames_r[] = { "powerkey_r", "homekey_r" }; static const char *const irqnames_r[] = { "powerkey_r", "homekey_r" };
struct mtk_pmic_keys *keys; struct mtk_pmic_keys *keys;
@ -343,24 +343,20 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
for_each_child_of_node(node, child) { for_each_child_of_node_scoped(node, child) {
keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index]; keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index];
keys->keys[index].irq = keys->keys[index].irq =
platform_get_irq_byname(pdev, irqnames[index]); platform_get_irq_byname(pdev, irqnames[index]);
if (keys->keys[index].irq < 0) { if (keys->keys[index].irq < 0)
of_node_put(child);
return keys->keys[index].irq; return keys->keys[index].irq;
}
if (of_device_is_compatible(node, "mediatek,mt6358-keys")) { if (of_device_is_compatible(node, "mediatek,mt6358-keys")) {
keys->keys[index].irq_r = platform_get_irq_byname(pdev, keys->keys[index].irq_r = platform_get_irq_byname(pdev,
irqnames_r[index]); irqnames_r[index]);
if (keys->keys[index].irq_r < 0) { if (keys->keys[index].irq_r < 0)
of_node_put(child);
return keys->keys[index].irq_r; return keys->keys[index].irq_r;
}
} }
error = of_property_read_u32(child, error = of_property_read_u32(child,
@ -369,7 +365,6 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
dev_err(keys->dev, dev_err(keys->dev,
"failed to read key:%d linux,keycode property: %d\n", "failed to read key:%d linux,keycode property: %d\n",
index, error); index, error);
of_node_put(child);
return error; return error;
} }
@ -377,10 +372,8 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
keys->keys[index].wakeup = true; keys->keys[index].wakeup = true;
error = mtk_pmic_key_setup(keys, &keys->keys[index]); error = mtk_pmic_key_setup(keys, &keys->keys[index]);
if (error) { if (error)
of_node_put(child);
return error; return error;
}
index++; index++;
} }

View File

@ -156,15 +156,15 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
if ((state != 1) && (state != 0)) if ((state != 1) && (state != 0))
return -EINVAL; return -EINVAL;
mutex_lock(&kp_enable_mutex); scoped_guard(mutex, &kp_enable_mutex) {
if (state != kp_enable) { if (state != kp_enable) {
if (state) if (state)
enable_irq(omap_kp->irq); enable_irq(omap_kp->irq);
else else
disable_irq(omap_kp->irq); disable_irq(omap_kp->irq);
kp_enable = state; kp_enable = state;
}
} }
mutex_unlock(&kp_enable_mutex);
return strnlen(buf, count); return strnlen(buf, count);
} }
@ -290,7 +290,7 @@ static void omap_kp_remove(struct platform_device *pdev)
static struct platform_driver omap_kp_driver = { static struct platform_driver omap_kp_driver = {
.probe = omap_kp_probe, .probe = omap_kp_probe,
.remove_new = omap_kp_remove, .remove = omap_kp_remove,
.driver = { .driver = {
.name = "omap-keypad", .name = "omap-keypad",
.dev_groups = omap_kp_groups, .dev_groups = omap_kp_groups,

View File

@ -144,7 +144,7 @@ static void omap4_keypad_scan_keys(struct omap4_keypad *keypad_data, u64 keys)
{ {
u64 changed; u64 changed;
mutex_lock(&keypad_data->lock); guard(mutex)(&keypad_data->lock);
changed = keys ^ keypad_data->keys; changed = keys ^ keypad_data->keys;
@ -158,8 +158,6 @@ static void omap4_keypad_scan_keys(struct omap4_keypad *keypad_data, u64 keys)
omap4_keypad_report_keys(keypad_data, changed & keys, true); omap4_keypad_report_keys(keypad_data, changed & keys, true);
keypad_data->keys = keys; keypad_data->keys = keys;
mutex_unlock(&keypad_data->lock);
} }
/* Interrupt handlers */ /* Interrupt handlers */
@ -487,7 +485,7 @@ MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
static struct platform_driver omap4_keypad_driver = { static struct platform_driver omap4_keypad_driver = {
.probe = omap4_keypad_probe, .probe = omap4_keypad_probe,
.remove_new = omap4_keypad_remove, .remove = omap4_keypad_remove,
.driver = { .driver = {
.name = "omap4-keypad", .name = "omap4-keypad",
.of_match_table = omap_keypad_dt_match, .of_match_table = omap_keypad_dt_match,

View File

@ -630,12 +630,10 @@ static int pmic8xxx_kp_suspend(struct device *dev)
if (device_may_wakeup(dev)) { if (device_may_wakeup(dev)) {
enable_irq_wake(kp->key_sense_irq); enable_irq_wake(kp->key_sense_irq);
} else { } else {
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev)) if (input_device_enabled(input_dev))
pmic8xxx_kp_disable(kp); pmic8xxx_kp_disable(kp);
mutex_unlock(&input_dev->mutex);
} }
return 0; return 0;
@ -650,12 +648,10 @@ static int pmic8xxx_kp_resume(struct device *dev)
if (device_may_wakeup(dev)) { if (device_may_wakeup(dev)) {
disable_irq_wake(kp->key_sense_irq); disable_irq_wake(kp->key_sense_irq);
} else { } else {
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev)) if (input_device_enabled(input_dev))
pmic8xxx_kp_enable(kp); pmic8xxx_kp_enable(kp);
mutex_unlock(&input_dev->mutex);
} }
return 0; return 0;

View File

@ -682,7 +682,7 @@ static int pxa27x_keypad_resume(struct device *dev)
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
struct input_dev *input_dev = keypad->input_dev; struct input_dev *input_dev = keypad->input_dev;
int ret = 0; int error;
/* /*
* If the keypad is used as wake up source, the clock is not turned * If the keypad is used as wake up source, the clock is not turned
@ -691,19 +691,19 @@ static int pxa27x_keypad_resume(struct device *dev)
if (device_may_wakeup(&pdev->dev)) { if (device_may_wakeup(&pdev->dev)) {
disable_irq_wake(keypad->irq); disable_irq_wake(keypad->irq);
} else { } else {
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev)) { if (input_device_enabled(input_dev)) {
/* Enable unit clock */ /* Enable unit clock */
ret = clk_prepare_enable(keypad->clk); error = clk_prepare_enable(keypad->clk);
if (!ret) if (error)
pxa27x_keypad_config(keypad); return error;
}
mutex_unlock(&input_dev->mutex); pxa27x_keypad_config(keypad);
}
} }
return ret; return 0;
} }
static DEFINE_SIMPLE_DEV_PM_OPS(pxa27x_keypad_pm_ops, static DEFINE_SIMPLE_DEV_PM_OPS(pxa27x_keypad_pm_ops,

View File

@ -587,7 +587,7 @@ MODULE_DEVICE_TABLE(platform, samsung_keypad_driver_ids);
static struct platform_driver samsung_keypad_driver = { static struct platform_driver samsung_keypad_driver = {
.probe = samsung_keypad_probe, .probe = samsung_keypad_probe,
.remove_new = samsung_keypad_remove, .remove = samsung_keypad_remove,
.driver = { .driver = {
.name = "samsung-keypad", .name = "samsung-keypad",
.of_match_table = of_match_ptr(samsung_keypad_dt_match), .of_match_table = of_match_ptr(samsung_keypad_dt_match),

View File

@ -319,7 +319,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(sh_keysc_dev_pm_ops,
static struct platform_driver sh_keysc_device_driver = { static struct platform_driver sh_keysc_device_driver = {
.probe = sh_keysc_probe, .probe = sh_keysc_probe,
.remove_new = sh_keysc_remove, .remove = sh_keysc_remove,
.driver = { .driver = {
.name = "sh_keysc", .name = "sh_keysc",
.pm = pm_sleep_ptr(&sh_keysc_dev_pm_ops), .pm = pm_sleep_ptr(&sh_keysc_dev_pm_ops),

View File

@ -20,7 +20,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_wakeup.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/platform_data/keyboard-spear.h> #include <linux/platform_data/keyboard-spear.h>
@ -274,7 +273,7 @@ static int spear_kbd_suspend(struct device *dev)
struct input_dev *input_dev = kbd->input; struct input_dev *input_dev = kbd->input;
unsigned int rate = 0, mode_ctl_reg, val; unsigned int rate = 0, mode_ctl_reg, val;
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
/* explicitly enable clock as we may program device */ /* explicitly enable clock as we may program device */
clk_enable(kbd->clk); clk_enable(kbd->clk);
@ -315,8 +314,6 @@ static int spear_kbd_suspend(struct device *dev)
/* restore previous clk state */ /* restore previous clk state */
clk_disable(kbd->clk); clk_disable(kbd->clk);
mutex_unlock(&input_dev->mutex);
return 0; return 0;
} }
@ -326,7 +323,7 @@ static int spear_kbd_resume(struct device *dev)
struct spear_kbd *kbd = platform_get_drvdata(pdev); struct spear_kbd *kbd = platform_get_drvdata(pdev);
struct input_dev *input_dev = kbd->input; struct input_dev *input_dev = kbd->input;
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (device_may_wakeup(&pdev->dev)) { if (device_may_wakeup(&pdev->dev)) {
if (kbd->irq_wake_enabled) { if (kbd->irq_wake_enabled) {
@ -342,8 +339,6 @@ static int spear_kbd_resume(struct device *dev)
if (input_device_enabled(input_dev)) if (input_device_enabled(input_dev))
writel_relaxed(kbd->mode_ctl_reg, kbd->io_base + MODE_CTL_REG); writel_relaxed(kbd->mode_ctl_reg, kbd->io_base + MODE_CTL_REG);
mutex_unlock(&input_dev->mutex);
return 0; return 0;
} }

View File

@ -216,14 +216,13 @@ static int keyscan_suspend(struct device *dev)
struct st_keyscan *keypad = platform_get_drvdata(pdev); struct st_keyscan *keypad = platform_get_drvdata(pdev);
struct input_dev *input = keypad->input_dev; struct input_dev *input = keypad->input_dev;
mutex_lock(&input->mutex); guard(mutex)(&input->mutex);
if (device_may_wakeup(dev)) if (device_may_wakeup(dev))
enable_irq_wake(keypad->irq); enable_irq_wake(keypad->irq);
else if (input_device_enabled(input)) else if (input_device_enabled(input))
keyscan_stop(keypad); keyscan_stop(keypad);
mutex_unlock(&input->mutex);
return 0; return 0;
} }
@ -232,17 +231,19 @@ static int keyscan_resume(struct device *dev)
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct st_keyscan *keypad = platform_get_drvdata(pdev); struct st_keyscan *keypad = platform_get_drvdata(pdev);
struct input_dev *input = keypad->input_dev; struct input_dev *input = keypad->input_dev;
int retval = 0; int error;
mutex_lock(&input->mutex); guard(mutex)(&input->mutex);
if (device_may_wakeup(dev)) if (device_may_wakeup(dev)) {
disable_irq_wake(keypad->irq); disable_irq_wake(keypad->irq);
else if (input_device_enabled(input)) } else if (input_device_enabled(input)) {
retval = keyscan_start(keypad); error = keyscan_start(keypad);
if (error)
return error;
}
mutex_unlock(&input->mutex); return 0;
return retval;
} }
static DEFINE_SIMPLE_DEV_PM_OPS(keyscan_dev_pm_ops, static DEFINE_SIMPLE_DEV_PM_OPS(keyscan_dev_pm_ops,

View File

@ -414,7 +414,7 @@ static void stmpe_keypad_remove(struct platform_device *pdev)
static struct platform_driver stmpe_keypad_driver = { static struct platform_driver stmpe_keypad_driver = {
.driver.name = "stmpe-keypad", .driver.name = "stmpe-keypad",
.probe = stmpe_keypad_probe, .probe = stmpe_keypad_probe,
.remove_new = stmpe_keypad_remove, .remove = stmpe_keypad_remove,
}; };
module_platform_driver(stmpe_keypad_driver); module_platform_driver(stmpe_keypad_driver);

View File

@ -24,7 +24,6 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_wakeirq.h> #include <linux/pm_wakeirq.h>
#include <linux/pm_wakeup.h>
#include <linux/property.h> #include <linux/property.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/reset.h> #include <linux/reset.h>
@ -202,7 +201,7 @@ static void sun4i_lradc_close(struct input_dev *dev)
static int sun4i_lradc_load_dt_keymap(struct device *dev, static int sun4i_lradc_load_dt_keymap(struct device *dev,
struct sun4i_lradc_data *lradc) struct sun4i_lradc_data *lradc)
{ {
struct device_node *np, *pp; struct device_node *np;
int i; int i;
int error; int error;
@ -223,28 +222,25 @@ static int sun4i_lradc_load_dt_keymap(struct device *dev,
return -ENOMEM; return -ENOMEM;
i = 0; i = 0;
for_each_child_of_node(np, pp) { for_each_child_of_node_scoped(np, pp) {
struct sun4i_lradc_keymap *map = &lradc->chan0_map[i]; struct sun4i_lradc_keymap *map = &lradc->chan0_map[i];
u32 channel; u32 channel;
error = of_property_read_u32(pp, "channel", &channel); error = of_property_read_u32(pp, "channel", &channel);
if (error || channel != 0) { if (error || channel != 0) {
dev_err(dev, "%pOFn: Inval channel prop\n", pp); dev_err(dev, "%pOFn: Inval channel prop\n", pp);
of_node_put(pp);
return -EINVAL; return -EINVAL;
} }
error = of_property_read_u32(pp, "voltage", &map->voltage); error = of_property_read_u32(pp, "voltage", &map->voltage);
if (error) { if (error) {
dev_err(dev, "%pOFn: Inval voltage prop\n", pp); dev_err(dev, "%pOFn: Inval voltage prop\n", pp);
of_node_put(pp);
return -EINVAL; return -EINVAL;
} }
error = of_property_read_u32(pp, "linux,code", &map->keycode); error = of_property_read_u32(pp, "linux,code", &map->keycode);
if (error) { if (error) {
dev_err(dev, "%pOFn: Inval linux,code prop\n", pp); dev_err(dev, "%pOFn: Inval linux,code prop\n", pp);
of_node_put(pp);
return -EINVAL; return -EINVAL;
} }

View File

@ -241,9 +241,8 @@ static void sunkbd_reinit(struct work_struct *work)
static void sunkbd_enable(struct sunkbd *sunkbd, bool enable) static void sunkbd_enable(struct sunkbd *sunkbd, bool enable)
{ {
serio_pause_rx(sunkbd->serio); scoped_guard(serio_pause_rx, sunkbd->serio)
sunkbd->enabled = enable; sunkbd->enabled = enable;
serio_continue_rx(sunkbd->serio);
if (!enable) { if (!enable) {
wake_up_interruptible(&sunkbd->wait); wake_up_interruptible(&sunkbd->wait);

View File

@ -141,7 +141,7 @@ static struct platform_driver pm80x_onkey_driver = {
.pm = &pm80x_onkey_pm_ops, .pm = &pm80x_onkey_pm_ops,
}, },
.probe = pm80x_onkey_probe, .probe = pm80x_onkey_probe,
.remove_new = pm80x_onkey_remove, .remove = pm80x_onkey_remove,
}; };
module_platform_driver(pm80x_onkey_driver); module_platform_driver(pm80x_onkey_driver);

View File

@ -941,7 +941,7 @@ static irqreturn_t ad714x_interrupt_thread(int irq, void *data)
struct ad714x_chip *ad714x = data; struct ad714x_chip *ad714x = data;
int i; int i;
mutex_lock(&ad714x->mutex); guard(mutex)(&ad714x->mutex);
ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3);
@ -954,8 +954,6 @@ static irqreturn_t ad714x_interrupt_thread(int irq, void *data)
for (i = 0; i < ad714x->hw->touchpad_num; i++) for (i = 0; i < ad714x->hw->touchpad_num; i++)
ad714x_touchpad_state_machine(ad714x, i); ad714x_touchpad_state_machine(ad714x, i);
mutex_unlock(&ad714x->mutex);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
@ -1169,13 +1167,11 @@ static int ad714x_suspend(struct device *dev)
dev_dbg(ad714x->dev, "%s enter\n", __func__); dev_dbg(ad714x->dev, "%s enter\n", __func__);
mutex_lock(&ad714x->mutex); guard(mutex)(&ad714x->mutex);
data = ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL] | 0x3; data = ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL] | 0x3;
ad714x->write(ad714x, AD714X_PWR_CTRL, data); ad714x->write(ad714x, AD714X_PWR_CTRL, data);
mutex_unlock(&ad714x->mutex);
return 0; return 0;
} }
@ -1184,7 +1180,7 @@ static int ad714x_resume(struct device *dev)
struct ad714x_chip *ad714x = dev_get_drvdata(dev); struct ad714x_chip *ad714x = dev_get_drvdata(dev);
dev_dbg(ad714x->dev, "%s enter\n", __func__); dev_dbg(ad714x->dev, "%s enter\n", __func__);
mutex_lock(&ad714x->mutex); guard(mutex)(&ad714x->mutex);
/* resume to non-shutdown mode */ /* resume to non-shutdown mode */
@ -1197,8 +1193,6 @@ static int ad714x_resume(struct device *dev)
ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3);
mutex_unlock(&ad714x->mutex);
return 0; return 0;
} }

View File

@ -244,29 +244,21 @@ static int ati_remote2_open(struct input_dev *idev)
if (r) { if (r) {
dev_err(&ar2->intf[0]->dev, dev_err(&ar2->intf[0]->dev,
"%s(): usb_autopm_get_interface() = %d\n", __func__, r); "%s(): usb_autopm_get_interface() = %d\n", __func__, r);
goto fail1; return r;
} }
mutex_lock(&ati_remote2_mutex); scoped_guard(mutex, &ati_remote2_mutex) {
if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) {
r = ati_remote2_submit_urbs(ar2);
if (r)
break;
}
if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) { ar2->flags |= ATI_REMOTE2_OPENED;
r = ati_remote2_submit_urbs(ar2);
if (r)
goto fail2;
} }
ar2->flags |= ATI_REMOTE2_OPENED;
mutex_unlock(&ati_remote2_mutex);
usb_autopm_put_interface(ar2->intf[0]); usb_autopm_put_interface(ar2->intf[0]);
return 0;
fail2:
mutex_unlock(&ati_remote2_mutex);
usb_autopm_put_interface(ar2->intf[0]);
fail1:
return r; return r;
} }
@ -276,14 +268,12 @@ static void ati_remote2_close(struct input_dev *idev)
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
mutex_lock(&ati_remote2_mutex); guard(mutex)(&ati_remote2_mutex);
if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) if (!(ar2->flags & ATI_REMOTE2_SUSPENDED))
ati_remote2_kill_urbs(ar2); ati_remote2_kill_urbs(ar2);
ar2->flags &= ~ATI_REMOTE2_OPENED; ar2->flags &= ~ATI_REMOTE2_OPENED;
mutex_unlock(&ati_remote2_mutex);
} }
static void ati_remote2_input_mouse(struct ati_remote2 *ar2) static void ati_remote2_input_mouse(struct ati_remote2 *ar2)
@ -713,16 +703,14 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev,
return r; return r;
} }
mutex_lock(&ati_remote2_mutex); scoped_guard(mutex, &ati_remote2_mutex) {
if (mask != ar2->channel_mask) {
if (mask != ar2->channel_mask) { r = ati_remote2_setup(ar2, mask);
r = ati_remote2_setup(ar2, mask); if (!r)
if (!r) ar2->channel_mask = mask;
ar2->channel_mask = mask; }
} }
mutex_unlock(&ati_remote2_mutex);
usb_autopm_put_interface(ar2->intf[0]); usb_autopm_put_interface(ar2->intf[0]);
return r ? r : count; return r ? r : count;
@ -892,15 +880,13 @@ static int ati_remote2_suspend(struct usb_interface *interface,
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
mutex_lock(&ati_remote2_mutex); guard(mutex)(&ati_remote2_mutex);
if (ar2->flags & ATI_REMOTE2_OPENED) if (ar2->flags & ATI_REMOTE2_OPENED)
ati_remote2_kill_urbs(ar2); ati_remote2_kill_urbs(ar2);
ar2->flags |= ATI_REMOTE2_SUSPENDED; ar2->flags |= ATI_REMOTE2_SUSPENDED;
mutex_unlock(&ati_remote2_mutex);
return 0; return 0;
} }
@ -917,7 +903,7 @@ static int ati_remote2_resume(struct usb_interface *interface)
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
mutex_lock(&ati_remote2_mutex); guard(mutex)(&ati_remote2_mutex);
if (ar2->flags & ATI_REMOTE2_OPENED) if (ar2->flags & ATI_REMOTE2_OPENED)
r = ati_remote2_submit_urbs(ar2); r = ati_remote2_submit_urbs(ar2);
@ -925,8 +911,6 @@ static int ati_remote2_resume(struct usb_interface *interface)
if (!r) if (!r)
ar2->flags &= ~ATI_REMOTE2_SUSPENDED; ar2->flags &= ~ATI_REMOTE2_SUSPENDED;
mutex_unlock(&ati_remote2_mutex);
return r; return r;
} }
@ -943,11 +927,11 @@ static int ati_remote2_reset_resume(struct usb_interface *interface)
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
mutex_lock(&ati_remote2_mutex); guard(mutex)(&ati_remote2_mutex);
r = ati_remote2_setup(ar2, ar2->channel_mask); r = ati_remote2_setup(ar2, ar2->channel_mask);
if (r) if (r)
goto out; return r;
if (ar2->flags & ATI_REMOTE2_OPENED) if (ar2->flags & ATI_REMOTE2_OPENED)
r = ati_remote2_submit_urbs(ar2); r = ati_remote2_submit_urbs(ar2);
@ -955,9 +939,6 @@ static int ati_remote2_reset_resume(struct usb_interface *interface)
if (!r) if (!r)
ar2->flags &= ~ATI_REMOTE2_SUSPENDED; ar2->flags &= ~ATI_REMOTE2_SUSPENDED;
out:
mutex_unlock(&ati_remote2_mutex);
return r; return r;
} }

View File

@ -355,6 +355,35 @@ static void cm109_submit_buzz_toggle(struct cm109_dev *dev)
__func__, error); __func__, error);
} }
static void cm109_submit_ctl(struct cm109_dev *dev)
{
int error;
guard(spinlock_irqsave)(&dev->ctl_submit_lock);
dev->irq_urb_pending = 0;
if (unlikely(dev->shutdown))
return;
if (dev->buzzer_state)
dev->ctl_data->byte[HID_OR0] |= BUZZER_ON;
else
dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON;
dev->ctl_data->byte[HID_OR1] = dev->keybit;
dev->ctl_data->byte[HID_OR2] = dev->keybit;
dev->buzzer_pending = 0;
dev->ctl_urb_pending = 1;
error = usb_submit_urb(dev->urb_ctl, GFP_ATOMIC);
if (error)
dev_err(&dev->intf->dev,
"%s: usb_submit_urb (urb_ctl) failed %d\n",
__func__, error);
}
/* /*
* IRQ handler * IRQ handler
*/ */
@ -362,8 +391,6 @@ static void cm109_urb_irq_callback(struct urb *urb)
{ {
struct cm109_dev *dev = urb->context; struct cm109_dev *dev = urb->context;
const int status = urb->status; const int status = urb->status;
int error;
unsigned long flags;
dev_dbg(&dev->intf->dev, "### URB IRQ: [0x%02x 0x%02x 0x%02x 0x%02x] keybit=0x%02x\n", dev_dbg(&dev->intf->dev, "### URB IRQ: [0x%02x 0x%02x 0x%02x 0x%02x] keybit=0x%02x\n",
dev->irq_data->byte[0], dev->irq_data->byte[0],
@ -401,32 +428,7 @@ static void cm109_urb_irq_callback(struct urb *urb)
} }
out: out:
cm109_submit_ctl(dev);
spin_lock_irqsave(&dev->ctl_submit_lock, flags);
dev->irq_urb_pending = 0;
if (likely(!dev->shutdown)) {
if (dev->buzzer_state)
dev->ctl_data->byte[HID_OR0] |= BUZZER_ON;
else
dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON;
dev->ctl_data->byte[HID_OR1] = dev->keybit;
dev->ctl_data->byte[HID_OR2] = dev->keybit;
dev->buzzer_pending = 0;
dev->ctl_urb_pending = 1;
error = usb_submit_urb(dev->urb_ctl, GFP_ATOMIC);
if (error)
dev_err(&dev->intf->dev,
"%s: usb_submit_urb (urb_ctl) failed %d\n",
__func__, error);
}
spin_unlock_irqrestore(&dev->ctl_submit_lock, flags);
} }
static void cm109_urb_ctl_callback(struct urb *urb) static void cm109_urb_ctl_callback(struct urb *urb)
@ -434,7 +436,6 @@ static void cm109_urb_ctl_callback(struct urb *urb)
struct cm109_dev *dev = urb->context; struct cm109_dev *dev = urb->context;
const int status = urb->status; const int status = urb->status;
int error; int error;
unsigned long flags;
dev_dbg(&dev->intf->dev, "### URB CTL: [0x%02x 0x%02x 0x%02x 0x%02x]\n", dev_dbg(&dev->intf->dev, "### URB CTL: [0x%02x 0x%02x 0x%02x 0x%02x]\n",
dev->ctl_data->byte[0], dev->ctl_data->byte[0],
@ -449,35 +450,31 @@ static void cm109_urb_ctl_callback(struct urb *urb)
__func__, status); __func__, status);
} }
spin_lock_irqsave(&dev->ctl_submit_lock, flags); guard(spinlock_irqsave)(&dev->ctl_submit_lock);
dev->ctl_urb_pending = 0; dev->ctl_urb_pending = 0;
if (likely(!dev->shutdown)) { if (unlikely(dev->shutdown))
return;
if (dev->buzzer_pending || status) { if (dev->buzzer_pending || status) {
dev->buzzer_pending = 0; dev->buzzer_pending = 0;
dev->ctl_urb_pending = 1; dev->ctl_urb_pending = 1;
cm109_submit_buzz_toggle(dev); cm109_submit_buzz_toggle(dev);
} else if (likely(!dev->irq_urb_pending)) { } else if (likely(!dev->irq_urb_pending)) {
/* ask for key data */ /* ask for key data */
dev->irq_urb_pending = 1; dev->irq_urb_pending = 1;
error = usb_submit_urb(dev->urb_irq, GFP_ATOMIC); error = usb_submit_urb(dev->urb_irq, GFP_ATOMIC);
if (error) if (error)
dev_err(&dev->intf->dev, dev_err(&dev->intf->dev,
"%s: usb_submit_urb (urb_irq) failed %d\n", "%s: usb_submit_urb (urb_irq) failed %d\n",
__func__, error); __func__, error);
}
} }
spin_unlock_irqrestore(&dev->ctl_submit_lock, flags);
} }
static void cm109_toggle_buzzer_async(struct cm109_dev *dev) static void cm109_toggle_buzzer_async(struct cm109_dev *dev)
{ {
unsigned long flags; guard(spinlock_irqsave)(&dev->ctl_submit_lock);
spin_lock_irqsave(&dev->ctl_submit_lock, flags);
if (dev->ctl_urb_pending) { if (dev->ctl_urb_pending) {
/* URB completion will resubmit */ /* URB completion will resubmit */
@ -486,8 +483,6 @@ static void cm109_toggle_buzzer_async(struct cm109_dev *dev)
dev->ctl_urb_pending = 1; dev->ctl_urb_pending = 1;
cm109_submit_buzz_toggle(dev); cm109_submit_buzz_toggle(dev);
} }
spin_unlock_irqrestore(&dev->ctl_submit_lock, flags);
} }
static void cm109_toggle_buzzer_sync(struct cm109_dev *dev, int on) static void cm109_toggle_buzzer_sync(struct cm109_dev *dev, int on)
@ -556,32 +551,30 @@ static int cm109_input_open(struct input_dev *idev)
return error; return error;
} }
mutex_lock(&dev->pm_mutex); scoped_guard(mutex, &dev->pm_mutex) {
dev->buzzer_state = 0;
dev->key_code = -1; /* no keys pressed */
dev->keybit = 0xf;
dev->buzzer_state = 0; /* issue INIT */
dev->key_code = -1; /* no keys pressed */ dev->ctl_data->byte[HID_OR0] = HID_OR_GPO_BUZ_SPDIF;
dev->keybit = 0xf; dev->ctl_data->byte[HID_OR1] = dev->keybit;
dev->ctl_data->byte[HID_OR2] = dev->keybit;
dev->ctl_data->byte[HID_OR3] = 0x00;
/* issue INIT */ dev->ctl_urb_pending = 1;
dev->ctl_data->byte[HID_OR0] = HID_OR_GPO_BUZ_SPDIF; error = usb_submit_urb(dev->urb_ctl, GFP_KERNEL);
dev->ctl_data->byte[HID_OR1] = dev->keybit; if (!error) {
dev->ctl_data->byte[HID_OR2] = dev->keybit; dev->open = 1;
dev->ctl_data->byte[HID_OR3] = 0x00; return 0;
}
dev->ctl_urb_pending = 1;
error = usb_submit_urb(dev->urb_ctl, GFP_KERNEL);
if (error) {
dev->ctl_urb_pending = 0;
dev_err(&dev->intf->dev, "%s: usb_submit_urb (urb_ctl) failed %d\n",
__func__, error);
} else {
dev->open = 1;
} }
mutex_unlock(&dev->pm_mutex); dev->ctl_urb_pending = 0;
usb_autopm_put_interface(dev->intf);
if (error) dev_err(&dev->intf->dev, "%s: usb_submit_urb (urb_ctl) failed %d\n",
usb_autopm_put_interface(dev->intf); __func__, error);
return error; return error;
} }
@ -590,17 +583,15 @@ static void cm109_input_close(struct input_dev *idev)
{ {
struct cm109_dev *dev = input_get_drvdata(idev); struct cm109_dev *dev = input_get_drvdata(idev);
mutex_lock(&dev->pm_mutex); scoped_guard(mutex, &dev->pm_mutex) {
/*
/* * Once we are here event delivery is stopped so we
* Once we are here event delivery is stopped so we * don't need to worry about someone starting buzzer
* don't need to worry about someone starting buzzer * again
* again */
*/ cm109_stop_traffic(dev);
cm109_stop_traffic(dev); dev->open = 0;
dev->open = 0; }
mutex_unlock(&dev->pm_mutex);
usb_autopm_put_interface(dev->intf); usb_autopm_put_interface(dev->intf);
} }
@ -823,9 +814,9 @@ static int cm109_usb_suspend(struct usb_interface *intf, pm_message_t message)
dev_info(&intf->dev, "cm109: usb_suspend (event=%d)\n", message.event); dev_info(&intf->dev, "cm109: usb_suspend (event=%d)\n", message.event);
mutex_lock(&dev->pm_mutex); guard(mutex)(&dev->pm_mutex);
cm109_stop_traffic(dev); cm109_stop_traffic(dev);
mutex_unlock(&dev->pm_mutex);
return 0; return 0;
} }
@ -836,9 +827,9 @@ static int cm109_usb_resume(struct usb_interface *intf)
dev_info(&intf->dev, "cm109: usb_resume\n"); dev_info(&intf->dev, "cm109: usb_resume\n");
mutex_lock(&dev->pm_mutex); guard(mutex)(&dev->pm_mutex);
cm109_restore_state(dev); cm109_restore_state(dev);
mutex_unlock(&dev->pm_mutex);
return 0; return 0;
} }

View File

@ -217,15 +217,13 @@ static int cma3000_open(struct input_dev *input_dev)
{ {
struct cma3000_accl_data *data = input_get_drvdata(input_dev); struct cma3000_accl_data *data = input_get_drvdata(input_dev);
mutex_lock(&data->mutex); guard(mutex)(&data->mutex);
if (!data->suspended) if (!data->suspended)
cma3000_poweron(data); cma3000_poweron(data);
data->opened = true; data->opened = true;
mutex_unlock(&data->mutex);
return 0; return 0;
} }
@ -233,40 +231,34 @@ static void cma3000_close(struct input_dev *input_dev)
{ {
struct cma3000_accl_data *data = input_get_drvdata(input_dev); struct cma3000_accl_data *data = input_get_drvdata(input_dev);
mutex_lock(&data->mutex); guard(mutex)(&data->mutex);
if (!data->suspended) if (!data->suspended)
cma3000_poweroff(data); cma3000_poweroff(data);
data->opened = false; data->opened = false;
mutex_unlock(&data->mutex);
} }
void cma3000_suspend(struct cma3000_accl_data *data) void cma3000_suspend(struct cma3000_accl_data *data)
{ {
mutex_lock(&data->mutex); guard(mutex)(&data->mutex);
if (!data->suspended && data->opened) if (!data->suspended && data->opened)
cma3000_poweroff(data); cma3000_poweroff(data);
data->suspended = true; data->suspended = true;
mutex_unlock(&data->mutex);
} }
EXPORT_SYMBOL(cma3000_suspend); EXPORT_SYMBOL(cma3000_suspend);
void cma3000_resume(struct cma3000_accl_data *data) void cma3000_resume(struct cma3000_accl_data *data)
{ {
mutex_lock(&data->mutex); guard(mutex)(&data->mutex);
if (data->suspended && data->opened) if (data->suspended && data->opened)
cma3000_poweron(data); cma3000_poweron(data);
data->suspended = false; data->suspended = false;
mutex_unlock(&data->mutex);
} }
EXPORT_SYMBOL(cma3000_resume); EXPORT_SYMBOL(cma3000_resume);

View File

@ -334,11 +334,12 @@ static int cs40l50_add(struct input_dev *dev, struct ff_effect *effect,
work_data.custom_len = effect->u.periodic.custom_len; work_data.custom_len = effect->u.periodic.custom_len;
work_data.vib = vib; work_data.vib = vib;
work_data.effect = effect; work_data.effect = effect;
INIT_WORK(&work_data.work, cs40l50_add_worker); INIT_WORK_ONSTACK(&work_data.work, cs40l50_add_worker);
/* Push to the workqueue to serialize with playbacks */ /* Push to the workqueue to serialize with playbacks */
queue_work(vib->vib_wq, &work_data.work); queue_work(vib->vib_wq, &work_data.work);
flush_work(&work_data.work); flush_work(&work_data.work);
destroy_work_on_stack(&work_data.work);
kfree(work_data.custom_data); kfree(work_data.custom_data);
@ -467,11 +468,12 @@ static int cs40l50_erase(struct input_dev *dev, int effect_id)
work_data.vib = vib; work_data.vib = vib;
work_data.effect = &dev->ff->effects[effect_id]; work_data.effect = &dev->ff->effects[effect_id];
INIT_WORK(&work_data.work, cs40l50_erase_worker); INIT_WORK_ONSTACK(&work_data.work, cs40l50_erase_worker);
/* Push to workqueue to serialize with playbacks */ /* Push to workqueue to serialize with playbacks */
queue_work(vib->vib_wq, &work_data.work); queue_work(vib->vib_wq, &work_data.work);
flush_work(&work_data.work); flush_work(&work_data.work);
destroy_work_on_stack(&work_data.work);
return work_data.error; return work_data.error;
} }

View File

@ -1263,39 +1263,37 @@ static int da7280_suspend(struct device *dev)
{ {
struct da7280_haptic *haptics = dev_get_drvdata(dev); struct da7280_haptic *haptics = dev_get_drvdata(dev);
mutex_lock(&haptics->input_dev->mutex); guard(mutex)(&haptics->input_dev->mutex);
/* /*
* Make sure no new requests will be submitted while device is * Make sure no new requests will be submitted while device is
* suspended. * suspended.
*/ */
spin_lock_irq(&haptics->input_dev->event_lock); scoped_guard(spinlock_irq, &haptics->input_dev->event_lock) {
haptics->suspended = true; haptics->suspended = true;
spin_unlock_irq(&haptics->input_dev->event_lock); }
da7280_haptic_stop(haptics); da7280_haptic_stop(haptics);
mutex_unlock(&haptics->input_dev->mutex);
return 0; return 0;
} }
static int da7280_resume(struct device *dev) static int da7280_resume(struct device *dev)
{ {
struct da7280_haptic *haptics = dev_get_drvdata(dev); struct da7280_haptic *haptics = dev_get_drvdata(dev);
int retval; int error;
mutex_lock(&haptics->input_dev->mutex); guard(mutex)(&haptics->input_dev->mutex);
retval = da7280_haptic_start(haptics); error = da7280_haptic_start(haptics);
if (!retval) { if (error)
spin_lock_irq(&haptics->input_dev->event_lock); return error;
scoped_guard(spinlock_irq, &haptics->input_dev->event_lock) {
haptics->suspended = false; haptics->suspended = false;
spin_unlock_irq(&haptics->input_dev->event_lock);
} }
mutex_unlock(&haptics->input_dev->mutex); return 0;
return retval;
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF

View File

@ -140,8 +140,8 @@ static void da9052_onkey_remove(struct platform_device *pdev)
static struct platform_driver da9052_onkey_driver = { static struct platform_driver da9052_onkey_driver = {
.probe = da9052_onkey_probe, .probe = da9052_onkey_probe,
.remove_new = da9052_onkey_remove, .remove = da9052_onkey_remove,
.driver = { .driver = {
.name = "da9052-onkey", .name = "da9052-onkey",
}, },
}; };

View File

@ -145,8 +145,8 @@ static void da9055_onkey_remove(struct platform_device *pdev)
static struct platform_driver da9055_onkey_driver = { static struct platform_driver da9055_onkey_driver = {
.probe = da9055_onkey_probe, .probe = da9055_onkey_probe,
.remove_new = da9055_onkey_remove, .remove = da9055_onkey_remove,
.driver = { .driver = {
.name = "da9055-onkey", .name = "da9055-onkey",
}, },
}; };

View File

@ -537,64 +537,62 @@ static int drv260x_probe(struct i2c_client *client)
static int drv260x_suspend(struct device *dev) static int drv260x_suspend(struct device *dev)
{ {
struct drv260x_data *haptics = dev_get_drvdata(dev); struct drv260x_data *haptics = dev_get_drvdata(dev);
int ret = 0; int error;
mutex_lock(&haptics->input_dev->mutex); guard(mutex)(&haptics->input_dev->mutex);
if (input_device_enabled(haptics->input_dev)) { if (input_device_enabled(haptics->input_dev)) {
ret = regmap_update_bits(haptics->regmap, error = regmap_update_bits(haptics->regmap,
DRV260X_MODE, DRV260X_MODE,
DRV260X_STANDBY_MASK, DRV260X_STANDBY_MASK,
DRV260X_STANDBY); DRV260X_STANDBY);
if (ret) { if (error) {
dev_err(dev, "Failed to set standby mode\n"); dev_err(dev, "Failed to set standby mode\n");
goto out; return error;
} }
gpiod_set_value(haptics->enable_gpio, 0); gpiod_set_value(haptics->enable_gpio, 0);
ret = regulator_disable(haptics->regulator); error = regulator_disable(haptics->regulator);
if (ret) { if (error) {
dev_err(dev, "Failed to disable regulator\n"); dev_err(dev, "Failed to disable regulator\n");
regmap_update_bits(haptics->regmap, regmap_update_bits(haptics->regmap,
DRV260X_MODE, DRV260X_MODE,
DRV260X_STANDBY_MASK, 0); DRV260X_STANDBY_MASK, 0);
return error;
} }
} }
out:
mutex_unlock(&haptics->input_dev->mutex); return 0;
return ret;
} }
static int drv260x_resume(struct device *dev) static int drv260x_resume(struct device *dev)
{ {
struct drv260x_data *haptics = dev_get_drvdata(dev); struct drv260x_data *haptics = dev_get_drvdata(dev);
int ret = 0; int error;
mutex_lock(&haptics->input_dev->mutex); guard(mutex)(&haptics->input_dev->mutex);
if (input_device_enabled(haptics->input_dev)) { if (input_device_enabled(haptics->input_dev)) {
ret = regulator_enable(haptics->regulator); error = regulator_enable(haptics->regulator);
if (ret) { if (error) {
dev_err(dev, "Failed to enable regulator\n"); dev_err(dev, "Failed to enable regulator\n");
goto out; return error;
} }
ret = regmap_update_bits(haptics->regmap, error = regmap_update_bits(haptics->regmap,
DRV260X_MODE, DRV260X_MODE,
DRV260X_STANDBY_MASK, 0); DRV260X_STANDBY_MASK, 0);
if (ret) { if (error) {
dev_err(dev, "Failed to unset standby mode\n"); dev_err(dev, "Failed to unset standby mode\n");
regulator_disable(haptics->regulator); regulator_disable(haptics->regulator);
goto out; return error;
} }
gpiod_set_value(haptics->enable_gpio, 1); gpiod_set_value(haptics->enable_gpio, 1);
} }
out: return 0;
mutex_unlock(&haptics->input_dev->mutex);
return ret;
} }
static DEFINE_SIMPLE_DEV_PM_OPS(drv260x_pm_ops, drv260x_suspend, drv260x_resume); static DEFINE_SIMPLE_DEV_PM_OPS(drv260x_pm_ops, drv260x_suspend, drv260x_resume);

View File

@ -15,7 +15,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
/* Contol registers */ /* Control registers */
#define DRV2665_STATUS 0x00 #define DRV2665_STATUS 0x00
#define DRV2665_CTRL_1 0x01 #define DRV2665_CTRL_1 0x01
#define DRV2665_CTRL_2 0x02 #define DRV2665_CTRL_2 0x02
@ -225,59 +225,57 @@ static int drv2665_probe(struct i2c_client *client)
static int drv2665_suspend(struct device *dev) static int drv2665_suspend(struct device *dev)
{ {
struct drv2665_data *haptics = dev_get_drvdata(dev); struct drv2665_data *haptics = dev_get_drvdata(dev);
int ret = 0; int error;
mutex_lock(&haptics->input_dev->mutex); guard(mutex)(&haptics->input_dev->mutex);
if (input_device_enabled(haptics->input_dev)) { if (input_device_enabled(haptics->input_dev)) {
ret = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2, error = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2,
DRV2665_STANDBY, DRV2665_STANDBY); DRV2665_STANDBY, DRV2665_STANDBY);
if (ret) { if (error) {
dev_err(dev, "Failed to set standby mode\n"); dev_err(dev, "Failed to set standby mode\n");
regulator_disable(haptics->regulator); regulator_disable(haptics->regulator);
goto out; return error;
} }
ret = regulator_disable(haptics->regulator); error = regulator_disable(haptics->regulator);
if (ret) { if (error) {
dev_err(dev, "Failed to disable regulator\n"); dev_err(dev, "Failed to disable regulator\n");
regmap_update_bits(haptics->regmap, regmap_update_bits(haptics->regmap,
DRV2665_CTRL_2, DRV2665_CTRL_2,
DRV2665_STANDBY, 0); DRV2665_STANDBY, 0);
return error;
} }
} }
out:
mutex_unlock(&haptics->input_dev->mutex); return 0;
return ret;
} }
static int drv2665_resume(struct device *dev) static int drv2665_resume(struct device *dev)
{ {
struct drv2665_data *haptics = dev_get_drvdata(dev); struct drv2665_data *haptics = dev_get_drvdata(dev);
int ret = 0; int error;
mutex_lock(&haptics->input_dev->mutex); guard(mutex)(&haptics->input_dev->mutex);
if (input_device_enabled(haptics->input_dev)) { if (input_device_enabled(haptics->input_dev)) {
ret = regulator_enable(haptics->regulator); error = regulator_enable(haptics->regulator);
if (ret) { if (error) {
dev_err(dev, "Failed to enable regulator\n"); dev_err(dev, "Failed to enable regulator\n");
goto out; return error;
} }
ret = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2, error = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2,
DRV2665_STANDBY, 0); DRV2665_STANDBY, 0);
if (ret) { if (error) {
dev_err(dev, "Failed to unset standby mode\n"); dev_err(dev, "Failed to unset standby mode\n");
regulator_disable(haptics->regulator); regulator_disable(haptics->regulator);
goto out; return error;
} }
} }
out: return 0;
mutex_unlock(&haptics->input_dev->mutex);
return ret;
} }
static DEFINE_SIMPLE_DEV_PM_OPS(drv2665_pm_ops, drv2665_suspend, drv2665_resume); static DEFINE_SIMPLE_DEV_PM_OPS(drv2665_pm_ops, drv2665_suspend, drv2665_resume);

View File

@ -16,7 +16,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
/* Contol registers */ /* Control registers */
#define DRV2667_STATUS 0x00 #define DRV2667_STATUS 0x00
#define DRV2667_CTRL_1 0x01 #define DRV2667_CTRL_1 0x01
#define DRV2667_CTRL_2 0x02 #define DRV2667_CTRL_2 0x02
@ -402,59 +402,57 @@ static int drv2667_probe(struct i2c_client *client)
static int drv2667_suspend(struct device *dev) static int drv2667_suspend(struct device *dev)
{ {
struct drv2667_data *haptics = dev_get_drvdata(dev); struct drv2667_data *haptics = dev_get_drvdata(dev);
int ret = 0; int error;
mutex_lock(&haptics->input_dev->mutex); guard(mutex)(&haptics->input_dev->mutex);
if (input_device_enabled(haptics->input_dev)) { if (input_device_enabled(haptics->input_dev)) {
ret = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2,
DRV2667_STANDBY, DRV2667_STANDBY); DRV2667_STANDBY, DRV2667_STANDBY);
if (ret) { if (error) {
dev_err(dev, "Failed to set standby mode\n"); dev_err(dev, "Failed to set standby mode\n");
regulator_disable(haptics->regulator); regulator_disable(haptics->regulator);
goto out; return error;
} }
ret = regulator_disable(haptics->regulator); error = regulator_disable(haptics->regulator);
if (ret) { if (error) {
dev_err(dev, "Failed to disable regulator\n"); dev_err(dev, "Failed to disable regulator\n");
regmap_update_bits(haptics->regmap, regmap_update_bits(haptics->regmap,
DRV2667_CTRL_2, DRV2667_CTRL_2,
DRV2667_STANDBY, 0); DRV2667_STANDBY, 0);
return error;
} }
} }
out:
mutex_unlock(&haptics->input_dev->mutex); return 0;
return ret;
} }
static int drv2667_resume(struct device *dev) static int drv2667_resume(struct device *dev)
{ {
struct drv2667_data *haptics = dev_get_drvdata(dev); struct drv2667_data *haptics = dev_get_drvdata(dev);
int ret = 0; int error;
mutex_lock(&haptics->input_dev->mutex); guard(mutex)(&haptics->input_dev->mutex);
if (input_device_enabled(haptics->input_dev)) { if (input_device_enabled(haptics->input_dev)) {
ret = regulator_enable(haptics->regulator); error = regulator_enable(haptics->regulator);
if (ret) { if (error) {
dev_err(dev, "Failed to enable regulator\n"); dev_err(dev, "Failed to enable regulator\n");
goto out; return error;
} }
ret = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2,
DRV2667_STANDBY, 0); DRV2667_STANDBY, 0);
if (ret) { if (error) {
dev_err(dev, "Failed to unset standby mode\n"); dev_err(dev, "Failed to unset standby mode\n");
regulator_disable(haptics->regulator); regulator_disable(haptics->regulator);
goto out; return error;
} }
} }
out: return 0;
mutex_unlock(&haptics->input_dev->mutex);
return ret;
} }
static DEFINE_SIMPLE_DEV_PM_OPS(drv2667_pm_ops, drv2667_suspend, drv2667_resume); static DEFINE_SIMPLE_DEV_PM_OPS(drv2667_pm_ops, drv2667_suspend, drv2667_resume);

View File

@ -77,12 +77,11 @@ static void ibm_panel_process_command(struct ibm_panel *panel)
static int ibm_panel_i2c_slave_cb(struct i2c_client *client, static int ibm_panel_i2c_slave_cb(struct i2c_client *client,
enum i2c_slave_event event, u8 *val) enum i2c_slave_event event, u8 *val)
{ {
unsigned long flags;
struct ibm_panel *panel = i2c_get_clientdata(client); struct ibm_panel *panel = i2c_get_clientdata(client);
dev_dbg(&panel->input->dev, "event: %u data: %02x\n", event, *val); dev_dbg(&panel->input->dev, "event: %u data: %02x\n", event, *val);
spin_lock_irqsave(&panel->lock, flags); guard(spinlock_irqsave)(&panel->lock);
switch (event) { switch (event) {
case I2C_SLAVE_STOP: case I2C_SLAVE_STOP:
@ -114,8 +113,6 @@ static int ibm_panel_i2c_slave_cb(struct i2c_client *client,
break; break;
} }
spin_unlock_irqrestore(&panel->lock, flags);
return 0; return 0;
} }

View File

@ -23,7 +23,7 @@
* *
* The value is in byte range, however, I only figured out * The value is in byte range, however, I only figured out
* how bits 0b10011001 work. Some other bits, probably, * how bits 0b10011001 work. Some other bits, probably,
* are meaningfull too. * are meaningful too.
* *
* Possible states: * Possible states:
* *
@ -95,41 +95,29 @@ static struct platform_device *slidebar_platform_dev;
static u8 slidebar_pos_get(void) static u8 slidebar_pos_get(void)
{ {
u8 res; guard(spinlock_irqsave)(&io_lock);
unsigned long flags;
spin_lock_irqsave(&io_lock, flags);
outb(0xf4, 0xff29); outb(0xf4, 0xff29);
outb(0xbf, 0xff2a); outb(0xbf, 0xff2a);
res = inb(0xff2b); return inb(0xff2b);
spin_unlock_irqrestore(&io_lock, flags);
return res;
} }
static u8 slidebar_mode_get(void) static u8 slidebar_mode_get(void)
{ {
u8 res; guard(spinlock_irqsave)(&io_lock);
unsigned long flags;
spin_lock_irqsave(&io_lock, flags);
outb(0xf7, 0xff29); outb(0xf7, 0xff29);
outb(0x8b, 0xff2a); outb(0x8b, 0xff2a);
res = inb(0xff2b); return inb(0xff2b);
spin_unlock_irqrestore(&io_lock, flags);
return res;
} }
static void slidebar_mode_set(u8 mode) static void slidebar_mode_set(u8 mode)
{ {
unsigned long flags; guard(spinlock_irqsave)(&io_lock);
spin_lock_irqsave(&io_lock, flags);
outb(0xf7, 0xff29); outb(0xf7, 0xff29);
outb(0x8b, 0xff2a); outb(0x8b, 0xff2a);
outb(mode, 0xff2b); outb(mode, 0xff2b);
spin_unlock_irqrestore(&io_lock, flags);
} }
static bool slidebar_i8042_filter(unsigned char data, unsigned char str, static bool slidebar_i8042_filter(unsigned char data, unsigned char str,
@ -267,7 +255,7 @@ static struct platform_driver slidebar_drv = {
.driver = { .driver = {
.name = "ideapad_slidebar", .name = "ideapad_slidebar",
}, },
.remove_new = ideapad_remove, .remove = ideapad_remove,
}; };
static int __init ideapad_dmi_check(const struct dmi_system_id *id) static int __init ideapad_dmi_check(const struct dmi_system_id *id)

View File

@ -739,7 +739,7 @@ static int ims_pcu_switch_to_bootloader(struct ims_pcu *pcu)
{ {
int error; int error;
/* Execute jump to the bootoloader */ /* Execute jump to the bootloader */
error = ims_pcu_execute_command(pcu, JUMP_TO_BTLDR, NULL, 0); error = ims_pcu_execute_command(pcu, JUMP_TO_BTLDR, NULL, 0);
if (error) { if (error) {
dev_err(pcu->dev, dev_err(pcu->dev,

View File

@ -365,7 +365,7 @@ static int iqs269_ati_mode_set(struct iqs269_private *iqs269,
if (mode > IQS269_CHx_ENG_A_ATI_MODE_MAX) if (mode > IQS269_CHx_ENG_A_ATI_MODE_MAX)
return -EINVAL; return -EINVAL;
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
engine_a = be16_to_cpu(ch_reg[ch_num].engine_a); engine_a = be16_to_cpu(ch_reg[ch_num].engine_a);
@ -375,8 +375,6 @@ static int iqs269_ati_mode_set(struct iqs269_private *iqs269,
ch_reg[ch_num].engine_a = cpu_to_be16(engine_a); ch_reg[ch_num].engine_a = cpu_to_be16(engine_a);
iqs269->ati_current = false; iqs269->ati_current = false;
mutex_unlock(&iqs269->lock);
return 0; return 0;
} }
@ -389,9 +387,9 @@ static int iqs269_ati_mode_get(struct iqs269_private *iqs269,
if (ch_num >= IQS269_NUM_CH) if (ch_num >= IQS269_NUM_CH)
return -EINVAL; return -EINVAL;
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
engine_a = be16_to_cpu(ch_reg[ch_num].engine_a); engine_a = be16_to_cpu(ch_reg[ch_num].engine_a);
mutex_unlock(&iqs269->lock);
engine_a &= IQS269_CHx_ENG_A_ATI_MODE_MASK; engine_a &= IQS269_CHx_ENG_A_ATI_MODE_MASK;
*mode = (engine_a >> IQS269_CHx_ENG_A_ATI_MODE_SHIFT); *mode = (engine_a >> IQS269_CHx_ENG_A_ATI_MODE_SHIFT);
@ -429,7 +427,7 @@ static int iqs269_ati_base_set(struct iqs269_private *iqs269,
return -EINVAL; return -EINVAL;
} }
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
@ -439,8 +437,6 @@ static int iqs269_ati_base_set(struct iqs269_private *iqs269,
ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); ch_reg[ch_num].engine_b = cpu_to_be16(engine_b);
iqs269->ati_current = false; iqs269->ati_current = false;
mutex_unlock(&iqs269->lock);
return 0; return 0;
} }
@ -453,9 +449,9 @@ static int iqs269_ati_base_get(struct iqs269_private *iqs269,
if (ch_num >= IQS269_NUM_CH) if (ch_num >= IQS269_NUM_CH)
return -EINVAL; return -EINVAL;
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
mutex_unlock(&iqs269->lock);
switch (engine_b & IQS269_CHx_ENG_B_ATI_BASE_MASK) { switch (engine_b & IQS269_CHx_ENG_B_ATI_BASE_MASK) {
case IQS269_CHx_ENG_B_ATI_BASE_75: case IQS269_CHx_ENG_B_ATI_BASE_75:
@ -491,7 +487,7 @@ static int iqs269_ati_target_set(struct iqs269_private *iqs269,
if (target > IQS269_CHx_ENG_B_ATI_TARGET_MAX) if (target > IQS269_CHx_ENG_B_ATI_TARGET_MAX)
return -EINVAL; return -EINVAL;
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
@ -501,8 +497,6 @@ static int iqs269_ati_target_set(struct iqs269_private *iqs269,
ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); ch_reg[ch_num].engine_b = cpu_to_be16(engine_b);
iqs269->ati_current = false; iqs269->ati_current = false;
mutex_unlock(&iqs269->lock);
return 0; return 0;
} }
@ -515,10 +509,9 @@ static int iqs269_ati_target_get(struct iqs269_private *iqs269,
if (ch_num >= IQS269_NUM_CH) if (ch_num >= IQS269_NUM_CH)
return -EINVAL; return -EINVAL;
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
mutex_unlock(&iqs269->lock);
engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
*target = (engine_b & IQS269_CHx_ENG_B_ATI_TARGET_MASK) * 32; *target = (engine_b & IQS269_CHx_ENG_B_ATI_TARGET_MASK) * 32;
return 0; return 0;
@ -557,7 +550,6 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
const struct fwnode_handle *ch_node) const struct fwnode_handle *ch_node)
{ {
struct i2c_client *client = iqs269->client; struct i2c_client *client = iqs269->client;
struct fwnode_handle *ev_node;
struct iqs269_ch_reg *ch_reg; struct iqs269_ch_reg *ch_reg;
u16 engine_a, engine_b; u16 engine_a, engine_b;
unsigned int reg, val; unsigned int reg, val;
@ -734,8 +726,9 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
} }
for (i = 0; i < ARRAY_SIZE(iqs269_events); i++) { for (i = 0; i < ARRAY_SIZE(iqs269_events); i++) {
ev_node = fwnode_get_named_child_node(ch_node, struct fwnode_handle *ev_node __free(fwnode_handle) =
iqs269_events[i].name); fwnode_get_named_child_node(ch_node,
iqs269_events[i].name);
if (!ev_node) if (!ev_node)
continue; continue;
@ -744,7 +737,6 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
dev_err(&client->dev, dev_err(&client->dev,
"Invalid channel %u threshold: %u\n", "Invalid channel %u threshold: %u\n",
reg, val); reg, val);
fwnode_handle_put(ev_node);
return -EINVAL; return -EINVAL;
} }
@ -758,7 +750,6 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
dev_err(&client->dev, dev_err(&client->dev,
"Invalid channel %u hysteresis: %u\n", "Invalid channel %u hysteresis: %u\n",
reg, val); reg, val);
fwnode_handle_put(ev_node);
return -EINVAL; return -EINVAL;
} }
@ -774,7 +765,6 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
} }
error = fwnode_property_read_u32(ev_node, "linux,code", &val); error = fwnode_property_read_u32(ev_node, "linux,code", &val);
fwnode_handle_put(ev_node);
if (error == -EINVAL) { if (error == -EINVAL) {
continue; continue;
} else if (error) { } else if (error) {
@ -1199,7 +1189,7 @@ static int iqs269_dev_init(struct iqs269_private *iqs269)
{ {
int error; int error;
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
/* /*
* Early revisions of silicon require the following workaround in order * Early revisions of silicon require the following workaround in order
@ -1210,19 +1200,19 @@ static int iqs269_dev_init(struct iqs269_private *iqs269)
error = regmap_multi_reg_write(iqs269->regmap, iqs269_tws_init, error = regmap_multi_reg_write(iqs269->regmap, iqs269_tws_init,
ARRAY_SIZE(iqs269_tws_init)); ARRAY_SIZE(iqs269_tws_init));
if (error) if (error)
goto err_mutex; return error;
} }
error = regmap_update_bits(iqs269->regmap, IQS269_HALL_UI, error = regmap_update_bits(iqs269->regmap, IQS269_HALL_UI,
IQS269_HALL_UI_ENABLE, IQS269_HALL_UI_ENABLE,
iqs269->hall_enable ? ~0 : 0); iqs269->hall_enable ? ~0 : 0);
if (error) if (error)
goto err_mutex; return error;
error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS, error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS,
&iqs269->sys_reg, sizeof(iqs269->sys_reg)); &iqs269->sys_reg, sizeof(iqs269->sys_reg));
if (error) if (error)
goto err_mutex; return error;
/* /*
* The following delay gives the device time to deassert its RDY output * The following delay gives the device time to deassert its RDY output
@ -1232,10 +1222,7 @@ static int iqs269_dev_init(struct iqs269_private *iqs269)
iqs269->ati_current = true; iqs269->ati_current = true;
err_mutex: return 0;
mutex_unlock(&iqs269->lock);
return error;
} }
static int iqs269_input_init(struct iqs269_private *iqs269) static int iqs269_input_init(struct iqs269_private *iqs269)
@ -1580,13 +1567,11 @@ static ssize_t hall_enable_store(struct device *dev,
if (error) if (error)
return error; return error;
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
iqs269->hall_enable = val; iqs269->hall_enable = val;
iqs269->ati_current = false; iqs269->ati_current = false;
mutex_unlock(&iqs269->lock);
return count; return count;
} }
@ -1643,13 +1628,11 @@ static ssize_t rx_enable_store(struct device *dev,
if (val > 0xFF) if (val > 0xFF)
return -EINVAL; return -EINVAL;
mutex_lock(&iqs269->lock); guard(mutex)(&iqs269->lock);
ch_reg[iqs269->ch_num].rx_enable = val; ch_reg[iqs269->ch_num].rx_enable = val;
iqs269->ati_current = false; iqs269->ati_current = false;
mutex_unlock(&iqs269->lock);
return count; return count;
} }

View File

@ -462,7 +462,6 @@ iqs626_parse_events(struct iqs626_private *iqs626,
{ {
struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg;
struct i2c_client *client = iqs626->client; struct i2c_client *client = iqs626->client;
struct fwnode_handle *ev_node;
const char *ev_name; const char *ev_name;
u8 *thresh, *hyst; u8 *thresh, *hyst;
unsigned int val; unsigned int val;
@ -501,6 +500,7 @@ iqs626_parse_events(struct iqs626_private *iqs626,
if (!iqs626_channels[ch_id].events[i]) if (!iqs626_channels[ch_id].events[i])
continue; continue;
struct fwnode_handle *ev_node __free(fwnode_handle) = NULL;
if (ch_id == IQS626_CH_TP_2 || ch_id == IQS626_CH_TP_3) { if (ch_id == IQS626_CH_TP_2 || ch_id == IQS626_CH_TP_3) {
/* /*
* Trackpad touch events are simply described under the * Trackpad touch events are simply described under the
@ -530,7 +530,6 @@ iqs626_parse_events(struct iqs626_private *iqs626,
dev_err(&client->dev, dev_err(&client->dev,
"Invalid input type: %u\n", "Invalid input type: %u\n",
val); val);
fwnode_handle_put(ev_node);
return -EINVAL; return -EINVAL;
} }
@ -545,7 +544,6 @@ iqs626_parse_events(struct iqs626_private *iqs626,
dev_err(&client->dev, dev_err(&client->dev,
"Invalid %s channel hysteresis: %u\n", "Invalid %s channel hysteresis: %u\n",
fwnode_get_name(ch_node), val); fwnode_get_name(ch_node), val);
fwnode_handle_put(ev_node);
return -EINVAL; return -EINVAL;
} }
@ -566,7 +564,6 @@ iqs626_parse_events(struct iqs626_private *iqs626,
dev_err(&client->dev, dev_err(&client->dev,
"Invalid %s channel threshold: %u\n", "Invalid %s channel threshold: %u\n",
fwnode_get_name(ch_node), val); fwnode_get_name(ch_node), val);
fwnode_handle_put(ev_node);
return -EINVAL; return -EINVAL;
} }
@ -575,8 +572,6 @@ iqs626_parse_events(struct iqs626_private *iqs626,
else else
*(thresh + iqs626_events[i].th_offs) = val; *(thresh + iqs626_events[i].th_offs) = val;
} }
fwnode_handle_put(ev_node);
} }
return 0; return 0;
@ -774,12 +769,12 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626,
for (i = 0; i < iqs626_channels[ch_id].num_ch; i++) { for (i = 0; i < iqs626_channels[ch_id].num_ch; i++) {
u8 *ati_base = &sys_reg->tp_grp_reg.ch_reg_tp[i].ati_base; u8 *ati_base = &sys_reg->tp_grp_reg.ch_reg_tp[i].ati_base;
u8 *thresh = &sys_reg->tp_grp_reg.ch_reg_tp[i].thresh; u8 *thresh = &sys_reg->tp_grp_reg.ch_reg_tp[i].thresh;
struct fwnode_handle *tc_node;
char tc_name[10]; char tc_name[10];
snprintf(tc_name, sizeof(tc_name), "channel-%d", i); snprintf(tc_name, sizeof(tc_name), "channel-%d", i);
tc_node = fwnode_get_named_child_node(ch_node, tc_name); struct fwnode_handle *tc_node __free(fwnode_handle) =
fwnode_get_named_child_node(ch_node, tc_name);
if (!tc_node) if (!tc_node)
continue; continue;
@ -790,7 +785,6 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626,
dev_err(&client->dev, dev_err(&client->dev,
"Invalid %s %s ATI base: %u\n", "Invalid %s %s ATI base: %u\n",
fwnode_get_name(ch_node), tc_name, val); fwnode_get_name(ch_node), tc_name, val);
fwnode_handle_put(tc_node);
return -EINVAL; return -EINVAL;
} }
@ -803,14 +797,11 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626,
dev_err(&client->dev, dev_err(&client->dev,
"Invalid %s %s threshold: %u\n", "Invalid %s %s threshold: %u\n",
fwnode_get_name(ch_node), tc_name, val); fwnode_get_name(ch_node), tc_name, val);
fwnode_handle_put(tc_node);
return -EINVAL; return -EINVAL;
} }
*thresh = val; *thresh = val;
} }
fwnode_handle_put(tc_node);
} }
if (!fwnode_property_present(ch_node, "linux,keycodes")) if (!fwnode_property_present(ch_node, "linux,keycodes"))
@ -1233,7 +1224,6 @@ static int iqs626_parse_prop(struct iqs626_private *iqs626)
{ {
struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg;
struct i2c_client *client = iqs626->client; struct i2c_client *client = iqs626->client;
struct fwnode_handle *ch_node;
unsigned int val; unsigned int val;
int error, i; int error, i;
u16 general; u16 general;
@ -1375,13 +1365,13 @@ static int iqs626_parse_prop(struct iqs626_private *iqs626)
sys_reg->active = 0; sys_reg->active = 0;
for (i = 0; i < ARRAY_SIZE(iqs626_channels); i++) { for (i = 0; i < ARRAY_SIZE(iqs626_channels); i++) {
ch_node = device_get_named_child_node(&client->dev, struct fwnode_handle *ch_node __free(fwnode_handle) =
iqs626_channels[i].name); device_get_named_child_node(&client->dev,
iqs626_channels[i].name);
if (!ch_node) if (!ch_node)
continue; continue;
error = iqs626_parse_channel(iqs626, ch_node, i); error = iqs626_parse_channel(iqs626, ch_node, i);
fwnode_handle_put(ch_node);
if (error) if (error)
return error; return error;

View File

@ -2385,9 +2385,9 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,
for (i = 0; i < ARRAY_SIZE(iqs7222_kp_events); i++) { for (i = 0; i < ARRAY_SIZE(iqs7222_kp_events); i++) {
const char *event_name = iqs7222_kp_events[i].name; const char *event_name = iqs7222_kp_events[i].name;
u16 event_enable = iqs7222_kp_events[i].enable; u16 event_enable = iqs7222_kp_events[i].enable;
struct fwnode_handle *event_node;
event_node = fwnode_get_named_child_node(chan_node, event_name); struct fwnode_handle *event_node __free(fwnode_handle) =
fwnode_get_named_child_node(chan_node, event_name);
if (!event_node) if (!event_node)
continue; continue;
@ -2408,7 +2408,6 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,
dev_err(&client->dev, dev_err(&client->dev,
"Invalid %s press timeout: %u\n", "Invalid %s press timeout: %u\n",
fwnode_get_name(event_node), val); fwnode_get_name(event_node), val);
fwnode_handle_put(event_node);
return -EINVAL; return -EINVAL;
} }
@ -2418,7 +2417,6 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,
dev_err(&client->dev, dev_err(&client->dev,
"Failed to read %s press timeout: %d\n", "Failed to read %s press timeout: %d\n",
fwnode_get_name(event_node), error); fwnode_get_name(event_node), error);
fwnode_handle_put(event_node);
return error; return error;
} }
@ -2429,7 +2427,6 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,
dev_desc->touch_link - (i ? 0 : 2), dev_desc->touch_link - (i ? 0 : 2),
&iqs7222->kp_type[chan_index][i], &iqs7222->kp_type[chan_index][i],
&iqs7222->kp_code[chan_index][i]); &iqs7222->kp_code[chan_index][i]);
fwnode_handle_put(event_node);
if (error) if (error)
return error; return error;
@ -2604,10 +2601,10 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,
for (i = 0; i < ARRAY_SIZE(iqs7222_sl_events); i++) { for (i = 0; i < ARRAY_SIZE(iqs7222_sl_events); i++) {
const char *event_name = iqs7222_sl_events[i].name; const char *event_name = iqs7222_sl_events[i].name;
struct fwnode_handle *event_node;
enum iqs7222_reg_key_id reg_key; enum iqs7222_reg_key_id reg_key;
event_node = fwnode_get_named_child_node(sldr_node, event_name); struct fwnode_handle *event_node __free(fwnode_handle) =
fwnode_get_named_child_node(sldr_node, event_name);
if (!event_node) if (!event_node)
continue; continue;
@ -2639,7 +2636,6 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,
: sldr_setup[4 + reg_offset], : sldr_setup[4 + reg_offset],
NULL, NULL,
&iqs7222->sl_code[sldr_index][i]); &iqs7222->sl_code[sldr_index][i]);
fwnode_handle_put(event_node);
if (error) if (error)
return error; return error;
@ -2742,9 +2738,9 @@ static int iqs7222_parse_tpad(struct iqs7222_private *iqs7222,
for (i = 0; i < ARRAY_SIZE(iqs7222_tp_events); i++) { for (i = 0; i < ARRAY_SIZE(iqs7222_tp_events); i++) {
const char *event_name = iqs7222_tp_events[i].name; const char *event_name = iqs7222_tp_events[i].name;
struct fwnode_handle *event_node;
event_node = fwnode_get_named_child_node(tpad_node, event_name); struct fwnode_handle *event_node __free(fwnode_handle) =
fwnode_get_named_child_node(tpad_node, event_name);
if (!event_node) if (!event_node)
continue; continue;
@ -2760,7 +2756,6 @@ static int iqs7222_parse_tpad(struct iqs7222_private *iqs7222,
iqs7222_tp_events[i].link, 1566, iqs7222_tp_events[i].link, 1566,
NULL, NULL,
&iqs7222->tp_code[i]); &iqs7222->tp_code[i]);
fwnode_handle_put(event_node);
if (error) if (error)
return error; return error;
@ -2818,9 +2813,9 @@ static int iqs7222_parse_reg_grp(struct iqs7222_private *iqs7222,
int reg_grp_index) int reg_grp_index)
{ {
struct i2c_client *client = iqs7222->client; struct i2c_client *client = iqs7222->client;
struct fwnode_handle *reg_grp_node;
int error; int error;
struct fwnode_handle *reg_grp_node __free(fwnode_handle) = NULL;
if (iqs7222_reg_grp_names[reg_grp]) { if (iqs7222_reg_grp_names[reg_grp]) {
char reg_grp_name[16]; char reg_grp_name[16];
@ -2838,14 +2833,17 @@ static int iqs7222_parse_reg_grp(struct iqs7222_private *iqs7222,
error = iqs7222_parse_props(iqs7222, reg_grp_node, reg_grp_index, error = iqs7222_parse_props(iqs7222, reg_grp_node, reg_grp_index,
reg_grp, IQS7222_REG_KEY_NONE); reg_grp, IQS7222_REG_KEY_NONE);
if (error)
return error;
if (!error && iqs7222_parse_extra[reg_grp]) if (iqs7222_parse_extra[reg_grp]) {
error = iqs7222_parse_extra[reg_grp](iqs7222, reg_grp_node, error = iqs7222_parse_extra[reg_grp](iqs7222, reg_grp_node,
reg_grp_index); reg_grp_index);
if (error)
return error;
}
fwnode_handle_put(reg_grp_node); return 0;
return error;
} }
static int iqs7222_parse_all(struct iqs7222_private *iqs7222) static int iqs7222_parse_all(struct iqs7222_private *iqs7222)

View File

@ -25,7 +25,7 @@
/* CONTROL REGISTER 1 BITS */ /* CONTROL REGISTER 1 BITS */
#define PC1_OFF 0x7F #define PC1_OFF 0x7F
#define PC1_ON (1 << 7) #define PC1_ON (1 << 7)
/* Data ready funtion enable bit: set during probe if using irq mode */ /* Data ready function enable bit: set during probe if using irq mode */
#define DRDYE (1 << 5) #define DRDYE (1 << 5)
/* DATA CONTROL REGISTER BITS */ /* DATA CONTROL REGISTER BITS */
#define ODR12_5F 0 #define ODR12_5F 0
@ -314,9 +314,8 @@ static ssize_t kxtj9_set_poll(struct device *dev, struct device_attribute *attr,
return error; return error;
/* Lock the device to prevent races with open/close (and itself) */ /* Lock the device to prevent races with open/close (and itself) */
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
guard(disable_irq)(&client->irq);
disable_irq(client->irq);
/* /*
* Set current interval to the greater of the minimum interval or * Set current interval to the greater of the minimum interval or
@ -326,9 +325,6 @@ static ssize_t kxtj9_set_poll(struct device *dev, struct device_attribute *attr,
kxtj9_update_odr(tj9, tj9->last_poll_interval); kxtj9_update_odr(tj9, tj9->last_poll_interval);
enable_irq(client->irq);
mutex_unlock(&input_dev->mutex);
return count; return count;
} }
@ -504,12 +500,11 @@ static int kxtj9_suspend(struct device *dev)
struct kxtj9_data *tj9 = i2c_get_clientdata(client); struct kxtj9_data *tj9 = i2c_get_clientdata(client);
struct input_dev *input_dev = tj9->input_dev; struct input_dev *input_dev = tj9->input_dev;
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev)) if (input_device_enabled(input_dev))
kxtj9_disable(tj9); kxtj9_disable(tj9);
mutex_unlock(&input_dev->mutex);
return 0; return 0;
} }
@ -519,12 +514,11 @@ static int kxtj9_resume(struct device *dev)
struct kxtj9_data *tj9 = i2c_get_clientdata(client); struct kxtj9_data *tj9 = i2c_get_clientdata(client);
struct input_dev *input_dev = tj9->input_dev; struct input_dev *input_dev = tj9->input_dev;
mutex_lock(&input_dev->mutex); guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev)) if (input_device_enabled(input_dev))
kxtj9_enable(tj9); kxtj9_enable(tj9);
mutex_unlock(&input_dev->mutex);
return 0; return 0;
} }

View File

@ -95,7 +95,7 @@ static struct platform_driver m68kspkr_platform_driver = {
.name = "m68kspkr", .name = "m68kspkr",
}, },
.probe = m68kspkr_probe, .probe = m68kspkr_probe,
.remove_new = m68kspkr_remove, .remove = m68kspkr_remove,
.shutdown = m68kspkr_shutdown, .shutdown = m68kspkr_shutdown,
}; };

View File

@ -153,19 +153,19 @@ static void max8997_haptic_enable(struct max8997_haptic *chip)
{ {
int error; int error;
mutex_lock(&chip->mutex); guard(mutex)(&chip->mutex);
error = max8997_haptic_set_duty_cycle(chip); error = max8997_haptic_set_duty_cycle(chip);
if (error) { if (error) {
dev_err(chip->dev, "set_pwm_cycle failed, error: %d\n", error); dev_err(chip->dev, "set_pwm_cycle failed, error: %d\n", error);
goto out; return;
} }
if (!chip->enabled) { if (!chip->enabled) {
error = regulator_enable(chip->regulator); error = regulator_enable(chip->regulator);
if (error) { if (error) {
dev_err(chip->dev, "Failed to enable regulator\n"); dev_err(chip->dev, "Failed to enable regulator\n");
goto out; return;
} }
max8997_haptic_configure(chip); max8997_haptic_configure(chip);
if (chip->mode == MAX8997_EXTERNAL_MODE) { if (chip->mode == MAX8997_EXTERNAL_MODE) {
@ -173,19 +173,16 @@ static void max8997_haptic_enable(struct max8997_haptic *chip)
if (error) { if (error) {
dev_err(chip->dev, "Failed to enable PWM\n"); dev_err(chip->dev, "Failed to enable PWM\n");
regulator_disable(chip->regulator); regulator_disable(chip->regulator);
goto out; return;
} }
} }
chip->enabled = true; chip->enabled = true;
} }
out:
mutex_unlock(&chip->mutex);
} }
static void max8997_haptic_disable(struct max8997_haptic *chip) static void max8997_haptic_disable(struct max8997_haptic *chip)
{ {
mutex_lock(&chip->mutex); guard(mutex)(&chip->mutex);
if (chip->enabled) { if (chip->enabled) {
chip->enabled = false; chip->enabled = false;
@ -194,8 +191,6 @@ static void max8997_haptic_disable(struct max8997_haptic *chip)
pwm_disable(chip->pwm); pwm_disable(chip->pwm);
regulator_disable(chip->regulator); regulator_disable(chip->regulator);
} }
mutex_unlock(&chip->mutex);
} }
static void max8997_haptic_play_effect_work(struct work_struct *work) static void max8997_haptic_play_effect_work(struct work_struct *work)
@ -389,7 +384,7 @@ static struct platform_driver max8997_haptic_driver = {
.pm = pm_sleep_ptr(&max8997_haptic_pm_ops), .pm = pm_sleep_ptr(&max8997_haptic_pm_ops),
}, },
.probe = max8997_haptic_probe, .probe = max8997_haptic_probe,
.remove_new = max8997_haptic_remove, .remove = max8997_haptic_remove,
.id_table = max8997_haptic_id, .id_table = max8997_haptic_id,
}; };
module_platform_driver(max8997_haptic_driver); module_platform_driver(max8997_haptic_driver);

View File

@ -253,7 +253,7 @@ static void mc13783_pwrbutton_remove(struct platform_device *pdev)
static struct platform_driver mc13783_pwrbutton_driver = { static struct platform_driver mc13783_pwrbutton_driver = {
.probe = mc13783_pwrbutton_probe, .probe = mc13783_pwrbutton_probe,
.remove_new = mc13783_pwrbutton_remove, .remove = mc13783_pwrbutton_remove,
.driver = { .driver = {
.name = "mc13783-pwrbutton", .name = "mc13783-pwrbutton",
}, },

View File

@ -310,7 +310,7 @@ MODULE_DEVICE_TABLE(of, of_palmas_pwr_match);
static struct platform_driver palmas_pwron_driver = { static struct platform_driver palmas_pwron_driver = {
.probe = palmas_pwron_probe, .probe = palmas_pwron_probe,
.remove_new = palmas_pwron_remove, .remove = palmas_pwron_remove,
.driver = { .driver = {
.name = "palmas_pwrbutton", .name = "palmas_pwrbutton",
.of_match_table = of_match_ptr(of_palmas_pwr_match), .of_match_table = of_match_ptr(of_palmas_pwr_match),

View File

@ -112,7 +112,7 @@ static void pcap_keys_remove(struct platform_device *pdev)
static struct platform_driver pcap_keys_device_driver = { static struct platform_driver pcap_keys_device_driver = {
.probe = pcap_keys_probe, .probe = pcap_keys_probe,
.remove_new = pcap_keys_remove, .remove = pcap_keys_remove,
.driver = { .driver = {
.name = "pcap-keys", .name = "pcap-keys",
} }

View File

@ -103,7 +103,7 @@ static struct platform_driver pcf50633_input_driver = {
.name = "pcf50633-input", .name = "pcf50633-input",
}, },
.probe = pcf50633_input_probe, .probe = pcf50633_input_probe,
.remove_new = pcf50633_input_remove, .remove = pcf50633_input_remove,
}; };
module_platform_driver(pcf50633_input_driver); module_platform_driver(pcf50633_input_driver);

View File

@ -127,7 +127,7 @@ static struct platform_driver pcspkr_platform_driver = {
.pm = &pcspkr_pm_ops, .pm = &pcspkr_pm_ops,
}, },
.probe = pcspkr_probe, .probe = pcspkr_probe,
.remove_new = pcspkr_remove, .remove = pcspkr_remove,
.shutdown = pcspkr_shutdown, .shutdown = pcspkr_shutdown,
}; };
module_platform_driver(pcspkr_platform_driver); module_platform_driver(pcspkr_platform_driver);

View File

@ -465,7 +465,7 @@ MODULE_DEVICE_TABLE(of, pm8941_pwr_key_id_table);
static struct platform_driver pm8941_pwrkey_driver = { static struct platform_driver pm8941_pwrkey_driver = {
.probe = pm8941_pwrkey_probe, .probe = pm8941_pwrkey_probe,
.remove_new = pm8941_pwrkey_remove, .remove = pm8941_pwrkey_remove,
.driver = { .driver = {
.name = "pm8941-pwrkey", .name = "pm8941-pwrkey",
.pm = pm_sleep_ptr(&pm8941_pwr_key_pm_ops), .pm = pm_sleep_ptr(&pm8941_pwr_key_pm_ops),

View File

@ -194,22 +194,18 @@ static void powermate_sync_state(struct powermate_device *pm)
static void powermate_config_complete(struct urb *urb) static void powermate_config_complete(struct urb *urb)
{ {
struct powermate_device *pm = urb->context; struct powermate_device *pm = urb->context;
unsigned long flags;
if (urb->status) if (urb->status)
printk(KERN_ERR "powermate: config urb returned %d\n", urb->status); printk(KERN_ERR "powermate: config urb returned %d\n", urb->status);
spin_lock_irqsave(&pm->lock, flags); guard(spinlock_irqsave)(&pm->lock);
powermate_sync_state(pm); powermate_sync_state(pm);
spin_unlock_irqrestore(&pm->lock, flags);
} }
/* Set the LED up as described and begin the sync with the hardware if required */ /* Set the LED up as described and begin the sync with the hardware if required */
static void powermate_pulse_led(struct powermate_device *pm, int static_brightness, int pulse_speed, static void powermate_pulse_led(struct powermate_device *pm, int static_brightness, int pulse_speed,
int pulse_table, int pulse_asleep, int pulse_awake) int pulse_table, int pulse_asleep, int pulse_awake)
{ {
unsigned long flags;
if (pulse_speed < 0) if (pulse_speed < 0)
pulse_speed = 0; pulse_speed = 0;
if (pulse_table < 0) if (pulse_table < 0)
@ -222,8 +218,7 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne
pulse_asleep = !!pulse_asleep; pulse_asleep = !!pulse_asleep;
pulse_awake = !!pulse_awake; pulse_awake = !!pulse_awake;
guard(spinlock_irqsave)(&pm->lock);
spin_lock_irqsave(&pm->lock, flags);
/* mark state updates which are required */ /* mark state updates which are required */
if (static_brightness != pm->static_brightness) { if (static_brightness != pm->static_brightness) {
@ -245,8 +240,6 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne
} }
powermate_sync_state(pm); powermate_sync_state(pm);
spin_unlock_irqrestore(&pm->lock, flags);
} }
/* Callback from the Input layer when an event arrives from userspace to configure the LED */ /* Callback from the Input layer when an event arrives from userspace to configure the LED */

View File

@ -203,9 +203,9 @@ static int pwm_beeper_suspend(struct device *dev)
* beeper->suspended, but to ensure that pwm_beeper_event * beeper->suspended, but to ensure that pwm_beeper_event
* does not re-submit work once flag is set. * does not re-submit work once flag is set.
*/ */
spin_lock_irq(&beeper->input->event_lock); scoped_guard(spinlock_irq, &beeper->input->event_lock) {
beeper->suspended = true; beeper->suspended = true;
spin_unlock_irq(&beeper->input->event_lock); }
pwm_beeper_stop(beeper); pwm_beeper_stop(beeper);
@ -216,9 +216,9 @@ static int pwm_beeper_resume(struct device *dev)
{ {
struct pwm_beeper *beeper = dev_get_drvdata(dev); struct pwm_beeper *beeper = dev_get_drvdata(dev);
spin_lock_irq(&beeper->input->event_lock); scoped_guard(spinlock_irq, &beeper->input->event_lock) {
beeper->suspended = false; beeper->suspended = false;
spin_unlock_irq(&beeper->input->event_lock); }
/* Let worker figure out if we should resume beeping */ /* Let worker figure out if we should resume beeping */
schedule_work(&beeper->work); schedule_work(&beeper->work);

View File

@ -83,12 +83,10 @@ static void regulator_haptic_work(struct work_struct *work)
struct regulator_haptic *haptic = container_of(work, struct regulator_haptic *haptic = container_of(work,
struct regulator_haptic, work); struct regulator_haptic, work);
mutex_lock(&haptic->mutex); guard(mutex)(&haptic->mutex);
if (!haptic->suspended) if (!haptic->suspended)
regulator_haptic_set_voltage(haptic, haptic->magnitude); regulator_haptic_set_voltage(haptic, haptic->magnitude);
mutex_unlock(&haptic->mutex);
} }
static int regulator_haptic_play_effect(struct input_dev *input, void *data, static int regulator_haptic_play_effect(struct input_dev *input, void *data,
@ -205,19 +203,15 @@ static int regulator_haptic_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct regulator_haptic *haptic = platform_get_drvdata(pdev); struct regulator_haptic *haptic = platform_get_drvdata(pdev);
int error;
error = mutex_lock_interruptible(&haptic->mutex); scoped_guard(mutex_intr, &haptic->mutex) {
if (error) regulator_haptic_set_voltage(haptic, 0);
return error; haptic->suspended = true;
regulator_haptic_set_voltage(haptic, 0); return 0;
}
haptic->suspended = true; return -EINTR;
mutex_unlock(&haptic->mutex);
return 0;
} }
static int regulator_haptic_resume(struct device *dev) static int regulator_haptic_resume(struct device *dev)
@ -226,7 +220,7 @@ static int regulator_haptic_resume(struct device *dev)
struct regulator_haptic *haptic = platform_get_drvdata(pdev); struct regulator_haptic *haptic = platform_get_drvdata(pdev);
unsigned int magnitude; unsigned int magnitude;
mutex_lock(&haptic->mutex); guard(mutex)(&haptic->mutex);
haptic->suspended = false; haptic->suspended = false;
@ -234,8 +228,6 @@ static int regulator_haptic_resume(struct device *dev)
if (magnitude) if (magnitude)
regulator_haptic_set_voltage(haptic, magnitude); regulator_haptic_set_voltage(haptic, magnitude);
mutex_unlock(&haptic->mutex);
return 0; return 0;
} }

View File

@ -106,7 +106,7 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
struct rotary_encoder *encoder = dev_id; struct rotary_encoder *encoder = dev_id;
unsigned int state; unsigned int state;
mutex_lock(&encoder->access_mutex); guard(mutex)(&encoder->access_mutex);
state = rotary_encoder_get_state(encoder); state = rotary_encoder_get_state(encoder);
@ -129,8 +129,6 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
break; break;
} }
mutex_unlock(&encoder->access_mutex);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
@ -139,7 +137,7 @@ static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id)
struct rotary_encoder *encoder = dev_id; struct rotary_encoder *encoder = dev_id;
unsigned int state; unsigned int state;
mutex_lock(&encoder->access_mutex); guard(mutex)(&encoder->access_mutex);
state = rotary_encoder_get_state(encoder); state = rotary_encoder_get_state(encoder);
@ -152,8 +150,6 @@ static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id)
} }
} }
mutex_unlock(&encoder->access_mutex);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
@ -162,22 +158,19 @@ static irqreturn_t rotary_encoder_quarter_period_irq(int irq, void *dev_id)
struct rotary_encoder *encoder = dev_id; struct rotary_encoder *encoder = dev_id;
unsigned int state; unsigned int state;
mutex_lock(&encoder->access_mutex); guard(mutex)(&encoder->access_mutex);
state = rotary_encoder_get_state(encoder); state = rotary_encoder_get_state(encoder);
if ((encoder->last_stable + 1) % 4 == state) if ((encoder->last_stable + 1) % 4 == state) {
encoder->dir = 1; encoder->dir = 1;
else if (encoder->last_stable == (state + 1) % 4) rotary_encoder_report_event(encoder);
} else if (encoder->last_stable == (state + 1) % 4) {
encoder->dir = -1; encoder->dir = -1;
else rotary_encoder_report_event(encoder);
goto out; }
rotary_encoder_report_event(encoder);
out:
encoder->last_stable = state; encoder->last_stable = state;
mutex_unlock(&encoder->access_mutex);
return IRQ_HANDLED; return IRQ_HANDLED;
} }

View File

@ -515,7 +515,7 @@ static const struct soc_device_data soc_device_INT33D3 = {
}; };
/* /*
* Button info for Microsoft Surface 3 (non pro), this is indentical to * Button info for Microsoft Surface 3 (non pro), this is identical to
* the PNP0C40 info except that the home button is active-high. * the PNP0C40 info except that the home button is active-high.
* *
* The Surface 3 Pro also has a MSHW0028 ACPI device, but that uses a custom * The Surface 3 Pro also has a MSHW0028 ACPI device, but that uses a custom
@ -612,7 +612,7 @@ MODULE_DEVICE_TABLE(acpi, soc_button_acpi_match);
static struct platform_driver soc_button_driver = { static struct platform_driver soc_button_driver = {
.probe = soc_button_probe, .probe = soc_button_probe,
.remove_new = soc_button_remove, .remove = soc_button_remove,
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.acpi_match_table = ACPI_PTR(soc_button_acpi_match), .acpi_match_table = ACPI_PTR(soc_button_acpi_match),

View File

@ -69,7 +69,6 @@ static int bbc_spkr_event(struct input_dev *dev, unsigned int type, unsigned int
struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent); struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent);
struct bbc_beep_info *info = &state->u.bbc; struct bbc_beep_info *info = &state->u.bbc;
unsigned int count = 0; unsigned int count = 0;
unsigned long flags;
if (type != EV_SND) if (type != EV_SND)
return -1; return -1;
@ -85,7 +84,7 @@ static int bbc_spkr_event(struct input_dev *dev, unsigned int type, unsigned int
count = bbc_count_to_reg(info, count); count = bbc_count_to_reg(info, count);
spin_lock_irqsave(&state->lock, flags); guard(spinlock_irqsave)(&state->lock);
if (count) { if (count) {
sbus_writeb(0x01, info->regs + 0); sbus_writeb(0x01, info->regs + 0);
@ -97,8 +96,6 @@ static int bbc_spkr_event(struct input_dev *dev, unsigned int type, unsigned int
sbus_writeb(0x00, info->regs + 0); sbus_writeb(0x00, info->regs + 0);
} }
spin_unlock_irqrestore(&state->lock, flags);
return 0; return 0;
} }
@ -107,7 +104,6 @@ static int grover_spkr_event(struct input_dev *dev, unsigned int type, unsigned
struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent); struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent);
struct grover_beep_info *info = &state->u.grover; struct grover_beep_info *info = &state->u.grover;
unsigned int count = 0; unsigned int count = 0;
unsigned long flags;
if (type != EV_SND) if (type != EV_SND)
return -1; return -1;
@ -121,7 +117,7 @@ static int grover_spkr_event(struct input_dev *dev, unsigned int type, unsigned
if (value > 20 && value < 32767) if (value > 20 && value < 32767)
count = 1193182 / value; count = 1193182 / value;
spin_lock_irqsave(&state->lock, flags); guard(spinlock_irqsave)(&state->lock);
if (count) { if (count) {
/* enable counter 2 */ /* enable counter 2 */
@ -136,8 +132,6 @@ static int grover_spkr_event(struct input_dev *dev, unsigned int type, unsigned
sbus_writeb(sbus_readb(info->enable_reg) & 0xFC, info->enable_reg); sbus_writeb(sbus_readb(info->enable_reg) & 0xFC, info->enable_reg);
} }
spin_unlock_irqrestore(&state->lock, flags);
return 0; return 0;
} }
@ -188,47 +182,38 @@ static int bbc_beep_probe(struct platform_device *op)
{ {
struct sparcspkr_state *state; struct sparcspkr_state *state;
struct bbc_beep_info *info; struct bbc_beep_info *info;
struct device_node *dp; int err;
int err = -ENOMEM;
state = kzalloc(sizeof(*state), GFP_KERNEL); state = devm_kzalloc(&op->dev, sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
goto out_err; return -ENOMEM;
state->name = "Sparc BBC Speaker"; state->name = "Sparc BBC Speaker";
state->event = bbc_spkr_event; state->event = bbc_spkr_event;
spin_lock_init(&state->lock); spin_lock_init(&state->lock);
dp = of_find_node_by_path("/"); struct device_node *dp __free(device_node) = of_find_node_by_path("/");
err = -ENODEV;
if (!dp) if (!dp)
goto out_free; return -ENODEV;
info = &state->u.bbc; info = &state->u.bbc;
info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0); info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0);
of_node_put(dp);
if (!info->clock_freq) if (!info->clock_freq)
goto out_free; return -ENODEV;
info->regs = of_ioremap(&op->resource[0], 0, 6, "bbc beep"); info->regs = of_ioremap(&op->resource[0], 0, 6, "bbc beep");
if (!info->regs) if (!info->regs)
goto out_free; return -ENODEV;
platform_set_drvdata(op, state); platform_set_drvdata(op, state);
err = sparcspkr_probe(&op->dev); err = sparcspkr_probe(&op->dev);
if (err) if (err) {
goto out_clear_drvdata; of_iounmap(&op->resource[0], info->regs, 6);
return err;
}
return 0; return 0;
out_clear_drvdata:
of_iounmap(&op->resource[0], info->regs, 6);
out_free:
kfree(state);
out_err:
return err;
} }
static void bbc_remove(struct platform_device *op) static void bbc_remove(struct platform_device *op)
@ -243,8 +228,6 @@ static void bbc_remove(struct platform_device *op)
input_unregister_device(input_dev); input_unregister_device(input_dev);
of_iounmap(&op->resource[0], info->regs, 6); of_iounmap(&op->resource[0], info->regs, 6);
kfree(state);
} }
static const struct of_device_id bbc_beep_match[] = { static const struct of_device_id bbc_beep_match[] = {
@ -262,7 +245,7 @@ static struct platform_driver bbc_beep_driver = {
.of_match_table = bbc_beep_match, .of_match_table = bbc_beep_match,
}, },
.probe = bbc_beep_probe, .probe = bbc_beep_probe,
.remove_new = bbc_remove, .remove = bbc_remove,
.shutdown = sparcspkr_shutdown, .shutdown = sparcspkr_shutdown,
}; };
@ -272,9 +255,9 @@ static int grover_beep_probe(struct platform_device *op)
struct grover_beep_info *info; struct grover_beep_info *info;
int err = -ENOMEM; int err = -ENOMEM;
state = kzalloc(sizeof(*state), GFP_KERNEL); state = devm_kzalloc(&op->dev, sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
goto out_err; return err;
state->name = "Sparc Grover Speaker"; state->name = "Sparc Grover Speaker";
state->event = grover_spkr_event; state->event = grover_spkr_event;
@ -283,7 +266,7 @@ static int grover_beep_probe(struct platform_device *op)
info = &state->u.grover; info = &state->u.grover;
info->freq_regs = of_ioremap(&op->resource[2], 0, 2, "grover beep freq"); info->freq_regs = of_ioremap(&op->resource[2], 0, 2, "grover beep freq");
if (!info->freq_regs) if (!info->freq_regs)
goto out_free; return err;
info->enable_reg = of_ioremap(&op->resource[3], 0, 1, "grover beep enable"); info->enable_reg = of_ioremap(&op->resource[3], 0, 1, "grover beep enable");
if (!info->enable_reg) if (!info->enable_reg)
@ -302,9 +285,7 @@ out_clear_drvdata:
out_unmap_freq_regs: out_unmap_freq_regs:
of_iounmap(&op->resource[2], info->freq_regs, 2); of_iounmap(&op->resource[2], info->freq_regs, 2);
out_free:
kfree(state);
out_err:
return err; return err;
} }
@ -321,8 +302,6 @@ static void grover_remove(struct platform_device *op)
of_iounmap(&op->resource[3], info->enable_reg, 1); of_iounmap(&op->resource[3], info->enable_reg, 1);
of_iounmap(&op->resource[2], info->freq_regs, 2); of_iounmap(&op->resource[2], info->freq_regs, 2);
kfree(state);
} }
static const struct of_device_id grover_beep_match[] = { static const struct of_device_id grover_beep_match[] = {
@ -340,7 +319,7 @@ static struct platform_driver grover_beep_driver = {
.of_match_table = grover_beep_match, .of_match_table = grover_beep_match,
}, },
.probe = grover_beep_probe, .probe = grover_beep_probe,
.remove_new = grover_remove, .remove = grover_remove,
.shutdown = sparcspkr_shutdown, .shutdown = sparcspkr_shutdown,
}; };

View File

@ -137,7 +137,7 @@ MODULE_DEVICE_TABLE(platform, tps65219_pwrbtn_id_table);
static struct platform_driver tps65219_pb_driver = { static struct platform_driver tps65219_pb_driver = {
.probe = tps65219_pb_probe, .probe = tps65219_pb_probe,
.remove_new = tps65219_pb_remove, .remove = tps65219_pb_remove,
.driver = { .driver = {
.name = "tps65219_pwrbutton", .name = "tps65219_pwrbutton",
}, },

View File

@ -165,15 +165,10 @@ static DEFINE_SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops,
static bool twl4030_vibra_check_coexist(struct device_node *parent) static bool twl4030_vibra_check_coexist(struct device_node *parent)
{ {
struct device_node *node; struct device_node *node __free(device_node) =
of_get_child_by_name(parent, "codec");
node = of_get_child_by_name(parent, "codec"); return node != NULL;
if (node) {
of_node_put(node);
return true;
}
return false;
} }
static int twl4030_vibra_probe(struct platform_device *pdev) static int twl4030_vibra_probe(struct platform_device *pdev)

View File

@ -229,14 +229,13 @@ static DEFINE_SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops,
static int twl6040_vibra_probe(struct platform_device *pdev) static int twl6040_vibra_probe(struct platform_device *pdev)
{ {
struct device *twl6040_core_dev = pdev->dev.parent; struct device *twl6040_core_dev = pdev->dev.parent;
struct device_node *twl6040_core_node;
struct vibra_info *info; struct vibra_info *info;
int vddvibl_uV = 0; int vddvibl_uV = 0;
int vddvibr_uV = 0; int vddvibr_uV = 0;
int error; int error;
twl6040_core_node = of_get_child_by_name(twl6040_core_dev->of_node, struct device_node *twl6040_core_node __free(device_node) =
"vibra"); of_get_child_by_name(twl6040_core_dev->of_node, "vibra");
if (!twl6040_core_node) { if (!twl6040_core_node) {
dev_err(&pdev->dev, "parent of node is missing?\n"); dev_err(&pdev->dev, "parent of node is missing?\n");
return -EINVAL; return -EINVAL;
@ -244,7 +243,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info) { if (!info) {
of_node_put(twl6040_core_node);
dev_err(&pdev->dev, "couldn't allocate memory\n"); dev_err(&pdev->dev, "couldn't allocate memory\n");
return -ENOMEM; return -ENOMEM;
} }
@ -264,8 +262,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", &vddvibl_uV); of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", &vddvibl_uV);
of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", &vddvibr_uV); of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", &vddvibr_uV);
of_node_put(twl6040_core_node);
if ((!info->vibldrv_res && !info->viblmotor_res) || if ((!info->vibldrv_res && !info->viblmotor_res) ||
(!info->vibrdrv_res && !info->vibrmotor_res)) { (!info->vibrdrv_res && !info->vibrmotor_res)) {
dev_err(info->dev, "invalid vibra driver/motor resistance\n"); dev_err(info->dev, "invalid vibra driver/motor resistance\n");

View File

@ -271,7 +271,7 @@ static struct key_entry keymap_fs_amilo_pro_v8210[] __initdata = {
{ KE_BLUETOOTH, 0x30 }, /* Fn+F10 */ { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */
{ KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */ { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */
{ KE_KEY, 0x36, {KEY_WWW} }, /* www button */ { KE_KEY, 0x36, {KEY_WWW} }, /* www button */
{ KE_WIFI, 0x78 }, /* satelite dish button */ { KE_WIFI, 0x78 }, /* satellite dish button */
{ KE_END, FE_WIFI_LED } { KE_END, FE_WIFI_LED }
}; };
@ -1334,7 +1334,7 @@ static struct platform_driver wistron_driver = {
.pm = pm_sleep_ptr(&wistron_pm_ops), .pm = pm_sleep_ptr(&wistron_pm_ops),
}, },
.probe = wistron_probe, .probe = wistron_probe,
.remove_new = wistron_remove, .remove = wistron_remove,
}; };
static int __init wb_module_init(void) static int __init wb_module_init(void)

View File

@ -134,7 +134,7 @@ static void wm831x_on_remove(struct platform_device *pdev)
static struct platform_driver wm831x_on_driver = { static struct platform_driver wm831x_on_driver = {
.probe = wm831x_on_probe, .probe = wm831x_on_probe,
.remove_new = wm831x_on_remove, .remove = wm831x_on_remove,
.driver = { .driver = {
.name = "wm831x-on", .name = "wm831x-on",
}, },

View File

@ -377,7 +377,7 @@ send_update:
if (len > sizeof(yld->ctl_data->data)) if (len > sizeof(yld->ctl_data->data))
len = sizeof(yld->ctl_data->data); len = sizeof(yld->ctl_data->data);
/* Combine up to <len> consecutive LCD bytes in a singe request /* Combine up to <len> consecutive LCD bytes in a single request
*/ */
yld->ctl_data->cmd = CMD_LCD; yld->ctl_data->cmd = CMD_LCD;
yld->ctl_data->offset = cpu_to_be16(ix); yld->ctl_data->offset = cpu_to_be16(ix);
@ -614,7 +614,7 @@ static ssize_t show_line3(struct device *dev, struct device_attribute *attr,
return show_line(dev, buf, LCD_LINE3_OFFSET, LCD_LINE4_OFFSET); return show_line(dev, buf, LCD_LINE3_OFFSET, LCD_LINE4_OFFSET);
} }
/* Writing to /sys/../lineX will set the coresponding LCD line. /* Writing to /sys/../lineX will set the corresponding LCD line.
* - Excess characters are ignored. * - Excess characters are ignored.
* - If less characters are written than allowed, the remaining digits are * - If less characters are written than allowed, the remaining digits are
* unchanged. * unchanged.

View File

@ -1585,7 +1585,7 @@ static void alps_flush_packet(struct timer_list *t)
struct alps_data *priv = from_timer(priv, t, timer); struct alps_data *priv = from_timer(priv, t, timer);
struct psmouse *psmouse = priv->psmouse; struct psmouse *psmouse = priv->psmouse;
serio_pause_rx(psmouse->ps2dev.serio); guard(serio_pause_rx)(psmouse->ps2dev.serio);
if (psmouse->pktcnt == psmouse->pktsize) { if (psmouse->pktcnt == psmouse->pktsize) {
@ -1605,8 +1605,6 @@ static void alps_flush_packet(struct timer_list *t)
} }
psmouse->pktcnt = 0; psmouse->pktcnt = 0;
} }
serio_continue_rx(psmouse->ps2dev.serio);
} }
static psmouse_ret_t alps_process_byte(struct psmouse *psmouse) static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)

View File

@ -139,7 +139,7 @@ static void __exit amimouse_remove(struct platform_device *pdev)
* triggering a section mismatch warning. * triggering a section mismatch warning.
*/ */
static struct platform_driver amimouse_driver __refdata = { static struct platform_driver amimouse_driver __refdata = {
.remove_new = __exit_p(amimouse_remove), .remove = __exit_p(amimouse_remove),
.driver = { .driver = {
.name = "amiga-mouse", .name = "amiga-mouse",
}, },

View File

@ -254,13 +254,12 @@ static void byd_clear_touch(struct timer_list *t)
struct byd_data *priv = from_timer(priv, t, timer); struct byd_data *priv = from_timer(priv, t, timer);
struct psmouse *psmouse = priv->psmouse; struct psmouse *psmouse = priv->psmouse;
serio_pause_rx(psmouse->ps2dev.serio); guard(serio_pause_rx)(psmouse->ps2dev.serio);
priv->touch = false; priv->touch = false;
byd_report_input(psmouse); byd_report_input(psmouse);
serio_continue_rx(psmouse->ps2dev.serio);
/* /*
* Move cursor back to center of pad when we lose touch - this * Move cursor back to center of pad when we lose touch - this
* specifically improves user experience when moving cursor with one * specifically improves user experience when moving cursor with one

View File

@ -541,7 +541,8 @@ static int elan_update_firmware(struct elan_tp_data *data,
dev_dbg(&client->dev, "Starting firmware update....\n"); dev_dbg(&client->dev, "Starting firmware update....\n");
disable_irq(client->irq); guard(disable_irq)(&client->irq);
data->in_fw_update = true; data->in_fw_update = true;
retval = __elan_update_firmware(data, fw); retval = __elan_update_firmware(data, fw);
@ -555,7 +556,6 @@ static int elan_update_firmware(struct elan_tp_data *data,
} }
data->in_fw_update = false; data->in_fw_update = false;
enable_irq(client->irq);
return retval; return retval;
} }
@ -621,8 +621,6 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct elan_tp_data *data = dev_get_drvdata(dev); struct elan_tp_data *data = dev_get_drvdata(dev);
const struct firmware *fw;
char *fw_name;
int error; int error;
const u8 *fw_signature; const u8 *fw_signature;
static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF}; static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF};
@ -631,15 +629,16 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
return -EINVAL; return -EINVAL;
/* Look for a firmware with the product id appended. */ /* Look for a firmware with the product id appended. */
fw_name = kasprintf(GFP_KERNEL, ETP_FW_NAME, data->product_id); const char *fw_name __free(kfree) =
kasprintf(GFP_KERNEL, ETP_FW_NAME, data->product_id);
if (!fw_name) { if (!fw_name) {
dev_err(dev, "failed to allocate memory for firmware name\n"); dev_err(dev, "failed to allocate memory for firmware name\n");
return -ENOMEM; return -ENOMEM;
} }
dev_info(dev, "requesting fw '%s'\n", fw_name); dev_info(dev, "requesting fw '%s'\n", fw_name);
const struct firmware *fw __free(firmware) = NULL;
error = request_firmware(&fw, fw_name, dev); error = request_firmware(&fw, fw_name, dev);
kfree(fw_name);
if (error) { if (error) {
dev_err(dev, "failed to request firmware: %d\n", error); dev_err(dev, "failed to request firmware: %d\n", error);
return error; return error;
@ -651,46 +650,36 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n", dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n",
(int)sizeof(signature), signature, (int)sizeof(signature), signature,
(int)sizeof(signature), fw_signature); (int)sizeof(signature), fw_signature);
error = -EBADF; return -EBADF;
goto out_release_fw;
} }
error = mutex_lock_interruptible(&data->sysfs_mutex); scoped_cond_guard(mutex_intr, return -EINTR, &data->sysfs_mutex) {
if (error) error = elan_update_firmware(data, fw);
goto out_release_fw; if (error)
return error;
}
error = elan_update_firmware(data, fw); return count;
mutex_unlock(&data->sysfs_mutex);
out_release_fw:
release_firmware(fw);
return error ?: count;
} }
static ssize_t calibrate_store(struct device *dev, static int elan_calibrate(struct elan_tp_data *data)
struct device_attribute *attr,
const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = data->client;
struct elan_tp_data *data = i2c_get_clientdata(client); struct device *dev = &client->dev;
int tries = 20; int tries = 20;
int retval; int retval;
int error; int error;
u8 val[ETP_CALIBRATE_MAX_LEN]; u8 val[ETP_CALIBRATE_MAX_LEN];
retval = mutex_lock_interruptible(&data->sysfs_mutex); guard(disable_irq)(&client->irq);
if (retval)
return retval;
disable_irq(client->irq);
data->mode |= ETP_ENABLE_CALIBRATE; data->mode |= ETP_ENABLE_CALIBRATE;
retval = data->ops->set_mode(client, data->mode); retval = data->ops->set_mode(client, data->mode);
if (retval) { if (retval) {
data->mode &= ~ETP_ENABLE_CALIBRATE;
dev_err(dev, "failed to enable calibration mode: %d\n", dev_err(dev, "failed to enable calibration mode: %d\n",
retval); retval);
goto out; return retval;
} }
retval = data->ops->calibrate(client); retval = data->ops->calibrate(client);
@ -728,10 +717,24 @@ out_disable_calibrate:
if (!retval) if (!retval)
retval = error; retval = error;
} }
out: return retval;
enable_irq(client->irq); }
mutex_unlock(&data->sysfs_mutex);
return retval ?: count; static ssize_t calibrate_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct elan_tp_data *data = i2c_get_clientdata(client);
int error;
scoped_cond_guard(mutex_intr, return -EINTR, &data->sysfs_mutex) {
error = elan_calibrate(data);
if (error)
return error;
}
return count;
} }
static ssize_t elan_sysfs_read_mode(struct device *dev, static ssize_t elan_sysfs_read_mode(struct device *dev,
@ -743,16 +746,11 @@ static ssize_t elan_sysfs_read_mode(struct device *dev,
int error; int error;
enum tp_mode mode; enum tp_mode mode;
error = mutex_lock_interruptible(&data->sysfs_mutex); scoped_cond_guard(mutex_intr, return -EINTR, &data->sysfs_mutex) {
if (error) error = data->ops->iap_get_mode(data->client, &mode);
return error; if (error)
return error;
error = data->ops->iap_get_mode(data->client, &mode); }
mutex_unlock(&data->sysfs_mutex);
if (error)
return error;
return sysfs_emit(buf, "%d\n", (int)mode); return sysfs_emit(buf, "%d\n", (int)mode);
} }
@ -783,44 +781,40 @@ static const struct attribute_group elan_sysfs_group = {
.attrs = elan_sysfs_entries, .attrs = elan_sysfs_entries,
}; };
static ssize_t acquire_store(struct device *dev, struct device_attribute *attr, static int elan_acquire_baseline(struct elan_tp_data *data)
const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = data->client;
struct elan_tp_data *data = i2c_get_clientdata(client); struct device *dev = &client->dev;
int error;
int retval; int retval;
int error;
retval = mutex_lock_interruptible(&data->sysfs_mutex); guard(disable_irq)(&client->irq);
if (retval)
return retval;
disable_irq(client->irq);
data->baseline_ready = false; data->baseline_ready = false;
data->mode |= ETP_ENABLE_CALIBRATE; data->mode |= ETP_ENABLE_CALIBRATE;
retval = data->ops->set_mode(data->client, data->mode); retval = data->ops->set_mode(client, data->mode);
if (retval) { if (retval) {
data->mode &= ~ETP_ENABLE_CALIBRATE;
dev_err(dev, "Failed to enable calibration mode to get baseline: %d\n", dev_err(dev, "Failed to enable calibration mode to get baseline: %d\n",
retval); retval);
goto out; return retval;
} }
msleep(250); msleep(250);
retval = data->ops->get_baseline_data(data->client, true, retval = data->ops->get_baseline_data(client, true,
&data->max_baseline); &data->max_baseline);
if (retval) { if (retval) {
dev_err(dev, "Failed to read max baseline form device: %d\n", dev_err(dev, "Failed to read max baseline from device: %d\n",
retval); retval);
goto out_disable_calibrate; goto out_disable_calibrate;
} }
retval = data->ops->get_baseline_data(data->client, false, retval = data->ops->get_baseline_data(client, false,
&data->min_baseline); &data->min_baseline);
if (retval) { if (retval) {
dev_err(dev, "Failed to read min baseline form device: %d\n", dev_err(dev, "Failed to read min baseline from device: %d\n",
retval); retval);
goto out_disable_calibrate; goto out_disable_calibrate;
} }
@ -829,17 +823,31 @@ static ssize_t acquire_store(struct device *dev, struct device_attribute *attr,
out_disable_calibrate: out_disable_calibrate:
data->mode &= ~ETP_ENABLE_CALIBRATE; data->mode &= ~ETP_ENABLE_CALIBRATE;
error = data->ops->set_mode(data->client, data->mode); error = data->ops->set_mode(client, data->mode);
if (error) { if (error) {
dev_err(dev, "Failed to disable calibration mode after acquiring baseline: %d\n", dev_err(dev, "Failed to disable calibration mode after acquiring baseline: %d\n",
error); error);
if (!retval) if (!retval)
retval = error; retval = error;
} }
out:
enable_irq(client->irq); return retval;
mutex_unlock(&data->sysfs_mutex); }
return retval ?: count;
static ssize_t acquire_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct elan_tp_data *data = i2c_get_clientdata(client);
int error;
scoped_cond_guard(mutex_intr, return -EINTR, &data->sysfs_mutex) {
error = elan_acquire_baseline(data);
if (error)
return error;
}
return count;
} }
static ssize_t min_show(struct device *dev, static ssize_t min_show(struct device *dev,
@ -847,22 +855,15 @@ static ssize_t min_show(struct device *dev,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct elan_tp_data *data = i2c_get_clientdata(client); struct elan_tp_data *data = i2c_get_clientdata(client);
int retval;
retval = mutex_lock_interruptible(&data->sysfs_mutex); scoped_guard(mutex_intr, &data->sysfs_mutex) {
if (retval) if (!data->baseline_ready)
return retval; return -ENODATA;
if (!data->baseline_ready) { return sysfs_emit(buf, "%d", data->min_baseline);
retval = -ENODATA;
goto out;
} }
retval = sysfs_emit(buf, "%d", data->min_baseline); return -EINTR;
out:
mutex_unlock(&data->sysfs_mutex);
return retval;
} }
static ssize_t max_show(struct device *dev, static ssize_t max_show(struct device *dev,
@ -870,25 +871,17 @@ static ssize_t max_show(struct device *dev,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct elan_tp_data *data = i2c_get_clientdata(client); struct elan_tp_data *data = i2c_get_clientdata(client);
int retval;
retval = mutex_lock_interruptible(&data->sysfs_mutex); scoped_guard(mutex_intr, &data->sysfs_mutex) {
if (retval) if (!data->baseline_ready)
return retval; return -ENODATA;
if (!data->baseline_ready) { return sysfs_emit(buf, "%d", data->max_baseline);
retval = -ENODATA;
goto out;
} }
retval = sysfs_emit(buf, "%d", data->max_baseline); return -EINTR;
out:
mutex_unlock(&data->sysfs_mutex);
return retval;
} }
static DEVICE_ATTR_WO(acquire); static DEVICE_ATTR_WO(acquire);
static DEVICE_ATTR_RO(min); static DEVICE_ATTR_RO(min);
static DEVICE_ATTR_RO(max); static DEVICE_ATTR_RO(max);
@ -1323,43 +1316,54 @@ static int elan_probe(struct i2c_client *client)
return 0; return 0;
} }
static int __elan_suspend(struct elan_tp_data *data)
{
struct i2c_client *client = data->client;
int error;
if (device_may_wakeup(&client->dev))
return elan_sleep(data);
/* Touchpad is not a wakeup source */
error = elan_set_power(data, false);
if (error)
return error;
error = regulator_disable(data->vcc);
if (error) {
dev_err(&client->dev,
"failed to disable regulator when suspending: %d\n",
error);
/* Attempt to power the chip back up */
elan_set_power(data, true);
return error;
}
return 0;
}
static int elan_suspend(struct device *dev) static int elan_suspend(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct elan_tp_data *data = i2c_get_clientdata(client); struct elan_tp_data *data = i2c_get_clientdata(client);
int ret; int error;
/* /*
* We are taking the mutex to make sure sysfs operations are * We are taking the mutex to make sure sysfs operations are
* complete before we attempt to bring the device into low[er] * complete before we attempt to bring the device into low[er]
* power mode. * power mode.
*/ */
ret = mutex_lock_interruptible(&data->sysfs_mutex); scoped_cond_guard(mutex_intr, return -EINTR, &data->sysfs_mutex) {
if (ret) disable_irq(client->irq);
return ret;
disable_irq(client->irq); error = __elan_suspend(data);
if (error) {
if (device_may_wakeup(dev)) { enable_irq(client->irq);
ret = elan_sleep(data); return error;
} else {
ret = elan_set_power(data, false);
if (ret)
goto err;
ret = regulator_disable(data->vcc);
if (ret) {
dev_err(dev, "error %d disabling regulator\n", ret);
/* Attempt to power the chip back up */
elan_set_power(data, true);
} }
} }
err: return 0;
if (ret)
enable_irq(client->irq);
mutex_unlock(&data->sysfs_mutex);
return ret;
} }
static int elan_resume(struct device *dev) static int elan_resume(struct device *dev)

View File

@ -628,12 +628,11 @@ static int elan_i2c_write_fw_block(struct i2c_client *client, u16 fw_page_size,
const u8 *page, u16 checksum, int idx) const u8 *page, u16 checksum, int idx)
{ {
struct device *dev = &client->dev; struct device *dev = &client->dev;
u8 *page_store;
u8 val[3]; u8 val[3];
u16 result; u16 result;
int ret, error; int ret, error;
page_store = kmalloc(fw_page_size + 4, GFP_KERNEL); u8 *page_store __free(kfree) = kmalloc(fw_page_size + 4, GFP_KERNEL);
if (!page_store) if (!page_store)
return -ENOMEM; return -ENOMEM;
@ -647,7 +646,7 @@ static int elan_i2c_write_fw_block(struct i2c_client *client, u16 fw_page_size,
if (ret != fw_page_size + 4) { if (ret != fw_page_size + 4) {
error = ret < 0 ? ret : -EIO; error = ret < 0 ? ret : -EIO;
dev_err(dev, "Failed to write page %d: %d\n", idx, error); dev_err(dev, "Failed to write page %d: %d\n", idx, error);
goto exit; return error;
} }
/* Wait for F/W to update one page ROM data. */ /* Wait for F/W to update one page ROM data. */
@ -656,20 +655,17 @@ static int elan_i2c_write_fw_block(struct i2c_client *client, u16 fw_page_size,
error = elan_i2c_read_cmd(client, ETP_I2C_IAP_CTRL_CMD, val); error = elan_i2c_read_cmd(client, ETP_I2C_IAP_CTRL_CMD, val);
if (error) { if (error) {
dev_err(dev, "Failed to read IAP write result: %d\n", error); dev_err(dev, "Failed to read IAP write result: %d\n", error);
goto exit; return error;
} }
result = le16_to_cpup((__le16 *)val); result = le16_to_cpup((__le16 *)val);
if (result & (ETP_FW_IAP_PAGE_ERR | ETP_FW_IAP_INTF_ERR)) { if (result & (ETP_FW_IAP_PAGE_ERR | ETP_FW_IAP_INTF_ERR)) {
dev_err(dev, "IAP reports failed write: %04hx\n", dev_err(dev, "IAP reports failed write: %04hx\n",
result); result);
error = -EIO; return -EIO;
goto exit;
} }
exit: return 0;
kfree(page_store);
return error;
} }
static int elan_i2c_finish_fw_update(struct i2c_client *client, static int elan_i2c_finish_fw_update(struct i2c_client *client,

View File

@ -35,7 +35,7 @@ static void psmouse_smbus_check_adapter(struct i2c_adapter *adapter)
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HOST_NOTIFY)) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HOST_NOTIFY))
return; return;
mutex_lock(&psmouse_smbus_mutex); guard(mutex)(&psmouse_smbus_mutex);
list_for_each_entry(smbdev, &psmouse_smbus_list, node) { list_for_each_entry(smbdev, &psmouse_smbus_list, node) {
if (smbdev->dead) if (smbdev->dead)
@ -55,15 +55,13 @@ static void psmouse_smbus_check_adapter(struct i2c_adapter *adapter)
"SMBus candidate adapter appeared, triggering rescan\n"); "SMBus candidate adapter appeared, triggering rescan\n");
serio_rescan(smbdev->psmouse->ps2dev.serio); serio_rescan(smbdev->psmouse->ps2dev.serio);
} }
mutex_unlock(&psmouse_smbus_mutex);
} }
static void psmouse_smbus_detach_i2c_client(struct i2c_client *client) static void psmouse_smbus_detach_i2c_client(struct i2c_client *client)
{ {
struct psmouse_smbus_dev *smbdev, *tmp; struct psmouse_smbus_dev *smbdev, *tmp;
mutex_lock(&psmouse_smbus_mutex); guard(mutex)(&psmouse_smbus_mutex);
list_for_each_entry_safe(smbdev, tmp, &psmouse_smbus_list, node) { list_for_each_entry_safe(smbdev, tmp, &psmouse_smbus_list, node) {
if (smbdev->client != client) if (smbdev->client != client)
@ -85,8 +83,6 @@ static void psmouse_smbus_detach_i2c_client(struct i2c_client *client)
kfree(smbdev); kfree(smbdev);
} }
} }
mutex_unlock(&psmouse_smbus_mutex);
} }
static int psmouse_smbus_notifier_call(struct notifier_block *nb, static int psmouse_smbus_notifier_call(struct notifier_block *nb,
@ -171,7 +167,7 @@ static void psmouse_smbus_disconnect(struct psmouse *psmouse)
{ {
struct psmouse_smbus_dev *smbdev = psmouse->private; struct psmouse_smbus_dev *smbdev = psmouse->private;
mutex_lock(&psmouse_smbus_mutex); guard(mutex)(&psmouse_smbus_mutex);
if (smbdev->dead) { if (smbdev->dead) {
list_del(&smbdev->node); list_del(&smbdev->node);
@ -186,8 +182,6 @@ static void psmouse_smbus_disconnect(struct psmouse *psmouse)
psmouse_smbus_schedule_remove(smbdev->client); psmouse_smbus_schedule_remove(smbdev->client);
} }
mutex_unlock(&psmouse_smbus_mutex);
psmouse->private = NULL; psmouse->private = NULL;
} }
@ -219,7 +213,7 @@ void psmouse_smbus_cleanup(struct psmouse *psmouse)
{ {
struct psmouse_smbus_dev *smbdev, *tmp; struct psmouse_smbus_dev *smbdev, *tmp;
mutex_lock(&psmouse_smbus_mutex); guard(mutex)(&psmouse_smbus_mutex);
list_for_each_entry_safe(smbdev, tmp, &psmouse_smbus_list, node) { list_for_each_entry_safe(smbdev, tmp, &psmouse_smbus_list, node) {
if (psmouse == smbdev->psmouse) { if (psmouse == smbdev->psmouse) {
@ -227,8 +221,6 @@ void psmouse_smbus_cleanup(struct psmouse *psmouse)
kfree(smbdev); kfree(smbdev);
} }
} }
mutex_unlock(&psmouse_smbus_mutex);
} }
int psmouse_smbus_init(struct psmouse *psmouse, int psmouse_smbus_init(struct psmouse *psmouse,
@ -267,9 +259,9 @@ int psmouse_smbus_init(struct psmouse *psmouse,
psmouse->disconnect = psmouse_smbus_disconnect; psmouse->disconnect = psmouse_smbus_disconnect;
psmouse->resync_time = 0; psmouse->resync_time = 0;
mutex_lock(&psmouse_smbus_mutex); scoped_guard(mutex, &psmouse_smbus_mutex) {
list_add_tail(&smbdev->node, &psmouse_smbus_list); list_add_tail(&smbdev->node, &psmouse_smbus_list);
mutex_unlock(&psmouse_smbus_mutex); }
/* Bind to already existing adapters right away */ /* Bind to already existing adapters right away */
error = i2c_for_each_dev(smbdev, psmouse_smbus_create_companion); error = i2c_for_each_dev(smbdev, psmouse_smbus_create_companion);
@ -293,9 +285,9 @@ int psmouse_smbus_init(struct psmouse *psmouse,
smbdev->board.platform_data = NULL; smbdev->board.platform_data = NULL;
if (error < 0 || !leave_breadcrumbs) { if (error < 0 || !leave_breadcrumbs) {
mutex_lock(&psmouse_smbus_mutex); scoped_guard(mutex, &psmouse_smbus_mutex) {
list_del(&smbdev->node); list_del(&smbdev->node);
mutex_unlock(&psmouse_smbus_mutex); }
kfree(smbdev); kfree(smbdev);
} }

View File

@ -650,9 +650,8 @@ static int synaptics_pt_start(struct serio *serio)
struct psmouse *parent = psmouse_from_serio(serio->parent); struct psmouse *parent = psmouse_from_serio(serio->parent);
struct synaptics_data *priv = parent->private; struct synaptics_data *priv = parent->private;
serio_pause_rx(parent->ps2dev.serio); guard(serio_pause_rx)(parent->ps2dev.serio);
priv->pt_port = serio; priv->pt_port = serio;
serio_continue_rx(parent->ps2dev.serio);
return 0; return 0;
} }
@ -662,9 +661,8 @@ static void synaptics_pt_stop(struct serio *serio)
struct psmouse *parent = psmouse_from_serio(serio->parent); struct psmouse *parent = psmouse_from_serio(serio->parent);
struct synaptics_data *priv = parent->private; struct synaptics_data *priv = parent->private;
serio_pause_rx(parent->ps2dev.serio); guard(serio_pause_rx)(parent->ps2dev.serio);
priv->pt_port = NULL; priv->pt_port = NULL;
serio_continue_rx(parent->ps2dev.serio);
} }
static int synaptics_is_pt_packet(u8 *buf) static int synaptics_is_pt_packet(u8 *buf)

View File

@ -21,7 +21,7 @@
#define SYN_QUE_EXT_MIN_COORDS 0x0f #define SYN_QUE_EXT_MIN_COORDS 0x0f
#define SYN_QUE_MEXT_CAPAB_10 0x10 #define SYN_QUE_MEXT_CAPAB_10 0x10
/* synatics modes */ /* synaptics modes */
#define SYN_BIT_ABSOLUTE_MODE BIT(7) #define SYN_BIT_ABSOLUTE_MODE BIT(7)
#define SYN_BIT_HIGH_RATE BIT(6) #define SYN_BIT_HIGH_RATE BIT(6)
#define SYN_BIT_SLEEP_MODE BIT(3) #define SYN_BIT_SLEEP_MODE BIT(3)

View File

@ -61,14 +61,14 @@ void rmi_f03_commit_buttons(struct rmi_function *fn)
struct f03_data *f03 = dev_get_drvdata(&fn->dev); struct f03_data *f03 = dev_get_drvdata(&fn->dev);
struct serio *serio = f03->serio; struct serio *serio = f03->serio;
serio_pause_rx(serio); guard(serio_pause_rx)(serio);
if (serio->drv) { if (serio->drv) {
serio->drv->interrupt(serio, PSMOUSE_OOB_EXTRA_BTNS, serio->drv->interrupt(serio, PSMOUSE_OOB_EXTRA_BTNS,
SERIO_OOB_DATA); SERIO_OOB_DATA);
serio->drv->interrupt(serio, f03->overwrite_buttons, serio->drv->interrupt(serio, f03->overwrite_buttons,
SERIO_OOB_DATA); SERIO_OOB_DATA);
} }
serio_continue_rx(serio);
} }
static int rmi_f03_pt_write(struct serio *id, unsigned char val) static int rmi_f03_pt_write(struct serio *id, unsigned char val)

View File

@ -246,7 +246,6 @@ static int rmi_f34_update_firmware(struct f34_data *f34,
(const struct rmi_f34_firmware *)fw->data; (const struct rmi_f34_firmware *)fw->data;
u32 image_size = le32_to_cpu(syn_fw->image_size); u32 image_size = le32_to_cpu(syn_fw->image_size);
u32 config_size = le32_to_cpu(syn_fw->config_size); u32 config_size = le32_to_cpu(syn_fw->config_size);
int ret;
BUILD_BUG_ON(offsetof(struct rmi_f34_firmware, data) != BUILD_BUG_ON(offsetof(struct rmi_f34_firmware, data) !=
F34_FW_IMAGE_OFFSET); F34_FW_IMAGE_OFFSET);
@ -267,8 +266,7 @@ static int rmi_f34_update_firmware(struct f34_data *f34,
dev_err(&f34->fn->dev, dev_err(&f34->fn->dev,
"Bad firmware image: fw size %d, expected %d\n", "Bad firmware image: fw size %d, expected %d\n",
image_size, f34->v5.fw_blocks * f34->v5.block_size); image_size, f34->v5.fw_blocks * f34->v5.block_size);
ret = -EILSEQ; return -EILSEQ;
goto out;
} }
if (config_size && if (config_size &&
@ -277,25 +275,18 @@ static int rmi_f34_update_firmware(struct f34_data *f34,
"Bad firmware image: config size %d, expected %d\n", "Bad firmware image: config size %d, expected %d\n",
config_size, config_size,
f34->v5.config_blocks * f34->v5.block_size); f34->v5.config_blocks * f34->v5.block_size);
ret = -EILSEQ; return -EILSEQ;
goto out;
} }
if (image_size && !config_size) { if (image_size && !config_size) {
dev_err(&f34->fn->dev, "Bad firmware image: no config data\n"); dev_err(&f34->fn->dev, "Bad firmware image: no config data\n");
ret = -EILSEQ; return -EILSEQ;
goto out;
} }
dev_info(&f34->fn->dev, "Firmware image OK\n"); dev_info(&f34->fn->dev, "Firmware image OK\n");
mutex_lock(&f34->v5.flash_mutex);
ret = rmi_f34_flash_firmware(f34, syn_fw); guard(mutex)(&f34->v5.flash_mutex);
return rmi_f34_flash_firmware(f34, syn_fw);
mutex_unlock(&f34->v5.flash_mutex);
out:
return ret;
} }
static int rmi_f34_status(struct rmi_function *fn) static int rmi_f34_status(struct rmi_function *fn)
@ -461,9 +452,8 @@ static ssize_t rmi_driver_update_fw_store(struct device *dev,
{ {
struct rmi_driver_data *data = dev_get_drvdata(dev); struct rmi_driver_data *data = dev_get_drvdata(dev);
char fw_name[NAME_MAX]; char fw_name[NAME_MAX];
const struct firmware *fw;
size_t copy_count = count; size_t copy_count = count;
int ret; int error;
if (count == 0 || count >= NAME_MAX) if (count == 0 || count >= NAME_MAX)
return -EINVAL; return -EINVAL;
@ -474,17 +464,18 @@ static ssize_t rmi_driver_update_fw_store(struct device *dev,
memcpy(fw_name, buf, copy_count); memcpy(fw_name, buf, copy_count);
fw_name[copy_count] = '\0'; fw_name[copy_count] = '\0';
ret = request_firmware(&fw, fw_name, dev); const struct firmware *fw __free(firmware) = NULL;
if (ret) error = request_firmware(&fw, fw_name, dev);
return ret; if (error)
return error;
dev_info(dev, "Flashing %s\n", fw_name); dev_info(dev, "Flashing %s\n", fw_name);
ret = rmi_firmware_update(data, fw); error = rmi_firmware_update(data, fw);
if (error)
return error;
release_firmware(fw); return count;
return ret ?: count;
} }
static DEVICE_ATTR(update_fw, 0200, NULL, rmi_driver_update_fw_store); static DEVICE_ATTR(update_fw, 0200, NULL, rmi_driver_update_fw_store);

View File

@ -146,7 +146,7 @@ MODULE_DEVICE_TABLE(of, altera_ps2_match);
*/ */
static struct platform_driver altera_ps2_driver = { static struct platform_driver altera_ps2_driver = {
.probe = altera_ps2_probe, .probe = altera_ps2_probe,
.remove_new = altera_ps2_remove, .remove = altera_ps2_remove,
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.of_match_table = of_match_ptr(altera_ps2_match), .of_match_table = of_match_ptr(altera_ps2_match),

View File

@ -182,7 +182,7 @@ static void ams_delta_serio_exit(struct platform_device *pdev)
static struct platform_driver ams_delta_serio_driver = { static struct platform_driver ams_delta_serio_driver = {
.probe = ams_delta_serio_init, .probe = ams_delta_serio_init,
.remove_new = ams_delta_serio_exit, .remove = ams_delta_serio_exit,
.driver = { .driver = {
.name = DRIVER_NAME .name = DRIVER_NAME
}, },

View File

@ -208,7 +208,7 @@ static struct platform_driver apbps2_of_driver = {
.of_match_table = apbps2_of_match, .of_match_table = apbps2_of_match,
}, },
.probe = apbps2_of_probe, .probe = apbps2_of_probe,
.remove_new = apbps2_of_remove, .remove = apbps2_of_remove,
}; };
module_platform_driver(apbps2_of_driver); module_platform_driver(apbps2_of_driver);

View File

@ -260,7 +260,7 @@ static struct platform_driver arc_ps2_driver = {
.of_match_table = of_match_ptr(arc_ps2_match), .of_match_table = of_match_ptr(arc_ps2_match),
}, },
.probe = arc_ps2_probe, .probe = arc_ps2_probe,
.remove_new = arc_ps2_remove, .remove = arc_ps2_remove,
}; };
module_platform_driver(arc_ps2_driver); module_platform_driver(arc_ps2_driver);

View File

@ -190,7 +190,7 @@ static struct platform_driver ct82c710_driver = {
.name = "ct82c710", .name = "ct82c710",
}, },
.probe = ct82c710_probe, .probe = ct82c710_probe,
.remove_new = ct82c710_remove, .remove = ct82c710_remove,
}; };

View File

@ -145,7 +145,6 @@ static void gscps2_flush(struct gscps2port *ps2port)
static inline int gscps2_writeb_output(struct gscps2port *ps2port, u8 data) static inline int gscps2_writeb_output(struct gscps2port *ps2port, u8 data)
{ {
unsigned long flags;
char __iomem *addr = ps2port->addr; char __iomem *addr = ps2port->addr;
if (!wait_TBE(addr)) { if (!wait_TBE(addr)) {
@ -156,9 +155,8 @@ static inline int gscps2_writeb_output(struct gscps2port *ps2port, u8 data)
while (gscps2_readb_status(addr) & GSC_STAT_RBNE) while (gscps2_readb_status(addr) & GSC_STAT_RBNE)
/* wait */; /* wait */;
spin_lock_irqsave(&ps2port->lock, flags); scoped_guard(spinlock_irqsave, &ps2port->lock)
writeb(data, addr+GSC_XMTDATA); writeb(data, addr+GSC_XMTDATA);
spin_unlock_irqrestore(&ps2port->lock, flags);
/* this is ugly, but due to timing of the port it seems to be necessary. */ /* this is ugly, but due to timing of the port it seems to be necessary. */
mdelay(6); mdelay(6);
@ -177,19 +175,19 @@ static inline int gscps2_writeb_output(struct gscps2port *ps2port, u8 data)
static void gscps2_enable(struct gscps2port *ps2port, int enable) static void gscps2_enable(struct gscps2port *ps2port, int enable)
{ {
unsigned long flags;
u8 data; u8 data;
/* now enable/disable the port */ /* now enable/disable the port */
spin_lock_irqsave(&ps2port->lock, flags); scoped_guard(spinlock_irqsave, &ps2port->lock) {
gscps2_flush(ps2port); gscps2_flush(ps2port);
data = gscps2_readb_control(ps2port->addr); data = gscps2_readb_control(ps2port->addr);
if (enable) if (enable)
data |= GSC_CTRL_ENBL; data |= GSC_CTRL_ENBL;
else else
data &= ~GSC_CTRL_ENBL; data &= ~GSC_CTRL_ENBL;
gscps2_writeb_control(data, ps2port->addr); gscps2_writeb_control(data, ps2port->addr);
spin_unlock_irqrestore(&ps2port->lock, flags); }
wait_TBE(ps2port->addr); wait_TBE(ps2port->addr);
gscps2_flush(ps2port); gscps2_flush(ps2port);
} }
@ -200,18 +198,57 @@ static void gscps2_enable(struct gscps2port *ps2port, int enable)
static void gscps2_reset(struct gscps2port *ps2port) static void gscps2_reset(struct gscps2port *ps2port)
{ {
unsigned long flags;
/* reset the interface */ /* reset the interface */
spin_lock_irqsave(&ps2port->lock, flags); guard(spinlock_irqsave)(&ps2port->lock);
gscps2_flush(ps2port); gscps2_flush(ps2port);
writeb(0xff, ps2port->addr + GSC_RESET); writeb(0xff, ps2port->addr + GSC_RESET);
gscps2_flush(ps2port); gscps2_flush(ps2port);
spin_unlock_irqrestore(&ps2port->lock, flags);
} }
static LIST_HEAD(ps2port_list); static LIST_HEAD(ps2port_list);
static void gscps2_read_data(struct gscps2port *ps2port)
{
u8 status;
do {
status = gscps2_readb_status(ps2port->addr);
if (!(status & GSC_STAT_RBNE))
break;
ps2port->buffer[ps2port->append].str = status;
ps2port->buffer[ps2port->append].data =
gscps2_readb_input(ps2port->addr);
} while (true);
}
static bool gscps2_report_data(struct gscps2port *ps2port)
{
unsigned int rxflags;
u8 data, status;
while (ps2port->act != ps2port->append) {
/*
* Did new data arrived while we read existing data ?
* If yes, exit now and let the new irq handler start
* over again.
*/
if (gscps2_readb_status(ps2port->addr) & GSC_STAT_CMPINTR)
return true;
status = ps2port->buffer[ps2port->act].str;
data = ps2port->buffer[ps2port->act].data;
ps2port->act = (ps2port->act + 1) & BUFFER_SIZE;
rxflags = ((status & GSC_STAT_TERR) ? SERIO_TIMEOUT : 0 ) |
((status & GSC_STAT_PERR) ? SERIO_PARITY : 0 );
serio_interrupt(ps2port->port, data, rxflags);
}
return false;
}
/** /**
* gscps2_interrupt() - Interruption service routine * gscps2_interrupt() - Interruption service routine
* *
@ -229,47 +266,18 @@ static irqreturn_t gscps2_interrupt(int irq, void *dev)
struct gscps2port *ps2port; struct gscps2port *ps2port;
list_for_each_entry(ps2port, &ps2port_list, node) { list_for_each_entry(ps2port, &ps2port_list, node) {
guard(spinlock_irqsave)(&ps2port->lock);
unsigned long flags; gscps2_read_data(ps2port);
spin_lock_irqsave(&ps2port->lock, flags);
while ( (ps2port->buffer[ps2port->append].str =
gscps2_readb_status(ps2port->addr)) & GSC_STAT_RBNE ) {
ps2port->buffer[ps2port->append].data =
gscps2_readb_input(ps2port->addr);
ps2port->append = ((ps2port->append+1) & BUFFER_SIZE);
}
spin_unlock_irqrestore(&ps2port->lock, flags);
} /* list_for_each_entry */ } /* list_for_each_entry */
/* all data was read from the ports - now report the data to upper layer */ /* all data was read from the ports - now report the data to upper layer */
list_for_each_entry(ps2port, &ps2port_list, node) { list_for_each_entry(ps2port, &ps2port_list, node) {
if (gscps2_report_data(ps2port)) {
while (ps2port->act != ps2port->append) { /* More data ready - break early to restart interrupt */
break;
unsigned int rxflags; }
u8 data, status; }
/* Did new data arrived while we read existing data ?
If yes, exit now and let the new irq handler start over again */
if (gscps2_readb_status(ps2port->addr) & GSC_STAT_CMPINTR)
return IRQ_HANDLED;
status = ps2port->buffer[ps2port->act].str;
data = ps2port->buffer[ps2port->act].data;
ps2port->act = ((ps2port->act+1) & BUFFER_SIZE);
rxflags = ((status & GSC_STAT_TERR) ? SERIO_TIMEOUT : 0 ) |
((status & GSC_STAT_PERR) ? SERIO_PARITY : 0 );
serio_interrupt(ps2port->port, data, rxflags);
} /* while() */
} /* list_for_each_entry */
return IRQ_HANDLED; return IRQ_HANDLED;
} }

Some files were not shown because too many files have changed in this diff Show More