* [PATCH 0/5] spi: omap2-mcspi: driver updates @ 2012-03-26 13:44 Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index Shubhrajyoti D ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Shubhrajyoti D @ 2012-03-26 13:44 UTC (permalink / raw) To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f Cc: Shubhrajyoti, linux-omap-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, D The patch series does the following cleanups - Converts the spi to module_platform_driver - Use the devm functions so that the freeing need not be done in the driver. - Makes the driver use autosuspend - Folds Benoit's bus_num removal patch in the series Changes from the previous version - Makes the driver use autosuspend - Folds Benoit's bus_num removal patch in the series This is also available through git : git://gitorious.org/linus-tree/linus-tree.git branch : spi Benoit Cousson (1): spi/omap: Remove bus_num usage for instance index Felipe Balbi (2): spi: omap2-mcspi: make it behave as a module spi: omap2-mcspi: convert to module_platform_driver Shubhrajyoti D (2): spi: omap2-mcspi: use devm_* functions spi: omap2-mcspi: add support for pm_runtime autosuspend drivers/spi/spi-omap2-mcspi.c | 127 +++++++++++++++------------------------- 1 files changed, 48 insertions(+), 79 deletions(-) ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index 2012-03-26 13:44 [PATCH 0/5] spi: omap2-mcspi: driver updates Shubhrajyoti D @ 2012-03-26 13:44 ` Shubhrajyoti D 2012-03-28 8:45 ` DebBarma, Tarun Kanti [not found] ` <1332769480-28069-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org> 2012-03-27 21:58 ` [PATCH 0/5] spi: omap2-mcspi: driver updates Grant Likely 2 siblings, 1 reply; 10+ messages in thread From: Shubhrajyoti D @ 2012-03-26 13:44 UTC (permalink / raw) To: spi-devel-general Cc: linux-omap, linux-kernel, Benoit Cousson, Shubhrajyoti D From: Benoit Cousson <b-cousson@ti.com> bus_num was used to reference the mcspi controller instance in a fixed array. Remove this array and store this information directly inside drvdata structure. bus_num is now just set if the pdev->id is present or with -1 for dynamic allocation by SPI core, but the driver does not access it anymore. Clean some bad comments format, and remove un-needed space. Signed-off-by: Benoit Cousson <b-cousson@ti.com> [Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore] Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com> --- drivers/spi/spi-omap2-mcspi.c | 75 ++++++++++++++++++---------------------- 1 files changed, 34 insertions(+), 41 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index bb9274c..7785091 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -45,9 +45,6 @@ #define OMAP2_MCSPI_MAX_FREQ 48000000 -/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */ -#define OMAP2_MCSPI_MAX_CTRL 4 - #define OMAP2_MCSPI_REVISION 0x00 #define OMAP2_MCSPI_SYSSTATUS 0x14 #define OMAP2_MCSPI_IRQSTATUS 0x18 @@ -111,6 +108,16 @@ struct omap2_mcspi_dma { #define DMA_MIN_BYTES 160 +/* + * Used for context save and restore, structure members to be updated whenever + * corresponding registers are modified. + */ +struct omap2_mcspi_regs { + u32 modulctrl; + u32 wakeupenable; + struct list_head cs; +}; + struct omap2_mcspi { struct work_struct work; /* lock protects queue and registers */ @@ -122,8 +129,9 @@ struct omap2_mcspi { unsigned long phys; /* SPI1 has 4 channels, while SPI2 has 2 */ struct omap2_mcspi_dma *dma_channels; - struct device *dev; + struct device *dev; struct workqueue_struct *wq; + struct omap2_mcspi_regs ctx; }; struct omap2_mcspi_cs { @@ -135,17 +143,6 @@ struct omap2_mcspi_cs { u32 chconf0; }; -/* used for context save and restore, structure members to be updated whenever - * corresponding registers are modified. - */ -struct omap2_mcspi_regs { - u32 modulctrl; - u32 wakeupenable; - struct list_head cs; -}; - -static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL]; - #define MOD_REG_BIT(val, mask, set) do { \ if (set) \ val |= mask; \ @@ -236,9 +233,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active) static void omap2_mcspi_set_master_mode(struct spi_master *master) { + struct omap2_mcspi *mcspi = spi_master_get_devdata(master); + struct omap2_mcspi_regs *ctx = &mcspi->ctx; u32 l; - /* setup when switching from (reset default) slave mode + /* + * Setup when switching from (reset default) slave mode * to single-channel master mode */ l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL); @@ -247,24 +247,20 @@ static void omap2_mcspi_set_master_mode(struct spi_master *master) MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1); mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l); - omap2_mcspi_ctx[master->bus_num - 1].modulctrl = l; + ctx->modulctrl = l; } static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi) { - struct spi_master *spi_cntrl; - struct omap2_mcspi_cs *cs; - spi_cntrl = mcspi->master; + struct spi_master *spi_cntrl = mcspi->master; + struct omap2_mcspi_regs *ctx = &mcspi->ctx; + struct omap2_mcspi_cs *cs; /* McSPI: context restore */ - mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, - omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl); + mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, ctx->modulctrl); + mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable); - mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, - omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable); - - list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs, - node) + list_for_each_entry(cs, &ctx->cs, node) __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); } static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi) @@ -777,7 +773,8 @@ static int omap2_mcspi_request_dma(struct spi_device *spi) static int omap2_mcspi_setup(struct spi_device *spi) { int ret; - struct omap2_mcspi *mcspi; + struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master); + struct omap2_mcspi_regs *ctx = &mcspi->ctx; struct omap2_mcspi_dma *mcspi_dma; struct omap2_mcspi_cs *cs = spi->controller_state; @@ -787,7 +784,6 @@ static int omap2_mcspi_setup(struct spi_device *spi) return -EINVAL; } - mcspi = spi_master_get_devdata(spi->master); mcspi_dma = &mcspi->dma_channels[spi->chip_select]; if (!cs) { @@ -799,8 +795,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) cs->chconf0 = 0; spi->controller_state = cs; /* Link this to context save list */ - list_add_tail(&cs->node, - &omap2_mcspi_ctx[mcspi->master->bus_num - 1].cs); + list_add_tail(&cs->node, &ctx->cs); } if (mcspi_dma->dma_rx_channel == -1 @@ -1053,8 +1048,9 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m) static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) { struct spi_master *master = mcspi->master; + struct omap2_mcspi_regs *ctx = &mcspi->ctx; u32 tmp; - int ret = 0; + int ret = 0; ret = omap2_mcspi_enable_clocks(mcspi); if (ret < 0) @@ -1062,7 +1058,7 @@ static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) tmp = OMAP2_MCSPI_WAKEUPENABLE_WKEN; mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, tmp); - omap2_mcspi_ctx[master->bus_num - 1].wakeupenable = tmp; + ctx->wakeupenable = tmp; omap2_mcspi_set_master_mode(master); omap2_mcspi_disable_clocks(mcspi); @@ -1109,7 +1105,6 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) struct omap2_mcspi *mcspi; struct resource *r; int status = 0, i; - char wq_name[20]; u32 regs_offset = 0; static int bus_num = 1; struct device_node *node = pdev->dev.of_node; @@ -1150,8 +1145,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) mcspi = spi_master_get_devdata(master); mcspi->master = master; - sprintf(wq_name, "omap2_mcspi/%d", master->bus_num); - mcspi->wq = alloc_workqueue(wq_name, WQ_MEM_RECLAIM, 1); + mcspi->wq = alloc_workqueue(dev_name(&pdev->dev), WQ_MEM_RECLAIM, 1); if (mcspi->wq == NULL) { status = -ENOMEM; goto free_master; @@ -1184,7 +1178,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) spin_lock_init(&mcspi->lock); INIT_LIST_HEAD(&mcspi->msg_queue); - INIT_LIST_HEAD(&omap2_mcspi_ctx[master->bus_num - 1].cs); + INIT_LIST_HEAD(&mcspi->ctx.cs); mcspi->dma_channels = kcalloc(master->num_chipselect, sizeof(struct omap2_mcspi_dma), @@ -1291,13 +1285,12 @@ static int omap2_mcspi_resume(struct device *dev) { struct spi_master *master = dev_get_drvdata(dev); struct omap2_mcspi *mcspi = spi_master_get_devdata(master); - struct omap2_mcspi_cs *cs; + struct omap2_mcspi_regs *ctx = &mcspi->ctx; + struct omap2_mcspi_cs *cs; omap2_mcspi_enable_clocks(mcspi); - list_for_each_entry(cs, &omap2_mcspi_ctx[master->bus_num - 1].cs, - node) { + list_for_each_entry(cs, &ctx->cs, node) { if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) { - /* * We need to toggle CS state for OMAP take this * change in account. -- 1.7.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index 2012-03-26 13:44 ` [PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index Shubhrajyoti D @ 2012-03-28 8:45 ` DebBarma, Tarun Kanti 2012-03-29 8:31 ` Shubhrajyoti Datta 0 siblings, 1 reply; 10+ messages in thread From: DebBarma, Tarun Kanti @ 2012-03-28 8:45 UTC (permalink / raw) To: Shubhrajyoti D Cc: spi-devel-general, linux-omap, linux-kernel, Benoit Cousson On Mon, Mar 26, 2012 at 7:14 PM, Shubhrajyoti D <shubhrajyoti@ti.com> wrote: > From: Benoit Cousson <b-cousson@ti.com> > > bus_num was used to reference the mcspi controller instance in a fixed array. > Remove this array and store this information directly inside drvdata structure. > > bus_num is now just set if the pdev->id is present or with -1 for dynamic > allocation by SPI core, but the driver does not access it anymore. > > Clean some bad comments format, and remove un-needed space. > > Signed-off-by: Benoit Cousson <b-cousson@ti.com> > [Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore] > Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com> > --- > drivers/spi/spi-omap2-mcspi.c | 75 ++++++++++++++++++---------------------- > 1 files changed, 34 insertions(+), 41 deletions(-) > > diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c > index bb9274c..7785091 100644 > --- a/drivers/spi/spi-omap2-mcspi.c > +++ b/drivers/spi/spi-omap2-mcspi.c > @@ -45,9 +45,6 @@ > > #define OMAP2_MCSPI_MAX_FREQ 48000000 > > -/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */ > -#define OMAP2_MCSPI_MAX_CTRL 4 > - > #define OMAP2_MCSPI_REVISION 0x00 > #define OMAP2_MCSPI_SYSSTATUS 0x14 > #define OMAP2_MCSPI_IRQSTATUS 0x18 > @@ -111,6 +108,16 @@ struct omap2_mcspi_dma { > #define DMA_MIN_BYTES 160 > > > +/* > + * Used for context save and restore, structure members to be updated whenever > + * corresponding registers are modified. > + */ > +struct omap2_mcspi_regs { > + u32 modulctrl; > + u32 wakeupenable; > + struct list_head cs; > +}; > + > struct omap2_mcspi { > struct work_struct work; > /* lock protects queue and registers */ > @@ -122,8 +129,9 @@ struct omap2_mcspi { > unsigned long phys; > /* SPI1 has 4 channels, while SPI2 has 2 */ > struct omap2_mcspi_dma *dma_channels; > - struct device *dev; > + struct device *dev; > struct workqueue_struct *wq; > + struct omap2_mcspi_regs ctx; > }; > > struct omap2_mcspi_cs { > @@ -135,17 +143,6 @@ struct omap2_mcspi_cs { > u32 chconf0; > }; > > -/* used for context save and restore, structure members to be updated whenever > - * corresponding registers are modified. > - */ > -struct omap2_mcspi_regs { > - u32 modulctrl; > - u32 wakeupenable; > - struct list_head cs; > -}; > - > -static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL]; > - > #define MOD_REG_BIT(val, mask, set) do { \ > if (set) \ > val |= mask; \ > @@ -236,9 +233,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active) > > static void omap2_mcspi_set_master_mode(struct spi_master *master) > { > + struct omap2_mcspi *mcspi = spi_master_get_devdata(master); > + struct omap2_mcspi_regs *ctx = &mcspi->ctx; > u32 l; > > - /* setup when switching from (reset default) slave mode > + /* > + * Setup when switching from (reset default) slave mode > * to single-channel master mode > */ > l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL); > @@ -247,24 +247,20 @@ static void omap2_mcspi_set_master_mode(struct spi_master *master) > MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1); > mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l); > > - omap2_mcspi_ctx[master->bus_num - 1].modulctrl = l; > + ctx->modulctrl = l; > } > > static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi) > { > - struct spi_master *spi_cntrl; > - struct omap2_mcspi_cs *cs; > - spi_cntrl = mcspi->master; > + struct spi_master *spi_cntrl = mcspi->master; > + struct omap2_mcspi_regs *ctx = &mcspi->ctx; > + struct omap2_mcspi_cs *cs; > > /* McSPI: context restore */ > - mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, > - omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl); > + mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, ctx->modulctrl); > + mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable); > > - mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, > - omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable); > - > - list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs, > - node) > + list_for_each_entry(cs, &ctx->cs, node) > __raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); > } > static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi) > @@ -777,7 +773,8 @@ static int omap2_mcspi_request_dma(struct spi_device *spi) > static int omap2_mcspi_setup(struct spi_device *spi) > { > int ret; > - struct omap2_mcspi *mcspi; > + struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master); > + struct omap2_mcspi_regs *ctx = &mcspi->ctx; > struct omap2_mcspi_dma *mcspi_dma; > struct omap2_mcspi_cs *cs = spi->controller_state; > > @@ -787,7 +784,6 @@ static int omap2_mcspi_setup(struct spi_device *spi) > return -EINVAL; > } > > - mcspi = spi_master_get_devdata(spi->master); > mcspi_dma = &mcspi->dma_channels[spi->chip_select]; > > if (!cs) { > @@ -799,8 +795,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) > cs->chconf0 = 0; > spi->controller_state = cs; > /* Link this to context save list */ > - list_add_tail(&cs->node, > - &omap2_mcspi_ctx[mcspi->master->bus_num - 1].cs); > + list_add_tail(&cs->node, &ctx->cs); > } > > if (mcspi_dma->dma_rx_channel == -1 > @@ -1053,8 +1048,9 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m) > static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) > { > struct spi_master *master = mcspi->master; > + struct omap2_mcspi_regs *ctx = &mcspi->ctx; > u32 tmp; > - int ret = 0; > + int ret = 0; > > ret = omap2_mcspi_enable_clocks(mcspi); > if (ret < 0) > @@ -1062,7 +1058,7 @@ static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) > > tmp = OMAP2_MCSPI_WAKEUPENABLE_WKEN; > mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, tmp); > - omap2_mcspi_ctx[master->bus_num - 1].wakeupenable = tmp; > + ctx->wakeupenable = tmp; Can't we get rid of tmp now? For example: ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN; mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable); -- Tarun > > omap2_mcspi_set_master_mode(master); > omap2_mcspi_disable_clocks(mcspi); > @@ -1109,7 +1105,6 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) > struct omap2_mcspi *mcspi; > struct resource *r; > int status = 0, i; > - char wq_name[20]; > u32 regs_offset = 0; > static int bus_num = 1; > struct device_node *node = pdev->dev.of_node; > @@ -1150,8 +1145,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) > mcspi = spi_master_get_devdata(master); > mcspi->master = master; > > - sprintf(wq_name, "omap2_mcspi/%d", master->bus_num); > - mcspi->wq = alloc_workqueue(wq_name, WQ_MEM_RECLAIM, 1); > + mcspi->wq = alloc_workqueue(dev_name(&pdev->dev), WQ_MEM_RECLAIM, 1); > if (mcspi->wq == NULL) { > status = -ENOMEM; > goto free_master; > @@ -1184,7 +1178,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) > > spin_lock_init(&mcspi->lock); > INIT_LIST_HEAD(&mcspi->msg_queue); > - INIT_LIST_HEAD(&omap2_mcspi_ctx[master->bus_num - 1].cs); > + INIT_LIST_HEAD(&mcspi->ctx.cs); > > mcspi->dma_channels = kcalloc(master->num_chipselect, > sizeof(struct omap2_mcspi_dma), > @@ -1291,13 +1285,12 @@ static int omap2_mcspi_resume(struct device *dev) > { > struct spi_master *master = dev_get_drvdata(dev); > struct omap2_mcspi *mcspi = spi_master_get_devdata(master); > - struct omap2_mcspi_cs *cs; > + struct omap2_mcspi_regs *ctx = &mcspi->ctx; > + struct omap2_mcspi_cs *cs; > > omap2_mcspi_enable_clocks(mcspi); > - list_for_each_entry(cs, &omap2_mcspi_ctx[master->bus_num - 1].cs, > - node) { > + list_for_each_entry(cs, &ctx->cs, node) { > if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) { > - > /* > * We need to toggle CS state for OMAP take this > * change in account. > -- > 1.7.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-omap" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index 2012-03-28 8:45 ` DebBarma, Tarun Kanti @ 2012-03-29 8:31 ` Shubhrajyoti Datta 0 siblings, 0 replies; 10+ messages in thread From: Shubhrajyoti Datta @ 2012-03-29 8:31 UTC (permalink / raw) To: DebBarma, Tarun Kanti Cc: Shubhrajyoti D, spi-devel-general, linux-omap, linux-kernel, Benoit Cousson Hi Tarun, On Wed, Mar 28, 2012 at 2:15 PM, DebBarma, Tarun Kanti <tarun.kanti@ti.com> wrote: > On Mon, Mar 26, 2012 at 7:14 PM, Shubhrajyoti D <shubhrajyoti@ti.com> wrote: >> From: Benoit Cousson <b-cousson@ti.com> >> >> bus_num was used to reference the mcspi controller instance in a fixed array. >> Remove this array and store this information directly inside drvdata structure. >> >> bus_num is now just set if the pdev->id is present or with -1 for dynamic >> allocation by SPI core, but the driver does not access it anymore. >> >> Clean some bad comments format, and remove un-needed space. >> >> Signed-off-by: Benoit Cousson <b-cousson@ti.com> >> [Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore] >> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com> >> --- >> drivers/spi/spi-omap2-mcspi.c | 75 ++++++++++++++++++---------------------- >> 1 files changed, 34 insertions(+), 41 deletions(-) >> >> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c >> index bb9274c..7785091 100644 >> --- a/drivers/spi/spi-omap2-mcspi.c >> +++ b/drivers/spi/spi-omap2-mcspi.c >> @@ -45,9 +45,6 @@ >> <snip> >> >> tmp = OMAP2_MCSPI_WAKEUPENABLE_WKEN; >> mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, tmp); >> - omap2_mcspi_ctx[master->bus_num - 1].wakeupenable = tmp; >> + ctx->wakeupenable = tmp; > Can't we get rid of tmp now? For example: > ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN; > mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable); Yes the tmp variable could be optimized since it is in addition to the $SUBJECT will do it in a separate patch . Is that fine? > -- > Tarun > -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <1332769480-28069-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>]
* [PATCH v2 2/5] spi: omap2-mcspi: make it behave as a module [not found] ` <1332769480-28069-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org> @ 2012-03-26 13:44 ` Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 3/5] spi: omap2-mcspi: convert to module_platform_driver Shubhrajyoti D ` (2 subsequent siblings) 3 siblings, 0 replies; 10+ messages in thread From: Shubhrajyoti D @ 2012-03-26 13:44 UTC (permalink / raw) To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Felipe Balbi, Shubhrajyoti D From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> move probe away from __init section and use platform_driver_register() instead of platform_driver_probe(). Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org> --- drivers/spi/spi-omap2-mcspi.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 7785091..26dd79f 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -1098,7 +1098,7 @@ static const struct of_device_id omap_mcspi_of_match[] = { }; MODULE_DEVICE_TABLE(of, omap_mcspi_of_match); -static int __init omap2_mcspi_probe(struct platform_device *pdev) +static int __devinit omap2_mcspi_probe(struct platform_device *pdev) { struct spi_master *master; struct omap2_mcspi_platform_config *pdata; @@ -1245,7 +1245,7 @@ free_master: return status; } -static int __exit omap2_mcspi_remove(struct platform_device *pdev) +static int __devexit omap2_mcspi_remove(struct platform_device *pdev) { struct spi_master *master; struct omap2_mcspi *mcspi; @@ -1320,13 +1320,14 @@ static struct platform_driver omap2_mcspi_driver = { .pm = &omap2_mcspi_pm_ops, .of_match_table = omap_mcspi_of_match, }, - .remove = __exit_p(omap2_mcspi_remove), + .probe = omap2_mcspi_probe, + .remove = __devexit_p(omap2_mcspi_remove), }; static int __init omap2_mcspi_init(void) { - return platform_driver_probe(&omap2_mcspi_driver, omap2_mcspi_probe); + return platform_driver_register(&omap2_mcspi_driver); } subsys_initcall(omap2_mcspi_init); -- 1.7.1 ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/5] spi: omap2-mcspi: convert to module_platform_driver [not found] ` <1332769480-28069-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org> 2012-03-26 13:44 ` [PATCH v2 2/5] spi: omap2-mcspi: make it behave as a module Shubhrajyoti D @ 2012-03-26 13:44 ` Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 4/5] spi: omap2-mcspi: use devm_* functions Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 5/5] spi: omap2-mcspi: add support for pm_runtime autosuspend Shubhrajyoti D 3 siblings, 0 replies; 10+ messages in thread From: Shubhrajyoti D @ 2012-03-26 13:44 UTC (permalink / raw) To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Felipe Balbi, Shubhrajyoti D From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> this will delete a few lines of code, no functional changes. Signed-off-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org> --- drivers/spi/spi-omap2-mcspi.c | 15 +-------------- 1 files changed, 1 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 26dd79f..66cbf22 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -1324,18 +1324,5 @@ static struct platform_driver omap2_mcspi_driver = { .remove = __devexit_p(omap2_mcspi_remove), }; - -static int __init omap2_mcspi_init(void) -{ - return platform_driver_register(&omap2_mcspi_driver); -} -subsys_initcall(omap2_mcspi_init); - -static void __exit omap2_mcspi_exit(void) -{ - platform_driver_unregister(&omap2_mcspi_driver); - -} -module_exit(omap2_mcspi_exit); - +module_platform_driver(omap2_mcspi_driver); MODULE_LICENSE("GPL"); -- 1.7.1 ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 4/5] spi: omap2-mcspi: use devm_* functions [not found] ` <1332769480-28069-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org> 2012-03-26 13:44 ` [PATCH v2 2/5] spi: omap2-mcspi: make it behave as a module Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 3/5] spi: omap2-mcspi: convert to module_platform_driver Shubhrajyoti D @ 2012-03-26 13:44 ` Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 5/5] spi: omap2-mcspi: add support for pm_runtime autosuspend Shubhrajyoti D 3 siblings, 0 replies; 10+ messages in thread From: Shubhrajyoti D @ 2012-03-26 13:44 UTC (permalink / raw) To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f Cc: Shubhrajyoti, linux-omap-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, D The various devm_* functions allocate memory that is released when a driver detaches. This patch uses devm_request_and_ioremap to request memory in probe function. Since the freeing is not needed the calls are deleted from remove function.Also use use devm_kzalloc for the cs memory allocation. Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org> --- drivers/spi/spi-omap2-mcspi.c | 24 ++++-------------------- 1 files changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 66cbf22..1907ed2 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -787,7 +787,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) mcspi_dma = &mcspi->dma_channels[spi->chip_select]; if (!cs) { - cs = kzalloc(sizeof *cs, GFP_KERNEL); + cs = devm_kzalloc(&spi->dev , sizeof *cs, GFP_KERNEL); if (!cs) return -ENOMEM; cs->base = mcspi->base + spi->chip_select * 0x14; @@ -828,7 +828,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) cs = spi->controller_state; list_del(&cs->node); - kfree(spi->controller_state); } if (spi->chip_select < spi->master->num_chipselect) { @@ -1160,17 +1159,12 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) r->start += regs_offset; r->end += regs_offset; mcspi->phys = r->start; - if (!request_mem_region(r->start, resource_size(r), - dev_name(&pdev->dev))) { - status = -EBUSY; - goto free_master; - } - mcspi->base = ioremap(r->start, resource_size(r)); + mcspi->base = devm_request_and_ioremap(&pdev->dev, r); if (!mcspi->base) { dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); status = -ENOMEM; - goto release_region; + goto free_master; } mcspi->dev = &pdev->dev; @@ -1185,7 +1179,7 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) GFP_KERNEL); if (mcspi->dma_channels == NULL) - goto unmap_io; + goto free_master; for (i = 0; i < master->num_chipselect; i++) { char dma_ch_name[14]; @@ -1235,10 +1229,6 @@ disable_pm: pm_runtime_disable(&pdev->dev); dma_chnl_free: kfree(mcspi->dma_channels); -unmap_io: - iounmap(mcspi->base); -release_region: - release_mem_region(r->start, resource_size(r)); free_master: kfree(master); platform_set_drvdata(pdev, NULL); @@ -1250,8 +1240,6 @@ static int __devexit omap2_mcspi_remove(struct platform_device *pdev) struct spi_master *master; struct omap2_mcspi *mcspi; struct omap2_mcspi_dma *dma_channels; - struct resource *r; - void __iomem *base; master = dev_get_drvdata(&pdev->dev); mcspi = spi_master_get_devdata(master); @@ -1259,12 +1247,8 @@ static int __devexit omap2_mcspi_remove(struct platform_device *pdev) omap2_mcspi_disable_clocks(mcspi); pm_runtime_disable(&pdev->dev); - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(r->start, resource_size(r)); - base = mcspi->base; spi_unregister_master(master); - iounmap(base); kfree(dma_channels); destroy_workqueue(mcspi->wq); platform_set_drvdata(pdev, NULL); -- 1.7.1 ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 5/5] spi: omap2-mcspi: add support for pm_runtime autosuspend [not found] ` <1332769480-28069-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org> ` (2 preceding siblings ...) 2012-03-26 13:44 ` [PATCH v2 4/5] spi: omap2-mcspi: use devm_* functions Shubhrajyoti D @ 2012-03-26 13:44 ` Shubhrajyoti D 3 siblings, 0 replies; 10+ messages in thread From: Shubhrajyoti D @ 2012-03-26 13:44 UTC (permalink / raw) To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f Cc: Shubhrajyoti, linux-omap-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, D Adds support for configuring the omap2-mcspi driver use autosuspend for runtime power management. This can reduce the latency in starting an spi transfer by not suspending the device immediately following completion of a transfer. If another transfer then takes place before the autosuspend timeout (2 secs), the call to resume the device can return immediately saving some save/ restore cycles. Acked-by: Govindraj.R <govindraj.raja-l0cyMroinI0@public.gmane.org> Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org> --- drivers/spi/spi-omap2-mcspi.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 1907ed2..0b0da2f 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -44,6 +44,7 @@ #include <plat/mcspi.h> #define OMAP2_MCSPI_MAX_FREQ 48000000 +#define SPI_AUTOSUSPEND_TIMEOUT 2000 #define OMAP2_MCSPI_REVISION 0x00 #define OMAP2_MCSPI_SYSSTATUS 0x14 @@ -265,7 +266,8 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi) } static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi) { - pm_runtime_put_sync(mcspi->dev); + pm_runtime_mark_last_busy(mcspi->dev); + pm_runtime_put_autosuspend(mcspi->dev); } static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi) @@ -1212,6 +1214,8 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) if (status < 0) goto dma_chnl_free; + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); pm_runtime_enable(&pdev->dev); if (status || omap2_mcspi_master_setup(mcspi) < 0) -- 1.7.1 ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/5] spi: omap2-mcspi: driver updates 2012-03-26 13:44 [PATCH 0/5] spi: omap2-mcspi: driver updates Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index Shubhrajyoti D [not found] ` <1332769480-28069-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org> @ 2012-03-27 21:58 ` Grant Likely 2012-03-28 5:48 ` Shubhrajyoti Datta 2 siblings, 1 reply; 10+ messages in thread From: Grant Likely @ 2012-03-27 21:58 UTC (permalink / raw) To: Shubhrajyoti D, spi-devel-general Cc: Shubhrajyoti, linux-omap, linux-kernel, D On Mon, 26 Mar 2012 19:14:35 +0530, Shubhrajyoti D <shubhrajyoti@ti.com> wrote: > The patch series does the following cleanups > - Converts the spi to module_platform_driver > - Use the devm functions so that the freeing need not > be done in the driver. > - Makes the driver use autosuspend > - Folds Benoit's bus_num removal patch in the series > > Changes from the previous version > - Makes the driver use autosuspend > - Folds Benoit's bus_num removal patch in the series > > > This is also available through > git : git://gitorious.org/linus-tree/linus-tree.git > branch : spi Hi Shubhrajyoti, I'll queue these ones up for v3.5 unless you make the argument that they are bug fixes that must go into v3.4. g. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/5] spi: omap2-mcspi: driver updates 2012-03-27 21:58 ` [PATCH 0/5] spi: omap2-mcspi: driver updates Grant Likely @ 2012-03-28 5:48 ` Shubhrajyoti Datta 0 siblings, 0 replies; 10+ messages in thread From: Shubhrajyoti Datta @ 2012-03-28 5:48 UTC (permalink / raw) To: Grant Likely Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, linux-omap-u79uwXL29TY76Z2rM5mHXA, Shubhrajyoti D, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Shubhrajyoti-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys Hi Grant, On Wed, Mar 28, 2012 at 3:28 AM, Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote: > On Mon, 26 Mar 2012 19:14:35 +0530, Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org> wrote: >> The patch series does the following cleanups >> - Converts the spi to module_platform_driver >> - Use the devm functions so that the freeing need not >> be done in the driver. >> - Makes the driver use autosuspend >> - Folds Benoit's bus_num removal patch in the series >> >> Changes from the previous version >> - Makes the driver use autosuspend >> - Folds Benoit's bus_num removal patch in the series >> >> >> This is also available through >> git : git://gitorious.org/linus-tree/linus-tree.git >> branch : spi > > Hi Shubhrajyoti, > > I'll queue these ones up for v3.5 unless you make the argument that > they are bug fixes that must go into v3.4. No thats fine if targeted for v3.5 . Thanks, > > g. > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-03-29 8:31 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-03-26 13:44 [PATCH 0/5] spi: omap2-mcspi: driver updates Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 1/5] spi/omap: Remove bus_num usage for instance index Shubhrajyoti D 2012-03-28 8:45 ` DebBarma, Tarun Kanti 2012-03-29 8:31 ` Shubhrajyoti Datta [not found] ` <1332769480-28069-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org> 2012-03-26 13:44 ` [PATCH v2 2/5] spi: omap2-mcspi: make it behave as a module Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 3/5] spi: omap2-mcspi: convert to module_platform_driver Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 4/5] spi: omap2-mcspi: use devm_* functions Shubhrajyoti D 2012-03-26 13:44 ` [PATCH v2 5/5] spi: omap2-mcspi: add support for pm_runtime autosuspend Shubhrajyoti D 2012-03-27 21:58 ` [PATCH 0/5] spi: omap2-mcspi: driver updates Grant Likely 2012-03-28 5:48 ` Shubhrajyoti Datta
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).