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: 313672 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAAAwLWV031229 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 10 Nov 2010 10:58:47 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 1PG8Nc-000434-JV; Wed, 10 Nov 2010 10:58:16 +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 1PG8Na-00042u-DW for spi-devel-general@lists.sourceforge.net; Wed, 10 Nov 2010 10:58:14 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of free-electrons.com designates 88.190.12.23 as permitted sender) client-ip=88.190.12.23; envelope-from=gregory.clement@free-electrons.com; helo=mail.free-electrons.com; Received: from mail.free-electrons.com ([88.190.12.23]) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.69) id 1PG8NZ-0005jv-1h for spi-devel-general@lists.sourceforge.net; Wed, 10 Nov 2010 10:58:14 +0000 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 Subject: [PATCH v2 1/2] spi: Add hook on suspend/resume for spi master X-Enigmail-Version: 1.0.1 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1PG8NZ-0005jv-1h Cc: Kevin Hilman , David Brownell 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 (demeter1.kernel.org [140.211.167.41]); Wed, 10 Nov 2010 10:58:47 +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