Commit 6bfa3175 authored by Linus Walleij's avatar Linus Walleij Committed by Jiri Kosina

HID: cp2112: Use irqchip template

This makes the driver use the irqchip template to assign
properties to the gpio_irq_chip instead of using the
explicit calls to gpiochip_irqchip_add(). The irqchip is
instead added while adding the gpiochip.

Cc: Eudean Sun <eudean@arista.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent b7b8e368
...@@ -1235,6 +1235,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -1235,6 +1235,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
struct cp2112_device *dev; struct cp2112_device *dev;
u8 buf[3]; u8 buf[3];
struct cp2112_smbus_config_report config; struct cp2112_smbus_config_report config;
struct gpio_irq_chip *girq;
int ret; int ret;
dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL); dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL);
...@@ -1338,6 +1339,15 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -1338,6 +1339,15 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
dev->gc.can_sleep = 1; dev->gc.can_sleep = 1;
dev->gc.parent = &hdev->dev; dev->gc.parent = &hdev->dev;
girq = &dev->gc.irq;
girq->chip = &cp2112_gpio_irqchip;
/* The event comes from the outside so no parent handler */
girq->parent_handler = NULL;
girq->num_parents = 0;
girq->parents = NULL;
girq->default_type = IRQ_TYPE_NONE;
girq->handler = handle_simple_irq;
ret = gpiochip_add_data(&dev->gc, dev); ret = gpiochip_add_data(&dev->gc, dev);
if (ret < 0) { if (ret < 0) {
hid_err(hdev, "error registering gpio chip\n"); hid_err(hdev, "error registering gpio chip\n");
...@@ -1353,17 +1363,8 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -1353,17 +1363,8 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
chmod_sysfs_attrs(hdev); chmod_sysfs_attrs(hdev);
hid_hw_power(hdev, PM_HINT_NORMAL); hid_hw_power(hdev, PM_HINT_NORMAL);
ret = gpiochip_irqchip_add(&dev->gc, &cp2112_gpio_irqchip, 0,
handle_simple_irq, IRQ_TYPE_NONE);
if (ret) {
dev_err(dev->gc.parent, "failed to add IRQ chip\n");
goto err_sysfs_remove;
}
return ret; return ret;
err_sysfs_remove:
sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group);
err_gpiochip_remove: err_gpiochip_remove:
gpiochip_remove(&dev->gc); gpiochip_remove(&dev->gc);
err_free_i2c: err_free_i2c:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment