Commit b7452d67 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Bartosz Golaszewski

gpiolib: acpi: avoid leaking ACPI details into upper gpiolib layers

There is no need for the generic parts of GPIOLIB to be aware of
implementation details of ACPI-bases lookups.
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 16ba046e
...@@ -89,6 +89,30 @@ struct acpi_gpio_chip { ...@@ -89,6 +89,30 @@ struct acpi_gpio_chip {
struct list_head deferred_req_irqs_list_entry; struct list_head deferred_req_irqs_list_entry;
}; };
/**
* struct acpi_gpio_info - ACPI GPIO specific information
* @adev: reference to ACPI device which consumes GPIO resource
* @flags: GPIO initialization flags
* @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
* @pin_config: pin bias as provided by ACPI
* @polarity: interrupt polarity as provided by ACPI
* @triggering: triggering type as provided by ACPI
* @wake_capable: wake capability as provided by ACPI
* @debounce: debounce timeout as provided by ACPI
* @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
*/
struct acpi_gpio_info {
struct acpi_device *adev;
enum gpiod_flags flags;
bool gpioint;
int pin_config;
int polarity;
int triggering;
bool wake_capable;
unsigned int debounce;
unsigned int quirks;
};
/* /*
* For GPIO chips which call acpi_gpiochip_request_interrupts() before late_init * For GPIO chips which call acpi_gpiochip_request_interrupts() before late_init
* (so builtin drivers) we register the ACPI GpioInt IRQ handlers from a * (so builtin drivers) we register the ACPI GpioInt IRQ handlers from a
...@@ -670,8 +694,8 @@ __acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, enum gpiod_flags update) ...@@ -670,8 +694,8 @@ __acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, enum gpiod_flags update)
return ret; return ret;
} }
int static int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags,
acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *info) struct acpi_gpio_info *info)
{ {
struct device *dev = &info->adev->dev; struct device *dev = &info->adev->dev;
enum gpiod_flags old = *flags; enum gpiod_flags old = *flags;
...@@ -690,7 +714,7 @@ acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *inf ...@@ -690,7 +714,7 @@ acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *inf
return ret; return ret;
} }
int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, static int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
struct acpi_gpio_info *info) struct acpi_gpio_info *info)
{ {
switch (info->pin_config) { switch (info->pin_config) {
...@@ -1005,7 +1029,8 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, ...@@ -1005,7 +1029,8 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
* @fwnode: pointer to an ACPI firmware node to get the GPIO information from * @fwnode: pointer to an ACPI firmware node to get the GPIO information from
* @propname: Property name of the GPIO * @propname: Property name of the GPIO
* @index: index of GpioIo/GpioInt resource (starting from %0) * @index: index of GpioIo/GpioInt resource (starting from %0)
* @info: info pointer to fill in (optional) * @lflags: bitmask of gpio_lookup_flags GPIO_* values
* @dflags: gpiod initialization flags
* *
* If @fwnode is an ACPI device object, call acpi_get_gpiod_by_index() for it. * If @fwnode is an ACPI device object, call acpi_get_gpiod_by_index() for it.
* Otherwise (i.e. it is a data-only non-device object), use the property-based * Otherwise (i.e. it is a data-only non-device object), use the property-based
...@@ -1017,15 +1042,25 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, ...@@ -1017,15 +1042,25 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
*/ */
struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
const char *propname, int index, const char *propname, int index,
struct acpi_gpio_info *info) unsigned long *lflags,
enum gpiod_flags *dflags)
{ {
struct acpi_gpio_info info;
struct acpi_device *adev; struct acpi_device *adev;
struct gpio_desc *desc;
adev = to_acpi_device_node(fwnode); adev = to_acpi_device_node(fwnode);
if (adev) if (adev)
return acpi_get_gpiod_by_index(adev, propname, index, info); desc = acpi_get_gpiod_by_index(adev, propname, index, &info);
else
desc = acpi_get_gpiod_from_data(fwnode, propname, index, &info);
return acpi_get_gpiod_from_data(fwnode, propname, index, info); if (!IS_ERR(desc)) {
acpi_gpio_update_gpiod_flags(dflags, &info);
acpi_gpio_update_gpiod_lookup_flags(lflags, &info);
}
return desc;
} }
/** /**
......
...@@ -10,30 +10,6 @@ ...@@ -10,30 +10,6 @@
struct acpi_device; struct acpi_device;
/**
* struct acpi_gpio_info - ACPI GPIO specific information
* @adev: reference to ACPI device which consumes GPIO resource
* @flags: GPIO initialization flags
* @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
* @pin_config: pin bias as provided by ACPI
* @polarity: interrupt polarity as provided by ACPI
* @triggering: triggering type as provided by ACPI
* @wake_capable: wake capability as provided by ACPI
* @debounce: debounce timeout as provided by ACPI
* @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
*/
struct acpi_gpio_info {
struct acpi_device *adev;
enum gpiod_flags flags;
bool gpioint;
int pin_config;
int polarity;
int triggering;
bool wake_capable;
unsigned int debounce;
unsigned int quirks;
};
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
void acpi_gpiochip_add(struct gpio_chip *chip); void acpi_gpiochip_add(struct gpio_chip *chip);
void acpi_gpiochip_remove(struct gpio_chip *chip); void acpi_gpiochip_remove(struct gpio_chip *chip);
...@@ -43,11 +19,6 @@ void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev); ...@@ -43,11 +19,6 @@ void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags,
struct acpi_gpio_info *info);
int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
struct acpi_gpio_info *info);
struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
const char *con_id, const char *con_id,
unsigned int idx, unsigned int idx,
...@@ -55,7 +26,8 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, ...@@ -55,7 +26,8 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
unsigned long *lookupflags); unsigned long *lookupflags);
struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
const char *propname, int index, const char *propname, int index,
struct acpi_gpio_info *info); unsigned long *lflags,
enum gpiod_flags *dflags);
int acpi_gpio_count(struct device *dev, const char *con_id); int acpi_gpio_count(struct device *dev, const char *con_id);
#else #else
...@@ -70,18 +42,6 @@ acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } ...@@ -70,18 +42,6 @@ acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
static inline void static inline void
acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
static inline int
acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *info)
{
return 0;
}
static inline int
acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
struct acpi_gpio_info *info)
{
return 0;
}
static inline struct gpio_desc * static inline struct gpio_desc *
acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id,
unsigned int idx, enum gpiod_flags *dflags, unsigned int idx, enum gpiod_flags *dflags,
...@@ -91,7 +51,7 @@ acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, ...@@ -91,7 +51,7 @@ acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id,
} }
static inline struct gpio_desc * static inline struct gpio_desc *
acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname, acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname,
int index, struct acpi_gpio_info *info) int index, unsigned long *lflags, enum gpiod_flags *dflags)
{ {
return ERR_PTR(-ENXIO); return ERR_PTR(-ENXIO);
} }
......
...@@ -3890,14 +3890,10 @@ static struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, ...@@ -3890,14 +3890,10 @@ static struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
label); label);
return desc; return desc;
} else if (is_acpi_node(fwnode)) { } else if (is_acpi_node(fwnode)) {
struct acpi_gpio_info info; desc = acpi_node_get_gpiod(fwnode, propname, index,
&lflags, &dflags);
desc = acpi_node_get_gpiod(fwnode, propname, index, &info);
if (IS_ERR(desc)) if (IS_ERR(desc))
return desc; return desc;
acpi_gpio_update_gpiod_flags(&dflags, &info);
acpi_gpio_update_gpiod_lookup_flags(&lflags, &info);
} else { } else {
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment