Skip to content

Commit 96a938a

Browse files
dtorbleungatchromium
authored andcommitted
Input: atmel_mxt_ts - remove platform data support
Now that there are no users of custom Atmel platform data, and everyone has switched to the generic device properties, we can remove support for the platform data. Acked-by: Nick Dyer <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Benson Leung <[email protected]>
1 parent c0bb060 commit 96a938a

File tree

3 files changed

+55
-107
lines changed

3 files changed

+55
-107
lines changed

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,6 @@ T: git git://github.com/ndyer/linux.git
23942394
S: Maintained
23952395
F: Documentation/devicetree/bindings/input/atmel,maxtouch.txt
23962396
F: drivers/input/touchscreen/atmel_mxt_ts.c
2397-
F: include/linux/platform_data/atmel_mxt_ts.h
23982397

23992398
ATMEL SAMA5D2 ADC DRIVER
24002399
M: Ludovic Desroches <[email protected]>

drivers/input/touchscreen/atmel_mxt_ts.c

Lines changed: 55 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
#include <linux/delay.h>
2424
#include <linux/firmware.h>
2525
#include <linux/i2c.h>
26-
#include <linux/platform_data/atmel_mxt_ts.h>
2726
#include <linux/input/mt.h>
2827
#include <linux/interrupt.h>
2928
#include <linux/of.h>
29+
#include <linux/property.h>
3030
#include <linux/slab.h>
3131
#include <linux/gpio/consumer.h>
3232
#include <linux/property.h>
@@ -269,12 +269,16 @@ static const struct v4l2_file_operations mxt_video_fops = {
269269
.poll = vb2_fop_poll,
270270
};
271271

272+
enum mxt_suspend_mode {
273+
MXT_SUSPEND_DEEP_SLEEP = 0,
274+
MXT_SUSPEND_T9_CTRL = 1,
275+
};
276+
272277
/* Each client has this additional data */
273278
struct mxt_data {
274279
struct i2c_client *client;
275280
struct input_dev *input_dev;
276281
char phys[64]; /* device physical location */
277-
const struct mxt_platform_data *pdata;
278282
struct mxt_object *object_table;
279283
struct mxt_info info;
280284
unsigned int irq;
@@ -326,6 +330,9 @@ struct mxt_data {
326330
/* for config update handling */
327331
struct completion crc_completion;
328332

333+
u32 *t19_keymap;
334+
unsigned int t19_num_keys;
335+
329336
enum mxt_suspend_mode suspend_mode;
330337
};
331338

@@ -745,23 +752,22 @@ static int mxt_write_object(struct mxt_data *data,
745752
static void mxt_input_button(struct mxt_data *data, u8 *message)
746753
{
747754
struct input_dev *input = data->input_dev;
748-
const struct mxt_platform_data *pdata = data->pdata;
749755
int i;
750756

751-
for (i = 0; i < pdata->t19_num_keys; i++) {
752-
if (pdata->t19_keymap[i] == KEY_RESERVED)
757+
for (i = 0; i < data->t19_num_keys; i++) {
758+
if (data->t19_keymap[i] == KEY_RESERVED)
753759
continue;
754760

755761
/* Active-low switch */
756-
input_report_key(input, pdata->t19_keymap[i],
762+
input_report_key(input, data->t19_keymap[i],
757763
!(message[1] & BIT(i)));
758764
}
759765
}
760766

761767
static void mxt_input_sync(struct mxt_data *data)
762768
{
763769
input_mt_report_pointer_emulation(data->input_dev,
764-
data->pdata->t19_num_keys);
770+
data->t19_num_keys);
765771
input_sync(data->input_dev);
766772
}
767773

@@ -1861,7 +1867,6 @@ static void mxt_input_close(struct input_dev *dev);
18611867
static void mxt_set_up_as_touchpad(struct input_dev *input_dev,
18621868
struct mxt_data *data)
18631869
{
1864-
const struct mxt_platform_data *pdata = data->pdata;
18651870
int i;
18661871

18671872
input_dev->name = "Atmel maXTouch Touchpad";
@@ -1875,15 +1880,14 @@ static void mxt_set_up_as_touchpad(struct input_dev *input_dev,
18751880
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
18761881
MXT_PIXELS_PER_MM);
18771882

1878-
for (i = 0; i < pdata->t19_num_keys; i++)
1879-
if (pdata->t19_keymap[i] != KEY_RESERVED)
1883+
for (i = 0; i < data->t19_num_keys; i++)
1884+
if (data->t19_keymap[i] != KEY_RESERVED)
18801885
input_set_capability(input_dev, EV_KEY,
1881-
pdata->t19_keymap[i]);
1886+
data->t19_keymap[i]);
18821887
}
18831888

18841889
static int mxt_initialize_input_device(struct mxt_data *data)
18851890
{
1886-
const struct mxt_platform_data *pdata = data->pdata;
18871891
struct device *dev = &data->client->dev;
18881892
struct input_dev *input_dev;
18891893
int error;
@@ -1949,7 +1953,7 @@ static int mxt_initialize_input_device(struct mxt_data *data)
19491953
}
19501954

19511955
/* If device has buttons we assume it is a touchpad */
1952-
if (pdata->t19_num_keys) {
1956+
if (data->t19_num_keys) {
19531957
mxt_set_up_as_touchpad(input_dev, data);
19541958
mt_flags |= INPUT_MT_POINTER;
19551959
} else {
@@ -2923,51 +2927,42 @@ static void mxt_input_close(struct input_dev *dev)
29232927
mxt_stop(data);
29242928
}
29252929

2926-
static const struct mxt_platform_data *
2927-
mxt_parse_device_properties(struct i2c_client *client)
2930+
static int mxt_parse_device_properties(struct mxt_data *data)
29282931
{
29292932
static const char keymap_property[] = "linux,gpio-keymap";
2930-
struct mxt_platform_data *pdata;
2933+
struct device *dev = &data->client->dev;
29312934
u32 *keymap;
29322935
int n_keys;
29332936
int error;
29342937

2935-
pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
2936-
if (!pdata)
2937-
return ERR_PTR(-ENOMEM);
2938-
2939-
if (device_property_present(&client->dev, keymap_property)) {
2940-
n_keys = device_property_read_u32_array(&client->dev,
2941-
keymap_property,
2938+
if (device_property_present(dev, keymap_property)) {
2939+
n_keys = device_property_read_u32_array(dev, keymap_property,
29422940
NULL, 0);
29432941
if (n_keys <= 0) {
29442942
error = n_keys < 0 ? n_keys : -EINVAL;
2945-
dev_err(&client->dev,
2946-
"invalid/malformed '%s' property: %d\n",
2943+
dev_err(dev, "invalid/malformed '%s' property: %d\n",
29472944
keymap_property, error);
2948-
return ERR_PTR(error);
2945+
return error;
29492946
}
29502947

2951-
keymap = devm_kmalloc_array(&client->dev, n_keys, sizeof(u32),
2948+
keymap = devm_kmalloc_array(dev, n_keys, sizeof(*keymap),
29522949
GFP_KERNEL);
29532950
if (!keymap)
2954-
return ERR_PTR(-ENOMEM);
2951+
return -ENOMEM;
29552952

2956-
error = device_property_read_u32_array(&client->dev,
2957-
keymap_property,
2953+
error = device_property_read_u32_array(dev, keymap_property,
29582954
keymap, n_keys);
29592955
if (error) {
2960-
dev_err(&client->dev,
2961-
"failed to parse '%s' property: %d\n",
2956+
dev_err(dev, "failed to parse '%s' property: %d\n",
29622957
keymap_property, error);
2963-
return ERR_PTR(error);
2958+
return error;
29642959
}
29652960

2966-
pdata->t19_keymap = keymap;
2967-
pdata->t19_num_keys = n_keys;
2961+
data->t19_keymap = keymap;
2962+
data->t19_num_keys = n_keys;
29682963
}
29692964

2970-
return pdata;
2965+
return 0;
29712966
}
29722967

29732968
#ifdef CONFIG_ACPI
@@ -3050,25 +3045,12 @@ static const struct dmi_system_id mxt_dmi_table[] = {
30503045
{ }
30513046
};
30523047

3053-
static int mxt_acpi_probe(struct i2c_client *client)
3048+
static int mxt_prepare_acpi_properties(struct i2c_client *client)
30543049
{
30553050
struct acpi_device *adev;
30563051
const struct dmi_system_id *system_id;
30573052
const struct mxt_acpi_platform_data *acpi_pdata;
30583053

3059-
/*
3060-
* Ignore ACPI devices representing bootloader mode.
3061-
*
3062-
* This is a bit of a hack: Google Chromebook BIOS creates ACPI
3063-
* devices for both application and bootloader modes, but we are
3064-
* interested in application mode only (if device is in bootloader
3065-
* mode we'll end up switching into application anyway). So far
3066-
* application mode addresses were all above 0x40, so we'll use it
3067-
* as a threshold.
3068-
*/
3069-
if (client->addr < 0x40)
3070-
return -ENXIO;
3071-
30723054
adev = ACPI_COMPANION(&client->dev);
30733055
if (!adev)
30743056
return -ENOENT;
@@ -3104,24 +3086,12 @@ static int mxt_acpi_probe(struct i2c_client *client)
31043086
return 0;
31053087
}
31063088
#else
3107-
static int mxt_acpi_probe(struct i2c_client *client)
3089+
static int mxt_prepare_acpi_properties(struct i2c_client *client)
31083090
{
31093091
return -ENOENT;
31103092
}
31113093
#endif
31123094

3113-
static const struct mxt_platform_data *
3114-
mxt_get_platform_data(struct i2c_client *client)
3115-
{
3116-
const struct mxt_platform_data *pdata;
3117-
3118-
pdata = dev_get_platdata(&client->dev);
3119-
if (pdata)
3120-
return pdata;
3121-
3122-
return mxt_parse_device_properties(client);
3123-
}
3124-
31253095
static const struct dmi_system_id chromebook_T9_suspend_dmi[] = {
31263096
{
31273097
.matches = {
@@ -3140,16 +3110,20 @@ static const struct dmi_system_id chromebook_T9_suspend_dmi[] = {
31403110
static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
31413111
{
31423112
struct mxt_data *data;
3143-
const struct mxt_platform_data *pdata;
31443113
int error;
31453114

3146-
error = mxt_acpi_probe(client);
3147-
if (error && error != -ENOENT)
3148-
return error;
3149-
3150-
pdata = mxt_get_platform_data(client);
3151-
if (IS_ERR(pdata))
3152-
return PTR_ERR(pdata);
3115+
/*
3116+
* Ignore ACPI devices representing bootloader mode.
3117+
*
3118+
* This is a bit of a hack: Google Chromebook BIOS creates ACPI
3119+
* devices for both application and bootloader modes, but we are
3120+
* interested in application mode only (if device is in bootloader
3121+
* mode we'll end up switching into application anyway). So far
3122+
* application mode addresses were all above 0x40, so we'll use it
3123+
* as a threshold.
3124+
*/
3125+
if (ACPI_COMPANION(&client->dev) && client->addr < 0x40)
3126+
return -ENXIO;
31533127

31543128
data = devm_kzalloc(&client->dev, sizeof(struct mxt_data), GFP_KERNEL);
31553129
if (!data)
@@ -3159,7 +3133,6 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
31593133
client->adapter->nr, client->addr);
31603134

31613135
data->client = client;
3162-
data->pdata = pdata;
31633136
data->irq = client->irq;
31643137
i2c_set_clientdata(client, data);
31653138

@@ -3170,6 +3143,14 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
31703143
data->suspend_mode = dmi_check_system(chromebook_T9_suspend_dmi) ?
31713144
MXT_SUSPEND_T9_CTRL : MXT_SUSPEND_DEEP_SLEEP;
31723145

3146+
error = mxt_prepare_acpi_properties(client);
3147+
if (error && error != -ENOENT)
3148+
return error;
3149+
3150+
error = mxt_parse_device_properties(data);
3151+
if (error)
3152+
return error;
3153+
31733154
data->reset_gpio = devm_gpiod_get_optional(&client->dev,
31743155
"reset", GPIOD_OUT_LOW);
31753156
if (IS_ERR(data->reset_gpio)) {
@@ -3179,8 +3160,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
31793160
}
31803161

31813162
error = devm_request_threaded_irq(&client->dev, client->irq,
3182-
NULL, mxt_interrupt,
3183-
pdata->irqflags | IRQF_ONESHOT,
3163+
NULL, mxt_interrupt, IRQF_ONESHOT,
31843164
client->name, data);
31853165
if (error) {
31863166
dev_err(&client->dev, "Failed to register interrupt\n");
@@ -3300,7 +3280,7 @@ MODULE_DEVICE_TABLE(i2c, mxt_id);
33003280
static struct i2c_driver mxt_driver = {
33013281
.driver = {
33023282
.name = "atmel_mxt_ts",
3303-
.of_match_table = of_match_ptr(mxt_of_match),
3283+
.of_match_table = mxt_of_match,
33043284
.acpi_match_table = ACPI_PTR(mxt_acpi_id),
33053285
.pm = &mxt_pm_ops,
33063286
},

include/linux/platform_data/atmel_mxt_ts.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)