提交 8ecffd79 编写于 作者: L Linus Torvalds

Merge tag 'gpio-v3.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio

Pull GPIO fixes from Linus Walleij:
 "Here are a few more GPIO patches, we're a bit noisy for being the GPIO
  subsystem, mostly due to the new descriptor API, but all is getting
  into shape.

   - Fix compile warnings

   - Fix overly talkative diagnostic messages from usual use cases wrt
     GPIO descriptors

   - Add a documentation 00-INDEX

   - Use platform GPIOs as fallback when ACPI or device tree is used as
     the primary means to get GPIO lines

   - A bug fix for the MPC8572/MPC8536 fixing erroneous input data"

* tag 'gpio-v3.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
  gpiolib: change a warning to debug message when failing to get gpio
  powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536
  gpiolib: use platform GPIO mappings as fallback
  Documentation: gpiolib: add 00-INDEX file
  gpiolib: fix lookup of platform-mapped GPIOs
  gpiolib: add missing declarations
00-INDEX
- This file
gpio.txt
- Introduction to GPIOs and their kernel interfaces
consumer.txt
- How to obtain and use GPIOs in a driver
driver.txt
- How to write a GPIO driver
board.txt
- How to assign GPIOs to a consumer device and a function
sysfs.txt
- Information about the GPIO sysfs interface
gpio-legacy.txt
- Historical documentation of the deprecated GPIO integer interface
...@@ -70,10 +70,14 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio) ...@@ -70,10 +70,14 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio)
u32 val; u32 val;
struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
u32 out_mask, out_shadow;
val = in_be32(mm->regs + GPIO_DAT) & ~in_be32(mm->regs + GPIO_DIR); out_mask = in_be32(mm->regs + GPIO_DIR);
return (val | mpc8xxx_gc->data) & mpc8xxx_gpio2mask(gpio); val = in_be32(mm->regs + GPIO_DAT) & ~out_mask;
out_shadow = mpc8xxx_gc->data & out_mask;
return (val | out_shadow) & mpc8xxx_gpio2mask(gpio);
} }
static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio) static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio)
......
...@@ -2368,7 +2368,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, ...@@ -2368,7 +2368,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
continue; continue;
} }
if (chip->ngpio >= p->chip_hwnum) { if (chip->ngpio <= p->chip_hwnum) {
dev_warn(dev, "GPIO chip %s has %d GPIOs\n", dev_warn(dev, "GPIO chip %s has %d GPIOs\n",
chip->label, chip->ngpio); chip->label, chip->ngpio);
continue; continue;
...@@ -2418,7 +2418,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, ...@@ -2418,7 +2418,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
const char *con_id, const char *con_id,
unsigned int idx) unsigned int idx)
{ {
struct gpio_desc *desc; struct gpio_desc *desc = NULL;
int status; int status;
enum gpio_lookup_flags flags = 0; enum gpio_lookup_flags flags = 0;
...@@ -2431,13 +2431,23 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, ...@@ -2431,13 +2431,23 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
} else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) { } else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) {
dev_dbg(dev, "using ACPI for GPIO lookup\n"); dev_dbg(dev, "using ACPI for GPIO lookup\n");
desc = acpi_find_gpio(dev, con_id, idx, &flags); desc = acpi_find_gpio(dev, con_id, idx, &flags);
} else { }
/*
* Either we are not using DT or ACPI, or their lookup did not return
* a result. In that case, use platform lookup as a fallback.
*/
if (!desc || IS_ERR(desc)) {
struct gpio_desc *pdesc;
dev_dbg(dev, "using lookup tables for GPIO lookup"); dev_dbg(dev, "using lookup tables for GPIO lookup");
desc = gpiod_find(dev, con_id, idx, &flags); pdesc = gpiod_find(dev, con_id, idx, &flags);
/* If used as fallback, do not replace the previous error */
if (!IS_ERR(pdesc) || !desc)
desc = pdesc;
} }
if (IS_ERR(desc)) { if (IS_ERR(desc)) {
dev_warn(dev, "lookup for GPIO %s failed\n", con_id); dev_dbg(dev, "lookup for GPIO %s failed\n", con_id);
return desc; return desc;
} }
......
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
#define __LINUX_GPIO_DRIVER_H #define __LINUX_GPIO_DRIVER_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/module.h>
struct device; struct device;
struct gpio_desc; struct gpio_desc;
struct of_phandle_args;
struct device_node;
struct seq_file; struct seq_file;
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册