Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mips_5.18_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux

Pull MIPS fixes from Thomas Bogendoerfer:

- build fix for gpio

- fix crc32 build problems

- check for failed memory allocations

* tag 'mips_5.18_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
MIPS: crypto: Fix CRC32 code
MIPS: rb532: move GPIOD definition into C-files
MIPS: lantiq: check the return value of kzalloc()
mips: sgi-ip22: add a check for the return of kzalloc()

+72 -45
+26 -20
arch/mips/crypto/crc32-mips.c
··· 28 }; 29 30 #ifndef TOOLCHAIN_SUPPORTS_CRC 31 - #define _ASM_MACRO_CRC32(OP, SZ, TYPE) \ 32 _ASM_MACRO_3R(OP, rt, rs, rt2, \ 33 ".ifnc \\rt, \\rt2\n\t" \ 34 ".error \"invalid operands \\\"" #OP " \\rt,\\rs,\\rt2\\\"\"\n\t" \ ··· 37 ((SZ) << 6) | ((TYPE) << 8)) \ 38 _ASM_INSN32_IF_MM(0x00000030 | (__rs << 16) | (__rt << 21) | \ 39 ((SZ) << 14) | ((TYPE) << 3))) 40 - _ASM_MACRO_CRC32(crc32b, 0, 0); 41 - _ASM_MACRO_CRC32(crc32h, 1, 0); 42 - _ASM_MACRO_CRC32(crc32w, 2, 0); 43 - _ASM_MACRO_CRC32(crc32d, 3, 0); 44 - _ASM_MACRO_CRC32(crc32cb, 0, 1); 45 - _ASM_MACRO_CRC32(crc32ch, 1, 1); 46 - _ASM_MACRO_CRC32(crc32cw, 2, 1); 47 - _ASM_MACRO_CRC32(crc32cd, 3, 1); 48 - #define _ASM_SET_CRC "" 49 #else /* !TOOLCHAIN_SUPPORTS_CRC */ 50 - #define _ASM_SET_CRC ".set\tcrc\n\t" 51 #endif 52 53 - #define _CRC32(crc, value, size, type) \ 54 - do { \ 55 - __asm__ __volatile__( \ 56 - ".set push\n\t" \ 57 - _ASM_SET_CRC \ 58 - #type #size " %0, %1, %0\n\t" \ 59 - ".set pop" \ 60 - : "+r" (crc) \ 61 - : "r" (value)); \ 62 } while (0) 63 64 #define CRC32(crc, value, size) \ 65 _CRC32(crc, value, size, crc32)
··· 28 }; 29 30 #ifndef TOOLCHAIN_SUPPORTS_CRC 31 + #define _ASM_SET_CRC(OP, SZ, TYPE) \ 32 _ASM_MACRO_3R(OP, rt, rs, rt2, \ 33 ".ifnc \\rt, \\rt2\n\t" \ 34 ".error \"invalid operands \\\"" #OP " \\rt,\\rs,\\rt2\\\"\"\n\t" \ ··· 37 ((SZ) << 6) | ((TYPE) << 8)) \ 38 _ASM_INSN32_IF_MM(0x00000030 | (__rs << 16) | (__rt << 21) | \ 39 ((SZ) << 14) | ((TYPE) << 3))) 40 + #define _ASM_UNSET_CRC(op, SZ, TYPE) ".purgem " #op "\n\t" 41 #else /* !TOOLCHAIN_SUPPORTS_CRC */ 42 + #define _ASM_SET_CRC(op, SZ, TYPE) ".set\tcrc\n\t" 43 + #define _ASM_UNSET_CRC(op, SZ, TYPE) 44 #endif 45 46 + #define __CRC32(crc, value, op, SZ, TYPE) \ 47 + do { \ 48 + __asm__ __volatile__( \ 49 + ".set push\n\t" \ 50 + _ASM_SET_CRC(op, SZ, TYPE) \ 51 + #op " %0, %1, %0\n\t" \ 52 + _ASM_UNSET_CRC(op, SZ, TYPE) \ 53 + ".set pop" \ 54 + : "+r" (crc) \ 55 + : "r" (value)); \ 56 } while (0) 57 + 58 + #define _CRC32_crc32b(crc, value) __CRC32(crc, value, crc32b, 0, 0) 59 + #define _CRC32_crc32h(crc, value) __CRC32(crc, value, crc32h, 1, 0) 60 + #define _CRC32_crc32w(crc, value) __CRC32(crc, value, crc32w, 2, 0) 61 + #define _CRC32_crc32d(crc, value) __CRC32(crc, value, crc32d, 3, 0) 62 + #define _CRC32_crc32cb(crc, value) __CRC32(crc, value, crc32cb, 0, 1) 63 + #define _CRC32_crc32ch(crc, value) __CRC32(crc, value, crc32ch, 1, 1) 64 + #define _CRC32_crc32cw(crc, value) __CRC32(crc, value, crc32cw, 2, 1) 65 + #define _CRC32_crc32cd(crc, value) __CRC32(crc, value, crc32cd, 3, 1) 66 + 67 + #define _CRC32(crc, value, size, op) \ 68 + _CRC32_##op##size(crc, value) 69 70 #define CRC32(crc, value, size) \ 71 _CRC32(crc, value, size, crc32)
-9
arch/mips/include/asm/mach-rc32434/rb.h
··· 29 #define DEV3TC 0x01003C 30 #define BTCS 0x010040 31 #define BTCOMPARE 0x010044 32 - #define GPIOBASE 0x050000 33 - /* Offsets relative to GPIOBASE */ 34 - #define GPIOFUNC 0x00 35 - #define GPIOCFG 0x04 36 - #define GPIOD 0x08 37 - #define GPIOILEVEL 0x0C 38 - #define GPIOISTAT 0x10 39 - #define GPIONMIEN 0x14 40 - #define IMASK6 0x38 41 #define LO_WPX (1 << 0) 42 #define LO_ALE (1 << 1) 43 #define LO_CLE (1 << 2)
··· 29 #define DEV3TC 0x01003C 30 #define BTCS 0x010040 31 #define BTCOMPARE 0x010044 32 #define LO_WPX (1 << 0) 33 #define LO_ALE (1 << 1) 34 #define LO_CLE (1 << 2)
+2
arch/mips/lantiq/falcon/sysctrl.c
··· 167 { 168 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 169 170 clk->cl.dev_id = dev; 171 clk->cl.con_id = NULL; 172 clk->cl.clk = clk;
··· 167 { 168 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 169 170 + if (!clk) 171 + return; 172 clk->cl.dev_id = dev; 173 clk->cl.con_id = NULL; 174 clk->cl.clk = clk;
+2
arch/mips/lantiq/xway/gptu.c
··· 122 { 123 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 124 125 clk->cl.dev_id = dev_name(dev); 126 clk->cl.con_id = con; 127 clk->cl.clk = clk;
··· 122 { 123 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 124 125 + if (!clk) 126 + return; 127 clk->cl.dev_id = dev_name(dev); 128 clk->cl.con_id = con; 129 clk->cl.clk = clk;
+30 -16
arch/mips/lantiq/xway/sysctrl.c
··· 315 { 316 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 317 318 clk->cl.dev_id = dev; 319 clk->cl.con_id = con; 320 clk->cl.clk = clk; ··· 340 { 341 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 342 343 clk->cl.dev_id = dev; 344 clk->cl.con_id = con; 345 clk->cl.clk = clk; ··· 360 struct clk *clk_ext = kzalloc(sizeof(struct clk), GFP_KERNEL); 361 362 /* main pci clock */ 363 - clk->cl.dev_id = "17000000.pci"; 364 - clk->cl.con_id = NULL; 365 - clk->cl.clk = clk; 366 - clk->rate = CLOCK_33M; 367 - clk->rates = valid_pci_rates; 368 - clk->enable = pci_enable; 369 - clk->disable = pmu_disable; 370 - clk->module = 0; 371 - clk->bits = PMU_PCI; 372 - clkdev_add(&clk->cl); 373 374 /* use internal/external bus clock */ 375 - clk_ext->cl.dev_id = "17000000.pci"; 376 - clk_ext->cl.con_id = "external"; 377 - clk_ext->cl.clk = clk_ext; 378 - clk_ext->enable = pci_ext_enable; 379 - clk_ext->disable = pci_ext_disable; 380 - clkdev_add(&clk_ext->cl); 381 } 382 383 /* xway socs can generate clocks on gpio pins */ ··· 401 char *name; 402 403 name = kzalloc(sizeof("clkout0"), GFP_KERNEL); 404 sprintf(name, "clkout%d", i); 405 406 clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 407 clk->cl.dev_id = "1f103000.cgu"; 408 clk->cl.con_id = name; 409 clk->cl.clk = clk;
··· 315 { 316 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 317 318 + if (!clk) 319 + return; 320 clk->cl.dev_id = dev; 321 clk->cl.con_id = con; 322 clk->cl.clk = clk; ··· 338 { 339 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 340 341 + if (!clk) 342 + return; 343 clk->cl.dev_id = dev; 344 clk->cl.con_id = con; 345 clk->cl.clk = clk; ··· 356 struct clk *clk_ext = kzalloc(sizeof(struct clk), GFP_KERNEL); 357 358 /* main pci clock */ 359 + if (clk) { 360 + clk->cl.dev_id = "17000000.pci"; 361 + clk->cl.con_id = NULL; 362 + clk->cl.clk = clk; 363 + clk->rate = CLOCK_33M; 364 + clk->rates = valid_pci_rates; 365 + clk->enable = pci_enable; 366 + clk->disable = pmu_disable; 367 + clk->module = 0; 368 + clk->bits = PMU_PCI; 369 + clkdev_add(&clk->cl); 370 + } 371 372 /* use internal/external bus clock */ 373 + if (clk_ext) { 374 + clk_ext->cl.dev_id = "17000000.pci"; 375 + clk_ext->cl.con_id = "external"; 376 + clk_ext->cl.clk = clk_ext; 377 + clk_ext->enable = pci_ext_enable; 378 + clk_ext->disable = pci_ext_disable; 379 + clkdev_add(&clk_ext->cl); 380 + } 381 } 382 383 /* xway socs can generate clocks on gpio pins */ ··· 393 char *name; 394 395 name = kzalloc(sizeof("clkout0"), GFP_KERNEL); 396 + if (!name) 397 + continue; 398 sprintf(name, "clkout%d", i); 399 400 clk = kzalloc(sizeof(struct clk), GFP_KERNEL); 401 + if (!clk) { 402 + kfree(name); 403 + continue; 404 + } 405 clk->cl.dev_id = "1f103000.cgu"; 406 clk->cl.con_id = name; 407 clk->cl.clk = clk;
+10
arch/mips/rb532/gpio.c
··· 37 #include <asm/mach-rc32434/rb.h> 38 #include <asm/mach-rc32434/gpio.h> 39 40 struct rb532_gpio_chip { 41 struct gpio_chip chip; 42 void __iomem *regbase;
··· 37 #include <asm/mach-rc32434/rb.h> 38 #include <asm/mach-rc32434/gpio.h> 39 40 + #define GPIOBASE 0x050000 41 + /* Offsets relative to GPIOBASE */ 42 + #define GPIOFUNC 0x00 43 + #define GPIOCFG 0x04 44 + #define GPIOD 0x08 45 + #define GPIOILEVEL 0x0C 46 + #define GPIOISTAT 0x10 47 + #define GPIONMIEN 0x14 48 + #define IMASK6 0x38 49 + 50 struct rb532_gpio_chip { 51 struct gpio_chip chip; 52 void __iomem *regbase;
+2
arch/mips/sgi-ip22/ip22-gio.c
··· 363 printk(KERN_INFO "GIO: slot %d : %s (id %x)\n", 364 slotno, name, id); 365 gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL); 366 gio_dev->name = name; 367 gio_dev->slotno = slotno; 368 gio_dev->id.id = id;
··· 363 printk(KERN_INFO "GIO: slot %d : %s (id %x)\n", 364 slotno, name, id); 365 gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL); 366 + if (!gio_dev) 367 + return; 368 gio_dev->name = name; 369 gio_dev->slotno = slotno; 370 gio_dev->id.id = id;