mirror of
https://github.com/torvalds/linux.git
synced 2024-11-16 17:12:06 +00:00
gpio updates for v5.7 part 4
- improve comments in the uapi header - fix documentation issues - add a warning to gpio-pl061 when the IRQ line is not configured - allow building gpio-mxc and gpio-mxs with COMPILE_TEST enabled - don't print an error message when an optional IRQ is missing in gpio-mvebu - fix a potential segfault in gpio-hammer - fix a couple typos and coding style issues in gpio tools - provide a new flag in gpio-mmio and use it in mt7621 to fix an issue with the controller ignoring value setting when a GPIO is in input mode - slightly refactor gpio_name_to_desc() -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAl57HkMACgkQEacuoBRx 13KeZw//a5fPtVNo9eEDWPqZoyuDISrzGLUM6AcOfSpQDdC2EsV9flGxL6Dpzt+h qQTSOVp7RXn10QTonYAN76XhQi7vKAS7wSb1Rb4LSJxkuLeg32U0BXL31Jzg/loX GRJTL4HbI2ba+OIYikkZjQzfYMgrSD2+kXseoo+sV6QZXODjA1asF1KhngdonS9K sWcmiN0m/YZvDIuzoCP97ry0NKYgt2gToER/5ucFeR7W5UoX6zCsTPg/RRwiONzj aorBZbGbBZjneXPKgnfTGZrgYnJPDkWYCbXdm1R3wTRy3pQEIbww8l3d36BzH7wd uGcH08phGjO2D64mnCOESueVNhAxKOVemLjv2mqmvXU+4ZkaJfImAGI7SPj4Vb2j cbjdyue8tLR/G08B0PaWrPU15HgVM7ZhNl2H4E0i3aUm8Oi/GBiV9RjN5dOisky9 DnLdBeiJx+4WqX1aWPpwpXp1LKFT3/I2ds73KzcWq4SGgRT5JkCb0qPe/ZJgbd3D 9B/5bwNvxciaQh2JkeTWaAXozD2Z+IE1JgR3Ij1vl8EzYDsdW5mKirSzE5nkaO1y 7G5uF/+2y70J8d/hTgnW3NiA0D+bcY/kZPGsASJNm/sxy6Xi+pDDMZKgRgNL827v kcDBKmVRu4KkXtPh+muETltk5UweBZ2blybBdg/3aDojKO8jGAw= =/Fgf -----END PGP SIGNATURE----- Merge tag 'gpio-updates-for-v5.7-part4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel gpio updates for v5.7 part 4 - improve comments in the uapi header - fix documentation issues - add a warning to gpio-pl061 when the IRQ line is not configured - allow building gpio-mxc and gpio-mxs with COMPILE_TEST enabled - don't print an error message when an optional IRQ is missing in gpio-mvebu - fix a potential segfault in gpio-hammer - fix a couple typos and coding style issues in gpio tools - provide a new flag in gpio-mmio and use it in mt7621 to fix an issue with the controller ignoring value setting when a GPIO is in input mode - slightly refactor gpio_name_to_desc()
This commit is contained in:
commit
30a464a8df
@ -416,7 +416,7 @@ The preferred way to set up the helpers is to fill in the
|
||||
struct gpio_irq_chip inside struct gpio_chip before adding the gpio_chip.
|
||||
If you do this, the additional irq_chip will be set up by gpiolib at the
|
||||
same time as setting up the rest of the GPIO functionality. The following
|
||||
is a typical example of a cascaded interrupt handler using gpio_irq_chip::
|
||||
is a typical example of a cascaded interrupt handler using gpio_irq_chip:
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
@ -453,7 +453,7 @@ is a typical example of a cascaded interrupt handler using gpio_irq_chip::
|
||||
return devm_gpiochip_add_data(dev, &g->gc, g);
|
||||
|
||||
The helper support using hierarchical interrupt controllers as well.
|
||||
In this case the typical set-up will look like this::
|
||||
In this case the typical set-up will look like this:
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
|
@ -394,13 +394,13 @@ config GPIO_MVEBU
|
||||
|
||||
config GPIO_MXC
|
||||
def_bool y
|
||||
depends on ARCH_MXC
|
||||
depends on ARCH_MXC || COMPILE_TEST
|
||||
select GPIO_GENERIC
|
||||
select GENERIC_IRQ_CHIP
|
||||
|
||||
config GPIO_MXS
|
||||
def_bool y
|
||||
depends on ARCH_MXS
|
||||
depends on ARCH_MXS || COMPILE_TEST
|
||||
select GPIO_GENERIC
|
||||
select GENERIC_IRQ_CHIP
|
||||
|
||||
|
@ -389,12 +389,10 @@ static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
|
||||
return GPIO_LINE_DIRECTION_IN;
|
||||
}
|
||||
|
||||
static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||
static void bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
gc->set(gc, gpio, val);
|
||||
|
||||
spin_lock_irqsave(&gc->bgpio_lock, flags);
|
||||
|
||||
gc->bgpio_dir |= bgpio_line2mask(gc, gpio);
|
||||
@ -405,7 +403,21 @@ static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||
gc->write_reg(gc->reg_dir_out, gc->bgpio_dir);
|
||||
|
||||
spin_unlock_irqrestore(&gc->bgpio_lock, flags);
|
||||
}
|
||||
|
||||
static int bgpio_dir_out_dir_first(struct gpio_chip *gc, unsigned int gpio,
|
||||
int val)
|
||||
{
|
||||
bgpio_dir_out(gc, gpio, val);
|
||||
gc->set(gc, gpio, val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bgpio_dir_out_val_first(struct gpio_chip *gc, unsigned int gpio,
|
||||
int val)
|
||||
{
|
||||
gc->set(gc, gpio, val);
|
||||
bgpio_dir_out(gc, gpio, val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -538,7 +550,10 @@ static int bgpio_setup_direction(struct gpio_chip *gc,
|
||||
if (dirout || dirin) {
|
||||
gc->reg_dir_out = dirout;
|
||||
gc->reg_dir_in = dirin;
|
||||
gc->direction_output = bgpio_dir_out;
|
||||
if (flags & BGPIOF_NO_SET_ON_INPUT)
|
||||
gc->direction_output = bgpio_dir_out_dir_first;
|
||||
else
|
||||
gc->direction_output = bgpio_dir_out_val_first;
|
||||
gc->direction_input = bgpio_dir_in;
|
||||
gc->get_direction = bgpio_get_dir;
|
||||
} else {
|
||||
|
@ -227,8 +227,8 @@ mediatek_gpio_bank_probe(struct device *dev,
|
||||
ctrl = mtk->base + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_STRIDE);
|
||||
diro = mtk->base + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_STRIDE);
|
||||
|
||||
ret = bgpio_init(&rg->chip, dev, 4,
|
||||
dat, set, ctrl, diro, NULL, 0);
|
||||
ret = bgpio_init(&rg->chip, dev, 4, dat, set, ctrl, diro, NULL,
|
||||
BGPIOF_NO_SET_ON_INPUT);
|
||||
if (ret) {
|
||||
dev_err(dev, "bgpio_init() failed\n");
|
||||
return ret;
|
||||
|
@ -1247,7 +1247,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
|
||||
* pins.
|
||||
*/
|
||||
for (i = 0; i < 4; i++) {
|
||||
int irq = platform_get_irq(pdev, i);
|
||||
int irq = platform_get_irq_optional(pdev, i);
|
||||
|
||||
if (irq < 0)
|
||||
continue;
|
||||
|
@ -326,10 +326,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
|
||||
|
||||
writeb(0, pl061->base + GPIOIE); /* disable irqs */
|
||||
irq = adev->irq[0];
|
||||
if (irq < 0) {
|
||||
dev_err(&adev->dev, "invalid IRQ\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
if (!irq)
|
||||
dev_warn(&adev->dev, "IRQ support disabled\n");
|
||||
pl061->parent_irq = irq;
|
||||
|
||||
girq = &pl061->gc.irq;
|
||||
|
@ -301,6 +301,9 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
|
||||
struct gpio_device *gdev;
|
||||
unsigned long flags;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
spin_lock_irqsave(&gpio_lock, flags);
|
||||
|
||||
list_for_each_entry(gdev, &gpio_devices, list) {
|
||||
@ -309,7 +312,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
|
||||
for (i = 0; i != gdev->ngpio; ++i) {
|
||||
struct gpio_desc *desc = &gdev->descs[i];
|
||||
|
||||
if (!desc->name || !name)
|
||||
if (!desc->name)
|
||||
continue;
|
||||
|
||||
if (!strcmp(desc->name, name)) {
|
||||
|
@ -572,6 +572,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,
|
||||
#define BGPIOF_BIG_ENDIAN_BYTE_ORDER BIT(3)
|
||||
#define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */
|
||||
#define BGPIOF_NO_OUTPUT BIT(5) /* only input */
|
||||
#define BGPIOF_NO_SET_ON_INPUT BIT(6)
|
||||
|
||||
int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
|
||||
irq_hw_number_t hwirq);
|
||||
|
@ -18,7 +18,7 @@
|
||||
* struct gpiochip_info - Information about a certain GPIO chip
|
||||
* @name: the Linux kernel name of this GPIO chip
|
||||
* @label: a functional name for this GPIO chip, such as a product
|
||||
* number, may be NULL
|
||||
* number, may be empty
|
||||
* @lines: number of GPIO lines on this chip
|
||||
*/
|
||||
struct gpiochip_info {
|
||||
@ -44,10 +44,10 @@ struct gpiochip_info {
|
||||
* @flags: various flags for this line
|
||||
* @name: the name of this GPIO line, such as the output pin of the line on the
|
||||
* chip, a rail or a pin header name on a board, as specified by the gpio
|
||||
* chip, may be NULL
|
||||
* chip, may be empty
|
||||
* @consumer: a functional name for the consumer of this GPIO line as set by
|
||||
* whatever is using it, will be NULL if there is no current user but may
|
||||
* also be NULL if the consumer doesn't set this up
|
||||
* whatever is using it, will be empty if there is no current user but may
|
||||
* also be empty if the consumer doesn't set this up
|
||||
*/
|
||||
struct gpioline_info {
|
||||
__u32 line_offset;
|
||||
|
@ -77,7 +77,7 @@ int hammer_device(const char *device_name, unsigned int *lines, int nlines,
|
||||
|
||||
fprintf(stdout, "[%c] ", swirr[j]);
|
||||
j++;
|
||||
if (j == sizeof(swirr)-1)
|
||||
if (j == sizeof(swirr) - 1)
|
||||
j = 0;
|
||||
|
||||
fprintf(stdout, "[");
|
||||
@ -135,7 +135,14 @@ int main(int argc, char **argv)
|
||||
device_name = optarg;
|
||||
break;
|
||||
case 'o':
|
||||
lines[i] = strtoul(optarg, NULL, 10);
|
||||
/*
|
||||
* Avoid overflow. Do not immediately error, we want to
|
||||
* be able to accurately report on the amount of times
|
||||
* '-o' was given to give an accurate error message
|
||||
*/
|
||||
if (i < GPIOHANDLES_MAX)
|
||||
lines[i] = strtoul(optarg, NULL, 10);
|
||||
|
||||
i++;
|
||||
break;
|
||||
case '?':
|
||||
@ -143,6 +150,14 @@ int main(int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= GPIOHANDLES_MAX) {
|
||||
fprintf(stderr,
|
||||
"Only %d occurrences of '-o' are allowed, %d were found\n",
|
||||
GPIOHANDLES_MAX, i + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nlines = i;
|
||||
|
||||
if (!device_name || !nlines) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <linux/gpio.h>
|
||||
#include "gpio-utils.h"
|
||||
|
||||
#define COMSUMER "gpio-utils"
|
||||
#define CONSUMER "gpio-utils"
|
||||
|
||||
/**
|
||||
* doc: Operation of gpio
|
||||
@ -209,7 +209,7 @@ int gpiotools_gets(const char *device_name, unsigned int *lines,
|
||||
|
||||
ret = gpiotools_request_linehandle(device_name, lines, nlines,
|
||||
GPIOHANDLE_REQUEST_INPUT, data,
|
||||
COMSUMER);
|
||||
CONSUMER);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@ -259,7 +259,7 @@ int gpiotools_sets(const char *device_name, unsigned int *lines,
|
||||
|
||||
ret = gpiotools_request_linehandle(device_name, lines, nlines,
|
||||
GPIOHANDLE_REQUEST_OUTPUT, data,
|
||||
COMSUMER);
|
||||
CONSUMER);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user