diff options
Diffstat (limited to 'drivers/input/misc')
27 files changed, 129 insertions, 636 deletions
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/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/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; } diff --git a/drivers/input/misc/arizona-haptics.c b/drivers/input/misc/arizona-haptics.c index 07ec465f1095..21dc1b8b2a4a 100644 --- a/drivers/input/misc/arizona-haptics.c +++ b/drivers/input/misc/arizona-haptics.c @@ -201,8 +201,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/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; } 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; } 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/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; 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/e3x0-button.c b/drivers/input/misc/e3x0-button.c index 13bfca8a7b16..e956cf1d273f 100644 --- a/drivers/input/misc/e3x0-button.c +++ b/drivers/input/misc/e3x0-button.c @@ -120,17 +120,10 @@ static int e3x0_button_probe(struct platform_device *pdev) return error; } - platform_set_drvdata(pdev, input); device_init_wakeup(&pdev->dev, 1); return 0; } -static int e3x0_button_remove(struct platform_device *pdev) -{ - device_init_wakeup(&pdev->dev, 0); - return 0; -} - #ifdef CONFIG_OF static const struct of_device_id e3x0_button_match[] = { { .compatible = "ettus,e3x0-button", }, @@ -146,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/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/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; } 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..dee6245f38d7 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,19 +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); - - return 0; -} - -static int hi65xx_powerkey_remove(struct platform_device *pdev) -{ - device_init_wakeup(&pdev->dev, 0); + device_init_wakeup(dev, 1); return 0; } @@ -133,7 +125,6 @@ static struct platform_driver hi65xx_powerkey_driver = { .name = "hi65xx-powerkey", }, .probe = hi65xx_powerkey_probe, - .remove = hi65xx_powerkey_remove, }; module_platform_driver(hi65xx_powerkey_driver); 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; } 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 <joseph_lai@wistron.com> - * - * Trimmed down by Alan Cox <alan@linux.intel.com> 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 <linux/module.h> -#include <linux/interrupt.h> -#include <linux/platform_device.h> -#include <linux/mutex.h> -#include <linux/err.h> -#include <linux/i2c.h> -#include <linux/input.h> -#include <linux/delay.h> -#include <linux/slab.h> -#include <linux/pm_runtime.h> - -#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"); 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..73323b0c72c1 100644 --- a/drivers/input/misc/pmic8xxx-pwrkey.c +++ b/drivers/input/misc/pmic8xxx-pwrkey.c @@ -438,13 +438,6 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev) return 0; } -static int pmic8xxx_pwrkey_remove(struct platform_device *pdev) -{ - device_init_wakeup(&pdev->dev, 0); - - 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 }, @@ -454,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/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index 5f9655d49a65..e53801dbd560 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -14,6 +14,7 @@ */ #include <linux/input.h> +#include <linux/regulator/consumer.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/of.h> @@ -25,29 +26,62 @@ 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; + struct pwm_state state; + int error; + + pwm_get_state(beeper->pwm, &state); + + 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; + + if (!beeper->amplifier_on) { + error = regulator_enable(beeper->amplifier); + if (error) { + pwm_disable(beeper->pwm); + return error; + } + + beeper->amplifier_on = true; + } + + return 0; +} - if (period) { - pwm_config(beeper->pwm, period / 2, period); - pwm_enable(beeper->pwm); - } else - pwm_disable(beeper->pwm); +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, @@ -73,7 +107,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; } @@ -81,9 +116,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) @@ -95,41 +128,50 @@ 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 device *dev = &pdev->dev; struct pwm_beeper *beeper; + struct pwm_state state; 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)) { - dev_dbg(&pdev->dev, "unable to request PWM, trying legacy API\n"); - beeper->pwm = pwm_request(pwm_id, "pwm beeper"); + error = PTR_ERR(beeper->pwm); + if (error != -EPROBE_DEFER) + dev_err(dev, "Failed to request PWM device: %d\n", + error); + return error; } - 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; + /* 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; } - /* - * FIXME: pwm_apply_args() should be removed when switching to - * the atomic PWM API. - */ - 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 = 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"; @@ -138,8 +180,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; @@ -148,41 +190,28 @@ 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; } 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; @@ -192,8 +221,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; } @@ -211,7 +244,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, 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 ed7237f19539..4fd038d476a3 100644 --- a/drivers/input/misc/sirfsoc-onkey.c +++ b/drivers/input/misc/sirfsoc-onkey.c @@ -172,13 +172,6 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) return 0; } -static int sirfsoc_pwrc_remove(struct platform_device *pdev) -{ - device_init_wakeup(&pdev->dev, 0); - - return 0; -} - static int __maybe_unused sirfsoc_pwrc_resume(struct device *dev) { struct sirfsoc_pwrc_drvdata *pwrcdrv = dev_get_drvdata(dev); @@ -200,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, diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index 908b51089dee..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++; } @@ -167,12 +169,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; diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c index cc74a41bdb0d..a4455bb12ae0 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; } 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; diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 92595b98e7ed..022be0e22eba 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -263,13 +263,21 @@ static int uinput_create_device(struct uinput_device *udev) return -EINVAL; } - if (test_bit(ABS_MT_SLOT, dev->absbit)) { - nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1; - error = input_mt_init_slots(dev, nslot, 0); - if (error) + if (test_bit(EV_ABS, dev->evbit)) { + input_alloc_absinfo(dev); + if (!dev->absinfo) { + error = -EINVAL; goto fail1; - } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) { - input_set_events_per_packet(dev, 60); + } + + if (test_bit(ABS_MT_SLOT, dev->absbit)) { + nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1; + error = input_mt_init_slots(dev, nslot, 0); + if (error) + goto fail1; + } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) { + input_set_events_per_packet(dev, 60); + } } if (test_bit(EV_FF, dev->evbit) && !udev->ff_effects_max) { |