From patchwork Wed Sep 12 10:01:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 11348 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 08E8723EFE for ; Wed, 12 Sep 2012 10:04:59 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 68A843DF8908 for ; Wed, 12 Sep 2012 10:04:58 +0000 (UTC) Received: by ieak11 with SMTP id k11so2529430iea.11 for ; Wed, 12 Sep 2012 03:04:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=ooP7FpCGjzpsh0XOqU+868ZJow3x/xJyfBvxOYPK7Cg=; b=SrfAlRdQLjXP6DPlcmBVa2g42pCNyjCRX9mV4z7ISyomqmVC0fYb9VjFT8vvTb/SkV +3UKU6sxzVTRkiYDpARFxQUOq/ZLuUg6uBkQEbpkTwheoVjX9dcZe58d//nXbZGDxB92 CmGTfKXYNv79M67K2hKxe42edRyWEoJmX9hZMnipoQF23ZsJ6KgQe7y5T55aq+IXM3b9 2s43mhBqKN30QlfN01IRk6+2jxc7KY3vvGjH69cLMqtmQrPdzfpfhVwBSiboeinPdLk9 Hh6lQjLwUuWpSpmg7f3fvRVIH7t5xmbZA5t0OKXqBgIkCdqNdRm7BO2xCXO+/l7b9+Nw grxw== Received: by 10.50.191.227 with SMTP id hb3mr12145313igc.43.1347444297740; Wed, 12 Sep 2012 03:04:57 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp61477igc; Wed, 12 Sep 2012 03:04:57 -0700 (PDT) Received: by 10.66.85.8 with SMTP id d8mr4299589paz.30.1347444296596; Wed, 12 Sep 2012 03:04:56 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id iv6si28987002pbc.28.2012.09.12.03.04.56 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 03:04:56 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) smtp.mail=tushar.behera@linaro.org Received: by pbcmd12 with SMTP id md12so2346933pbc.37 for ; Wed, 12 Sep 2012 03:04:56 -0700 (PDT) Received: by 10.68.241.226 with SMTP id wl2mr16099803pbc.62.1347444296042; Wed, 12 Sep 2012 03:04:56 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id kt1sm11164634pbc.45.2012.09.12.03.04.53 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 03:04:54 -0700 (PDT) From: Tushar Behera To: linux-kernel@vger.kernel.org Cc: thierry.reding@avionic-design.de, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH v4] pwm: Fix compilation error when CONFIG_PWM is not defined Date: Wed, 12 Sep 2012 15:31:46 +0530 Message-Id: <1347444106-30509-1-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQn99ok76cFFd79lfPvMDcQSfH9vlHWO4Ixsd+gFmPnFKh2L5IPQ/KfQ1PBeN0J2dSkc6qwT Add dummy implemention of public symbols for compilation-safe inclusion of include/linux/pwm.h file when CONFIG_PWM is not defined. Reported-by: Sachin Kamat Signed-off-by: Tushar Behera --- Changes since v3: * Nitpicks Changes since v2: * #if condition for legacy functions modified * Reverted layout changes, can be taken up when HAVE_PWM is no longer required. Changes since v1: * Incorporated Thierry's suggestions regarding adding dummy function implemention for all global functions * Reorganized header file to have structure definitions first and then the function definitions. include/linux/pwm.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 69 insertions(+), 2 deletions(-) diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 21d076c..946651d 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -6,6 +6,7 @@ struct pwm_device; struct seq_file; +#if IS_ENABLED(CONFIG_PWM) || IS_ENABLED(CONFIG_HAVE_PWM) /* * pwm_request - request a PWM device */ @@ -30,8 +31,31 @@ int pwm_enable(struct pwm_device *pwm); * pwm_disable - stop a PWM output toggling */ void pwm_disable(struct pwm_device *pwm); +#else +static inline struct pwm_device *pwm_request(int pwm_id, const char *label) +{ + return NULL; +} + +static inline void pwm_free(struct pwm_device *pwm) +{ +} + +static inline int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) +{ + return -EINVAL; +} + +static inline int pwm_enable(struct pwm_device *pwm) +{ + return -EINVAL; +} + +static inline void pwm_disable(struct pwm_device *pwm) +{ +} +#endif -#ifdef CONFIG_PWM struct pwm_chip; enum { @@ -113,6 +137,7 @@ struct pwm_chip { unsigned int of_pwm_n_cells; }; +#if IS_ENABLED(CONFIG_PWM) int pwm_set_chip_data(struct pwm_device *pwm, void *data); void *pwm_get_chip_data(struct pwm_device *pwm); @@ -124,6 +149,44 @@ struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, struct pwm_device *pwm_get(struct device *dev, const char *consumer); void pwm_put(struct pwm_device *pwm); +#else +static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) +{ + return -EINVAL; +} + +static inline void *pwm_get_chip_data(struct pwm_device *pwm) +{ + return NULL; +} + +static inline int pwmchip_add(struct pwm_chip *chip) +{ + return -EINVAL; +} + +static inline int pwmchip_remove(struct pwm_chip *chip) +{ + return -EINVAL; +} + +static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, + unsigned int index, + const char *label) +{ + return NULL; +} + +static inline struct pwm_device *pwm_get(struct device *dev, + const char *consumer) +{ + return NULL; +} + +static inline void pwm_put(struct pwm_device *pwm) +{ +} +#endif struct pwm_lookup { struct list_head list; @@ -141,8 +204,12 @@ struct pwm_lookup { .con_id = _con_id, \ } +#if IS_ENABLED(CONFIG_PWM) void pwm_add_table(struct pwm_lookup *table, size_t num); - +#else +static inline void pwm_add_table(struct pwm_lookup *table, size_t num) +{ +} #endif #endif /* __LINUX_PWM_H */