2012-05-10 13:51:09

by Shubhrajyoti D

[permalink] [raw]
Subject: [PATCH RFC] spi: Dont call prepare/unprepare transfer if not populated

Currently the prepare/unprepare transfer are called unconditionally.
The assumption is that every driver using the spi core queue infrastructure
has to populate the prepare and unprepare functions. This encourages
drivers to populate empty functions to prevent crashing.
This patch prevents the call to prepare/unprepare if not populated.

Cc: Linus Walleij <[email protected]>
Signed-off-by: Shubhrajyoti D <[email protected]>
---

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

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 37c555e..30e114c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -532,7 +532,7 @@ static void spi_pump_messages(struct kthread_work *work)
/* Lock queue and check for queue work */
spin_lock_irqsave(&master->queue_lock, flags);
if (list_empty(&master->queue) || !master->running) {
- if (master->busy) {
+ if (master->busy && master->unprepare_transfer_hardware) {
ret = master->unprepare_transfer_hardware(master);
if (ret) {
spin_unlock_irqrestore(&master->queue_lock, flags);
@@ -562,7 +562,7 @@ static void spi_pump_messages(struct kthread_work *work)
master->busy = true;
spin_unlock_irqrestore(&master->queue_lock, flags);

- if (!was_busy) {
+ if (!was_busy && master->prepare_transfer_hardware) {
ret = master->prepare_transfer_hardware(master);
if (ret) {
dev_err(&master->dev,
--
1.7.5.4


2012-05-10 14:01:30

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH RFC] spi: Dont call prepare/unprepare transfer if not populated

On Thu, May 10, 2012 at 3:50 PM, Shubhrajyoti D <[email protected]> wrote:

> Currently the prepare/unprepare transfer are called unconditionally.
> The assumption is that every driver using the spi core queue infrastructure
> has to populate the prepare and unprepare functions. This encourages
> drivers to populate empty functions to prevent crashing.
> This patch prevents the call to prepare/unprepare if not populated.
>
> Cc: Linus Walleij <[email protected]>
> Signed-off-by: Shubhrajyoti D <[email protected]>

Great!
Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2012-05-11 03:28:50

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH RFC] spi: Dont call prepare/unprepare transfer if not populated

On Thu, 10 May 2012 16:01:27 +0200, Linus Walleij <[email protected]> wrote:
> On Thu, May 10, 2012 at 3:50 PM, Shubhrajyoti D <[email protected]> wrote:
>
> > Currently the prepare/unprepare transfer are called unconditionally.
> > The assumption is that every driver using the spi core queue infrastructure
> > has to populate the prepare and unprepare functions. This encourages
> > drivers to populate empty functions to prevent crashing.
> > This patch prevents the call to prepare/unprepare if not populated.
> >
> > Cc: Linus Walleij <[email protected]>
> > Signed-off-by: Shubhrajyoti D <[email protected]>
>
> Great!
> Acked-by: Linus Walleij <[email protected]>

Applied, thanks (after fixing extra whitespace defect).

g.

2012-05-15 19:58:23

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH RFC] spi: Dont call prepare/unprepare transfer if not populated

On Thu, May 10, 2012 at 09:24:55PM -0600, Grant Likely wrote:
> On Thu, 10 May 2012 16:01:27 +0200, Linus Walleij <[email protected]> wrote:
> > On Thu, May 10, 2012 at 3:50 PM, Shubhrajyoti D <[email protected]> wrote:
> >
> > > Currently the prepare/unprepare transfer are called unconditionally.
> > > The assumption is that every driver using the spi core queue infrastructure
> > > has to populate the prepare and unprepare functions. This encourages
> > > drivers to populate empty functions to prevent crashing.
> > > This patch prevents the call to prepare/unprepare if not populated.
> > >
> > > Cc: Linus Walleij <[email protected]>
> > > Signed-off-by: Shubhrajyoti D <[email protected]>
> >
> > Great!
> > Acked-by: Linus Walleij <[email protected]>
>
> Applied, thanks (after fixing extra whitespace defect).

Hi Grant

Is this going to appear in linux-next soon? Can i depend on having
this patch for 3.5?

Thanks
Andrew

2012-05-20 05:00:37

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH RFC] spi: Dont call prepare/unprepare transfer if not populated

On Tue, 15 May 2012 21:58:01 +0200, Andrew Lunn <[email protected]> wrote:
> On Thu, May 10, 2012 at 09:24:55PM -0600, Grant Likely wrote:
> > On Thu, 10 May 2012 16:01:27 +0200, Linus Walleij <[email protected]> wrote:
> > > On Thu, May 10, 2012 at 3:50 PM, Shubhrajyoti D <[email protected]> wrote:
> > >
> > > > Currently the prepare/unprepare transfer are called unconditionally.
> > > > The assumption is that every driver using the spi core queue infrastructure
> > > > has to populate the prepare and unprepare functions. This encourages
> > > > drivers to populate empty functions to prevent crashing.
> > > > This patch prevents the call to prepare/unprepare if not populated.
> > > >
> > > > Cc: Linus Walleij <[email protected]>
> > > > Signed-off-by: Shubhrajyoti D <[email protected]>
> > >
> > > Great!
> > > Acked-by: Linus Walleij <[email protected]>
> >
> > Applied, thanks (after fixing extra whitespace defect).
>
> Hi Grant
>
> Is this going to appear in linux-next soon? Can i depend on having
> this patch for 3.5?

It's pushed out now.

g.