Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 259628
b: refs/heads/master
c: 9f8632d
h: refs/heads/master
v: v3
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed Jun 28, 2011
1 parent 3ca9f65 commit 2b2fee7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1dd9290a7ef8877d12a9df28c2df677fde145dfe
refs/heads/master: 9f8632d73edc0f132212cf7eb826c450283014d9
50 changes: 20 additions & 30 deletions trunk/drivers/staging/iio/gyro/adis16130_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@
/**
* struct adis16130_state - device instance specific data
* @us: actual spi_device to write data
* @indio_dev: industrial I/O device structure
* @mode: 24 bits (1) or 16 bits (0)
* @buf_lock: mutex to protect tx and rx
* @buf: unified tx/rx buffer
**/
struct adis16130_state {
struct spi_device *us;
struct iio_dev *indio_dev;
u32 mode;
struct mutex buf_lock;
u8 buf[4] ____cacheline_aligned;
Expand All @@ -59,7 +57,7 @@ static int adis16130_spi_write(struct device *dev, u8 reg_addr,
{
int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16130_state *st = iio_dev_get_devdata(indio_dev);
struct adis16130_state *st = iio_priv(indio_dev);

mutex_lock(&st->buf_lock);
st->buf[0] = reg_addr;
Expand All @@ -76,7 +74,7 @@ static int adis16130_spi_read(struct device *dev, u8 reg_addr,
{
int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16130_state *st = iio_dev_get_devdata(indio_dev);
struct adis16130_state *st = iio_priv(indio_dev);

mutex_lock(&st->buf_lock);

Expand Down Expand Up @@ -125,7 +123,7 @@ static ssize_t adis16130_bitsmode_read(struct device *dev,
char *buf)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16130_state *st = iio_dev_get_devdata(indio_dev);
struct adis16130_state *st = iio_priv(indio_dev);

if (st->mode == 1)
return sprintf(buf, "s24\n");
Expand Down Expand Up @@ -183,51 +181,43 @@ static const struct iio_info adis16130_info = {
static int __devinit adis16130_probe(struct spi_device *spi)
{
int ret;
struct adis16130_state *st = kzalloc(sizeof *st, GFP_KERNEL);
if (!st) {
ret = -ENOMEM;
struct adis16130_state *st;
struct iio_dev *indio_dev;

/* setup the industrialio driver allocated elements */
indio_dev = iio_allocate_device(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
}
st = iio_priv(indio_dev);
/* this is only used for removal purposes */
spi_set_drvdata(spi, st);
spi_set_drvdata(spi, indio_dev);
st->us = spi;
mutex_init(&st->buf_lock);
/* setup the industrialio driver allocated elements */
st->indio_dev = iio_allocate_device(0);
if (st->indio_dev == NULL) {
ret = -ENOMEM;
goto error_free_st;
}

st->indio_dev->name = spi->dev.driver->name;
st->indio_dev->dev.parent = &spi->dev;
st->indio_dev->info = &adis16130_info;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->name = spi->dev.driver->name;
indio_dev->dev.parent = &spi->dev;
indio_dev->info = &adis16130_info;
indio_dev->modes = INDIO_DIRECT_MODE;
st->mode = 1;

ret = iio_device_register(st->indio_dev);
ret = iio_device_register(indio_dev);
if (ret)
goto error_free_dev;

return 0;

error_free_dev:
iio_free_device(st->indio_dev);
error_free_st:
kfree(st);
iio_free_device(indio_dev);

error_ret:
return ret;
}

/* fixme, confirm ordering in this function */
static int adis16130_remove(struct spi_device *spi)
{
struct adis16130_state *st = spi_get_drvdata(spi);
struct iio_dev *indio_dev = st->indio_dev;

iio_device_unregister(indio_dev);
kfree(st);
iio_device_unregister(spi_get_drvdata(spi));

return 0;
}
Expand Down

0 comments on commit 2b2fee7

Please sign in to comment.