Re: [PATCH 13/13] drivers/media/tuners/e4000.c: use macros for i2c_msg initialization
I found 6 cases where there are more than 2 messages in the array. I didn't check how many cases where there are two messages but there is something other than one read and one write. Perhaps a reasonable option would be to use I2C_MSG_READ I2C_MSG_WRITE I2C_MSG_READ_OP I2C_MSG_WRITE_OP The last two are for the few cases where more flags are specified. As compared to the original proposal of I2C_MSG_OP, these keep the READ or WRITE idea in the macro name. The additional argument to the OP macros would be or'd with the read or write (nothing to do in this case) flags as appropriate. Mauro proposed INIT_I2C_READ_SUBADDR for the very common case where a message array has one read and one write. I think that putting one I2C_MSG_READ and one I2C_MSG_WRITE in this case is readable enough, and avoids the need to do something special for the cases that don't match the expectations of INIT_I2C_READ_SUBADDR. I propose not to do anything for the moment either for sizes or for message or buffer arrays that contain only one element. julia -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] i2c: rcar: used devm_request_and_ioremap() instead of devm_ioremap()
From: Kuninori Morimoto Signed-off-by: Kuninori Morimoto --- based on latest linus/master drivers/i2c/busses/i2c-rcar.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index f9399d1..2bce56d 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -642,7 +642,7 @@ static int __devinit rcar_i2c_probe(struct platform_device *pdev) if (ret < 0) return ret; - priv->io = devm_ioremap(dev, res->start, resource_size(res)); + priv->io = devm_request_and_ioremap(dev, res); if (!priv->io) { dev_err(dev, "cannot ioremap\n"); return -ENODEV; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] i2c: at91: add a sanity check on i2c message length
From: Ludovic Desroches If the i2c message length is zero, i2c-at91 will directly return an error instead of trying to send a zero-length message. Signed-off-by: Ludovic Desroches --- fix for 3.7 drivers/i2c/busses/i2c-at91.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index aa59a25..eaddc77 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c @@ -263,6 +263,9 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num) unsigned int_addr_flag = 0; struct i2c_msg *m_start = msg; + if (!msg->len) + return -EINVAL; + dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num); /* -- 1.7.11.3 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [tpmdd-devel] [PATCH] char/tpm: Convert struct i2c_msg initialization to C99 format
> -Original Message- > From: Shubhrajyoti Datta [mailto:omaplinuxker...@gmail.com] > Subject: [PATCHv2] char/tpm: Convert struct i2c_msg initialization to C99 > format > Convert the struct i2c_msg initialization to C99 format. This makes > maintaining and editing the code simpler. Also helps once other fields > like transferred are added in future. > Thanks to Julia Lawall for automating the conversion > Acked-by: Jean Delvare > Signed-off-by: Shubhrajyoti D Acked-by: Peter Huewe -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] i2c: at91: add dma support
From: Ludovic Desroches Add dma support for Atmel TWI which is available on sam9x5 and later. When using dma for reception, you have to read only n-2 bytes. The last two bytes are read manually. Don't doing this should cause to send the STOP command too late and then to get extra data in the receive register. Signed-off-by: Ludovic Desroches --- drivers/i2c/busses/i2c-at91.c | 326 -- 1 file changed, 314 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index aa59a25..33219f8 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c @@ -19,6 +19,8 @@ #include #include +#include +#include #include #include #include @@ -30,6 +32,8 @@ #include #include +#include + #define TWI_CLK_HZ 10 /* max 400 Kbits/s */ #define AT91_I2C_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */ @@ -65,9 +69,21 @@ #defineAT91_TWI_THR0x0034 /* Transmit Holding Register */ struct at91_twi_pdata { - unsignedclk_max_div; - unsignedclk_offset; - boolhas_unre_flag; + unsignedclk_max_div; + unsignedclk_offset; + boolhas_unre_flag; + boolhas_dma_support; + struct at_dma_slave dma_slave; +}; + +struct at91_twi_dma { + struct dma_chan *chan_rx; + struct dma_chan *chan_tx; + struct scatterlist sg; + struct dma_async_tx_descriptor *data_desc; + enum dma_data_direction direction; + boolbuf_mapped; + boolxfer_in_progress; }; struct at91_twi_dev { @@ -79,10 +95,13 @@ struct at91_twi_dev { size_t buf_len; struct i2c_msg *msg; int irq; + unsignedimr; unsignedtransfer_status; struct i2c_adapter adapter; unsignedtwi_cwgr_reg; struct at91_twi_pdata *pdata; + booluse_dma; + struct at91_twi_dma dma; }; static unsigned at91_twi_read(struct at91_twi_dev *dev, unsigned reg) @@ -98,7 +117,18 @@ static void at91_twi_write(struct at91_twi_dev *dev, unsigned reg, unsigned val) static void at91_disable_twi_interrupts(struct at91_twi_dev *dev) { at91_twi_write(dev, AT91_TWI_IDR, - AT91_TWI_TXCOMP | AT91_TWI_RXRDY | AT91_TWI_TXRDY); + AT91_TWI_TXCOMP | AT91_TWI_RXRDY | AT91_TWI_TXRDY); +} + +static void at91_twi_irq_save(struct at91_twi_dev *dev) +{ + dev->imr = at91_twi_read(dev, AT91_TWI_IMR) & 0x7; + at91_disable_twi_interrupts(dev); +} + +static void at91_twi_irq_restore(struct at91_twi_dev *dev) +{ + at91_twi_write(dev, AT91_TWI_IER, dev->imr); } static void at91_init_twi_bus(struct at91_twi_dev *dev) @@ -137,6 +167,30 @@ static void __devinit at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk) dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv); } +static void at91_twi_dma_cleanup(struct at91_twi_dev *dev) +{ + struct at91_twi_dma *dma = &dev->dma; + + at91_twi_irq_save(dev); + + if (dma->xfer_in_progress) { + if (dma->direction == DMA_FROM_DEVICE) + dma->chan_rx->device->device_control(dma->chan_rx, + DMA_TERMINATE_ALL, 0); + else + dma->chan_tx->device->device_control(dma->chan_tx, + DMA_TERMINATE_ALL, 0); + dma->xfer_in_progress = false; + } + if (dma->buf_mapped) { + dma_unmap_single(dev->dev, sg_dma_address(&dma->sg), +dev->buf_len, dma->direction); + dma->buf_mapped = false; + } + + at91_twi_irq_restore(dev); +} + static void at91_twi_write_next_byte(struct at91_twi_dev *dev) { if (dev->buf_len <= 0) @@ -153,6 +207,65 @@ static void at91_twi_write_next_byte(struct at91_twi_dev *dev) ++dev->buf; } +static void at91_twi_write_data_dma_callback(void *data) +{ + struct at91_twi_dev *dev = (struct at91_twi_dev *)data; + + dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg), +dev->buf_len, DMA_TO_DEVICE); + + at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP); +} + +static void at91_twi_write_data_dma(struct at91_twi_dev *dev) +{ + dma_addr_t dma_addr; + dma_cookie_t cookie; + struct dma_async_tx_descriptor *txdesc; + struct at91_twi_dma *dma = &dev->dma; + struct dma_chan *chan_tx = dma->chan_tx; + + if (dev->buf_len <= 0) + return; + + dma->direction = DMA_TO_DEVICE; + + at91_tw
[PATCH v3] ARM: OMAP: i2c: fix interrupt flood during resume
The resume_noirq enables interrupts one-by-one starting from first one. Now if the wake up event for suspend came from i2c device, the i2c bus irq gets enabled before the threaded i2c device irq, causing a flood of i2c bus interrupts as the threaded irq that should clear the event is not enabled yet. Fixed the issue by adding suspend_noirq and resume_early functions that keep i2c bus interrupts disabled until resume_noirq has run completely. Issue was detected doing a wake up from autosleep with twl4030 power key on N9. Patch tested on N9. Signed-off-by: Kalle Jokiniemi --- drivers/i2c/busses/i2c-omap.c | 34 ++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index a0e49f6..991341b 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1132,6 +1132,36 @@ static int __devexit omap_i2c_remove(struct platform_device *pdev) } #ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP +static int omap_i2c_suspend_noirq(struct device *dev) +{ + + struct platform_device *pdev = to_platform_device(dev); + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); + + /* Disabling irq here to balance the enable in resume_early */ + disable_irq(_dev->irq); + return 0; +} + +static int omap_i2c_resume_early(struct device *dev) +{ + + struct platform_device *pdev = to_platform_device(dev); + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); + + /* +* The noirq_resume enables the interrupts one by one, +* this causes a interrupt flood if the SW irq actually reading +* event from i2c device is enabled only after i2c bus irq, as the +* irq that should clear the event is still disabled. We have to +* keep the bus irq disabled until all other irqs have been enabled. +*/ + enable_irq(_dev->irq); + + return 0; +} +#endif #ifdef CONFIG_PM_RUNTIME static int omap_i2c_runtime_suspend(struct device *dev) { @@ -1183,6 +1213,10 @@ static int omap_i2c_runtime_resume(struct device *dev) #endif /* CONFIG_PM_RUNTIME */ static struct dev_pm_ops omap_i2c_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend_noirq = omap_i2c_suspend_noirq, + .resume_early = omap_i2c_resume_early, +#endif SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, omap_i2c_runtime_resume, NULL) }; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] ARM: OMAP: i2c: fix interrupt flood during resume
ke, 2012-10-10 kello 14:54 +0300, Kalle Jokiniemi kirjoitti: > ke, 2012-10-10 kello 14:46 +0300, Kalle Jokiniemi kirjoitti: > > The resume_noirq enables interrupts one-by-one starting from > > first one. Now if the wake up event for suspend came from i2c > > device, the i2c bus irq gets enabled before the threaded > > i2c device irq, causing a flood of i2c bus interrupts as the > > threaded irq that should clear the event is not enabled yet. > > > > Fixed the issue by adding suspend_late and resume_early > > functions that keep i2c bus interrupts disabled until > > resume_noirq has run completely. Ugh, forgot to update commit message. Version 3 coming shortly... - Kalle > > > > Issue was detected doing a wake up from autosleep with > > twl4030 power key on N9. Patch tested on N9. > > I did this now on top of latest linux-omap, should apply also to Jean's > staging tree. Let me know if something more is needed. > > - Kalle > > > > > Signed-off-by: Kalle Jokiniemi > > --- > > drivers/i2c/busses/i2c-omap.c | 34 ++ > > 1 files changed, 34 insertions(+), 0 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c > > index a0e49f6..991341b 100644 > > --- a/drivers/i2c/busses/i2c-omap.c > > +++ b/drivers/i2c/busses/i2c-omap.c > > @@ -1132,6 +1132,36 @@ static int __devexit omap_i2c_remove(struct > > platform_device *pdev) > > } > > > > #ifdef CONFIG_PM > > +#ifdef CONFIG_PM_SLEEP > > +static int omap_i2c_suspend_noirq(struct device *dev) > > +{ > > + > > + struct platform_device *pdev = to_platform_device(dev); > > + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); > > + > > + /* Disabling irq here to balance the enable in resume_early */ > > + disable_irq(_dev->irq); > > + return 0; > > +} > > + > > +static int omap_i2c_resume_early(struct device *dev) > > +{ > > + > > + struct platform_device *pdev = to_platform_device(dev); > > + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); > > + > > + /* > > +* The noirq_resume enables the interrupts one by one, > > +* this causes a interrupt flood if the SW irq actually reading > > +* event from i2c device is enabled only after i2c bus irq, as the > > +* irq that should clear the event is still disabled. We have to > > +* keep the bus irq disabled until all other irqs have been enabled. > > +*/ > > + enable_irq(_dev->irq); > > + > > + return 0; > > +} > > +#endif > > #ifdef CONFIG_PM_RUNTIME > > static int omap_i2c_runtime_suspend(struct device *dev) > > { > > @@ -1183,6 +1213,10 @@ static int omap_i2c_runtime_resume(struct device > > *dev) > > #endif /* CONFIG_PM_RUNTIME */ > > > > static struct dev_pm_ops omap_i2c_pm_ops = { > > +#ifdef CONFIG_PM_SLEEP > > + .suspend_noirq = omap_i2c_suspend_noirq, > > + .resume_early = omap_i2c_resume_early, > > +#endif > > SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, > >omap_i2c_runtime_resume, NULL) > > }; > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-omap" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] ARM: OMAP: i2c: fix interrupt flood during resume
ke, 2012-10-10 kello 14:46 +0300, Kalle Jokiniemi kirjoitti: > The resume_noirq enables interrupts one-by-one starting from > first one. Now if the wake up event for suspend came from i2c > device, the i2c bus irq gets enabled before the threaded > i2c device irq, causing a flood of i2c bus interrupts as the > threaded irq that should clear the event is not enabled yet. > > Fixed the issue by adding suspend_late and resume_early > functions that keep i2c bus interrupts disabled until > resume_noirq has run completely. > > Issue was detected doing a wake up from autosleep with > twl4030 power key on N9. Patch tested on N9. I did this now on top of latest linux-omap, should apply also to Jean's staging tree. Let me know if something more is needed. - Kalle > > Signed-off-by: Kalle Jokiniemi > --- > drivers/i2c/busses/i2c-omap.c | 34 ++ > 1 files changed, 34 insertions(+), 0 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c > index a0e49f6..991341b 100644 > --- a/drivers/i2c/busses/i2c-omap.c > +++ b/drivers/i2c/busses/i2c-omap.c > @@ -1132,6 +1132,36 @@ static int __devexit omap_i2c_remove(struct > platform_device *pdev) > } > > #ifdef CONFIG_PM > +#ifdef CONFIG_PM_SLEEP > +static int omap_i2c_suspend_noirq(struct device *dev) > +{ > + > + struct platform_device *pdev = to_platform_device(dev); > + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); > + > + /* Disabling irq here to balance the enable in resume_early */ > + disable_irq(_dev->irq); > + return 0; > +} > + > +static int omap_i2c_resume_early(struct device *dev) > +{ > + > + struct platform_device *pdev = to_platform_device(dev); > + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); > + > + /* > + * The noirq_resume enables the interrupts one by one, > + * this causes a interrupt flood if the SW irq actually reading > + * event from i2c device is enabled only after i2c bus irq, as the > + * irq that should clear the event is still disabled. We have to > + * keep the bus irq disabled until all other irqs have been enabled. > + */ > + enable_irq(_dev->irq); > + > + return 0; > +} > +#endif > #ifdef CONFIG_PM_RUNTIME > static int omap_i2c_runtime_suspend(struct device *dev) > { > @@ -1183,6 +1213,10 @@ static int omap_i2c_runtime_resume(struct device *dev) > #endif /* CONFIG_PM_RUNTIME */ > > static struct dev_pm_ops omap_i2c_pm_ops = { > +#ifdef CONFIG_PM_SLEEP > + .suspend_noirq = omap_i2c_suspend_noirq, > + .resume_early = omap_i2c_resume_early, > +#endif > SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, > omap_i2c_runtime_resume, NULL) > }; -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] ARM: OMAP: i2c: fix interrupt flood during resume
The resume_noirq enables interrupts one-by-one starting from first one. Now if the wake up event for suspend came from i2c device, the i2c bus irq gets enabled before the threaded i2c device irq, causing a flood of i2c bus interrupts as the threaded irq that should clear the event is not enabled yet. Fixed the issue by adding suspend_late and resume_early functions that keep i2c bus interrupts disabled until resume_noirq has run completely. Issue was detected doing a wake up from autosleep with twl4030 power key on N9. Patch tested on N9. Signed-off-by: Kalle Jokiniemi --- drivers/i2c/busses/i2c-omap.c | 34 ++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index a0e49f6..991341b 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1132,6 +1132,36 @@ static int __devexit omap_i2c_remove(struct platform_device *pdev) } #ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP +static int omap_i2c_suspend_noirq(struct device *dev) +{ + + struct platform_device *pdev = to_platform_device(dev); + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); + + /* Disabling irq here to balance the enable in resume_early */ + disable_irq(_dev->irq); + return 0; +} + +static int omap_i2c_resume_early(struct device *dev) +{ + + struct platform_device *pdev = to_platform_device(dev); + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); + + /* +* The noirq_resume enables the interrupts one by one, +* this causes a interrupt flood if the SW irq actually reading +* event from i2c device is enabled only after i2c bus irq, as the +* irq that should clear the event is still disabled. We have to +* keep the bus irq disabled until all other irqs have been enabled. +*/ + enable_irq(_dev->irq); + + return 0; +} +#endif #ifdef CONFIG_PM_RUNTIME static int omap_i2c_runtime_suspend(struct device *dev) { @@ -1183,6 +1213,10 @@ static int omap_i2c_runtime_resume(struct device *dev) #endif /* CONFIG_PM_RUNTIME */ static struct dev_pm_ops omap_i2c_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend_noirq = omap_i2c_suspend_noirq, + .resume_early = omap_i2c_resume_early, +#endif SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, omap_i2c_runtime_resume, NULL) }; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] input: Convert struct i2c_msg initialization to C99 format
On Wed, Oct 10, 2012 at 2:32 PM, Jean Delvare wrote: > On Tue, 9 Oct 2012 17:01:18 +0530, Shubhrajyoti D wrote: [...] > > Acked-by: Jean Delvare thanks updated patch below >From 6638ecfa7982f95815382922c50573712c9626d7 Mon Sep 17 00:00:00 2001 From: Shubhrajyoti D Date: Mon, 17 Sep 2012 19:37:17 +0530 Subject: [PATCHv2 1/2] input: Convert struct i2c_msg initialization to C99 format Convert the struct i2c_msg initialization to C99 format. This makes maintaining and editing the code simpler. Also helps once other fields like transferred are added in future. Thanks to Julia Lawall for automating the conversion Acked-by: Jean Delvare Signed-off-by: Shubhrajyoti D --- drivers/input/touchscreen/cy8ctmg110_ts.c | 13 +++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c index 464f1bf..ad6a664 100644 --- a/drivers/input/touchscreen/cy8ctmg110_ts.c +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c @@ -99,9 +99,18 @@ static int cy8ctmg110_read_regs(struct cy8ctmg110 *tsc, int ret; struct i2c_msg msg[2] = { /* first write slave position to i2c devices */ - { client->addr, 0, 1, &cmd }, + { + .addr = client->addr, + .len = 1, + .buf = &cmd + }, /* Second read data from position */ - { client->addr, I2C_M_RD, len, data } + { + .addr = client->addr, + .flags = I2C_M_RD, + .len = len, + .buf = data + } }; ret = i2c_transfer(client->adapter, msg, 2); -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] matroxfb: Convert struct i2c_msg initialization to C99 format
On Wed, Oct 10, 2012 at 2:35 PM, Jean Delvare wrote: > On Tue, 9 Oct 2012 17:07:48 +0530, Shubhrajyoti D wrote: Thanks updated patch below. >From 99073779197f5759a76e65c3f4ef2ad4e9c88eaf Mon Sep 17 00:00:00 2001 From: Shubhrajyoti D Date: Mon, 17 Sep 2012 21:19:32 +0530 Subject: [PATCHv2] matroxfb: Convert struct i2c_msg initialization to C99 format Convert the struct i2c_msg initialization to C99 format. This makes maintaining and editing the code simpler. Also helps once other fields like transferred are added in future. Thanks to Julia Lawall for automating the conversion Acked-by: Jean Delvare Signed-off-by: Shubhrajyoti D --- drivers/video/matrox/matroxfb_maven.c | 16 ++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index 217678e..f66c34c 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c @@ -137,8 +137,20 @@ static int* get_ctrl_ptr(struct maven_data* md, int idx) { static int maven_get_reg(struct i2c_client* c, char reg) { char dst; - struct i2c_msg msgs[] = {{ c->addr, I2C_M_REV_DIR_ADDR, sizeof(reg), ® }, -{ c->addr, I2C_M_RD | I2C_M_NOSTART, sizeof(dst), &dst }}; + struct i2c_msg msgs[] = { + { + .addr = c->addr, + .flags = I2C_M_REV_DIR_ADDR, + .len = sizeof(reg), + .buf = ® + }, + { + .addr = c->addr, + .flags = I2C_M_RD | I2C_M_NOSTART, + .len = sizeof(dst), + .buf = &dst + } + }; s32 err; err = i2c_transfer(c->adapter, msgs, 2); -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] char/tpm: Convert struct i2c_msg initialization to C99 format
On Wed, Oct 10, 2012 at 2:36 PM, Jean Delvare wrote: > On Tue, 9 Oct 2012 17:12:31 +0530, Shubhrajyoti D wrote: Thanks for review updated patch below >From f3786807bbaafe1f0dfcf2d94e3bee1c273296a4 Mon Sep 17 00:00:00 2001 From: Shubhrajyoti D Date: Mon, 17 Sep 2012 19:34:37 +0530 Subject: [PATCHv2] char/tpm: Convert struct i2c_msg initialization to C99 format Convert the struct i2c_msg initialization to C99 format. This makes maintaining and editing the code simpler. Also helps once other fields like transferred are added in future. Thanks to Julia Lawall for automating the conversion Acked-by: Jean Delvare Signed-off-by: Shubhrajyoti D --- v2: removed zero initialisation of flags. drivers/char/tpm/tpm_i2c_infineon.c | 19 --- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c index 5a831ae..cbf72e1 100644 --- a/drivers/char/tpm/tpm_i2c_infineon.c +++ b/drivers/char/tpm/tpm_i2c_infineon.c @@ -90,8 +90,17 @@ static struct i2c_driver tpm_tis_i2c_driver; static int iic_tpm_read(u8 addr, u8 *buffer, size_t len) { - struct i2c_msg msg1 = { tpm_dev.client->addr, 0, 1, &addr }; - struct i2c_msg msg2 = { tpm_dev.client->addr, I2C_M_RD, len, buffer }; + struct i2c_msg msg1 = { + .addr = tpm_dev.client->addr, + .len = 1, + .buf = &addr + }; + struct i2c_msg msg2 = { + .addr = tpm_dev.client->addr, + .flags = I2C_M_RD, + .len = len, + .buf = buffer + }; int rc; int count; @@ -138,7 +147,11 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len, int rc = -EIO; int count; - struct i2c_msg msg1 = { tpm_dev.client->addr, 0, len + 1, tpm_dev.buf }; + struct i2c_msg msg1 = { + .addr = tpm_dev.client->addr, + .len = len + 1, + .buf = tpm_dev.buf + }; if (len > TPM_BUFSIZE) return -EINVAL; -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2 v3] i2c: nomadik: adopt pinctrl support
From: Patrice Chotard Amend the I2C nomadik pin controller to optionally take a pin control handle and set the state of the pins to: - "default" on boot, resume and before performing an i2c transfer - "idle" after initial default, after resume default, and after each i2c xfer - "sleep" on suspend() This should make it possible to optimize energy usage for the pins both for the suspend/resume cycle, and for runtime cases inbetween I2C transfers. Signed-off-by: Patrice Chotard Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Rebase on top of the patch from Philippe/Ulf. ChangeLog v1->v2: - We used only two states initially: default and sleep. It turns out you can save some energy when idling (between transfers) and even more when suspending on our platform, so grab all three states and use them as applicable. --- drivers/i2c/busses/i2c-nomadik.c | 101 +++ 1 file changed, 101 insertions(+) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 3eeae52..d50b16a 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -24,6 +24,7 @@ #include #include #include +#include #define DRIVER_NAME "nmk-i2c" @@ -145,6 +146,10 @@ struct i2c_nmk_client { * @stop: stop condition. * @xfer_complete: acknowledge completion for a I2C message. * @result: controller propogated result. + * @pinctrl: pinctrl handle. + * @pins_default: default state for the pins. + * @pins_idle: idle state for the pins. + * @pins_sleep: sleep state for the pins. * @busy: Busy doing transfer. */ struct nmk_i2c_dev { @@ -158,6 +163,11 @@ struct nmk_i2c_dev { int stop; struct completion xfer_complete; int result; + /* Three pin states - default, idle & sleep */ + struct pinctrl *pinctrl; + struct pinctrl_state*pins_default; + struct pinctrl_state*pins_idle; + struct pinctrl_state*pins_sleep; boolbusy; }; @@ -648,6 +658,15 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, goto out_clk; } + /* Optionaly enable pins to be muxed in and configured */ + if (!IS_ERR(dev->pins_default)) { + status = pinctrl_select_state(dev->pinctrl, + dev->pins_default); + if (status) + dev_err(&dev->adev->dev, + "could not set default pins\n"); + } + status = init_hw(dev); if (status) goto out; @@ -675,6 +694,15 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, out: clk_disable_unprepare(dev->clk); out_clk: + /* Optionally let pins go into idle state */ + if (!IS_ERR(dev->pins_idle)) { + status = pinctrl_select_state(dev->pinctrl, + dev->pins_idle); + if (status) + dev_err(&dev->adev->dev, + "could not set pins to idle state\n"); + } + pm_runtime_put_sync(&dev->adev->dev); dev->busy = false; @@ -869,15 +897,44 @@ static int nmk_i2c_suspend(struct device *dev) { struct amba_device *adev = to_amba_device(dev); struct nmk_i2c_dev *nmk_i2c = amba_get_drvdata(adev); + int ret; if (nmk_i2c->busy) return -EBUSY; + if (!IS_ERR(nmk_i2c->pins_sleep)) { + ret = pinctrl_select_state(nmk_i2c->pinctrl, + nmk_i2c->pins_sleep); + if (ret) + dev_err(dev, + "could not set pins to sleep state\n"); + } + return 0; } static int nmk_i2c_resume(struct device *dev) { + struct amba_device *adev = to_amba_device(dev); + struct nmk_i2c_dev *nmk_i2c = amba_get_drvdata(adev); + int ret; + + /* First go to the default state */ + if (!IS_ERR(nmk_i2c->pins_default)) { + ret = pinctrl_select_state(nmk_i2c->pinctrl, + nmk_i2c->pins_default); + if (ret) + dev_err(dev, + "could not set pins to default state\n"); + } + /* Then let's idle the pins until the next transfer happens */ + if (!IS_ERR(nmk_i2c->pins_idle)) { + ret = pinctrl_select_state(nmk_i2c->pinctrl, + nmk_i2c->pins_idle); + if (ret) + dev_err(dev, + "could not set pins to idle state\n"); + } return 0; } #else @@ -941,6 +998,40 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) dev->adev = adev; amba_set_drvdata(adev, dev); + dev->
[PATCH 1/2 RESEND] i2c-nomadik: Fixup clock handling
From: Philippe Begnic Make sure to clk_prepare as well as clk_enable. Signed-off-by: Philippe Begnic Signed-off-by: Ulf Hansson Signed-off-by: Linus Walleij --- drivers/i2c/busses/i2c-nomadik.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 1b898b6..3eeae52 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -642,7 +642,11 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, pm_runtime_get_sync(&dev->adev->dev); - clk_enable(dev->clk); + status = clk_prepare_enable(dev->clk); + if (status) { + dev_err(&dev->adev->dev, "can't prepare_enable clock\n"); + goto out_clk; + } status = init_hw(dev); if (status) @@ -669,7 +673,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, } out: - clk_disable(dev->clk); + clk_disable_unprepare(dev->clk); +out_clk: pm_runtime_put_sync(&dev->adev->dev); dev->busy = false; -- 1.7.11.3 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] i2c: nomadik: adopt pinctrl support
On Wed, Oct 10, 2012 at 11:16:45AM +0200, Linus Walleij wrote: > On Sat, Oct 6, 2012 at 3:30 PM, Wolfram Sang wrote: > > > And it is also unneeded because of Ulf > > Hansson's patch? > > Hm Ulf's patch is not even in linux-next? Where is this thing merged... It is not merged yet since I was waiting for an answer if my assumption was right that Ulf's patch should go in first. I wasn't 100% sure. If you could resend both patches based on the latest code that would be much appreciated! Thanks, Wolfram -- Pengutronix e.K. | Wolfram Sang| Industrial Linux Solutions | http://www.pengutronix.de/ | signature.asc Description: Digital signature
Re: [PATCH v2] i2c: nomadik: adopt pinctrl support
On Sat, Oct 6, 2012 at 3:30 PM, Wolfram Sang wrote: > And it is also unneeded because of Ulf > Hansson's patch? Hm Ulf's patch is not even in linux-next? Where is this thing merged... Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] char/tpm: Convert struct i2c_msg initialization to C99 format
On Tue, 9 Oct 2012 17:12:31 +0530, Shubhrajyoti D wrote: > Convert the struct i2c_msg initialization to C99 format. This makes > maintaining and editing the code simpler. Also helps once other fields > like transferred are added in future. > > Thanks to Julia Lawall for automating the conversion > > Signed-off-by: Shubhrajyoti D > --- > drivers/char/tpm/tpm_i2c_infineon.c | 21 ++--- > 1 files changed, 18 insertions(+), 3 deletions(-) > > diff --git a/drivers/char/tpm/tpm_i2c_infineon.c > b/drivers/char/tpm/tpm_i2c_infineon.c > index 5a831ae..01b07c7 100644 > --- a/drivers/char/tpm/tpm_i2c_infineon.c > +++ b/drivers/char/tpm/tpm_i2c_infineon.c > @@ -90,8 +90,18 @@ static struct i2c_driver tpm_tis_i2c_driver; > static int iic_tpm_read(u8 addr, u8 *buffer, size_t len) > { > > - struct i2c_msg msg1 = { tpm_dev.client->addr, 0, 1, &addr }; > - struct i2c_msg msg2 = { tpm_dev.client->addr, I2C_M_RD, len, buffer }; > + struct i2c_msg msg1 = { > + .addr = tpm_dev.client->addr, > + .flags = 0, As said before, you can omit zero fields. > + .len = 1, > + .buf = &addr > + }; > + struct i2c_msg msg2 = { > + .addr = tpm_dev.client->addr, > + .flags = I2C_M_RD, > + .len = len, > + .buf = buffer > + }; > > int rc; > int count; > @@ -138,7 +148,12 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, > size_t len, > int rc = -EIO; > int count; > > - struct i2c_msg msg1 = { tpm_dev.client->addr, 0, len + 1, tpm_dev.buf }; > + struct i2c_msg msg1 = { > + .addr = tpm_dev.client->addr, > + .flags = 0, > + .len = len + 1, > + .buf = tpm_dev.buf > + }; > > if (len > TPM_BUFSIZE) > return -EINVAL; Acked-by: Jean Delvare -- Jean Delvare -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] matroxfb: Convert struct i2c_msg initialization to C99 format
On Tue, 9 Oct 2012 17:07:48 +0530, Shubhrajyoti D wrote: > Convert the struct i2c_msg initialization to C99 format. This makes > maintaining and editing the code simpler. Also helps once other fields > like transferred are added in future. > > Thanks to Julia Lawall for automating the conversion > > Signed-off-by: Shubhrajyoti D > --- > drivers/video/matrox/matroxfb_maven.c | 15 +-- > 1 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/video/matrox/matroxfb_maven.c > b/drivers/video/matrox/matroxfb_maven.c > index 217678e..fb5c123 100644 > --- a/drivers/video/matrox/matroxfb_maven.c > +++ b/drivers/video/matrox/matroxfb_maven.c > @@ -137,8 +137,19 @@ static int* get_ctrl_ptr(struct maven_data* md, int idx) > { > > static int maven_get_reg(struct i2c_client* c, char reg) { > char dst; > - struct i2c_msg msgs[] = {{ c->addr, I2C_M_REV_DIR_ADDR, sizeof(reg), > ® }, > - { c->addr, I2C_M_RD | I2C_M_NOSTART, > sizeof(dst), &dst }}; > + struct i2c_msg msgs[] = {{ > + .addr = c->addr, > + .flags = I2C_M_REV_DIR_ADDR, > + .len = sizeof(reg), > + .buf = ® > + }, > + { > + .addr = c->addr, > + .flags = I2C_M_RD | I2C_M_NOSTART, > + .len = sizeof(dst), > + .buf = &dst > + } I'd prefer clean indentation as you have in the previous patches. > + }; > s32 err; > > err = i2c_transfer(c->adapter, msgs, 2); Acked-by: Jean Delvare -- Jean Delvare -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] input: Convert struct i2c_msg initialization to C99 format
On Tue, 9 Oct 2012 17:01:18 +0530, Shubhrajyoti D wrote: > Convert the struct i2c_msg initialization to C99 format. This makes > maintaining and editing the code simpler. Also helps once other fields > like transferred are added in future. > > Thanks to Julia Lawall for automating the conversion > > Signed-off-by: Shubhrajyoti D > --- > drivers/input/touchscreen/cy8ctmg110_ts.c | 14 -- > 1 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c > b/drivers/input/touchscreen/cy8ctmg110_ts.c > index 464f1bf..f4cfedf 100644 > --- a/drivers/input/touchscreen/cy8ctmg110_ts.c > +++ b/drivers/input/touchscreen/cy8ctmg110_ts.c > @@ -99,9 +99,19 @@ static int cy8ctmg110_read_regs(struct cy8ctmg110 *tsc, > int ret; > struct i2c_msg msg[2] = { > /* first write slave position to i2c devices */ > - { client->addr, 0, 1, &cmd }, > + { > + .addr = client->addr, > + .flags = 0, You can actually omit fields with value 0, that's one of the benefits of C99-style struct initialization. > + .len = 1, > + .buf = &cmd > + }, > /* Second read data from position */ > - { client->addr, I2C_M_RD, len, data } > + { > + .addr = client->addr, > + .flags = I2C_M_RD, > + .len = len, > + .buf = data > + } > }; > > ret = i2c_transfer(client->adapter, msg, 2); Acked-by: Jean Delvare -- Jean Delvare -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] input: Convert struct i2c_msg initialization to C99 format
On Tue, 9 Oct 2012 17:01:17 +0530, Shubhrajyoti D wrote: > Convert the struct i2c_msg initialization to C99 format. This makes > maintaining and editing the code simpler. Also helps once other fields > like transferred are added in future. > > Thanks to Julia Lawall for automating the conversion > > Signed-off-by: Shubhrajyoti D > --- > drivers/input/joystick/as5011.c | 19 --- > 1 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/drivers/input/joystick/as5011.c b/drivers/input/joystick/as5011.c > index c96653b..9d869e2 100644 > --- a/drivers/input/joystick/as5011.c > +++ b/drivers/input/joystick/as5011.c > @@ -85,7 +85,10 @@ static int as5011_i2c_write(struct i2c_client *client, > { > uint8_t data[2] = { aregaddr, avalue }; > struct i2c_msg msg = { > - client->addr, I2C_M_IGNORE_NAK, 2, (uint8_t *)data > + .addr = client->addr, > + .flags = I2C_M_IGNORE_NAK, > + .len = 2, > + .buf = (uint8_t *)data > }; > int error; > > @@ -98,8 +101,18 @@ static int as5011_i2c_read(struct i2c_client *client, > { > uint8_t data[2] = { aregaddr }; > struct i2c_msg msg_set[2] = { > - { client->addr, I2C_M_REV_DIR_ADDR, 1, (uint8_t *)data }, > - { client->addr, I2C_M_RD | I2C_M_NOSTART, 1, (uint8_t *)data } > + { > + .addr = client->addr, > + .flags = I2C_M_REV_DIR_ADDR, > + .len = 1, > + .buf = (uint8_t *)data > + }, > + { > + .addr = client->addr, > + .flags = I2C_M_RD | I2C_M_NOSTART, > + .len = 1, > + .buf = (uint8_t *)data > + } > }; > int error; > Acked-by: Jean Delvare -- Jean Delvare -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] i2c: nomadik: adopt pinctrl support
On Sat, Oct 6, 2012 at 3:30 PM, Wolfram Sang wrote: >> err_add_adap: >> + clk_unprepare(dev->clk); >> + err_prep_clk: > > This is unrelated, right? And it is also unneeded because of Ulf > Hansson's patch? True. I'll roll out a v3 based on the latest i2c code. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html