From f63bb4f442d6c7929e58d671d1f46e122c441884 Mon Sep 17 00:00:00 2001 From: Aniroop Mathur Date: Tue, 27 Dec 2016 13:22:42 -0800 Subject: Input: bma150 - switch to using usleep_range instead of msleep msleep (1~20) may not do what the caller intends, and will often sleep longer. (~20 ms actual sleep for any value given in the 1~20ms range) This is not the desired behaviour for many cases like device resume time, device suspend time, device enable time, etc. Thus, change msleep to usleep_range for precise wakeups. Signed-off-by: Aniroop Mathur Acked by: Albert Zhang Signed-off-by: Dmitry Torokhov --- drivers/input/misc/bma150.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c index 2124390ec38c..1fa85379f86c 100644 --- a/drivers/input/misc/bma150.c +++ b/drivers/input/misc/bma150.c @@ -207,7 +207,7 @@ static int bma150_set_mode(struct bma150_data *bma150, u8 mode) return error; if (mode == BMA150_MODE_NORMAL) - msleep(2); + usleep_range(2000, 2100); bma150->mode = mode; return 0; @@ -222,7 +222,7 @@ static int bma150_soft_reset(struct bma150_data *bma150) if (error) return error; - msleep(2); + usleep_range(2000, 2100); return 0; } -- cgit v1.2.1 From 0265c324b8a2bbe502fee3007361d310de3b6d0c Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 18 Jan 2017 11:36:25 -0800 Subject: Input: bfin_rotary - switch to using devm_add_action_or_reset() Use local variable 'dev' instead of dereferencing it several times and replace devm_add_action() and manual error handling with devm_add_action_or_reset(). Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/bfin_rotary.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/bfin_rotary.c b/drivers/input/misc/bfin_rotary.c index a0fc18fdfc0c..799ce3d2820e 100644 --- a/drivers/input/misc/bfin_rotary.c +++ b/drivers/input/misc/bfin_rotary.c @@ -147,19 +147,18 @@ static int bfin_rotary_probe(struct platform_device *pdev) if (pdata->pin_list) { error = peripheral_request_list(pdata->pin_list, - dev_name(&pdev->dev)); + dev_name(dev)); if (error) { dev_err(dev, "requesting peripherals failed: %d\n", error); return error; } - error = devm_add_action(dev, bfin_rotary_free_action, - pdata->pin_list); + error = devm_add_action_or_reset(dev, bfin_rotary_free_action, + pdata->pin_list); if (error) { dev_err(dev, "setting cleanup action failed: %d\n", error); - peripheral_free_list(pdata->pin_list); return error; } } @@ -189,7 +188,7 @@ static int bfin_rotary_probe(struct platform_device *pdev) input->name = pdev->name; input->phys = "bfin-rotary/input0"; - input->dev.parent = &pdev->dev; + input->dev.parent = dev; input_set_drvdata(input, rotary); @@ -239,7 +238,7 @@ static int bfin_rotary_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, rotary); - device_init_wakeup(&pdev->dev, 1); + device_init_wakeup(dev, 1); return 0; } -- cgit v1.2.1 From a196b2c9f5f752e139f91d306fcb471e97723253 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 18 Jan 2017 11:40:04 -0800 Subject: Input: gpio_decoder - drop unnecessary call to platform_set_drvdata There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata(). Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/gpio_decoder.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/gpio_decoder.c b/drivers/input/misc/gpio_decoder.c index ca7e0bacb2d8..1dca526e6f1a 100644 --- a/drivers/input/misc/gpio_decoder.c +++ b/drivers/input/misc/gpio_decoder.c @@ -110,7 +110,6 @@ static int gpio_decoder_probe(struct platform_device *pdev) dev_err(dev, "failed to register polled device\n"); return err; } - platform_set_drvdata(pdev, decoder); return 0; } -- cgit v1.2.1 From 9e85aa695659407bb7a2b2d5de47be8c335049c0 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 18 Jan 2017 11:41:01 -0800 Subject: Input: mma8450 - drop unnecessary call to i2c_set_clientdata There is no call to i2c_get_clientdata() or dev_get_drvdata(). Drop the unnecessary call to i2c_set_clientdata(). Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/mma8450.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c index 19c73574458e..b60cdea73826 100644 --- a/drivers/input/misc/mma8450.c +++ b/drivers/input/misc/mma8450.c @@ -205,8 +205,6 @@ static int mma8450_probe(struct i2c_client *c, return err; } - i2c_set_clientdata(c, m); - return 0; } -- cgit v1.2.1 From aa45590ae8581e25b909f2fed591c3499cd8e352 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 18 Jan 2017 11:41:51 -0800 Subject: Input: soc_button_array - use 'dev' instead of dereferencing it Use local variable 'dev' instead of dereferencing it several times. Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/soc_button_array.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index 908b51089dee..fb3219a8d3c0 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c @@ -167,12 +167,12 @@ static int soc_button_probe(struct platform_device *pdev) button_info = (struct soc_button_info *)id->driver_data; - if (gpiod_count(&pdev->dev, KBUILD_MODNAME) <= 0) { - dev_dbg(&pdev->dev, "no GPIO attached, ignoring...\n"); + if (gpiod_count(dev, KBUILD_MODNAME) <= 0) { + dev_dbg(dev, "no GPIO attached, ignoring...\n"); return -ENODEV; } - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; -- cgit v1.2.1 From 8ace98df9ade746de229dd75c144a25ec9fe2613 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 18 Jan 2017 11:42:44 -0800 Subject: Input: tps65218-pwrbutton - drop unnecessary call to platform_set_drvdata There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata(). Also use existing variable 'dev' instead of dereferencing it several times. Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/tps65218-pwrbutton.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c index 3273217ce80c..65384754714d 100644 --- a/drivers/input/misc/tps65218-pwrbutton.c +++ b/drivers/input/misc/tps65218-pwrbutton.c @@ -95,7 +95,7 @@ static int tps6521x_pb_probe(struct platform_device *pdev) int error; int irq; - match = of_match_node(of_tps6521x_pb_match, pdev->dev.of_node); + match = of_match_node(of_tps6521x_pb_match, dev->of_node); if (!match) return -ENXIO; @@ -118,10 +118,9 @@ static int tps6521x_pb_probe(struct platform_device *pdev) input_set_capability(idev, EV_KEY, KEY_POWER); - pwr->regmap = dev_get_regmap(pdev->dev.parent, NULL); + pwr->regmap = dev_get_regmap(dev->parent, NULL); pwr->dev = dev; pwr->idev = idev; - platform_set_drvdata(pdev, pwr); device_init_wakeup(dev, true); irq = platform_get_irq(pdev, 0); @@ -136,8 +135,7 @@ static int tps6521x_pb_probe(struct platform_device *pdev) IRQF_ONESHOT, pwr->data->name, pwr); if (error) { - dev_err(dev, "failed to request IRQ #%d: %d\n", - irq, error); + dev_err(dev, "failed to request IRQ #%d: %d\n", irq, error); return error; } -- cgit v1.2.1 From b8f6a6ad777f14e3ec48d410a840621a45fce98a Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 18 Jan 2017 11:44:55 -0800 Subject: Input: ab8500-ponkey - drop unnecessary call to platform_set_drvdata There is no call to platform_get_drvdata() or dev_get_drvdata(). Drop the unnecessary call to platform_set_drvdata(). Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/ab8500-ponkey.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c index 4f5ef5bb535b..a33ed5710b15 100644 --- a/drivers/input/misc/ab8500-ponkey.c +++ b/drivers/input/misc/ab8500-ponkey.c @@ -109,7 +109,6 @@ static int ab8500_ponkey_probe(struct platform_device *pdev) return error; } - platform_set_drvdata(pdev, ponkey); return 0; } -- cgit v1.2.1 From 5c4fa2a6da7fbc76290d1cb54a7e35633517a522 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 21 Jan 2017 11:14:14 -0800 Subject: Input: soc_button_array - debounce the buttons The soc_button_array driver was initializing (kzalloc) the debounce_interval value to 0, leading to no debouncing at all, while the buttons are simple mechanical switches. This commit sets debounce_interval to 50ms to avoid spurious button press reports both on press and release of the button. Note 50ms may seem like a lot but soc_button_array is typically used with cheap tablets, with not so great buttons. I tried 10ms on my tablet and it is not enough, where as 50ms works well. Signed-off-by: Hans de Goede Signed-off-by: Dmitry Torokhov --- drivers/input/misc/soc_button_array.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index fb3219a8d3c0..ddb2f22fca7a 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c @@ -102,6 +102,8 @@ soc_button_device_create(struct platform_device *pdev, gpio_keys[n_buttons].active_low = 1; gpio_keys[n_buttons].desc = info->name; gpio_keys[n_buttons].wakeup = info->wakeup; + /* These devices often use cheap buttons, use 50 ms debounce */ + gpio_keys[n_buttons].debounce_interval = 50; n_buttons++; } -- cgit v1.2.1 From 4cd216cbe744f907e7201f1f93f383980b7f931a Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sat, 21 Jan 2017 23:32:34 -0800 Subject: Input: misc - drop calls to platform_set_drvdata and i2c_set_clientdata There is no call to i2c_get_clientdata(), platform_get_drvdata(), or dev_get_drvdata() in any of the drivers in this patch. Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/arizona-haptics.c | 2 -- drivers/input/misc/atmel_captouch.c | 1 - drivers/input/misc/da9063_onkey.c | 1 - drivers/input/misc/e3x0-button.c | 1 - drivers/input/misc/twl4030-pwrbutton.c | 1 - 5 files changed, 6 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/arizona-haptics.c b/drivers/input/misc/arizona-haptics.c index 982936334537..de1b64703c8c 100644 --- a/drivers/input/misc/arizona-haptics.c +++ b/drivers/input/misc/arizona-haptics.c @@ -196,8 +196,6 @@ static int arizona_haptics_probe(struct platform_device *pdev) return ret; } - platform_set_drvdata(pdev, haptics); - return 0; } diff --git a/drivers/input/misc/atmel_captouch.c b/drivers/input/misc/atmel_captouch.c index 941265415a89..c4c0f4bb7627 100644 --- a/drivers/input/misc/atmel_captouch.c +++ b/drivers/input/misc/atmel_captouch.c @@ -191,7 +191,6 @@ static int atmel_captouch_probe(struct i2c_client *client, return -ENOMEM; capdev->client = client; - i2c_set_clientdata(client, capdev); err = atmel_read(capdev, REG_KEY_STATE, &capdev->prev_btn, sizeof(capdev->prev_btn)); diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c index b4ff1e86d3d3..3e9c353d82ef 100644 --- a/drivers/input/misc/da9063_onkey.c +++ b/drivers/input/misc/da9063_onkey.c @@ -287,7 +287,6 @@ static int da9063_onkey_probe(struct platform_device *pdev) return error; } - platform_set_drvdata(pdev, onkey); return 0; } diff --git a/drivers/input/misc/e3x0-button.c b/drivers/input/misc/e3x0-button.c index 13bfca8a7b16..b0b374112db3 100644 --- a/drivers/input/misc/e3x0-button.c +++ b/drivers/input/misc/e3x0-button.c @@ -120,7 +120,6 @@ static int e3x0_button_probe(struct platform_device *pdev) return error; } - platform_set_drvdata(pdev, input); device_init_wakeup(&pdev->dev, 1); return 0; } diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c index 603fc2fadf05..54162d2cbcfc 100644 --- a/drivers/input/misc/twl4030-pwrbutton.c +++ b/drivers/input/misc/twl4030-pwrbutton.c @@ -85,7 +85,6 @@ static int twl4030_pwrbutton_probe(struct platform_device *pdev) return err; } - platform_set_drvdata(pdev, pwr); device_init_wakeup(&pdev->dev, true); return 0; -- cgit v1.2.1 From a0d86ecd23a9e8ae36e274191e55068cc4d10129 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sat, 21 Jan 2017 23:44:18 -0800 Subject: Input: misc - use local variables consistently If a function declares a variable to access a structure element, use it consistently. Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/drv260x.c | 2 +- drivers/input/misc/gpio_tilt_polled.c | 2 +- drivers/input/misc/hisi_powerkey.c | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c index 0a2b865b1000..fb089d36c0d6 100644 --- a/drivers/input/misc/drv260x.c +++ b/drivers/input/misc/drv260x.c @@ -538,7 +538,7 @@ static int drv260x_probe(struct i2c_client *client, haptics->input_dev = devm_input_allocate_device(dev); if (!haptics->input_dev) { - dev_err(&client->dev, "Failed to allocate input device\n"); + dev_err(dev, "Failed to allocate input device\n"); return -ENOMEM; } diff --git a/drivers/input/misc/gpio_tilt_polled.c b/drivers/input/misc/gpio_tilt_polled.c index f103b99d1852..6e217a45e39a 100644 --- a/drivers/input/misc/gpio_tilt_polled.c +++ b/drivers/input/misc/gpio_tilt_polled.c @@ -138,7 +138,7 @@ static int gpio_tilt_polled_probe(struct platform_device *pdev) input->name = pdev->name; input->phys = DRV_NAME"/input0"; - input->dev.parent = &pdev->dev; + input->dev.parent = dev; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; diff --git a/drivers/input/misc/hisi_powerkey.c b/drivers/input/misc/hisi_powerkey.c index 675539c529ce..c4c42124a059 100644 --- a/drivers/input/misc/hisi_powerkey.c +++ b/drivers/input/misc/hisi_powerkey.c @@ -75,9 +75,9 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev) struct input_dev *input; int irq, i, error; - input = devm_input_allocate_device(&pdev->dev); + input = devm_input_allocate_device(dev); if (!input) { - dev_err(&pdev->dev, "failed to allocate input device\n"); + dev_err(dev, "failed to allocate input device\n"); return -ENOMEM; } @@ -111,12 +111,11 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev) error = input_register_device(input); if (error) { - dev_err(&pdev->dev, "failed to register input device: %d\n", - error); + dev_err(dev, "failed to register input device: %d\n", error); return error; } - device_init_wakeup(&pdev->dev, 1); + device_init_wakeup(dev, 1); return 0; } -- cgit v1.2.1 From 56580c2cb7d72e2176136b8146bcc6a527d8ac38 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sat, 21 Jan 2017 23:48:45 -0800 Subject: Input: misc - drop unnecessary calls to device_init_wakeup Calling device_init_wakeup in the remove function is unnecessary since the device is going away, and thus won't be able to cause any wakeups under any circumstances. Besides, the driver cleanup code already handles the necessary cleanup. Similarly, disabling wakeup in the probe error path is unnecessary, as is disabling wakeup in the probe function in the first place. Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/88pm80x_onkey.c | 1 - drivers/input/misc/e3x0-button.c | 1 - drivers/input/misc/gp2ap002a00f.c | 2 -- drivers/input/misc/hisi_powerkey.c | 2 -- drivers/input/misc/pm8941-pwrkey.c | 1 - drivers/input/misc/pmic8xxx-pwrkey.c | 2 -- drivers/input/misc/sirfsoc-onkey.c | 2 -- 7 files changed, 11 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/88pm80x_onkey.c b/drivers/input/misc/88pm80x_onkey.c index cf9908f1e5d5..45a09497f680 100644 --- a/drivers/input/misc/88pm80x_onkey.c +++ b/drivers/input/misc/88pm80x_onkey.c @@ -143,7 +143,6 @@ static int pm80x_onkey_remove(struct platform_device *pdev) { struct pm80x_onkey_info *info = platform_get_drvdata(pdev); - device_init_wakeup(&pdev->dev, 0); pm80x_free_irq(info->pm80x, info->irq, info); input_unregister_device(info->idev); kfree(info); diff --git a/drivers/input/misc/e3x0-button.c b/drivers/input/misc/e3x0-button.c index b0b374112db3..1e50314db1ab 100644 --- a/drivers/input/misc/e3x0-button.c +++ b/drivers/input/misc/e3x0-button.c @@ -126,7 +126,6 @@ static int e3x0_button_probe(struct platform_device *pdev) static int e3x0_button_remove(struct platform_device *pdev) { - device_init_wakeup(&pdev->dev, 0); return 0; } diff --git a/drivers/input/misc/gp2ap002a00f.c b/drivers/input/misc/gp2ap002a00f.c index 3bfdfcc20485..c6a29e57b5e4 100644 --- a/drivers/input/misc/gp2ap002a00f.c +++ b/drivers/input/misc/gp2ap002a00f.c @@ -210,8 +210,6 @@ static int gp2a_remove(struct i2c_client *client) struct gp2a_data *dt = i2c_get_clientdata(client); const struct gp2a_platform_data *pdata = dt->pdata; - device_init_wakeup(&client->dev, false); - free_irq(client->irq, dt); input_unregister_device(dt->input); diff --git a/drivers/input/misc/hisi_powerkey.c b/drivers/input/misc/hisi_powerkey.c index c4c42124a059..baa81dccfc1f 100644 --- a/drivers/input/misc/hisi_powerkey.c +++ b/drivers/input/misc/hisi_powerkey.c @@ -122,8 +122,6 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev) static int hi65xx_powerkey_remove(struct platform_device *pdev) { - device_init_wakeup(&pdev->dev, 0); - return 0; } diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index e317b75357a0..18ad956454f1 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -266,7 +266,6 @@ static int pm8941_pwrkey_remove(struct platform_device *pdev) { struct pm8941_pwrkey *pwrkey = platform_get_drvdata(pdev); - device_init_wakeup(&pdev->dev, 0); unregister_reboot_notifier(&pwrkey->reboot_notifier); return 0; diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c b/drivers/input/misc/pmic8xxx-pwrkey.c index 67aab86048ad..c75be2dd00e7 100644 --- a/drivers/input/misc/pmic8xxx-pwrkey.c +++ b/drivers/input/misc/pmic8xxx-pwrkey.c @@ -440,8 +440,6 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) static int pmic8xxx_pwrkey_remove(struct platform_device *pdev) { - device_init_wakeup(&pdev->dev, 0); - return 0; } diff --git a/drivers/input/misc/sirfsoc-onkey.c b/drivers/input/misc/sirfsoc-onkey.c index ed7237f19539..a2ed0e4fcd0b 100644 --- a/drivers/input/misc/sirfsoc-onkey.c +++ b/drivers/input/misc/sirfsoc-onkey.c @@ -174,8 +174,6 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) static int sirfsoc_pwrc_remove(struct platform_device *pdev) { - device_init_wakeup(&pdev->dev, 0); - return 0; } -- cgit v1.2.1 From 8010e0db7071bdcd0fbd47983e88990d6ce979fb Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sat, 21 Jan 2017 23:50:09 -0800 Subject: Input: misc - drop empty remove functions Empty remove functions don't serve a useful purpose and can be removed. Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/e3x0-button.c | 6 ------ drivers/input/misc/hisi_powerkey.c | 6 ------ drivers/input/misc/pmic8xxx-pwrkey.c | 6 ------ drivers/input/misc/retu-pwrbutton.c | 6 ------ drivers/input/misc/sirfsoc-onkey.c | 6 ------ 5 files changed, 30 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/e3x0-button.c b/drivers/input/misc/e3x0-button.c index 1e50314db1ab..e956cf1d273f 100644 --- a/drivers/input/misc/e3x0-button.c +++ b/drivers/input/misc/e3x0-button.c @@ -124,11 +124,6 @@ static int e3x0_button_probe(struct platform_device *pdev) return 0; } -static int e3x0_button_remove(struct platform_device *pdev) -{ - return 0; -} - #ifdef CONFIG_OF static const struct of_device_id e3x0_button_match[] = { { .compatible = "ettus,e3x0-button", }, @@ -144,7 +139,6 @@ static struct platform_driver e3x0_button_driver = { .pm = &e3x0_button_pm_ops, }, .probe = e3x0_button_probe, - .remove = e3x0_button_remove, }; module_platform_driver(e3x0_button_driver); diff --git a/drivers/input/misc/hisi_powerkey.c b/drivers/input/misc/hisi_powerkey.c index baa81dccfc1f..dee6245f38d7 100644 --- a/drivers/input/misc/hisi_powerkey.c +++ b/drivers/input/misc/hisi_powerkey.c @@ -120,17 +120,11 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev) return 0; } -static int hi65xx_powerkey_remove(struct platform_device *pdev) -{ - return 0; -} - static struct platform_driver hi65xx_powerkey_driver = { .driver = { .name = "hi65xx-powerkey", }, .probe = hi65xx_powerkey_probe, - .remove = hi65xx_powerkey_remove, }; module_platform_driver(hi65xx_powerkey_driver); diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c b/drivers/input/misc/pmic8xxx-pwrkey.c index c75be2dd00e7..73323b0c72c1 100644 --- a/drivers/input/misc/pmic8xxx-pwrkey.c +++ b/drivers/input/misc/pmic8xxx-pwrkey.c @@ -438,11 +438,6 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) return 0; } -static int pmic8xxx_pwrkey_remove(struct platform_device *pdev) -{ - return 0; -} - static const struct of_device_id pm8xxx_pwr_key_id_table[] = { { .compatible = "qcom,pm8058-pwrkey", .data = &pm8058_pwrkey_shutdown }, { .compatible = "qcom,pm8921-pwrkey", .data = &pm8921_pwrkey_shutdown }, @@ -452,7 +447,6 @@ MODULE_DEVICE_TABLE(of, pm8xxx_pwr_key_id_table); static struct platform_driver pmic8xxx_pwrkey_driver = { .probe = pmic8xxx_pwrkey_probe, - .remove = pmic8xxx_pwrkey_remove, .shutdown = pmic8xxx_pwrkey_shutdown, .driver = { .name = "pm8xxx-pwrkey", diff --git a/drivers/input/misc/retu-pwrbutton.c b/drivers/input/misc/retu-pwrbutton.c index 30b459b6b344..64023ac08e2b 100644 --- a/drivers/input/misc/retu-pwrbutton.c +++ b/drivers/input/misc/retu-pwrbutton.c @@ -76,14 +76,8 @@ static int retu_pwrbutton_probe(struct platform_device *pdev) return 0; } -static int retu_pwrbutton_remove(struct platform_device *pdev) -{ - return 0; -} - static struct platform_driver retu_pwrbutton_driver = { .probe = retu_pwrbutton_probe, - .remove = retu_pwrbutton_remove, .driver = { .name = "retu-pwrbutton", }, diff --git a/drivers/input/misc/sirfsoc-onkey.c b/drivers/input/misc/sirfsoc-onkey.c index a2ed0e4fcd0b..4fd038d476a3 100644 --- a/drivers/input/misc/sirfsoc-onkey.c +++ b/drivers/input/misc/sirfsoc-onkey.c @@ -172,11 +172,6 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) return 0; } -static int sirfsoc_pwrc_remove(struct platform_device *pdev) -{ - return 0; -} - static int __maybe_unused sirfsoc_pwrc_resume(struct device *dev) { struct sirfsoc_pwrc_drvdata *pwrcdrv = dev_get_drvdata(dev); @@ -198,7 +193,6 @@ static SIMPLE_DEV_PM_OPS(sirfsoc_pwrc_pm_ops, NULL, sirfsoc_pwrc_resume); static struct platform_driver sirfsoc_pwrc_driver = { .probe = sirfsoc_pwrc_probe, - .remove = sirfsoc_pwrc_remove, .driver = { .name = "sirfsoc-pwrc", .pm = &sirfsoc_pwrc_pm_ops, -- cgit v1.2.1 From 2031717544cab77b9b6fd8c33fd24cbbe2f607b6 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 6 Jan 2017 09:48:20 -0800 Subject: Input: pwm-beeper - remove calls to legacy pwm_request API There are no more users of pwm-beeper driver in mainline relying on this legacy API, so let's remove it and simplify the driver code. Acked-by: Thierry Reding Tested-by: David Lechner Signed-off-by: Dmitry Torokhov --- drivers/input/misc/pwm-beeper.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index 5f9655d49a65..cb87e475bd23 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -95,7 +95,6 @@ static void pwm_beeper_close(struct input_dev *input) static int pwm_beeper_probe(struct platform_device *pdev) { - unsigned long pwm_id = (unsigned long)dev_get_platdata(&pdev->dev); struct pwm_beeper *beeper; int error; @@ -104,11 +103,6 @@ static int pwm_beeper_probe(struct platform_device *pdev) return -ENOMEM; beeper->pwm = pwm_get(&pdev->dev, NULL); - if (IS_ERR(beeper->pwm)) { - dev_dbg(&pdev->dev, "unable to request PWM, trying legacy API\n"); - beeper->pwm = pwm_request(pwm_id, "pwm beeper"); - } - if (IS_ERR(beeper->pwm)) { error = PTR_ERR(beeper->pwm); dev_err(&pdev->dev, "Failed to request pwm device: %d\n", error); -- cgit v1.2.1 From bcf4b0460ba558b1e1fcaa7c160076751b560d03 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 6 Jan 2017 09:50:14 -0800 Subject: Input: pwm-beeper - switch to using managed resources Use of managed resources (devm) simplifies error handling and tear down of the driver. Reviewed-by: Thierry Reding Tested-by: David Lechner Signed-off-by: Dmitry Torokhov --- drivers/input/misc/pwm-beeper.c | 44 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index cb87e475bd23..f8b163b0eb43 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -95,18 +95,19 @@ static void pwm_beeper_close(struct input_dev *input) static int pwm_beeper_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct pwm_beeper *beeper; int error; - beeper = kzalloc(sizeof(*beeper), GFP_KERNEL); + beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL); if (!beeper) return -ENOMEM; - beeper->pwm = pwm_get(&pdev->dev, NULL); + beeper->pwm = devm_pwm_get(dev, NULL); if (IS_ERR(beeper->pwm)) { error = PTR_ERR(beeper->pwm); - dev_err(&pdev->dev, "Failed to request pwm device: %d\n", error); - goto err_free; + dev_err(dev, "Failed to request PWM device: %d\n", error); + return error; } /* @@ -117,13 +118,11 @@ static int pwm_beeper_probe(struct platform_device *pdev) INIT_WORK(&beeper->work, pwm_beeper_work); - beeper->input = input_allocate_device(); + beeper->input = devm_input_allocate_device(dev); if (!beeper->input) { - dev_err(&pdev->dev, "Failed to allocate input device\n"); - error = -ENOMEM; - goto err_pwm_free; + dev_err(dev, "Failed to allocate input device\n"); + return -ENOMEM; } - beeper->input->dev.parent = &pdev->dev; beeper->input->name = "pwm-beeper"; beeper->input->phys = "pwm/input0"; @@ -142,34 +141,12 @@ static int pwm_beeper_probe(struct platform_device *pdev) error = input_register_device(beeper->input); if (error) { - dev_err(&pdev->dev, "Failed to register input device: %d\n", error); - goto err_input_free; + dev_err(dev, "Failed to register input device: %d\n", error); + return error; } platform_set_drvdata(pdev, beeper); - return 0; - -err_input_free: - input_free_device(beeper->input); -err_pwm_free: - pwm_free(beeper->pwm); -err_free: - kfree(beeper); - - return error; -} - -static int pwm_beeper_remove(struct platform_device *pdev) -{ - struct pwm_beeper *beeper = platform_get_drvdata(pdev); - - input_unregister_device(beeper->input); - - pwm_free(beeper->pwm); - - kfree(beeper); - return 0; } @@ -205,7 +182,6 @@ MODULE_DEVICE_TABLE(of, pwm_beeper_match); static struct platform_driver pwm_beeper_driver = { .probe = pwm_beeper_probe, - .remove = pwm_beeper_remove, .driver = { .name = "pwm-beeper", .pm = &pwm_beeper_pm_ops, -- cgit v1.2.1 From 48a55d7de79f95176f3ab372be66165a60be222f Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 6 Jan 2017 09:54:14 -0800 Subject: Input: pwm-beeper - use input_set_capability() Instead of manipulating capability bits directly, let's use input_set_capability() API. Reviewed-by: Thierry Reding Tested-by: David Lechner Signed-off-by: Dmitry Torokhov --- drivers/input/misc/pwm-beeper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index f8b163b0eb43..58a60b42c836 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -131,8 +131,8 @@ static int pwm_beeper_probe(struct platform_device *pdev) beeper->input->id.product = 0x0001; beeper->input->id.version = 0x0100; - beeper->input->evbit[0] = BIT(EV_SND); - beeper->input->sndbit[0] = BIT(SND_TONE) | BIT(SND_BELL); + input_set_capability(beeper->input, EV_SND, SND_TONE); + input_set_capability(beeper->input, EV_SND, SND_BELL); beeper->input->event = pwm_beeper_event; beeper->input->close = pwm_beeper_close; -- cgit v1.2.1 From e9728f0dd7dc06fb0f0d18552ab9599005cd2ab7 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 19 Jan 2017 11:13:37 -0800 Subject: Input: pwm-beeper - fix race when suspending Usually userspace sends SND_BELL and SND_TONE events, and by the time pwm_beeper_suspend() runs userpsace is already frozen, but theoretically in-kernel users may send these events too, and that may cause pwm_beeper_event() scheduling another work after we canceled it. Let's introduce a "suspended" flag and check it in pwm_beeper_event() to avoid this race. Reviewed-by: Thierry Reding Tested-by: David Lechner Signed-off-by: Dmitry Torokhov --- drivers/input/misc/pwm-beeper.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index 58a60b42c836..9d7987d9ba1b 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -27,6 +27,7 @@ struct pwm_beeper { struct pwm_device *pwm; struct work_struct work; unsigned long period; + bool suspended; }; #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x)) @@ -73,7 +74,8 @@ static int pwm_beeper_event(struct input_dev *input, else beeper->period = HZ_TO_NANOSECONDS(value); - schedule_work(&beeper->work); + if (!beeper->suspended) + schedule_work(&beeper->work); return 0; } @@ -154,6 +156,15 @@ static int __maybe_unused pwm_beeper_suspend(struct device *dev) { struct pwm_beeper *beeper = dev_get_drvdata(dev); + /* + * Spinlock is taken here is not to protect write to + * beeper->suspended, but to ensure that pwm_beeper_event + * does not re-submit work once flag is set. + */ + spin_lock_irq(&beeper->input->event_lock); + beeper->suspended = true; + spin_unlock_irq(&beeper->input->event_lock); + pwm_beeper_stop(beeper); return 0; @@ -163,8 +174,12 @@ static int __maybe_unused pwm_beeper_resume(struct device *dev) { struct pwm_beeper *beeper = dev_get_drvdata(dev); - if (beeper->period) - __pwm_beeper_set(beeper); + spin_lock_irq(&beeper->input->event_lock); + beeper->suspended = false; + spin_unlock_irq(&beeper->input->event_lock); + + /* Let worker figure out if we should resume beeping */ + schedule_work(&beeper->work); return 0; } -- cgit v1.2.1 From 62481881401246859d9bd06b7c7b9a391c78892c Mon Sep 17 00:00:00 2001 From: David Lechner Date: Fri, 6 Jan 2017 10:35:16 -0800 Subject: Input: pwm-beeper - suppress error message on probe defer This suppress printing an error message when pwm_get returns -EPROBE_DEFER. Otherwise you get a bunch of noise in the kernel log. Signed-off-by: David Lechner Reviewed-by: Thierry Reding Signed-off-by: Dmitry Torokhov --- drivers/input/misc/pwm-beeper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index 9d7987d9ba1b..069d594554bd 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -108,7 +108,9 @@ static int pwm_beeper_probe(struct platform_device *pdev) beeper->pwm = devm_pwm_get(dev, NULL); if (IS_ERR(beeper->pwm)) { error = PTR_ERR(beeper->pwm); - dev_err(dev, "Failed to request PWM device: %d\n", error); + if (error != -EPROBE_DEFER) + dev_err(dev, "Failed to request PWM device: %d\n", + error); return error; } -- cgit v1.2.1 From 9e54924432783bfb21e905e0bf7042556bcb4b90 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sun, 15 Jan 2017 17:09:43 -0800 Subject: Input: pwm-beeper - add optional amplifier regulator This adds an optional regulator to the pwm-beeper device. This regulator acts as an amplifier. The amplifier is only enabled while beeping in order to reduce power consumption. Tested on LEGO MINDSTORMS EV3, which has a speaker connected to PWM through an amplifier. Signed-off-by: David Lechner Acked-by: Rob Herring Signed-off-by: Dmitry Torokhov --- drivers/input/misc/pwm-beeper.c | 63 ++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 13 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index 069d594554bd..ad9b231e8468 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -25,30 +26,59 @@ struct pwm_beeper { struct input_dev *input; struct pwm_device *pwm; + struct regulator *amplifier; struct work_struct work; unsigned long period; bool suspended; + bool amplifier_on; }; #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x)) -static void __pwm_beeper_set(struct pwm_beeper *beeper) +static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period) { - unsigned long period = beeper->period; + int error; + + error = pwm_config(beeper->pwm, period / 2, period); + if (error) + return error; + + error = pwm_enable(beeper->pwm); + if (error) + return error; + + if (!beeper->amplifier_on) { + error = regulator_enable(beeper->amplifier); + if (error) { + pwm_disable(beeper->pwm); + return error; + } - if (period) { - pwm_config(beeper->pwm, period / 2, period); - pwm_enable(beeper->pwm); - } else - pwm_disable(beeper->pwm); + beeper->amplifier_on = true; + } + + return 0; +} + +static void pwm_beeper_off(struct pwm_beeper *beeper) +{ + if (beeper->amplifier_on) { + regulator_disable(beeper->amplifier); + beeper->amplifier_on = false; + } + + pwm_disable(beeper->pwm); } static void pwm_beeper_work(struct work_struct *work) { - struct pwm_beeper *beeper = - container_of(work, struct pwm_beeper, work); + struct pwm_beeper *beeper = container_of(work, struct pwm_beeper, work); + unsigned long period = READ_ONCE(beeper->period); - __pwm_beeper_set(beeper); + if (period) + pwm_beeper_on(beeper, period); + else + pwm_beeper_off(beeper); } static int pwm_beeper_event(struct input_dev *input, @@ -83,9 +113,7 @@ static int pwm_beeper_event(struct input_dev *input, static void pwm_beeper_stop(struct pwm_beeper *beeper) { cancel_work_sync(&beeper->work); - - if (beeper->period) - pwm_disable(beeper->pwm); + pwm_beeper_off(beeper); } static void pwm_beeper_close(struct input_dev *input) @@ -120,6 +148,15 @@ static int pwm_beeper_probe(struct platform_device *pdev) */ pwm_apply_args(beeper->pwm); + beeper->amplifier = devm_regulator_get(dev, "amp"); + if (IS_ERR(beeper->amplifier)) { + error = PTR_ERR(beeper->amplifier); + if (error != -EPROBE_DEFER) + dev_err(dev, "Failed to get 'amp' regulator: %d\n", + error); + return error; + } + INIT_WORK(&beeper->work, pwm_beeper_work); beeper->input = devm_input_allocate_device(dev); -- cgit v1.2.1 From 2de8b4110c82c243530a68381a1c39a4fe05c14f Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 19 Jan 2017 13:52:49 -0800 Subject: Input: pwm-beeper - switch to using "atomic" PWM API The "atomic" API allows us to configure PWM period and duty cycle and enable it in one call. Reviewed-by: Thierry Reding Tested-by: David Lechner Signed-off-by: Dmitry Torokhov --- drivers/input/misc/pwm-beeper.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index ad9b231e8468..e53801dbd560 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -37,13 +37,16 @@ struct pwm_beeper { static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period) { + struct pwm_state state; int error; - error = pwm_config(beeper->pwm, period / 2, period); - if (error) - return error; + pwm_get_state(beeper->pwm, &state); - error = pwm_enable(beeper->pwm); + state.enabled = true; + state.period = period; + pwm_set_relative_duty_cycle(&state, 50, 100); + + error = pwm_apply_state(beeper->pwm, &state); if (error) return error; @@ -127,6 +130,7 @@ static int pwm_beeper_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct pwm_beeper *beeper; + struct pwm_state state; int error; beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL); @@ -142,11 +146,15 @@ static int pwm_beeper_probe(struct platform_device *pdev) return error; } - /* - * FIXME: pwm_apply_args() should be removed when switching to - * the atomic PWM API. - */ - pwm_apply_args(beeper->pwm); + /* Sync up PWM state and ensure it is off. */ + pwm_init_state(beeper->pwm, &state); + state.enabled = false; + error = pwm_apply_state(beeper->pwm, &state); + if (error) { + dev_err(dev, "failed to apply initial PWM state: %d\n", + error); + return error; + } beeper->amplifier = devm_regulator_get(dev, "amp"); if (IS_ERR(beeper->amplifier)) { -- cgit v1.2.1 From 86178c8634ff8abe04933839d009c4440213040f Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sun, 22 Jan 2017 17:18:45 -0800 Subject: Input: dm355evm_keys - drop unnecessary call to input_set_drvdata Since there is no call to dev_get_drvdata() or input_get_drvdata(), the call to input_set_drvdata() is unnecessary and can be dropped. Signed-off-by: Guenter Roeck Signed-off-by: Dmitry Torokhov --- drivers/input/misc/dm355evm_keys.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c index b6b7bd4e5462..82e272ebc0ed 100644 --- a/drivers/input/misc/dm355evm_keys.c +++ b/drivers/input/misc/dm355evm_keys.c @@ -195,8 +195,6 @@ static int dm355evm_keys_probe(struct platform_device *pdev) goto fail1; keys->irq = status; - input_set_drvdata(input, keys); - input->name = "DM355 EVM Controls"; input->phys = "dm355evm/input0"; input->dev.parent = &pdev->dev; -- cgit v1.2.1 From b1fe0cf06f92ff8ebe77959810ec3ff2555ff56c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 31 Jan 2017 00:12:21 -0800 Subject: Input: delete MPU3050 driver The MPU3050 driver in the input subsystem has been superseded by a proper IIO driver found in drivers/iio/gyro/mpu3050*. Patches have been submitted to remove all defconfig and related references to the old driver and replace this input driver with the IIO driver. So delete the input driver. Input was never a good fit for sensors anyway. Signed-off-by: Linus Walleij Reviewed-by: Heikki Krogerus Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 10 - drivers/input/misc/Makefile | 1 - drivers/input/misc/mpu3050.c | 481 ------------------------------------------- 3 files changed, 492 deletions(-) delete mode 100644 drivers/input/misc/mpu3050.c (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 1ae4d9617ff8..5b6c52210d20 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -234,16 +234,6 @@ config INPUT_MMA8450 To compile this driver as a module, choose M here: the module will be called mma8450. -config INPUT_MPU3050 - tristate "MPU3050 Triaxial gyroscope sensor" - depends on I2C - help - Say Y here if you want to support InvenSense MPU3050 - connected via an I2C bus. - - To compile this driver as a module, choose M here: the - module will be called mpu3050. - config INPUT_APANEL tristate "Fujitsu Lifebook Application Panel buttons" depends on X86 && I2C && LEDS_CLASS diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 0b6d025f0487..b10523f2878e 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -48,7 +48,6 @@ obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o obj-$(CONFIG_INPUT_MMA8450) += mma8450.o -obj-$(CONFIG_INPUT_MPU3050) += mpu3050.o obj-$(CONFIG_INPUT_PALMAS_PWRBUTTON) += palmas-pwrbutton.o obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o diff --git a/drivers/input/misc/mpu3050.c b/drivers/input/misc/mpu3050.c deleted file mode 100644 index f088db31cfc7..000000000000 --- a/drivers/input/misc/mpu3050.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * MPU3050 Tri-axis gyroscope driver - * - * Copyright (C) 2011 Wistron Co.Ltd - * Joseph Lai - * - * Trimmed down by Alan Cox to produce this version - * - * This is a 'lite' version of the driver, while we consider the right way - * to present the other features to user space. In particular it requires the - * device has an IRQ, and it only provides an input interface, so is not much - * use for device orientation. A fuller version is available from the Meego - * tree. - * - * This program is based on bma023.c. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MPU3050_CHIP_ID 0x69 - -#define MPU3050_AUTO_DELAY 1000 - -#define MPU3050_MIN_VALUE -32768 -#define MPU3050_MAX_VALUE 32767 - -#define MPU3050_DEFAULT_POLL_INTERVAL 200 -#define MPU3050_DEFAULT_FS_RANGE 3 - -/* Register map */ -#define MPU3050_CHIP_ID_REG 0x00 -#define MPU3050_SMPLRT_DIV 0x15 -#define MPU3050_DLPF_FS_SYNC 0x16 -#define MPU3050_INT_CFG 0x17 -#define MPU3050_XOUT_H 0x1D -#define MPU3050_PWR_MGM 0x3E -#define MPU3050_PWR_MGM_POS 6 - -/* Register bits */ - -/* DLPF_FS_SYNC */ -#define MPU3050_EXT_SYNC_NONE 0x00 -#define MPU3050_EXT_SYNC_TEMP 0x20 -#define MPU3050_EXT_SYNC_GYROX 0x40 -#define MPU3050_EXT_SYNC_GYROY 0x60 -#define MPU3050_EXT_SYNC_GYROZ 0x80 -#define MPU3050_EXT_SYNC_ACCELX 0xA0 -#define MPU3050_EXT_SYNC_ACCELY 0xC0 -#define MPU3050_EXT_SYNC_ACCELZ 0xE0 -#define MPU3050_EXT_SYNC_MASK 0xE0 -#define MPU3050_FS_250DPS 0x00 -#define MPU3050_FS_500DPS 0x08 -#define MPU3050_FS_1000DPS 0x10 -#define MPU3050_FS_2000DPS 0x18 -#define MPU3050_FS_MASK 0x18 -#define MPU3050_DLPF_CFG_256HZ_NOLPF2 0x00 -#define MPU3050_DLPF_CFG_188HZ 0x01 -#define MPU3050_DLPF_CFG_98HZ 0x02 -#define MPU3050_DLPF_CFG_42HZ 0x03 -#define MPU3050_DLPF_CFG_20HZ 0x04 -#define MPU3050_DLPF_CFG_10HZ 0x05 -#define MPU3050_DLPF_CFG_5HZ 0x06 -#define MPU3050_DLPF_CFG_2100HZ_NOLPF 0x07 -#define MPU3050_DLPF_CFG_MASK 0x07 -/* INT_CFG */ -#define MPU3050_RAW_RDY_EN 0x01 -#define MPU3050_MPU_RDY_EN 0x02 -#define MPU3050_LATCH_INT_EN 0x04 -/* PWR_MGM */ -#define MPU3050_PWR_MGM_PLL_X 0x01 -#define MPU3050_PWR_MGM_PLL_Y 0x02 -#define MPU3050_PWR_MGM_PLL_Z 0x03 -#define MPU3050_PWR_MGM_CLKSEL 0x07 -#define MPU3050_PWR_MGM_STBY_ZG 0x08 -#define MPU3050_PWR_MGM_STBY_YG 0x10 -#define MPU3050_PWR_MGM_STBY_XG 0x20 -#define MPU3050_PWR_MGM_SLEEP 0x40 -#define MPU3050_PWR_MGM_RESET 0x80 -#define MPU3050_PWR_MGM_MASK 0x40 - -struct axis_data { - s16 x; - s16 y; - s16 z; -}; - -struct mpu3050_sensor { - struct i2c_client *client; - struct device *dev; - struct input_dev *idev; -}; - -/** - * mpu3050_xyz_read_reg - read the axes values - * @buffer: provide register addr and get register - * @length: length of register - * - * Reads the register values in one transaction or returns a negative - * error code on failure. - */ -static int mpu3050_xyz_read_reg(struct i2c_client *client, - u8 *buffer, int length) -{ - /* - * Annoying we can't make this const because the i2c layer doesn't - * declare input buffers const. - */ - char cmd = MPU3050_XOUT_H; - struct i2c_msg msg[] = { - { - .addr = client->addr, - .flags = 0, - .len = 1, - .buf = &cmd, - }, - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = length, - .buf = buffer, - }, - }; - - return i2c_transfer(client->adapter, msg, 2); -} - -/** - * mpu3050_read_xyz - get co-ordinates from device - * @client: i2c address of sensor - * @coords: co-ordinates to update - * - * Return the converted X Y and Z co-ordinates from the sensor device - */ -static void mpu3050_read_xyz(struct i2c_client *client, - struct axis_data *coords) -{ - u16 buffer[3]; - - mpu3050_xyz_read_reg(client, (u8 *)buffer, 6); - coords->x = be16_to_cpu(buffer[0]); - coords->y = be16_to_cpu(buffer[1]); - coords->z = be16_to_cpu(buffer[2]); - dev_dbg(&client->dev, "%s: x %d, y %d, z %d\n", __func__, - coords->x, coords->y, coords->z); -} - -/** - * mpu3050_set_power_mode - set the power mode - * @client: i2c client for the sensor - * @val: value to switch on/off of power, 1: normal power, 0: low power - * - * Put device to normal-power mode or low-power mode. - */ -static void mpu3050_set_power_mode(struct i2c_client *client, u8 val) -{ - u8 value; - - value = i2c_smbus_read_byte_data(client, MPU3050_PWR_MGM); - value = (value & ~MPU3050_PWR_MGM_MASK) | - (((val << MPU3050_PWR_MGM_POS) & MPU3050_PWR_MGM_MASK) ^ - MPU3050_PWR_MGM_MASK); - i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, value); -} - -/** - * mpu3050_input_open - called on input event open - * @input: input dev of opened device - * - * The input layer calls this function when input event is opened. The - * function will push the device to resume. Then, the device is ready - * to provide data. - */ -static int mpu3050_input_open(struct input_dev *input) -{ - struct mpu3050_sensor *sensor = input_get_drvdata(input); - int error; - - pm_runtime_get(sensor->dev); - - /* Enable interrupts */ - error = i2c_smbus_write_byte_data(sensor->client, MPU3050_INT_CFG, - MPU3050_LATCH_INT_EN | - MPU3050_RAW_RDY_EN | - MPU3050_MPU_RDY_EN); - if (error < 0) { - pm_runtime_put(sensor->dev); - return error; - } - - return 0; -} - -/** - * mpu3050_input_close - called on input event close - * @input: input dev of closed device - * - * The input layer calls this function when input event is closed. The - * function will push the device to suspend. - */ -static void mpu3050_input_close(struct input_dev *input) -{ - struct mpu3050_sensor *sensor = input_get_drvdata(input); - - pm_runtime_put(sensor->dev); -} - -/** - * mpu3050_interrupt_thread - handle an IRQ - * @irq: interrupt numner - * @data: the sensor - * - * Called by the kernel single threaded after an interrupt occurs. Read - * the sensor data and generate an input event for it. - */ -static irqreturn_t mpu3050_interrupt_thread(int irq, void *data) -{ - struct mpu3050_sensor *sensor = data; - struct axis_data axis; - - mpu3050_read_xyz(sensor->client, &axis); - - input_report_abs(sensor->idev, ABS_X, axis.x); - input_report_abs(sensor->idev, ABS_Y, axis.y); - input_report_abs(sensor->idev, ABS_Z, axis.z); - input_sync(sensor->idev); - - return IRQ_HANDLED; -} - -/** - * mpu3050_hw_init - initialize hardware - * @sensor: the sensor - * - * Called during device probe; configures the sampling method. - */ -static int mpu3050_hw_init(struct mpu3050_sensor *sensor) -{ - struct i2c_client *client = sensor->client; - int ret; - u8 reg; - - /* Reset */ - ret = i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, - MPU3050_PWR_MGM_RESET); - if (ret < 0) - return ret; - - ret = i2c_smbus_read_byte_data(client, MPU3050_PWR_MGM); - if (ret < 0) - return ret; - - ret &= ~MPU3050_PWR_MGM_CLKSEL; - ret |= MPU3050_PWR_MGM_PLL_Z; - ret = i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, ret); - if (ret < 0) - return ret; - - /* Output frequency divider. The poll interval */ - ret = i2c_smbus_write_byte_data(client, MPU3050_SMPLRT_DIV, - MPU3050_DEFAULT_POLL_INTERVAL - 1); - if (ret < 0) - return ret; - - /* Set low pass filter and full scale */ - reg = MPU3050_DEFAULT_FS_RANGE; - reg |= MPU3050_DLPF_CFG_42HZ << 3; - reg |= MPU3050_EXT_SYNC_NONE << 5; - ret = i2c_smbus_write_byte_data(client, MPU3050_DLPF_FS_SYNC, reg); - if (ret < 0) - return ret; - - return 0; -} - -/** - * mpu3050_probe - device detection callback - * @client: i2c client of found device - * @id: id match information - * - * The I2C layer calls us when it believes a sensor is present at this - * address. Probe to see if this is correct and to validate the device. - * - * If present install the relevant sysfs interfaces and input device. - */ -static int mpu3050_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct mpu3050_sensor *sensor; - struct input_dev *idev; - int ret; - int error; - - sensor = kzalloc(sizeof(struct mpu3050_sensor), GFP_KERNEL); - idev = input_allocate_device(); - if (!sensor || !idev) { - dev_err(&client->dev, "failed to allocate driver data\n"); - error = -ENOMEM; - goto err_free_mem; - } - - sensor->client = client; - sensor->dev = &client->dev; - sensor->idev = idev; - - mpu3050_set_power_mode(client, 1); - msleep(10); - - ret = i2c_smbus_read_byte_data(client, MPU3050_CHIP_ID_REG); - if (ret < 0) { - dev_err(&client->dev, "failed to detect device\n"); - error = -ENXIO; - goto err_free_mem; - } - - if (ret != MPU3050_CHIP_ID) { - dev_err(&client->dev, "unsupported chip id\n"); - error = -ENXIO; - goto err_free_mem; - } - - idev->name = "MPU3050"; - idev->id.bustype = BUS_I2C; - idev->dev.parent = &client->dev; - - idev->open = mpu3050_input_open; - idev->close = mpu3050_input_close; - - __set_bit(EV_ABS, idev->evbit); - input_set_abs_params(idev, ABS_X, - MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0); - input_set_abs_params(idev, ABS_Y, - MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0); - input_set_abs_params(idev, ABS_Z, - MPU3050_MIN_VALUE, MPU3050_MAX_VALUE, 0, 0); - - input_set_drvdata(idev, sensor); - - pm_runtime_set_active(&client->dev); - - error = mpu3050_hw_init(sensor); - if (error) - goto err_pm_set_suspended; - - error = request_threaded_irq(client->irq, - NULL, mpu3050_interrupt_thread, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, - "mpu3050", sensor); - if (error) { - dev_err(&client->dev, - "can't get IRQ %d, error %d\n", client->irq, error); - goto err_pm_set_suspended; - } - - error = input_register_device(idev); - if (error) { - dev_err(&client->dev, "failed to register input device\n"); - goto err_free_irq; - } - - pm_runtime_enable(&client->dev); - pm_runtime_set_autosuspend_delay(&client->dev, MPU3050_AUTO_DELAY); - i2c_set_clientdata(client, sensor); - - return 0; - -err_free_irq: - free_irq(client->irq, sensor); -err_pm_set_suspended: - pm_runtime_set_suspended(&client->dev); -err_free_mem: - input_free_device(idev); - kfree(sensor); - return error; -} - -/** - * mpu3050_remove - remove a sensor - * @client: i2c client of sensor being removed - * - * Our sensor is going away, clean up the resources. - */ -static int mpu3050_remove(struct i2c_client *client) -{ - struct mpu3050_sensor *sensor = i2c_get_clientdata(client); - - pm_runtime_disable(&client->dev); - pm_runtime_set_suspended(&client->dev); - - free_irq(client->irq, sensor); - input_unregister_device(sensor->idev); - kfree(sensor); - - return 0; -} - -#ifdef CONFIG_PM -/** - * mpu3050_suspend - called on device suspend - * @dev: device being suspended - * - * Put the device into sleep mode before we suspend the machine. - */ -static int mpu3050_suspend(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - - mpu3050_set_power_mode(client, 0); - - return 0; -} - -/** - * mpu3050_resume - called on device resume - * @dev: device being resumed - * - * Put the device into powered mode on resume. - */ -static int mpu3050_resume(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - - mpu3050_set_power_mode(client, 1); - msleep(100); /* wait for gyro chip resume */ - - return 0; -} -#endif - -static UNIVERSAL_DEV_PM_OPS(mpu3050_pm, mpu3050_suspend, mpu3050_resume, NULL); - -static const struct i2c_device_id mpu3050_ids[] = { - { "mpu3050", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, mpu3050_ids); - -static const struct of_device_id mpu3050_of_match[] = { - { .compatible = "invn,mpu3050", }, - { }, -}; -MODULE_DEVICE_TABLE(of, mpu3050_of_match); - -static struct i2c_driver mpu3050_i2c_driver = { - .driver = { - .name = "mpu3050", - .pm = &mpu3050_pm, - .of_match_table = mpu3050_of_match, - }, - .probe = mpu3050_probe, - .remove = mpu3050_remove, - .id_table = mpu3050_ids, -}; - -module_i2c_driver(mpu3050_i2c_driver); - -MODULE_AUTHOR("Wistron Corp."); -MODULE_DESCRIPTION("MPU3050 Tri-axis gyroscope driver"); -MODULE_LICENSE("GPL"); -- cgit v1.2.1