All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@mvista.com>
To: "Manjunathappa, Prakash" <prakash.pm@ti.com>
Cc: netdev@vger.kernel.org,
	davinci-linux-open-source@linux.davincidsp.com,
	davem@davemloft.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] davinci_emac: Add cpu_freq support
Date: Mon, 09 Apr 2012 15:29:52 +0400	[thread overview]
Message-ID: <4F82C830.1020100@mvista.com> (raw)
In-Reply-To: <1333968549-3282-1-git-send-email-prakash.pm@ti.com>

Hello.

On 09-04-2012 14:49, Manjunathappa, Prakash wrote:

> Reconfigure interrupt coalesce parameter for changed emac bus_freq
> due to DVFS.

> Signed-off-by: Manjunathappa, Prakash<prakash.pm@ti.com>
> ---
>   drivers/net/ethernet/ti/davinci_emac.c |   60 ++++++++++++++++++++++++++++++++
>   1 files changed, 60 insertions(+), 0 deletions(-)

> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
> index 174a334..11d3bd7 100644
> --- a/drivers/net/ethernet/ti/davinci_emac.c
> +++ b/drivers/net/ethernet/ti/davinci_emac.c
[...]
> @@ -1761,6 +1765,46 @@ static const struct net_device_ops emac_netdev_ops = {
>   #endif
>   };
>
> +#ifdef CONFIG_CPU_FREQ
> +static int davinci_emac_cpufreq_transition(struct notifier_block *nb,
> +				     unsigned long val, void *data)
> +{
> +	int ret = 0;
> +	struct emac_priv *priv;
> +
> +	priv = container_of(nb, struct emac_priv, freq_transition);
> +	if (priv->coal_intvl != 0) {
> +		if (val == CPUFREQ_POSTCHANGE) {
> +			if (emac_bus_frequency != clk_get_rate(emac_clk)) {

    These 3 *if*s could be collapsed into one, and so indentation level 
lowered significantly.

> +				struct ethtool_coalesce coal;
> +
> +				emac_bus_frequency = clk_get_rate(emac_clk);
> +
> +				priv->bus_freq_mhz = (u32)(emac_bus_frequency /
> +						1000000);
> +				coal.rx_coalesce_usecs = (priv->coal_intvl
> +						<<  4);
> +				ret = emac_set_coalesce(priv->ndev,&coal);
> +			}
> +		}
> +	}
> +	return ret;
> +}
> +
> +static inline int davinci_emac_cpufreq_register(struct emac_priv *priv)
> +{
> +	priv->freq_transition.notifier_call = davinci_emac_cpufreq_transition;
> +	return cpufreq_register_notifier(&priv->freq_transition,
> +					 CPUFREQ_TRANSITION_NOTIFIER);
> +}
> +
> +static inline void davinci_emac_cpufreq_deregister(struct emac_priv *priv)
> +{
> +	cpufreq_unregister_notifier(&priv->freq_transition,
> +				    CPUFREQ_TRANSITION_NOTIFIER);
> +}
> +#endif
> +
>   /**
>    * davinci_emac_probe: EMAC device probe
>    * @pdev: The DaVinci EMAC device that we are removing
> @@ -1925,8 +1969,21 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
>   			   "(regs: %p, irq: %d)\n",
>   			   (void *)priv->emac_base_phys, ndev->irq);
>   	}
> +
> +#ifdef CONFIG_CPU_FREQ
> +	rc = davinci_emac_cpufreq_register(priv);
> +	if (rc) {
> +		dev_err(&pdev->dev, "error in register_netdev\n");

    Really?

> +		rc = -ENODEV;
> +		goto cpufreq_reg_err;
> +	}
> +#endif
>   	return 0;
>
> +#ifdef CONFIG_CPU_FREQ
> +cpufreq_reg_err:
> +	unregister_netdev(ndev);
> +#endif
>   netdev_reg_err:
>   	clk_disable(emac_clk);
>   no_irq_res:
> @@ -1973,6 +2030,9 @@ static int __devexit davinci_emac_remove(struct platform_device *pdev)
>
>   	release_mem_region(res->start, resource_size(res));
>
> +#ifdef CONFIG_CPU_FREQ
> +	davinci_emac_cpufreq_deregister(priv);
> +#endif

    This is considered a bad practice to use #ifdef in the body of function.
Define the faunction you call here as empty inline in case CONFIG_CPU_FREQ is 
not defined instead. The same about davinci_emac_cpufreq_register().

WBR, Sergei

WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sshtylyov-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
To: "Manjunathappa, Prakash" <prakash.pm-l0cyMroinI0@public.gmane.org>
Cc: <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	<davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org>,
	<davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] davinci_emac: Add cpu_freq support
Date: Mon, 9 Apr 2012 15:29:52 +0400	[thread overview]
Message-ID: <4F82C830.1020100@mvista.com> (raw)
In-Reply-To: <1333968549-3282-1-git-send-email-prakash.pm-l0cyMroinI0@public.gmane.org>

Hello.

On 09-04-2012 14:49, Manjunathappa, Prakash wrote:

> Reconfigure interrupt coalesce parameter for changed emac bus_freq
> due to DVFS.

> Signed-off-by: Manjunathappa, Prakash<prakash.pm-l0cyMroinI0@public.gmane.org>
> ---
>   drivers/net/ethernet/ti/davinci_emac.c |   60 ++++++++++++++++++++++++++++++++
>   1 files changed, 60 insertions(+), 0 deletions(-)

> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
> index 174a334..11d3bd7 100644
> --- a/drivers/net/ethernet/ti/davinci_emac.c
> +++ b/drivers/net/ethernet/ti/davinci_emac.c
[...]
> @@ -1761,6 +1765,46 @@ static const struct net_device_ops emac_netdev_ops = {
>   #endif
>   };
>
> +#ifdef CONFIG_CPU_FREQ
> +static int davinci_emac_cpufreq_transition(struct notifier_block *nb,
> +				     unsigned long val, void *data)
> +{
> +	int ret = 0;
> +	struct emac_priv *priv;
> +
> +	priv = container_of(nb, struct emac_priv, freq_transition);
> +	if (priv->coal_intvl != 0) {
> +		if (val == CPUFREQ_POSTCHANGE) {
> +			if (emac_bus_frequency != clk_get_rate(emac_clk)) {

    These 3 *if*s could be collapsed into one, and so indentation level 
lowered significantly.

> +				struct ethtool_coalesce coal;
> +
> +				emac_bus_frequency = clk_get_rate(emac_clk);
> +
> +				priv->bus_freq_mhz = (u32)(emac_bus_frequency /
> +						1000000);
> +				coal.rx_coalesce_usecs = (priv->coal_intvl
> +						<<  4);
> +				ret = emac_set_coalesce(priv->ndev,&coal);
> +			}
> +		}
> +	}
> +	return ret;
> +}
> +
> +static inline int davinci_emac_cpufreq_register(struct emac_priv *priv)
> +{
> +	priv->freq_transition.notifier_call = davinci_emac_cpufreq_transition;
> +	return cpufreq_register_notifier(&priv->freq_transition,
> +					 CPUFREQ_TRANSITION_NOTIFIER);
> +}
> +
> +static inline void davinci_emac_cpufreq_deregister(struct emac_priv *priv)
> +{
> +	cpufreq_unregister_notifier(&priv->freq_transition,
> +				    CPUFREQ_TRANSITION_NOTIFIER);
> +}
> +#endif
> +
>   /**
>    * davinci_emac_probe: EMAC device probe
>    * @pdev: The DaVinci EMAC device that we are removing
> @@ -1925,8 +1969,21 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
>   			   "(regs: %p, irq: %d)\n",
>   			   (void *)priv->emac_base_phys, ndev->irq);
>   	}
> +
> +#ifdef CONFIG_CPU_FREQ
> +	rc = davinci_emac_cpufreq_register(priv);
> +	if (rc) {
> +		dev_err(&pdev->dev, "error in register_netdev\n");

    Really?

> +		rc = -ENODEV;
> +		goto cpufreq_reg_err;
> +	}
> +#endif
>   	return 0;
>
> +#ifdef CONFIG_CPU_FREQ
> +cpufreq_reg_err:
> +	unregister_netdev(ndev);
> +#endif
>   netdev_reg_err:
>   	clk_disable(emac_clk);
>   no_irq_res:
> @@ -1973,6 +2030,9 @@ static int __devexit davinci_emac_remove(struct platform_device *pdev)
>
>   	release_mem_region(res->start, resource_size(res));
>
> +#ifdef CONFIG_CPU_FREQ
> +	davinci_emac_cpufreq_deregister(priv);
> +#endif

    This is considered a bad practice to use #ifdef in the body of function.
Define the faunction you call here as empty inline in case CONFIG_CPU_FREQ is 
not defined instead. The same about davinci_emac_cpufreq_register().

WBR, Sergei

  reply	other threads:[~2012-04-09 11:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-09 10:49 [PATCH] davinci_emac: Add cpu_freq support Manjunathappa, Prakash
2012-04-09 11:29 ` Sergei Shtylyov [this message]
2012-04-09 11:29   ` Sergei Shtylyov
2012-04-10  5:16   ` Manjunathappa, Prakash
2012-04-09 15:56 ` Ben Hutchings

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=4F82C830.1020100@mvista.com \
    --to=sshtylyov@mvista.com \
    --cc=davem@davemloft.net \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=prakash.pm@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.