Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: 88pm860x_onkey - switch to using managed resources

Let's switch the driver to use managed resources, this will simplify
error handling and driver unbinding logic.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Himangi Saraogi and committed by
Dmitry Torokhov
cde51e73 157d45fb

+10 -30
+10 -30
drivers/input/misc/88pm860x_onkey.c
··· 26 26 #include <linux/interrupt.h> 27 27 #include <linux/mfd/88pm860x.h> 28 28 #include <linux/slab.h> 29 + #include <linux/device.h> 29 30 30 31 #define PM8607_WAKEUP 0x0b 31 32 ··· 69 68 return -EINVAL; 70 69 } 71 70 72 - info = kzalloc(sizeof(struct pm860x_onkey_info), GFP_KERNEL); 71 + info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_onkey_info), 72 + GFP_KERNEL); 73 73 if (!info) 74 74 return -ENOMEM; 75 75 info->chip = chip; ··· 78 76 info->dev = &pdev->dev; 79 77 info->irq = irq; 80 78 81 - info->idev = input_allocate_device(); 79 + info->idev = devm_input_allocate_device(&pdev->dev); 82 80 if (!info->idev) { 83 81 dev_err(chip->dev, "Failed to allocate input dev\n"); 84 - ret = -ENOMEM; 85 - goto out; 82 + return -ENOMEM; 86 83 } 87 84 88 85 info->idev->name = "88pm860x_on"; ··· 94 93 ret = input_register_device(info->idev); 95 94 if (ret) { 96 95 dev_err(chip->dev, "Can't register input device: %d\n", ret); 97 - goto out_reg; 96 + return ret; 98 97 } 99 98 100 - ret = request_threaded_irq(info->irq, NULL, pm860x_onkey_handler, 101 - IRQF_ONESHOT, "onkey", info); 99 + ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, 100 + pm860x_onkey_handler, IRQF_ONESHOT, 101 + "onkey", info); 102 102 if (ret < 0) { 103 103 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", 104 104 info->irq, ret); 105 - goto out_irq; 105 + return ret; 106 106 } 107 107 108 108 platform_set_drvdata(pdev, info); 109 109 device_init_wakeup(&pdev->dev, 1); 110 110 111 - return 0; 112 - 113 - out_irq: 114 - input_unregister_device(info->idev); 115 - kfree(info); 116 - return ret; 117 - 118 - out_reg: 119 - input_free_device(info->idev); 120 - out: 121 - kfree(info); 122 - return ret; 123 - } 124 - 125 - static int pm860x_onkey_remove(struct platform_device *pdev) 126 - { 127 - struct pm860x_onkey_info *info = platform_get_drvdata(pdev); 128 - 129 - free_irq(info->irq, info); 130 - input_unregister_device(info->idev); 131 - kfree(info); 132 111 return 0; 133 112 } 134 113 ··· 142 161 .pm = &pm860x_onkey_pm_ops, 143 162 }, 144 163 .probe = pm860x_onkey_probe, 145 - .remove = pm860x_onkey_remove, 146 164 }; 147 165 module_platform_driver(pm860x_onkey_driver); 148 166