Re: [RFC PATCH v3] reset: Add a defer reset object to send board specific reset

From: Linus Walleij
Date: Mon Jul 07 2014 - 08:38:43 EST


On Wed, Jun 18, 2014 at 3:37 PM, Houcheng Lin <houcheng@xxxxxxxxx> wrote:

(...)
> +static DEFINE_MUTEX(deferred_reset_mutex);
> +static LIST_HEAD(deferred_reset_list);
> +
> +struct defer_reset_private {
> + struct list_head lnode;
> + struct device_node *node; /* defer_reset device */

Isn't it better if you get the gpio descriptor(s) in probe() and store that
inside defer_reset_private instead of storing the device_node?

struct gpio_desc *gpiod;

(Then you need not include <linux/of_gpio.h>)

> +};


> +static int gdr_issue_reset_line(
> + struct device_node *of_node, int index, int val)
> +{
> + enum of_gpio_flags flags = 0;
> + struct gpio_desc *gpiod;
> + gpiod = of_get_named_gpiod_flags(of_node, "reset-gpios", index, &flags);
> + if (IS_ERR(gpiod))
> + return -PTR_ERR(gpiod);
> + gdr_issue_reset_gpio(gpiod, val, flags);

So here just use the gpiod from the private struct instead
of looking it up in the last minute.

> +static int gdr_probe(struct platform_device *pdev_gdr)
> +{
> + struct list_head *pos, *n;
> +
> + pr_debug("gpio defer reset probe\n");
> +
> + mutex_lock(&deferred_reset_mutex);
> + list_for_each_safe(pos, n, &deferred_reset_list) {
> + struct defer_reset_private *pdata;
> + struct platform_device *pdev;
> + pdata = list_entry(pos, struct defer_reset_private, lnode);
> + pdev = of_find_device_by_node(pdata->node->parent);

So in this iteration I would get the gpio descriptor for each one using
something like:

pdata->gpiod = gpiod_get_index(&pdev->dev, ...);

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/