99 * Author: Pieter Truter<ptruter@intrinsyc.com>
1010 */
1111
12- #include <linux/module.h>
13- #include <linux/hrtimer.h>
14- #include <linux/slab.h>
15- #include <linux/input.h>
16- #include <linux/interrupt.h>
17- #include <linux/i2c.h>
1812#include <linux/delay.h>
19- #include <linux/gpio/consumer.h>
2013#include <linux/device.h>
21- #include <linux/sysfs.h>
14+ #include <linux/gpio/consumer.h>
15+ #include <linux/i2c.h>
16+ #include <linux/input.h>
2217#include <linux/input/mt.h>
2318#include <linux/input/touchscreen.h>
24- #include <linux/platform_data/zforce_ts .h>
25- #include <linux/regulator/consumer .h>
19+ #include <linux/interrupt .h>
20+ #include <linux/module .h>
2621#include <linux/of.h>
22+ #include <linux/property.h>
23+ #include <linux/regulator/consumer.h>
24+ #include <linux/slab.h>
2725
2826#define WAIT_TIMEOUT msecs_to_jiffies(1000)
2927
@@ -108,7 +106,6 @@ struct zforce_ts {
108106 struct i2c_client * client ;
109107 struct input_dev * input ;
110108 struct touchscreen_properties prop ;
111- const struct zforce_ts_platdata * pdata ;
112109 char phys [32 ];
113110
114111 struct regulator * reg_vdd ;
@@ -702,39 +699,24 @@ static void zforce_reset(void *data)
702699 regulator_disable (ts -> reg_vdd );
703700}
704701
705- static struct zforce_ts_platdata * zforce_parse_dt (struct device * dev )
702+ static void zforce_ts_parse_legacy_properties (struct zforce_ts * ts )
706703{
707- struct zforce_ts_platdata * pdata ;
708- struct device_node * np = dev -> of_node ;
709-
710- if (!np )
711- return ERR_PTR (- ENOENT );
704+ u32 x_max = 0 ;
705+ u32 y_max = 0 ;
712706
713- pdata = devm_kzalloc (dev , sizeof (* pdata ), GFP_KERNEL );
714- if (!pdata ) {
715- dev_err (dev , "failed to allocate platform data\n" );
716- return ERR_PTR (- ENOMEM );
717- }
718-
719- of_property_read_u32 (np , "x-size" , & pdata -> x_max );
720- of_property_read_u32 (np , "y-size" , & pdata -> y_max );
707+ device_property_read_u32 (& ts -> client -> dev , "x-size" , & x_max );
708+ input_set_abs_params (ts -> input , ABS_MT_POSITION_X , 0 , x_max , 0 , 0 );
721709
722- return pdata ;
710+ device_property_read_u32 (& ts -> client -> dev , "y-size" , & y_max );
711+ input_set_abs_params (ts -> input , ABS_MT_POSITION_Y , 0 , y_max , 0 , 0 );
723712}
724713
725714static int zforce_probe (struct i2c_client * client )
726715{
727- const struct zforce_ts_platdata * pdata = dev_get_platdata (& client -> dev );
728716 struct zforce_ts * ts ;
729717 struct input_dev * input_dev ;
730718 int ret ;
731719
732- if (!pdata ) {
733- pdata = zforce_parse_dt (& client -> dev );
734- if (IS_ERR (pdata ))
735- return PTR_ERR (pdata );
736- }
737-
738720 ts = devm_kzalloc (& client -> dev , sizeof (struct zforce_ts ), GFP_KERNEL );
739721 if (!ts )
740722 return - ENOMEM ;
@@ -822,7 +804,6 @@ static int zforce_probe(struct i2c_client *client)
822804 mutex_init (& ts -> access_mutex );
823805 mutex_init (& ts -> command_mutex );
824806
825- ts -> pdata = pdata ;
826807 ts -> client = client ;
827808 ts -> input = input_dev ;
828809
@@ -837,12 +818,7 @@ static int zforce_probe(struct i2c_client *client)
837818 __set_bit (EV_SYN , input_dev -> evbit );
838819 __set_bit (EV_ABS , input_dev -> evbit );
839820
840- /* For multi touch */
841- input_set_abs_params (input_dev , ABS_MT_POSITION_X , 0 ,
842- pdata -> x_max , 0 , 0 );
843- input_set_abs_params (input_dev , ABS_MT_POSITION_Y , 0 ,
844- pdata -> y_max , 0 , 0 );
845-
821+ zforce_ts_parse_legacy_properties (ts );
846822 touchscreen_parse_properties (input_dev , true, & ts -> prop );
847823 if (ts -> prop .max_x == 0 || ts -> prop .max_y == 0 ) {
848824 dev_err (& client -> dev , "no size specified\n" );
0 commit comments