mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: Tushar Behera <tushar.behera@linaro.org>
Cc: linux-kernel@vger.kernel.org, sachin.kamat@linaro.org,
	patches@linaro.org
Subject: Re: [PATCH v3] pwm: Fix compilation error when CONFIG_PWM is not defined
Date: Wed, 12 Sep 2012 11:41:51 +0200	[thread overview]
Message-ID: <20120912094151.GA21786@avionic-0098.mockup.avionic-design.de> (raw)
In-Reply-To: <1347440412-17249-1-git-send-email-tushar.behera@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 3955 bytes --]

On Wed, Sep 12, 2012 at 02:30:12PM +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 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 |   69 ++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 66 insertions(+), 3 deletions(-)

This is starting to look real good. Two more things I forgot to mention
on the last round. And one nitpick.

> diff --git a/include/linux/pwm.h b/include/linux/pwm.h
> index 21d076c..2c5daa9 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,29 @@ 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)
> +{}

These should also go on separate lines. I should have been more clear
about that. So:

	static inline void pwm_free(struct pwm_device *pwm)
	{
	}

There are a couple more of these below.

> +
> +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 /* !(IS_ENABLED(CONFIG_PWM) || IS_ENABLED(CONFIG_HAVE_PWM)) */

I don't think this comment is necessary. Most editors allow you to jump
to the matching #if or #else. Mostly these comments just confuse me.

>  
> -#ifdef CONFIG_PWM
>  struct pwm_chip;
>  
>  enum {
> @@ -113,6 +135,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 +147,43 @@ 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;
> +}

Can you align the split parameter list on subsequent lines with the
first parameter, please? Like so:

static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
						       unsigned int index,
						       const char *label)

static inline struct pwm_device *pwm_get(struct device *dev,
					 const char *consumer)

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

      reply	other threads:[~2012-09-12  9:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12  9:00 Tushar Behera
2012-09-12  9:41 ` Thierry Reding [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120912094151.GA21786@avionic-0098.mockup.avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=sachin.kamat@linaro.org \
    --cc=tushar.behera@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome