From patchwork Wed Aug 11 14:43:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory CLEMENT X-Patchwork-Id: 118828 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7BEhiqr022021 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 11 Aug 2010 14:44:23 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OjCWu-000642-GH; Wed, 11 Aug 2010 14:43:44 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OjCWt-00063t-CK for spi-devel-general@lists.sourceforge.net; Wed, 11 Aug 2010 14:43:43 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.161.47 as permitted sender) client-ip=209.85.161.47; envelope-from=gclement00@gmail.com; helo=mail-fx0-f47.google.com; Received: from mail-fx0-f47.google.com ([209.85.161.47]) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.69) id 1OjCWs-0003Kb-D3 for spi-devel-general@lists.sourceforge.net; Wed, 11 Aug 2010 14:43:43 +0000 Received: by fxm6 with SMTP id 6so173431fxm.34 for ; Wed, 11 Aug 2010 07:43:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.2.8 with SMTP id e8mr1572161mui.100.1281537816614; Wed, 11 Aug 2010 07:43:36 -0700 (PDT) Received: by 10.223.115.144 with HTTP; Wed, 11 Aug 2010 07:43:36 -0700 (PDT) Date: Wed, 11 Aug 2010 16:43:36 +0200 Message-ID: From: Gregory CLEMENT To: spi-devel-general X-Spam-Score: 0.6 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.161.47 listed in list.dnswl.org] -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is freemail (gclement00[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 2.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (gclement00[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1OjCWs-0003Kb-D3 X-Content-Filtered-By: Mailman/MimeDel 2.1.9 Cc: linux-omap Subject: [spi-devel-general] [PATCH 1/2] spi: Add hook on suspend/resume for spi master X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 11 Aug 2010 14:44:24 +0000 (UTC) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 1bb1b88..fe8140e 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include #include #include @@ -106,6 +105,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 +118,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 +128,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 +140,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 af56071..2483a1d 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -293,7 +293,9 @@ struct spi_master { struct spi_message *mesg); /* called on release() to free memory provided by spi_master */ - void (*cleanup)(struct spi_device *spi); + void (*cleanup)(struct spi_device *spi); + void (*suspend)(struct spi_device *spi); + void (*resume)(struct spi_device *spi); }; static inline void *spi_master_get_devdata(struct spi_master *master)