lkml.org 
[lkml]   [2014]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH v3] reset: Add a defer reset object to send board specific reset
From
On Wed, Jun 18, 2014 at 3:37 PM, Houcheng Lin <houcheng@gmail.com> 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


\
 
 \ /
  Last update: 2014-07-07 15:21    [W:0.096 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site