From 340af0aaf7a9d2d8838c7f1d917a1cbec2b6bcfa Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 19 Sep 2017 14:36:41 -0700 Subject: lib,ratp: avoid too verbose info messages When using a cli-based RATP that opens and closes the RATP channel for each command sent/received, it gets annoying to get the "Closed" message printed all the time in console after each RATP channel close operation. Just demote it to debug level. E.g.: barebox@barebox sandbox:/ ratp: Closed ratp: Closed ratp: Closed ratp: Closed ... Signed-off-by: Aleksander Morgado Signed-off-by: Sascha Hauer --- lib/ratp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ratp.c b/lib/ratp.c index e7fbf640a7..4c5c748b48 100644 --- a/lib/ratp.c +++ b/lib/ratp.c @@ -1717,7 +1717,7 @@ void ratp_close(struct ratp *ratp) free(ri); ratp->internal = NULL; - pr_info("Closed\n"); + pr_debug("Closed\n"); } /** -- cgit v1.2.3 From b2ac13f498fb217194d6afe836981411bf14158c Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Thu, 21 Sep 2017 22:44:55 +0200 Subject: gpiolib: check validity for gpio_info in *_active() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gpio_set_active, gpio_is_active and gpio_direction_active are public functions, accordingly there should be error checking. If an invalid gpio number is given to these functions without checking gpio_adjust_value is called with gi == NULL which then dereferences this pointer. Signed-off-by: Uwe Kleine-König Signed-off-by: Sascha Hauer --- drivers/gpio/gpiolib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 67d771bae3..b83a27de7d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -204,6 +204,10 @@ EXPORT_SYMBOL(gpio_set_value); void gpio_set_active(unsigned gpio, bool value) { struct gpio_info *gi = gpio_to_desc(gpio); + + if (!gi) + return; + gpio_set_value(gpio, gpio_adjust_value(gi, value)); } EXPORT_SYMBOL(gpio_set_active); @@ -229,6 +233,10 @@ EXPORT_SYMBOL(gpio_get_value); int gpio_is_active(unsigned gpio) { struct gpio_info *gi = gpio_to_desc(gpio); + + if (!gi) + return -ENODEV; + return gpio_adjust_value(gi, gpio_get_value(gpio)); } EXPORT_SYMBOL(gpio_is_active); @@ -255,6 +263,10 @@ EXPORT_SYMBOL(gpio_direction_output); int gpio_direction_active(unsigned gpio, bool value) { struct gpio_info *gi = gpio_to_desc(gpio); + + if (!gi) + return -ENODEV; + return gpio_direction_output(gpio, gpio_adjust_value(gi, value)); } EXPORT_SYMBOL(gpio_direction_active); -- cgit v1.2.3 From 0b8f3441aa032b69770f59cafc37087a6d505cee Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 20 Sep 2017 12:07:16 -0700 Subject: console_countdown: ignore errors in getchar() The getchar() call may return an error reported as a -1, e.g. when the console detects a RATP message and switches to RATP mode. In general it probably is a good idea to ignore these errors in the console countdown operation; and in particular for the RATP usecase, this also prevents from interfering with the countdown and menu just when switching one of the consoles to RATP mode. As a hint, this is what the standard console was printing due to this issue when the RATP console was activated: Hit m for menu or any other key to stop autoboot: [: missing `]' Signed-off-by: Aleksander Morgado Signed-off-by: Sascha Hauer --- common/console_countdown.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/console_countdown.c b/common/console_countdown.c index 03b9b33538..36da1ce577 100644 --- a/common/console_countdown.c +++ b/common/console_countdown.c @@ -47,12 +47,14 @@ int console_countdown(int timeout_s, unsigned flags, char *out_key) do { if (tstc()) { key = getchar(); - if (flags & CONSOLE_COUNTDOWN_ANYKEY) - goto out; - if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n') - goto out; - if (flags & CONSOLE_COUNTDOWN_CTRLC && key == 3) - goto out; + if (key >= 0) { + if (flags & CONSOLE_COUNTDOWN_ANYKEY) + goto out; + if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n') + goto out; + if (flags & CONSOLE_COUNTDOWN_CTRLC && key == 3) + goto out; + } key = 0; } if ((flags & CONSOLE_COUNTDOWN_EXTERN) && -- cgit v1.2.3 From b9bbbc9730a12db09bcad3c5da1d75a06f34c8e7 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Fri, 22 Sep 2017 15:50:23 +0200 Subject: imx-bbu-nand-fcb: read_firmware_all(): Spell "Secondary firmware" with a capital "S" "Primary firmware" is writte with a capital "P" so adjust "Secondary firmware" to use a capital "S". Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- common/imx-bbu-nand-fcb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c index 7218c5e1cc..89b404884a 100644 --- a/common/imx-bbu-nand-fcb.c +++ b/common/imx-bbu-nand-fcb.c @@ -1126,7 +1126,7 @@ static void read_firmware_all(struct mtd_info *mtd, struct fcb_block *fcb, void fcb->Firmware1_startingPage + fcb->PagesInFirmware1, primary ? "" : "in", primary_refresh ? "needs cleanup" : "clean"); - pr_info("secondary firmware is on pages %d-%d, %svalid, %s\n", fcb->Firmware2_startingPage, + pr_info("Secondary firmware is on pages %d-%d, %svalid, %s\n", fcb->Firmware2_startingPage, fcb->Firmware2_startingPage + fcb->PagesInFirmware2, secondary ? "" : "in", secondary_refresh ? "needs cleanup" : "clean"); -- cgit v1.2.3 From 347ab857903a8e613052a28540abdcf78edb2f1b Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Sun, 24 Sep 2017 23:28:53 +0200 Subject: pinctrl: mxs: fix error message to mention right property name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Sascha Hauer --- drivers/pinctrl/pinctrl-mxs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-mxs.c b/drivers/pinctrl/pinctrl-mxs.c index fa1176fe1b..479c31a426 100644 --- a/drivers/pinctrl/pinctrl-mxs.c +++ b/drivers/pinctrl/pinctrl-mxs.c @@ -52,7 +52,7 @@ static int mxs_pinctrl_set_state(struct pinctrl_device *pdev, struct device_node return -EINVAL; if (!size || size % 4) { - dev_err(iomux->pinctrl.dev, "Invalid fsl,pins property in %s\n", + dev_err(iomux->pinctrl.dev, "Invalid fsl,pinmux-ids property in %s\n", np->full_name); return -EINVAL; } -- cgit v1.2.3 From 25e67cbb2fce8690bcde07598ad4998aad475f13 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Mon, 25 Sep 2017 12:02:35 +0200 Subject: remove checks for xzalloc() returning NULL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xzalloc() either returns memory or panics, so checking for NULL is useless. Signed-off-by: Uwe Kleine-König Signed-off-by: Sascha Hauer --- common/state/backend_bucket_circular.c | 2 -- common/state/backend_format_dtb.c | 2 -- common/state/backend_format_raw.c | 4 ---- drivers/clk/mxs/clk-div.c | 2 -- drivers/clk/mxs/clk-pll.c | 2 -- drivers/clk/mxs/clk-ref.c | 2 -- drivers/gpio/gpio-clps711x.c | 2 -- drivers/gpio/gpio-generic.c | 2 -- drivers/gpio/gpio-vf610.c | 2 -- drivers/mtd/nand/atmel_nand.c | 2 -- drivers/net/gianfar.c | 3 --- drivers/of/base.c | 2 -- drivers/pci/pci-imx6.c | 2 -- drivers/pinctrl/pinctrl-rockchip.c | 2 -- drivers/usb/gadget/pxa27x_udc.c | 2 -- drivers/usb/musb/musb_host.c | 2 -- drivers/usb/musb/phy-am335x-control.c | 4 ---- drivers/usb/musb/phy-am335x.c | 2 -- drivers/video/backlight-pwm.c | 2 -- drivers/video/tc358767.c | 2 -- fs/omap4_usbbootfs.c | 2 -- fs/pstore/fs.c | 2 -- 22 files changed, 49 deletions(-) diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index f83bd679d7..2324903255 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -310,8 +310,6 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck * random changes */ write_buf = xzalloc(written_length); - if (!write_buf) - return -ENOMEM; memcpy(write_buf, buf, len); meta = (struct state_backend_storage_bucket_circular_meta *) diff --git a/common/state/backend_format_dtb.c b/common/state/backend_format_dtb.c index 4c9d2eefc7..48f30db1f5 100644 --- a/common/state/backend_format_dtb.c +++ b/common/state/backend_format_dtb.c @@ -136,8 +136,6 @@ int backend_format_dtb_create(struct state_backend_format **format, struct state_backend_format_dtb *dtb; dtb = xzalloc(sizeof(*dtb)); - if (!dtb) - return -ENOMEM; dtb->dev = dev; dtb->format.pack = state_backend_format_dtb_pack; diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c index 2ba97e08a0..4369f76e37 100644 --- a/common/state/backend_format_raw.c +++ b/common/state/backend_format_raw.c @@ -222,8 +222,6 @@ static int backend_format_raw_pack(struct state_backend_format *format, size_full = size_data + sizeof(*header) + backend_raw->digest_length; buf = xzalloc(size_full); - if (!buf) - return -ENOMEM; header = buf; data = buf + sizeof(*header); @@ -308,8 +306,6 @@ int backend_format_raw_create(struct state_backend_format **format, int ret; raw = xzalloc(sizeof(*raw)); - if (!raw) - return -ENOMEM; raw->dev = dev; ret = backend_format_raw_init_digest(raw, node, secret_name); diff --git a/drivers/clk/mxs/clk-div.c b/drivers/clk/mxs/clk-div.c index e8dae25da5..797e5a274f 100644 --- a/drivers/clk/mxs/clk-div.c +++ b/drivers/clk/mxs/clk-div.c @@ -86,8 +86,6 @@ struct clk *mxs_clk_div(const char *name, const char *parent_name, int ret; div = xzalloc(sizeof(*div)); - if (!div) - return ERR_PTR(-ENOMEM); div->parent = parent_name; div->divider.clk.name = name; diff --git a/drivers/clk/mxs/clk-pll.c b/drivers/clk/mxs/clk-pll.c index 89fd6b5e31..1b1c9b3543 100644 --- a/drivers/clk/mxs/clk-pll.c +++ b/drivers/clk/mxs/clk-pll.c @@ -96,8 +96,6 @@ struct clk *mxs_clk_pll(const char *name, const char *parent_name, int ret; pll = xzalloc(sizeof(*pll)); - if (!pll) - return ERR_PTR(-ENOMEM); pll->parent = parent_name; pll->clk.name = name; diff --git a/drivers/clk/mxs/clk-ref.c b/drivers/clk/mxs/clk-ref.c index 7ff5527797..8d0be05615 100644 --- a/drivers/clk/mxs/clk-ref.c +++ b/drivers/clk/mxs/clk-ref.c @@ -144,8 +144,6 @@ struct clk *mxs_clk_ref(const char *name, const char *parent_name, int ret; ref = xzalloc(sizeof(*ref)); - if (!ref) - return ERR_PTR(-ENOMEM); ref->parent = parent_name; ref->clk.name = name; diff --git a/drivers/gpio/gpio-clps711x.c b/drivers/gpio/gpio-clps711x.c index 769e6ca4f7..c1ec6ab685 100644 --- a/drivers/gpio/gpio-clps711x.c +++ b/drivers/gpio/gpio-clps711x.c @@ -47,8 +47,6 @@ static int clps711x_gpio_probe(struct device_d *dev) } bgc = xzalloc(sizeof(struct bgpio_chip)); - if (!bgc) - return -ENOMEM; err = bgpio_init(bgc, dev, 1, dat, NULL, NULL, dir, dir_inv, 0); if (err) diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index 14b451bfff..e4c4f39b62 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -373,8 +373,6 @@ static int bgpio_dev_probe(struct device_d *dev) dev_get_drvdata(dev, (const void **)&flags); bgc = xzalloc(sizeof(struct bgpio_chip)); - if (!bgc) - return -ENOMEM; err = bgpio_init(bgc, dev, sz, dat, set, clr, dirout, dirin, flags); if (err) diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index 7c8d1e4c98..2aff62be59 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c @@ -106,8 +106,6 @@ static int vf610_gpio_probe(struct device_d *dev) const __be32 *gpio_ranges; port = xzalloc(sizeof(*port)); - if (!port) - return -ENOMEM; gpio_ranges = of_get_property(dev->device_node, "gpio-ranges", &size); if (!gpio_ranges) { diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 299cc15c3d..0b9071c9bc 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -898,8 +898,6 @@ static int __init atmel_pmecc_nand_init_params(struct device_d *dev, /* Set pmecc_rom_base as the begin of gf table */ int size = sector_size == 512 ? 0x2000 : 0x4000; pmecc_galois_table = xzalloc(2 * size * sizeof(uint16_t)); - if (!pmecc_galois_table) - return -ENOMEM; host->pmecc_rom_base = pmecc_galois_table; ret = pmecc_build_galois_table((sector_size == 512) ? PMECC_GF_DIMENSION_13 : diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index ac698332cf..9b2f781d9c 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c @@ -483,9 +483,6 @@ static int gfar_probe(struct device_d *dev) priv = xzalloc(sizeof(struct gfar_private)); - if (NULL == priv) - return -ENODEV; - edev = &priv->edev; priv->mdiobus_tbi = gfar_info->mdiobus_tbi; diff --git a/drivers/of/base.c b/drivers/of/base.c index 95bea4ee83..a6c0cd1b57 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -194,8 +194,6 @@ void of_alias_scan(void) /* Allocate an alias_prop with enough space for the stem */ ap = xzalloc(sizeof(*ap) + len + 1); - if (!ap) - continue; ap->alias = start; of_alias_add(ap, np, id, start, len); } diff --git a/drivers/pci/pci-imx6.c b/drivers/pci/pci-imx6.c index affc705d0a..fc56a0d14a 100644 --- a/drivers/pci/pci-imx6.c +++ b/drivers/pci/pci-imx6.c @@ -580,8 +580,6 @@ static int __init imx6_pcie_probe(struct device_d *dev) int ret; imx6_pcie = xzalloc(sizeof(*imx6_pcie)); - if (!imx6_pcie) - return -ENOMEM; pp = &imx6_pcie->pp; pp->dev = dev; diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 1130f3d845..58f2c4af26 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -412,8 +412,6 @@ static int rockchip_pinctrl_probe(struct device_d *dev) int ret; info = xzalloc(sizeof(struct rockchip_pinctrl)); - if (!info) - return -ENOMEM; ctrl = rockchip_pinctrl_get_soc_data(info, dev); if (!ctrl) { diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 372c07b418..4e6b858868 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c @@ -218,8 +218,6 @@ static struct usb_request *pxa_ep_alloc_request(struct usb_ep *_ep) struct pxa27x_request *req; req = xzalloc(sizeof *req); - if (!req) - return NULL; INIT_LIST_HEAD(&req->queue); req->in_use = 0; diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 32a8f06529..68d819af2c 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -1717,8 +1717,6 @@ int musb_host_alloc(struct musb *musb) { /* usbcore sets dev->driver_data to hcd, and sometimes uses that... */ musb->hcd = xzalloc(sizeof(struct usb_hcd)); - if (!musb->hcd) - return -EINVAL; musb->hcd->hcd_priv = musb; diff --git a/drivers/usb/musb/phy-am335x-control.c b/drivers/usb/musb/phy-am335x-control.c index 5fd8802b3a..55a2ed27b7 100644 --- a/drivers/usb/musb/phy-am335x-control.c +++ b/drivers/usb/musb/phy-am335x-control.c @@ -140,10 +140,6 @@ static int am335x_control_usb_probe(struct device_d *dev) return ret; ctrl_usb = xzalloc(sizeof(*ctrl_usb)); - if (!ctrl_usb) { - dev_err(dev, "unable to alloc memory for control usb\n"); - return -ENOMEM; - } ctrl_usb->dev = dev; diff --git a/drivers/usb/musb/phy-am335x.c b/drivers/usb/musb/phy-am335x.c index 204e51054d..ec8c0f538b 100644 --- a/drivers/usb/musb/phy-am335x.c +++ b/drivers/usb/musb/phy-am335x.c @@ -34,8 +34,6 @@ static int am335x_phy_probe(struct device_d *dev) int ret; am_usbphy = xzalloc(sizeof(*am_usbphy)); - if (!am_usbphy) - return -ENOMEM; iores = dev_request_mem_resource(dev, 0); if (IS_ERR(iores)) { diff --git a/drivers/video/backlight-pwm.c b/drivers/video/backlight-pwm.c index 2915dba174..ec35bd1bc0 100644 --- a/drivers/video/backlight-pwm.c +++ b/drivers/video/backlight-pwm.c @@ -147,8 +147,6 @@ static int pwm_backlight_parse_dt(struct device_d *dev, size_t size = sizeof(*pwm_backlight->levels) * length; pwm_backlight->levels = xzalloc(size); - if (!pwm_backlight->levels) - return -ENOMEM; ret = of_property_read_u32_array(node, "brightness-levels", pwm_backlight->levels, diff --git a/drivers/video/tc358767.c b/drivers/video/tc358767.c index 2d366ae662..f9ca06c62b 100644 --- a/drivers/video/tc358767.c +++ b/drivers/video/tc358767.c @@ -1352,8 +1352,6 @@ static int tc_probe(struct device_d *dev) int ret; tc = xzalloc(sizeof(struct tc_data)); - if (!tc) - return -ENOMEM; tc->client = client; tc->dev = dev; diff --git a/fs/omap4_usbbootfs.c b/fs/omap4_usbbootfs.c index 6085bca841..b35f411cbb 100644 --- a/fs/omap4_usbbootfs.c +++ b/fs/omap4_usbbootfs.c @@ -73,8 +73,6 @@ static struct file_priv *omap4_usbbootfs_do_open( return ERR_PTR(-ENOSYS); priv = xzalloc(sizeof(*priv)); - if (!priv) - return ERR_PTR(-ENOMEM); data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4); data = OMAP4_USBBOOT_FS_CMD_OPEN; omap4_usbboot_write(&data, 4); diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c index 0e05d48ea0..a879a68064 100644 --- a/fs/pstore/fs.c +++ b/fs/pstore/fs.c @@ -64,8 +64,6 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count, } private = xzalloc(sizeof(*private) + size); - if (!private) - return -ENOMEM; private->type = type; private->id = id; private->count = count; -- cgit v1.2.3 From b5289b742a890a31e8b3fc1706774514dcbe1238 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 20 Sep 2017 17:50:44 +0200 Subject: mmc: allow skipping SD card initialization This patch allows to skip SD card initialization for eMMCs by setting the "no-sd" property in the host controller device tree node. Avoiding two SD command timeouts speeds up detection time by well over 200 ms. Signed-off-by: Philipp Zabel Signed-off-by: Sascha Hauer --- drivers/mci/mci-core.c | 12 ++++++++---- include/mci.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 07911d43d7..208b7666d6 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -1682,10 +1682,13 @@ static int mci_card_probe(struct mci *mci) } /* Check if this card can handle the "SD Card Physical Layer Specification 2.0" */ - rc = sd_send_if_cond(mci); - rc = sd_send_op_cond(mci); - if (rc && rc == -ETIMEDOUT) { - /* If the command timed out, we check for an MMC card */ + if (!host->no_sd) { + rc = sd_send_if_cond(mci); + rc = sd_send_op_cond(mci); + } + if (host->no_sd || rc == -ETIMEDOUT) { + /* If SD card initialization was skipped or if it timed out, + * we check for an MMC card */ dev_dbg(&mci->dev, "Card seems to be a MultiMediaCard\n"); rc = mmc_send_op_cond(mci); } @@ -1904,6 +1907,7 @@ void mci_of_parse_node(struct mci_host *host, } host->non_removable = of_property_read_bool(np, "non-removable"); + host->no_sd = of_property_read_bool(np, "no-sd"); } void mci_of_parse(struct mci_host *host) diff --git a/include/mci.h b/include/mci.h index d3115e8cc6..1f6533391a 100644 --- a/include/mci.h +++ b/include/mci.h @@ -403,6 +403,7 @@ struct mci_host { unsigned dsr_val; /**< optional dsr value */ int use_dsr; /**< optional dsr usage flag */ bool non_removable; /**< device is non removable */ + bool no_sd; /**< do not send SD commands during initialization */ struct regulator *supply; /** init the host interface */ -- cgit v1.2.3 From 81d6f55f4d05c781d77751f577ed488a314b4bb9 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Sun, 15 Oct 2017 13:16:31 +0200 Subject: UBI: attach: add missing newline at end of pr_err() This patch adds the missing newline at the end of the pr_err() statement. Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- drivers/mtd/ubi/attach.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c index b49842be39..ff4b4e7acb 100644 --- a/drivers/mtd/ubi/attach.c +++ b/drivers/mtd/ubi/attach.c @@ -782,7 +782,7 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr, pnum); ubi_err(ubi, "this may be a non-UBI PEB or a severe VID header corruption which requires manual inspection"); ubi_dump_vid_hdr(vid_hdr); - pr_err("hexdump of PEB %d offset %d, length %d", + pr_err("hexdump of PEB %d offset %d, length %d\n", pnum, ubi->leb_start, ubi->leb_size); ubi_dbg_print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, ubi->peb_buf, ubi->leb_size, 1); -- cgit v1.2.3 From bdcb3b0505e785e1b3264dab5fc23539ce201fe8 Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Wed, 26 Apr 2017 17:17:34 +0300 Subject: mtd: m25p80: make it possible to use 4K erase block We already have the MTD_SPI_NOR_USE_4K_SECTORS option handling in C code for 4K erase block support. Alas this 4K erase block support code can't be used because the MTD_SPI_NOR_USE_4K_SECTORS option support is missed in Kconfig. This patch imports necessary Kconfig MTD_SPI_NOR_USE_4K_SECTORS option declaration from linux v4.11-rc8. Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- drivers/mtd/spi-nor/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig index a84591fdd1..51cebcf35b 100644 --- a/drivers/mtd/spi-nor/Kconfig +++ b/drivers/mtd/spi-nor/Kconfig @@ -7,6 +7,19 @@ menuconfig MTD_SPI_NOR if MTD_SPI_NOR +config MTD_SPI_NOR_USE_4K_SECTORS + bool "Use small 4096 B erase sectors" + help + Many flash memories support erasing small (4096 B) sectors. Depending + on the usage this feature may provide performance gain in comparison + to erasing whole blocks (32/64 KiB). + Changing a small part of the flash's contents is usually faster with + small sectors. On the other hand erasing should be faster when using + 64 KiB block instead of 16 × 4 KiB sectors. + + Please note that some tools/drivers/filesystems may not work with + 4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum). + config SPI_CADENCE_QUADSPI tristate "Cadence Quad SPI controller" help -- cgit v1.2.3 From 3c31cae11390350a5d229a860a60986806fa5f19 Mon Sep 17 00:00:00 2001 From: Clément Leger Date: Tue, 10 Oct 2017 14:38:19 +0200 Subject: Marvell: implement marvell_of_reg_init From ed1cbcd05d5efeb4012d77a9a4ab9c1da0449bdc Mon Sep 17 00:00:00 2001 From: Clement Leger Date: Tue, 10 Oct 2017 14:29:49 +0200 Subject: [PATCH] Marvell: implement marvell_of_reg_init Implement marvell_of_reg_init in order to use marvell,reg-init property from device-tree. The code is taken from Linux kernel and slighlty modify to fit barebox structures. Signed-off-by: Sascha Hauer --- drivers/net/phy/marvell.c | 73 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index ea5a4a9be2..73d6453b36 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -175,13 +175,78 @@ static inline bool phy_interface_is_rgmii(struct phy_device *phydev) }; /* - * This same function in the Linux kernel parses the marvell,reg-init dt - * property and does the necessary register writes. It's kept as an exercise for - * a future user to implement this. :-) + * Set and/or override some configuration registers based on the + * marvell,reg-init property stored in the of_node for the phydev. + * + * marvell,reg-init = ,...; + * + * There may be one or more sets of : + * + * reg-page: which register bank to use. + * reg: the register. + * mask: if non-zero, ANDed with existing register value. + * value: ORed with the masked value and written to the regiser. + * */ static int marvell_of_reg_init(struct phy_device *phydev) { - return 0; + const __be32 *paddr; + int len, i, saved_page, current_page, page_changed, ret; + + if (!phydev->dev.device_node) + return 0; + + paddr = of_get_property(phydev->dev.device_node, + "marvell,reg-init", &len); + if (!paddr || len < (4 * sizeof(*paddr))) + return 0; + + saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE); + if (saved_page < 0) + return saved_page; + page_changed = 0; + current_page = saved_page; + + ret = 0; + len /= sizeof(*paddr); + for (i = 0; i < len - 3; i += 4) { + u16 reg_page = be32_to_cpup(paddr + i); + u16 reg = be32_to_cpup(paddr + i + 1); + u16 mask = be32_to_cpup(paddr + i + 2); + u16 val_bits = be32_to_cpup(paddr + i + 3); + int val; + + if (reg_page != current_page) { + current_page = reg_page; + page_changed = 1; + ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page); + if (ret < 0) + goto err; + } + + val = 0; + if (mask) { + val = phy_read(phydev, reg); + if (val < 0) { + ret = val; + goto err; + } + val &= mask; + } + val |= val_bits; + + ret = phy_write(phydev, reg, val); + if (ret < 0) + goto err; + + } +err: + if (page_changed) { + i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page); + if (ret == 0) + ret = i; + } + return ret; } static int m88e1121_config_aneg(struct phy_device *phydev) -- cgit v1.2.3 From 1cb2517f1b6715e15c5858947d5a1991b6c6c780 Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Mon, 9 Oct 2017 16:40:53 +0300 Subject: elf.h: Use EI_NIDENT instead of numeric value This is an adoption of the linux kernel commit | commit eb6900fbfa43cb50391b80b38608e25280705693 | Author: Cyrill Gorcunov | Date: Tue Apr 29 01:01:17 2008 -0700 | | ELF: Use EI_NIDENT instead of numeric value | | Signed-off-by: Cyrill Gorcunov | Signed-off-by: Andrew Morton | Signed-off-by: Linus Torvalds Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- include/elf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/elf.h b/include/elf.h index a749bec34e..ebcec7db0d 100644 --- a/include/elf.h +++ b/include/elf.h @@ -207,7 +207,7 @@ typedef struct elf32_hdr{ } Elf32_Ehdr; typedef struct elf64_hdr { - unsigned char e_ident[16]; /* ELF "magic number" */ + unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ Elf64_Half e_type; Elf64_Half e_machine; Elf64_Word e_version; -- cgit v1.2.3 From 25c3fb28d8017595942115d4dbffc16d96f43930 Mon Sep 17 00:00:00 2001 From: Steffen Trumtrar Date: Fri, 6 Oct 2017 11:53:02 +0200 Subject: regmap: port regmap_update_bits from linux Port the regmap_update_bits function from linux v4.14-rc1 to barebox. Signed-off-by: Steffen Trumtrar Signed-off-by: Sascha Hauer --- drivers/base/regmap/regmap.c | 29 +++++++++++++++++++++++++++++ include/regmap.h | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 52b7d88c74..67d95fe30a 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -136,6 +136,35 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val) return map->bus->reg_read(map->bus_context, reg, val); } +/** + * regmap_update_bits() - Perform a read/modify/write cycle on a register + * + * @map: Register map to update + * @reg: Register to update + * @mask: Bitmask to change + * @val: New value for bitmask + * + * Returns zero for success, a negative number on error. + */ +int regmap_update_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val) +{ + int ret; + unsigned int tmp, orig; + + ret = regmap_read(map, reg, &orig); + if (ret != 0) + return ret; + + tmp = orig & ~mask; + tmp |= val & mask; + + if (tmp != orig) + ret = regmap_write(map, reg, tmp); + + return ret; +} + /** * regmap_write_bits - write bits of a register in a map * diff --git a/include/regmap.h b/include/regmap.h index 9675a17b96..09b7b57d52 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -62,6 +62,7 @@ int regmap_get_reg_stride(struct regmap *map); int regmap_write_bits(struct regmap *map, unsigned int reg, unsigned int mask, unsigned int val); - +int regmap_update_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val); #endif /* __REGMAP_H */ -- cgit v1.2.3