diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c index c3ba67e..6addfed 100644 --- a/arch/arm/mach-imx/iim.c +++ b/arch/arm/mach-imx/iim.c @@ -196,7 +196,7 @@ if (!imx_iim) return -ENODEV; - if (banknum > IIM_NUM_BANKS) + if (banknum >= IIM_NUM_BANKS) return -EINVAL; bank = iim->bank[banknum]; diff --git a/commands/menu.c b/commands/menu.c index 9ec2d57..e1079fd 100644 --- a/commands/menu.c +++ b/commands/menu.c @@ -83,7 +83,7 @@ else me = menu_add_command_entry(m, cm->description, cm->command, cm->type); - if (!me) + if (IS_ERR(me)) return PTR_ERR(me); me->box_state = cm->box_state > 0 ? 1 : 0; diff --git a/common/.gitignore b/common/.gitignore index 3d71b7e..8e0d6c1 100644 --- a/common/.gitignore +++ b/common/.gitignore @@ -1 +1,2 @@ module.lds +barebox_default_env* diff --git a/crypto/crc32.c b/crypto/crc32.c index 3bff6fe..232c023 100644 --- a/crypto/crc32.c +++ b/crypto/crc32.c @@ -24,9 +24,7 @@ #ifdef CONFIG_DYNAMIC_CRC_TABLE -static int crc_table_empty = 1; -static ulong crc_table[256]; -static void make_crc_table(void); +static ulong *crc_table; /* Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: @@ -65,6 +63,8 @@ for (n = 0; n < sizeof(p)/sizeof(char); n++) poly |= 1L << (31 - p[n]); + crc_table = xmalloc(sizeof(ulong) * 256); + for (n = 0; n < 256; n++) { c = (ulong)n; @@ -72,7 +72,6 @@ c = c & 1 ? poly ^ (c >> 1) : c >> 1; crc_table[n] = c; } - crc_table_empty = 0; } #else /* ======================================================================== @@ -147,8 +146,8 @@ const unsigned char *buf = _buf; #ifdef CONFIG_DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); + if (!crc_table) + make_crc_table(); #endif crc = crc ^ 0xffffffffL; while (len >= 8) @@ -173,8 +172,8 @@ const unsigned char *buf = _buf; #ifdef CONFIG_DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); + if (!crc_table) + make_crc_table(); #endif while (len >= 8) { diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index d9a1c21..1bc5c6d 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -181,8 +181,8 @@ if (dev) { clk = of_clk_get_by_name(dev->device_node, con_id); - if (!IS_ERR(clk)) - return clk; + if (!IS_ERR(clk)) + return clk; } return clk_get_sys(dev_id, con_id); diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c index fd6307d..4ae3776 100644 --- a/drivers/eeprom/at24.c +++ b/drivers/eeprom/at24.c @@ -441,12 +441,7 @@ dev_err(&client->dev, "no index found to name device\n"); goto err_device_name; } - devname = basprintf("eeprom%d", err); - if (!devname) { - err = -ENOMEM; - dev_err(&client->dev, "failed to allocate space for device name\n"); - goto err_device_name; - } + devname = xasprintf("eeprom%d", err); } at24->cdev.name = devname; diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 7d2c194..e694a98 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -1,8 +1,7 @@ -obj-$(CONFIG_INPUT) += input.o +obj-$(CONFIG_INPUT) += input.o keymap.o obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o obj-$(CONFIG_KEYBOARD_USB) += usb_kbd.o obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o obj-$(CONFIG_KEYBOARD_TWL6030) += twl6030_pwrbtn.o obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o -obj-y += keymap.o diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 670720a..426ad9b 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -445,10 +445,7 @@ { struct nand_chip *chip = mtd->priv; - if (IS_ENABLED(CONFIG_NAND_BBT)) { - if (!chip->bbt) - return chip->block_bad(mtd, ofs, getchip); - + if (IS_ENABLED(CONFIG_NAND_BBT) && chip->bbt) { /* Return info from the table */ return nand_isbad_bbt(mtd, ofs, allowbbt); } diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index ed69d9b..13b8324 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -300,7 +300,8 @@ phydev->registered = 0; } -struct phy_device *of_phy_register_fixed_link(struct device_node *np, struct eth_device *edev) +static struct phy_device *of_phy_register_fixed_link(struct device_node *np, + struct eth_device *edev) { struct phy_device *phydev; diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index fe9d1df..45175bb 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -38,7 +38,7 @@ struct mii_bus miibus; void __iomem *base; - int shift; + u32 shift; int generation; unsigned int flags; unsigned int idrev; @@ -516,6 +516,19 @@ priv->shift = pdata->shift; priv->flags = pdata->flags; priv->phy_mask = pdata->phy_mask; + } else if (IS_ENABLED(CONFIG_OFDEVICE) && dev->device_node) { + ret = of_property_read_u32(dev->device_node, "reg-io-width", &val); + if (ret) + return ret; + is_32bit = (val == 4); + + of_property_read_u32(dev->device_node, "reg-shift", &priv->shift); + + if (of_property_read_bool(dev->device_node, "smsc,force-internal-phy")) + priv->flags |= SMC911X_FORCE_INTERNAL_PHY; + + if (of_property_read_bool(dev->device_node, "smsc,force-external-phy")) + priv->flags |= SMC911X_FORCE_EXTERNAL_PHY; } if (is_32bit) { @@ -562,7 +575,7 @@ if (val != 0x87654321) { dev_err(dev, "no smc911x found on 0x%p (byte_test=0x%08x)\n", priv->base, val); - if (((val >> 16) & 0xFFFF) == (val & 0xFFFF)) { + if ((((val >> 16) & 0xFFFF) == (val & 0xFFFF)) && is_32bit) { /* * This may mean the chip is set * for 32 bit while the bus is reading 16 bit diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 9e38ac4..1cfc49d 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -86,7 +86,7 @@ struct usb_function *f, struct usb_ep *_ep) { - struct usb_composite_dev *cdev = get_gadget_data(g); + struct usb_composite_dev *cdev; struct usb_endpoint_descriptor *chosen_desc = NULL; struct usb_descriptor_header **speed_desc = NULL; @@ -98,6 +98,8 @@ if (!g || !f || !_ep) return -EIO; + cdev = get_gadget_data(g); + /* select desired speed */ switch (g->speed) { case USB_SPEED_SUPER: diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index b0bf922..35cf6aa 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -215,7 +215,7 @@ static int ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, - int length, struct devrequest *req) + int length, struct devrequest *req, int timeout_ms) { struct usb_host *host = dev->host; struct ehci_priv *ehci = to_ehci(host); @@ -364,7 +364,7 @@ } /* Wait for TDs to be processed. */ - timeout_val = usb_pipebulk(pipe) ? (SECOND << 2) : (SECOND >> 2); + timeout_val = timeout_ms * MSECOND; start = get_time_ns(); vtd = td; do { @@ -893,7 +893,7 @@ dev_dbg(ehci->dev, "non-bulk pipe (type=%lu)", usb_pipetype(pipe)); return -1; } - return ehci_submit_async(dev, pipe, buffer, length, NULL); + return ehci_submit_async(dev, pipe, buffer, length, NULL, timeout); } static int @@ -913,7 +913,7 @@ dev->speed = USB_SPEED_HIGH; return ehci_submit_root(dev, pipe, buffer, length, setup); } - return ehci_submit_async(dev, pipe, buffer, length, setup); + return ehci_submit_async(dev, pipe, buffer, length, setup, timeout); } static int diff --git a/include/.gitignore b/include/.gitignore index 18e58a7..f28372a 100644 --- a/include/.gitignore +++ b/include/.gitignore @@ -1 +1,2 @@ +asm /config.h diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 020ad16..91331dd 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -4,8 +4,8 @@ #ifndef __ASSEMBLY__ #ifdef __CHECKER__ -# define __user __attribute__((noderef, address_space(1))) -# define __kernel __attribute__((address_space(0))) +# define __user /* no user address space in barebox */ +# define __kernel /* default address space */ # define __safe __attribute__((safe)) # define __force __attribute__((force)) # define __nocast __attribute__((nocast)) diff --git a/include/platform_data/eth-smc911x.h b/include/platform_data/eth-smc911x.h index 4a802ee..c97a296 100644 --- a/include/platform_data/eth-smc911x.h +++ b/include/platform_data/eth-smc911x.h @@ -12,7 +12,7 @@ * Pass pointer to this structure as part of device_d -> platform_data */ struct smc911x_plat { - int shift; + u32 shift; unsigned int flags; unsigned int phy_mask; /* external PHY only: mask out PHYs, e.g. ~(1 << 5) to use PHY addr 5 */ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 27365d8..e55bc27 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -39,10 +39,9 @@ obj-y += $(obj-pbl-y) pbl-y += $(obj-pbl-y) -# for non dirs add pbl- prefix to the target -# so we recompile the source with custom flags and custom quiet -__pbl-y := $(notdir $(pbl-y)) -pbl-y := $(patsubst %.o,pbl-%.o,$(__pbl-y)) +# add pbl- prefix to the target +pbl-y := $(shell echo $(pbl-y) | sed -e 's%\(\([^ \t]\+/\)*\)\([^ \t]*\.o\)%\2pbl-\3%g') + # add subdir from $(obj-y) too so we do not need to have the dir define in # both $(obj-y) and $(pbl-y) __pbl-y := $(filter-out $(pbl-y), $(filter %/, $(obj-y))) diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore index a776371..dc24f5f 100644 --- a/scripts/basic/.gitignore +++ b/scripts/basic/.gitignore @@ -1 +1,2 @@ +docproc fixdep