Title: [8818] trunk/drivers/input/misc: input: ad714x: merge changes from mainline
Revision
8818
Author
vapier
Date
2010-05-23 00:35:04 -0400 (Sun, 23 May 2010)

Log Message

input: ad714x: merge changes from mainline

Modified Paths


Diff

Modified: trunk/drivers/input/misc/Kconfig (8817 => 8818)


--- trunk/drivers/input/misc/Kconfig	2010-05-23 04:30:06 UTC (rev 8817)
+++ trunk/drivers/input/misc/Kconfig	2010-05-23 04:35:04 UTC (rev 8818)
@@ -22,6 +22,36 @@
 	  To compile this driver as a module, choose M here: the module
 	  will be called 88pm860x_onkey.
 
+config INPUT_AD714X
+	tristate "Analog Devices AD714x Capacitance Touch Sensor"
+	help
+	  Say Y here if you want to support an AD7142/3/7/8/7A touch sensor.
+
+	  You should select a bus connection too.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ad714x.
+
+config INPUT_AD714X_I2C
+	tristate "support I2C bus connection"
+	depends on INPUT_AD714X && I2C
+	default y
+	help
+	  Say Y here if you have AD7142/AD7147 hooked to an I2C bus.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ad714x-i2c.
+
+config INPUT_AD714X_SPI
+	tristate "support SPI bus connection"
+	depends on INPUT_AD714X && SPI
+	default y
+	help
+	  Say Y here if you have AD7142/AD7147 hooked to a SPI bus.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ad714x-spi.
+
 config INPUT_PCSPKR
 	tristate "PC Speaker support"
 	depends on PCSPKR_PLATFORM
@@ -350,36 +380,6 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called pcap_keys.
 
-config INPUT_AD714X
-	tristate "Analog Devices AD714x Capacitance Touch Sensor"
-	help
-	  Say Y here if you want to support an AD7142/3/7/8/7A touch sensor.
-
-	  You should select a bus connection too.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ad714x.
-
-config INPUT_AD714X_I2C
-	tristate "support I2C bus connection"
-	depends on INPUT_AD714X && I2C
-	default y
-	help
-	  Say Y here if you have AD7142/AD7147 hooked to an I2C bus.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ad714x-i2c.
-
-config INPUT_AD714X_SPI
-	tristate "support SPI bus connection"
-	depends on INPUT_AD714X && SPI
-	default y
-	help
-	  Say Y here if you have AD7142/AD7147 hooked to a SPI bus.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ad714x-spi.
-
 config INPUT_ADXL34X
 	tristate "Analog Devices ADXL34x Three-Axis Digital Accelerometer"
 	default n

Modified: trunk/drivers/input/misc/ad714x-i2c.c (8817 => 8818)


--- trunk/drivers/input/misc/ad714x-i2c.c	2010-05-23 04:30:06 UTC (rev 8817)
+++ trunk/drivers/input/misc/ad714x-i2c.c	2010-05-23 04:35:04 UTC (rev 8818)
@@ -28,7 +28,7 @@
 #endif
 
 static int ad714x_i2c_write(struct device *dev, unsigned short reg,
-		unsigned short data)
+				unsigned short data)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	int ret = 0;
@@ -50,7 +50,7 @@
 }
 
 static int ad714x_i2c_read(struct device *dev, unsigned short reg,
-		unsigned short *data)
+				unsigned short *data)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	int ret = 0;
@@ -64,39 +64,42 @@
 	u8 rx[2];
 
 	ret = i2c_master_send(client, tx, 2);
-	if (ret < 0) {
-		dev_err(&client->dev, "I2C read error\n");
-		return ret;
-	}
+	if (ret >= 0)
+		ret = i2c_master_recv(client, rx, 2);
 
-	ret = i2c_master_recv(client, rx, 2);
-	if (ret < 0) {
+	if (unlikely(ret < 0)) {
 		dev_err(&client->dev, "I2C read error\n");
-		return ret;
+	} else {
+		_data[0] = rx[1];
+		_data[1] = rx[0];
 	}
 
-	_data[0] = rx[1];
-	_data[1] = rx[0];
-
 	return ret;
 }
 
 static int __devinit ad714x_i2c_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
+					const struct i2c_device_id *id)
 {
-	int ret = 0;
-	struct ad714x_chip *chip = NULL;
+	struct ad714x_chip *chip;
 
-	ret = ad714x_probe(&chip, &client->dev, BUS_I2C, client->irq,
-		ad714x_i2c_read, ad714x_i2c_write);
+	chip = ad714x_probe(&client->dev, BUS_I2C, client->irq,
+			    ad714x_i2c_read, ad714x_i2c_write);
+	if (IS_ERR(chip))
+		return PTR_ERR(chip);
+
 	i2c_set_clientdata(client, chip);
 
-	return ret;
+	return 0;
 }
 
 static int __devexit ad714x_i2c_remove(struct i2c_client *client)
 {
-	return ad714x_remove(i2c_get_clientdata(client));
+	struct ad714x_chip *chip = i2c_get_clientdata(client);
+
+	ad714x_remove(chip);
+	i2c_set_clientdata(client, NULL);
+
+	return 0;
 }
 
 static const struct i2c_device_id ad714x_id[] = {

Modified: trunk/drivers/input/misc/ad714x-spi.c (8817 => 8818)


--- trunk/drivers/input/misc/ad714x-spi.c	2010-05-23 04:30:06 UTC (rev 8817)
+++ trunk/drivers/input/misc/ad714x-spi.c	2010-05-23 04:35:04 UTC (rev 8818)
@@ -53,19 +53,26 @@
 
 static int __devinit ad714x_spi_probe(struct spi_device *spi)
 {
-	int ret;
-	struct ad714x_chip *chip = NULL;
+	struct ad714x_chip *chip;
 
-	ret = ad714x_probe(&chip, &spi->dev, BUS_SPI, spi->irq,
-		ad714x_spi_read, ad714x_spi_write);
+	chip = ad714x_probe(&spi->dev, BUS_SPI, spi->irq,
+			    ad714x_spi_read, ad714x_spi_write);
+	if (IS_ERR(chip))
+		return PTR_ERR(chip);
+
 	spi_set_drvdata(spi, chip);
 
-	return ret;
+	return 0;
 }
 
 static int __devexit ad714x_spi_remove(struct spi_device *spi)
 {
-	return ad714x_remove(spi_get_drvdata(spi));
+	struct ad714x_chip *chip = spi_get_drvdata(spi);
+
+	ad714x_remove(chip);
+	spi_set_drvdata(spi, NULL);
+
+	return 0;
 }
 
 static struct spi_driver ad714x_spi_driver = {

Modified: trunk/drivers/input/misc/ad714x.c (8817 => 8818)


--- trunk/drivers/input/misc/ad714x.c	2010-05-23 04:30:06 UTC (rev 8817)
+++ trunk/drivers/input/misc/ad714x.c	2010-05-23 04:35:04 UTC (rev 8818)
@@ -66,13 +66,13 @@
 /*
  * driver information which will be used to maintain the software flow
  */
-typedef enum {IDLE, JITTER, ACTIVE, SPACE} ad714x_device_state;
+enum ad714x_device_state { IDLE, JITTER, ACTIVE, SPACE };
 
 struct ad714x_slider_drv {
 	int highest_stage;
 	int abs_pos;
 	int flt_pos;
-	ad714x_device_state state;
+	enum ad714x_device_state state;
 	struct input_dev *input;
 };
 
@@ -87,7 +87,7 @@
 	int pos_offset;
 	int pos_ratio;
 	int highest_stage;
-	ad714x_device_state state;
+	enum ad714x_device_state state;
 	struct input_dev *input;
 };
 
@@ -106,13 +106,14 @@
 	int top_ep_val;
 	int bottom_ep;
 	int bottom_ep_val;
-	ad714x_device_state state;
+	enum ad714x_device_state state;
 	struct input_dev *input;
 };
 
 struct ad714x_button_drv {
-	ad714x_device_state state;
-	/* Unlike slider/wheel/touchpad, all buttons point to
+	enum ad714x_device_state state;
+	/*
+	 * Unlike slider/wheel/touchpad, all buttons point to
 	 * same input_dev instance
 	 */
 	struct input_dev *input;
@@ -125,7 +126,8 @@
 	struct ad714x_button_drv *button;
 };
 
-/* information to integrate all things which will be private data
+/*
+ * information to integrate all things which will be private data
  * of spi/i2c device
  */
 struct ad714x_chip {
@@ -141,8 +143,8 @@
 
 	int irq;
 	struct device *dev;
-	ad714x_read_t *read;
-	ad714x_write_t *write;
+	ad714x_read_t read;
+	ad714x_write_t write;
 
 	struct mutex mutex;
 
@@ -150,8 +152,8 @@
 	unsigned version;
 };
 
-static void ad714x_use_com_int(struct ad714x_chip *ad714x, int start_stage,
-		int end_stage)
+static void ad714x_use_com_int(struct ad714x_chip *ad714x,
+				int start_stage, int end_stage)
 {
 	unsigned short data;
 	unsigned short mask;
@@ -167,8 +169,8 @@
 	ad714x->write(ad714x->dev, STG_HIGH_INT_EN_REG, data);
 }
 
-static void ad714x_use_thr_int(struct ad714x_chip *ad714x, int start_stage,
-		int end_stage)
+static void ad714x_use_thr_int(struct ad714x_chip *ad714x,
+				int start_stage, int end_stage)
 {
 	unsigned short data;
 	unsigned short mask;
@@ -184,8 +186,8 @@
 	ad714x->write(ad714x->dev, STG_HIGH_INT_EN_REG, data);
 }
 
-static int ad714x_cal_highest_stage(struct ad714x_chip *ad714x, int start_stage,
-		int end_stage)
+static int ad714x_cal_highest_stage(struct ad714x_chip *ad714x,
+					int start_stage, int end_stage)
 {
 	int max_res = 0;
 	int max_idx = 0;
@@ -201,8 +203,9 @@
 	return max_idx;
 }
 
-static int ad714x_cal_abs_pos(struct ad714x_chip *ad714x, int start_stage,
-		int end_stage, int highest_stage, int max_coord)
+static int ad714x_cal_abs_pos(struct ad714x_chip *ad714x,
+				int start_stage, int end_stage,
+				int highest_stage, int max_coord)
 {
 	int a_param, b_param;
 
@@ -232,8 +235,8 @@
 	return (max_coord / (end_stage - start_stage)) * a_param / b_param;
 }
 
-
-/* One button can connect to multi positive and negative of CDCs
+/*
+ * One button can connect to multi positive and negative of CDCs
  * Multi-buttons can connect to same positive/negative of one CDC
  */
 static void ad714x_button_state_machine(struct ad714x_chip *ad714x, int idx)
@@ -244,31 +247,34 @@
 	switch (sw->state) {
 	case IDLE:
 		if (((ad714x->h_state & hw->h_mask) == hw->h_mask) &&
-			((ad714x->l_state & hw->l_mask) == hw->l_mask)) {
+		    ((ad714x->l_state & hw->l_mask) == hw->l_mask)) {
 			dev_dbg(ad714x->dev, "button %d touched\n", idx);
 			input_report_key(sw->input, hw->keycode, 1);
 			input_sync(sw->input);
 			sw->state = ACTIVE;
 		}
 		break;
+
 	case ACTIVE:
 		if (((ad714x->h_state & hw->h_mask) != hw->h_mask) ||
-			((ad714x->l_state & hw->l_mask) != hw->l_mask)) {
+		    ((ad714x->l_state & hw->l_mask) != hw->l_mask)) {
 			dev_dbg(ad714x->dev, "button %d released\n", idx);
 			input_report_key(sw->input, hw->keycode, 0);
 			input_sync(sw->input);
 			sw->state = IDLE;
 		}
 		break;
+
 	default:
 		break;
 	}
 }
 
-/* The response of a sensor is defined by the absolute number of codes
+/*
+ * The response of a sensor is defined by the absolute number of codes
  * between the current CDC value and the ambient value.
  */
-void ad714x_slider_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
+static void ad714x_slider_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx];
 	int i;
@@ -285,7 +291,7 @@
 	}
 }
 
-void ad714x_slider_cal_highest_stage(struct ad714x_chip *ad714x, int idx)
+static void ad714x_slider_cal_highest_stage(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx];
 	struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx];
@@ -297,7 +303,8 @@
 		sw->highest_stage);
 }
 
-/* The formulae are very straight forward. It uses the sensor with the
+/*
+ * The formulae are very straight forward. It uses the sensor with the
  * highest response and the 2 adjacent ones.
  * When Sensor 0 has the highest response, only sensor 0 and sensor 1
  * are used in the calculations. Similarly when the last sensor has the
@@ -309,7 +316,7 @@
  *         w += Sensor response(i)
  * POS=(Number_of_Positions_Wanted/(Number_of_Sensors_Used-1)) *(v/w)
  */
-void ad714x_slider_cal_abs_pos(struct ad714x_chip *ad714x, int idx)
+static void ad714x_slider_cal_abs_pos(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx];
 	struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx];
@@ -329,9 +336,9 @@
  * in firmware and attenuates the noise on the CDC results after they've
  * been read by the host processor.
  * Filtered_CDC_result = (Filtered_CDC_result * (10 - Coefficient) +
- * 				Latest_CDC_result * Coefficient)/10
+ *				Latest_CDC_result * Coefficient)/10
  */
-void ad714x_slider_cal_flt_pos(struct ad714x_chip *ad714x, int idx)
+static void ad714x_slider_cal_flt_pos(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx];
 
@@ -345,12 +352,14 @@
 static void ad714x_slider_use_com_int(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx];
+
 	ad714x_use_com_int(ad714x, hw->start_stage, hw->end_stage);
 }
 
 static void ad714x_slider_use_thr_int(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx];
+
 	ad714x_use_thr_int(ad714x, hw->start_stage, hw->end_stage);
 }
 
@@ -377,6 +386,7 @@
 			dev_dbg(ad714x->dev, "slider %d touched\n", idx);
 		}
 		break;
+
 	case JITTER:
 		if (c_state == mask) {
 			ad714x_slider_cal_sensor_val(ad714x, idx);
@@ -386,6 +396,7 @@
 			sw->state = ACTIVE;
 		}
 		break;
+
 	case ACTIVE:
 		if (c_state == mask) {
 			if (h_state) {
@@ -409,12 +420,14 @@
 			input_sync(sw->input);
 		}
 		break;
+
 	default:
 		break;
 	}
 }
 
-/* When the scroll wheel is activated, we compute the absolute position based
+/*
+ * When the scroll wheel is activated, we compute the absolute position based
  * on the sensor values. To calculate the position, we first determine the
  * sensor that has the greatest response among the 8 sensors that constitutes
  * the scrollwheel. Then we determined the 2 sensors on either sides of the
@@ -452,7 +465,8 @@
 	}
 }
 
-/* When the scroll wheel is activated, we compute the absolute position based
+/*
+ * When the scroll wheel is activated, we compute the absolute position based
  * on the sensor values. To calculate the position, we first determine the
  * sensor that has the greatest response among the 8 sensors that constitutes
  * the scrollwheel. Then we determined the 2 sensors on either sides of the
@@ -464,7 +478,6 @@
  *         w += Sensor response(i)
  * Mean_Value=v/w
  * pos_on_scrollwheel = (Mean_Value - position_offset) / position_ratio
- *
  */
 
 #define WEIGHT_FACTOR 30
@@ -487,7 +500,7 @@
 	second_after = (sw->highest_stage + stage_num + 2) % stage_num;
 
 	if (((sw->highest_stage - hw->start_stage) > 1) &&
-			((hw->end_stage - sw->highest_stage) > 1)) {
+	    ((hw->end_stage - sw->highest_stage) > 1)) {
 		a_param = ad714x->sensor_val[second_before] *
 			(second_before - hw->start_stage + 3) +
 			ad714x->sensor_val[first_before] *
@@ -529,6 +542,7 @@
 	else if ((sw->pre_highest_stage == hw->start_stage) &&
 			(sw->highest_stage == hw->end_stage))
 		sw->pos_offset = sw->pre_mean_value;
+
 	if (sw->pos_offset > OFFSET_POSITION_CLAMP)
 		sw->pos_offset = OFFSET_POSITION_CLAMP;
 
@@ -559,9 +573,9 @@
 	struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx];
 	struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx];
 	if (((sw->pre_highest_stage == hw->end_stage) &&
-				(sw->highest_stage == hw->start_stage)) ||
-			((sw->pre_highest_stage == hw->start_stage) &&
-			 (sw->highest_stage == hw->end_stage)))
+			(sw->highest_stage == hw->start_stage)) ||
+	    ((sw->pre_highest_stage == hw->start_stage) &&
+			(sw->highest_stage == hw->end_stage)))
 		sw->flt_pos = sw->abs_pos;
 	else
 		sw->flt_pos = ((sw->flt_pos * 30) + (sw->abs_pos * 71)) / 100;
@@ -573,12 +587,14 @@
 static void ad714x_wheel_use_com_int(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx];
+
 	ad714x_use_com_int(ad714x, hw->start_stage, hw->end_stage);
 }
 
 static void ad714x_wheel_use_thr_int(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx];
+
 	ad714x_use_thr_int(ad714x, hw->start_stage, hw->end_stage);
 }
 
@@ -605,6 +621,7 @@
 			dev_dbg(ad714x->dev, "wheel %d touched\n", idx);
 		}
 		break;
+
 	case JITTER:
 		if (c_state == mask)	{
 			ad714x_wheel_cal_sensor_val(ad714x, idx);
@@ -614,6 +631,7 @@
 			sw->state = ACTIVE;
 		}
 		break;
+
 	case ACTIVE:
 		if (c_state == mask) {
 			if (h_state) {
@@ -639,6 +657,7 @@
 			input_sync(sw->input);
 		}
 		break;
+
 	default:
 		break;
 	}
@@ -678,7 +697,8 @@
 		idx, sw->x_highest_stage, sw->y_highest_stage);
 }
 
-/* If 2 fingers are touching the sensor then 2 peaks can be observed in the
+/*
+ * If 2 fingers are touching the sensor then 2 peaks can be observed in the
  * distribution.
  * The arithmetic doesn't support to get absolute coordinates for multi-touch
  * yet.
@@ -716,7 +736,8 @@
 	return 0;
 }
 
-/* If only one finger is used to activate the touch pad then only 1 peak will be
+/*
+ * If only one finger is used to activate the touch pad then only 1 peak will be
  * registered in the distribution. This peak and the 2 adjacent sensors will be
  * used in the calculation of the absolute position. This will prevent hand
  * shadows to affect the absolute position calculation.
@@ -748,7 +769,8 @@
 			idx, sw->x_flt_pos, sw->y_flt_pos);
 }
 
-/* To prevent distortion from showing in the absolute position, it is
+/*
+ * To prevent distortion from showing in the absolute position, it is
  * necessary to detect the end points. When endpoints are detected, the
  * driver stops updating the status variables with absolute positions.
  * End points are detected on the 4 edges of the touchpad sensor. The
@@ -783,8 +805,8 @@
 		}
 	} else {
 		if ((percent_sensor_diff < LEFT_END_POINT_DETECTION_LEVEL) &&
-		(ad714x->sensor_val[hw->x_start_stage + 1] >
-		LEFT_RIGHT_END_POINT_DEAVTIVALION_LEVEL + sw->left_ep_val))
+		    (ad714x->sensor_val[hw->x_start_stage + 1] >
+		     LEFT_RIGHT_END_POINT_DEAVTIVALION_LEVEL + sw->left_ep_val))
 			sw->left_ep = 0;
 	}
 
@@ -845,12 +867,14 @@
 static void touchpad_use_com_int(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx];
+
 	ad714x_use_com_int(ad714x, hw->x_start_stage, hw->x_end_stage);
 }
 
 static void touchpad_use_thr_int(struct ad714x_chip *ad714x, int idx)
 {
 	struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx];
+
 	ad714x_use_thr_int(ad714x, hw->x_start_stage, hw->x_end_stage);
 	ad714x_use_thr_int(ad714x, hw->y_start_stage, hw->y_end_stage);
 }
@@ -881,6 +905,7 @@
 			dev_dbg(ad714x->dev, "touchpad %d touched\n", idx);
 		}
 		break;
+
 	case JITTER:
 		if (c_state == mask) {
 			touchpad_cal_sensor_val(ad714x, idx);
@@ -897,6 +922,7 @@
 			}
 		}
 		break;
+
 	case ACTIVE:
 		if (c_state == mask) {
 			if (h_state) {
@@ -926,6 +952,7 @@
 			input_sync(sw->input);
 		}
 		break;
+
 	default:
 		break;
 	}
@@ -943,18 +970,21 @@
 		dev_info(ad714x->dev, "found AD7142 captouch, rev:%d\n",
 				ad714x->version);
 		return 0;
+
 	case AD7143_PARTID:
 		ad714x->product = 0x7143;
 		ad714x->version = data & 0xF;
 		dev_info(ad714x->dev, "found AD7143 captouch, rev:%d\n",
 				ad714x->version);
 		return 0;
+
 	case AD7147_PARTID:
 		ad714x->product = 0x7147;
 		ad714x->version = data & 0xF;
 		dev_info(ad714x->dev, "found AD7147(A) captouch, rev:%d\n",
 				ad714x->version);
 		return 0;
+
 	case AD7148_PARTID:
 		ad714x->product = 0x7148;
 		ad714x->version = data & 0xF;
@@ -976,7 +1006,7 @@
 	unsigned short reg_base;
 	unsigned short data;
 
-	/* configuration CDC and interrupts*/
+	/* configuration CDC and interrupts */
 
 	for (i = 0; i < STAGE_NUM; i++) {
 		reg_base = AD714X_STAGECFG_REG + i * STAGE_CFGREG_NUM;
@@ -1025,19 +1055,15 @@
 	return IRQ_HANDLED;
 }
 
-static irqreturn_t ad714x_interrupt(int irq, void *data)
-{
-	return IRQ_WAKE_THREAD;
-}
-
 #define MAX_DEVICE_NUM 8
-int ad714x_probe(struct ad714x_chip **pad714x, struct device *dev,
-	u16 bus_type, int irq, ad714x_read_t read, ad714x_write_t write)
+struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
+				 ad714x_read_t read, ad714x_write_t write)
 {
-	int ret, i, alloc_idx;
+	int i, alloc_idx;
+	int error;
 	struct input_dev *input[MAX_DEVICE_NUM];
 
-	struct ad714x_platform_data *plat_data;
+	struct ad714x_platform_data *plat_data = dev->platform_data;
 	struct ad714x_chip *ad714x;
 	void *drv_mem;
 
@@ -1046,19 +1072,29 @@
 	struct ad714x_wheel_drv *wl_drv;
 	struct ad714x_touchpad_drv *tp_drv;
 
-	plat_data = dev->platform_data;
+
+	if (irq <= 0) {
+		dev_err(dev, "IRQ not configured!\n");
+		error = -EINVAL;
+		goto err_out;
+	}
+
 	if (dev->platform_data == NULL) {
 		dev_err(dev, "platform data for ad714x doesn't exist\n");
-		return -ENODEV;
+		error = -EINVAL;
+		goto err_out;
 	}
 
-	*pad714x = ad714x = kzalloc(sizeof(*ad714x) + sizeof(*ad714x->sw) +
-			sizeof(*sd_drv) * plat_data->slider_num +
-			sizeof(*wl_drv) * plat_data->wheel_num +
-			sizeof(*tp_drv) * plat_data->touchpad_num +
-			sizeof(*bt_drv) * plat_data->button_num, GFP_KERNEL);
-	if (!ad714x)
-		return -ENOMEM;
+	ad714x = kzalloc(sizeof(*ad714x) + sizeof(*ad714x->sw) +
+			 sizeof(*sd_drv) * plat_data->slider_num +
+			 sizeof(*wl_drv) * plat_data->wheel_num +
+			 sizeof(*tp_drv) * plat_data->touchpad_num +
+			 sizeof(*bt_drv) * plat_data->button_num, GFP_KERNEL);
+	if (!ad714x) {
+		error = -ENOMEM;
+		goto err_out;
+	}
+
 	ad714x->hw = plat_data;
 
 	drv_mem = ad714x + 1;
@@ -1078,30 +1114,15 @@
 	ad714x->irq = irq;
 	ad714x->dev = dev;
 
-	ret = ad714x_hw_detect(ad714x);
-	if (ret)
-		goto det_err;
+	error = ad714x_hw_detect(ad714x);
+	if (error)
+		goto err_free_mem;
 
 	/* initilize and request sw/hw resources */
 
 	ad714x_hw_init(ad714x);
 	mutex_init(&ad714x->mutex);
 
-	if (ad714x->irq > 0) {
-		ret = request_threaded_irq(ad714x->irq, ad714x_interrupt,
-				ad714x_interrupt_thread, IRQF_TRIGGER_FALLING,
-				"ad714x_captouch", ad714x);
-		if (ret) {
-			dev_err(dev, "can't allocate irq %d\n",
-					ad714x->irq);
-			goto fail_irq;
-		}
-	} else {
-		dev_err(dev, "IRQ not configured!\n");
-		ret = -EINVAL;
-		goto det_err;
-	}
-
 	/*
 	 * Allocate and register AD714X input device
 	 */
@@ -1114,24 +1135,24 @@
 		for (i = 0; i < ad714x->hw->slider_num; i++) {
 			sd_drv[i].input = input[alloc_idx] = input_allocate_device();
 			if (!input[alloc_idx]) {
-				ret = -ENOMEM;
-				goto fail_alloc_reg;
+				error = -ENOMEM;
+				goto err_free_dev;
 			}
 
 			__set_bit(EV_ABS, input[alloc_idx]->evbit);
 			__set_bit(EV_KEY, input[alloc_idx]->evbit);
 			__set_bit(ABS_X, input[alloc_idx]->absbit);
 			__set_bit(BTN_TOUCH, input[alloc_idx]->keybit);
-			input_set_abs_params(input[alloc_idx], ABS_X, 0,
-					sd_plat->max_coord, 0, 0);
+			input_set_abs_params(input[alloc_idx],
+				ABS_X, 0, sd_plat->max_coord, 0, 0);
 
 			input[alloc_idx]->id.bustype = bus_type;
 			input[alloc_idx]->id.product = ad714x->product;
 			input[alloc_idx]->id.version = ad714x->version;
 
-			ret = input_register_device(input[alloc_idx]);
-			if (ret)
-				goto fail_alloc_reg;
+			error = input_register_device(input[alloc_idx]);
+			if (error)
+				goto err_free_dev;
 
 			alloc_idx++;
 		}
@@ -1144,24 +1165,24 @@
 		for (i = 0; i < ad714x->hw->wheel_num; i++) {
 			wl_drv[i].input = input[alloc_idx] = input_allocate_device();
 			if (!input[alloc_idx]) {
-				ret = -ENOMEM;
-				goto fail_alloc_reg;
+				error = -ENOMEM;
+				goto err_free_dev;
 			}
 
 			__set_bit(EV_KEY, input[alloc_idx]->evbit);
 			__set_bit(EV_ABS, input[alloc_idx]->evbit);
 			__set_bit(ABS_WHEEL, input[alloc_idx]->absbit);
 			__set_bit(BTN_TOUCH, input[alloc_idx]->keybit);
-			input_set_abs_params(input[alloc_idx], ABS_WHEEL, 0,
-					wl_plat->max_coord, 0, 0);
+			input_set_abs_params(input[alloc_idx],
+				ABS_WHEEL, 0, wl_plat->max_coord, 0, 0);
 
 			input[alloc_idx]->id.bustype = bus_type;
 			input[alloc_idx]->id.product = ad714x->product;
 			input[alloc_idx]->id.version = ad714x->version;
 
-			ret = input_register_device(input[alloc_idx]);
-			if (ret)
-				goto fail_alloc_reg;
+			error = input_register_device(input[alloc_idx]);
+			if (error)
+				goto err_free_dev;
 
 			alloc_idx++;
 		}
@@ -1174,8 +1195,8 @@
 		for (i = 0; i < ad714x->hw->touchpad_num; i++) {
 			tp_drv[i].input = input[alloc_idx] = input_allocate_device();
 			if (!input[alloc_idx]) {
-				ret = -ENOMEM;
-				goto fail_alloc_reg;
+				error = -ENOMEM;
+				goto err_free_dev;
 			}
 
 			__set_bit(EV_ABS, input[alloc_idx]->evbit);
@@ -1183,18 +1204,18 @@
 			__set_bit(ABS_X, input[alloc_idx]->absbit);
 			__set_bit(ABS_Y, input[alloc_idx]->absbit);
 			__set_bit(BTN_TOUCH, input[alloc_idx]->keybit);
-			input_set_abs_params(input[alloc_idx], ABS_X, 0,
-					tp_plat->x_max_coord, 0, 0);
-			input_set_abs_params(input[alloc_idx], ABS_Y, 0,
-					tp_plat->y_max_coord, 0, 0);
+			input_set_abs_params(input[alloc_idx],
+				ABS_X, 0, tp_plat->x_max_coord, 0, 0);
+			input_set_abs_params(input[alloc_idx],
+				ABS_Y, 0, tp_plat->y_max_coord, 0, 0);
 
 			input[alloc_idx]->id.bustype = bus_type;
 			input[alloc_idx]->id.product = ad714x->product;
 			input[alloc_idx]->id.version = ad714x->version;
 
-			ret = input_register_device(input[alloc_idx]);
-			if (ret)
-				goto fail_alloc_reg;
+			error = input_register_device(input[alloc_idx]);
+			if (error)
+				goto err_free_dev;
 
 			alloc_idx++;
 		}
@@ -1206,8 +1227,8 @@
 
 		input[alloc_idx] = input_allocate_device();
 		if (!input[alloc_idx]) {
-			ret = -ENOMEM;
-			goto fail_alloc_reg;
+			error = -ENOMEM;
+			goto err_free_dev;
 		}
 
 		__set_bit(EV_KEY, input[alloc_idx]->evbit);
@@ -1220,53 +1241,58 @@
 		input[alloc_idx]->id.product = ad714x->product;
 		input[alloc_idx]->id.version = ad714x->version;
 
-		ret = input_register_device(input[alloc_idx]);
-		if (ret)
-			goto fail_alloc_reg;
+		error = input_register_device(input[alloc_idx]);
+		if (error)
+			goto err_free_dev;
 
 		alloc_idx++;
 	}
 
+	error = request_threaded_irq(ad714x->irq, NULL, ad714x_interrupt_thread,
+			IRQF_TRIGGER_FALLING, "ad714x_captouch", ad714x);
+	if (error) {
+		dev_err(dev, "can't allocate irq %d\n", ad714x->irq);
+		goto err_unreg_dev;
+	}
 
-	return 0;
+	return ad714x;
 
- fail_alloc_reg:
+ err_free_dev:
 	dev_err(dev, "failed to setup AD714x input device %i\n", alloc_idx);
-	for (i = 0; i < alloc_idx - 1; i++)
-		input_unregister_device(input[i]);
 	input_free_device(input[alloc_idx]);
-
-	free_irq(ad714x->irq, ad714x);
- fail_irq:
- det_err:
+ err_unreg_dev:
+	while (--alloc_idx >= 0)
+		input_unregister_device(input[alloc_idx]);
+ err_free_mem:
 	kfree(ad714x);
-	return ret;
+ err_out:
+	return ERR_PTR(error);
 }
 EXPORT_SYMBOL(ad714x_probe);
 
-int ad714x_remove(struct ad714x_chip *ad714x)
+void ad714x_remove(struct ad714x_chip *ad714x)
 {
+	struct ad714x_platform_data *hw = ad714x->hw;
+	struct ad714x_driver_data *sw = ad714x->sw;
 	int i;
 
+	free_irq(ad714x->irq, ad714x);
+
 	/* unregister and free all input devices */
 
-	for (i = 0; i < ad714x->hw->slider_num; i++)
-		input_unregister_device(ad714x->sw->slider[i].input);
+	for (i = 0; i < hw->slider_num; i++)
+		input_unregister_device(sw->slider[i].input);
 
-	for (i = 0; i < ad714x->hw->wheel_num; i++)
-		input_unregister_device(ad714x->sw->wheel[i].input);
+	for (i = 0; i < hw->wheel_num; i++)
+		input_unregister_device(sw->wheel[i].input);
 
-	for (i = 0; i < ad714x->hw->touchpad_num; i++)
-		input_unregister_device(ad714x->sw->touchpad[i].input);
+	for (i = 0; i < hw->touchpad_num; i++)
+		input_unregister_device(sw->touchpad[i].input);
 
-	if (ad714x->hw->button_num)
-		input_unregister_device(ad714x->sw->button[0].input);
+	if (hw->button_num)
+		input_unregister_device(sw->button[0].input);
 
-	free_irq(ad714x->irq, ad714x);
-
 	kfree(ad714x);
-
-	return 0;
 }
 EXPORT_SYMBOL(ad714x_remove);
 

Modified: trunk/drivers/input/misc/ad714x.h (8817 => 8818)


--- trunk/drivers/input/misc/ad714x.h	2010-05-23 04:30:06 UTC (rev 8817)
+++ trunk/drivers/input/misc/ad714x.h	2010-05-23 04:35:04 UTC (rev 8818)
@@ -13,13 +13,14 @@
 
 struct device;
 struct ad714x_chip;
-typedef int (ad714x_read_t) (struct device *, unsigned short, unsigned short *);
-typedef int (ad714x_write_t) (struct device *, unsigned short, unsigned short);
 
+typedef int (*ad714x_read_t)(struct device *, unsigned short, unsigned short *);
+typedef int (*ad714x_write_t)(struct device *, unsigned short, unsigned short);
+
 int ad714x_disable(struct ad714x_chip *ad714x);
 int ad714x_enable(struct ad714x_chip *ad714x);
-int ad714x_probe(struct ad714x_chip **pad714x, struct device *dev,
-	u16 bus_type, int irq, ad714x_read_t read, ad714x_write_t write);
-int ad714x_remove(struct ad714x_chip *ad714x);
+struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
+				 ad714x_read_t read, ad714x_write_t write);
+void ad714x_remove(struct ad714x_chip *ad714x);
 
 #endif
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to