netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	linux-kernel@vger.kernel.org, Jamie Iles <jamie@jamieiles.com>,
	Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Subject: Re: [PATCH] macb: detect IP version to determin if we are on at91 or avr32
Date: Mon, 14 Mar 2011 10:15:13 +0000	[thread overview]
Message-ID: <20110314101512.GA26085@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1299863585-17263-1-git-send-email-plagnioj@jcrosoft.com>

On Fri, Mar 11, 2011 at 06:13:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> +	if (macb_is_at91(bp)) {
> +		bp->pclk = clk_get(&pdev->dev, "macb_clk");
> +		if (IS_ERR(bp->pclk)) {
> +			dev_err(&pdev->dev, "failed to get macb_clk\n");
> +			goto err_out_free_dev;
> +		}
> +		clk_enable(bp->pclk);
> +	} else {
> +		bp->pclk = clk_get(&pdev->dev, "pclk");
> +		if (IS_ERR(bp->pclk)) {
> +			dev_err(&pdev->dev, "failed to get pclk\n");
> +			goto err_out_free_dev;
> +		}
> +		bp->hclk = clk_get(&pdev->dev, "hclk");
> +		if (IS_ERR(bp->hclk)) {
> +			dev_err(&pdev->dev, "failed to get hclk\n");
> +			goto err_out_put_pclk;
> +		}
> +
> +		clk_enable(bp->pclk);
> +		clk_enable(bp->hclk);
> +	}

This is the same kind of sillyness that started getting OMAP into problems
with the clk API.  Just do this instead:

	bp->pclk = clk_get(&pdev->dev, "pclk");
	if (IS_ERR(bp->pclk)) {
		dev_err(&pdev->dev, "failed to get pclk\n");
		goto err_out_free_dev;
	}
	bp->hclk = clk_get(&pdev->dev, "hclk");
	if (IS_ERR(bp->hclk)) {
		dev_err(&pdev->dev, "failed to get hclk\n");
		goto err_out_put_pclk;
	}

	clk_enable(bp->pclk);
	clk_enable(bp->hclk);

And then require _all_ platforms using this driver to provide a pclk and
a hclk for this device, whether they exist in the SoC or not.  Where they
don't, provide dummy clocks for it.

This probably means you end up with _less_ bloat overall because you're
not having to build the above code.  You've less lines of source code to
maintain.  You have a simplified dirver with consistent requirements
across all platforms.  You don't need to read the version register, and
you don't need macb_is_at91() and macb_is_avr32().

With clkdev it's _cheap_ to provide these dummy clocks once you have one
dummy clock already in place.

  reply	other threads:[~2011-03-14 10:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11 17:13 [PATCH] macb: detect IP version to determin if we are on at91 or avr32 Jean-Christophe PLAGNIOL-VILLARD
2011-03-14 10:15 ` Russell King - ARM Linux [this message]
2011-03-14 17:24   ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-14 10:39 ` Jamie Iles

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=20110314101512.GA26085@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=hans-christian.egtvedt@atmel.com \
    --cc=jamie@jamieiles.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=plagnioj@jcrosoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).