Title: [8184] trunk/drivers/input/touchscreen: ad7879: restructure the bus logic a bit per upstream feedback
Revision
8184
Author
vapier
Date
2010-01-19 03:47:45 -0500 (Tue, 19 Jan 2010)

Log Message

ad7879: restructure the bus logic a bit per upstream feedback

Modified Paths


Diff

Modified: trunk/drivers/input/touchscreen/ad7879-i2c.c (8183 => 8184)


--- trunk/drivers/input/touchscreen/ad7879-i2c.c	2010-01-19 07:04:29 UTC (rev 8183)
+++ trunk/drivers/input/touchscreen/ad7879-i2c.c	2010-01-19 08:47:45 UTC (rev 8184)
@@ -51,15 +51,19 @@
 	return i2c_smbus_write_word_data(client, reg, swab16(val));
 }
 
+static const struct ad7879_bus_ops bops = {
+	.read = ad7879_i2c_read,
+	.multi_read = ad7879_i2c_multi_read,
+	.write = ad7879_i2c_write,
+};
+
 static int __devinit ad7879_i2c_probe(struct i2c_client *client,
 				      const struct i2c_device_id *id)
 {
-	struct ad7879_bus_ops bops = {
-		.bus_data = client,
+	struct ad7879_bus_data bdata = {
+		.client = client,
 		.irq = client->irq,
-		.read = ad7879_i2c_read,
-		.multi_read = ad7879_i2c_multi_read,
-		.write = ad7879_i2c_write,
+		.bops = &bops,
 	};
 
 	if (!i2c_check_functionality(client->adapter,
@@ -68,7 +72,7 @@
 		return -EIO;
 	}
 
-	return ad7879_probe(&client->dev, &bops, AD7879_DEVID, BUS_I2C);
+	return ad7879_probe(&client->dev, &bdata, AD7879_DEVID, BUS_I2C);
 }
 
 static int __devexit ad7879_i2c_remove(struct i2c_client *client)

Modified: trunk/drivers/input/touchscreen/ad7879-spi.c (8183 => 8184)


--- trunk/drivers/input/touchscreen/ad7879-spi.c	2010-01-19 07:04:29 UTC (rev 8183)
+++ trunk/drivers/input/touchscreen/ad7879-spi.c	2010-01-19 08:47:45 UTC (rev 8184)
@@ -108,14 +108,18 @@
 	return ad7879_spi_xfer(spi, AD7879_WRITECMD(reg), 1, &val, &dummy);
 }
 
+static const struct ad7879_bus_ops bops = {
+	.read = ad7879_spi_read,
+	.multi_read = ad7879_spi_multi_read,
+	.write = ad7879_spi_write,
+};
+
 static int __devinit ad7879_spi_probe(struct spi_device *spi)
 {
-	struct ad7879_bus_ops bops = {
-		.bus_data = spi,
+	struct ad7879_bus_data bdata = {
+		.client = spi,
 		.irq = spi->irq,
-		.read = ad7879_spi_read,
-		.multi_read = ad7879_spi_multi_read,
-		.write = ad7879_spi_write,
+		.bops = &bops,
 	};
 
 	/* don't exceed max specified SPI CLK frequency */
@@ -124,7 +128,7 @@
 		return -EINVAL;
 	}
 
-	return ad7879_probe(&spi->dev, &bops, AD7879_DEVID, BUS_SPI);
+	return ad7879_probe(&spi->dev, &bdata, AD7879_DEVID, BUS_SPI);
 }
 
 static int __devexit ad7879_spi_remove(struct spi_device *spi)

Modified: trunk/drivers/input/touchscreen/ad7879.c (8183 => 8184)


--- trunk/drivers/input/touchscreen/ad7879.c	2010-01-19 07:04:29 UTC (rev 8183)
+++ trunk/drivers/input/touchscreen/ad7879.c	2010-01-19 08:47:45 UTC (rev 8184)
@@ -104,7 +104,7 @@
 #define	TS_PEN_UP_TIMEOUT		msecs_to_jiffies(50)
 
 struct ad7879 {
-	struct ad7879_bus_ops	bops;
+	struct ad7879_bus_data	bdata;
 	struct input_dev	*input;
 	struct work_struct	work;
 	struct timer_list	timer;
@@ -129,15 +129,15 @@
 
 static int ad7879_read(struct ad7879 *ts, u8 reg)
 {
-	return ts->bops.read(ts->bops.bus_data, reg);
+	return ts->bdata.bops->read(ts->bdata.client, reg);
 }
 static int ad7879_multi_read(struct ad7879 *ts, u8 first_reg, u8 count, u16 *buf)
 {
-	return ts->bops.multi_read(ts->bops.bus_data, first_reg, count, buf);
+	return ts->bdata.bops->multi_read(ts->bdata.client, first_reg, count, buf);
 }
 static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val)
 {
-	return ts->bops.write(ts->bops.bus_data, reg, val);
+	return ts->bdata.bops->write(ts->bdata.client, reg, val);
 }
 
 static void ad7879_report(struct ad7879 *ts)
@@ -230,7 +230,7 @@
 	if (!ts->disabled) {
 
 		ts->disabled = 1;
-		disable_irq(ts->bops.irq);
+		disable_irq(ts->bdata.irq);
 
 		cancel_work_sync(&ts->work);
 
@@ -256,7 +256,7 @@
 	if (ts->disabled) {
 		ad7879_setup(ts);
 		ts->disabled = 0;
-		enable_irq(ts->bops.irq);
+		enable_irq(ts->bdata.irq);
 	}
 
 	mutex_unlock(&ts->mutex);
@@ -417,7 +417,7 @@
 #endif
 
 __devinit int
-ad7879_probe(struct device *dev, struct ad7879_bus_ops *bops, u8 devid, u16 bustype)
+ad7879_probe(struct device *dev, struct ad7879_bus_data *bdata, u8 devid, u16 bustype)
 {
 	struct input_dev *input_dev;
 	struct ad7879_platform_data *pdata = dev->platform_data;
@@ -425,7 +425,7 @@
 	u16 revid;
 	struct ad7879 *ts;
 
-	if (!bops->irq) {
+	if (!bdata->irq) {
 		dev_err(dev, "no IRQ?\n");
 		return -ENODEV;
 	}
@@ -445,7 +445,7 @@
 	if (!input_dev)
 		goto err_free_ts_mem;
 
-	ts->bops = *bops;
+	ts->bdata = *bdata;
 	ts->input = input_dev;
 	dev_set_drvdata(dev, ts);
 
@@ -521,10 +521,10 @@
 
 	ad7879_setup(ts);
 
-	err = request_irq(ts->bops.irq, ad7879_irq, IRQF_TRIGGER_FALLING,
+	err = request_irq(ts->bdata.irq, ad7879_irq, IRQF_TRIGGER_FALLING,
 			  dev_name(dev), ts);
 	if (err) {
-		dev_err(dev, "irq %d busy?\n", ts->bops.irq);
+		dev_err(dev, "irq %d busy?\n", ts->bdata.irq);
 		goto err_free_mem;
 	}
 
@@ -541,7 +541,7 @@
 		goto err_remove_gpio;
 
 	dev_info(dev, "Rev.%d touchscreen, irq %d\n",
-		 revid >> 8, ts->bops.irq);
+		 revid >> 8, ts->bdata.irq);
 
 	return 0;
 
@@ -550,7 +550,7 @@
 err_remove_attr:
 	sysfs_remove_group(&dev->kobj, &ad7879_attr_group);
 err_free_irq:
-	free_irq(ts->bops.irq, ts);
+	free_irq(ts->bdata.irq, ts);
 err_free_mem:
 	input_free_device(input_dev);
 err_free_ts_mem:
@@ -568,7 +568,7 @@
 	ad7879_gpio_remove(dev);
 	ad7879_disable(dev);
 	sysfs_remove_group(&dev->kobj, &ad7879_attr_group);
-	free_irq(ts->bops.irq, ts);
+	free_irq(ts->bdata.irq, ts);
 	input_unregister_device(ts->input);
 	dev_set_drvdata(dev, NULL);
 	kfree(ts);

Modified: trunk/drivers/input/touchscreen/ad7879.h (8183 => 8184)


--- trunk/drivers/input/touchscreen/ad7879.h	2010-01-19 07:04:29 UTC (rev 8183)
+++ trunk/drivers/input/touchscreen/ad7879.h	2010-01-19 08:47:45 UTC (rev 8184)
@@ -13,21 +13,20 @@
 
 struct ad7879;
 
-typedef int (ad7879_read_t) (void *bus_data, u8 reg);
-typedef int (ad7879_multi_read_t) (void *bus_data, u8 first_reg, u8 count, u16 *buf);
-typedef int (ad7879_write_t) (void *bus_data, u8 reg, u16 val);
-
 struct ad7879_bus_ops {
-	void *bus_data;
+	int (*read) (void *client, u8 reg);
+	int (*multi_read) (void *client, u8 first_reg, u8 count, u16 *buf);
+	int (*write) (void *client, u8 reg, u16 val);
+};
+struct ad7879_bus_data {
+	void *client;
 	int irq;
-	ad7879_read_t *read;
-	ad7879_multi_read_t *multi_read;
-	ad7879_write_t *write;
+	const struct ad7879_bus_ops *bops;
 };
 
 int ad7879_disable(struct device *dev);
 int ad7879_enable(struct device *dev);
-int ad7879_probe(struct device *dev, struct ad7879_bus_ops *bops, u8 devid, u16 bustype);
+int ad7879_probe(struct device *dev, struct ad7879_bus_data *bdata, u8 devid, u16 bustype);
 int ad7879_remove(struct device *dev);
 
 #endif
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to