Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 280102
b: refs/heads/master
c: 1a2d397
h: refs/heads/master
v: v3
  • Loading branch information
Grant Likely committed Dec 12, 2011
1 parent 0c12948 commit bde2519
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fe9f68449a507e03d41bee4500456bbfa22095d3
refs/heads/master: 1a2d397a6eb5cf40c382d9e3d4bc04aaeb025336
42 changes: 8 additions & 34 deletions trunk/arch/powerpc/sysdev/qe_lib/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,10 @@ struct qe_pin {
struct qe_pin *qe_pin_request(struct device_node *np, int index)
{
struct qe_pin *qe_pin;
struct device_node *gpio_np;
struct gpio_chip *gc;
struct of_mm_gpio_chip *mm_gc;
struct qe_gpio_chip *qe_gc;
int err;
int size;
const void *gpio_spec;
const u32 *gpio_cells;
unsigned long flags;

qe_pin = kzalloc(sizeof(*qe_pin), GFP_KERNEL);
Expand All @@ -155,45 +151,25 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
return ERR_PTR(-ENOMEM);
}

err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index,
&gpio_np, &gpio_spec);
if (err) {
pr_debug("%s: can't parse gpios property\n", __func__);
err = of_get_gpio(np, index);
if (err < 0)
goto err0;
gc = gpio_to_chip(err);
if (WARN_ON(!gc))
goto err0;
}

if (!of_device_is_compatible(gpio_np, "fsl,mpc8323-qe-pario-bank")) {
if (!of_device_is_compatible(gc->of_node, "fsl,mpc8323-qe-pario-bank")) {
pr_debug("%s: tried to get a non-qe pin\n", __func__);
err = -EINVAL;
goto err1;
}

gc = of_node_to_gpiochip(gpio_np);
if (!gc) {
pr_debug("%s: gpio controller %s isn't registered\n",
np->full_name, gpio_np->full_name);
err = -ENODEV;
goto err1;
}

gpio_cells = of_get_property(gpio_np, "#gpio-cells", &size);
if (!gpio_cells || size != sizeof(*gpio_cells) ||
*gpio_cells != gc->of_gpio_n_cells) {
pr_debug("%s: wrong #gpio-cells for %s\n",
np->full_name, gpio_np->full_name);
err = -EINVAL;
goto err1;
goto err0;
}

err = gc->of_xlate(gc, np, gpio_spec, NULL);
if (err < 0)
goto err1;

mm_gc = to_of_mm_gpio_chip(gc);
qe_gc = to_qe_gpio_chip(mm_gc);

spin_lock_irqsave(&qe_gc->lock, flags);

err -= gc->base;
if (test_and_set_bit(QE_PIN_REQUESTED, &qe_gc->pin_flags[err]) == 0) {
qe_pin->controller = qe_gc;
qe_pin->num = err;
Expand All @@ -206,8 +182,6 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)

if (!err)
return qe_pin;
err1:
of_node_put(gpio_np);
err0:
kfree(qe_pin);
pr_debug("%s failed with status %d\n", __func__, err);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static int gpio_ensure_requested(struct gpio_desc *desc, unsigned offset)
}

/* caller holds gpio_lock *OR* gpio is marked as requested */
static inline struct gpio_chip *gpio_to_chip(unsigned gpio)
struct gpio_chip *gpio_to_chip(unsigned gpio)
{
return gpio_desc[gpio].chip;
}
Expand Down
1 change: 1 addition & 0 deletions trunk/include/asm-generic/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct gpio_chip {

extern const char *gpiochip_is_requested(struct gpio_chip *chip,
unsigned offset);
extern struct gpio_chip *gpio_to_chip(unsigned gpio);
extern int __must_check gpiochip_reserve(int start, int ngpio);

/* add/remove chips */
Expand Down

0 comments on commit bde2519

Please sign in to comment.