From patchwork Fri Jan 25 13:44:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Vaussard X-Patchwork-Id: 2045481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id B7CF93FE4B for ; Fri, 25 Jan 2013 13:47:37 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tyjad-0004lu-OL; Fri, 25 Jan 2013 13:45:07 +0000 Received: from slb-mail4.epfl.ch ([2001:620:618:1e0:1:80b2:e058:1] helo=smtp0.epfl.ch) by merlin.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1TyjaF-0004iH-CA for linux-arm-kernel@lists.infradead.org; Fri, 25 Jan 2013 13:44:45 +0000 Received: (qmail 8273 invoked by uid 107); 25 Jan 2013 13:44:40 -0000 X-Virus-Scanned: ClamAV Received: from lsro1pc340.epfl.ch (HELO lsro1pc340.epfl.ch) (128.178.145.154) (authenticated) by smtp0.epfl.ch (AngelmatoPhylax SMTP proxy) with ESMTPA; Fri, 25 Jan 2013 14:44:40 +0100 From: Florian Vaussard To: Bryan Wu , Richard Purdie , Thierry Reding Subject: [PATCH v2 1/3] pwm: Add pwm_cansleep() as exported API to users Date: Fri, 25 Jan 2013 14:44:29 +0100 Message-Id: <1359121471-21457-2-git-send-email-florian.vaussard@epfl.ch> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1359121471-21457-1-git-send-email-florian.vaussard@epfl.ch> References: <1359121471-21457-1-git-send-email-florian.vaussard@epfl.ch> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130125_084444_226161_2F46B686 X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Peter Ujfalusi , Florian Vaussard , linux-arm-kernel@lists.infradead.org, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Calls to some external PWM chips can sleep. To help users, add pwm_cansleep() API. Signed-off-by: Florian Vaussard Reviewed-by: Peter Ujfalusi --- drivers/pwm/core.c | 12 ++++++++++++ include/linux/pwm.h | 10 ++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 4a13da4..e737f5f 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -763,6 +763,18 @@ void devm_pwm_put(struct device *dev, struct pwm_device *pwm) } EXPORT_SYMBOL_GPL(devm_pwm_put); +/** + * pwm_cansleep() - report whether pwm access will sleep + * @pwm: PWM device + * + * It returns nonzero if accessing the PWM can sleep. + */ +int pwm_cansleep(struct pwm_device *pwm) +{ + return pwm->chip->can_sleep; +} +EXPORT_SYMBOL_GPL(pwm_cansleep); + #ifdef CONFIG_DEBUG_FS static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s) { diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 70655a2..e2cb5c7 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -146,6 +146,8 @@ struct pwm_ops { * @base: number of first PWM controlled by this chip * @npwm: number of PWMs controlled by this chip * @pwms: array of PWM devices allocated by the framework + * @can_sleep: flag must be set iff config()/enable()/disable() methods sleep, + * as they must while accessing PWM chips over I2C or SPI */ struct pwm_chip { struct device *dev; @@ -159,6 +161,7 @@ struct pwm_chip { struct pwm_device * (*of_xlate)(struct pwm_chip *pc, const struct of_phandle_args *args); unsigned int of_pwm_n_cells; + unsigned int can_sleep:1; }; #if IS_ENABLED(CONFIG_PWM) @@ -182,6 +185,8 @@ struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id); struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np, const char *con_id); void devm_pwm_put(struct device *dev, struct pwm_device *pwm); + +int pwm_cansleep(struct pwm_device *pwm); #else static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) { @@ -242,6 +247,11 @@ static inline struct pwm_device *devm_of_pwm_get(struct device *dev, static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm) { } + +static inline int pwm_cansleep(struct pwm_device *pwm) +{ + return 0; +} #endif struct pwm_lookup {