public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: arnd@arndb•de (Arnd Bergmann)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v3 02/10] pwm: Allow chips to support multiple PWMs.
Date: Wed, 22 Feb 2012 16:34:44 +0000	[thread overview]
Message-ID: <201202221634.45159.arnd@arndb.de> (raw)
In-Reply-To: <1329923841-32017-3-git-send-email-thierry.reding@avionic-design.de>

On Wednesday 22 February 2012, Thierry Reding wrote:

>  #include <linux/module.h>
> +#include <linux/of_pwm.h>
>  #include <linux/pwm.h>

You should probably reorder the patches for bisectability, or move the
of_* related changes out of this patch into patch 3. At the point
where patch 2 is applied, linux/of_pwm.h does not exist yet.

>  
> +/**
> + * pwmchip_find() - iterator for locating a specific pwm_chip
> + * @data: data to pass to match function
> + * @match: callback function to check pwm_chip
> + */
> +struct pwm_chip *pwmchip_find(void *data, int (*match)(struct pwm_chip *chip,
> +						       void *data))
> +{
> +	struct pwm_chip *ret = NULL;
> +	struct pwm_chip *chip;
> +
> +	mutex_lock(&pwm_lock);
> +
> +	list_for_each_entry(chip, &pwm_chips, list) {
> +		if (match(chip, data)) {
> +			ret = chip;
> +			break;
> +		}
> +	}
> +
> +	mutex_unlock(&pwm_lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(pwmchip_find);

Is this only used for the device tree functions? If so, I would recommend
making it less generic and always search for a device node.

> +static int pwm_show(struct seq_file *s, void *unused)
> +{
> +	const char *prefix = "";
> +	struct pwm_chip *chip;
> +
> +	list_for_each_entry(chip, &pwm_chips, list) {
> +		struct device *dev = chip->dev;
> +
> +		seq_printf(s, "%s%s/%s, %d PWM devices\n", prefix,
> +			   dev->bus ? dev->bus->name : "no-bus",
> +			   dev_name(dev), chip->npwm);
> +
> +		if (chip->ops->dbg_show)
> +			chip->ops->dbg_show(chip, s);
> +		else
> +			pwm_dbg_show(chip, s);
> +
> +		prefix = "\n";
> +	}
> +
> +	return 0;
> +}
> +
> +static int pwm_open(struct inode *inode, struct file *file)
> +{
> +	return single_open(file, pwm_show, NULL);
> +}

When you have a seq_file with a (possibly long) list of entries, better
use seq_open instead of single_open and print each item in the
->next() callback function.

	Arnd

  reply	other threads:[~2012-02-22 16:34 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22 15:17 [PATCH v3 00/10] Add PWM framework and device tree support Thierry Reding
2012-02-22 15:17 ` [PATCH v3 01/10] PWM: add pwm framework support Thierry Reding
2012-02-22 15:17 ` [PATCH v3 02/10] pwm: Allow chips to support multiple PWMs Thierry Reding
2012-02-22 16:34   ` Arnd Bergmann [this message]
2012-02-23  8:12     ` Thierry Reding
2012-02-23 14:07       ` Arnd Bergmann
2012-02-23 16:04         ` Thierry Reding
2012-03-03 19:32           ` Thierry Reding
2012-03-06 15:38             ` Arnd Bergmann
2012-03-06 19:17               ` Thierry Reding
2012-02-22 15:17 ` [PATCH v3 03/10] of: Add PWM support Thierry Reding
2012-02-22 16:15   ` Arnd Bergmann
2012-02-23  7:55     ` Thierry Reding
2012-02-23 14:03       ` Arnd Bergmann
2012-02-24  6:47         ` Thierry Reding
2012-02-24 16:58           ` Arnd Bergmann
2012-02-25 12:33             ` Sascha Hauer
2012-02-25 23:08               ` Ryan Mallon
2012-02-22 15:17 ` [PATCH v3 04/10] arm/tegra: Fix PWM clock programming Thierry Reding
2012-02-28 21:01   ` Stephen Warren
2012-03-03 22:47     ` Thierry Reding
2012-03-05 17:33       ` Stephen Warren
2012-02-22 15:17 ` [PATCH v3 05/10] arm/tegra: Provide clock for only one PWM controller Thierry Reding
2012-02-22 15:17 ` [PATCH v3 06/10] pwm: Add NVIDIA Tegra SoC support Thierry Reding
2012-02-23  1:47   ` Ryan Mallon
2012-02-23  8:14     ` Thierry Reding
2012-02-23  9:25       ` Ryan Mallon
2012-02-24  6:48         ` Thierry Reding
2012-02-28 21:14   ` Stephen Warren
2012-03-03 22:42     ` Thierry Reding
2012-03-05  3:39       ` Olof Johansson
2012-03-05  7:00         ` Thierry Reding
2012-02-22 15:17 ` [PATCH v3 07/10] arm/tegra: Add PWFM controller device tree probing Thierry Reding
2012-02-28 21:20   ` Stephen Warren
2012-03-03 22:54     ` Thierry Reding
2012-03-04 20:39       ` Arnd Bergmann
2012-03-05 17:51       ` Stephen Warren
2012-03-05 18:15         ` Thierry Reding
2012-03-05 18:39           ` Stephen Warren
2012-02-22 15:17 ` [PATCH v3 08/10] pwm: Add Blackfin support Thierry Reding
2012-02-22 15:17 ` [PATCH v3 09/10] pwm: Add PXA support Thierry Reding
2012-02-22 15:40   ` Arnd Bergmann
2012-02-23  6:10     ` Thierry Reding
2012-02-22 15:17 ` [PATCH v3 10/10] pwm-backlight: Add rudimentary device tree support Thierry Reding
2012-02-22 16:02 ` [PATCH v3 00/10] Add PWM framework and " Arnd Bergmann
2012-02-23  7:29   ` Thierry Reding

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=201202221634.45159.arnd@arndb.de \
    --to=arnd@arndb$(echo .)de \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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