MIPS: TXX9: Legacy GPIO interfaces cleanup
cover MIPS: TXX9: Legacy GPIO interfaces cleanup
Hi all,
This patch series gets rid of legacy GPIO interface usage on the MIPS RBTX4927 development board, preceded and followed by some cleanups. No blinky LEDs were harmed during the production of this series.
Thanks for your comments!
Geert Uytterhoeven (9):
MIPS: TXX9: Remove tx4938_spi_init() and txx9_spi_init()
MIPS: TXX9: Remove txx9_7segled_*() forward declarations
MIPS: TXX9: rbtx4927: Use GPIO lookup table for SIO DTR
MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
MIPS: TXX9: Reduce TXX9_IOCLED_MAXLEDS to 3
MIPS: TXX9: Use GPIO lookup table for iocled LEDs
MIPS: TXX9: Drop GPIOLIB_LEGACY select
MIPS: TXX9: Convert gpio_txx9 to dynamic GPIO base allocation
MIPS: TXX9: Clean up txx9_iocled_init()
arch/mips/include/asm/txx9/generic.h | 9 +----- arch/mips/include/asm/txx9/tx4938.h | 1 - arch/mips/include/asm/txx9pio.h | 3 +- arch/mips/kernel/gpio_txx9.c | 5 ++- arch/mips/txx9/Kconfig | 1 - arch/mips/txx9/generic/setup.c | 45 ++++++++++----------------- arch/mips/txx9/generic/setup_tx4938.c | 6 ---- arch/mips/txx9/rbtx4927/setup.c | 36 ++++++++++++++++----- 8 files changed, 49 insertions(+), 57 deletions(-)
Signature · 12 lines
2.43.0
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsPATCH 1/9 MIPS: TXX9: Remove tx4938_spi_init() and txx9_spi_init()
The last user of tx4938_spi_init() was removed in commit 21d638ef9483d8cf ("MIPS: TXX9: Remove rbtx4938 board support").
--- arch/mips/include/asm/txx9/generic.h | 1 - arch/mips/include/asm/txx9/tx4938.h | 1 - arch/mips/txx9/generic/setup.c | 17 ----------------- arch/mips/txx9/generic/setup_tx4938.c | 6 ------ 4 files changed, 25 deletions(-)
arch/mips/include/asm/txx9/generic.h +0 -1
@@ -45,7 +45,6 @@ extern int (*txx9_irq_dispatch)(int pending);const char *prom_getenv (const char *name);void txx9_wdt_init (unsigned long base);void txx9_wdt_now (unsigned long base); -void txx9_spi_init (int busid,unsigned long base,int irq);void txx9_ethaddr_init (unsigned int id,unsigned char *ethaddr);void txx9_sio_init (unsigned long baseaddr,int irq,unsigned int line,unsigned int sclk,int nocts);
arch/mips/include/asm/txx9/tx4938.h +0 -1
@@ -281,7 +281,6 @@ void tx4938_wdt_init(void);void tx4938_setup (void );void tx4938_time_init (unsigned int tmrnr);void tx4938_sio_init (unsigned int sclk,unsigned int cts_mask); -void tx4938_spi_init (int busid);void tx4938_ethaddr_init (unsigned char *addr0,unsigned char *addr1);int tx4938_report_pciclk (void );void tx4938_report_pci1clk (void );
arch/mips/txx9/generic/setup.c +0 -17
@@ -341,23 +341,6 @@ void txx9_wdt_now(unsigned long base) &tmrptr->tcr); } -/* SPI support */ -void __init txx9_spi_init (int busid,unsigned long base,int irq) -{ -struct resource res[] = { - { - .start = base, - .end = base +0x20 -1 , - .flags =IORESOURCE_MEM , - }, { - .start = irq, - .flags =IORESOURCE_IRQ , - }, - }; -platform_device_register_simple ("spi_txx9" , busid, - res,ARRAY_SIZE (res)); -} -void __init txx9_ethaddr_init (unsigned int id,unsigned char *ethaddr) { struct platform_device *pdev =
arch/mips/txx9/generic/setup_tx4938.c +0 -6
@@ -301,12 +301,6 @@ void __init tx4938_sio_init(unsigned int sclk, unsigned int cts_mask) } } -void __init tx4938_spi_init (int busid) -{ -txx9_spi_init (busid,TX4938_SPI_REG &0xfffffffffULL , -TXX9_IRQ_BASE +TX4938_IR_SPI ); -} -void __init tx4938_ethaddr_init (unsigned char *addr0,unsigned char *addr1) {u64 pcfg =__raw_readq (&tx4938_ccfgptr->pcfg);
Signature · 1 line
2.43.0
Re: [PATCH 1/9] MIPS: TXX9: Remove tx4938_spi_init() and txx9_spi_init()
Quoted 10 lines · Geert Uytterhoeven
The last user of
tx4938_spi_init()was removed in commit21d638ef9483d8cf("MIPS: TXX9: Remove rbtx4938 board support").Signed-off-by Geert Uytterhoeven <[email protected]>--- arch/mips/include/asm/txx9/generic.h | 1 - arch/mips/include/asm/txx9/tx4938.h | 1 - arch/mips/txx9/generic/setup.c | 17 ----------------- arch/mips/txx9/generic/setup_tx4938.c | 6 ------ 4 files changed, 25 deletions(-)
PATCH 2/9 MIPS: TXX9: Remove txx9_7segled_*() forward declarations
In reply to Geert UytterhoevenThe actual implementation was removed in commit 5a8df9281b052ff3 ("MIPS:
TXX9: Remove rbtx4939 board support").
--- arch/mips/include/asm/txx9/generic.h | 5 ----- 1 file changed, 5 deletions(-)
arch/mips/include/asm/txx9/generic.h +0 -5
@@ -83,11 +83,6 @@ void txx9_iocled_init(unsigned long baseaddr, int basenum, unsigned int num, int lowactive, const char *color, char **deftriggers); -/* 7SEG LED */ -void txx9_7segled_init (unsigned int num, -void (*putc)(unsigned int pos,unsigned char val)); -int txx9_7segled_putc (unsigned int pos,char c); - void __init txx9_aclc_init(unsigned long baseaddr, int irq, unsigned int dmac_id, unsigned int dma_chan_out,
Signature · 1 line
2.43.0
Re: [PATCH 2/9] MIPS: TXX9: Remove txx9_7segled_*() forward declarations
Quoted 7 lines · Geert Uytterhoeven
The actual implementation was removed in commit
5a8df9281b052ff3("MIPS:
TXX9: Remove rbtx4939 board support").Signed-off-by Geert Uytterhoeven <[email protected]>--- arch/mips/include/asm/txx9/generic.h | 5 ----- 1 file changed, 5 deletions(-)
PATCH 3/9 MIPS: TXX9: rbtx4927: Use GPIO lookup table for SIO DTR
In reply to Geert UytterhoevenConvert SIO DTR handling from legacy GPIO calls to GPIO descriptors using a GPIO lookup table.
--- arch/mips/txx9/rbtx4927/setup.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
arch/mips/txx9/rbtx4927/setup.c +13 -3
@@ -49,6 +49,7 @@#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/gpio.h> +#include <linux/gpio/machine.h> #include <linux/leds.h> #include <asm/io.h> #include <asm/reboot.h>
@@ -157,11 +158,20 @@ static inline void tx4927_pci_setup(void) {}static inline void tx4937_pci_setup (void ) {}#endif /* CONFIG_PCI */ +/* TX4927-SIO DTR on (PIO[15]) */ +GPIO_LOOKUP_SINGLE (sio_gpio_table,NULL ,"TXx9" ,15 ,"sio-dtr" , +GPIO_ACTIVE_HIGH ); +static void __init rbtx4927_gpio_init (void ) { -/* TX4927-SIO DTR on (PIO[15]) */ -gpio_request (15 ,"sio-dtr" ); -gpio_direction_output (15 ,1 ); +struct gpio_desc *d; + +gpiod_add_lookup_table (&sio_gpio_table); + d =gpiod_get (NULL ,"sio-dtr" ,GPIOD_OUT_HIGH ); +if (IS_ERR (d)) +pr_err ("Unable to get sio-dtr GPIO descriptor\n" ); +else +gpiod_put (d);tx4927_sio_init (0 ,0 ); }
Signature · 1 line
2.43.0
PATCH 4/9 MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
In reply to Geert UytterhoevenConvert TXx9 LED description from legacy GPIO numbers to GPIO descriptors using a GPIO lookup table.
--- arch/mips/txx9/rbtx4927/setup.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/mips/txx9/rbtx4927/setup.c +12 -2
@@ -327,11 +327,19 @@ static void __init rbtx4927_mtd_init(void)tx4927_mtd_init (i); } +static struct gpiod_lookup_table rbtx4927_gpioled_table = { + .table = { +GPIO_LOOKUP_IDX ("TXx9" ,0 ,NULL ,0 ,GPIO_ACTIVE_LOW ), +GPIO_LOOKUP_IDX ("TXx9" ,1 ,NULL ,1 ,GPIO_ACTIVE_LOW ), + { }, + }, +}; +static void __init rbtx4927_gpioled_init (void ) {static const struct gpio_led leds[] = { - { .name ="gpioled:green:0" , .gpio =0 , .active_low =1 , }, - { .name ="gpioled:green:1" , .gpio =1 , .active_low =1 , }, + { .name ="gpioled:green:0" , }, + { .name ="gpioled:green:1" , }, };static struct gpio_led_platform_data pdata = { .num_leds =ARRAY_SIZE (leds),
@@ -344,6 +352,8 @@ static void __init rbtx4927_gpioled_init(void) pdev->dev.platform_data = &pdata;if (platform_device_add (pdev))platform_device_put (pdev); + rbtx4927_gpioled_table.dev_id =dev_name (&pdev->dev); +gpiod_add_lookup_table (&rbtx4927_gpioled_table); }static void __init rbtx4927_device_init (void )
Signature · 1 line
2.43.0
Re: [PATCH 4/9] MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
Hi,
I came across the Sashiko AI review of this series and reproduced the use-after-free that it flagged in rbtx4927_gpioled_init() — a KASAN slab-use-after-free triggers when platform_device_add() fails on the error path.
The Sashiko review is at:
https://sashiko.dev/#/patchset/[email protected]
In rbtx4927_gpioled_init() (arch/mips/txx9/rbtx4927/setup.c), this patch introduces a GPIO lookup table that references the platform device name. The error path looks like:
```c
pdev = platform_device_alloc("leds-gpio", 0);
if (!pdev)
return;
pdev->dev.platform_data = &pdata;
if (platform_device_add(pdev))
platform_device_put(pdev); // frees pdev on error!
rbtx4927_gpioled_table.dev_id = dev_name(&pdev->dev); // UAF!
```If platform_device_add() fails (e.g., because a device with the same name already exists in the platform bus), platform_device_put() drops the last reference and frees the struct platform_device. The code then unconditionally calls dev_name(&pdev->dev) on the freed pointer, and assigns the dangling pointer into the global GPIO lookup table.
This is a classic use-after-free: the freed memory can be reallocated and overwritten, and the GPIO lookup table will later dereference a dangling or corrupted dev_id pointer.
For comparison, the iocled equivalent introduced in patch 6 handles this correctly with a goto:
```c if (platform_device_add(pdev)) goto out_pdev; // skips dev_name() txx9_iocled_table.dev_id = dev_name(&pdev->dev); ... out_pdev: platform_device_put(pdev); ```
=== Reproduction ===
Kernel: 7.1.0-next-20260623-gaca8efd71d03-dirty #3 PREEMPT(full) Arch: x86_64 (QEMU Standard PC Q35 + ICH9, 2009)
Config: CONFIG_KASAN=y
The UAF pattern is reproduced via a kernel module that mirrors the same platform_device_add / dev_name error path sequence. The module loads at boot via late_initcall.
=== Crash Log ===
[ 18.070459][ T1] BUG: KASAN: slab-use-after-free in poc_uaf_init+0x25b/0x270
[ 18.071324][ T1] Read of size 8 at addr ffff8880300f5060 by task swapper/0/1
[ 18.072437][ T1] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.1.0-next-20260623-gaca8efd71d03-dirty #3 [ 18.072448][ T1] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009)
[ 18.072452][ T1] Call Trace:
[ 18.072455][ T1] <TASK>
[ 18.072458][ T1] dump_stack_lvl+0x116/0x1f0
[ 18.072466][ T1] print_report+0xf4/0x600
[ 18.072497][ T1] kasan_report+0xe0/0x110
[ 18.072509][ T1] ? poc_uaf_init+0x25b/0x270
[ 18.072519][ T1] poc_uaf_init+0x25b/0x270
[ 18.072528][ T1] do_one_initcall+0x128/0x700
[ 18.072558][ T1] kernel_init_freeable+0x5d2/0x940
[ 18.072573][ T1] kernel_init+0x21/0x2c0
[ 18.072596][ T1] ret_from_fork+0xb2c/0xdd0
[ 18.072648][ T1] </TASK>
[ 18.087231][ T1] Allocated by task 1:
[ 18.088000][ T1] kasan_save_stack+0x33/0x60
[ 18.089000][ T1] __kasan_kmalloc+0xaa/0xb0
[ 18.090000][ T1] platform_device_alloc+0x3a/0x110
[ 18.091000][ T1] poc_uaf_init+0x1a0/0x270
[ 18.092000][ T1] Freed by task 1:
[ 18.093000][ T1] kfree+0x171/0x720
[ 18.094000][ T1] platform_device_put+0x2f/0x40
[ 18.095000][ T1] poc_uaf_init+0x240/0x270
The KASAN report confirms: platform_device_alloc() allocates, then platform_device_put() frees, and the subsequent dev_name() read triggers the slab-use-after-free.
=== PoC ===
The trigger is a minimal kernel module that replicates the buggy error-path pattern. It:
1. Calls platform_device_alloc("poc-uaf", 0)
2. Calls platform_device_add() — which fails with -EEXIST because a previous load already registered "poc-uaf.0"
3. Calls platform_device_put() — frees the device
4. Reads dev_name(&pdev->dev) — UAF on freed pdev
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/init.h>
static int __init poc_uaf_init(void)
{
struct platform_device *pdev;
int ret;
pdev = platform_device_alloc("poc-uaf", 0);
if (!pdev)
return -ENOMEM;
ret = platform_device_add(pdev);
if (ret)
platform_device_put(pdev);
/* UAF: pdev freed by platform_device_put() above,
* but dev_name() dereferences the freed memory. */
pr_info("poc-uaf: dev_name=%s\n", dev_name(&pdev->dev));
return 0;
}module_init(poc_uaf_init);MODULE_LICENSE("GPL");
Build: insert into kernel tree and build with CONFIG_POC_UAF=m Run: insmod poc_uaf.ko (twice, so the second load hits -EEXIST)
Thanks,
Xiao
Re: [PATCH 4/9] MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
Hi Xiao,
Quoted 28 lines · XIAO WU
I came across the Sashiko AI review of this series and reproduced the use-after-free that it flagged in
rbtx4927_gpioled_init()— a KASAN slab-use-after-free triggers whenplatform_device_add()fails on the error path.The Sashiko review is at:
https://sashiko.dev/#/patchset/[email protected]In
rbtx4927_gpioled_init()(arch/mips/txx9/rbtx4927/setup.c), this patch introduces a GPIO lookup table that references the platform device name. The error path looks like:```c pdev = platform_device_alloc("leds-gpio", 0); if (!pdev) return; pdev->dev.platform_data = &pdata; if (platform_device_add(pdev)) platform_device_put(pdev); // frees pdev on error! rbtx4927_gpioled_table.dev_id = dev_name(&pdev->dev); // UAF! ```If
platform_device_add()fails (e.g., because a device with the same name already exists in the platform bus),platform_device_put()drops the last reference and frees the structplatform_device. The code then unconditionally callsdev_name(&pdev->dev)on the freed pointer, and assigns the dangling pointer into the global GPIO lookup table.
Quoted 3 lines
This is a classic use-after-free: the freed memory can be reallocated and overwritten, and the GPIO lookup table will later dereference a dangling or corrupted
dev_idpointer.
Thanks, I will fix that in v2.
Quoted 22 lines
For comparison, the iocled equivalent introduced in patch 6 handles this correctly with a goto:
```c if (platform_device_add(pdev)) goto out_pdev; // skips dev_name() txx9_iocled_table.dev_id = dev_name(&pdev->dev); ... out_pdev: platform_device_put(pdev); ```=== Reproduction ===
Kernel: 7.1.0-next-20260623-gaca8efd71d03-dirty #3 PREEMPT(full) Arch: x86_64 (QEMU Standard PC Q35 + ICH9, 2009) Config: CONFIG_KASAN=yThe UAF pattern is reproduced via a kernel module that mirrors the same
platform_device_add/dev_nameerror path sequence. The module loads at boot vialate_initcall.
[...]
Quoted 2 lines
Build: insert into kernel tree and build with CONFIG_POC_UAF=m Run: insmod poc_uaf.ko (twice, so the second load hits -EEXIST)
Thanks for verifying! But TBH, I think writing a PoC for this is a bit over the top...
And if the platform_device_add() in rbtx4927_gpioled_init() would ever fail, that would be due to out-of-memory, and the system would be dead anyway.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 5/9 MIPS: TXX9: Reduce TXX9_IOCLED_MAXLEDS to 3
In reply to Geert UytterhoevenThe number of available GPIOs and LEDs on the TXx9 IOC FPGA depends on the platform. Since commit 455481fc9a807798 ("MIPS: Remove TX39XX support"), the only remaining platform (rbtx4927) supports just three. Hence reduce the maximum number, to reduce allocation size.
--- arch/mips/txx9/generic/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/txx9/generic/setup.c +1 -1
@@ -569,7 +569,7 @@ void __init txx9_ndfmc_init(unsigned long baseaddr, #if IS_ENABLED(CONFIG_LEDS_GPIO) static DEFINE_SPINLOCK(txx9_iocled_lock); -#define TXX9_IOCLED_MAXLEDS 8 +#define TXX9_IOCLED_MAXLEDS 3 /* rbtx4927 */ struct txx9_iocled_data { struct gpio_chip chip;
Signature · 1 line
2.43.0
Re: [PATCH 5/9] MIPS: TXX9: Reduce TXX9_IOCLED_MAXLEDS to 3
Quoted 9 lines · Geert Uytterhoeven
The number of available GPIOs and LEDs on the TXx9 IOC FPGA depends on the platform. Since commit
455481fc9a807798("MIPS: Remove TX39XX support"), the only remaining platform (rbtx4927) supports just three. Hence reduce the maximum number, to reduce allocation size.Signed-off-by Geert Uytterhoeven <[email protected]>--- arch/mips/txx9/generic/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 6/9 MIPS: TXX9: Use GPIO lookup table for iocled LEDs
In reply to Geert UytterhoevenConvert iocled LED description from legacy GPIO numbers to GPIO descriptors using a GPIO lookup table.
For now, just ignore the "lowactive" parameter, and force GPIO_ACTIVE_LOW, as that is what the sole caller wants.
--- arch/mips/txx9/generic/setup.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/mips/txx9/generic/setup.c +12 -2
@@ -19,6 +19,7 @@#include <linux/clkdev.h> #include <linux/err.h> #include <linux/gpio/driver.h> +#include <linux/gpio/machine.h> #include <linux/platform_device.h> #include <linux/platform_data/txx9/ndfmc.h> #include <linux/serial_core.h>
@@ -615,6 +616,15 @@ static int txx9_iocled_dir_out(struct gpio_chip *chip, unsigned int offset,return 0 ; } +static struct gpiod_lookup_table txx9_iocled_table = { + .table = { +GPIO_LOOKUP_IDX ("iocled" ,0 ,NULL ,0 ,GPIO_ACTIVE_LOW ), +GPIO_LOOKUP_IDX ("iocled" ,1 ,NULL ,1 ,GPIO_ACTIVE_LOW ), +GPIO_LOOKUP_IDX ("iocled" ,2 ,NULL ,2 ,GPIO_ACTIVE_LOW ), + { }, + }, +}; +void __init txx9_iocled_init (unsigned long baseaddr,int basenum,unsigned int num,int lowactive,const char *color,char **deftriggers)
@@ -659,14 +669,14 @@ void __init txx9_iocled_init(unsigned long baseaddr,snprintf (iocled->names[i],sizeof (iocled->names[i]),"iocled:%s:%u" , color, i); led->name = iocled->names[i]; - led->gpio = basenum + i; - led->active_low = lowactive;if (deftriggers && *deftriggers) led->default_trigger = *deftriggers++; } pdev->dev.platform_data = &iocled->pdata;if (platform_device_add (pdev)) goto out_pdev; + txx9_iocled_table.dev_id =dev_name (&pdev->dev); +gpiod_add_lookup_table (&txx9_iocled_table);return ; out_pdev:
Signature · 1 line
2.43.0
PATCH 7/9 MIPS: TXX9: Drop GPIOLIB_LEGACY select
In reply to Geert UytterhoevenTXx has been converted away from the old-style gpiolib interfaces.
--- arch/mips/txx9/Kconfig | 1 - 1 file changed, 1 deletion(-)
arch/mips/txx9/Kconfig +0 -1
@@ -37,7 +37,6 @@ config SOC_TX4927 select IRQ_TXX9 select PCI_TX4927 select GPIO_TXX9 - select GPIOLIB_LEGACY config SOC_TX4938 bool
Signature · 1 line
2.43.0
PATCH 8/9 MIPS: TXX9: Convert gpio_txx9 to dynamic GPIO base allocation
In reply to Geert UytterhoevenStatic allocation of GPIO base is deprecated, use dynamic allocation.
--- arch/mips/include/asm/txx9pio.h | 3 +-- arch/mips/kernel/gpio_txx9.c | 5 ++--- arch/mips/txx9/rbtx4927/setup.c | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-)
arch/mips/include/asm/txx9pio.h +1 -2
@@ -23,7 +23,6 @@ struct txx9_pio_reg { __u32 maskext; }; -int txx9_gpio_init (unsigned long baseaddr, -unsigned int base,unsigned int num); +int txx9_gpio_init (unsigned long baseaddr,unsigned int num);#endif /* __ASM_TXX9PIO_H */
arch/mips/kernel/gpio_txx9.c +2 -3
@@ -76,13 +76,12 @@ static struct gpio_chip txx9_gpio_chip = { .label = "TXx9", }; -int __init txx9_gpio_init (unsigned long baseaddr, -unsigned int base,unsigned int num) +int __init txx9_gpio_init (unsigned long baseaddr,unsigned int num) { txx9_pioptr =ioremap (baseaddr,sizeof (struct txx9_pio_reg ));if (!txx9_pioptr)return -ENODEV ; - txx9_gpio_chip.base = base; + txx9_gpio_chip.base =-1 ; txx9_gpio_chip.ngpio = num;return gpiochip_add_data (&txx9_gpio_chip,NULL ); }
arch/mips/txx9/rbtx4927/setup.c +2 -2
@@ -178,7 +178,7 @@ static void __init rbtx4927_gpio_init(void)static void __init rbtx4927_arch_init (void ) { -txx9_gpio_init (TX4927_PIO_REG &0xfffffffffULL ,0 ,TX4927_NUM_PIO ); +txx9_gpio_init (TX4927_PIO_REG &0xfffffffffULL ,TX4927_NUM_PIO );rbtx4927_gpio_init ();
@@ -187,7 +187,7 @@ static void __init rbtx4927_arch_init(void)static void __init rbtx4937_arch_init (void ) { -txx9_gpio_init (TX4938_PIO_REG &0xfffffffffULL ,0 ,TX4938_NUM_PIO ); +txx9_gpio_init (TX4938_PIO_REG &0xfffffffffULL ,TX4938_NUM_PIO );rbtx4927_gpio_init ();
Signature · 1 line
2.43.0
PATCH 9/9 MIPS: TXX9: Clean up txx9_iocled_init()
In reply to Geert UytterhoevenThe sole caller already uses dynamic GPIO base allocation, so drop support for static allocation.
While at it, drop the no longer used "lowactive" parameter.
--- arch/mips/include/asm/txx9/generic.h | 3 +-- arch/mips/txx9/generic/setup.c | 12 ++++-------- arch/mips/txx9/rbtx4927/setup.c | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-)
arch/mips/include/asm/txx9/generic.h +1 -2
@@ -79,8 +79,7 @@ static inline unsigned int __fls8(unsigned char x)return r; } -void txx9_iocled_init (unsigned long baseaddr, -int basenum,unsigned int num,int lowactive, +void txx9_iocled_init (unsigned long baseaddr,unsigned int num,const char *color,char **deftriggers); void __init txx9_aclc_init(unsigned long baseaddr, int irq,
arch/mips/txx9/generic/setup.c +4 -8
@@ -625,8 +625,7 @@ static struct gpiod_lookup_table txx9_iocled_table = { }, }; -void __init txx9_iocled_init (unsigned long baseaddr, -int basenum,unsigned int num,int lowactive, +void __init txx9_iocled_init (unsigned long baseaddr,unsigned int num,const char *color,char **deftriggers) {struct txx9_iocled_data *iocled;
@@ -652,14 +651,12 @@ void __init txx9_iocled_init(unsigned long baseaddr, iocled->chip.direction_input = txx9_iocled_dir_in; iocled->chip.direction_output = txx9_iocled_dir_out; iocled->chip.label ="iocled" ; - iocled->chip.base = basenum; + iocled->chip.base =-1 ; iocled->chip.ngpio = num;if (gpiochip_add_data (&iocled->chip, iocled)) goto out_unmap; -if (basenum <0 ) - basenum = iocled->chip.base; - pdev =platform_device_alloc ("leds-gpio" , basenum); + pdev =platform_device_alloc ("leds-gpio" , iocled->chip.base);if (!pdev) goto out_gpio; iocled->pdata.num_leds = num;
@@ -689,8 +686,7 @@ void __init txx9_iocled_init(unsigned long baseaddr, kfree(iocled); }#else /* CONFIG_LEDS_GPIO */ -void __init txx9_iocled_init (unsigned long baseaddr, -int basenum,unsigned int num,int lowactive, +void __init txx9_iocled_init (unsigned long baseaddr,unsigned int num,const char *color,char **deftriggers) { }
arch/mips/txx9/rbtx4927/setup.c +1 -1
@@ -370,7 +370,7 @@ static void __init rbtx4927_device_init(void)tx4938_aclc_init (); }platform_device_register_simple ("txx9aclc-generic" ,-1 ,NULL ,0 ); -txx9_iocled_init (RBTX4927_LED_ADDR -IO_BASE ,-1 ,3 ,1 ,"green" ,NULL ); +txx9_iocled_init (RBTX4927_LED_ADDR -IO_BASE ,3 ,"green" ,NULL );rbtx4927_gpioled_init (); }
Signature · 1 line
2.43.0
Re: [PATCH 9/9] MIPS: TXX9: Clean up txx9_iocled_init()
Quoted 10 lines · Geert Uytterhoeven
The sole caller already uses dynamic GPIO base allocation, so drop support for static allocation.
While at it, drop the no longer used "lowactive" parameter.Signed-off-by Geert Uytterhoeven <[email protected]>--- arch/mips/include/asm/txx9/generic.h | 3 +-- arch/mips/txx9/generic/setup.c | 12 ++++-------- arch/mips/txx9/rbtx4927/setup.c | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-)
Quoted 29 lines · Geert Uytterhoeven
Hi all,
This patch series gets rid of legacy GPIO interface usage on the MIPS RBTX4927 development board, preceded and followed by some cleanups. No blinky LEDs were harmed during the production of this series.
Thanks for your comments!
Geert Uytterhoeven (9):
MIPS: TXX9: Removetx4938_spi_init()andtxx9_spi_init()
MIPS: TXX9: Remove txx9_7segled_*() forward declarations
MIPS: TXX9: rbtx4927: Use GPIO lookup table for SIO DTR
MIPS: TXX9: rbtx4927: Use GPIO lookup table for TXx9 LEDs
MIPS: TXX9: ReduceTXX9_IOCLED_MAXLEDSto 3
MIPS: TXX9: Use GPIO lookup table for iocled LEDs
MIPS: TXX9: DropGPIOLIB_LEGACYselect
MIPS: TXX9: Convertgpio_txx9to dynamic GPIO base allocation
MIPS: TXX9: Clean uptxx9_iocled_init()arch/mips/include/asm/txx9/generic.h | 9 +----- arch/mips/include/asm/txx9/tx4938.h | 1 - arch/mips/include/asm/txx9pio.h | 3 +- arch/mips/kernel/gpio_txx9.c | 5 ++- arch/mips/txx9/Kconfig | 1 - arch/mips/txx9/generic/setup.c | 45 ++++++++++----------------- arch/mips/txx9/generic/setup_tx4938.c | 6 ---- arch/mips/txx9/rbtx4927/setup.c | 36 ++++++++++++++++----- 8 files changed, 49 insertions(+), 57 deletions(-)
Quoted 1 line
--
For the series:
Sashiko sashikos as usual but it points out issues in error paths in legacy board files so we can safely ignore them.
Bart
Quoted 3 lines · Geert Uytterhoeven
This patch series gets rid of legacy GPIO interface usage on the MIPS RBTX4927 development board, preceded and followed by some cleanups. No blinky LEDs were harmed during the production of this series.
Sashiko is asking you to fix the entire universe as usual, I couldn't care less.
Yours,
Linus Walleij
Hi Linus,
Quoted 6 lines · Linus Walleij
Quoted 3 lines · Geert Uytterhoeven
This patch series gets rid of legacy GPIO interface usage on the MIPS RBTX4927 development board, preceded and followed by some cleanups. No blinky LEDs were harmed during the production of this series.
Reviewed-by Linus Walleij <[email protected]>
Thanks!
Quoted 2 lines
Sashiko is asking you to fix the entire universe as usual, I couldn't care less.
Feeling lucky for not being CCed by Sashiko ;-)
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds