[PATCH 4/4] HID: usbhid: use to_usb_device

2015-12-23 Thread Geliang Tang
Use to_usb_device() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/hid/usbhid/usbhid.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index 807922b..fa47d66 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -96,7 +96,7 @@ struct usbhid_device {
 };
 
 #definehid_to_usb_dev(hid_dev) \
-   container_of(hid_dev->dev.parent->parent, struct usb_device, dev)
+   to_usb_device(hid_dev->dev.parent->parent)
 
 #endif
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Input: rotary-encoder: use request_any_context_irq and gpio_get_value_cansleep

2015-12-23 Thread Timo Teräs
This allows to use GPIO expanders behind I2C or SPI bus.

Signed-off-by: Timo Teräs 
---
 drivers/input/misc/rotary_encoder.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/input/misc/rotary_encoder.c 
b/drivers/input/misc/rotary_encoder.c
index 8aee719..8bedd7b 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -48,8 +48,8 @@ struct rotary_encoder {
 
 static int rotary_encoder_get_state(const struct rotary_encoder_platform_data 
*pdata)
 {
-   int a = !!gpio_get_value(pdata->gpio_a);
-   int b = !!gpio_get_value(pdata->gpio_b);
+   int a = !!gpio_get_value_cansleep(pdata->gpio_a);
+   int b = !!gpio_get_value_cansleep(pdata->gpio_b);
 
a ^= pdata->inverted_a;
b ^= pdata->inverted_b;
@@ -335,18 +335,18 @@ static int rotary_encoder_probe(struct platform_device 
*pdev)
goto exit_free_gpio_b;
}
 
-   err = request_irq(encoder->irq_a, handler,
- IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
- DRV_NAME, encoder);
-   if (err) {
+   err = request_any_context_irq(encoder->irq_a, handler,
+ IRQF_TRIGGER_RISING | 
IRQF_TRIGGER_FALLING,
+ DRV_NAME, encoder);
+   if (err < 0) {
dev_err(dev, "unable to request IRQ %d\n", encoder->irq_a);
goto exit_free_gpio_b;
}
 
-   err = request_irq(encoder->irq_b, handler,
- IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
- DRV_NAME, encoder);
-   if (err) {
+   err = request_any_context_irq(encoder->irq_b, handler,
+ IRQF_TRIGGER_RISING | 
IRQF_TRIGGER_FALLING,
+ DRV_NAME, encoder);
+   if (err < 0) {
dev_err(dev, "unable to request IRQ %d\n", encoder->irq_b);
goto exit_free_irq_a;
}
-- 
2.6.4


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html