summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/ad7879.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2017-02-17 09:29:40 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2017-02-23 09:21:26 -0800
commit069b2e2cd7ef5b42e1ab8ee991347f9dbf9f51d1 (patch)
tree67ffe20af7c170dc584934c7a7c853a9f3fc6b2b /drivers/input/touchscreen/ad7879.c
parent404a24c35db8c44dce91010023f12b73f2f44441 (diff)
Input: ad7879 - use more devm interfaces
gpiochip_add now has a managed version, and we can remove sysfs attribute group via devm_add_action_or_reset (at least until we have devm version of sysfs_create_group). This allows us to get rid of ad7879_remove(). Reviewed-by: Michael Hennerich <michael.hennerich@analog.com> Tested-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/touchscreen/ad7879.c')
-rw-r--r--drivers/input/touchscreen/ad7879.c60
1 files changed, 21 insertions, 39 deletions
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index 6465db7a1b20..b7ab7f9767ca 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -458,7 +458,7 @@ static int ad7879_gpio_add(struct ad7879 *ts,
mutex_init(&ts->mutex);
- if (pdata->gpio_export) {
+ if (pdata && pdata->gpio_export) {
ts->gc.direction_input = ad7879_gpio_direction_input;
ts->gc.direction_output = ad7879_gpio_direction_output;
ts->gc.get = ad7879_gpio_get_value;
@@ -470,7 +470,7 @@ static int ad7879_gpio_add(struct ad7879 *ts,
ts->gc.owner = THIS_MODULE;
ts->gc.parent = ts->dev;
- ret = gpiochip_add_data(&ts->gc, ts);
+ ret = devm_gpiochip_add_data(ts->dev, &ts->gc, ts);
if (ret)
dev_err(ts->dev, "failed to register gpio %d\n",
ts->gc.base);
@@ -478,25 +478,12 @@ static int ad7879_gpio_add(struct ad7879 *ts,
return ret;
}
-
-static void ad7879_gpio_remove(struct ad7879 *ts)
-{
- const struct ad7879_platform_data *pdata = dev_get_platdata(ts->dev);
-
- if (pdata && pdata->gpio_export)
- gpiochip_remove(&ts->gc);
-
-}
#else
-static inline int ad7879_gpio_add(struct ad7879 *ts,
- const struct ad7879_platform_data *pdata)
+static int ad7879_gpio_add(struct ad7879 *ts,
+ const struct ad7879_platform_data *pdata)
{
return 0;
}
-
-static inline void ad7879_gpio_remove(struct ad7879 *ts)
-{
-}
#endif
static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts)
@@ -525,6 +512,13 @@ static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts)
return 0;
}
+static void ad7879_cleanup_sysfs(void *_ts)
+{
+ struct ad7879 *ts = _ts;
+
+ sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group);
+}
+
struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,
int irq, u16 bustype, u8 devid)
{
@@ -660,36 +654,24 @@ struct ad7879 *ad7879_probe(struct device *dev, struct regmap *regmap,
err = sysfs_create_group(&dev->kobj, &ad7879_attr_group);
if (err)
- goto err_out;
+ return ERR_PTR(err);
- if (pdata) {
- err = ad7879_gpio_add(ts, pdata);
- if (err)
- goto err_remove_attr;
- }
+ err = devm_add_action_or_reset(dev, ad7879_cleanup_sysfs, ts);
+ if (err)
+ return ERR_PTR(err);
- err = input_register_device(input_dev);
+ err = ad7879_gpio_add(ts, pdata);
if (err)
- goto err_remove_gpio;
+ return ERR_PTR(err);
- return ts;
+ err = input_register_device(input_dev);
+ if (err)
+ return ERR_PTR(err);
-err_remove_gpio:
- ad7879_gpio_remove(ts);
-err_remove_attr:
- sysfs_remove_group(&dev->kobj, &ad7879_attr_group);
-err_out:
- return ERR_PTR(err);
+ return 0;
}
EXPORT_SYMBOL(ad7879_probe);
-void ad7879_remove(struct ad7879 *ts)
-{
- ad7879_gpio_remove(ts);
- sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group);
-}
-EXPORT_SYMBOL(ad7879_remove);
-
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
MODULE_DESCRIPTION("AD7879(-1) touchscreen Driver");
MODULE_LICENSE("GPL");