Commit graph

12 commits

Author SHA1 Message Date
Rob Herring
e91d0f05e6 gpio: Explicitly include correct DT includes
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-07-19 13:24:01 +02:00
Uwe Kleine-König
b41cabb7be gpio: Switch i2c drivers back to use .probe()
After commit b8a1a4cd5a ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-05-23 10:09:11 +02:00
Stephen Kitt
bf08ce132c drivers/gpio: use simple i2c probe
All these drivers have an i2c probe function which doesn't use the
"struct i2c_device_id *id" parameter, so they can trivially be
converted to the "probe_new" style of probe with a single argument.

This is part of an ongoing transition to single-argument i2c probe
functions. Old-style probe functions involve a call to i2c_match_id:
in drivers/i2c/i2c-core-base.c,

         /*
          * When there are no more users of probe(),
          * rename probe_new to probe.
          */
         if (driver->probe_new)
                 status = driver->probe_new(client);
         else if (driver->probe)
                 status = driver->probe(client,
                                        i2c_match_id(driver->id_table, client));
         else
                 status = -EINVAL;

Drivers which don't need the second parameter can be declared using
probe_new instead, avoiding the call to i2c_match_id. Drivers which do
can still be converted to probe_new-style, calling i2c_match_id
themselves (as is done currently for of_match_id).

This change was done using the following Coccinelle script, and fixed
up for whitespace changes:

@ rule1 @
identifier fn;
identifier client, id;
@@

- static int fn(struct i2c_client *client, const struct i2c_device_id *id)
+ static int fn(struct i2c_client *client)
{
...when != id
}

@ rule2 depends on rule1 @
identifier rule1.fn;
identifier driver;
@@

struct i2c_driver driver = {
-       .probe
+       .probe_new
                =
(
                   fn
|
-                  &fn
+                  fn
)
                ,
};

Signed-off-by: Stephen Kitt <steve@sk2.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2022-10-17 10:36:19 +02:00
Linus Torvalds
26803bac2b gpio fixes for v5.18-rc1
- grammar and formatting fixes in comments for gpio-ts4900
 - correct links in gpio-ts5500
 - fix a warning in doc generation for the core GPIO documentation
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmJHBBQACgkQEacuoBRx
 13Ih3A//bkylULu9FUjRS+zFlpbN+BFFNtDTfVKic0wRsJhU+eJb4pbpC6ZokyqT
 NxkIm8qvZHb3RUFB6qPm44UbuELjeU09E4atxUfuiBNyb0t8WAW0YgFAQql7RweX
 mwTQ82+ARQm1qGhsqxKwRn0qFlMEdBLvYVGffVZp3NbOGaAIIKpCu5ZvWg9yC6rW
 ksAE0jmmxY1ak2H0q5D0VPj1aScZhXjaN94GTCYbTRAY0SSZMxbkuG3Mo6vLO8go
 u3jsZ7hGaGvadNcpmtmA0sqWLXVq7qCi6CdmUM6iTnIsPMHwUi9I722VKQzE2yS/
 bp8v7YOUhEAT+324QzLxTDZjZWSJnFf9tJ24pjUl0V9M6+31iSnf3uNWijfCJgG5
 SHdJeZUx6vqqyN2JObHng5zdYS38TksywmkijrVas/C7IHl9sRZLJPM5Qg9bKuGO
 PwOr0zuOlTxhi3R91dvOECZsan159gnnpnZFinYrqsIrOOt9VRkdv97en+4nV2p0
 vgnwLRBDanMF7y7/8yyZzDGip+qI+3L3j/6x6WvFhPWaXqda3Xoh6rSj0JHM0BOi
 x1qvzI/wokOZN6aBrbJoFfDcbL6nU+QWLBxlB2/prMMVh7KD7yDyE3wvQVZGx/xt
 zPQJksXIFLebtVQ1TGfClgsqYoPfk/E3epouOfdaryXb1tPiD0A=
 =9+Rg
 -----END PGP SIGNATURE-----

Merge tag 'gpio-fixes-for-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

 - grammar and formatting fixes in comments for gpio-ts4900

 - correct links in gpio-ts5500

 - fix a warning in doc generation for the core GPIO documentation

* tag 'gpio-fixes-for-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpio: ts5500: Fix Links to Technologic Systems web resources
  gpio: Properly document parent data union
  gpio: ts4900: Fix comment formatting and grammar
2022-04-01 10:26:09 -07:00
Kris Bahnsen
576892a84f gpio: ts4900: Fix comment formatting and grammar
The issues were pointed out after the prior commit was applied.

Signed-off-by: Kris Bahnsen <kris@embeddedTS.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2022-03-31 16:24:03 +02:00
Linus Torvalds
ebcb577aee gpio updates for v5.18-rc1
- new driver: gpio-en7523
 - dt-bindings: convertion of faraday,ftgpio010 to YAML, new compatible string
   in gpio-vf610 and a bugfix in an example
 - gpiolib core: several improvements and some code shrink
 - documentation: convert all public docs into kerneldoc format
 - set IRQ bus token in gpio-crystalcove (addresses a debugfs issue)
 - add a missing return value check for kstrdup() in gpio-merrifield
 - allow gpio-tps68470 to be built as module
 - more work on limiting usage of of_node in GPIO drivers
 - several sysfs interface improvements
 - use SDPX in gpio-ts4900
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmI7SAwACgkQEacuoBRx
 13JJEA/+MdTAmPHyCp55POmKmxMIafejc2EXaZKYK82WhuqOBWyc4UHMzGGD/7YF
 TXKidJ8Bnzki2XiAJlHuyRLrBR67qUs79UkCKQPoEsaBJ4AeQj48bR8YHb+1x+gS
 2LS7IqW4sFB5O61ZCB1Bg8k8Ots9E5OI4Q9+gGxyLVbCK0L8mN8U63a/Fhv4sIJU
 z5WBXVTOsIMrprN2N9/VxNnSUkRqaUcl78ko0yV9B6vi957pojkFApg3rdJmWqV6
 RLGdrQIklY95SdlnTHuG8+7Jy0Ut/ohwdUFDpyd/Hv/qvzE/vRWdvsccSS8KHwtL
 dK+8sGN67QWfLmUhjqd0Y+Q/f/IIZyGHTkHWUojPE9cW6HJudgXQlCkcbjdV+tdB
 2DO67wal6UKIw6efScLeBB7N/x9p8UioxVwHQiy05GBZJYTI184NWoel5hKqUbnh
 GZVBf30fVQxmsJoHJa7e+xPLcHOrrTU+80CR9NhZBBm6xNLbkl1MidbJWfuEgNC1
 6+o6jhy5K+SS09NKQteJFNQtc7f2Mt3Rc1NQzxJc2AaQXFvqbQLC36qkk5oqeDKH
 Ndw4AYuxXWBU62sHZCJkWtG2CIAykvBNRoje3rXukbcv583jx18WScWJx/FKS9hh
 k//1hdlesCV1ouo4qDvCiEC5hby0+FQ/HWgkXGIlNC/gZ6fcrZs=
 =0SYv
 -----END PGP SIGNATURE-----

Merge tag 'gpio-updates-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:
 "Relatively few updates for this release cycle. We have a single new
  driver and some minor changes in drivers, more work on limiting the
  usage of of_node in drivers and DT updates:

   - new driver: gpio-en7523

   - dt-bindings: convertion of faraday,ftgpio010 to YAML, new
     compatible string in gpio-vf610 and a bugfix in an example

   - gpiolib core: several improvements and some code shrink

   - documentation: convert all public docs into kerneldoc format

   - set IRQ bus token in gpio-crystalcove (addresses a debugfs issue)

   - add a missing return value check for kstrdup() in gpio-merrifield

   - allow gpio-tps68470 to be built as module

   - more work on limiting usage of of_node in GPIO drivers

   - several sysfs interface improvements

   - use SDPX in gpio-ts4900"

* tag 'gpio-updates-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpio: ts4900: Use SPDX header
  gpiolib: Use list_first_entry()/list_last_entry()
  gpiolib: sysfs: Simplify edge handling in the code
  gpiolib: sysfs: Move kstrtox() calls outside of the mutex lock
  gpiolib: sysfs: Move sysfs_emit() calls outside of the mutex lock
  gpiolib: make struct comments into real kernel docs
  dt-bindings: gpio: convert faraday,ftgpio01 to yaml
  dt-bindings: gpio: gpio-vf610: Add imx93 compatible string
  gpiolib: Simplify error path in gpiod_get_index() when requesting GPIO
  gpiolib: Use short form of ternary operator in gpiod_get_index()
  gpiolib: Introduce for_each_gpio_desc_with_flag() macro
  gpio: Add support for Airoha EN7523 GPIO controller
  dt-bindings: arm: airoha: Add binding for Airoha GPIO controller
  dt-bindings: gpio: fix gpio-hog example
  gpio: tps68470: Allow building as module
  gpio: tegra: Get rid of duplicate of_node assignment
  gpio: altera-a10sr: Switch to use fwnode instead of of_node
  gpio: merrifield: check the return value of devm_kstrdup()
  gpio: crystalcove: Set IRQ domain bus token to DOMAIN_BUS_WIRED
2022-03-25 12:28:23 -07:00
Kris Bahnsen
87ba5badc5 gpio: ts4900: Use SPDX header
Remove boilerplate, use the SPDX license identifier.

Signed-off-by: Kris Bahnsen <kris@embeddedTS.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2022-03-10 10:05:39 +01:00
Mark Featherston
03fe003547 gpio: ts4900: Do not set DAT and OE together
This works around an issue with the hardware where both OE and
DAT are exposed in the same register. If both are updated
simultaneously, the harware makes no guarantees that OE or DAT
will actually change in any given order and may result in a
glitch of a few ns on a GPIO pin when changing direction and value
in a single write.

Setting direction to input now only affects OE bit. Setting
direction to output updates DAT first, then OE.

Fixes: 9c6686322d ("gpio: add Technologic I2C-FPGA gpio support")
Signed-off-by: Mark Featherston <mark@embeddedTS.com>
Signed-off-by: Kris Bahnsen <kris@embeddedTS.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2022-03-10 10:00:27 +01:00
Matti Vaittinen
e42615ec23 gpio: Use new GPIO_LINE_DIRECTION
It's hard for occasional GPIO code reader/writer to know if values 0/1
equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
GPIO_LINE_DIRECTION_OUT to help them out.

NOTE - for gpio-amd-fch and gpio-bd9571mwv:
This commit also changes the return value for direction get to equal 1
for direction INPUT. Prior this commit these drivers might have
returned some other positive value but 1 for INPUT.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Acked-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2019-11-07 09:27:48 +01:00
Thierry Reding
81317c5a08 gpio: ts4900: Use of_device_get_match_data()
Use of_device_get_match_data() instead of open-coding it.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-05-16 14:35:24 +02:00
Julia Lawall
e35b5ab0a7 gpio: constify gpio_chip structures
These structures are only used to copy into other structures, so declare
them as const.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct gpio_chip i@p = { ... };

@ok@
identifier r.i;
expression e;
position p;
@@
e = i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct gpio_chip e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct gpio_chip i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-09-13 10:35:56 +02:00
Lucile Quirion
9c6686322d gpio: add Technologic I2C-FPGA gpio support
This driver is generic and aims to support all Technologic Systems's
boards embedding FPGA GPIOs with an I2C interface.

This driver supports TS-4900, TS-7970, TS-7990 and TS-4100 series.

Signed-off-by: Lucile Quirion <lucile.quirion@savoirfairelinux.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-08-19 11:04:53 +02:00