All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jack Stone <jwjstone@fastmail.fm>
To: Bill Gatliff <bgat@billgatliff.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PWM v6 1/3] PWM: Implement a generic PWM framework
Date: Mon, 07 Mar 2011 04:20:47 +0000	[thread overview]
Message-ID: <4D745D1F.2070808@fastmail.fm> (raw)
In-Reply-To: <1299385050-13674-2-git-send-email-bgat@billgatliff.com>

On 06/03/2011 04:17, Bill Gatliff wrote:
> +The Generic PWM Device API framework is implemented in
> +include/linux/pwm/pwm.h and drivers/pwm/pwm.c.  The functions therein
> +use information from pwm_device and pwm__config structures to invoke

Could you fix that to be pwm_config please.

[snip]

> --- /dev/null
> +++ b/drivers/pwm/Kconfig
> @@ -0,0 +1,10 @@
> +#
> +# PWM infrastructure and devices
> +#
> +
> +menuconfig GENERIC_PWM
> +	tristate "PWM Support"
> +	help
> +	  Enables PWM device support implemented via a generic
> +	  framework.  If unsure, say N.
> +

Does this need help text? Can't we just select GENERIC_PWM for the
drivers / users that need it?

> diff --git a/drivers/pwm/pwm.c b/drivers/pwm/pwm.c

[snip]

> +static int __pwm_request(struct pwm_device *p, const char *label)
> +{
> +	int ret;
> +
> +	ret = test_and_set_bit(FLAG_REQUESTED, &p->flags);
> +	if (ret) {
> +		ret = -EBUSY;
> +		goto done;
> +	}
> +
> +	p->label = label;
> +
> +	if (p->ops->request) {
> +		ret = p->ops->request(p);
> +		if (ret) {
> +			clear_bit(FLAG_REQUESTED, &p->flags);
> +			goto done;

You don't need this goto here.

> +		}
> +	}
> +
> +done:
> +	return ret;
> +}
> +

[snip]

> +struct pwm_device *pwm_request(const char *bus_id, int id, const char *label)
> +{
> +	char name[256];
> +	int ret;
> +
> +	if (id == -1)
> +		ret = scnprintf(name, sizeof name, "%s", bus_id);

Kernel doc comment for the function to describe the id == -1 case?

> +	else
> +		ret = scnprintf(name, sizeof name, "%s:%d", bus_id, id);
> +	if (ret <= 0 || ret >= sizeof name)
> +		return ERR_PTR(-EINVAL);
> +
> +	return pwm_request_byname(name, label);
> +}
> +EXPORT_SYMBOL(pwm_request);

[snip]

> +int pwm_config(struct pwm_device *p, struct pwm_config *c)
> +{
> +	int ret = 0;

	might_sleep() ?

[snip]

> +static void pwm_handler(struct work_struct *w)
> +{
> +	struct pwm_device *p = container_of(w, struct pwm_device,
> +					    handler_work);

	You could just not queue the work if !p->handler

> +	if (p->handler)
> +		p->handler(p, p->handler_data);
> +}
> +
> +void pwm_callback(struct pwm_device *p)
> +{
> +	queue_work(pwm_handler_workqueue, &p->handler_work);
> +}
> +EXPORT_SYMBOL(pwm_callback);
> +

[snip]

> +int pwm_register(struct pwm_device *p, struct device *parent, int id)
> +{
> +	int ret;
> +	char name[256];
> +
> +	if (IS_ERR_OR_NULL(parent))
> +		return -EINVAL;
> +
> +	if (id == -1)
> +		ret = scnprintf(name, sizeof name, "%s", dev_name(parent));

A kernel doc comment to explain id == -1 would be nice.

> +	else
> +		ret = scnprintf(name, sizeof name, "%s:%d", dev_name(parent), id);
> +	if (ret <= 0 || ret >= sizeof name)
> +		return -EINVAL;
> +
> +	return pwm_register_byname(p, parent, name);
> +}
> +EXPORT_SYMBOL(pwm_register);
> +

Very nice framework!

Would be nice to have kernel doc comments for the functions but that can
follow on later.

Thanks,

Jack

  parent reply	other threads:[~2011-03-07  4:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-06  4:17 [PWM v6 0/3] Implement a generic PWM framework Bill Gatliff
2011-03-06  4:17 ` [PWM v6 1/3] PWM: " Bill Gatliff
2011-03-06  6:16   ` Lars-Peter Clausen
2011-03-06  6:35     ` Lars-Peter Clausen
2011-03-07 16:28       ` Bill Gatliff
2011-03-07 19:26         ` Lars-Peter Clausen
2011-03-09 16:15           ` Bill Gatliff
2011-03-07 16:26     ` Bill Gatliff
2011-03-07 19:02       ` Lars-Peter Clausen
2011-03-09 16:19         ` Bill Gatliff
2011-03-09 17:05     ` Bill Gatliff
2011-03-10  3:13       ` Lars-Peter Clausen
2011-03-06 12:16   ` Linus Walleij
2011-03-07 16:30     ` Bill Gatliff
2011-03-07  4:20   ` Jack Stone [this message]
2011-03-07 16:35     ` Bill Gatliff
2011-03-07 17:08       ` Bill Gatliff
2011-03-08 18:12         ` Jack Stone
2011-03-09 16:19           ` Bill Gatliff
2011-03-06  4:17 ` [PWM v6 2/3] PWM: GPIO+hrtimer device emulation Bill Gatliff
2011-03-06  4:17 ` [PWM v6 3/3] PWM: Atmel PWMC driver Bill Gatliff
  -- strict thread matches above, loose matches on Subject: below --
2011-02-21  3:35 [PWM v6 0/3] Implement a generic PWM framework Bill Gatliff
2011-02-21  3:35 ` [PWM v6 1/3] PWM: " Bill Gatliff

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=4D745D1F.2070808@fastmail.fm \
    --to=jwjstone@fastmail.fm \
    --cc=bgat@billgatliff.com \
    --cc=linux-kernel@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 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.