Skip to content

Commit 0b0fa57

Browse files
committed
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()
2 parents 3890491 + 41022ef commit 0b0fa57

File tree

7 files changed

+72
-45
lines changed

7 files changed

+72
-45
lines changed

arch/mips/crypto/crc32-mips.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum crc_type {
2828
};
2929

3030
#ifndef TOOLCHAIN_SUPPORTS_CRC
31-
#define _ASM_MACRO_CRC32(OP, SZ, TYPE) \
31+
#define _ASM_SET_CRC(OP, SZ, TYPE) \
3232
_ASM_MACRO_3R(OP, rt, rs, rt2, \
3333
".ifnc \\rt, \\rt2\n\t" \
3434
".error \"invalid operands \\\"" #OP " \\rt,\\rs,\\rt2\\\"\"\n\t" \
@@ -37,30 +37,36 @@ _ASM_MACRO_3R(OP, rt, rs, rt2, \
3737
((SZ) << 6) | ((TYPE) << 8)) \
3838
_ASM_INSN32_IF_MM(0x00000030 | (__rs << 16) | (__rt << 21) | \
3939
((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 ""
40+
#define _ASM_UNSET_CRC(op, SZ, TYPE) ".purgem " #op "\n\t"
4941
#else /* !TOOLCHAIN_SUPPORTS_CRC */
50-
#define _ASM_SET_CRC ".set\tcrc\n\t"
42+
#define _ASM_SET_CRC(op, SZ, TYPE) ".set\tcrc\n\t"
43+
#define _ASM_UNSET_CRC(op, SZ, TYPE)
5144
#endif
5245

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)); \
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)); \
6256
} while (0)
6357

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+
6470
#define CRC32(crc, value, size) \
6571
_CRC32(crc, value, size, crc32)
6672

arch/mips/include/asm/mach-rc32434/rb.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@
2929
#define DEV3TC 0x01003C
3030
#define BTCS 0x010040
3131
#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
4132
#define LO_WPX (1 << 0)
4233
#define LO_ALE (1 << 1)
4334
#define LO_CLE (1 << 2)

arch/mips/lantiq/falcon/sysctrl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ static inline void clkdev_add_sys(const char *dev, unsigned int module,
167167
{
168168
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
169169

170+
if (!clk)
171+
return;
170172
clk->cl.dev_id = dev;
171173
clk->cl.con_id = NULL;
172174
clk->cl.clk = clk;

arch/mips/lantiq/xway/gptu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ static inline void clkdev_add_gptu(struct device *dev, const char *con,
122122
{
123123
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
124124

125+
if (!clk)
126+
return;
125127
clk->cl.dev_id = dev_name(dev);
126128
clk->cl.con_id = con;
127129
clk->cl.clk = clk;

arch/mips/lantiq/xway/sysctrl.c

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ static void clkdev_add_pmu(const char *dev, const char *con, bool deactivate,
315315
{
316316
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
317317

318+
if (!clk)
319+
return;
318320
clk->cl.dev_id = dev;
319321
clk->cl.con_id = con;
320322
clk->cl.clk = clk;
@@ -338,6 +340,8 @@ static void clkdev_add_cgu(const char *dev, const char *con,
338340
{
339341
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
340342

343+
if (!clk)
344+
return;
341345
clk->cl.dev_id = dev;
342346
clk->cl.con_id = con;
343347
clk->cl.clk = clk;
@@ -356,24 +360,28 @@ static void clkdev_add_pci(void)
356360
struct clk *clk_ext = kzalloc(sizeof(struct clk), GFP_KERNEL);
357361

358362
/* main pci clock */
359-
clk->cl.dev_id = "17000000.pci";
360-
clk->cl.con_id = NULL;
361-
clk->cl.clk = clk;
362-
clk->rate = CLOCK_33M;
363-
clk->rates = valid_pci_rates;
364-
clk->enable = pci_enable;
365-
clk->disable = pmu_disable;
366-
clk->module = 0;
367-
clk->bits = PMU_PCI;
368-
clkdev_add(&clk->cl);
363+
if (clk) {
364+
clk->cl.dev_id = "17000000.pci";
365+
clk->cl.con_id = NULL;
366+
clk->cl.clk = clk;
367+
clk->rate = CLOCK_33M;
368+
clk->rates = valid_pci_rates;
369+
clk->enable = pci_enable;
370+
clk->disable = pmu_disable;
371+
clk->module = 0;
372+
clk->bits = PMU_PCI;
373+
clkdev_add(&clk->cl);
374+
}
369375

370376
/* use internal/external bus clock */
371-
clk_ext->cl.dev_id = "17000000.pci";
372-
clk_ext->cl.con_id = "external";
373-
clk_ext->cl.clk = clk_ext;
374-
clk_ext->enable = pci_ext_enable;
375-
clk_ext->disable = pci_ext_disable;
376-
clkdev_add(&clk_ext->cl);
377+
if (clk_ext) {
378+
clk_ext->cl.dev_id = "17000000.pci";
379+
clk_ext->cl.con_id = "external";
380+
clk_ext->cl.clk = clk_ext;
381+
clk_ext->enable = pci_ext_enable;
382+
clk_ext->disable = pci_ext_disable;
383+
clkdev_add(&clk_ext->cl);
384+
}
377385
}
378386

379387
/* xway socs can generate clocks on gpio pins */
@@ -393,9 +401,15 @@ static void clkdev_add_clkout(void)
393401
char *name;
394402

395403
name = kzalloc(sizeof("clkout0"), GFP_KERNEL);
404+
if (!name)
405+
continue;
396406
sprintf(name, "clkout%d", i);
397407

398408
clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
409+
if (!clk) {
410+
kfree(name);
411+
continue;
412+
}
399413
clk->cl.dev_id = "1f103000.cgu";
400414
clk->cl.con_id = name;
401415
clk->cl.clk = clk;

arch/mips/rb532/gpio.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737
#include <asm/mach-rc32434/rb.h>
3838
#include <asm/mach-rc32434/gpio.h>
3939

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+
4050
struct rb532_gpio_chip {
4151
struct gpio_chip chip;
4252
void __iomem *regbase;

arch/mips/sgi-ip22/ip22-gio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ static void ip22_check_gio(int slotno, unsigned long addr, int irq)
363363
printk(KERN_INFO "GIO: slot %d : %s (id %x)\n",
364364
slotno, name, id);
365365
gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL);
366+
if (!gio_dev)
367+
return;
366368
gio_dev->name = name;
367369
gio_dev->slotno = slotno;
368370
gio_dev->id.id = id;

0 commit comments

Comments
 (0)