From: Paul Mundt <lethal@linux-sh.org>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH 18/27] ARM: shmobile: armadillo800eva: enable camera
Date: Mon, 11 Jun 2012 04:35:22 +0000 [thread overview]
Message-ID: <20120611043521.GG10170@linux-sh.org> (raw)
In-Reply-To: <87wr3epkkt.wl%kuninori.morimoto.gx@renesas.com>
On Sun, Jun 10, 2012 at 08:57:10PM -0700, Kuninori Morimoto wrote:
> @@ -630,6 +633,80 @@ static struct platform_device sh_mmcif_device = {
> .resource = sh_mmcif_resources,
> };
>
> +/* Camera */
> +static struct clk *cam1_mclk; /* initialized on eva_clock_init() */
> +static int mt9t111_power(struct device *dev, int mode)
> +{
> + if (!cam1_mclk)
> + return -EINVAL;
> +
This isn't necessary, clk_enable/disable() can handle being passed NULL
just fine. If you've gotten control of the GPIO then you can still do
meaningful work regardless of whether you have acquired the clock or not.
> + cam1_mclk = clk_get(NULL, "video1");
> + if (IS_ERR(cam1_mclk)) {
> + cam1_mclk = NULL;
> + goto clock_error;
> + }
> +
On the other hand, I don't see why you don't do this in the ->power
routine directly, where you already have a struct device passed in for
you.
> /* armadillo 800 eva extal1 is 24MHz */
> clk_set_rate(xtal1, 24000000);
>
> /* usb24s use extal1 (= system) clock (= 24MHz) */
> clk_set_parent(usb24s, system);
>
> + /* video1 (= CON1 camera) expect 24MHz */
> + clk_set_rate(cam1_mclk, clk_round_rate(cam1_mclk, 24000000));
> +
> clock_error:
> if (!IS_ERR(system))
> clk_put(system);
This error path makes absolutely no sense. If you fail to get the camera
clock for some reason you skip over xtal and usb24s initialization?
Without the xtal rate propagation pretty much every other clock in the
system is going to be broken.
This is a good indicator that this routine is getting too big and you
need to start splitting things out in to smaller initialization
subroutines that you can conditionalize.
> + /* CON1/CON15 Camera */
> + gpio_request(GPIO_PORT173, NULL); /* STANDBY */
> + gpio_request(GPIO_PORT172, NULL); /* RST */
gpio_request() can return error, and you should not be calling in to
gpio_direction_output() on a pin you have no idea if you own or not.
> + gpio_direction_output(GPIO_PORT173, 0);
> + gpio_direction_output(GPIO_PORT172, 1);
> +
> + gpio_request(GPIO_PORT158, NULL); /* CAM_PON */
> + gpio_direction_output(GPIO_PORT158, 0); /* see mt9t111_power() */
> +
Likewise, if you require these GPIOs to be successfully requested as well
as the clock then you need to check that all of these have succeeded,
roll back the work if it hasn't, and conditionalize registration of the
platform device based on this criteria.
next prev parent reply other threads:[~2012-06-11 4:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-11 3:57 [PATCH 18/27] ARM: shmobile: armadillo800eva: enable camera Kuninori Morimoto
2012-06-11 4:35 ` Paul Mundt [this message]
2012-06-11 9:07 ` Simon Horman
2012-06-11 9:57 ` kuninori.morimoto.gx
2012-06-11 10:05 ` Kuninori Morimoto
2012-06-12 1:27 ` Simon Horman
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=20120611043521.GG10170@linux-sh.org \
--to=lethal@linux-sh.org \
--cc=linux-sh@vger.kernel.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