diff mbox

[1/2] pwm: Add __weak attributed functions for pwm operations

Message ID 1305290602-29859-2-git-send-email-mpallaka@codeaurora.org (mailing list archive)
State New, archived
Headers show

Commit Message

Mohan Pallaka May 13, 2011, 12:43 p.m. UTC
For chip drivers that support both pwm and non-pwm modes
would encounter compilation errors if the platform doesn't
have support for pwm though the chip is programmed to work
in non-pwm mode. Add __weak attributed pwm functions to avoid
compilation issues in these scenarios.

Change-Id: Ia507bf659d4d67d71f135012e7d919aca6c45c6c
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
---
 include/linux/pwm.h |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

Comments

David Brown May 13, 2011, 4:25 p.m. UTC | #1
On Fri, May 13 2011, Mohan Pallaka wrote:

> For chip drivers that support both pwm and non-pwm modes
> would encounter compilation errors if the platform doesn't
> have support for pwm though the chip is programmed to work
> in non-pwm mode. Add __weak attributed pwm functions to avoid
> compilation issues in these scenarios.
>
> Change-Id: Ia507bf659d4d67d71f135012e7d919aca6c45c6c

Make sure you remove these 'Change-Id' lines before sending patches.
They aren't supposed to be in the kernel since they refer to an internal
server, and aren't useful to anyone else.

David
Dmitry Torokhov May 15, 2011, 8 a.m. UTC | #2
On Fri, May 13, 2011 at 06:13:21PM +0530, Mohan Pallaka wrote:
> For chip drivers that support both pwm and non-pwm modes
> would encounter compilation errors if the platform doesn't
> have support for pwm though the chip is programmed to work
> in non-pwm mode. Add __weak attributed pwm functions to avoid
> compilation issues in these scenarios.
> 

Russell,

You seem to have authored pwm.h, do you have any objections to this
change?

Thanks!

> Change-Id: Ia507bf659d4d67d71f135012e7d919aca6c45c6c
> Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
> ---
>  include/linux/pwm.h |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/pwm.h b/include/linux/pwm.h
> index 7c77575..e0c8c3f 100644
> --- a/include/linux/pwm.h
> +++ b/include/linux/pwm.h
> @@ -3,29 +3,31 @@
>  
>  struct pwm_device;
>  
> +/* Add __weak functions to support PWM */
> +
>  /*
>   * pwm_request - request a PWM device
>   */
> -struct pwm_device *pwm_request(int pwm_id, const char *label);
> +struct pwm_device __weak *pwm_request(int pwm_id, const char *label);
>  
>  /*
>   * pwm_free - free a PWM device
>   */
> -void pwm_free(struct pwm_device *pwm);
> +void __weak 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);
> +int __weak 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);
> +int __weak pwm_enable(struct pwm_device *pwm);
>  
>  /*
>   * pwm_disable - stop a PWM output toggling
>   */
> -void pwm_disable(struct pwm_device *pwm);
> +void __weak pwm_disable(struct pwm_device *pwm);
>  
>  #endif /* __LINUX_PWM_H */
> 
> -- 
> Sent by a consultant of the Qualcomm Innovation Center, Inc.
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Dmitry Torokhov May 15, 2011, 8:16 a.m. UTC | #3
On Fri, May 13, 2011 at 06:13:21PM +0530, Mohan Pallaka wrote:
> For chip drivers that support both pwm and non-pwm modes
> would encounter compilation errors if the platform doesn't
> have support for pwm though the chip is programmed to work
> in non-pwm mode. Add __weak attributed pwm functions to avoid
> compilation issues in these scenarios.
> 

Russell,

You seem to have authored pwm.h, do you have any objections to this
change?

Thanks!

> Change-Id: Ia507bf659d4d67d71f135012e7d919aca6c45c6c
> Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
> ---
>  include/linux/pwm.h |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/pwm.h b/include/linux/pwm.h
> index 7c77575..e0c8c3f 100644
> --- a/include/linux/pwm.h
> +++ b/include/linux/pwm.h
> @@ -3,29 +3,31 @@
>  
>  struct pwm_device;
>  
> +/* Add __weak functions to support PWM */
> +
>  /*
>   * pwm_request - request a PWM device
>   */
> -struct pwm_device *pwm_request(int pwm_id, const char *label);
> +struct pwm_device __weak *pwm_request(int pwm_id, const char *label);
>  
>  /*
>   * pwm_free - free a PWM device
>   */
> -void pwm_free(struct pwm_device *pwm);
> +void __weak 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);
> +int __weak 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);
> +int __weak pwm_enable(struct pwm_device *pwm);
>  
>  /*
>   * pwm_disable - stop a PWM output toggling
>   */
> -void pwm_disable(struct pwm_device *pwm);
> +void __weak pwm_disable(struct pwm_device *pwm);
>  
>  #endif /* __LINUX_PWM_H */
> 
> -- 
> Sent by a consultant of the Qualcomm Innovation Center, Inc.
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Russell King - ARM Linux May 15, 2011, 10:58 a.m. UTC | #4
On Sun, May 15, 2011 at 01:00:31AM -0700, Dmitry Torokhov wrote:
> On Fri, May 13, 2011 at 06:13:21PM +0530, Mohan Pallaka wrote:
> > For chip drivers that support both pwm and non-pwm modes
> > would encounter compilation errors if the platform doesn't
> > have support for pwm though the chip is programmed to work
> > in non-pwm mode. Add __weak attributed pwm functions to avoid
> > compilation issues in these scenarios.
> > 
> 
> Russell,
> 
> You seem to have authored pwm.h, do you have any objections to this
> change?

This seems to be a recipe for an oops.  Have a look at how
linux/regulator/consumer.h deals with this kind of problem, and notice
that we have CONFIG_HAVE_PWM to indicate whether this interface is
supported or not.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mohan Pallaka May 17, 2011, 4:42 a.m. UTC | #5
On 5/15/2011 4:28 PM, Russell King - ARM Linux wrote:
> On Sun, May 15, 2011 at 01:00:31AM -0700, Dmitry Torokhov wrote:
>> On Fri, May 13, 2011 at 06:13:21PM +0530, Mohan Pallaka wrote:
>>> For chip drivers that support both pwm and non-pwm modes
>>> would encounter compilation errors if the platform doesn't
>>> have support for pwm though the chip is programmed to work
>>> in non-pwm mode. Add __weak attributed pwm functions to avoid
>>> compilation issues in these scenarios.
>>>
>> Russell,
>>
>> You seem to have authored pwm.h, do you have any objections to this
>> change?
> This seems to be a recipe for an oops.  Have a look at how
> linux/regulator/consumer.h deals with this kind of problem, and notice
> that we have CONFIG_HAVE_PWM to indicate whether this interface is
> supported or not.
Thanks for the suggestion. I'll upload a new patch.

--Mohan.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 7c77575..e0c8c3f 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -3,29 +3,31 @@ 
 
 struct pwm_device;
 
+/* Add __weak functions to support PWM */
+
 /*
  * pwm_request - request a PWM device
  */
-struct pwm_device *pwm_request(int pwm_id, const char *label);
+struct pwm_device __weak *pwm_request(int pwm_id, const char *label);
 
 /*
  * pwm_free - free a PWM device
  */
-void pwm_free(struct pwm_device *pwm);
+void __weak 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);
+int __weak 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);
+int __weak pwm_enable(struct pwm_device *pwm);
 
 /*
  * pwm_disable - stop a PWM output toggling
  */
-void pwm_disable(struct pwm_device *pwm);
+void __weak pwm_disable(struct pwm_device *pwm);
 
 #endif /* __LINUX_PWM_H */