[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201208200537.48993.arnd@arndb.de>
Date: Mon, 20 Aug 2012 05:37:48 +0000
From: Arnd Bergmann <arnd@...db.de>
To: "Kim, Milo" <Milo.Kim@...com>
Cc: Bryan Wu <bryan.wu@...onical.com>,
"thierry.reding@...onic-design.de" <thierry.reding@...onic-design.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] leds-lm3530: replace pwm platform functions with generic pwm functions
On Monday 20 August 2012, Kim, Milo wrote:
> +#ifdef CONFIG_PWM
> +static int lm3530_pwm_request(struct lm3530_data *drvdata)
> +{
> + int pwm_id;
> +
> + /* if the pwm device exists, skip requesting the device */
> + if (drvdata->pwm)
> + return 0;
> +
> + pwm_id = drvdata->pdata ? drvdata->pdata->pwm_id : 0;
> +
> + drvdata->pwm = pwm_request(pwm_id, "lm3530-pwm");
> + drvdata->period_ns = drvdata->pdata ? drvdata->pdata->period_ns : 0;
> +
> + return IS_ERR(drvdata->pwm) ? PTR_ERR(drvdata->pwm) : 0;
> +}
> +
A few comments on this:
* Rather than having to do the #ifdef here, I think it would be better if
the PWM subsystem provided stub functions for pwm_request, pwm_config,
pwm_enable, pwm_disable and pwm_free that do nothing, so you can in effect
let the compiler optimize away the above code.
* I don't understand why you need the "if (rvdata->pwm) return 0;" case.
It's normally better to do the initialization exactly once from the
probe() function. You might want to return -EPROBE_DEFER if the pwm
source is not yet available though.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists