--- zzzz-none-000/linux-3.10.107/drivers/input/touchscreen/mcs5000_ts.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/input/touchscreen/mcs5000_ts.c 2021-02-04 17:41:59.000000000 +0000 @@ -14,7 +14,6 @@ */ #include -#include #include #include #include @@ -162,10 +161,9 @@ return IRQ_HANDLED; } -static void mcs5000_ts_phys_init(struct mcs5000_ts_data *data) +static void mcs5000_ts_phys_init(struct mcs5000_ts_data *data, + const struct mcs_platform_data *platform_data) { - const struct mcs_platform_data *platform_data = - data->platform_data; struct i2c_client *client = data->client; /* Touch reset & sleep mode */ @@ -188,28 +186,32 @@ } static int mcs5000_ts_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { + const struct mcs_platform_data *pdata; struct mcs5000_ts_data *data; struct input_dev *input_dev; - int ret; + int error; - if (!client->dev.platform_data) + pdata = dev_get_platdata(&client->dev); + if (!pdata) return -EINVAL; - data = kzalloc(sizeof(struct mcs5000_ts_data), GFP_KERNEL); - input_dev = input_allocate_device(); - if (!data || !input_dev) { + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); + if (!data) { dev_err(&client->dev, "Failed to allocate memory\n"); - ret = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } data->client = client; - data->input_dev = input_dev; - data->platform_data = client->dev.platform_data; - input_dev->name = "MELPAS MCS-5000 Touchscreen"; + input_dev = devm_input_allocate_device(&client->dev); + if (!input_dev) { + dev_err(&client->dev, "Failed to allocate input device\n"); + return -ENOMEM; + } + + input_dev->name = "MELFAS MCS-5000 Touchscreen"; input_dev->id.bustype = BUS_I2C; input_dev->dev.parent = &client->dev; @@ -220,48 +222,33 @@ input_set_abs_params(input_dev, ABS_Y, 0, MCS5000_MAX_YC, 0, 0); input_set_drvdata(input_dev, data); + data->input_dev = input_dev; - if (data->platform_data->cfg_pin) - data->platform_data->cfg_pin(); - - ret = request_threaded_irq(client->irq, NULL, mcs5000_ts_interrupt, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, "mcs5000_ts", data); + if (pdata->cfg_pin) + pdata->cfg_pin(); - if (ret < 0) { + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, mcs5000_ts_interrupt, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + "mcs5000_ts", data); + if (error) { dev_err(&client->dev, "Failed to register interrupt\n"); - goto err_free_mem; + return error; } - ret = input_register_device(data->input_dev); - if (ret < 0) - goto err_free_irq; + error = input_register_device(data->input_dev); + if (error) { + dev_err(&client->dev, "Failed to register input device\n"); + return error; + } - mcs5000_ts_phys_init(data); + mcs5000_ts_phys_init(data, pdata); i2c_set_clientdata(client, data); return 0; - -err_free_irq: - free_irq(client->irq, data); -err_free_mem: - input_free_device(input_dev); - kfree(data); - return ret; -} - -static int mcs5000_ts_remove(struct i2c_client *client) -{ - struct mcs5000_ts_data *data = i2c_get_clientdata(client); - - free_irq(client->irq, data); - input_unregister_device(data->input_dev); - kfree(data); - - return 0; } -#ifdef CONFIG_PM -static int mcs5000_ts_suspend(struct device *dev) +static int __maybe_unused mcs5000_ts_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -271,18 +258,18 @@ return 0; } -static int mcs5000_ts_resume(struct device *dev) +static int __maybe_unused mcs5000_ts_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct mcs5000_ts_data *data = i2c_get_clientdata(client); + const struct mcs_platform_data *pdata = dev_get_platdata(dev); - mcs5000_ts_phys_init(data); + mcs5000_ts_phys_init(data, pdata); return 0; } static SIMPLE_DEV_PM_OPS(mcs5000_ts_pm, mcs5000_ts_suspend, mcs5000_ts_resume); -#endif static const struct i2c_device_id mcs5000_ts_id[] = { { "mcs5000_ts", 0 }, @@ -292,12 +279,9 @@ static struct i2c_driver mcs5000_ts_driver = { .probe = mcs5000_ts_probe, - .remove = mcs5000_ts_remove, .driver = { .name = "mcs5000_ts", -#ifdef CONFIG_PM .pm = &mcs5000_ts_pm, -#endif }, .id_table = mcs5000_ts_id, };