From patchwork Tue Sep 11 09:44:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 11305 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 4AC2523E02 for ; Tue, 11 Sep 2012 09:47:19 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id D47E4A1804C for ; Tue, 11 Sep 2012 09:47:18 +0000 (UTC) Received: by iafj25 with SMTP id j25so239613iaf.11 for ; Tue, 11 Sep 2012 02:47:18 -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=bgqRlBEVfAjMxt0GsKSmf2fs5n/IKvH+xfM8780B5PE=; b=MyWVA+79emJ51L008tsHwPsR5QYJdSjVdS+yopf/ncddI2ZJs/JtMWXnz8Rqmayrqq Qt9JbgzA5cdroAclaXXT6tKeVqhR8/axWcs4Nr0OuBxgfw8LiSWzn/UmbEoeiV0tjEBu npOo/F7s9oenC/ZwE+QIfvZzY6ZEsqVr2UrLTyRqz9JRoHWPNb7JoW5uLCzBKrmx5ZD2 sgqGHjdjotlIWRmM0f3VdwKGBC0sDwAZogxARgjGWZeDIrqvcV40DFOkZCxiz8gopJz3 0Zb/SRw6YEgnHsj7CbAl10ceUxKGQW25hbZ7kxHL0caX4OuK3dK75TK9iJc44Z1/8+l9 frow== Received: by 10.50.217.227 with SMTP id pb3mr15176245igc.28.1347356838090; Tue, 11 Sep 2012 02:47:18 -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 ex8csp5039igc; Tue, 11 Sep 2012 02:47:17 -0700 (PDT) Received: by 10.66.86.201 with SMTP id r9mr26236947paz.16.1347356837384; Tue, 11 Sep 2012 02:47:17 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id qs7si24266865pbc.12.2012.09.11.02.47.17 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Sep 2012 02:47:17 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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 mail-pz0-f50.google.com with SMTP id e7so258583dad.37 for ; Tue, 11 Sep 2012 02:47:17 -0700 (PDT) Received: by 10.68.220.104 with SMTP id pv8mr10554422pbc.119.1347356837038; Tue, 11 Sep 2012 02:47:17 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id sr3sm9506152pbc.44.2012.09.11.02.47.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Sep 2012 02:47:16 -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 v2] pwm: Fix compilation error when CONFIG_PWM is not defined Date: Tue, 11 Sep 2012 15:14:15 +0530 Message-Id: <1347356655-17191-1-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQlIZaKiqVdQ7hI5V8FxBFFDV5e9cr6gZBEdtYk3tncgplPSGsjuCkFUBd6fI9BXJsp8OS9z Add dummy implemention of public symbols for compilation-safe inclusion of include/linux/pwm.h file when CONFIG_PWM is not defined. While at it, also reorganize the file. Reported-by: Sachin Kamat Signed-off-by: Tushar Behera --- 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 | 135 ++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 97 insertions(+), 38 deletions(-) diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 21d076c..f1e685b 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -6,32 +6,6 @@ struct pwm_device; struct seq_file; -/* - * pwm_request - request a PWM device - */ -struct pwm_device *pwm_request(int pwm_id, const char *label); - -/* - * pwm_free - free a PWM device - */ -void pwm_free(struct pwm_device *pwm); - -/* - * pwm_config - change a PWM device configuration - */ -int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns); - -/* - * pwm_enable - start a PWM output toggling - */ -int pwm_enable(struct pwm_device *pwm); - -/* - * pwm_disable - stop a PWM output toggling - */ -void pwm_disable(struct pwm_device *pwm); - -#ifdef CONFIG_PWM struct pwm_chip; enum { @@ -113,18 +87,6 @@ struct pwm_chip { unsigned int of_pwm_n_cells; }; -int pwm_set_chip_data(struct pwm_device *pwm, void *data); -void *pwm_get_chip_data(struct pwm_device *pwm); - -int pwmchip_add(struct pwm_chip *chip); -int pwmchip_remove(struct pwm_chip *chip); -struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, - unsigned int index, - const char *label); - -struct pwm_device *pwm_get(struct device *dev, const char *consumer); -void pwm_put(struct pwm_device *pwm); - struct pwm_lookup { struct list_head list; const char *provider; @@ -141,8 +103,105 @@ struct pwm_lookup { .con_id = _con_id, \ } +#ifdef CONFIG_PWM +/* + * pwm_request - request a PWM device + */ +struct pwm_device *pwm_request(int pwm_id, const char *label); + +/* + * pwm_free - free a PWM device + */ +void pwm_free(struct pwm_device *pwm); + +/* + * pwm_config - change a PWM device configuration + */ +int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns); + +/* + * pwm_enable - start a PWM output toggling + */ +int pwm_enable(struct pwm_device *pwm); + +/* + * pwm_disable - stop a PWM output toggling + */ +void pwm_disable(struct pwm_device *pwm); + +int pwm_set_chip_data(struct pwm_device *pwm, void *data); +void *pwm_get_chip_data(struct pwm_device *pwm); + +int pwmchip_add(struct pwm_chip *chip); +int pwmchip_remove(struct pwm_chip *chip); +struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, + unsigned int index, + const char *label); + +struct pwm_device *pwm_get(struct device *dev, const char *consumer); +void pwm_put(struct pwm_device *pwm); + void pwm_add_table(struct pwm_lookup *table, size_t num); +#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) +{} + +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) +{} +static inline void pwm_add_table(struct pwm_lookup *table, size_t num) +{} #endif #endif /* __LINUX_PWM_H */