Re: [PATCH V2 0/6] spi/spi-pl022 fixes

2011-09-01 Thread Viresh Kumar
On 8/10/2011 2:20 PM, Viresh KUMAR wrote:
 Hi Grant,
 
 I have added Tested-by: Linus Walleij linus.wall...@linaro.org on all 
 patches.
 
 This patchset mainly covers following fixes:
 - formatting related issues
 - Passing GFP_ATOMIC for sg allocation from tasklet
 - Fixing calculate_effective_freq() routine
 - Allocate/free DMA channels as and when required.
 

Grant,

Did you already pushed this patchset?
There are few concerns on PATCH 6/6 and i am not sure if there are any decisions
on it.
@Linus: What do you say?

So, probably you can push first 5 patches for now.

--
viresh

--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH V2 0/6] spi/spi-pl022 fixes

2011-09-01 Thread Linus Walleij
On Thu, Sep 1, 2011 at 12:04 PM, Viresh Kumar viresh.ku...@st.com wrote:
 On 8/10/2011 2:20 PM, Viresh KUMAR wrote:

 This patchset mainly covers following fixes:
 - formatting related issues
 - Passing GFP_ATOMIC for sg allocation from tasklet
 - Fixing calculate_effective_freq() routine
 - Allocate/free DMA channels as and when required.


 Grant,

 Did you already pushed this patchset?
 There are few concerns on PATCH 6/6 and i am not sure if there are any 
 decisions
 on it.
 @Linus: What do you say?

I agree. Acked-by: Linus Walleij linus.wall...@linaro.org for
all except 6/6, it's probably just as possible to keep the channel handle
taken in the driver if we modify the affected DMA driver instead.
This would be better for performance I think.

Thanks,
Linus Walleij

--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [uclinux-dist-devel] [PATCH v2] spi:spi_bfin5xx: SPI SSEL deasserted too early in soft irq mode.

2011-09-01 Thread Barry Song
2011/8/12 Sonic Zhang sonic@gmail.com:
 From: Sonic Zhang sonic.zh...@analog.com

 Poll the FIFO till it is empty before deassert SSEL in pump_transfers in
 soft irq mode. No polling is necessary in interrupt mode and error handling.

 Signed-off-by: Sonic Zhang sonic.zh...@analog.com

Acked-by: Barry Song 21cn...@gmail.com

it is actually making sure the last message is finished.

 ---
  drivers/spi/spi-bfin5xx.c |    5 -
  1 files changed, 4 insertions(+), 1 deletions(-)

 diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c
 index b8d25f2..7e03e7d 100644
 --- a/drivers/spi/spi-bfin5xx.c
 +++ b/drivers/spi/spi-bfin5xx.c
 @@ -587,6 +587,7 @@ static void bfin_spi_pump_transfers(unsigned long data)
        if (message-state == DONE_STATE) {
                dev_dbg(drv_data-pdev-dev, transfer: all done!\n);
                message-status = 0;
 +               bfin_spi_flush(drv_data);
                bfin_spi_giveback(drv_data);
                return;
        }
 @@ -870,8 +871,10 @@ static void bfin_spi_pump_transfers(unsigned long data)
                message-actual_length += drv_data-len_in_bytes;
                /* Move to next transfer of this msg */
                message-state = bfin_spi_next_transfer(drv_data);
 -               if (drv_data-cs_change)
 +               if (drv_data-cs_change) {
 +                       bfin_spi_flush(drv_data);
                        bfin_spi_cs_deactive(drv_data, chip);
 +               }
        }

        /* Schedule next transfer tasklet */
 --
 1.7.0.4


 ___
 Uclinux-dist-devel mailing list
 uclinux-dist-de...@blackfin.uclinux.org
 https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel

--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 3/5] staging:iio:magnetometer:ak8975 Don't use irq_to_gpio()

2011-09-01 Thread Stephen Warren
Tegra doesn't have irq_to_gpio() any more, and ak8975 is included in
tegra_defconfig. This causes a build failure.

Instead, obtain the GPIO ID corresponding to the chip's IRQ from the new
i2c_client field irq_gpio.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
 drivers/staging/iio/magnetometer/ak8975.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/ak8975.c 
b/drivers/staging/iio/magnetometer/ak8975.c
index a17fa9f..14076da 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -477,7 +477,7 @@ static int ak8975_probe(struct i2c_client *client,
int err;
 
/* Grab and set up the supplied GPIO. */
-   eoc_gpio = irq_to_gpio(client-irq);
+   eoc_gpio = client-irq_gpio;
 
/* We may not have a GPIO based IRQ to scan, that is fine, we will
   poll if so */
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 4/5] staging:iio:magnetometer:ak8975: Don't assume 0 is an invalid GPIO

2011-09-01 Thread Stephen Warren
gpio_is_valid() is the defined mechanism to determine whether a GPIO is
valid. Use this instead of assuming that 0 is an invalid GPIO.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
 drivers/staging/iio/magnetometer/ak8975.c |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/ak8975.c 
b/drivers/staging/iio/magnetometer/ak8975.c
index 14076da..0dfdf50 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -373,7 +373,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int 
index, int *val)
}
 
/* Wait for the conversion to complete. */
-   if (data-eoc_gpio)
+   if (gpio_is_valid(data-eoc_gpio))
ret = wait_conversion_complete_gpio(data);
else
ret = wait_conversion_complete_polled(data);
@@ -481,7 +481,7 @@ static int ak8975_probe(struct i2c_client *client,
 
/* We may not have a GPIO based IRQ to scan, that is fine, we will
   poll if so */
-   if (eoc_gpio  0) {
+   if (gpio_is_valid(eoc_gpio)) {
err = gpio_request(eoc_gpio, ak_8975);
if (err  0) {
dev_err(client-dev,
@@ -497,8 +497,7 @@ static int ak8975_probe(struct i2c_client *client,
eoc_gpio, err);
goto exit_gpio;
}
-   } else
-   eoc_gpio = 0;   /* No GPIO available */
+   }
 
/* Register with IIO */
indio_dev = iio_allocate_device(sizeof(*data));
@@ -534,7 +533,7 @@ static int ak8975_probe(struct i2c_client *client,
 exit_free_iio:
iio_free_device(indio_dev);
 exit_gpio:
-   if (eoc_gpio)
+   if (gpio_is_valid(eoc_gpio))
gpio_free(eoc_gpio);
 exit:
return err;
@@ -549,7 +548,7 @@ static int ak8975_remove(struct i2c_client *client)
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
 
-   if (eoc_gpio)
+   if (gpio_is_valid(eoc_gpio))
gpio_free(eoc_gpio);
 
return 0;
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 1/5] i2c: Add irq_gpio field to struct i2c_client, i2c_board_info.

2011-09-01 Thread Stephen Warren
Some devices use a single pin as both an IRQ and a GPIO. In that case,
irq_gpio is the GPIO ID for that pin. Not all drivers use this feature.
Where they do, and the use of this feature is optional, and the system
wishes to disable this feature, this field must be explicitly set to a
defined invalid GPIO ID, such as -1.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
v3: Also add the field to i2c_board_info, and copy the field from
i2c_board_info to i2c_client upon instantiation

 drivers/i2c/i2c-core.c |1 +
 include/linux/i2c.h|9 +
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 131079a..da12540 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -518,6 +518,7 @@ i2c_new_device(struct i2c_adapter *adap, struct 
i2c_board_info const *info)
client-flags = info-flags;
client-addr = info-addr;
client-irq = info-irq;
+   client-irq_gpio = info-irq_gpio;
 
strlcpy(client-name, info-type, sizeof(client-name));
 
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 3fad485..49e2e36 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -192,6 +192,12 @@ struct i2c_driver {
  * @driver: device's driver, hence pointer to access routines
  * @dev: Driver model device node for the slave.
  * @irq: indicates the IRQ generated by this device (if any)
+ * @irq_gpio: some devices use a single pin as both an IRQ and a GPIO. In
+ * that case, irq_gpio is the GPIO ID for that pin. Not all drivers
+ * use this feature. Where they do, and the use of this feature is
+ * optional, and the system wishes to disable this feature, this
+ * field must be explicitly set to a defined invalid GPIO ID, such
+ * as -1.
  * @detected: member of an i2c_driver.clients list or i2c-core's
  * userspace_devices list
  *
@@ -209,6 +215,7 @@ struct i2c_client {
struct i2c_driver *driver;  /* and our access routines  */
struct device dev;  /* the device structure */
int irq;/* irq issued by device */
+   int irq_gpio;   /* gpio corresponding to irq*/
struct list_head detected;
 };
 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
@@ -240,6 +247,7 @@ static inline void i2c_set_clientdata(struct i2c_client 
*dev, void *data)
  * @archdata: copied into i2c_client.dev.archdata
  * @of_node: pointer to OpenFirmware device node
  * @irq: stored in i2c_client.irq
+ * @irq_gpio: stored in i2c_client.irq_gpio
  *
  * I2C doesn't actually support hardware probing, although controllers and
  * devices may be able to use I2C_SMBUS_QUICK to tell whether or not there's
@@ -260,6 +268,7 @@ struct i2c_board_info {
struct dev_archdata *archdata;
struct device_node *of_node;
int irq;
+   int irq_gpio;
 };
 
 /**
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 5/5] staging:iio:magnetometer:ak8975: Fix probe() error-handling

2011-09-01 Thread Stephen Warren
Fix ak8975_probe() to jump to the appropriate exit labels when an error
occurs. With the previous code, some cleanup actions were being skipped
for some error conditions.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
 drivers/staging/iio/magnetometer/ak8975.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/ak8975.c 
b/drivers/staging/iio/magnetometer/ak8975.c
index 0dfdf50..cc20e8d 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -510,7 +510,7 @@ static int ak8975_probe(struct i2c_client *client,
err = ak8975_setup(client);
if (err  0) {
dev_err(client-dev, AK8975 initialization fails\n);
-   goto exit_gpio;
+   goto exit_free_iio;
}
 
i2c_set_clientdata(client, indio_dev);
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 2/5] spi: Add irq_gpio field to struct spi_device, spi_board_info.

2011-09-01 Thread Stephen Warren
Some devices use a single pin as both an IRQ and a GPIO. In that case,
irq_gpio is the GPIO ID for that pin. Not all drivers use this feature.
Where they do, and the use of this feature is optional, and the system
wishes to disable this feature, this field must be explicitly set to a
defined invalid GPIO ID, such as -1.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
v3: New patch for v3; apply the same change to spi as for i2c per Mark
Brown.

 drivers/spi/spi.c   |1 +
 include/linux/spi/spi.h |   10 ++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 77eae99..9932572 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -433,6 +433,7 @@ struct spi_device *spi_new_device(struct spi_master *master,
proxy-max_speed_hz = chip-max_speed_hz;
proxy-mode = chip-mode;
proxy-irq = chip-irq;
+   proxy-irq_gpio = chip-irq_gpio;
strlcpy(proxy-modalias, chip-modalias, sizeof(proxy-modalias));
proxy-dev.platform_data = (void *) chip-platform_data;
proxy-controller_data = chip-controller_data;
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index bb4f5fb..086b591 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -50,6 +50,12 @@ extern struct bus_type spi_bus_type;
  * The spi_transfer.bits_per_word can override this for each transfer.
  * @irq: Negative, or the number passed to request_irq() to receive
  * interrupts from this device.
+ * @irq_gpio: some devices use a single pin as both an IRQ and a GPIO. In
+ * that case, irq_gpio is the GPIO ID for that pin. Not all drivers
+ * use this feature. Where they do, and the use of this feature is
+ * optional, and the system wishes to disable this feature, this
+ * field must be explicitly set to a defined invalid GPIO ID, such
+ * as -1.
  * @controller_state: Controller's runtime state
  * @controller_data: Board-specific definitions for controller, such as
  * FIFO initialization parameters; from board_info.controller_data
@@ -86,6 +92,7 @@ struct spi_device {
 #defineSPI_READY   0x80/* slave pulls low to 
pause */
u8  bits_per_word;
int irq;
+   int irq_gpio;
void*controller_state;
void*controller_data;
charmodalias[SPI_NAME_SIZE];
@@ -692,6 +699,8 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 
cmd)
  * @controller_data: Initializes spi_device.controller_data; some
  * controllers need hints about hardware setup, e.g. for DMA.
  * @irq: Initializes spi_device.irq; depends on how the board is wired.
+ * @irq_gpio: Initializes spi_device.irq_gpio; depends on how the board
+ * is wired.
  * @max_speed_hz: Initializes spi_device.max_speed_hz; based on limits
  * from the chip datasheet and board-specific signal quality issues.
  * @bus_num: Identifies which spi_master parents the spi_device; unused
@@ -727,6 +736,7 @@ struct spi_board_info {
const void  *platform_data;
void*controller_data;
int irq;
+   int irq_gpio;
 
/* slower signaling on noisy or low voltage boards */
u32 max_speed_hz;
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 2/5] spi: Add irq_gpio field to struct spi_device, spi_board_info.

2011-09-01 Thread Stephen Warren
Some devices use a single pin as both an IRQ and a GPIO. In that case,
irq_gpio is the GPIO ID for that pin. Not all drivers use this feature.
Where they do, and the use of this feature is optional, and the system
wishes to disable this feature, this field must be explicitly set to a
defined invalid GPIO ID, such as -1.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
v3: New patch for v3; apply the same change to spi as for i2c per Mark
Brown.

 drivers/spi/spi.c   |1 +
 include/linux/spi/spi.h |   10 ++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 77eae99..9932572 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -433,6 +433,7 @@ struct spi_device *spi_new_device(struct spi_master *master,
proxy-max_speed_hz = chip-max_speed_hz;
proxy-mode = chip-mode;
proxy-irq = chip-irq;
+   proxy-irq_gpio = chip-irq_gpio;
strlcpy(proxy-modalias, chip-modalias, sizeof(proxy-modalias));
proxy-dev.platform_data = (void *) chip-platform_data;
proxy-controller_data = chip-controller_data;
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index bb4f5fb..086b591 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -50,6 +50,12 @@ extern struct bus_type spi_bus_type;
  * The spi_transfer.bits_per_word can override this for each transfer.
  * @irq: Negative, or the number passed to request_irq() to receive
  * interrupts from this device.
+ * @irq_gpio: some devices use a single pin as both an IRQ and a GPIO. In
+ * that case, irq_gpio is the GPIO ID for that pin. Not all drivers
+ * use this feature. Where they do, and the use of this feature is
+ * optional, and the system wishes to disable this feature, this
+ * field must be explicitly set to a defined invalid GPIO ID, such
+ * as -1.
  * @controller_state: Controller's runtime state
  * @controller_data: Board-specific definitions for controller, such as
  * FIFO initialization parameters; from board_info.controller_data
@@ -86,6 +92,7 @@ struct spi_device {
 #defineSPI_READY   0x80/* slave pulls low to 
pause */
u8  bits_per_word;
int irq;
+   int irq_gpio;
void*controller_state;
void*controller_data;
charmodalias[SPI_NAME_SIZE];
@@ -692,6 +699,8 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 
cmd)
  * @controller_data: Initializes spi_device.controller_data; some
  * controllers need hints about hardware setup, e.g. for DMA.
  * @irq: Initializes spi_device.irq; depends on how the board is wired.
+ * @irq_gpio: Initializes spi_device.irq_gpio; depends on how the board
+ * is wired.
  * @max_speed_hz: Initializes spi_device.max_speed_hz; based on limits
  * from the chip datasheet and board-specific signal quality issues.
  * @bus_num: Identifies which spi_master parents the spi_device; unused
@@ -727,6 +736,7 @@ struct spi_board_info {
const void  *platform_data;
void*controller_data;
int irq;
+   int irq_gpio;
 
/* slower signaling on noisy or low voltage boards */
u32 max_speed_hz;
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 3/5] staging:iio:magnetometer:ak8975 Don't use irq_to_gpio()

2011-09-01 Thread Stephen Warren
Tegra doesn't have irq_to_gpio() any more, and ak8975 is included in
tegra_defconfig. This causes a build failure.

Instead, obtain the GPIO ID corresponding to the chip's IRQ from the new
i2c_client field irq_gpio.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
 drivers/staging/iio/magnetometer/ak8975.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/ak8975.c 
b/drivers/staging/iio/magnetometer/ak8975.c
index a17fa9f..14076da 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -477,7 +477,7 @@ static int ak8975_probe(struct i2c_client *client,
int err;
 
/* Grab and set up the supplied GPIO. */
-   eoc_gpio = irq_to_gpio(client-irq);
+   eoc_gpio = client-irq_gpio;
 
/* We may not have a GPIO based IRQ to scan, that is fine, we will
   poll if so */
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 1/5] i2c: Add irq_gpio field to struct i2c_client, i2c_board_info.

2011-09-01 Thread Stephen Warren
Some devices use a single pin as both an IRQ and a GPIO. In that case,
irq_gpio is the GPIO ID for that pin. Not all drivers use this feature.
Where they do, and the use of this feature is optional, and the system
wishes to disable this feature, this field must be explicitly set to a
defined invalid GPIO ID, such as -1.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
v3: Also add the field to i2c_board_info, and copy the field from
i2c_board_info to i2c_client upon instantiation

 drivers/i2c/i2c-core.c |1 +
 include/linux/i2c.h|9 +
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 131079a..da12540 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -518,6 +518,7 @@ i2c_new_device(struct i2c_adapter *adap, struct 
i2c_board_info const *info)
client-flags = info-flags;
client-addr = info-addr;
client-irq = info-irq;
+   client-irq_gpio = info-irq_gpio;
 
strlcpy(client-name, info-type, sizeof(client-name));
 
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 3fad485..49e2e36 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -192,6 +192,12 @@ struct i2c_driver {
  * @driver: device's driver, hence pointer to access routines
  * @dev: Driver model device node for the slave.
  * @irq: indicates the IRQ generated by this device (if any)
+ * @irq_gpio: some devices use a single pin as both an IRQ and a GPIO. In
+ * that case, irq_gpio is the GPIO ID for that pin. Not all drivers
+ * use this feature. Where they do, and the use of this feature is
+ * optional, and the system wishes to disable this feature, this
+ * field must be explicitly set to a defined invalid GPIO ID, such
+ * as -1.
  * @detected: member of an i2c_driver.clients list or i2c-core's
  * userspace_devices list
  *
@@ -209,6 +215,7 @@ struct i2c_client {
struct i2c_driver *driver;  /* and our access routines  */
struct device dev;  /* the device structure */
int irq;/* irq issued by device */
+   int irq_gpio;   /* gpio corresponding to irq*/
struct list_head detected;
 };
 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
@@ -240,6 +247,7 @@ static inline void i2c_set_clientdata(struct i2c_client 
*dev, void *data)
  * @archdata: copied into i2c_client.dev.archdata
  * @of_node: pointer to OpenFirmware device node
  * @irq: stored in i2c_client.irq
+ * @irq_gpio: stored in i2c_client.irq_gpio
  *
  * I2C doesn't actually support hardware probing, although controllers and
  * devices may be able to use I2C_SMBUS_QUICK to tell whether or not there's
@@ -260,6 +268,7 @@ struct i2c_board_info {
struct dev_archdata *archdata;
struct device_node *of_node;
int irq;
+   int irq_gpio;
 };
 
 /**
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 5/5] staging:iio:magnetometer:ak8975: Fix probe() error-handling

2011-09-01 Thread Stephen Warren
Fix ak8975_probe() to jump to the appropriate exit labels when an error
occurs. With the previous code, some cleanup actions were being skipped
for some error conditions.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
 drivers/staging/iio/magnetometer/ak8975.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/ak8975.c 
b/drivers/staging/iio/magnetometer/ak8975.c
index 0dfdf50..cc20e8d 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -510,7 +510,7 @@ static int ak8975_probe(struct i2c_client *client,
err = ak8975_setup(client);
if (err  0) {
dev_err(client-dev, AK8975 initialization fails\n);
-   goto exit_gpio;
+   goto exit_free_iio;
}
 
i2c_set_clientdata(client, indio_dev);
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH V3 4/5] staging:iio:magnetometer:ak8975: Don't assume 0 is an invalid GPIO

2011-09-01 Thread Stephen Warren
gpio_is_valid() is the defined mechanism to determine whether a GPIO is
valid. Use this instead of assuming that 0 is an invalid GPIO.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
 drivers/staging/iio/magnetometer/ak8975.c |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/ak8975.c 
b/drivers/staging/iio/magnetometer/ak8975.c
index 14076da..0dfdf50 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -373,7 +373,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int 
index, int *val)
}
 
/* Wait for the conversion to complete. */
-   if (data-eoc_gpio)
+   if (gpio_is_valid(data-eoc_gpio))
ret = wait_conversion_complete_gpio(data);
else
ret = wait_conversion_complete_polled(data);
@@ -481,7 +481,7 @@ static int ak8975_probe(struct i2c_client *client,
 
/* We may not have a GPIO based IRQ to scan, that is fine, we will
   poll if so */
-   if (eoc_gpio  0) {
+   if (gpio_is_valid(eoc_gpio)) {
err = gpio_request(eoc_gpio, ak_8975);
if (err  0) {
dev_err(client-dev,
@@ -497,8 +497,7 @@ static int ak8975_probe(struct i2c_client *client,
eoc_gpio, err);
goto exit_gpio;
}
-   } else
-   eoc_gpio = 0;   /* No GPIO available */
+   }
 
/* Register with IIO */
indio_dev = iio_allocate_device(sizeof(*data));
@@ -534,7 +533,7 @@ static int ak8975_probe(struct i2c_client *client,
 exit_free_iio:
iio_free_device(indio_dev);
 exit_gpio:
-   if (eoc_gpio)
+   if (gpio_is_valid(eoc_gpio))
gpio_free(eoc_gpio);
 exit:
return err;
@@ -549,7 +548,7 @@ static int ak8975_remove(struct i2c_client *client)
iio_device_unregister(indio_dev);
iio_free_device(indio_dev);
 
-   if (eoc_gpio)
+   if (gpio_is_valid(eoc_gpio))
gpio_free(eoc_gpio);
 
return 0;
-- 
1.7.0.4


--
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free Love Thy Logs t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general