From patchwork Wed Nov 10 10:32:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory CLEMENT X-Patchwork-Id: 313642 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAAAhEAN029306 for ; Wed, 10 Nov 2010 10:43:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753801Ab0KJKnK (ORCPT ); Wed, 10 Nov 2010 05:43:10 -0500 Received: from mail.free-electrons.com ([88.190.12.23]:44545 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752747Ab0KJKnJ (ORCPT ); Wed, 10 Nov 2010 05:43:09 -0500 Received: by mail.free-electrons.com (Postfix, from userid 106) id C77CA223; Wed, 10 Nov 2010 11:33:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.1 Received: from [192.168.100.11] (tra42-1-82-232-183-99.fbx.proxad.net [82.232.183.99]) by mail.free-electrons.com (Postfix) with ESMTPA id 4A8FA127; Wed, 10 Nov 2010 11:33:00 +0100 (CET) Message-ID: <4CDA74D6.1040107@free-electrons.com> Date: Wed, 10 Nov 2010 11:32:54 +0100 From: Gregory CLEMENT User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101027 Lightning/1.0b1 Thunderbird/3.0.10 MIME-Version: 1.0 To: spi-devel-general , linux-omap CC: David Brownell , Grant Likely , Kevin Hilman Subject: [PATCH v2 1/2] spi: Add hook on suspend/resume for spi master X-Enigmail-Version: 1.0.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 10 Nov 2010 10:43:14 +0000 (UTC) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 709c836..1094aef 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -106,6 +106,11 @@ static int spi_suspend(struct device *dev, pm_message_t message) { int value = 0; struct spi_driver *drv = to_spi_driver(dev->driver); + struct spi_device *spi_dev = to_spi_device(dev); + struct spi_master *master = NULL; + + if (spi_dev) + master = spi_dev->master; /* suspend will stop irqs and dma; no more i/o */ if (drv) { @@ -114,6 +119,9 @@ static int spi_suspend(struct device *dev, pm_message_t message) else dev_dbg(dev, "... can't suspend\n"); } + if (master && master->suspend ) + master->suspend(spi_dev); + return value; } @@ -121,7 +129,11 @@ static int spi_resume(struct device *dev) { int value = 0; struct spi_driver *drv = to_spi_driver(dev->driver); + struct spi_device *spi_dev = to_spi_device(dev); + struct spi_master *master = NULL; + if (spi_dev) + master = spi_dev->master; /* resume may restart the i/o queue */ if (drv) { if (drv->resume) @@ -129,6 +141,8 @@ static int spi_resume(struct device *dev) else dev_dbg(dev, "... can't resume\n"); } + if (master && master->resume ) + master->resume(spi_dev); return value; } diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index b4d7710..e98c630 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -307,6 +307,11 @@ struct spi_master { /* called on release() to free memory provided by spi_master */ void (*cleanup)(struct spi_device *spi); + + /* called on suspend() and resume() if spi_master has to do + * some actions */ + void (*suspend)(struct spi_device *spi); + void (*resume)(struct spi_device *spi); }; static inline void *spi_master_get_devdata(struct spi_master *master) -- 1.7.0.4