* [PATCH v4] pwm: Fix compilation error when CONFIG_PWM is not defined
@ 2012-09-12 10:01 Tushar Behera
2012-09-18 6:08 ` Thierry Reding
0 siblings, 1 reply; 2+ messages in thread
From: Tushar Behera @ 2012-09-12 10:01 UTC (permalink / raw)
To: linux-kernel; +Cc: thierry.reding, sachin.kamat, patches
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 <sachin.kamat@linaro.org>
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
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 */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v4] pwm: Fix compilation error when CONFIG_PWM is not defined
2012-09-12 10:01 [PATCH v4] pwm: Fix compilation error when CONFIG_PWM is not defined Tushar Behera
@ 2012-09-18 6:08 ` Thierry Reding
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2012-09-18 6:08 UTC (permalink / raw)
To: Tushar Behera; +Cc: linux-kernel, sachin.kamat, patches
[-- Attachment #1: Type: text/plain, Size: 1238 bytes --]
On Wed, Sep 12, 2012 at 03:31:46PM +0530, Tushar Behera wrote:
> 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 <sachin.kamat@linaro.org>
> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> ---
> 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(-)
Okay, I've applied this to my for-next branch, with some minor changes.
For one I had to merge it with Alex's managed functions patch. Second I
changed all dummy functions that return a struct pwm_device * to return
ERR_PTR(-ENODEV) instead of NULL because PWM users typically check for
IS_ERR(pwm) and not for NULL.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-18 6:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-12 10:01 [PATCH v4] pwm: Fix compilation error when CONFIG_PWM is not defined Tushar Behera
2012-09-18 6:08 ` Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox