Diff
Modified: trunk/drivers/input/misc/adxl34x-i2c.c (7663 => 7664)
--- trunk/drivers/input/misc/adxl34x-i2c.c 2009-10-16 06:25:41 UTC (rev 7663)
+++ trunk/drivers/input/misc/adxl34x-i2c.c 2009-10-16 08:18:21 UTC (rev 7664)
@@ -56,6 +56,7 @@
static int __devinit adxl34x_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct adxl34x_bus_ops bops;
struct adxl34x *ac;
int error;
@@ -66,13 +67,16 @@
return -EIO;
}
- error = adxl34x_probe(&ac, &client->dev, BUS_I2C, client->irq, 0,
- adxl34x_smbus_read,
- i2c_check_functionality(client->adapter,
- I2C_FUNC_SMBUS_READ_I2C_BLOCK) ?
- adxl34x_smbus_read_block :
- adxl34x_i2c_read_block,
- adxl34x_smbus_write);
+ bops.bustype = BUS_I2C;
+ bops.write = adxl34x_smbus_write;
+ bops.read = adxl34x_smbus_read;
+ if (i2c_check_functionality(client->adapter,
+ I2C_FUNC_SMBUS_READ_I2C_BLOCK))
+ bops.read_block = adxl34x_smbus_read_block;
+ else
+ bops.read_block = adxl34x_i2c_read_block;
+
+ error = adxl34x_probe(&ac, &client->dev, client->irq, 0, &bops);
i2c_set_clientdata(client, ac);
return error;
Modified: trunk/drivers/input/misc/adxl34x-spi.c (7663 => 7664)
--- trunk/drivers/input/misc/adxl34x-spi.c 2009-10-16 06:25:41 UTC (rev 7663)
+++ trunk/drivers/input/misc/adxl34x-spi.c 2009-10-16 08:18:21 UTC (rev 7664)
@@ -59,6 +59,7 @@
static int __devinit adxl34x_spi_probe(struct spi_device *spi)
{
+ struct adxl34x_bus_ops bops;
struct adxl34x *ac;
int error;
@@ -68,9 +69,12 @@
return -EINVAL;
}
- error = adxl34x_probe(&ac, &spi->dev, BUS_SPI, spi->irq,
- spi->max_speed_hz > MAX_FREQ_NO_FIFODELAY,
- adxl34x_spi_read, adxl34x_spi_read_block, adxl34x_spi_write);
+ bops.bustype = BUS_SPI;
+ bops.write = adxl34x_spi_write;
+ bops.read = adxl34x_spi_read;
+ bops.read_block = adxl34x_spi_read_block;
+ error = adxl34x_probe(&ac, &spi->dev, spi->irq,
+ spi->max_speed_hz > MAX_FREQ_NO_FIFODELAY, &bops);
spi_set_drvdata(spi, ac);
return error;
Modified: trunk/drivers/input/misc/adxl34x.c (7663 => 7664)
--- trunk/drivers/input/misc/adxl34x.c 2009-10-16 06:25:41 UTC (rev 7663)
+++ trunk/drivers/input/misc/adxl34x.c 2009-10-16 08:18:21 UTC (rev 7664)
@@ -655,9 +655,8 @@
mutex_unlock(&ac->mutex);
}
-int adxl34x_probe(struct adxl34x **pac, struct device *dev, u16 bus_type,
- int irq, int fifo_delay_default, adxl34x_read_t read,
- adxl34x_read_block_t read_block, adxl34x_write_t write)
+int adxl34x_probe(struct adxl34x **pac, struct device *dev, int irq,
+ int fifo_delay_default, const struct adxl34x_bus_ops *bops)
{
struct adxl34x *ac;
struct input_dev *input_dev;
@@ -692,9 +691,9 @@
ac->disabled = 1;
ac->dev = dev;
ac->irq = irq;
- ac->write = write;
- ac->read = read;
- ac->read_block = read_block;
+ ac->write = bops->write;
+ ac->read = bops->read;
+ ac->read_block = bops->read_block;
INIT_WORK(&ac->work, adxl34x_work);
mutex_init(&ac->mutex);
@@ -720,7 +719,7 @@
input_dev->phys = ac->phys;
input_dev->dev.parent = dev;
input_dev->id.product = ac->model;
- input_dev->id.bustype = bus_type;
+ input_dev->id.bustype = bops->bustype;
input_dev->open = adxl34x_input_open;
input_dev->close = adxl34x_input_close;
Modified: trunk/drivers/input/misc/adxl34x.h (7663 => 7664)
--- trunk/drivers/input/misc/adxl34x.h 2009-10-16 06:25:41 UTC (rev 7663)
+++ trunk/drivers/input/misc/adxl34x.h 2009-10-16 08:18:21 UTC (rev 7664)
@@ -16,11 +16,17 @@
typedef int (adxl34x_read_block_t) (struct device *, unsigned char, int, unsigned char *);
typedef int (adxl34x_write_t) (struct device *, unsigned char, unsigned char);
+struct adxl34x_bus_ops {
+ u16 bustype;
+ adxl34x_read_t *read;
+ adxl34x_read_block_t *read_block;
+ adxl34x_write_t *write;
+};
+
void adxl34x_disable(struct adxl34x *ac);
void adxl34x_enable(struct adxl34x *ac);
-int adxl34x_probe(struct adxl34x **pac, struct device *dev, u16 bus_type,
- int irq, int fifo_delay_default, adxl34x_read_t read,
- adxl34x_read_block_t read_block, adxl34x_write_t write);
+int adxl34x_probe(struct adxl34x **pac, struct device *dev, int irq,
+ int fifo_delay_default, const struct adxl34x_bus_ops *bops);
int adxl34x_remove(struct adxl34x *ac);
#endif