Skip to contentSkip to conversation

dm: Print device name in dev_xxx like Linux

PATCH New Sean Anderson 9 participants 79 messages Sep 15, 2020 – Sep 30, 2020

Subsystems (27)
lore
Share & tools
lore
#0 lore raw

v2 cover dm: Print device name in dev_xxx like Linux

This series adds some additional information to dev_xxx output. This requires the first argument to dev_xxx to be a struct udevice. The first argument has never been used in U-Boot, so many drivers have some invalid calls. To fix these drivers, the following strategies were generally followed

* If there is a udevice already passed to the function, use it.
* If there is a udevice contained in a struct passed to the function, use it. When there are multiple possible devices, I have tried to use whatever "makes sense" given the content of the message.
* If there is no udevice passed to the function either directly or indirectly, but all the callers of said function can access a udevice, modify the function signature to pass in a udevice and use that.
* If the driver does not use DM, convert the log statements to log_xxx.
* If the driver uses DM only some of the time, use ifdefs to select an appropriate log function.

I have done a little bit of cleanup beyond these strategies, but for the most part I have tried to *only* to the minimum necessary. Many drivers could use a follow-up patch to convert their printf()s and debug()s to an appropriate log function.

I have tried to CC relevant maintainers/reviewers only for patches they maintain/review. If I have left someone out, please let me know and I will add them.

CI is passing at [1]. This does not necessarily mean that this series is free of bugs, so I would appreciate testing on hardware. During my refactoring, I noticed a few bugs like

	struct udevice *dev;

	if (some_condition)
		dev_err(dev, "Something went wrong\n");

	dev = some_function();

I have fixed such errors when I have encountered them, but they will not always warn or error on build.

Removal of the duplicate definitions in <linux/compat.h> will be done in a follow-up patch due to the already-large size of this series.

To test this series on sandbox, apply the following options in addition to sandbox_defconfig

CONFIG_LOGLEVEL=8
CONFIG_LOG=n
CONFIG_CMD_LOG=n
CONFIG_CMD_TPM=n

Note that there is a soft dependency on [2] if you would like to test this patch with CONFIG_LOG and a higher LOG_LEVEL than LOGL_INFO.

[1] https://dev.azure.com/seanga2/u-boot/_build/results?buildId=34&view=results
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=201343

Changes in v2:
- Support logging with struct device as well as struct udevice. A lot of drivers, especially USB gadgets, log with devices and not udevices. There is no major reason why they can't use udevice, but big changes like that are outside the scope of this series.
- Add some comments to __dev_printk and dev_printk_emit
- Handle struct device as well as struct udevice
- Match format strings for the NULL path to the regular path. This reduces the amount of duplicated strings.
- Print the device name before the driver name
- Many new patches added to fix build bugs

Sean Anderson (46):
dm: syscon: Fix calling dev_dbg with an uninitialized device
firmware: ti_sci: Fix not calling dev_err with a device
i2c: mxc: Fix dev_err being called on a nonexistant variable
mtd: nand: pxa3xx: Fix not calling dev_xxx with a device
mtd: nand: sunxi: Fix not calling dev_err with a device
mtd: spi: Include dm.h in spi-nor-core.c
mtd: spi: Fix logging in spi-nor-tiny
mtd: spi-nand: Fix not calling dev_err with a device
mmc: Add mmc_dev()
mmc: bcm2835-host: Fix not calling dev_dbg with a device
mmc: mtk-sd: Fix not calling dev_err with a device
mailbox: k3: Fix not calling dev_err with a device
nand: atmel: Fix not calling dev_xxx with a device
nand: brcmnand: Fix not calling dev_err() with a device
nand: vybrid: Re-introduce vf610_nfc.dev
net: bcm6368: Fix not calling dev_info with a device
net: mdio: Fix not calling dev_dbg with a device
net: mvneta: Fix not always calling dev_err with a device
net: mvneta: Convert netdev_xxx to dev_xxx
net: mvpp2: Fix not calling dev_xxx with a device
net: mvpp2: Convert netdev_xxx to dev_xxx linux/compat.h: Remove netdev_xxx functions
net: sunxi: Fix not calling dev_xxx with a device
net: sun8i_emac: Fix not calling dev_xxx with a device
net: ti: cpsw: Fix not calling dev_dbg with a device
phy: marvell: Fix not calling dev_err with a device
phy: rockchip: Fix not calling dev_err with a device
phy: sun4i-usb: Fix not calling dev_err with a device
phy: ti: Fix not calling dev_err with a device
phy: usbphyc: Fix not calling dev_err with a device
remoteproc: Remove unused function rproc_elf_sanity_check
remoteproc: k3-r5: Fix not calling dev_xxx with a device
remoteproc: k3: Fix not calling dev_xxx with a device
soc: qualcomm: Fix not calling dev_err with a device
spi: sunxi: Fix not calling dev_err with a device
spi: zynqmp_gqspi: Fix not calling dev_err with a device
sysreset: ti: Fix not calling dev_err with a device
usb: cdns3: Fix not calling dev_xxx with a device
usb: dwc2: Fix not calling dev_xxx with a device
usb: dwc3: Fix not calling dev_xxx with a device
usb: dwc3: ti: Fix not calling dev_err with a device
usb: dwc3: Don't include asm-generic/io.h
usb: musb-new: sunxi: Fix not calling dev_err with a device
video: stm32: Fix not calling dev_xxx with a device
dm: Use symbolic constants for log levels in dev_xxx
dm: Print device name in dev_xxx like Linux

 drivers/core/syscon-uclass.c              |   2 +-
 drivers/firmware/ti_sci.c                 |  23 ++--
 drivers/i2c/mxc_i2c.c                     |   7 +-
 drivers/mailbox/k3-sec-proxy.c            |   6 +-
 drivers/mmc/bcm2835_sdhost.c              |  34 +++---
 drivers/mmc/mtk-sd.c                      |  24 ++--
 drivers/mtd/nand/raw/atmel_nand.c         |  69 +++++++-----
 drivers/mtd/nand/raw/brcmnand/brcmnand.c  |  20 +---
 drivers/mtd/nand/raw/pxa3xx_nand.c        |  30 ++---
 drivers/mtd/nand/raw/sunxi_nand.c         |  45 ++++----
 drivers/mtd/nand/raw/vf610_nfc.c          |  38 ++++---
 drivers/mtd/nand/spi/core.c               |   8 +-
 drivers/mtd/spi/spi-nor-core.c            |   1 +
 drivers/mtd/spi/spi-nor-tiny.c            |  21 +++-
 drivers/net/bcm6368-eth.c                 |   3 +-
 drivers/net/mvneta.c                      |  56 +++++-----
 drivers/net/mvpp2.c                       |  87 ++++++++-------
 drivers/net/sun8i_emac.c                  |   9 +-
 drivers/net/sunxi_emac.c                  |   5 +-
 drivers/net/ti/cpsw.c                     |   6 +
 drivers/phy/allwinner/phy-sun4i-usb.c     |  12 +-
 drivers/phy/marvell/comphy_core.c         |   6 +-
 drivers/phy/phy-stm32-usbphyc.c           |   2 +-
 drivers/phy/phy-ti-am654.c                |   4 +-
 drivers/phy/rockchip/phy-rockchip-pcie.c  |  14 +--
 drivers/phy/rockchip/phy-rockchip-typec.c |   6 +-
 drivers/remoteproc/k3_system_controller.c |   9 +-
 drivers/remoteproc/rproc-elf-loader.c     |  16 ---
 drivers/remoteproc/ti_k3_r5f_rproc.c      |  24 ++--
 drivers/smem/msm_smem.c                   |   2 +-
 drivers/spi/spi-sunxi.c                   |   6 +-
 drivers/spi/zynqmp_gqspi.c                |   6 +-
 drivers/sysreset/sysreset-ti-sci.c        |   3 +-
 drivers/usb/cdns3/ep0.c                   |   5 +-
 drivers/usb/cdns3/gadget.c                |   3 +-
 drivers/usb/dwc3/core.c                   |  15 +--
 drivers/usb/dwc3/dwc3-generic.c           |   1 -
 drivers/usb/dwc3/ep0.c                    |   1 +
 drivers/usb/dwc3/gadget.c                 |  23 ++--
 drivers/usb/dwc3/ti_usb_phy.c             |   4 +-
 drivers/usb/host/dwc2.c                   |  39 ++++---
 drivers/usb/musb-new/sunxi.c              |   9 +-
 drivers/video/dw_mipi_dsi.c               |  24 ++--
 include/dm/device_compat.h                | 127 ++++++++++++++++------
 include/linux/compat.h                    |  19 ----
 include/mmc.h                             |   2 +
 include/remoteproc.h                      |  13 ---
 net/mdio-uclass.c                         |   4 +-
 48 files changed, 486 insertions(+), 407 deletions(-)
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 1/46 dm: syscon: Fix calling dev_dbg with an uninitialized device

We can't use dev_dbg here because we haven't bound to the device yet. Use log_debug instead.

---

Changes in v2:
- New

 drivers/core/syscon-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/core/syscon-uclass.c +1 -1
index b5cd763b6b..453933f59e 100644
@@ -66,7 +66,7 @@ static int syscon_probe_by_ofnode(ofnode node, struct udevice **devp)
 
 	/* found node with "syscon" compatible, not bounded to SYSCON UCLASS */
 	if (!ofnode_device_is_compatible(node, "syscon")) {
-		dev_dbg(dev, "invalid compatible for syscon device\n");
+		log_debug("invalid compatible for syscon device\n");
 		return -EINVAL;
 	}
 
Signature · 1 line
2.28.0
#2 lore raw

PATCH v2 1/46 dm: syscon: Fix calling dev_dbg with an uninitialized device

Hi Sean,

Quoted 31 lines

From: U-Boot <[email protected]> On Behalf Of Sean Anderson
Sent: mardi 15 septembre 2020 16:45

We can't use dev_dbg here because we haven't bound to the device yet. Use log_debug instead.

---

Changes in v2:
- New

 drivers/core/syscon-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/core/syscon-uclass.c index renamed from drivers/core/syscon-uclass.c +0 -0

b5cd763b6b..453933f59e 100644

drivers/core/syscon-uclass.c +0 -0
@@ -66,7 +66,7 @@ static int syscon_probe_by_ofnode(ofnode node, struct
 udevice **devp)
 
 	/* found node with "syscon" compatible, not bounded to SYSCON

UCLASS */

drivers/core/syscon-uclass.c +1 -2
 	if (!ofnode_device_is_compatible(node, "syscon")) {
-		dev_dbg(dev, "invalid compatible for syscon device\n");
+		log_debug("invalid compatible for syscon device\n");
 		return -EINVAL;
 	}
 
--
Quoted 1 line

2.28.0

As log API is used, the category could be indicated at the beginning of the files... before ' #include <log.h>'

+ #define LOG_CATEGORY UCLASS_SYSCON
+
#include <common.h>
#include <log.h>

Anyway

Thanks

Patrick

#3 lore raw

PATCH v2 1/46 dm: syscon: Fix calling dev_dbg with an uninitialized device

Quoted 38 lines · Patrick DELAUNAY

Hi Sean,

Quoted 31 lines

From: U-Boot <[email protected]> On Behalf Of Sean Anderson
Sent: mardi 15 septembre 2020 16:45

We can't use dev_dbg here because we haven't bound to the device yet. Use log_debug instead.

---

Changes in v2:
- New

 drivers/core/syscon-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/core/syscon-uclass.c index renamed from drivers/core/syscon-uclass.c +0 -0

b5cd763b6b..453933f59e 100644

drivers/core/syscon-uclass.c +0 -0
@@ -66,7 +66,7 @@ static int syscon_probe_by_ofnode(ofnode node, struct
 udevice **devp)
 
 	/* found node with "syscon" compatible, not bounded to SYSCON

UCLASS */

drivers/core/syscon-uclass.c +1 -2
 	if (!ofnode_device_is_compatible(node, "syscon")) {
-		dev_dbg(dev, "invalid compatible for syscon device\n");
+		log_debug("invalid compatible for syscon device\n");
 		return -EINVAL;
 	}
 
--
Quoted 1 line

2.28.0

As log API is used, the category could be indicated at the beginning of the files... before ' #include <log.h>'

Quoted 4 lines

+ #define LOG_CATEGORY UCLASS_SYSCON
+
#include <common.h>
#include <log.h>

Sure, I will include that in v3.

Quoted 8 lines

Anyway

Thanks

Patrick

#4 lore raw

PATCH v2 2/46 firmware: ti_sci: Fix not calling dev_err with a device

In reply to Sean Anderson

This converts calls to dev_err to get the device from ti_sci_info where appropriate.

---

Changes in v2:
- New

 drivers/firmware/ti_sci.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
drivers/firmware/ti_sci.c +16 -7
index e311f55ef8..a2beb0079d 100644
@@ -619,7 +619,7 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,
 
 	ret = ti_sci_do_xfer(info, xfer);
 	if (ret) {
-		dev_err(dev, "Mbox send fail %d\n", ret);
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
 		return ret;
 	}
 
@@ -1591,7 +1591,7 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)
 
 	ret = ti_sci_do_xfer(info, xfer);
 	if (ret) {
-		dev_err(dev, "Mbox send fail %d\n", ret);
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
 		return ret;
 	}
 
@@ -1639,7 +1639,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(dev, "Message alloc failed(%d)\n", ret);
+		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
 
@@ -1649,7 +1649,7 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,
 
 	ret = ti_sci_do_xfer(info, xfer);
 	if (ret) {
-		dev_err(dev, "Mbox send fail %d\n", ret);
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
 		goto fail;
 	}
 
@@ -1745,7 +1745,7 @@ static int ti_sci_cmd_query_msmc(const struct ti_sci_handle *handle,
 
 	ret = ti_sci_do_xfer(info, xfer);
 	if (ret) {
-		dev_err(dev, "Mbox send fail %d\n", ret);
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
 		return ret;
 	}
 
@@ -2229,6 +2229,14 @@ static int ti_sci_cmd_proc_shutdown_no_wait(const struct ti_sci_handle *handle,
 					    u8 proc_id)
 {
 	int ret;
+	struct ti_sci_info *info;
+
+	if (IS_ERR(handle))
+		return PTR_ERR(handle);
+	if (!handle)
+		return -EINVAL;
+
+	info = handle_to_ti_sci_info(handle);
 
 	/*
 	 * Send the core boot status wait message waiting for either WFE or
@@ -2554,7 +2562,8 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(
 				     (u32 *)&req, sizeof(req), sizeof(*resp));
 	if (IS_ERR(xfer)) {
 		ret = PTR_ERR(xfer);
-		dev_err(dev, "RX_FL_CFG: Message alloc failed(%d)\n", ret);
+		dev_err(info->dev, "RX_FL_CFG: Message alloc failed(%d)\n",
+			ret);
 		return ret;
 	}
 
@@ -2583,7 +2592,7 @@ static int ti_sci_cmd_rm_udmap_rx_flow_cfg(
 
 	ret = ti_sci_do_xfer(info, xfer);
 	if (ret) {
-		dev_err(dev, "RX_FL_CFG: Mbox send fail %d\n", ret);
+		dev_err(info->dev, "RX_FL_CFG: Mbox send fail %d\n", ret);
 		goto fail;
 	}
 
Signature · 1 line
2.28.0
maintainer
#5 lore raw

PATCH v2 2/46 firmware: ti_sci: Fix not calling dev_err with a device

Quoted 18 lines · Sean Anderson

This converts calls to dev_err to get the device from ti_sci_info where appropriate.

---

Changes in v2:
- New

 drivers/firmware/ti_sci.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
drivers/firmware/ti_sci.c +0 -0
index e311f55ef8..a2beb0079d 100644

drivers/firmware/ti_sci.c static int ti_sci_get_device_state(const struct ti_sci_handle *handle, · line 625

Quoted 8 lines
drivers/firmware/ti_sci.c +1 -1
@@ -619,7 +619,7 @@ static int ti_sci_get_device_state(const struct ti_sci_handle *handle,
 
 	ret = ti_sci_do_xfer(info, xfer);
 	if (ret) {
-		dev_err(dev, "Mbox send fail %d\n", ret);
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
 		return ret;
 	}
 

[...]
Aaah. Thanks.

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#6 lore raw

PATCH v2 3/46 i2c: mxc: Fix dev_err being called on a nonexistant variable

In reply to Sean Anderson

The udevice we are working with is called bus and not dev.

---

Changes in v2:
- New

 drivers/i2c/mxc_i2c.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/i2c/mxc_i2c.c +5 -2
index e3d980a9df..7609594bd0 100644
@@ -941,7 +941,8 @@ static int mxc_i2c_probe(struct udevice *bus)
 	 */
 	ret = fdt_stringlist_search(fdt, node, "pinctrl-names", "gpio");
 	if (ret < 0) {
-		debug("i2c bus %d@0x%2lx, no gpio pinctrl state.\n", bus->seq, i2c_bus->base);
+		debug("i2c bus %d at 0x%2lx, no gpio pinctrl state.\n",
+		      bus->seq, i2c_bus->base);
 	} else {
 		ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
 				"scl-gpios", 0, &i2c_bus->scl_gpio,
@@ -952,7 +953,9 @@ static int mxc_i2c_probe(struct udevice *bus)
 		if (!dm_gpio_is_valid(&i2c_bus->sda_gpio) ||
 		    !dm_gpio_is_valid(&i2c_bus->scl_gpio) ||
 		    ret || ret2) {
-			dev_err(dev, "i2c bus %d at %lu, fail to request scl/sda gpio\n", bus->seq, i2c_bus->base);
+			dev_err(bus,
+				"i2c bus %d at %lu, fail to request scl/sda gpio\n",
+				bus->seq, i2c_bus->base);
 			return -EINVAL;
 		}
 	}
Signature · 1 line
2.28.0
#8 lore raw

PATCH v2 3/46 i2c: mxc: Fix dev_err being called on a nonexistant variable

In reply to Sean Anderson

Hello Sean,

Am 15.09.2020 um 16:44 schrieb Sean Anderson:

Quoted 10 lines

The udevice we are working with is called bus and not dev.

---

Changes in v2:
- New

  drivers/i2c/mxc_i2c.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#9 lore raw

PATCH v2 4/46 mtd: nand: pxa3xx: Fix not calling dev_xxx with a device

In reply to Sean Anderson

Use the device from any mtd already available, or from the active mtd via pxa3xx_nand_info if one is not.

---

Changes in v2:
- New

 drivers/mtd/nand/raw/pxa3xx_nand.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/mtd/nand/raw/pxa3xx_nand.c +15 -15
index a30e82166b..5fb3081c83 100644
@@ -512,7 +512,7 @@ static int pxa3xx_nand_init_timings(struct pxa3xx_nand_host *host)
 		}
 
 		if (i == ntypes) {
-			dev_err(&info->pdev->dev, "Error: timings not found\n");
+			dev_err(mtd->dev, "Error: timings not found\n");
 			return -EINVAL;
 		}
 
@@ -603,7 +603,7 @@ static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
 			ts = get_timer(0);
 			while (!(nand_readl(info, NDSR) & NDSR_RDDREQ)) {
 				if (get_timer(ts) > TIMEOUT_DRAIN_FIFO) {
-					dev_err(&info->pdev->dev,
+					dev_err(info->controller.active->mtd.dev,
 						"Timeout on RDDREQ while draining the FIFO\n");
 					return;
 				}
@@ -656,8 +656,8 @@ static void handle_data_pio(struct pxa3xx_nand_info *info)
 				   DIV_ROUND_UP(info->step_spare_size, 4));
 		break;
 	default:
-		dev_err(&info->pdev->dev, "%s: invalid state %d\n", __func__,
-				info->state);
+		dev_err(info->controller.active->mtd.dev,
+			"%s: invalid state %d\n", __func__, info->state);
 		BUG();
 	}
 
@@ -1027,7 +1027,7 @@ static int prepare_set_command(struct pxa3xx_nand_info *info, int command,
 
 	default:
 		exec_cmd = 0;
-		dev_err(&info->pdev->dev, "non-supported command %x\n",
+		dev_err(mtd->dev, "non-supported command %x\n",
 			command);
 		break;
 	}
@@ -1087,7 +1087,7 @@ static void nand_cmdfunc(struct mtd_info *mtd, unsigned command,
 				break;
 
 			if (get_timer(ts) > CHIP_DELAY_TIMEOUT) {
-				dev_err(&info->pdev->dev, "Wait timeout!!!\n");
+				dev_err(mtd->dev, "Wait timeout!!!\n");
 				return;
 			}
 		}
@@ -1180,7 +1180,7 @@ static void nand_cmdfunc_extended(struct mtd_info *mtd,
 				break;
 
 			if (get_timer(ts) > CHIP_DELAY_TIMEOUT) {
-				dev_err(&info->pdev->dev, "Wait timeout!!!\n");
+				dev_err(mtd->dev, "Wait timeout!!!\n");
 				return;
 			}
 		}
@@ -1426,7 +1426,7 @@ static int pxa3xx_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this)
 				break;
 
 			if (get_timer(ts) > CHIP_DELAY_TIMEOUT) {
-				dev_err(&info->pdev->dev, "Ready timeout!!!\n");
+				dev_err(mtd->dev, "Ready timeout!!!\n");
 				return NAND_STATUS_FAIL;
 			}
 		}
@@ -1633,7 +1633,7 @@ static int pxa_ecc_init(struct pxa3xx_nand_info *info,
 		ecc->strength = 16;
 
 	} else {
-		dev_err(&info->pdev->dev,
+		dev_err(info->controller.active->mtd.dev,
 			"ECC strength %d at page size %d is not supported\n",
 			strength, page_size);
 		return -ENODEV;
@@ -1659,8 +1659,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
 			return ret;
 		ret = pxa3xx_nand_sensing(host);
 		if (ret) {
-			dev_info(&info->pdev->dev,
-				 "There is no chip on cs %d!\n",
+			dev_info(mtd->dev, "There is no chip on cs %d!\n",
 				 info->cs);
 			return ret;
 		}
@@ -1676,7 +1675,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
 	if (!pdata->keep_config) {
 		ret = pxa3xx_nand_init_timings(host);
 		if (ret) {
-			dev_err(&info->pdev->dev,
+			dev_err(mtd->dev,
 				"Failed to set timings: %d\n", ret);
 			return ret;
 		}
@@ -1720,7 +1719,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
 		if (info->variant == PXA3XX_NAND_VARIANT_ARMADA370) {
 			chip->cmdfunc = nand_cmdfunc_extended;
 		} else {
-			dev_err(&info->pdev->dev,
+			dev_err(mtd->dev,
 				"unsupported page size on this variant\n");
 			return -ENODEV;
 		}
@@ -1873,6 +1872,7 @@ static int pxa3xx_nand_probe_dt(struct pxa3xx_nand_info *info)
 
 static int pxa3xx_nand_probe(struct pxa3xx_nand_info *info)
 {
+	struct mtd_info *mtd = &info->controller.active->mtd;
 	struct pxa3xx_nand_platform_data *pdata;
 	int ret, cs, probe_success;
 
@@ -1884,7 +1884,7 @@ static int pxa3xx_nand_probe(struct pxa3xx_nand_info *info)
 
 	ret = alloc_nand_resource(info);
 	if (ret) {
-		dev_err(&pdev->dev, "alloc nand resource failed\n");
+		dev_err(mtd->dev, "alloc nand resource failed\n");
 		return ret;
 	}
 
@@ -1901,7 +1901,7 @@ static int pxa3xx_nand_probe(struct pxa3xx_nand_info *info)
 		info->cs = cs;
 		ret = pxa3xx_nand_scan(mtd);
 		if (ret) {
-			dev_info(&pdev->dev, "failed to scan nand at cs %d\n",
+			dev_info(mtd->dev, "failed to scan nand at cs %d\n",
 				 cs);
 			continue;
 		}
Signature · 1 line
2.28.0
#10 lore raw

PATCH v2 5/46 mtd: nand: sunxi: Fix not calling dev_err with a device

In reply to Sean Anderson

Usually the device is gotten from sunxi_nfc. This is a struct device and not a struct udevice, but the whole driver seems to be written wihout DM anyway...

In a few instances, this patch modifies functions to take an nfc to log with. In once instance we use mtd_info's device since there is no nfc.

---

Changes in v2:
- New

 drivers/mtd/nand/raw/sunxi_nand.c | 45 ++++++++++++++++---------------
 1 file changed, 23 insertions(+), 22 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +23 -22
index 004b6f17a5..12fc065b32 100644
@@ -1226,7 +1226,8 @@ static int _sunxi_nand_lookup_timing(const s32 *lut, int lut_size, u32 duration,
 #define sunxi_nand_lookup_timing(l, p, c) \
 			_sunxi_nand_lookup_timing(l, ARRAY_SIZE(l), p, c)
 
-static int sunxi_nand_chip_set_timings(struct sunxi_nand_chip *chip,
+static int sunxi_nand_chip_set_timings(struct sunxi_nfc *nfc,
+				       struct sunxi_nand_chip *chip,
 				       const struct nand_sdr_timings *timings)
 {
 	u32 min_clk_period = 0;
@@ -1349,7 +1350,8 @@ static int sunxi_nand_chip_set_timings(struct sunxi_nand_chip *chip,
 	return 0;
 }
 
-static int sunxi_nand_chip_init_timings(struct sunxi_nand_chip *chip)
+static int sunxi_nand_chip_init_timings(struct sunxi_nfc *nfc,
+					struct sunxi_nand_chip *chip)
 {
 	struct mtd_info *mtd = nand_to_mtd(&chip->nand);
 	const struct nand_sdr_timings *timings;
@@ -1384,7 +1386,7 @@ static int sunxi_nand_chip_init_timings(struct sunxi_nand_chip *chip)
 	if (IS_ERR(timings))
 		return PTR_ERR(timings);
 
-	return sunxi_nand_chip_set_timings(chip, timings);
+	return sunxi_nand_chip_set_timings(nfc, chip, timings);
 }
 
 static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
@@ -1423,7 +1425,7 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
 	}
 
 	if (i >= ARRAY_SIZE(strengths)) {
-		dev_err(nfc->dev, "unsupported strength\n");
+		dev_err(mtd->dev, "unsupported strength\n");
 		ret = -ENOTSUPP;
 		goto err;
 	}
@@ -1619,7 +1621,7 @@ static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum)
 
 	nsels /= sizeof(u32);
 	if (!nsels || nsels > 8) {
-		dev_err(dev, "invalid reg property size\n");
+		dev_err(nfc->dev, "invalid reg property size\n");
 		return -EINVAL;
 	}
 
@@ -1627,7 +1629,7 @@ static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum)
 		       (nsels * sizeof(struct sunxi_nand_chip_sel)),
 		       GFP_KERNEL);
 	if (!chip) {
-		dev_err(dev, "could not allocate chip\n");
+		dev_err(nfc->dev, "could not allocate chip\n");
 		return -ENOMEM;
 	}
 
@@ -1641,14 +1643,14 @@ static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum)
 
 	ret = fdtdec_get_int_array(gd->fdt_blob, node, "reg", cs, nsels);
 	if (ret) {
-		dev_err(dev, "could not retrieve reg property: %d\n", ret);
+		dev_err(nfc->dev, "could not retrieve reg property: %d\n", ret);
 		return ret;
 	}
 
 	ret = fdtdec_get_int_array(gd->fdt_blob, node, "allwinner,rb", rb,
 				   nsels);
 	if (ret) {
-		dev_err(dev, "could not retrieve reg property: %d\n", ret);
+		dev_err(nfc->dev, "could not retrieve reg property: %d\n", ret);
 		return ret;
 	}
 
@@ -1656,14 +1658,13 @@ static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum)
 		int tmp = cs[i];
 
 		if (tmp > NFC_MAX_CS) {
-			dev_err(dev,
-				"invalid reg value: %u (max CS = 7)\n",
-				tmp);
+			dev_err(nfc->dev,
+				"invalid reg value: %u (max CS = 7)\n", tmp);
 			return -EINVAL;
 		}
 
 		if (test_and_set_bit(tmp, &nfc->assigned_cs)) {
-			dev_err(dev, "CS %d already assigned\n", tmp);
+			dev_err(nfc->dev, "CS %d already assigned\n", tmp);
 			return -EINVAL;
 		}
 
@@ -1688,15 +1689,15 @@ static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum)
 	timings = onfi_async_timing_mode_to_sdr_timings(0);
 	if (IS_ERR(timings)) {
 		ret = PTR_ERR(timings);
-		dev_err(dev,
+		dev_err(nfc->dev,
 			"could not retrieve timings for ONFI mode 0: %d\n",
 			ret);
 		return ret;
 	}
 
-	ret = sunxi_nand_chip_set_timings(chip, timings);
+	ret = sunxi_nand_chip_set_timings(nfc, chip, timings);
 	if (ret) {
-		dev_err(dev, "could not configure chip timings: %d\n", ret);
+		dev_err(nfc->dev, "could not configure chip timings: %d\n", ret);
 		return ret;
 	}
 
@@ -1729,27 +1730,27 @@ static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum)
 
 	nand->options |= NAND_SUBPAGE_READ;
 
-	ret = sunxi_nand_chip_init_timings(chip);
+	ret = sunxi_nand_chip_init_timings(nfc, chip);
 	if (ret) {
-		dev_err(dev, "could not configure chip timings: %d\n", ret);
+		dev_err(nfc->dev, "could not configure chip timings: %d\n", ret);
 		return ret;
 	}
 
 	ret = sunxi_nand_ecc_init(mtd, &nand->ecc);
 	if (ret) {
-		dev_err(dev, "ECC init failed: %d\n", ret);
+		dev_err(nfc->dev, "ECC init failed: %d\n", ret);
 		return ret;
 	}
 
 	ret = nand_scan_tail(mtd);
 	if (ret) {
-		dev_err(dev, "nand_scan_tail failed: %d\n", ret);
+		dev_err(nfc->dev, "nand_scan_tail failed: %d\n", ret);
 		return ret;
 	}
 
 	ret = nand_register(devnum, mtd);
 	if (ret) {
-		dev_err(dev, "failed to register mtd device: %d\n", ret);
+		dev_err(nfc->dev, "failed to register mtd device: %d\n", ret);
 		return ret;
 	}
 
@@ -1769,7 +1770,7 @@ static int sunxi_nand_chips_init(int node, struct sunxi_nfc *nfc)
 		i++;
 
 	if (i > 8) {
-		dev_err(dev, "too many NAND chips: %d (max = 8)\n", i);
+		dev_err(nfc->dev, "too many NAND chips: %d (max = 8)\n", i);
 		return -EINVAL;
 	}
 
@@ -1841,7 +1842,7 @@ void sunxi_nand_init(void)
 
 	ret = sunxi_nand_chips_init(node, nfc);
 	if (ret) {
-		dev_err(dev, "failed to init nand chips\n");
+		dev_err(nfc->dev, "failed to init nand chips\n");
 		goto err;
 	}
 
Signature · 1 line
2.28.0
#11 lore raw

PATCH v2 6/46 mtd: spi: Include dm.h in spi-nor-core.c

In reply to Sean Anderson

This header is needed so struct udevice can be used in dev_xxx().

---

Changes in v2:
- New

 drivers/mtd/spi/spi-nor-core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi/spi-nor-core.c +1 -0
index 0113e70037..e16b0e1462 100644
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <log.h>
+#include <dm.h>
 #include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/bitops.h>
Signature · 1 line
2.28.0
#12 lore raw

PATCH v2 7/46 mtd: spi: Fix logging in spi-nor-tiny

In reply to Sean Anderson

This fixes dev_xxx() not always being called with a device. In spi_nor_reg_read, a the slave device may not always be available, so we use bus and cs instead.

---

Changes in v2:
- New

 drivers/mtd/spi/spi-nor-tiny.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/mtd/spi/spi-nor-tiny.c +16 -5
index fa26ea33c8..07c8c7b82b 100644
@@ -55,9 +55,19 @@ static int spi_nor_read_reg(struct spi_nor *nor, u8 code, u8 *val, int len)
 	int ret;
 
 	ret = spi_nor_read_write_reg(nor, &op, val);
-	if (ret < 0)
-		dev_dbg(&flash->spimem->spi->dev, "error %d reading %x\n", ret,
+	if (ret < 0) {
+		/*
+		 * spi_slave does not have a struct udevice member without DM,
+		 * so use the bus and cs instead.
+		 */
+#if CONFIG_IS_ENABLED(DM_SPI)
+		dev_dbg(nor->spi->dev, "error %d reading %x\n", ret,
 			code);
+#else
+		log_debug("spi%u.%u: error %d reading %x\n",
+			  nor->spi->bus, nor->spi->cs, ret, code);
+#endif
+	}
 
 	return ret;
 }
@@ -512,7 +522,8 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor)
 	/* Check current Quad Enable bit value. */
 	ret = read_cr(nor);
 	if (ret < 0) {
-		dev_dbg(dev, "error while reading configuration register\n");
+		dev_dbg(nor->dev,
+			"error while reading configuration register\n");
 		return -EINVAL;
 	}
 
@@ -524,7 +535,7 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor)
 	/* Keep the current value of the Status Register. */
 	ret = read_sr(nor);
 	if (ret < 0) {
-		dev_dbg(dev, "error while reading status register\n");
+		dev_dbg(nor->dev, "error while reading status register\n");
 		return -EINVAL;
 	}
 	sr_cr[0] = ret;
@@ -785,7 +796,7 @@ int spi_nor_scan(struct spi_nor *nor)
 	}
 
 	if (nor->addr_width > SPI_NOR_MAX_ADDR_WIDTH) {
-		dev_dbg(dev, "address width is too large: %u\n",
+		dev_dbg(nor->dev, "address width is too large: %u\n",
 			nor->addr_width);
 		return -EINVAL;
 	}
Signature · 1 line
2.28.0
#13 lore raw

PATCH v2 8/46 mtd: spi-nand: Fix not calling dev_err with a device

In reply to Sean Anderson

Get it from spinand->slave->dev. Another option would be to use spinand_to_mtd(spinand)->dev, but this is what the existing code uses.

---

Changes in v2:
- New

 drivers/mtd/nand/spi/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/nand/spi/core.c +4 -4
index 93371fdde0..8c7e07d463 100644
@@ -984,13 +984,13 @@ static int spinand_detect(struct spinand_device *spinand)
 
 	ret = spinand_manufacturer_detect(spinand);
 	if (ret) {
-		dev_err(dev, "unknown raw ID %*phN\n", SPINAND_MAX_ID_LEN,
-			spinand->id.data);
+		dev_err(spinand->slave->dev, "unknown raw ID %*phN\n",
+			SPINAND_MAX_ID_LEN, spinand->id.data);
 		return ret;
 	}
 
 	if (nand->memorg.ntargets > 1 && !spinand->select_target) {
-		dev_err(dev,
+		dev_err(spinand->slave->dev,
 			"SPI NANDs with more than one die must implement ->select_target()\n");
 		return -EINVAL;
 	}
@@ -1076,7 +1076,7 @@ static int spinand_init(struct spinand_device *spinand)
 
 	ret = spinand_manufacturer_init(spinand);
 	if (ret) {
-		dev_err(dev,
+		dev_err(spinand->slave->dev,
 			"Failed to initialize the SPI NAND chip (err = %d)\n",
 			ret);
 		goto err_free_bufs;
Signature · 1 line
2.28.0
#14 lore raw

PATCH v2 8/46 mtd: spi-nand: Fix not calling dev_err with a device

Quoted 4 lines · Sean Anderson

Get it from spinand->slave->dev. Another option would be to use spinand_to_mtd(spinand)->dev, but this is what the existing code uses.

Quoted 8 lines

---

Changes in v2:
- New

 drivers/mtd/nand/spi/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
#15 lore raw

PATCH v2 9/46 mmc: Add mmc_dev()

In reply to Sean Anderson

This macro is necessary for arasan_zynqmp_dll_reset to compile.

---

Changes in v2:
- New

 include/mmc.h | 2 ++
 1 file changed, 2 insertions(+)
include/mmc.h +2 -0
index 82562193cc..75bcaaf6b3 100644
@@ -888,6 +888,8 @@ void mmc_set_preinit(struct mmc *mmc, int preinit);
 #define mmc_host_is_spi(mmc)	0
 #endif
 
+#define mmc_dev(x)	((x)->dev)
+
 void board_mmc_power_init(void);
 int board_mmc_init(struct bd_info *bis);
 int cpu_mmc_init(struct bd_info *bis);
Signature · 1 line
2.28.0
#17 lore raw

PATCH v2 10/46 mmc: bcm2835-host: Fix not calling dev_dbg with a device

In reply to Sean Anderson

dev needs to be qualified as a member of host.

---

Changes in v2:
- New

 drivers/mmc/bcm2835_sdhost.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/mmc/bcm2835_sdhost.c +17 -17
index b793028ab5..ea8b385d7e 100644
@@ -185,22 +185,22 @@ struct bcm2835_host {
 
 static void bcm2835_dumpregs(struct bcm2835_host *host)
 {
-	dev_dbg(dev, "=========== REGISTER DUMP ===========\n");
-	dev_dbg(dev, "SDCMD  0x%08x\n", readl(host->ioaddr + SDCMD));
-	dev_dbg(dev, "SDARG  0x%08x\n", readl(host->ioaddr + SDARG));
-	dev_dbg(dev, "SDTOUT 0x%08x\n", readl(host->ioaddr + SDTOUT));
-	dev_dbg(dev, "SDCDIV 0x%08x\n", readl(host->ioaddr + SDCDIV));
-	dev_dbg(dev, "SDRSP0 0x%08x\n", readl(host->ioaddr + SDRSP0));
-	dev_dbg(dev, "SDRSP1 0x%08x\n", readl(host->ioaddr + SDRSP1));
-	dev_dbg(dev, "SDRSP2 0x%08x\n", readl(host->ioaddr + SDRSP2));
-	dev_dbg(dev, "SDRSP3 0x%08x\n", readl(host->ioaddr + SDRSP3));
-	dev_dbg(dev, "SDHSTS 0x%08x\n", readl(host->ioaddr + SDHSTS));
-	dev_dbg(dev, "SDVDD  0x%08x\n", readl(host->ioaddr + SDVDD));
-	dev_dbg(dev, "SDEDM  0x%08x\n", readl(host->ioaddr + SDEDM));
-	dev_dbg(dev, "SDHCFG 0x%08x\n", readl(host->ioaddr + SDHCFG));
-	dev_dbg(dev, "SDHBCT 0x%08x\n", readl(host->ioaddr + SDHBCT));
-	dev_dbg(dev, "SDHBLC 0x%08x\n", readl(host->ioaddr + SDHBLC));
-	dev_dbg(dev, "===========================================\n");
+	dev_dbg(host->dev, "=========== REGISTER DUMP ===========\n");
+	dev_dbg(host->dev, "SDCMD  0x%08x\n", readl(host->ioaddr + SDCMD));
+	dev_dbg(host->dev, "SDARG  0x%08x\n", readl(host->ioaddr + SDARG));
+	dev_dbg(host->dev, "SDTOUT 0x%08x\n", readl(host->ioaddr + SDTOUT));
+	dev_dbg(host->dev, "SDCDIV 0x%08x\n", readl(host->ioaddr + SDCDIV));
+	dev_dbg(host->dev, "SDRSP0 0x%08x\n", readl(host->ioaddr + SDRSP0));
+	dev_dbg(host->dev, "SDRSP1 0x%08x\n", readl(host->ioaddr + SDRSP1));
+	dev_dbg(host->dev, "SDRSP2 0x%08x\n", readl(host->ioaddr + SDRSP2));
+	dev_dbg(host->dev, "SDRSP3 0x%08x\n", readl(host->ioaddr + SDRSP3));
+	dev_dbg(host->dev, "SDHSTS 0x%08x\n", readl(host->ioaddr + SDHSTS));
+	dev_dbg(host->dev, "SDVDD  0x%08x\n", readl(host->ioaddr + SDVDD));
+	dev_dbg(host->dev, "SDEDM  0x%08x\n", readl(host->ioaddr + SDEDM));
+	dev_dbg(host->dev, "SDHCFG 0x%08x\n", readl(host->ioaddr + SDHCFG));
+	dev_dbg(host->dev, "SDHBCT 0x%08x\n", readl(host->ioaddr + SDHBCT));
+	dev_dbg(host->dev, "SDHBLC 0x%08x\n", readl(host->ioaddr + SDHBLC));
+	dev_dbg(host->dev, "===========================================\n");
 }
 
 static void bcm2835_reset_internal(struct bcm2835_host *host)
@@ -738,7 +738,7 @@ static void bcm2835_add_host(struct bcm2835_host *host)
 	cfg->f_min = host->max_clk / SDCDIV_MAX_CDIV;
 	cfg->b_max = 65535;
 
-	dev_dbg(dev, "f_max %d, f_min %d\n",
+	dev_dbg(host->dev, "f_max %d, f_min %d\n",
 		cfg->f_max, cfg->f_min);
 
 	/* host controller capabilities */
Signature · 1 line
2.28.0
#18 lore raw

PATCH v2 11/46 mmc: mtk-sd: Fix not calling dev_err with a device

In reply to Sean Anderson

This adds a udevice parameter to get_best_delay and msdc_set_mclk so they can call dev_err properly.

---

Changes in v2:
- New

 drivers/mmc/mtk-sd.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/mmc/mtk-sd.c +13 -11
index bd1fb09d1c..30fe7a0aa2 100644
@@ -774,7 +774,8 @@ static void msdc_set_buswidth(struct msdc_host *host, u32 width)
 	writel(val, &host->base->sdc_cfg);
 }
 
-static void msdc_set_mclk(struct msdc_host *host, enum bus_mode timing, u32 hz)
+static void msdc_set_mclk(struct udevice *dev,
+			  struct msdc_host *host, enum bus_mode timing, u32 hz)
 {
 	u32 mode;
 	u32 div;
@@ -897,7 +898,7 @@ static int msdc_ops_set_ios(struct udevice *dev)
 		clock = mmc->cfg->f_min;
 
 	if (host->mclk != clock || host->timing != mmc->selected_mode)
-		msdc_set_mclk(host, mmc->selected_mode, clock);
+		msdc_set_mclk(dev, host, mmc->selected_mode, clock);
 
 	return 0;
 }
@@ -957,7 +958,8 @@ static int get_delay_len(u32 delay, u32 start_bit)
 	return PAD_DELAY_MAX - start_bit;
 }
 
-static struct msdc_delay_phase get_best_delay(struct msdc_host *host, u32 delay)
+static struct msdc_delay_phase get_best_delay(struct udevice *dev,
+					      struct msdc_host *host, u32 delay)
 {
 	int start = 0, len = 0;
 	int start_final = 0, len_final = 0;
@@ -1067,7 +1069,7 @@ static int hs400_tune_response(struct udevice *dev, u32 opcode)
 		}
 	}
 
-	final_cmd_delay = get_best_delay(host, cmd_delay);
+	final_cmd_delay = get_best_delay(dev, host, cmd_delay);
 	clrsetbits_le32(tune_reg, PAD_CMD_TUNE_RX_DLY3,
 			final_cmd_delay.final_phase <<
 			PAD_CMD_TUNE_RX_DLY3_S);
@@ -1117,7 +1119,7 @@ static int msdc_tune_response(struct udevice *dev, u32 opcode)
 		}
 	}
 
-	final_rise_delay = get_best_delay(host, rise_delay);
+	final_rise_delay = get_best_delay(dev, host, rise_delay);
 	/* if rising edge has enough margin, do not scan falling edge */
 	if (final_rise_delay.maxlen >= 12 ||
 	    (final_rise_delay.start == 0 && final_rise_delay.maxlen >= 4))
@@ -1139,7 +1141,7 @@ static int msdc_tune_response(struct udevice *dev, u32 opcode)
 		}
 	}
 
-	final_fall_delay = get_best_delay(host, fall_delay);
+	final_fall_delay = get_best_delay(dev, host, fall_delay);
 
 skip_fall:
 	final_maxlen = max(final_rise_delay.maxlen, final_fall_delay.maxlen);
@@ -1171,7 +1173,7 @@ skip_fall:
 
 	dev_err(dev, "Final internal delay: 0x%x\n", internal_delay);
 
-	internal_delay_phase = get_best_delay(host, internal_delay);
+	internal_delay_phase = get_best_delay(dev, host, internal_delay);
 	clrsetbits_le32(tune_reg, MSDC_PAD_TUNE_CMDRRDLY_M,
 			internal_delay_phase.final_phase <<
 			MSDC_PAD_TUNE_CMDRRDLY_S);
@@ -1214,7 +1216,7 @@ static int msdc_tune_data(struct udevice *dev, u32 opcode)
 		}
 	}
 
-	final_rise_delay = get_best_delay(host, rise_delay);
+	final_rise_delay = get_best_delay(dev, host, rise_delay);
 	if (final_rise_delay.maxlen >= 12 ||
 	    (final_rise_delay.start == 0 && final_rise_delay.maxlen >= 4))
 		goto skip_fall;
@@ -1237,7 +1239,7 @@ static int msdc_tune_data(struct udevice *dev, u32 opcode)
 		}
 	}
 
-	final_fall_delay = get_best_delay(host, fall_delay);
+	final_fall_delay = get_best_delay(dev, host, fall_delay);
 
 skip_fall:
 	final_maxlen = max(final_rise_delay.maxlen, final_fall_delay.maxlen);
@@ -1293,7 +1295,7 @@ static int msdc_tune_together(struct udevice *dev, u32 opcode)
 			rise_delay |= (1 << i);
 	}
 
-	final_rise_delay = get_best_delay(host, rise_delay);
+	final_rise_delay = get_best_delay(dev, host, rise_delay);
 	if (final_rise_delay.maxlen >= 12 ||
 	    (final_rise_delay.start == 0 && final_rise_delay.maxlen >= 4))
 		goto skip_fall;
@@ -1309,7 +1311,7 @@ static int msdc_tune_together(struct udevice *dev, u32 opcode)
 			fall_delay |= (1 << i);
 	}
 
-	final_fall_delay = get_best_delay(host, fall_delay);
+	final_fall_delay = get_best_delay(dev, host, fall_delay);
 
 skip_fall:
 	final_maxlen = max(final_rise_delay.maxlen, final_fall_delay.maxlen);
Signature · 1 line
2.28.0
#19 lore raw

PATCH v2 11/46 mmc: mtk-sd: Fix not calling dev_err with a device

Quoted 4 lines · Sean Anderson

This adds a udevice parameter to get_best_delay and msdc_set_mclk so they can call dev_err properly.

Quoted 8 lines

---

Changes in v2:
- New

 drivers/mmc/mtk-sd.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
#20 lore raw

PATCH v2 12/46 mailbox: k3: Fix not calling dev_err with a device

In reply to Sean Anderson

dev needs to be gotten from mbox_chan

---

Changes in v2:
- New

 drivers/mailbox/k3-sec-proxy.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mailbox/k3-sec-proxy.c +4 -2
index 3f9afaed32..27ccc6eab0 100644
@@ -212,14 +212,16 @@ static int k3_sec_proxy_send(struct mbox_chan *chan, const void *data)
 
 	ret = k3_sec_proxy_verify_thread(spt, THREAD_IS_TX);
 	if (ret) {
-		dev_err(dev, "%s: Thread%d verification failed. ret = %d\n",
+		dev_err(chan->dev,
+			"%s: Thread%d verification failed. ret = %d\n",
 			__func__, spt->id, ret);
 		return ret;
 	}
 
 	/* Check the message size. */
 	if (msg->len > spm->desc->max_msg_size) {
-		printf("%s: Thread %ld message length %zu > max msg size %d\n",
+		dev_err(chan->dev,
+			"%s: Thread %ld message length %zu > max msg size %d\n",
 		       __func__, chan->id, msg->len, spm->desc->max_msg_size);
 		return -EINVAL;
 	}
Signature · 1 line
2.28.0
#22 lore raw

PATCH v2 13/46 nand: atmel: Fix not calling dev_xxx with a device

In reply to Sean Anderson

Use mtd_info to get a device to log with.

---

Changes in v2:
- New

 drivers/mtd/nand/raw/atmel_nand.c | 69 +++++++++++++++++--------------
 1 file changed, 39 insertions(+), 30 deletions(-)
drivers/mtd/nand/raw/atmel_nand.c +39 -30
index 5e95901e27..abc432c862 100644
@@ -424,7 +424,8 @@ static int pmecc_err_location(struct mtd_info *mtd)
 	}
 
 	if (!timeout) {
-		dev_err(host->dev, "atmel_nand : Timeout to calculate PMECC error location\n");
+		dev_err(mtd->dev,
+			"Timeout to calculate PMECC error location\n");
 		return -1;
 	}
 
@@ -464,7 +465,8 @@ static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc,
 			*(buf + byte_pos) ^= (1 << bit_pos);
 
 			pos = sector_num * host->pmecc_sector_size + byte_pos;
-			dev_dbg(host->dev, "Bit flip in data area, byte_pos: %d, bit_pos: %d, 0x%02x -> 0x%02x\n",
+			dev_dbg(mtd->dev,
+				"Bit flip in data area, byte_pos: %d, bit_pos: %d, 0x%02x -> 0x%02x\n",
 				pos, bit_pos, err_byte, *(buf + byte_pos));
 		} else {
 			/* Bit flip in OOB area */
@@ -474,7 +476,8 @@ static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc,
 			ecc[tmp] ^= (1 << bit_pos);
 
 			pos = tmp + nand_chip->ecc.layout->eccpos[0];
-			dev_dbg(host->dev, "Bit flip in OOB, oob_byte_pos: %d, bit_pos: %d, 0x%02x -> 0x%02x\n",
+			dev_dbg(mtd->dev,
+				"Bit flip in OOB, oob_byte_pos: %d, bit_pos: %d, 0x%02x -> 0x%02x\n",
 				pos, bit_pos, err_byte, ecc[tmp]);
 		}
 
@@ -516,7 +519,7 @@ normal_check:
 
 			err_nbr = pmecc_err_location(mtd);
 			if (err_nbr == -1) {
-				dev_err(host->dev, "PMECC: Too many errors\n");
+				dev_err(mtd->dev, "PMECC: Too many errors\n");
 				mtd->ecc_stats.failed++;
 				return -EBADMSG;
 			} else {
@@ -560,7 +563,7 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,
 	}
 
 	if (!timeout) {
-		dev_err(host->dev, "atmel_nand : Timeout to read PMECC page\n");
+		dev_err(mtd->dev, "Timeout to read PMECC page\n");
 		return -1;
 	}
 
@@ -600,7 +603,8 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
 	}
 
 	if (!timeout) {
-		dev_err(host->dev, "atmel_nand : Timeout to read PMECC status, fail to write PMECC in oob\n");
+		dev_err(mtd->dev,
+			"Timeout to read PMECC status, fail to write PMECC in oob\n");
 		goto out;
 	}
 
@@ -713,7 +717,8 @@ static int pmecc_choose_ecc(struct atmel_nand_host *host,
 
 	if (*cap == 0 && *sector_size == 0) {
 		/* Non-ONFI compliant */
-		dev_info(host->dev, "NAND chip is not ONFI compliant, assume ecc_bits is 2 in 512 bytes\n");
+		dev_info(chip->mtd.dev,
+			 "NAND chip is not ONFI compliant, assume ecc_bits is 2 in 512 bytes\n");
 		*cap = 2;
 		*sector_size = 512;
 	}
@@ -835,17 +840,20 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,
 	 * from ONFI.
 	 */
 	if (pmecc_choose_ecc(host, nand, &cap, &sector_size)) {
-		dev_err(host->dev, "Required ECC %d bits in %d bytes not supported!\n",
+		dev_err(mtd->dev,
+			"Required ECC %d bits in %d bytes not supported!\n",
 			cap, sector_size);
 		return -EINVAL;
 	}
 
 	if (cap > host->pmecc_corr_cap)
-		dev_info(host->dev, "WARNING: Using different ecc correct bits(%d bit) from Nand ONFI ECC reqirement (%d bit).\n",
-				host->pmecc_corr_cap, cap);
+		dev_info(mtd->dev,
+			 "WARNING: Using different ecc correct bits(%d bit) from Nand ONFI ECC reqirement (%d bit).\n",
+			 host->pmecc_corr_cap, cap);
 	if (sector_size < host->pmecc_sector_size)
-		dev_info(host->dev, "WARNING: Using different ecc correct sector size (%d bytes) from Nand ONFI ECC reqirement (%d bytes).\n",
-				host->pmecc_sector_size, sector_size);
+		dev_info(mtd->dev,
+			 "WARNING: Using different ecc correct sector size (%d bytes) from Nand ONFI ECC reqirement (%d bytes).\n",
+			 host->pmecc_sector_size, sector_size);
 #else	/* CONFIG_SYS_NAND_ONFI_DETECTION */
 	host->pmecc_corr_cap = CONFIG_PMECC_CAP;
 	host->pmecc_sector_size = CONFIG_PMECC_SECTOR_SIZE;
@@ -877,7 +885,7 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,
 #if defined(NO_GALOIS_TABLE_IN_ROM)
 	pmecc_galois_table = create_lookup_table(host->pmecc_sector_size);
 	if (!pmecc_galois_table) {
-		dev_err(host->dev, "out of memory\n");
+		dev_err(mtd->dev, "out of memory\n");
 		return -ENOMEM;
 	}
 
@@ -909,13 +917,14 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,
 				       host->pmecc_sector_number;
 
 		if (nand->ecc.bytes > MTD_MAX_ECCPOS_ENTRIES_LARGE) {
-			dev_err(host->dev, "too large eccpos entries. max support ecc.bytes is %d\n",
-					MTD_MAX_ECCPOS_ENTRIES_LARGE);
+			dev_err(mtd->dev,
+				"too large eccpos entries. max support ecc.bytes is %d\n",
+				MTD_MAX_ECCPOS_ENTRIES_LARGE);
 			return -EINVAL;
 		}
 
 		if (nand->ecc.bytes > mtd->oobsize - PMECC_OOB_RESERVED_BYTES) {
-			dev_err(host->dev, "No room for ECC bytes\n");
+			dev_err(mtd->dev, "No room for ECC bytes\n");
 			return -EINVAL;
 		}
 		pmecc_config_ecc_layout(&atmel_pmecc_oobinfo,
@@ -926,7 +935,8 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,
 	case 512:
 	case 1024:
 		/* TODO */
-		dev_err(host->dev, "Unsupported page size for PMECC, use Software ECC\n");
+		dev_err(mtd->dev,
+			"Unsupported page size for PMECC, use Software ECC\n");
 	default:
 		/* page size not handled by HW ECC */
 		/* switching back to soft ECC */
@@ -940,7 +950,8 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,
 
 	/* Allocate data for PMECC computation */
 	if (pmecc_data_alloc(host)) {
-		dev_err(host->dev, "Cannot allocate memory for PMECC computation!\n");
+		dev_err(mtd->dev,
+			"Cannot allocate memory for PMECC computation!\n");
 		return -ENOMEM;
 	}
 
@@ -951,7 +962,7 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,
 
 	/* Check the PMECC ip version */
 	host->pmecc_version = pmecc_readl(host->pmerrloc, version);
-	dev_dbg(host->dev, "PMECC IP version is: %x\n", host->pmecc_version);
+	dev_dbg(mtd->dev, "PMECC IP version is: %x\n", host->pmecc_version);
 
 	atmel_pmecc_core_init(mtd);
 
@@ -1114,8 +1125,8 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
 		/* it doesn't seems to be a freshly
 		 * erased block.
 		 * We can't correct so many errors */
-		dev_warn(host->dev, "atmel_nand : multiple errors detected."
-				" Unable to correct.\n");
+		dev_warn(mtd->dev,
+			 "multiple errors detected. Unable to correct.\n");
 		return -EBADMSG;
 	}
 
@@ -1124,15 +1135,14 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
 		/* there's nothing much to do here.
 		 * the bit error is on the ECC itself.
 		 */
-		dev_warn(host->dev, "atmel_nand : one bit error on ECC code."
-				" Nothing to correct\n");
+		dev_warn(mtd->dev,
+			 "one bit error on ECC code. Nothing to correct\n");
 		return 0;
 	}
 
-	dev_warn(host->dev, "atmel_nand : one bit error on data."
-			" (word offset in the page :"
-			" 0x%x bit offset : 0x%x)\n",
-			ecc_word, ecc_bit);
+	dev_warn(mtd->dev,
+		 "one bit error on data. (word offset in the page : 0x%x bit offset : 0x%x)\n",
+		 ecc_word, ecc_bit);
 	/* correct the error */
 	if (nand_chip->options & NAND_BUSWIDTH_16) {
 		/* 16 bits words */
@@ -1141,7 +1151,7 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
 		/* 8 bits words */
 		dat[ecc_word] ^= (1 << ecc_bit);
 	}
-	dev_warn(host->dev, "atmel_nand : error corrected\n");
+	dev_warn(mtd->dev, "error corrected\n");
 	return 1;
 }
 
@@ -1511,7 +1521,6 @@ void board_nand_init(void)
 	int i;
 	for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
 		if (atmel_nand_chip_init(i, base_addr[i]))
-			dev_err(host->dev, "atmel_nand: Fail to initialize #%d chip",
-				i);
+			log_err("atmel_nand: Fail to initialize #%d chip", i);
 }
 #endif /* CONFIG_SPL_BUILD */
Signature · 1 line
2.28.0
#24 lore raw

PATCH v2 14/46 nand: brcmnand: Fix not calling dev_err() with a device

In reply to Sean Anderson

There are too many levels of indirection when calling dev_err. This is an artifact of the conversion of brcmnand_host.pdev from a struct platform_device (which has a member dev pointing to a struct device) to struct udevice.

---

Changes in v2:
- New

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +6 -14
index 48c0ca69de..7349a9bc99 100644
@@ -956,7 +956,7 @@ static struct nand_ecclayout *brcmnand_create_layout(int ecc_level,
 	 */
 	req = DIV_ROUND_UP(ecc_level * 14, 8);
 	if (req >= sas) {
-		dev_err(&host->pdev->dev,
+		dev_err(host->pdev,
 			"error: ECC too large for OOB (ECC bytes %d, spare sector %d)\n",
 			req, sas);
 		return NULL;
@@ -1012,8 +1012,8 @@ static struct nand_ecclayout *brcmstb_choose_ecc_layout(
 
 	layout = brcmnand_create_layout(ecc_level, host);
 	if (!layout) {
-		dev_err(&host->pdev->dev,
-				"no proper ecc_layout for this NAND cfg\n");
+		dev_err(host->pdev,
+			"no proper ecc_layout for this NAND cfg\n");
 		return NULL;
 	}
 
@@ -1056,17 +1056,9 @@ static void brcmnand_wp(struct mtd_info *mtd, int wp)
 					       NAND_CTRL_RDY |
 					       NAND_STATUS_READY |
 					       (wp ? 0 : NAND_STATUS_WP), 0);
-#ifndef __UBOOT__
 		if (ret)
-			dev_err_ratelimited(&host->pdev->dev,
-					    "nand #WP expected %s\n",
-					    wp ? "on" : "off");
-#else
-		if (ret)
-			dev_err(&host->pdev->dev,
-					    "nand #WP expected %s\n",
-					    wp ? "on" : "off");
-#endif /* __UBOOT__ */
+			dev_err(host->pdev, "nand #WP expected %s\n",
+				wp ? "on" : "off");
 	}
 }
 
@@ -2257,7 +2249,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, ofnode dn)
 	ret = ofnode_read_s32(dn, "reg", &host->cs);
 #endif
 	if (ret) {
-		dev_err(&pdev->dev, "can't get chip-select\n");
+		dev_err(pdev, "can't get chip-select\n");
 		return -ENXIO;
 	}
 
Signature · 1 line
2.28.0
#25 lore raw

PATCH v2 15/46 nand: vybrid: Re-introduce vf610_nfc.dev

In reply to Sean Anderson

This member was presumably dropped when this driver was converted from Linux. However, it is still used in log statements during initialization. This patch adds the member back. In addition, allocation of struct vf610_nfc has been moved to the callers of vf610_nfc_nand_init. This allows it to be allocated by DM (if it is being used) and for dev to be initialized.

---

Changes in v2:
- New

 drivers/mtd/nand/raw/vf610_nfc.c | 38 ++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 17 deletions(-)
drivers/mtd/nand/raw/vf610_nfc.c +21 -17
index 52c8a94778..4e6fdc607f 100644
@@ -152,6 +152,8 @@ enum vf610_nfc_alt_buf {
 
 struct vf610_nfc {
 	struct nand_chip chip;
+	/* NULL without CONFIG_NAND_VF610_NFC_DT */
+	struct udevice *dev;
 	void __iomem *regs;
 	uint buf_offset;
 	int write_sz;
@@ -631,11 +633,10 @@ struct vf610_nfc_config {
 	int flash_bbt;
 };
 
-static int vf610_nfc_nand_init(int devnum, void __iomem *addr)
+static int vf610_nfc_nand_init(struct vf610_nfc *nfc, int devnum)
 {
-	struct mtd_info *mtd;
-	struct nand_chip *chip;
-	struct vf610_nfc *nfc;
+	struct nand_chip *chip = &nfc->chip;
+	struct mtd_info *mtd = nand_to_mtd(chip);
 	int err = 0;
 	struct vf610_nfc_config cfg = {
 		.hardware_ecc = 1,
@@ -647,16 +648,6 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr)
 		.flash_bbt = 1,
 	};
 
-	nfc = calloc(1, sizeof(*nfc));
-	if (!nfc) {
-		printf(KERN_ERR "%s: Memory exhausted!\n", __func__);
-		return -ENOMEM;
-	}
-
-	chip = &nfc->chip;
-	nfc->regs = addr;
-
-	mtd = nand_to_mtd(chip);
 	nand_set_controller_data(chip, nfc);
 
 	if (cfg.width == 16)
@@ -777,20 +768,23 @@ static const struct udevice_id vf610_nfc_dt_ids[] = {
 static int vf610_nfc_dt_probe(struct udevice *dev)
 {
 	struct resource res;
+	struct vf610_nfc *nfc = dev_get_priv(dev);
 	int ret;
 
 	ret = dev_read_resource(dev, 0, &res);
 	if (ret)
 		return ret;
 
-	return vf610_nfc_nand_init(0, devm_ioremap(dev, res.start,
-						   resource_size(&res)));
+	nfc->regs = devm_ioremap(dev, res.start, resource_size(&res));
+	nfc->dev = dev;
+	return vf610_nfc_nand_init(nfc, 0);
 }
 
 U_BOOT_DRIVER(vf610_nfc_dt) = {
 	.name = "vf610-nfc-dt",
 	.id = UCLASS_MTD,
 	.of_match = vf610_nfc_dt_ids,
+	.priv_auto_alloc_size = sizeof(struct vf610_nfc),
 	.probe = vf610_nfc_dt_probe,
 };
 
@@ -809,7 +803,17 @@ void board_nand_init(void)
 #else
 void board_nand_init(void)
 {
-	int err = vf610_nfc_nand_init(0, (void __iomem *)CONFIG_SYS_NAND_BASE);
+	int err;
+	struct vf610_nfc *nfc;
+
+	nfc = calloc(1, sizeof(*nfc));
+	if (!nfc) {
+		printf("%s: Out of memory\n", __func__);
+		return;
+	}
+
+	nfc->regs = (void __iomem *)CONFIG_SYS_NAND_BASE;
+	err = vf610_nfc_nand_init(nfc, 0);
 	if (err)
 		printf("VF610 NAND init failed (err %d)\n", err);
 }
Signature · 1 line
2.28.0
#26 lore raw

PATCH v2 16/46 net: bcm6368: Fix not calling dev_info with a device

In reply to Sean Anderson

Remove the pdev indirection.

---

Changes in v2:
- New

 drivers/net/bcm6368-eth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/bcm6368-eth.c +1 -2
index 648fafd3e0..38a2a30fe6 100644
@@ -249,8 +249,7 @@ static int bcm6368_eth_adjust_link(struct udevice *dev)
 
 		/* link changed */
 		if (!up) {
-			dev_info(&priv->pdev->dev, "link DOWN on %s\n",
-				 port->name);
+			dev_info(dev, "link DOWN on %s\n", port->name);
 			writeb_be(ETH_PORTOV_ENABLE_MASK,
 				  priv->base + ETH_PORTOV_REG(i));
 			writeb_be(ETH_PTCTRL_RXDIS_MASK |
Signature · 1 line
2.28.0
#27 lore raw

PATCH v2 17/46 net: mdio: Fix not calling dev_dbg with a device

In reply to Sean Anderson

The name of the device we are working on is ethdev and not just dev.

---

(no changes since v1)

 net/mdio-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/mdio-uclass.c +2 -2
index 66ee2e1976..b5e8e46512 100644
@@ -145,7 +145,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
 			break;
 
 	if (!ofnode_valid(phandle.node)) {
-		dev_dbg(dev, "can't find PHY node\n");
+		dev_dbg(ethdev, "can't find PHY node\n");
 		return NULL;
 	}
 
@@ -161,7 +161,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
 	if (uclass_get_device_by_ofnode(UCLASS_MDIO,
 					ofnode_get_parent(phandle.node),
 					&mdiodev)) {
-		dev_dbg(dev, "can't find MDIO bus for node %s\n",
+		dev_dbg(ethdev, "can't find MDIO bus for node %s\n",
 			ofnode_get_name(ofnode_get_parent(phandle.node)));
 		return NULL;
 	}
Signature · 1 line
2.28.0
#28 lore raw

PATCH v2 18/46 net: mvneta: Fix not always calling dev_err with a device

In reply to Sean Anderson

No need for indirection here.

---

Changes in v2:
- New

 drivers/net/mvneta.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/mvneta.c +2 -2
index 4c7d06ca40..2c93fe42f7 100644
@@ -1402,7 +1402,7 @@ static int mvneta_init(struct udevice *dev)
 
 	err = mvneta_init2(pp);
 	if (err < 0) {
-		dev_err(&pdev->dev, "can't init eth hal\n");
+		dev_err(dev, "can't init eth hal\n");
 		return err;
 	}
 
@@ -1410,7 +1410,7 @@ static int mvneta_init(struct udevice *dev)
 
 	err = mvneta_port_power_up(pp, pp->phy_interface);
 	if (err < 0) {
-		dev_err(&pdev->dev, "can't power up port\n");
+		dev_err(dev, "can't power up port\n");
 		return err;
 	}
 
Signature · 1 line
2.28.0
#30 lore raw

PATCH v2 19/46 net: mvneta: Convert netdev_xxx to dev_xxx

In reply to Sean Anderson

netdev_xxx evaluates to printf in U-Boot, so there is no extra info printed. mvneta is one of two drivers which use these functions in U-Boot. Convert these functions to dev_xxx where possible (and to log_xxx where not).

---

Changes in v2:
- New

 drivers/net/mvneta.c | 52 ++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 24 deletions(-)
drivers/net/mvneta.c +28 -24
index 2c93fe42f7..83f99e5d8a 100644
@@ -625,9 +625,9 @@ static void mvneta_port_down(struct mvneta_port *pp)
 	count = 0;
 	do {
 		if (count++ >= MVNETA_RX_DISABLE_TIMEOUT_MSEC) {
-			netdev_warn(pp->dev,
-				    "TIMEOUT for RX stopped ! rx_queue_cmd: 0x08%x\n",
-				    val);
+			dev_warn(pp->phydev->dev,
+				 "TIMEOUT for RX stopped ! rx_queue_cmd: 0x08%x\n",
+				 val);
 			break;
 		}
 		mdelay(1);
@@ -648,9 +648,9 @@ static void mvneta_port_down(struct mvneta_port *pp)
 	count = 0;
 	do {
 		if (count++ >= MVNETA_TX_DISABLE_TIMEOUT_MSEC) {
-			netdev_warn(pp->dev,
-				    "TIMEOUT for TX stopped status=0x%08x\n",
-				    val);
+			dev_warn(pp->phydev->dev,
+				 "TIMEOUT for TX stopped status=0x%08x\n",
+				 val);
 			break;
 		}
 		mdelay(1);
@@ -664,9 +664,9 @@ static void mvneta_port_down(struct mvneta_port *pp)
 	count = 0;
 	do {
 		if (count++ >= MVNETA_TX_FIFO_EMPTY_TIMEOUT) {
-			netdev_warn(pp->dev,
-				    "TX FIFO empty timeout status=0x08%x\n",
-				    val);
+			dev_warn(pp->phydev->dev,
+				 "TX FIFO empty timeout status=0x08%x\n",
+				 val);
 			break;
 		}
 		mdelay(1);
@@ -949,28 +949,32 @@ static void mvneta_rx_error(struct mvneta_port *pp,
 	u32 status = rx_desc->status;
 
 	if (!mvneta_rxq_desc_is_first_last(status)) {
-		netdev_err(pp->dev,
-			   "bad rx status %08x (buffer oversize), size=%d\n",
-			   status, rx_desc->data_size);
+		dev_err(pp->phydev->dev,
+			"bad rx status %08x (buffer oversize), size=%d\n",
+			status, rx_desc->data_size);
 		return;
 	}
 
 	switch (status & MVNETA_RXD_ERR_CODE_MASK) {
 	case MVNETA_RXD_ERR_CRC:
-		netdev_err(pp->dev, "bad rx status %08x (crc error), size=%d\n",
-			   status, rx_desc->data_size);
+		dev_err(pp->phydev->dev,
+			"bad rx status %08x (crc error), size=%d\n", status,
+			rx_desc->data_size);
 		break;
 	case MVNETA_RXD_ERR_OVERRUN:
-		netdev_err(pp->dev, "bad rx status %08x (overrun error), size=%d\n",
-			   status, rx_desc->data_size);
+		dev_err(pp->phydev->dev,
+			"bad rx status %08x (overrun error), size=%d\n", status,
+			rx_desc->data_size);
 		break;
 	case MVNETA_RXD_ERR_LEN:
-		netdev_err(pp->dev, "bad rx status %08x (max frame length error), size=%d\n",
-			   status, rx_desc->data_size);
+		dev_err(pp->phydev->dev,
+			"bad rx status %08x (max frame length error), size=%d\n",
+			status, rx_desc->data_size);
 		break;
 	case MVNETA_RXD_ERR_RESOURCE:
-		netdev_err(pp->dev, "bad rx status %08x (resource error), size=%d\n",
-			   status, rx_desc->data_size);
+		dev_err(pp->phydev->dev,
+			"bad rx status %08x (resource error), size=%d\n",
+			status, rx_desc->data_size);
 		break;
 	}
 }
@@ -1127,8 +1131,8 @@ static int mvneta_setup_rxqs(struct mvneta_port *pp)
 	for (queue = 0; queue < rxq_number; queue++) {
 		int err = mvneta_rxq_init(pp, &pp->rxqs[queue]);
 		if (err) {
-			netdev_err(pp->dev, "%s: can't create rxq=%d\n",
-				   __func__, queue);
+			dev_err(pp->phydev->dev, "%s: can't create rxq=%d\n",
+				__func__, queue);
 			mvneta_cleanup_rxqs(pp);
 			return err;
 		}
@@ -1145,8 +1149,8 @@ static int mvneta_setup_txqs(struct mvneta_port *pp)
 	for (queue = 0; queue < txq_number; queue++) {
 		int err = mvneta_txq_init(pp, &pp->txqs[queue]);
 		if (err) {
-			netdev_err(pp->dev, "%s: can't create txq=%d\n",
-				   __func__, queue);
+			dev_err(pp->phydev->dev, "%s: can't create txq=%d\n",
+				__func__, queue);
 			mvneta_cleanup_txqs(pp);
 			return err;
 		}
Signature · 1 line
2.28.0
#31 lore raw

PATCH v2 19/46 net: mvneta: Convert netdev_xxx to dev_xxx

Quoted 6 lines · Sean Anderson

netdev_xxx evaluates to printf in U-Boot, so there is no extra info printed. mvneta is one of two drivers which use these functions in U-Boot. Convert these functions to dev_xxx where possible (and to log_xxx where not).

Quoted 9 lines

---

Changes in v2:
- New

 drivers/net/mvneta.c | 52 ++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 24 deletions(-)
#32 lore raw

PATCH v2 20/46 net: mvpp2: Fix not calling dev_xxx with a device

In reply to Sean Anderson

Remove some prefixes, or get the device from the phy.

---

Changes in v2:
- New

 drivers/net/mvpp2.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/net/mvpp2.c +12 -11
index a5747a25ab..6f3ee235d1 100644
@@ -2568,7 +2568,7 @@ static int mvpp2_bm_pool_create(struct udevice *dev,
 
 	if (!IS_ALIGNED((unsigned long)bm_pool->virt_addr,
 			MVPP2_BM_POOL_PTR_ALIGN)) {
-		dev_err(&pdev->dev, "BM pool %d is not %d bytes aligned\n",
+		dev_err(dev, "BM pool %d is not %d bytes aligned\n",
 			bm_pool->id, MVPP2_BM_POOL_PTR_ALIGN);
 		return -ENOMEM;
 	}
@@ -2659,7 +2659,7 @@ static int mvpp2_bm_pools_init(struct udevice *dev,
 	return 0;
 
 err_unroll_pools:
-	dev_err(&pdev->dev, "failed to create BM pool %d, size %d\n", i, size);
+	dev_err(dev, "failed to create BM pool %d, size %d\n", i, size);
 	for (i = i - 1; i >= 0; i--)
 		mvpp2_bm_pool_destroy(dev, priv, &priv->bm_pools[i]);
 	return err;
@@ -2834,8 +2834,9 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type,
 		/* Allocate buffers for this pool */
 		num = mvpp2_bm_bufs_add(port, new_pool, pkts_num);
 		if (num != pkts_num) {
-			dev_err(dev, "pool %d: %d of %d allocated\n",
-				new_pool->id, num, pkts_num);
+			dev_err(port->phy_dev->dev,
+				"pool %d: %d of %d allocated\n", new_pool->id,
+				num, pkts_num);
 			return NULL;
 		}
 	}
@@ -4725,7 +4726,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
 		int parent;
 		phyaddr = fdtdec_get_int(gd->fdt_blob, phy_node, "reg", 0);
 		if (phyaddr < 0) {
-			dev_err(&pdev->dev, "could not find phy address\n");
+			dev_err(dev, "could not find phy address\n");
 			return -1;
 		}
 		parent = fdt_parent_offset(gd->fdt_blob, phy_node);
@@ -4742,13 +4743,13 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
 	if (phy_mode_str)
 		phy_mode = phy_get_interface_by_name(phy_mode_str);
 	if (phy_mode == -1) {
-		dev_err(&pdev->dev, "incorrect phy mode\n");
+		dev_err(dev, "incorrect phy mode\n");
 		return -EINVAL;
 	}
 
 	id = fdtdec_get_int(gd->fdt_blob, port_node, "port-id", -1);
 	if (id == -1) {
-		dev_err(&pdev->dev, "missing port-id value\n");
+		dev_err(dev, "missing port-id value\n");
 		return -EINVAL;
 	}
 
@@ -4807,7 +4808,7 @@ static int mvpp2_port_probe(struct udevice *dev,
 
 	err = mvpp2_port_init(dev, port);
 	if (err < 0) {
-		dev_err(&pdev->dev, "failed to init port %d\n", port->id);
+		dev_err(dev, "failed to init port %d\n", port->id);
 		return err;
 	}
 	mvpp2_port_power_up(port);
@@ -4978,7 +4979,7 @@ static int mvpp2_init(struct udevice *dev, struct mvpp2 *priv)
 	/* Checks for hardware constraints (U-Boot uses only one rxq) */
 	if ((rxq_number > priv->max_port_rxqs) ||
 	    (txq_number > MVPP2_MAX_TXQ)) {
-		dev_err(&pdev->dev, "invalid queue size parameter\n");
+		dev_err(dev, "invalid queue size parameter\n");
 		return -EINVAL;
 	}
 
@@ -5345,7 +5346,7 @@ static int mvpp2_probe(struct udevice *dev)
 		port->gop_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					      "gop-port-id", -1);
 		if (port->id == -1) {
-			dev_err(&pdev->dev, "missing gop-port-id value\n");
+			dev_err(dev, "missing gop-port-id value\n");
 			return -EINVAL;
 		}
 
@@ -5364,7 +5365,7 @@ static int mvpp2_probe(struct udevice *dev)
 		/* Initialize network controller */
 		err = mvpp2_init(dev, priv);
 		if (err < 0) {
-			dev_err(&pdev->dev, "failed to initialize controller\n");
+			dev_err(dev, "failed to initialize controller\n");
 			return err;
 		}
 		priv->num_ports = 0;
Signature · 1 line
2.28.0
#34 lore raw

PATCH v2 21/46 net: mvpp2: Convert netdev_xxx to dev_xxx

In reply to Sean Anderson

netdev_xxx evaluates to printf in U-Boot, so there is no extra info printed. mvpp2 one of only two drivers which use these functions in U-Boot. Convert these functions to dev_xxx where possible (and to log_xxx where not).

---

Changes in v2:
- New

 drivers/net/mvpp2.c | 64 +++++++++++++++++++++++----------------------
 1 file changed, 33 insertions(+), 31 deletions(-)
drivers/net/mvpp2.c +33 -31
index 6f3ee235d1..8f790a8b44 100644
@@ -2773,9 +2773,9 @@ static int mvpp2_bm_bufs_add(struct mvpp2_port *port,
 
 	if (buf_num < 0 ||
 	    (buf_num + bm_pool->buf_num > bm_pool->size)) {
-		netdev_err(port->dev,
-			   "cannot allocate %d buffers for pool %d\n",
-			   buf_num, bm_pool->id);
+		dev_err(port->phy_dev->dev,
+			"cannot allocate %d buffers for pool %d\n", buf_num,
+			bm_pool->id);
 		return 0;
 	}
 
@@ -2803,7 +2803,7 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type,
 	int num;
 
 	if (new_pool->type != MVPP2_BM_FREE && new_pool->type != type) {
-		netdev_err(port->dev, "mixing pool types is forbidden\n");
+		dev_err(port->phy_dev->dev, "mixing pool types is forbidden\n");
 		return NULL;
 	}
 
@@ -3345,8 +3345,7 @@ static int gop_port_init(struct mvpp2_port *port)
 	int num_of_act_lanes;
 
 	if (mac_num >= MVPP22_GOP_MAC_NUM) {
-		netdev_err(NULL, "%s: illegal port number %d", __func__,
-			   mac_num);
+		log_err("illegal port number %d", mac_num);
 		return -1;
 	}
 
@@ -3400,8 +3399,8 @@ static int gop_port_init(struct mvpp2_port *port)
 		break;
 
 	default:
-		netdev_err(NULL, "%s: Requested port mode (%d) not supported\n",
-			   __func__, port->phy_interface);
+		log_err("Requested port mode (%d) not supported\n",
+			port->phy_interface);
 		return -1;
 	}
 
@@ -3441,8 +3440,8 @@ static void gop_port_enable(struct mvpp2_port *port, int enable)
 
 		break;
 	default:
-		netdev_err(NULL, "%s: Wrong port mode (%d)\n", __func__,
-			   port->phy_interface);
+		log_err("%s: Wrong port mode (%d)\n", __func__,
+			port->phy_interface);
 		return;
 	}
 }
@@ -3812,9 +3811,9 @@ static void mvpp2_egress_disable(struct mvpp2_port *port)
 	delay = 0;
 	do {
 		if (delay >= MVPP2_TX_DISABLE_TIMEOUT_MSEC) {
-			netdev_warn(port->dev,
-				    "Tx stop timed out, status=0x%08x\n",
-				    reg_data);
+			dev_warn(port->phy_dev->dev,
+				 "Tx stop timed out, status=0x%08x\n",
+				 reg_data);
 			break;
 		}
 		mdelay(1);
@@ -4262,9 +4261,9 @@ static void mvpp2_txq_clean(struct mvpp2_port *port, struct mvpp2_tx_queue *txq)
 	delay = 0;
 	do {
 		if (delay >= MVPP2_TX_PENDING_TIMEOUT_MSEC) {
-			netdev_warn(port->dev,
-				    "port %d: cleaning queue %d timed out\n",
-				    port->id, txq->log_id);
+			dev_warn(port->phy_dev->dev,
+				 "port %d: cleaning queue %d timed out\n",
+				 port->id, txq->log_id);
 			break;
 		}
 		mdelay(1);
@@ -4431,16 +4430,19 @@ static void mvpp2_rx_error(struct mvpp2_port *port,
 
 	switch (status & MVPP2_RXD_ERR_CODE_MASK) {
 	case MVPP2_RXD_ERR_CRC:
-		netdev_err(port->dev, "bad rx status %08x (crc error), size=%zu\n",
-			   status, sz);
+		dev_err(port->phy_dev->dev,
+			"bad rx status %08x (crc error), size=%zu\n", status,
+			sz);
 		break;
 	case MVPP2_RXD_ERR_OVERRUN:
-		netdev_err(port->dev, "bad rx status %08x (overrun error), size=%zu\n",
-			   status, sz);
+		dev_err(port->phy_dev->dev,
+			"bad rx status %08x (overrun error), size=%zu\n",
+			status, sz);
 		break;
 	case MVPP2_RXD_ERR_RESOURCE:
-		netdev_err(port->dev, "bad rx status %08x (resource error), size=%zu\n",
-			   status, sz);
+		dev_err(port->phy_dev->dev,
+			"bad rx status %08x (resource error), size=%zu\n",
+			status, sz);
 		break;
 	}
 }
@@ -4508,8 +4510,8 @@ static void mvpp2_phy_connect(struct udevice *dev, struct mvpp2_port *port)
 		 */
 		if (phy_dev &&
 		    phy_dev->drv->uid == 0xffffffff) {/* Generic phy */
-			netdev_warn(port->dev,
-				    "Marking phy as invalid, link will not be checked\n");
+			dev_warn(port->phy_dev->dev,
+				 "Marking phy as invalid, link will not be checked\n");
 			/* set phy_addr to invalid value */
 			port->phyaddr = PHY_MAX_ADDR;
 			mvpp2_egress_enable(port);
@@ -4520,7 +4522,7 @@ static void mvpp2_phy_connect(struct udevice *dev, struct mvpp2_port *port)
 
 		port->phy_dev = phy_dev;
 		if (!phy_dev) {
-			netdev_err(port->dev, "cannot connect to phy\n");
+			dev_err(port->phy_dev->dev, "cannot connect to phy\n");
 			return;
 		}
 		phy_dev->supported &= PHY_GBIT_FEATURES;
@@ -4551,31 +4553,31 @@ static int mvpp2_open(struct udevice *dev, struct mvpp2_port *port)
 
 	err = mvpp2_prs_mac_da_accept(port->priv, port->id, mac_bcast, true);
 	if (err) {
-		netdev_err(dev, "mvpp2_prs_mac_da_accept BC failed\n");
+		dev_err(dev, "mvpp2_prs_mac_da_accept BC failed\n");
 		return err;
 	}
 	err = mvpp2_prs_mac_da_accept(port->priv, port->id,
 				      port->dev_addr, true);
 	if (err) {
-		netdev_err(dev, "mvpp2_prs_mac_da_accept MC failed\n");
+		dev_err(dev, "mvpp2_prs_mac_da_accept MC failed\n");
 		return err;
 	}
 	err = mvpp2_prs_def_flow(port);
 	if (err) {
-		netdev_err(dev, "mvpp2_prs_def_flow failed\n");
+		dev_err(dev, "mvpp2_prs_def_flow failed\n");
 		return err;
 	}
 
 	/* Allocate the Rx/Tx queues */
 	err = mvpp2_setup_rxqs(port);
 	if (err) {
-		netdev_err(port->dev, "cannot allocate Rx queues\n");
+		dev_err(port->phy_dev->dev, "cannot allocate Rx queues\n");
 		return err;
 	}
 
 	err = mvpp2_setup_txqs(port);
 	if (err) {
-		netdev_err(port->dev, "cannot allocate Tx queues\n");
+		dev_err(port->phy_dev->dev, "cannot allocate Tx queues\n");
 		return err;
 	}
 
@@ -5100,7 +5102,7 @@ static int mvpp2_recv(struct udevice *dev, int flags, uchar **packetp)
 
 	err = mvpp2_rx_refill(port, bm_pool, bm, dma_addr);
 	if (err) {
-		netdev_err(port->dev, "failed to refill BM pools\n");
+		dev_err(port->phy_dev->dev, "failed to refill BM pools\n");
 		return 0;
 	}
 
Signature · 1 line
2.28.0
#35 lore raw

PATCH v2 21/46 net: mvpp2: Convert netdev_xxx to dev_xxx

Quoted 6 lines · Sean Anderson

netdev_xxx evaluates to printf in U-Boot, so there is no extra info printed. mvpp2 one of only two drivers which use these functions in U-Boot. Convert these functions to dev_xxx where possible (and to log_xxx where not).

Quoted 9 lines

---

Changes in v2:
- New

 drivers/net/mvpp2.c | 64 +++++++++++++++++++++++----------------------
 1 file changed, 33 insertions(+), 31 deletions(-)
#36 lore raw

PATCH v2 22/46 linux/compat.h: Remove netdev_xxx functions

In reply to Sean Anderson

No drivers in U-Boot use these functions.

---

Changes in v2:
- New

 include/linux/compat.h | 19 -------------------
 1 file changed, 19 deletions(-)
include/linux/compat.h +0 -19
index 363b2b9425..d129780312 100644
@@ -52,25 +52,6 @@ extern struct p_current *current;
 #define dev_warn(dev, fmt, args...)		\
 	printf(fmt, ##args)
 
-#define netdev_emerg(dev, fmt, args...)		\
-	printf(fmt, ##args)
-#define netdev_alert(dev, fmt, args...)		\
-	printf(fmt, ##args)
-#define netdev_crit(dev, fmt, args...)		\
-	printf(fmt, ##args)
-#define netdev_err(dev, fmt, args...)		\
-	printf(fmt, ##args)
-#define netdev_warn(dev, fmt, args...)		\
-	printf(fmt, ##args)
-#define netdev_notice(dev, fmt, args...)	\
-	printf(fmt, ##args)
-#define netdev_info(dev, fmt, args...)		\
-	printf(fmt, ##args)
-#define netdev_dbg(dev, fmt, args...)		\
-	debug(fmt, ##args)
-#define netdev_vdbg(dev, fmt, args...)		\
-	debug(fmt, ##args)
-
 #define GFP_ATOMIC ((gfp_t) 0)
 #define GFP_KERNEL ((gfp_t) 0)
 #define GFP_NOFS ((gfp_t) 0)
Signature · 1 line
2.28.0
#38 lore raw

PATCH v2 23/46 net: sunxi: Fix not calling dev_xxx with a device

In reply to Sean Anderson

There's no dev to log with, so pass the device along with the priv data.

---

Changes in v2:
- New

 drivers/net/sunxi_emac.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/sunxi_emac.c +3 -2
index df18ecc064..8e66ce2461 100644
@@ -505,7 +505,8 @@ static int _sunxi_emac_eth_send(struct emac_eth_dev *priv, void *packet,
 	return 0;
 }
 
-static int sunxi_emac_board_setup(struct emac_eth_dev *priv)
+static int sunxi_emac_board_setup(struct udevice *dev,
+				  struct emac_eth_dev *priv)
 {
 	struct sunxi_sramc_regs *sram =
 		(struct sunxi_sramc_regs *)SUNXI_SRAMC_BASE;
@@ -576,7 +577,7 @@ static int sunxi_emac_eth_probe(struct udevice *dev)
 		return ret;
 	}
 
-	ret = sunxi_emac_board_setup(priv);
+	ret = sunxi_emac_board_setup(dev, priv);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.28.0
#40 lore raw

PATCH v2 24/46 net: sun8i_emac: Fix not calling dev_xxx with a device

In reply to Sean Anderson

Pass a udevice into a few functions so dev is defined.

---

Changes in v2:
- New

 drivers/net/sun8i_emac.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/sun8i_emac.c +5 -4
index 546cc6ccb6..1dae81c7bf 100644
@@ -663,7 +663,8 @@ static int sun8i_eth_write_hwaddr(struct udevice *dev)
 	return _sun8i_write_hwaddr(priv, pdata->enetaddr);
 }
 
-static int sun8i_emac_board_setup(struct emac_eth_dev *priv)
+static int sun8i_emac_board_setup(struct udevice *dev,
+				  struct emac_eth_dev *priv)
 {
 	int ret;
 
@@ -833,7 +834,7 @@ static int sun8i_emac_eth_probe(struct udevice *dev)
 
 	priv->mac_reg = (void *)pdata->iobase;
 
-	ret = sun8i_emac_board_setup(priv);
+	ret = sun8i_emac_board_setup(dev, priv);
 	if (ret)
 		return ret;
 
@@ -854,7 +855,7 @@ static const struct eth_ops sun8i_emac_eth_ops = {
 	.stop                   = sun8i_emac_eth_stop,
 };
 
-static int sun8i_get_ephy_nodes(struct emac_eth_dev *priv)
+static int sun8i_get_ephy_nodes(struct udevice *dev, struct emac_eth_dev *priv)
 {
 	int emac_node, ephy_node, ret, ephy_handle;
 
@@ -986,7 +987,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 	}
 
 	if (priv->variant == H3_EMAC) {
-		ret = sun8i_get_ephy_nodes(priv);
+		ret = sun8i_get_ephy_nodes(dev, priv);
 		if (ret)
 			return ret;
 	}
Signature · 1 line
2.28.0
#42 lore raw

PATCH v2 25/46 net: ti: cpsw: Fix not calling dev_dbg with a device

In reply to Sean Anderson

Without DM_ETH, cpsw_priv.dev is an eth_device. Just use its name instead.

---

Changes in v2:
- New

 drivers/net/ti/cpsw.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ti/cpsw.c +6 -0
index d6fefe5306..1c11257839 100644
@@ -856,8 +856,14 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)
 		ret = phy_set_supported(phydev, slave->data->max_speed);
 		if (ret)
 			return ret;
+#if CONFIG_IS_ENABLED(DM_ETH)
 		dev_dbg(priv->dev, "Port %u speed forced to %uMbit\n",
 			slave->slave_num + 1, slave->data->max_speed);
+#else
+		log_debug("%s: Port %u speed forced to %uMbit\n",
+			  priv->dev->name, slave->slave_num + 1,
+			  slave->data->max_speed);
+#endif
 	}
 	phydev->advertising = phydev->supported;
 
Signature · 1 line
2.28.0
#43 lore raw

PATCH v2 26/46 phy: marvell: Fix not calling dev_err with a device

In reply to Sean Anderson

No need for indirection here.

---

Changes in v2:
- New

 drivers/phy/marvell/comphy_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/marvell/comphy_core.c +3 -3
index 27bff27ff7..5e8ce740cd 100644
@@ -98,14 +98,14 @@ static int comphy_probe(struct udevice *dev)
 	chip_cfg->comphy_lanes_count = fdtdec_get_int(blob, node,
 						      "max-lanes", 0);
 	if (chip_cfg->comphy_lanes_count <= 0) {
-		dev_err(&dev->dev, "comphy max lanes is wrong\n");
+		dev_err(dev, "comphy max lanes is wrong\n");
 		return -EINVAL;
 	}
 
 	chip_cfg->comphy_mux_bitcount = fdtdec_get_int(blob, node,
 						       "mux-bitcount", 0);
 	if (chip_cfg->comphy_mux_bitcount <= 0) {
-		dev_err(&dev->dev, "comphy mux bit count is wrong\n");
+		dev_err(dev, "comphy mux bit count is wrong\n");
 		return -EINVAL;
 	}
 
@@ -124,7 +124,7 @@ static int comphy_probe(struct udevice *dev)
 	 * compatible node is found
 	 */
 	if (!chip_cfg->ptr_comphy_chip_init) {
-		dev_err(&dev->dev, "comphy: No compatible DT node found\n");
+		dev_err(dev, "comphy: No compatible DT node found\n");
 		return -ENODEV;
 	}
 
Signature · 1 line
2.28.0
#44 lore raw

PATCH v2 27/46 phy: rockchip: Fix not calling dev_err with a device

In reply to Sean Anderson

Get the device from phy, or pass the phy in.

---

Changes in v2:
- New

 drivers/phy/rockchip/phy-rockchip-pcie.c  | 14 +++++++-------
 drivers/phy/rockchip/phy-rockchip-typec.c |  6 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/phy/rockchip/phy-rockchip-pcie.c +7 -7
index 83928cffe0..617943fd82 100644
@@ -98,7 +98,7 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
 
 	ret = reset_deassert(&priv->phy_rst);
 	if (ret) {
-		dev_err(dev, "failed to assert phy reset\n");
+		dev_err(phy->dev, "failed to assert phy reset\n");
 		return ret;
 	}
 
@@ -119,7 +119,7 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
 				       20 * 1000,
 				       50);
 	if (ret) {
-		dev_err(&priv->dev, "pll lock timeout!\n");
+		dev_err(phy->dev, "pll lock timeout!\n");
 		goto err_pll_lock;
 	}
 
@@ -133,7 +133,7 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
 				       20 * 1000,
 				       50);
 	if (ret) {
-		dev_err(&priv->dev, "pll output enable timeout!\n");
+		dev_err(phy->dev, "pll output enable timeout!\n");
 		goto err_pll_lock;
 	}
 
@@ -149,7 +149,7 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
 				       20 * 1000,
 				       50);
 	if (ret) {
-		dev_err(&priv->dev, "pll relock timeout!\n");
+		dev_err(phy->dev, "pll relock timeout!\n");
 		goto err_pll_lock;
 	}
 
@@ -173,7 +173,7 @@ static int rockchip_pcie_phy_power_off(struct phy *phy)
 
 	ret = reset_assert(&priv->phy_rst);
 	if (ret) {
-		dev_err(dev, "failed to assert phy reset\n");
+		dev_err(phy->dev, "failed to assert phy reset\n");
 		return ret;
 	}
 
@@ -187,13 +187,13 @@ static int rockchip_pcie_phy_init(struct phy *phy)
 
 	ret = clk_enable(&priv->refclk);
 	if (ret) {
-		dev_err(dev, "failed to enable refclk clock\n");
+		dev_err(phy->dev, "failed to enable refclk clock\n");
 		return ret;
 	}
 
 	ret = reset_assert(&priv->phy_rst);
 	if (ret) {
-		dev_err(dev, "failed to assert phy reset\n");
+		dev_err(phy->dev, "failed to assert phy reset\n");
 		goto err_reset;
 	}
 
drivers/phy/rockchip/phy-rockchip-typec.c +3 -3
index c9c8e1c542..da00daa447 100644
@@ -448,7 +448,7 @@ static void rockchip_tcphy_rx_usb3_cfg_lane(struct rockchip_tcphy *priv,
 	writel(0xfb, priv->reg_base + XCVR_DIAG_BIDI_CTRL(lane));
 }
 
-static int rockchip_tcphy_init(struct rockchip_tcphy *priv)
+static int rockchip_tcphy_init(struct phy *phy, struct rockchip_tcphy *priv)
 {
 	const struct rockchip_usb3phy_port_cfg *cfg = priv->port_cfgs;
 	u32 val;
@@ -559,9 +559,9 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
 		return 0;
 
 	if (priv->mode == MODE_DISCONNECT) {
-		ret = rockchip_tcphy_init(priv);
+		ret = rockchip_tcphy_init(phy, priv);
 		if (ret) {
-			dev_err(dev, "failed to init tcphy (ret=%d)\n", ret);
+			dev_err(phy->dev, "failed to init tcphy (ret=%d)\n", ret);
 			return ret;
 		}
 	}
Signature · 1 line
2.28.0
#45 lore raw

PATCH v2 27/46 phy: rockchip: Fix not calling dev_err with a device

Quoted 3 lines · Sean Anderson

Get the device from phy, or pass the phy in.

Thanks,

- Kever

Quoted 99 lines

---

Changes in v2:
- New

  drivers/phy/rockchip/phy-rockchip-pcie.c  | 14 +++++++-------
  drivers/phy/rockchip/phy-rockchip-typec.c |  6 +++---
  2 files changed, 10 insertions(+), 10 deletions(-)
drivers/phy/rockchip/phy-rockchip-pcie.c +7 -7
index 83928cffe0..617943fd82 100644
@@ -98,7 +98,7 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
 
  	ret = reset_deassert(&priv->phy_rst);
  	if (ret) {
-		dev_err(dev, "failed to assert phy reset\n");
+		dev_err(phy->dev, "failed to assert phy reset\n");
  		return ret;
  	}
 
@@ -119,7 +119,7 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
  				       20 * 1000,
  				       50);
  	if (ret) {
-		dev_err(&priv->dev, "pll lock timeout!\n");
+		dev_err(phy->dev, "pll lock timeout!\n");
  		goto err_pll_lock;
  	}
 
@@ -133,7 +133,7 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
  				       20 * 1000,
  				       50);
  	if (ret) {
-		dev_err(&priv->dev, "pll output enable timeout!\n");
+		dev_err(phy->dev, "pll output enable timeout!\n");
  		goto err_pll_lock;
  	}
 
@@ -149,7 +149,7 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
  				       20 * 1000,
  				       50);
  	if (ret) {
-		dev_err(&priv->dev, "pll relock timeout!\n");
+		dev_err(phy->dev, "pll relock timeout!\n");
  		goto err_pll_lock;
  	}
 
@@ -173,7 +173,7 @@ static int rockchip_pcie_phy_power_off(struct phy *phy)
 
  	ret = reset_assert(&priv->phy_rst);
  	if (ret) {
-		dev_err(dev, "failed to assert phy reset\n");
+		dev_err(phy->dev, "failed to assert phy reset\n");
  		return ret;
  	}
 
@@ -187,13 +187,13 @@ static int rockchip_pcie_phy_init(struct phy *phy)
 
  	ret = clk_enable(&priv->refclk);
  	if (ret) {
-		dev_err(dev, "failed to enable refclk clock\n");
+		dev_err(phy->dev, "failed to enable refclk clock\n");
  		return ret;
  	}
 
  	ret = reset_assert(&priv->phy_rst);
  	if (ret) {
-		dev_err(dev, "failed to assert phy reset\n");
+		dev_err(phy->dev, "failed to assert phy reset\n");
  		goto err_reset;
  	}
 
drivers/phy/rockchip/phy-rockchip-typec.c +3 -3
index c9c8e1c542..da00daa447 100644
@@ -448,7 +448,7 @@ static void rockchip_tcphy_rx_usb3_cfg_lane(struct rockchip_tcphy *priv,
  	writel(0xfb, priv->reg_base + XCVR_DIAG_BIDI_CTRL(lane));
  }
 
-static int rockchip_tcphy_init(struct rockchip_tcphy *priv)
+static int rockchip_tcphy_init(struct phy *phy, struct rockchip_tcphy *priv)
  {
  	const struct rockchip_usb3phy_port_cfg *cfg = priv->port_cfgs;
  	u32 val;
@@ -559,9 +559,9 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
  		return 0;
 
  	if (priv->mode == MODE_DISCONNECT) {
-		ret = rockchip_tcphy_init(priv);
+		ret = rockchip_tcphy_init(phy, priv);
  		if (ret) {
-			dev_err(dev, "failed to init tcphy (ret=%d)\n", ret);
+			dev_err(phy->dev, "failed to init tcphy (ret=%d)\n", ret);
  			return ret;
  		}
  	}
#46 lore raw

PATCH v2 28/46 phy: sun4i-usb: Fix not calling dev_err with a device

In reply to Sean Anderson

This uses phy's device

---

Changes in v2:
- New

 drivers/phy/allwinner/phy-sun4i-usb.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/phy/allwinner/phy-sun4i-usb.c +8 -4
index f050645044..7b9d3eefc5 100644
@@ -272,13 +272,15 @@ static int sun4i_usb_phy_init(struct phy *phy)
 
 	ret = clk_enable(&usb_phy->clocks);
 	if (ret) {
-		dev_err(dev, "failed to enable usb_%ldphy clock\n", phy->id);
+		dev_err(phy->dev, "failed to enable usb_%ldphy clock\n",
+			phy->id);
 		return ret;
 	}
 
 	ret = reset_deassert(&usb_phy->resets);
 	if (ret) {
-		dev_err(dev, "failed to deassert usb_%ldreset reset\n", phy->id);
+		dev_err(phy->dev, "failed to deassert usb_%ldreset reset\n",
+			phy->id);
 		return ret;
 	}
 
@@ -338,13 +340,15 @@ static int sun4i_usb_phy_exit(struct phy *phy)
 
 	ret = clk_disable(&usb_phy->clocks);
 	if (ret) {
-		dev_err(dev, "failed to disable usb_%ldphy clock\n", phy->id);
+		dev_err(phy->dev, "failed to disable usb_%ldphy clock\n",
+			phy->id);
 		return ret;
 	}
 
 	ret = reset_assert(&usb_phy->resets);
 	if (ret) {
-		dev_err(dev, "failed to assert usb_%ldreset reset\n", phy->id);
+		dev_err(phy->dev, "failed to assert usb_%ldreset reset\n",
+			phy->id);
 		return ret;
 	}
 
Signature · 1 line
2.28.0
#47 lore raw

PATCH v2 29/46 phy: ti: Fix not calling dev_err with a device

In reply to Sean Anderson

phy doesn't exist; we need to use x instead.

---

Changes in v2:
- New

 drivers/phy/phy-ti-am654.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-ti-am654.c +2 -2
index 6907c1afb3..cc73760c8b 100644
@@ -318,13 +318,13 @@ static int serdes_am654_of_xlate(struct phy *x,
 	struct serdes_am654 *phy = dev_get_priv(x->dev);
 
 	if (args->args_count != 2) {
-		dev_err(phy->dev, "Invalid DT PHY argument count: %d\n",
+		dev_err(x->dev, "Invalid DT PHY argument count: %d\n",
 			args->args_count);
 		return -EINVAL;
 	}
 
 	if (args->args[0] != PHY_TYPE_PCIE) {
-		dev_err(phy->dev, "Unrecognized PHY type: %d\n",
+		dev_err(x->dev, "Unrecognized PHY type: %d\n",
 			args->args[0]);
 		return -EINVAL;
 	}
Signature · 1 line
2.28.0
#48 lore raw

PATCH v2 30/46 phy: usbphyc: Fix not calling dev_err with a device

In reply to Sean Anderson

Use the phy's device.

---

Changes in v2:
- New

 drivers/phy/phy-stm32-usbphyc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-stm32-usbphyc.c +1 -1
index c6d3048602..9d4296d649 100644
@@ -311,7 +311,7 @@ static int stm32_usbphyc_of_xlate(struct phy *phy,
 
 	if ((phy->id == 0 && args->args_count != 1) ||
 	    (phy->id == 1 && args->args_count != 2)) {
-		dev_err(dev, "invalid number of cells for phy port%ld\n",
+		dev_err(phy->dev, "invalid number of cells for phy port%ld\n",
 			phy->id);
 		return -EINVAL;
 	}
Signature · 1 line
2.28.0
#49 lore raw

PATCH v2 30/46 phy: usbphyc: Fix not calling dev_err with a device

Hi Sean

Quoted 16 lines · Sean Anderson

Use the phy's device.

---

Changes in v2:
- New

 drivers/phy/phy-stm32-usbphyc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-stm32-usbphyc.c +0 -0
index c6d3048602..9d4296d649 100644

drivers/phy/phy-stm32-usbphyc.c static int stm32_usbphyc_of_xlate(struct phy *phy, · line 317

Quoted 8 lines
drivers/phy/phy-stm32-usbphyc.c +1 -1
@@ -311,7 +311,7 @@ static int stm32_usbphyc_of_xlate(struct phy *phy,
 
 	if ((phy->id == 0 && args->args_count != 1) ||
 	    (phy->id == 1 && args->args_count != 2)) {
-		dev_err(dev, "invalid number of cells for phy port%ld\n",
+		dev_err(phy->dev, "invalid number of cells for phy port%ld\n",
 			phy->id);
 		return -EINVAL;
 	}

Thanks

#51 lore raw

PATCH v2 31/46 remoteproc: Remove unused function rproc_elf_sanity_check

In reply to Sean Anderson

This function is never used anywhere, and it also tries to log with a nonexistant device.

---

(no changes since v1)

 drivers/remoteproc/rproc-elf-loader.c | 16 ----------------
 include/remoteproc.h                  | 13 -------------
 2 files changed, 29 deletions(-)
drivers/remoteproc/rproc-elf-loader.c +0 -16
index c464ecebb7..b185a6cafb 100644
@@ -158,22 +158,6 @@ int rproc_elf64_sanity_check(ulong addr, ulong size)
 	return 0;
 }
 
-/* Basic function to verify ELF image format */
-int rproc_elf_sanity_check(ulong addr, ulong size)
-{
-	Elf32_Ehdr *ehdr = (Elf32_Ehdr *)addr;
-
-	if (!addr) {
-		dev_err(dev, "Invalid firmware address\n");
-		return -EFAULT;
-	}
-
-	if (ehdr->e_ident[EI_CLASS] == ELFCLASS64)
-		return rproc_elf64_sanity_check(addr, size);
-	else
-		return rproc_elf32_sanity_check(addr, size);
-}
-
 int rproc_elf32_load_image(struct udevice *dev, unsigned long addr, ulong size)
 {
 	Elf32_Ehdr *ehdr; /* Elf header structure pointer */
include/remoteproc.h +0 -13
index a903acb9b2..74d01723f6 100644
@@ -226,19 +226,6 @@ int rproc_elf32_sanity_check(ulong addr, ulong size);
  */
 int rproc_elf64_sanity_check(ulong addr, ulong size);
 
-/**
- * rproc_elf_sanity_check() - Verify if an image is a valid ELF one
- *
- * Check if a valid ELF image exists at the given memory location. Auto
- * detects ELF32/ELF64 and verifies basic ELF64/ELF32 format requirements
- * like magic number and sections size.
- *
- * @addr:	address of the image to verify
- * @size:	size of the image
- * @return 0 if the image looks good, else appropriate error value.
- */
-int rproc_elf_sanity_check(ulong addr, ulong size);
-
 /**
  * rproc_elf32_load_image() - load an ELF32 image
  * @dev:	device loading the ELF32 image
Signature · 1 line
2.28.0
#52 lore raw

PATCH v2 32/46 remoteproc: k3-r5: Fix not calling dev_xxx with a device

In reply to Sean Anderson

Usually we can get a device from the current core, but some dev_dbg calls have been converted to debug, since we are called on a cluster.

---

Changes in v2:
- New

 drivers/remoteproc/ti_k3_r5f_rproc.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/remoteproc/ti_k3_r5f_rproc.c +14 -10
index 1a7f1f8a00..94454e7b65 100644
@@ -150,7 +150,7 @@ static int k3_r5f_lockstep_release(struct k3_r5f_cluster *cluster)
 {
 	int ret, c;
 
-	dev_dbg(dev, "%s\n", __func__);
+	debug("%s\n", __func__);
 
 	for (c = NR_CORES - 1; c >= 0; c--) {
 		ret = ti_sci_proc_power_domain_on(&cluster->cores[c]->tsp);
@@ -186,7 +186,7 @@ static int k3_r5f_split_release(struct k3_r5f_core *core)
 {
 	int ret;
 
-	dev_dbg(dev, "%s\n", __func__);
+	dev_dbg(core->dev, "%s\n", __func__);
 
 	ret = ti_sci_proc_power_domain_on(&core->tsp);
 	if (ret) {
@@ -231,25 +231,29 @@ static int k3_r5f_core_sanity_check(struct k3_r5f_core *core)
 	struct k3_r5f_cluster *cluster = core->cluster;
 
 	if (core->in_use) {
-		dev_err(dev, "Invalid op: Trying to load/start on already running core %d\n",
+		dev_err(core->dev,
+			"Invalid op: Trying to load/start on already running core %d\n",
 			core->tsp.proc_id);
 		return -EINVAL;
 	}
 
 	if (cluster->mode == CLUSTER_MODE_LOCKSTEP && !cluster->cores[1]) {
-		printf("Secondary core is not probed in this cluster\n");
+		dev_err(core->dev,
+			"Secondary core is not probed in this cluster\n");
 		return -EAGAIN;
 	}
 
 	if (cluster->mode == CLUSTER_MODE_LOCKSTEP && !is_primary_core(core)) {
-		dev_err(dev, "Invalid op: Trying to start secondary core %d in lockstep mode\n",
+		dev_err(core->dev,
+			"Invalid op: Trying to start secondary core %d in lockstep mode\n",
 			core->tsp.proc_id);
 		return -EINVAL;
 	}
 
 	if (cluster->mode == CLUSTER_MODE_SPLIT && !is_primary_core(core)) {
 		if (!core->cluster->cores[0]->in_use) {
-			dev_err(dev, "Invalid seq: Enable primary core before loading secondary core\n");
+			dev_err(core->dev,
+				"Invalid seq: Enable primary core before loading secondary core\n");
 			return -EINVAL;
 		}
 	}
@@ -401,7 +405,7 @@ static int k3_r5f_split_reset(struct k3_r5f_core *core)
 {
 	int ret;
 
-	dev_dbg(dev, "%s\n", __func__);
+	dev_dbg(core->dev, "%s\n", __func__);
 
 	if (reset_assert(&core->reset))
 		ret = -EINVAL;
@@ -416,7 +420,7 @@ static int k3_r5f_lockstep_reset(struct k3_r5f_cluster *cluster)
 {
 	int ret = 0, c;
 
-	dev_dbg(dev, "%s\n", __func__);
+	debug("%s\n", __func__);
 
 	for (c = 0; c < NR_CORES; c++)
 		if (reset_assert(&cluster->cores[c]->reset))
@@ -548,7 +552,7 @@ static int k3_r5f_rproc_configure(struct k3_r5f_core *core)
 	u64 boot_vec = 0;
 	int ret;
 
-	dev_dbg(dev, "%s\n", __func__);
+	dev_dbg(core->dev, "%s\n", __func__);
 
 	ret = ti_sci_proc_request(&core->tsp);
 	if (ret < 0)
@@ -641,7 +645,7 @@ static int k3_r5f_of_to_priv(struct k3_r5f_core *core)
 {
 	int ret;
 
-	dev_dbg(dev, "%s\n", __func__);
+	dev_dbg(core->dev, "%s\n", __func__);
 
 	core->atcm_enable = dev_read_u32_default(core->dev, "atcm-enable", 0);
 	core->btcm_enable = dev_read_u32_default(core->dev, "btcm-enable", 1);
Signature · 1 line
2.28.0
#53 lore raw

PATCH v2 33/46 remoteproc: k3: Fix not calling dev_xxx with a device

In reply to Sean Anderson

Pass a device to functions which log with one.

---

Changes in v2:
- New

 drivers/remoteproc/k3_system_controller.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/remoteproc/k3_system_controller.c +5 -4
index 54209fccb3..702d98d1a8 100644
@@ -100,7 +100,7 @@ void k3_sysctrler_load_msg_setup(struct k3_sysctrler_load_msg *fw,
 	fw->buffer_size = size;
 }
 
-static int k3_sysctrler_load_response(u32 *buf)
+static int k3_sysctrler_load_response(struct udevice *dev, u32 *buf)
 {
 	struct k3_sysctrler_load_msg *fw;
 
@@ -129,7 +129,8 @@ static int k3_sysctrler_load_response(u32 *buf)
 	return 0;
 }
 
-static int k3_sysctrler_boot_notification_response(u32 *buf)
+static int k3_sysctrler_boot_notification_response(struct udevice *dev,
+						   u32 *buf)
 {
 	struct k3_sysctrler_boot_notification_msg *boot;
 
@@ -193,7 +194,7 @@ static int k3_sysctrler_load(struct udevice *dev, ulong addr, ulong size)
 	}
 
 	/* Process the response */
-	ret = k3_sysctrler_load_response(msg.buf);
+	ret = k3_sysctrler_load_response(dev, msg.buf);
 	if (ret)
 		return ret;
 
@@ -230,7 +231,7 @@ static int k3_sysctrler_start(struct udevice *dev)
 	}
 
 	/* Process the response */
-	ret = k3_sysctrler_boot_notification_response(msg.buf);
+	ret = k3_sysctrler_boot_notification_response(dev, msg.buf);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.28.0
#54 lore raw

PATCH v2 34/46 soc: qualcomm: Fix not calling dev_err with a device

In reply to Sean Anderson

Remove the indirection.

---

Changes in v2:
- New

 drivers/smem/msm_smem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/smem/msm_smem.c +1 -1
index 2557269bc5..597d425d11 100644
@@ -879,7 +879,7 @@ static int qcom_smem_probe(struct udevice *dev)
 	header = smem->regions[0].virt_base;
 	if (le32_to_cpu(header->initialized) != 1 ||
 	    le32_to_cpu(header->reserved)) {
-		dev_err(&pdev->dev, "SMEM is not initialized by SBL\n");
+		dev_err(dev, "SMEM is not initialized by SBL\n");
 		return -EINVAL;
 	}
 
Signature · 1 line
2.28.0
#56 lore raw

PATCH v2 35/46 spi: sunxi: Fix not calling dev_err with a device

In reply to Sean Anderson

Use bus and not dev.

---

Changes in v2:
- New

 drivers/spi/spi-sunxi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-sunxi.c +3 -3
index cd2e17bfd1..0844a5a0a6 100644
@@ -489,19 +489,19 @@ static int sun4i_spi_probe(struct udevice *bus)
 
 	ret = clk_get_by_name(bus, "ahb", &priv->clk_ahb);
 	if (ret) {
-		dev_err(dev, "failed to get ahb clock\n");
+		dev_err(bus, "failed to get ahb clock\n");
 		return ret;
 	}
 
 	ret = clk_get_by_name(bus, "mod", &priv->clk_mod);
 	if (ret) {
-		dev_err(dev, "failed to get mod clock\n");
+		dev_err(bus, "failed to get mod clock\n");
 		return ret;
 	}
 
 	ret = reset_get_by_index(bus, 0, &priv->reset);
 	if (ret && ret != -ENOENT) {
-		dev_err(dev, "failed to get reset\n");
+		dev_err(bus, "failed to get reset\n");
 		return ret;
 	}
 
Signature · 1 line
2.28.0
#57 lore raw

PATCH v2 36/46 spi: zynqmp_gqspi: Fix not calling dev_err with a device

In reply to Sean Anderson

Use bus instead of dev.

---

Changes in v2:
- New

 drivers/spi/zynqmp_gqspi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/zynqmp_gqspi.c +3 -3
index a72986be90..e0e6687037 100644
@@ -346,20 +346,20 @@ static int zynqmp_qspi_probe(struct udevice *bus)
 
 	ret = clk_get_by_index(bus, 0, &clk);
 	if (ret < 0) {
-		dev_err(dev, "failed to get clock\n");
+		dev_err(bus, "failed to get clock\n");
 		return ret;
 	}
 
 	clock = clk_get_rate(&clk);
 	if (IS_ERR_VALUE(clock)) {
-		dev_err(dev, "failed to get rate\n");
+		dev_err(bus, "failed to get rate\n");
 		return clock;
 	}
 	debug("%s: CLK %ld\n", __func__, clock);
 
 	ret = clk_enable(&clk);
 	if (ret && ret != -ENOSYS) {
-		dev_err(dev, "failed to enable clock\n");
+		dev_err(bus, "failed to enable clock\n");
 		return ret;
 	}
 	plat->frequency = clock;
Signature · 1 line
2.28.0
#58 lore raw

PATCH v2 36/46 spi: zynqmp_gqspi: Fix not calling dev_err with a device

Hi,

Quoted 30 lines · Sean Anderson

Use bus instead of dev.

---

Changes in v2:
- New

 drivers/spi/zynqmp_gqspi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/zynqmp_gqspi.c +2 -2
index a72986be90..e0e6687037 100644
@@ -346,20 +346,20 @@ static int zynqmp_qspi_probe(struct udevice *bus)
 
 	ret = clk_get_by_index(bus, 0, &clk);
 	if (ret < 0) {
-		dev_err(dev, "failed to get clock\n");
+		dev_err(bus, "failed to get clock\n");
 		return ret;
 	}
 
 	clock = clk_get_rate(&clk);
 	if (IS_ERR_VALUE(clock)) {
-		dev_err(dev, "failed to get rate\n");
+		dev_err(bus, "failed to get rate\n");
 		return clock;

drivers/spi/zynqmp_gqspi.c static int zynqmp_qspi_probe(struct udevice *bus) · line 365

Quoted 10 lines
drivers/spi/zynqmp_gqspi.c +1 -1
 	}
 	debug("%s: CLK %ld\n", __func__, clock);
 
 	ret = clk_enable(&clk);
 	if (ret && ret != -ENOSYS) {
-		dev_err(dev, "failed to enable clock\n");
+		dev_err(bus, "failed to enable clock\n");
 		return ret;
 	}
 	plat->frequency = clock;

Good catch.

Thanks,
Michal

#59 lore raw

PATCH v2 37/46 sysreset: ti: Fix not calling dev_err with a device

In reply to Sean Anderson

The rst variable doesn't exist.

---

Changes in v2:
- New

 drivers/sysreset/sysreset-ti-sci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/sysreset/sysreset-ti-sci.c +1 -2
index 3877b9bc12..7707c72bb5 100644
@@ -51,8 +51,7 @@ static int ti_sci_sysreset_request(struct udevice *dev, enum sysreset_t type)
 
 	ret = cops->reboot_device(sci);
 	if (ret)
-		dev_err(rst->dev, "%s: reboot_device failed (%d)\n",
-			__func__, ret);
+		dev_err(dev, "%s: reboot_device failed (%d)\n", __func__, ret);
 
 	return ret;
 }
Signature · 1 line
2.28.0
#60 lore raw

PATCH v2 38/46 usb: cdns3: Fix not calling dev_xxx with a device

In reply to Sean Anderson

ep0.c also need to include dm.h so dev_xxx can access udevice fields.

---

Changes in v2:
- New

 drivers/usb/cdns3/ep0.c    | 5 +++--
 drivers/usb/cdns3/gadget.c | 3 +--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/usb/cdns3/ep0.c +3 -2
index a08c694559..acff79ae1c 100644
@@ -11,8 +11,9 @@
  */
 
 #include <cpu_func.h>
-#include <asm/cache.h>
+#include <dm.h>
 #include <dm/device_compat.h>
+#include <asm/cache.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/usb/composite.h>
@@ -810,7 +811,7 @@ int cdns3_gadget_ep_set_wedge(struct usb_ep *ep)
 {
 	struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep);
 
-	dev_dbg(priv_dev->dev, "Wedge for %s\n", ep->name);
+	dev_dbg(priv_ep->cdns3_dev->dev, "Wedge for %s\n", ep->name);
 	cdns3_gadget_ep_set_halt(ep, 1);
 	priv_ep->flags |= EP_WEDGE;
 
drivers/usb/cdns3/gadget.c +1 -2
index 8f81d17ec8..83dbb5a103 100644
@@ -2399,8 +2399,7 @@ static void cdns3_gadget_udc_set_speed(struct usb_gadget *gadget,
 	case USB_SPEED_SUPER:
 		break;
 	default:
-		dev_err(cdns->dev, "invalid speed parameter %d\n",
-			speed);
+		dev_err(priv_dev->dev, "invalid speed parameter %d\n", speed);
 	}
 
 	priv_dev->gadget.speed = speed;
Signature · 1 line
2.28.0
#61 lore raw

PATCH v2 39/46 usb: dwc2: Fix not calling dev_xxx with a device

In reply to Sean Anderson

This adds a dev argument to some functions so dev_xxx always has a device to log with. In one instance we must use use a different log function when we are compiled without DM_USB.

---

Changes in v2:
- New

 drivers/usb/host/dwc2.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/usb/host/dwc2.c +23 -16
index cefe9d83b1..f1d13b1c1d 100644
@@ -114,7 +114,8 @@ static void init_fslspclksel(struct dwc2_core_regs *regs)
  * @param regs Programming view of DWC_otg controller.
  * @param num Tx FIFO to flush.
  */
-static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
+static void dwc_otg_flush_tx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs, const int num)
 {
 	int ret;
 
@@ -134,7 +135,8 @@ static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
  *
  * @param regs Programming view of DWC_otg controller.
  */
-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+static void dwc_otg_flush_rx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs)
 {
 	int ret;
 
@@ -152,7 +154,8 @@ static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
  * Do core a soft reset of the core.  Be careful with this because it
  * resets all the internal state machines of the core.
  */
-static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
+static void dwc_otg_core_reset(struct udevice *dev,
+			       struct dwc2_core_regs *regs)
 {
 	int ret;
 
@@ -284,8 +287,8 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 	clrbits_le32(&regs->gotgctl, DWC2_GOTGCTL_HSTSETHNPEN);
 
 	/* Make sure the FIFOs are flushed. */
-	dwc_otg_flush_tx_fifo(regs, 0x10);	/* All Tx FIFOs */
-	dwc_otg_flush_rx_fifo(regs);
+	dwc_otg_flush_tx_fifo(dev, regs, 0x10);	/* All Tx FIFOs */
+	dwc_otg_flush_rx_fifo(dev, regs);
 
 	/* Flush out any leftover queued requests. */
 	num_channels = readl(&regs->ghwcfg2);
@@ -306,7 +309,7 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 		ret = wait_for_bit_le32(&regs->hc_regs[i].hcchar,
 					DWC2_HCCHAR_CHEN, false, 1000, false);
 		if (ret)
-			dev_info("%s: Timeout!\n", __func__);
+			dev_info(dev, "%s: Timeout!\n", __func__);
 	}
 
 	/* Turn on the vbus power. */
@@ -330,8 +333,9 @@ static void dwc_otg_core_host_init(struct udevice *dev,
  *
  * @param regs Programming view of the DWC_otg controller
  */
-static void dwc_otg_core_init(struct dwc2_priv *priv)
+static void dwc_otg_core_init(struct udevice *dev)
 {
+	struct dwc2_priv *priv = dev_get_priv(dev);
 	struct dwc2_core_regs *regs = priv->regs;
 	uint32_t ahbcfg = 0;
 	uint32_t usbcfg = 0;
@@ -360,7 +364,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset the Controller */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * This programming sequence needs to happen in FS mode before
@@ -372,7 +376,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_PHYSEL);
 
 	/* Reset after a PHY select */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * Program DCFG.DevSpd or HCFG.FSLSPclkSel to 48Mhz in FS.
@@ -419,7 +423,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset after setting the PHY parameters */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 #endif
 
 	usbcfg = readl(&regs->gusbcfg);
@@ -1128,7 +1132,12 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev,
 	timeout = get_timer(0) + USB_TIMEOUT_MS(pipe);
 	for (;;) {
 		if (get_timer(0) > timeout) {
-			dev_err(dev, "Timeout poll on interrupt endpoint\n");
+#if CONFIG_IS_ENABLED(DM_USB)
+			dev_err(dev->dev,
+				"Timeout poll on interrupt endpoint\n");
+#else
+			log_err("Timeout poll on interrupt endpoint\n");
+#endif
 			return -ETIMEDOUT;
 		}
 		ret = _submit_bulk_msg(priv, dev, pipe, buffer, len);
@@ -1194,7 +1203,7 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
 	priv->ext_vbus = 0;
 #endif
 
-	dwc_otg_core_init(priv);
+	dwc_otg_core_init(dev);
 	dwc_otg_core_host_init(dev, regs);
 
 	clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
@@ -1320,12 +1329,10 @@ static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev,
 static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc2_priv *priv = dev_get_priv(dev);
-	fdt_addr_t addr;
 
-	addr = dev_read_addr(dev);
-	if (addr == FDT_ADDR_T_NONE)
+	priv->regs = dev_read_addr_ptr(dev);
+	if (!priv->regs)
 		return -EINVAL;
-	priv->regs = (struct dwc2_core_regs *)addr;
 
 	priv->oc_disable = dev_read_bool(dev, "disable-over-current");
 	priv->hnp_srp_disable = dev_read_bool(dev, "hnp-srp-disable");
Signature · 1 line
2.28.0
#62 lore raw

PATCH v2 39/46 usb: dwc2: Fix not calling dev_xxx with a device

Hi Sean

Quoted 2 lines · Sean Anderson

This adds a dev argument to some functions so dev_xxx always has a device to log with. In one instance we must use use a different log function when

remove one "use"

Quoted 10 lines

we are compiled without DM_USB.

---

Changes in v2:
- New

 drivers/usb/host/dwc2.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

Thanks

Quoted 131 lines
drivers/usb/host/dwc2.c +23 -16
index cefe9d83b1..f1d13b1c1d 100644
@@ -114,7 +114,8 @@ static void init_fslspclksel(struct dwc2_core_regs *regs)
  * @param regs Programming view of DWC_otg controller.
  * @param num Tx FIFO to flush.
  */
-static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
+static void dwc_otg_flush_tx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs, const int num)
 {
 	int ret;
 
@@ -134,7 +135,8 @@ static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
  *
  * @param regs Programming view of DWC_otg controller.
  */
-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+static void dwc_otg_flush_rx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs)
 {
 	int ret;
 
@@ -152,7 +154,8 @@ static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
  * Do core a soft reset of the core.  Be careful with this because it
  * resets all the internal state machines of the core.
  */
-static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
+static void dwc_otg_core_reset(struct udevice *dev,
+			       struct dwc2_core_regs *regs)
 {
 	int ret;
 
@@ -284,8 +287,8 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 	clrbits_le32(&regs->gotgctl, DWC2_GOTGCTL_HSTSETHNPEN);
 
 	/* Make sure the FIFOs are flushed. */
-	dwc_otg_flush_tx_fifo(regs, 0x10);	/* All Tx FIFOs */
-	dwc_otg_flush_rx_fifo(regs);
+	dwc_otg_flush_tx_fifo(dev, regs, 0x10);	/* All Tx FIFOs */
+	dwc_otg_flush_rx_fifo(dev, regs);
 
 	/* Flush out any leftover queued requests. */
 	num_channels = readl(&regs->ghwcfg2);
@@ -306,7 +309,7 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 		ret = wait_for_bit_le32(&regs->hc_regs[i].hcchar,
 					DWC2_HCCHAR_CHEN, false, 1000, false);
 		if (ret)
-			dev_info("%s: Timeout!\n", __func__);
+			dev_info(dev, "%s: Timeout!\n", __func__);
 	}
 
 	/* Turn on the vbus power. */
@@ -330,8 +333,9 @@ static void dwc_otg_core_host_init(struct udevice *dev,
  *
  * @param regs Programming view of the DWC_otg controller
  */
-static void dwc_otg_core_init(struct dwc2_priv *priv)
+static void dwc_otg_core_init(struct udevice *dev)
 {
+	struct dwc2_priv *priv = dev_get_priv(dev);
 	struct dwc2_core_regs *regs = priv->regs;
 	uint32_t ahbcfg = 0;
 	uint32_t usbcfg = 0;
@@ -360,7 +364,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset the Controller */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * This programming sequence needs to happen in FS mode before
@@ -372,7 +376,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_PHYSEL);
 
 	/* Reset after a PHY select */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * Program DCFG.DevSpd or HCFG.FSLSPclkSel to 48Mhz in FS.
@@ -419,7 +423,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset after setting the PHY parameters */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 #endif
 
 	usbcfg = readl(&regs->gusbcfg);
@@ -1128,7 +1132,12 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev,
 	timeout = get_timer(0) + USB_TIMEOUT_MS(pipe);
 	for (;;) {
 		if (get_timer(0) > timeout) {
-			dev_err(dev, "Timeout poll on interrupt endpoint\n");
+#if CONFIG_IS_ENABLED(DM_USB)
+			dev_err(dev->dev,
+				"Timeout poll on interrupt endpoint\n");
+#else
+			log_err("Timeout poll on interrupt endpoint\n");
+#endif
 			return -ETIMEDOUT;
 		}
 		ret = _submit_bulk_msg(priv, dev, pipe, buffer, len);
@@ -1194,7 +1203,7 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
 	priv->ext_vbus = 0;
 #endif
 
-	dwc_otg_core_init(priv);
+	dwc_otg_core_init(dev);
 	dwc_otg_core_host_init(dev, regs);
 
 	clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
@@ -1320,12 +1329,10 @@ static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev,
 static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc2_priv *priv = dev_get_priv(dev);
-	fdt_addr_t addr;
 
-	addr = dev_read_addr(dev);
-	if (addr == FDT_ADDR_T_NONE)
+	priv->regs = dev_read_addr_ptr(dev);
+	if (!priv->regs)
 		return -EINVAL;
-	priv->regs = (struct dwc2_core_regs *)addr;
 
 	priv->oc_disable = dev_read_bool(dev, "disable-over-current");
 	priv->hnp_srp_disable = dev_read_bool(dev, "hnp-srp-disable");
#63 lore raw

PATCH v2 39/46 usb: dwc2: Fix not calling dev_xxx with a device

Quoted 6 lines · Patrice CHOTARD

Hi Sean

Quoted 2 lines · Sean Anderson

This adds a dev argument to some functions so dev_xxx always has a device to log with. In one instance we must use use a different log function when

remove one "use"

Thanks for catching that.

--Sean

Quoted 147 lines
Quoted 10 lines

we are compiled without DM_USB.

---

Changes in v2:
- New

 drivers/usb/host/dwc2.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

Thanks

Quoted 131 lines
drivers/usb/host/dwc2.c +23 -16
index cefe9d83b1..f1d13b1c1d 100644
@@ -114,7 +114,8 @@ static void init_fslspclksel(struct dwc2_core_regs *regs)
  * @param regs Programming view of DWC_otg controller.
  * @param num Tx FIFO to flush.
  */
-static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
+static void dwc_otg_flush_tx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs, const int num)
 {
 	int ret;
 
@@ -134,7 +135,8 @@ static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
  *
  * @param regs Programming view of DWC_otg controller.
  */
-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+static void dwc_otg_flush_rx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs)
 {
 	int ret;
 
@@ -152,7 +154,8 @@ static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
  * Do core a soft reset of the core.  Be careful with this because it
  * resets all the internal state machines of the core.
  */
-static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
+static void dwc_otg_core_reset(struct udevice *dev,
+			       struct dwc2_core_regs *regs)
 {
 	int ret;
 
@@ -284,8 +287,8 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 	clrbits_le32(&regs->gotgctl, DWC2_GOTGCTL_HSTSETHNPEN);
 
 	/* Make sure the FIFOs are flushed. */
-	dwc_otg_flush_tx_fifo(regs, 0x10);	/* All Tx FIFOs */
-	dwc_otg_flush_rx_fifo(regs);
+	dwc_otg_flush_tx_fifo(dev, regs, 0x10);	/* All Tx FIFOs */
+	dwc_otg_flush_rx_fifo(dev, regs);
 
 	/* Flush out any leftover queued requests. */
 	num_channels = readl(&regs->ghwcfg2);
@@ -306,7 +309,7 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 		ret = wait_for_bit_le32(&regs->hc_regs[i].hcchar,
 					DWC2_HCCHAR_CHEN, false, 1000, false);
 		if (ret)
-			dev_info("%s: Timeout!\n", __func__);
+			dev_info(dev, "%s: Timeout!\n", __func__);
 	}
 
 	/* Turn on the vbus power. */
@@ -330,8 +333,9 @@ static void dwc_otg_core_host_init(struct udevice *dev,
  *
  * @param regs Programming view of the DWC_otg controller
  */
-static void dwc_otg_core_init(struct dwc2_priv *priv)
+static void dwc_otg_core_init(struct udevice *dev)
 {
+	struct dwc2_priv *priv = dev_get_priv(dev);
 	struct dwc2_core_regs *regs = priv->regs;
 	uint32_t ahbcfg = 0;
 	uint32_t usbcfg = 0;
@@ -360,7 +364,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset the Controller */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * This programming sequence needs to happen in FS mode before
@@ -372,7 +376,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_PHYSEL);
 
 	/* Reset after a PHY select */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * Program DCFG.DevSpd or HCFG.FSLSPclkSel to 48Mhz in FS.
@@ -419,7 +423,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset after setting the PHY parameters */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 #endif
 
 	usbcfg = readl(&regs->gusbcfg);
@@ -1128,7 +1132,12 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev,
 	timeout = get_timer(0) + USB_TIMEOUT_MS(pipe);
 	for (;;) {
 		if (get_timer(0) > timeout) {
-			dev_err(dev, "Timeout poll on interrupt endpoint\n");
+#if CONFIG_IS_ENABLED(DM_USB)
+			dev_err(dev->dev,
+				"Timeout poll on interrupt endpoint\n");
+#else
+			log_err("Timeout poll on interrupt endpoint\n");
+#endif
 			return -ETIMEDOUT;
 		}
 		ret = _submit_bulk_msg(priv, dev, pipe, buffer, len);
@@ -1194,7 +1203,7 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
 	priv->ext_vbus = 0;
 #endif
 
-	dwc_otg_core_init(priv);
+	dwc_otg_core_init(dev);
 	dwc_otg_core_host_init(dev, regs);
 
 	clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
@@ -1320,12 +1329,10 @@ static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev,
 static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc2_priv *priv = dev_get_priv(dev);
-	fdt_addr_t addr;
 
-	addr = dev_read_addr(dev);
-	if (addr == FDT_ADDR_T_NONE)
+	priv->regs = dev_read_addr_ptr(dev);
+	if (!priv->regs)
 		return -EINVAL;
-	priv->regs = (struct dwc2_core_regs *)addr;
 
 	priv->oc_disable = dev_read_bool(dev, "disable-over-current");
 	priv->hnp_srp_disable = dev_read_bool(dev, "hnp-srp-disable");
#64 lore raw

PATCH v2 39/46 usb: dwc2: Fix not calling dev_xxx with a device

In reply to Sean Anderson

Hi Sean,

Quoted 149 lines

From: Sean Anderson <[email protected]>
Sent: mardi 15 septembre 2020 16:45

This adds a dev argument to some functions so dev_xxx always has a device to log with. In one instance we must use use a different log function when we are compiled without DM_USB.

---

Changes in v2:
- New

 drivers/usb/host/dwc2.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/usb/host/dwc2.c index renamed from drivers/usb/host/dwc2.c +0 -0

cefe9d83b1..f1d13b1c1d 100644

drivers/usb/host/dwc2.c +9 -6
@@ -114,7 +114,8 @@ static void init_fslspclksel(struct dwc2_core_regs *regs)
  * @param regs Programming view of DWC_otg controller.
  * @param num Tx FIFO to flush.
  */
-static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
+static void dwc_otg_flush_tx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs, const int num)
 {
 	int ret;
 
@@ -134,7 +135,8 @@ static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs
 *regs, const int num)
  *
  * @param regs Programming view of DWC_otg controller.
  */
-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+static void dwc_otg_flush_rx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs)
 {
 	int ret;
@@ -152,7 +154,8 @@ static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs
 *regs)
  * Do core a soft reset of the core.  Be careful with this because it
  * resets all the internal state machines of the core.
  */
-static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
+static void dwc_otg_core_reset(struct udevice *dev,
+			       struct dwc2_core_regs *regs)
 {
 	int ret;
@@ -284,8 +287,8 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 	clrbits_le32(&regs->gotgctl, DWC2_GOTGCTL_HSTSETHNPEN);
 
 	/* Make sure the FIFOs are flushed. */
-	dwc_otg_flush_tx_fifo(regs, 0x10);	/* All Tx FIFOs */
-	dwc_otg_flush_rx_fifo(regs);
+	dwc_otg_flush_tx_fifo(dev, regs, 0x10);	/* All Tx FIFOs */
+	dwc_otg_flush_rx_fifo(dev, regs);
 
 	/* Flush out any leftover queued requests. */
 	num_channels = readl(&regs->ghwcfg2);
@@ -306,7 +309,7 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 		ret = wait_for_bit_le32(&regs->hc_regs[i].hcchar,
 					DWC2_HCCHAR_CHEN, false, 1000,
 false);
 		if (ret)
-			dev_info("%s: Timeout!\n", __func__);
+			dev_info(dev, "%s: Timeout!\n", __func__);
 	}
 
drivers/usb/host/dwc2.c +3 -2
 	/* Turn on the vbus power. */
@@ -330,8 +333,9 @@ static void dwc_otg_core_host_init(struct udevice *dev,
  *
  * @param regs Programming view of the DWC_otg controller
  */
-static void dwc_otg_core_init(struct dwc2_priv *priv)
+static void dwc_otg_core_init(struct udevice *dev)
 {
+	struct dwc2_priv *priv = dev_get_priv(dev);
 	struct dwc2_core_regs *regs = priv->regs;
 	uint32_t ahbcfg = 0;
 	uint32_t usbcfg = 0;
@@ -360,7 +364,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset the Controller */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * This programming sequence needs to happen in FS mode before @@ -

372,7 +376,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)

drivers/usb/host/dwc2.c +7 -3
 	setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_PHYSEL);
 
 	/* Reset after a PHY select */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * Program DCFG.DevSpd or HCFG.FSLSPclkSel to 48Mhz in FS.
@@ -419,7 +423,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset after setting the PHY parameters */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 #endif
 
 	usbcfg = readl(&regs->gusbcfg);
@@ -1128,7 +1132,12 @@ int _submit_int_msg(struct dwc2_priv *priv, struct
 usb_device *dev,
 	timeout = get_timer(0) + USB_TIMEOUT_MS(pipe);
 	for (;;) {
 		if (get_timer(0) > timeout) {
-			dev_err(dev, "Timeout poll on interrupt endpoint\n");
+#if CONFIG_IS_ENABLED(DM_USB)
+			dev_err(dev->dev,
+				"Timeout poll on interrupt endpoint\n"); #else
+			log_err("Timeout poll on interrupt endpoint\n"); #endif
 			return -ETIMEDOUT;
 		}
 		ret = _submit_bulk_msg(priv, dev, pipe, buffer, len); @@ -1194,7
+1203,7 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv

*priv)

drivers/usb/host/dwc2.c +2 -1
 	priv->ext_vbus = 0;
 #endif
 
-	dwc_otg_core_init(priv);
+	dwc_otg_core_init(dev);
 	dwc_otg_core_host_init(dev, regs);
 
 	clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA | @@ -1320,12
+1329,10 @@ static int dwc2_submit_int_msg(struct udevice *dev, struct

usb_device *udev, static int dwc2_usb_ofdata_to_platdata(struct udevice *dev) {

drivers/usb/host/dwc2.c +2 -5
 	struct dwc2_priv *priv = dev_get_priv(dev);
-	fdt_addr_t addr;
 
-	addr = dev_read_addr(dev);
-	if (addr == FDT_ADDR_T_NONE)
+	priv->regs = dev_read_addr_ptr(dev);
+	if (!priv->regs)
 		return -EINVAL;
-	priv->regs = (struct dwc2_core_regs *)addr;
 
 	priv->oc_disable = dev_read_bool(dev, "disable-over-current");
 	priv->hnp_srp_disable = dev_read_bool(dev, "hnp-srp-disable");
--
Quoted 1 line

2.28.0

I had just a concern about the addition of dev parameter when regs exist in dwc_otg_flush_rx_fifo, dwc_otg_flush_rx_fifo and dwc_otg_core_reset

struct udevice *dev,
struct dwc2_core_regs *regs,

as regs can be found in dev, I think that duplicate the parameter without need....

	struct dwc2_priv *priv = dev_get_priv(dev);

struct dwc2_core_regs *regs = priv->regs;

but it is also the case in existing function, for example :

dwc_otg_core_host_init(dev, regs);

Patrick

#65 lore raw

PATCH v2 39/46 usb: dwc2: Fix not calling dev_xxx with a device

Quoted 162 lines · Patrick DELAUNAY

Hi Sean,

Quoted 149 lines

From: Sean Anderson <[email protected]>
Sent: mardi 15 septembre 2020 16:45

This adds a dev argument to some functions so dev_xxx always has a device to log with. In one instance we must use use a different log function when we are compiled without DM_USB.

---

Changes in v2:
- New

 drivers/usb/host/dwc2.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/usb/host/dwc2.c index renamed from drivers/usb/host/dwc2.c +0 -0

cefe9d83b1..f1d13b1c1d 100644

drivers/usb/host/dwc2.c +9 -6
@@ -114,7 +114,8 @@ static void init_fslspclksel(struct dwc2_core_regs *regs)
  * @param regs Programming view of DWC_otg controller.
  * @param num Tx FIFO to flush.
  */
-static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
+static void dwc_otg_flush_tx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs, const int num)
 {
 	int ret;
 
@@ -134,7 +135,8 @@ static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs
 *regs, const int num)
  *
  * @param regs Programming view of DWC_otg controller.
  */
-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+static void dwc_otg_flush_rx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs)
 {
 	int ret;
@@ -152,7 +154,8 @@ static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs
 *regs)
  * Do core a soft reset of the core.  Be careful with this because it
  * resets all the internal state machines of the core.
  */
-static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
+static void dwc_otg_core_reset(struct udevice *dev,
+			       struct dwc2_core_regs *regs)
 {
 	int ret;
@@ -284,8 +287,8 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 	clrbits_le32(&regs->gotgctl, DWC2_GOTGCTL_HSTSETHNPEN);
 
 	/* Make sure the FIFOs are flushed. */
-	dwc_otg_flush_tx_fifo(regs, 0x10);	/* All Tx FIFOs */
-	dwc_otg_flush_rx_fifo(regs);
+	dwc_otg_flush_tx_fifo(dev, regs, 0x10);	/* All Tx FIFOs */
+	dwc_otg_flush_rx_fifo(dev, regs);
 
 	/* Flush out any leftover queued requests. */
 	num_channels = readl(&regs->ghwcfg2);
@@ -306,7 +309,7 @@ static void dwc_otg_core_host_init(struct udevice *dev,
 		ret = wait_for_bit_le32(&regs->hc_regs[i].hcchar,
 					DWC2_HCCHAR_CHEN, false, 1000,
 false);
 		if (ret)
-			dev_info("%s: Timeout!\n", __func__);
+			dev_info(dev, "%s: Timeout!\n", __func__);
 	}
 
drivers/usb/host/dwc2.c +3 -2
 	/* Turn on the vbus power. */
@@ -330,8 +333,9 @@ static void dwc_otg_core_host_init(struct udevice *dev,
  *
  * @param regs Programming view of the DWC_otg controller
  */
-static void dwc_otg_core_init(struct dwc2_priv *priv)
+static void dwc_otg_core_init(struct udevice *dev)
 {
+	struct dwc2_priv *priv = dev_get_priv(dev);
 	struct dwc2_core_regs *regs = priv->regs;
 	uint32_t ahbcfg = 0;
 	uint32_t usbcfg = 0;
@@ -360,7 +364,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset the Controller */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * This programming sequence needs to happen in FS mode before @@ -

372,7 +376,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)

drivers/usb/host/dwc2.c +7 -3
 	setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_PHYSEL);
 
 	/* Reset after a PHY select */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * Program DCFG.DevSpd or HCFG.FSLSPclkSel to 48Mhz in FS.
@@ -419,7 +423,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset after setting the PHY parameters */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 #endif
 
 	usbcfg = readl(&regs->gusbcfg);
@@ -1128,7 +1132,12 @@ int _submit_int_msg(struct dwc2_priv *priv, struct
 usb_device *dev,
 	timeout = get_timer(0) + USB_TIMEOUT_MS(pipe);
 	for (;;) {
 		if (get_timer(0) > timeout) {
-			dev_err(dev, "Timeout poll on interrupt endpoint\n");
+#if CONFIG_IS_ENABLED(DM_USB)
+			dev_err(dev->dev,
+				"Timeout poll on interrupt endpoint\n"); #else
+			log_err("Timeout poll on interrupt endpoint\n"); #endif
 			return -ETIMEDOUT;
 		}
 		ret = _submit_bulk_msg(priv, dev, pipe, buffer, len); @@ -1194,7
+1203,7 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv

*priv)

drivers/usb/host/dwc2.c +2 -1
 	priv->ext_vbus = 0;
 #endif
 
-	dwc_otg_core_init(priv);
+	dwc_otg_core_init(dev);
 	dwc_otg_core_host_init(dev, regs);
 
 	clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA | @@ -1320,12
+1329,10 @@ static int dwc2_submit_int_msg(struct udevice *dev, struct

usb_device *udev, static int dwc2_usb_ofdata_to_platdata(struct udevice *dev) {

drivers/usb/host/dwc2.c +2 -5
 	struct dwc2_priv *priv = dev_get_priv(dev);
-	fdt_addr_t addr;
 
-	addr = dev_read_addr(dev);
-	if (addr == FDT_ADDR_T_NONE)
+	priv->regs = dev_read_addr_ptr(dev);
+	if (!priv->regs)
 		return -EINVAL;
-	priv->regs = (struct dwc2_core_regs *)addr;
 
 	priv->oc_disable = dev_read_bool(dev, "disable-over-current");
 	priv->hnp_srp_disable = dev_read_bool(dev, "hnp-srp-disable");
--
Quoted 1 line

2.28.0

I had just a concern about the addition of dev parameter when regs exist in dwc_otg_flush_rx_fifo, dwc_otg_flush_rx_fifo and dwc_otg_core_reset

struct udevice *dev,
struct dwc2_core_regs *regs,

Quoted 8 lines

as regs can be found in dev, I think that duplicate the parameter without need....

	struct dwc2_priv *priv = dev_get_priv(dev);

struct dwc2_core_regs *regs = priv->regs;

but it is also the case in existing function, for example :

dwc_otg_core_host_init(dev, regs);

So if I understand correctly, you would you prefer something like

-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs) +static void dwc_otg_flush_rx_fifo(struct udevice *dev)
{
int ret;
+ struct dwc2_priv *priv = dev_get_priv(dev);
+ struct dwc2_core_regs *regs = priv->regs;

--Sean

#66 lore raw

PATCH v2 39/46 usb: dwc2: Fix not calling dev_xxx with a device

Hi,

Quoted 186 lines

From: Sean Anderson <[email protected]>
Sent: mercredi 16 septembre 2020 15:44

Quoted 15 lines · Patrick DELAUNAY

Hi Sean,

Quoted 13 lines

From: Sean Anderson <[email protected]>
Sent: mardi 15 septembre 2020 16:45

This adds a dev argument to some functions so dev_xxx always has a device to log with. In one instance we must use use a different log function when we are compiled without DM_USB.

---

Changes in v2:
- New

Quoted 8 lines

drivers/usb/host/dwc2.c static void init_fslspclksel(struct dwc2_core_regs

Quoted 8 lines
 drivers/usb/host/dwc2.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/usb/host/dwc2.c index renamed from drivers/usb/host/dwc2.c +0 -0

cefe9d83b1..f1d13b1c1d 100644

drivers/usb/host/dwc2.c +0 -0
@@ -114,7 +114,8 @@ static void init_fslspclksel(struct dwc2_core_regs

*regs)

Quoted 33 lines
Quoted 33 lines
drivers/usb/host/dwc2.c +4 -2
  * @param regs Programming view of DWC_otg controller.
  * @param num Tx FIFO to flush.
  */
-static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const
 int num)
+static void dwc_otg_flush_tx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs, const int num)
 {
 	int ret;
@@ -134,7 +135,8 @@ static void dwc_otg_flush_tx_fifo(struct
 dwc2_core_regs *regs, const int num)
  *
  * @param regs Programming view of DWC_otg controller.
  */
-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+static void dwc_otg_flush_rx_fifo(struct udevice *dev,
+				  struct dwc2_core_regs *regs)
 {
 	int ret;
@@ -152,7 +154,8 @@ static void dwc_otg_flush_rx_fifo(struct

dwc2_core_regs
*regs)
* Do core a soft reset of the core. Be careful with this because it
* resets all the internal state machines of the core.
*/

drivers/usb/host/dwc2.c +2 -1
-static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
+static void dwc_otg_core_reset(struct udevice *dev,
+			       struct dwc2_core_regs *regs)
 {
 	int ret;
Quoted 1 line

drivers/usb/host/dwc2.c static void dwc_otg_core_host_init(struct udevice

Quoted 1 line
drivers/usb/host/dwc2.c +0 -0
@@ -284,8 +287,8 @@ static void dwc_otg_core_host_init(struct udevice

*dev,

Quoted 19 lines
Quoted 19 lines
drivers/usb/host/dwc2.c +2 -2
 	clrbits_le32(&regs->gotgctl, DWC2_GOTGCTL_HSTSETHNPEN);
 
 	/* Make sure the FIFOs are flushed. */
-	dwc_otg_flush_tx_fifo(regs, 0x10);	/* All Tx FIFOs */
-	dwc_otg_flush_rx_fifo(regs);
+	dwc_otg_flush_tx_fifo(dev, regs, 0x10);	/* All Tx FIFOs */
+	dwc_otg_flush_rx_fifo(dev, regs);
 
 	/* Flush out any leftover queued requests. */
 	num_channels = readl(&regs->ghwcfg2); @@ -306,7 +309,7 @@ static

void dwc_otg_core_host_init(struct udevice *dev,

drivers/usb/host/dwc2.c +0 -0
 		ret = wait_for_bit_le32(&regs->hc_regs[i].hcchar,
 					DWC2_HCCHAR_CHEN, false, 1000,

false);

drivers/usb/host/dwc2.c +1 -1
 		if (ret)
-			dev_info("%s: Timeout!\n", __func__);
+			dev_info(dev, "%s: Timeout!\n", __func__);
 	}
Quoted 2 lines

drivers/usb/host/dwc2.c static void dwc_otg_core_host_init(struct udevice

Quoted 2 lines
drivers/usb/host/dwc2.c +0 -0
 	/* Turn on the vbus power. */
@@ -330,8 +333,9 @@ static void dwc_otg_core_host_init(struct udevice

*dev,

Quoted 56 lines
Quoted 56 lines
drivers/usb/host/dwc2.c +3 -2
  *
  * @param regs Programming view of the DWC_otg controller
  */
-static void dwc_otg_core_init(struct dwc2_priv *priv)
+static void dwc_otg_core_init(struct udevice *dev)
 {
+	struct dwc2_priv *priv = dev_get_priv(dev);
 	struct dwc2_core_regs *regs = priv->regs;
 	uint32_t ahbcfg = 0;
 	uint32_t usbcfg = 0;
@@ -360,7 +364,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset the Controller */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * This programming sequence needs to happen in FS mode before @@ -

372,7 +376,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)

drivers/usb/host/dwc2.c +8 -3
 	setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_PHYSEL);
 
 	/* Reset after a PHY select */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 
 	/*
 	 * Program DCFG.DevSpd or HCFG.FSLSPclkSel to 48Mhz in FS.
@@ -419,7 +423,7 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	writel(usbcfg, &regs->gusbcfg);
 
 	/* Reset after setting the PHY parameters */
-	dwc_otg_core_reset(regs);
+	dwc_otg_core_reset(dev, regs);
 #endif
 
 	usbcfg = readl(&regs->gusbcfg);
@@ -1128,7 +1132,12 @@ int _submit_int_msg(struct dwc2_priv *priv,
 struct usb_device *dev,
 	timeout = get_timer(0) + USB_TIMEOUT_MS(pipe);
 	for (;;) {
 		if (get_timer(0) > timeout) {
-			dev_err(dev, "Timeout poll on interrupt endpoint\n");
+#if CONFIG_IS_ENABLED(DM_USB)
+			dev_err(dev->dev,
+				"Timeout poll on interrupt endpoint\n"); #else
+			log_err("Timeout poll on interrupt endpoint\n"); #endif
 			return -ETIMEDOUT;
 		}
 		ret = _submit_bulk_msg(priv, dev, pipe, buffer, len); @@ -1194,7
+1203,7 @@ static int dwc2_init_common(struct udevice *dev, struct
+dwc2_priv

*priv)
priv->ext_vbus = 0;
#endif

Quoted 8 lines
Quoted 8 lines
drivers/usb/host/dwc2.c +3 -1
-	dwc_otg_core_init(priv);
+	dwc_otg_core_init(dev);
 	dwc_otg_core_host_init(dev, regs);
 
 	clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA | @@ -1320,12
+1329,10 @@ static int dwc2_submit_int_msg(struct udevice *dev,
+struct

usb_device *udev, static int dwc2_usb_ofdata_to_platdata(struct udevice

*dev) {

Quoted 25 lines
Quoted 13 lines
drivers/usb/host/dwc2.c +2 -5
 	struct dwc2_priv *priv = dev_get_priv(dev);
-	fdt_addr_t addr;
 
-	addr = dev_read_addr(dev);
-	if (addr == FDT_ADDR_T_NONE)
+	priv->regs = dev_read_addr_ptr(dev);
+	if (!priv->regs)
 		return -EINVAL;
-	priv->regs = (struct dwc2_core_regs *)addr;
 
 	priv->oc_disable = dev_read_bool(dev, "disable-over-current");
 	priv->hnp_srp_disable = dev_read_bool(dev, "hnp-srp-disable");
--
Quoted 1 line

2.28.0

I had just a concern about the addition of dev parameter when regs exist in dwc_otg_flush_rx_fifo, dwc_otg_flush_rx_fifo and dwc_otg_core_reset

struct udevice *dev,
struct dwc2_core_regs *regs,

Quoted 8 lines

as regs can be found in dev, I think that duplicate the parameter without need....

	struct dwc2_priv *priv = dev_get_priv(dev);

struct dwc2_core_regs *regs = priv->regs;

but it is also the case in existing function, for example :

dwc_otg_core_host_init(dev, regs);

So if I understand correctly, you would you prefer something like

drivers/usb/host/dwc2.c static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)

Quoted 8 lines
drivers/usb/host/dwc2.c +3 -2
-static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+static void dwc_otg_flush_rx_fifo(struct udevice *dev)
 {
 	int ret;
+	struct dwc2_priv *priv = dev_get_priv(dev);
+   	struct dwc2_core_regs *regs = priv->regs;
 
--Sean

Yes exactly.

Because I assume that dev_get_priv() is just a macro to access dev element, so my proposal don't increase the code size / the execution time.

But I check it yesterday, because I start to migrate all stm32 driver to log API and it is not the case...

drivers/core/device.c:545

void *dev_get_priv(const struct udevice *dev)

{
	if (!dev) {
		dm_warn("%s: null device\n", __func__);
		return NULL;
	}

	return dev->priv;
}

So now, I don't sure that duplicate the call to dev_get_priv() is a good solution. And I think your first solution is correct.

Sorry for disturbance

Patrick

#67 lore raw

PATCH v2 40/46 usb: dwc3: Fix not calling dev_xxx with a device

In reply to Sean Anderson

This logs with the device from struct dwc3. Some files also need to include dm.h so fields in udevice can be accessed.

---

Changes in v2:
- New

 drivers/usb/dwc3/core.c   | 15 ++++++++-------
 drivers/usb/dwc3/ep0.c    |  1 +
 drivers/usb/dwc3/gadget.c | 23 ++++++++++++-----------
 3 files changed, 21 insertions(+), 18 deletions(-)
drivers/usb/dwc3/core.c +8 -7
index 8682556589..2e003530a1 100644
@@ -592,7 +592,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
 		dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
 		ret = dwc3_gadget_init(dwc);
 		if (ret) {
-			dev_err(dev, "failed to initialize gadget\n");
+			dev_err(dwc->dev, "failed to initialize gadget\n");
 			return ret;
 		}
 		break;
@@ -600,7 +600,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
 		dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
 		ret = dwc3_host_init(dwc);
 		if (ret) {
-			dev_err(dev, "failed to initialize host\n");
+			dev_err(dwc->dev, "failed to initialize host\n");
 			return ret;
 		}
 		break;
@@ -608,18 +608,19 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
 		dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
 		ret = dwc3_host_init(dwc);
 		if (ret) {
-			dev_err(dev, "failed to initialize host\n");
+			dev_err(dwc->dev, "failed to initialize host\n");
 			return ret;
 		}
 
 		ret = dwc3_gadget_init(dwc);
 		if (ret) {
-			dev_err(dev, "failed to initialize gadget\n");
+			dev_err(dwc->dev, "failed to initialize gadget\n");
 			return ret;
 		}
 		break;
 	default:
-		dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode);
+		dev_err(dwc->dev,
+			"Unsupported mode of operation %d\n", dwc->dr_mode);
 		return -EINVAL;
 	}
 
@@ -768,7 +769,7 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev)
 
 	ret = dwc3_core_init(dwc);
 	if (ret) {
-		dev_err(dev, "failed to initialize core\n");
+		dev_err(dwc->dev, "failed to initialize core\n");
 		goto err0;
 	}
 
@@ -974,7 +975,7 @@ int dwc3_init(struct dwc3 *dwc)
 
 	ret = dwc3_core_init(dwc);
 	if (ret) {
-		dev_err(dev, "failed to initialize core\n");
+		dev_err(dwc->dev, "failed to initialize core\n");
 		goto core_fail;
 	}
 
drivers/usb/dwc3/ep0.c +1 -0
index 385bed3e34..75ac993bc6 100644
@@ -14,6 +14,7 @@
  */
 #include <common.h>
 #include <cpu_func.h>
+#include <dm.h>
 #include <dm/device_compat.h>
 #include <linux/bug.h>
 #include <linux/kernel.h>
drivers/usb/dwc3/gadget.c +12 -11
index 2aec874e1d..4e68fb0a82 100644
@@ -17,6 +17,7 @@
 #include <cpu_func.h>
 #include <log.h>
 #include <malloc.h>
+#include <dm.h>
 #include <dm/device_compat.h>
 #include <dm/devres.h>
 #include <linux/bug.h>
@@ -633,7 +634,7 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
 		strlcat(dep->name, "-int", sizeof(dep->name));
 		break;
 	default:
-		dev_err(dwc->dev, "invalid endpoint transfer type\n");
+		dev_err(dep->dwc->dev, "invalid endpoint transfer type\n");
 	}
 
 	spin_lock_irqsave(&dwc->lock, flags);
@@ -708,10 +709,9 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
 {
 	struct dwc3_trb		*trb;
 
-	dev_vdbg(dwc->dev, "%s: req %p dma %08llx length %d%s%s\n",
-			dep->name, req, (unsigned long long) dma,
-			length, last ? " last" : "",
-			chain ? " chain" : "");
+	dev_vdbg(dep->dwc->dev, "%s: req %p dma %08llx length %d%s%s\n",
+		 dep->name, req, (unsigned long long)dma,
+		 length, last ? " last" : "", chain ? " chain" : "");
 
 
 	trb = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK];
@@ -1074,21 +1074,22 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
 
 	spin_lock_irqsave(&dwc->lock, flags);
 	if (!dep->endpoint.desc) {
-		dev_dbg(dwc->dev, "trying to queue request %p to disabled %s\n",
-				request, ep->name);
+		dev_dbg(dep->dwc->dev,
+			"trying to queue request %p to disabled %s\n", request,
+			ep->name);
 		ret = -ESHUTDOWN;
 		goto out;
 	}
 
 	if (req->dep != dep) {
-		WARN(true, "request %p belongs to '%s'\n",
-				request, req->dep->name);
+		WARN(true, "request %p belongs to '%s'\n", request,
+		     req->dep->name);
 		ret = -EINVAL;
 		goto out;
 	}
 
-	dev_vdbg(dwc->dev, "queing request %p to %s length %d\n",
-			request, ep->name, request->length);
+	dev_vdbg(dep->dwc->dev, "queing request %p to %s length %d\n",
+		 request, ep->name, request->length);
 
 	ret = __dwc3_gadget_ep_queue(dep, req);
 
Signature · 1 line
2.28.0
#68 lore raw

PATCH v2 41/46 usb: dwc3: ti: Fix not calling dev_err with a device

In reply to Sean Anderson

This driver does not use DM, so use log_xxx instead.

---

Changes in v2:
- New

 drivers/usb/dwc3/ti_usb_phy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/ti_usb_phy.c +2 -2
index f8ab06482c..f476810763 100644
@@ -129,7 +129,7 @@ static struct usb3_dpll_params *ti_usb3_get_dpll_params(struct ti_usb_phy *phy)
 			return &dpll_map->params;
 	}
 
-	dev_err(phy->dev, "No DPLL configuration for %lu Hz SYS CLK\n", rate);
+	log_err("No DPLL configuration for %lu Hz SYS CLK\n", rate);
 
 	return NULL;
 }
@@ -269,7 +269,7 @@ int ti_usb_phy_uboot_init(struct ti_usb_phy_device *dev)
 
 	phy = devm_kzalloc(NULL, sizeof(*phy), GFP_KERNEL);
 	if (!phy) {
-		dev_err(NULL, "unable to alloc mem for TI USB3 PHY\n");
+		log_err("unable to alloc mem for TI USB3 PHY\n");
 		return -ENOMEM;
 	}
 
Signature · 1 line
2.28.0
#69 lore raw

PATCH v2 42/46 usb: dwc3: Don't include asm-generic/io.h

In reply to Sean Anderson

This can conflict with asm/io.h on some archs, and it isn't needed to build dwc3-generic.c

---

Changes in v2:
- New

 drivers/usb/dwc3/dwc3-generic.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/dwc3/dwc3-generic.c +0 -1
index 551f682024..97aa3a3a5c 100644
@@ -10,7 +10,6 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <log.h>
-#include <asm-generic/io.h>
 #include <dm.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
Signature · 1 line
2.28.0
#70 lore raw

PATCH v2 43/46 usb: musb-new: sunxi: Fix not calling dev_err with a device

In reply to Sean Anderson

This driver does not use DM, so we need to use a struct device instead of a struct udevice. Not ideal, but it'll have to do for now.

---

Changes in v2:
- New

 drivers/usb/musb-new/sunxi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/musb-new/sunxi.c +5 -4
index 53c336fc3f..cf128f148c 100644
@@ -301,21 +301,21 @@ static int sunxi_musb_init(struct musb *musb)
 
 	ret = clk_enable(&glue->clk);
 	if (ret) {
-		dev_err(dev, "failed to enable clock\n");
+		dev_err(musb->controller, "failed to enable clock\n");
 		return ret;
 	}
 
 	if (reset_valid(&glue->rst)) {
 		ret = reset_deassert(&glue->rst);
 		if (ret) {
-			dev_err(dev, "failed to deassert reset\n");
+			dev_err(musb->controller, "failed to deassert reset\n");
 			goto err_clk;
 		}
 	}
 
 	ret = generic_phy_init(&glue->phy);
 	if (ret) {
-		dev_err(dev, "failed to init USB PHY\n");
+		dev_err(musb->controller, "failed to init USB PHY\n");
 		goto err_rst;
 	}
 
@@ -352,7 +352,8 @@ static int sunxi_musb_exit(struct musb *musb)
 	if (generic_phy_valid(&glue->phy)) {
 		ret = generic_phy_exit(&glue->phy);
 		if (ret) {
-			dev_err(dev, "failed to power off usb phy\n");
+			dev_err(musb->controller,
+				"failed to power off usb phy\n");
 			return ret;
 		}
 	}
Signature · 1 line
2.28.0
#71 lore raw

PATCH v2 44/46 video: stm32: Fix not calling dev_xxx with a device

In reply to Sean Anderson

There is no member dev in dw_mipi_dsi, but there is one in mipi_dsi_host, so use that.

---

Changes in v2:
- New

 drivers/video/dw_mipi_dsi.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/video/dw_mipi_dsi.c +14 -10
index b7bfbb5e50..2743836fb4 100644
@@ -314,7 +314,8 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val)
 				 val, !(val & GEN_CMD_FULL),
 				 CMD_PKT_STATUS_TIMEOUT_US);
 	if (ret) {
-		dev_err(dsi->dev, "failed to get available command FIFO\n");
+		dev_err(dsi->dsi_host.dev,
+			"failed to get available command FIFO\n");
 		return ret;
 	}
 
@@ -325,7 +326,7 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val)
 				 val, (val & mask) == mask,
 				 CMD_PKT_STATUS_TIMEOUT_US);
 	if (ret) {
-		dev_err(dsi->dev, "failed to write command FIFO\n");
+		dev_err(dsi->dsi_host.dev, "failed to write command FIFO\n");
 		return ret;
 	}
 
@@ -357,7 +358,7 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi,
 					 val, !(val & GEN_PLD_W_FULL),
 					 CMD_PKT_STATUS_TIMEOUT_US);
 		if (ret) {
-			dev_err(dsi->dev,
+			dev_err(dsi->dsi_host.dev,
 				"failed to get available write payload FIFO\n");
 			return ret;
 		}
@@ -380,7 +381,7 @@ static int dw_mipi_dsi_read(struct dw_mipi_dsi *dsi,
 				 val, !(val & GEN_RD_CMD_BUSY),
 				 CMD_PKT_STATUS_TIMEOUT_US);
 	if (ret) {
-		dev_err(dsi->dev, "Timeout during read operation\n");
+		dev_err(dsi->dsi_host.dev, "Timeout during read operation\n");
 		return ret;
 	}
 
@@ -390,7 +391,8 @@ static int dw_mipi_dsi_read(struct dw_mipi_dsi *dsi,
 					 val, !(val & GEN_PLD_R_EMPTY),
 					 CMD_PKT_STATUS_TIMEOUT_US);
 		if (ret) {
-			dev_err(dsi->dev, "Read payload FIFO is empty\n");
+			dev_err(dsi->dsi_host.dev,
+				"Read payload FIFO is empty\n");
 			return ret;
 		}
 
@@ -411,7 +413,7 @@ static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host,
 
 	ret = mipi_dsi_create_packet(&packet, msg);
 	if (ret) {
-		dev_err(dsi->dev, "failed to create packet: %d\n", ret);
+		dev_err(host->dev, "failed to create packet: %d\n", ret);
 		return ret;
 	}
 
@@ -702,13 +704,15 @@ static void dw_mipi_dsi_dphy_enable(struct dw_mipi_dsi *dsi)
 	ret = readl_poll_timeout(dsi->base + DSI_PHY_STATUS, val,
 				 val & PHY_LOCK, PHY_STATUS_TIMEOUT_US);
 	if (ret)
-		dev_warn(dsi->dev, "failed to wait phy lock state\n");
+		dev_warn(dsi->dsi_host.dev,
+			 "failed to wait phy lock state\n");
 
 	ret = readl_poll_timeout(dsi->base + DSI_PHY_STATUS,
 				 val, val & PHY_STOP_STATE_CLK_LANE,
 				 PHY_STATUS_TIMEOUT_US);
 	if (ret)
-		dev_warn(dsi->dev, "failed to wait phy clk lane stop state\n");
+		dev_warn(dsi->dsi_host.dev,
+			 "failed to wait phy clk lane stop state\n");
 }
 
 static void dw_mipi_dsi_clear_err(struct dw_mipi_dsi *dsi)
@@ -729,7 +733,7 @@ static void dw_mipi_dsi_bridge_set(struct dw_mipi_dsi *dsi,
 	ret = phy_ops->get_lane_mbps(dsi->device, timings, device->lanes,
 				     device->format, &dsi->lane_mbps);
 	if (ret)
-		dev_warn(dsi->dev, "Phy get_lane_mbps() failed\n");
+		dev_warn(dsi->dsi_host.dev, "Phy get_lane_mbps() failed\n");
 
 	dw_mipi_dsi_init_pll(dsi);
 	dw_mipi_dsi_dpi_config(dsi, timings);
@@ -748,7 +752,7 @@ static void dw_mipi_dsi_bridge_set(struct dw_mipi_dsi *dsi,
 
 	ret = phy_ops->init(dsi->device);
 	if (ret)
-		dev_warn(dsi->dev, "Phy init() failed\n");
+		dev_warn(dsi->dsi_host.dev, "Phy init() failed\n");
 
 	dw_mipi_dsi_dphy_enable(dsi);
 
Signature · 1 line
2.28.0
#73 lore raw

PATCH v2 45/46 dm: Use symbolic constants for log levels in dev_xxx

In reply to Sean Anderson

This substitutes literal log levels with their symbolic constants.

---

(no changes since v1)

 include/dm/device_compat.h | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
include/dm/device_compat.h +11 -10
index 3d8cd09f4c..7c14aa464d 100644
@@ -10,6 +10,7 @@
 #ifndef _DM_DEVICE_COMPAT_H
 #define _DM_DEVICE_COMPAT_H
 
+#include <log.h>
 #include <linux/compat.h>
 
 /*
@@ -48,28 +49,28 @@
 })
 
 #define dev_emerg(dev, fmt, ...) \
-	__dev_printk(0, dev, fmt, ##__VA_ARGS__)
+	__dev_printk(LOGL_EMERG, dev, fmt, ##__VA_ARGS__)
 #define dev_alert(dev, fmt, ...) \
-	__dev_printk(1, dev, fmt, ##__VA_ARGS__)
+	__dev_printk(LOGL_ALERT, dev, fmt, ##__VA_ARGS__)
 #define dev_crit(dev, fmt, ...) \
-	__dev_printk(2, dev, fmt, ##__VA_ARGS__)
+	__dev_printk(LOGL_CRIT, dev, fmt, ##__VA_ARGS__)
 #define dev_err(dev, fmt, ...) \
-	__dev_printk(3, dev, fmt, ##__VA_ARGS__)
+	__dev_printk(LOGL_ERR, dev, fmt, ##__VA_ARGS__)
 #define dev_warn(dev, fmt, ...) \
-	__dev_printk(4, dev, fmt, ##__VA_ARGS__)
+	__dev_printk(LOGL_WARNING, dev, fmt, ##__VA_ARGS__)
 #define dev_notice(dev, fmt, ...) \
-	__dev_printk(5, dev, fmt, ##__VA_ARGS__)
+	__dev_printk(LOGL_NOTICE, dev, fmt, ##__VA_ARGS__)
 #define dev_info(dev, fmt, ...) \
-	__dev_printk(6, dev, fmt, ##__VA_ARGS__)
+	__dev_printk(LOGL_INFO, dev, fmt, ##__VA_ARGS__)
 
 #ifdef DEBUG
 #define dev_dbg(dev, fmt, ...) \
-	__dev_printk(7, dev, fmt, ##__VA_ARGS__)
+	__dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__)
 #else
 #define dev_dbg(dev, fmt, ...)					\
 ({								\
 	if (0)							\
-		__dev_printk(7, dev, fmt, ##__VA_ARGS__);	\
+		__dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__);	\
 })
 #endif
 
@@ -79,7 +80,7 @@
 #define dev_vdbg(dev, fmt, ...)					\
 ({								\
 	if (0)							\
-		__dev_printk(7, dev, fmt, ##__VA_ARGS__);	\
+		__dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__);	\
 })
 #endif
 
Signature · 1 line
2.28.0
#74 lore raw

PATCH v2 45/46 dm: Use symbolic constants for log levels in dev_xxx

Quoted 11 lines · Sean Anderson

This substitutes literal log levels with their symbolic constants.

---

(no changes since v1)

 include/dm/device_compat.h | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
#75 lore raw

PATCH v2 46/46 dm: Print device name in dev_xxx like Linux

In reply to Sean Anderson

This adorns messages generated by dev_xxx with the device and driver names. It also redirects dev_xxx to log when it is available. The names of these functions very roughly take inspiration from Linux, but there is no deeper correlation.

Both struct udevice and struct device are supported when logging, though logging with struct device is no better than using log_xxx. The latter is supported because of the large amount of existing code which logs with struct device.

---

Changes in v2:
- Support logging with struct device as well as struct udevice. A lot of drivers, especially USB gadgets, log with devices and not udevices. There is no major reason why they can't use udevice, but big changes like that are outside the scope of this series.
- Add some comments to __dev_printk and dev_printk_emit
- Handle struct device as well as struct udevice
- Match format strings for the NULL path to the regular path. This reduces the amount of duplicated strings.
- Print the device name before the driver name

 include/dm/device_compat.h | 110 +++++++++++++++++++++++++++----------
 1 file changed, 82 insertions(+), 28 deletions(-)
include/dm/device_compat.h +82 -28
index 7c14aa464d..8f26053b45 100644
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
+ * Copyright (C) 2020 Sean Anderson <[email protected]>
  * Copyright (c) 2013 Google, Inc
  *
  * (C) Copyright 2012
@@ -11,6 +12,7 @@
 #define _DM_DEVICE_COMPAT_H
 
 #include <log.h>
+#include <linux/build_bug.h>
 #include <linux/compat.h>
 
 /*
@@ -34,18 +36,87 @@
 #endif
 
 /*
- * REVISIT:
- * print device name like Linux
+ * Define a new identifier which can be tested on by C code. A similar
+ * definition is made for DEBUG in <log.h>.
  */
-#define dev_printk(dev, fmt, ...)				\
-({								\
-	printk(fmt, ##__VA_ARGS__);				\
+#ifdef VERBOSE_DEBUG
+#define _VERBOSE_DEBUG 1
+#else
+#define _VERBOSE_DEBUG 0
+#endif
+
+/**
+ * dev_printk_emit() - Emit a formatted log message
+ * @cat: Category of the message
+ * @level: Log level of the message
+ * @fmt: Format string
+ * @...: Arguments for @fmt
+ *
+ * This macro logs a message through the appropriate channel. It is a macro so
+ * the if statements can be optimized out (as @level should be a constant known
+ * at compile-time).
+ *
+ * If DEBUG or VERBOSE_DEBUG is defined, then some messages are always printed
+ * (through printf()). This is to match the historical behavior of the dev_xxx
+ * functions.
+ *
+ * If LOG is enabled, use log() to emit the message, otherwise print it based on
+ * the console loglevel.
+ */
+#define dev_printk_emit(cat, level, fmt, ...) \
+({ \
+	if ((_DEBUG && level == LOGL_DEBUG) || \
+	    (_VERBOSE_DEBUG && level == LOGL_DEBUG_CONTENT)) \
+		printf(fmt, ##__VA_ARGS__); \
+	else if (CONFIG_IS_ENABLED(LOG)) \
+		log(cat, level, fmt, ##__VA_ARGS__); \
+	else if (level < CONFIG_VAL(LOGLEVEL)) \
+		printf(fmt, ##__VA_ARGS__); \
 })
 
-#define __dev_printk(level, dev, fmt, ...)			\
-({								\
-	if (level < CONFIG_VAL(LOGLEVEL))			\
-		dev_printk(dev, fmt, ##__VA_ARGS__);		\
+/**
+ * __dev_printk() - Log a message for a device
+ * @level: Log level of the message
+ * @dev: A &struct udevice or &struct device
+ * @fmt: Format string
+ * @...: Arguments for @fmt
+ *
+ * This macro formats and prints dev_xxx log messages. It is done as a macro
+ * because working with variadic argument is much easier this way, we can
+ * interrogate the type of device we are passed (and whether it *is* a &struct
+ * udevice or &struct device), and dev_printk_emit() can optimize out unused if
+ * branches.
+ *
+ * Because this is a macro, we must enforce type checks ourselves. Ideally, we
+ * would only accept udevices, but there is a significant amount of code (mostly
+ * USB) which calls dev_xxx with &struct device. When assigning ``__dev``, we
+ * must first cast ``dev`` to ``void *`` so we don't get warned when ``dev`` is
+ * a &struct device. Even though the latter branch is not taken, it will still
+ * get compiled and type-checked.
+ *
+ * The format strings in case of a ``NULL`` ``dev`` MUST be kept the same.
+ * Otherwise, @fmt will be duplicated in the data section (with slightly
+ * different prefixes). This is why ``(NULL udevice *)`` is printed as two
+ * string arguments, and not by string pasting.
+ */
+#define __dev_printk(level, dev, fmt, ...) \
+({ \
+	if (__same_type(dev, struct device  *)) { \
+		dev_printk_emit(LOG_CATEGORY, level, fmt, ##__VA_ARGS__); \
+	} else { \
+		BUILD_BUG_ON(!__same_type(dev, struct udevice *)); \
+		struct udevice *__dev = (void *)dev; \
+		if (__dev) \
+			dev_printk_emit(__dev->driver->id, level, \
+					"%s %s: " fmt, \
+					__dev->driver->name, __dev->name, \
+					##__VA_ARGS__); \
+		else \
+			dev_printk_emit(LOG_CATEGORY, level, \
+					"%s %s: " fmt, \
+					"(NULL", "udevice *)", \
+					##__VA_ARGS__); \
+	} \
 })
 
 #define dev_emerg(dev, fmt, ...) \
@@ -62,26 +133,9 @@
 	__dev_printk(LOGL_NOTICE, dev, fmt, ##__VA_ARGS__)
 #define dev_info(dev, fmt, ...) \
 	__dev_printk(LOGL_INFO, dev, fmt, ##__VA_ARGS__)
-
-#ifdef DEBUG
 #define dev_dbg(dev, fmt, ...) \
 	__dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__)
-#else
-#define dev_dbg(dev, fmt, ...)					\
-({								\
-	if (0)							\
-		__dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__);	\
-})
-#endif
-
-#ifdef VERBOSE_DEBUG
-#define dev_vdbg	dev_dbg
-#else
-#define dev_vdbg(dev, fmt, ...)					\
-({								\
-	if (0)							\
-		__dev_printk(LOGL_DEBUG, dev, fmt, ##__VA_ARGS__);	\
-})
-#endif
+#define dev_vdbg(dev, fmt, ...) \
+	__dev_printk(LOGL_DEBUG_CONTENT, dev, fmt, ##__VA_ARGS__)
 
 #endif
Signature · 1 line
2.28.0
#76 lore raw

v2 cover dm: Print device name in dev_xxx like Linux

In reply to Sean Anderson

Hi Sean,

Quoted 167 lines

From: Sean Anderson <[email protected]>
Sent: mardi 15 septembre 2020 16:45

This series adds some additional information to dev_xxx output. This requires the first argument to dev_xxx to be a struct udevice. The first argument has never been used in U-Boot, so many drivers have some invalid calls. To fix these drivers, the following strategies were generally followed

* If there is a udevice already passed to the function, use it.
* If there is a udevice contained in a struct passed to the function, use it. When there are multiple possible devices, I have tried to use whatever "makes sense" given the content of the message.
* If there is no udevice passed to the function either directly or indirectly, but all the callers of said function can access a udevice, modify the function signature to pass in a udevice and use that.
* If the driver does not use DM, convert the log statements to log_xxx.
* If the driver uses DM only some of the time, use ifdefs to select an appropriate log function.

I have done a little bit of cleanup beyond these strategies, but for the most part I have tried to *only* to the minimum necessary. Many drivers could use a follow-up patch to convert their printf()s and debug()s to an appropriate log function.

I have tried to CC relevant maintainers/reviewers only for patches they maintain/review. If I have left someone out, please let me know and I will add them.

CI is passing at [1]. This does not necessarily mean that this series is free of bugs, so I would appreciate testing on hardware. During my refactoring, I noticed a few bugs like

	struct udevice *dev;

	if (some_condition)
		dev_err(dev, "Something went wrong\n");

	dev = some_function();

I have fixed such errors when I have encountered them, but they will not always warn or error on build.

Removal of the duplicate definitions in <linux/compat.h> will be done in a follow- up patch due to the already-large size of this series.

To test this series on sandbox, apply the following options in addition to sandbox_defconfig

CONFIG_LOGLEVEL=8
CONFIG_LOG=n
CONFIG_CMD_LOG=n
CONFIG_CMD_TPM=n

Note that there is a soft dependency on [2] if you would like to test this patch with CONFIG_LOG and a higher LOG_LEVEL than LOGL_INFO.

[1] https://dev.azure.com/seanga2/u-boot/_build/results?buildId=34&view=results
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=201343

Changes in v2:
- Support logging with struct device as well as struct udevice. A lot of drivers, especially USB gadgets, log with devices and not udevices. There is no major reason why they can't use udevice, but big changes like that are outside the scope of this series.
- Add some comments to __dev_printk and dev_printk_emit
- Handle struct device as well as struct udevice
- Match format strings for the NULL path to the regular path. This reduces the amount of duplicated strings.
- Print the device name before the driver name
- Many new patches added to fix build bugs

Sean Anderson (46):
dm: syscon: Fix calling dev_dbg with an uninitialized device
firmware: ti_sci: Fix not calling dev_err with a device
i2c: mxc: Fix dev_err being called on a nonexistant variable
mtd: nand: pxa3xx: Fix not calling dev_xxx with a device
mtd: nand: sunxi: Fix not calling dev_err with a device
mtd: spi: Include dm.h in spi-nor-core.c
mtd: spi: Fix logging in spi-nor-tiny
mtd: spi-nand: Fix not calling dev_err with a device
mmc: Add mmc_dev()
mmc: bcm2835-host: Fix not calling dev_dbg with a device
mmc: mtk-sd: Fix not calling dev_err with a device
mailbox: k3: Fix not calling dev_err with a device
nand: atmel: Fix not calling dev_xxx with a device
nand: brcmnand: Fix not calling dev_err() with a device
nand: vybrid: Re-introduce vf610_nfc.dev
net: bcm6368: Fix not calling dev_info with a device
net: mdio: Fix not calling dev_dbg with a device
net: mvneta: Fix not always calling dev_err with a device
net: mvneta: Convert netdev_xxx to dev_xxx
net: mvpp2: Fix not calling dev_xxx with a device
net: mvpp2: Convert netdev_xxx to dev_xxx linux/compat.h: Remove netdev_xxx functions
net: sunxi: Fix not calling dev_xxx with a device
net: sun8i_emac: Fix not calling dev_xxx with a device
net: ti: cpsw: Fix not calling dev_dbg with a device
phy: marvell: Fix not calling dev_err with a device
phy: rockchip: Fix not calling dev_err with a device
phy: sun4i-usb: Fix not calling dev_err with a device
phy: ti: Fix not calling dev_err with a device
phy: usbphyc: Fix not calling dev_err with a device
remoteproc: Remove unused function rproc_elf_sanity_check
remoteproc: k3-r5: Fix not calling dev_xxx with a device
remoteproc: k3: Fix not calling dev_xxx with a device
soc: qualcomm: Fix not calling dev_err with a device
spi: sunxi: Fix not calling dev_err with a device
spi: zynqmp_gqspi: Fix not calling dev_err with a device
sysreset: ti: Fix not calling dev_err with a device
usb: cdns3: Fix not calling dev_xxx with a device
usb: dwc2: Fix not calling dev_xxx with a device
usb: dwc3: Fix not calling dev_xxx with a device
usb: dwc3: ti: Fix not calling dev_err with a device
usb: dwc3: Don't include asm-generic/io.h
usb: musb-new: sunxi: Fix not calling dev_err with a device
video: stm32: Fix not calling dev_xxx with a device
dm: Use symbolic constants for log levels in dev_xxx
dm: Print device name in dev_xxx like Linux

 drivers/core/syscon-uclass.c              |   2 +-
 drivers/firmware/ti_sci.c                 |  23 ++--
 drivers/i2c/mxc_i2c.c                     |   7 +-
 drivers/mailbox/k3-sec-proxy.c            |   6 +-
 drivers/mmc/bcm2835_sdhost.c              |  34 +++---
 drivers/mmc/mtk-sd.c                      |  24 ++--
 drivers/mtd/nand/raw/atmel_nand.c         |  69 +++++++-----
 drivers/mtd/nand/raw/brcmnand/brcmnand.c  |  20 +---
 drivers/mtd/nand/raw/pxa3xx_nand.c        |  30 ++---
 drivers/mtd/nand/raw/sunxi_nand.c         |  45 ++++----
 drivers/mtd/nand/raw/vf610_nfc.c          |  38 ++++---
 drivers/mtd/nand/spi/core.c               |   8 +-
 drivers/mtd/spi/spi-nor-core.c            |   1 +
 drivers/mtd/spi/spi-nor-tiny.c            |  21 +++-
 drivers/net/bcm6368-eth.c                 |   3 +-
 drivers/net/mvneta.c                      |  56 +++++-----
 drivers/net/mvpp2.c                       |  87 ++++++++-------
 drivers/net/sun8i_emac.c                  |   9 +-
 drivers/net/sunxi_emac.c                  |   5 +-
 drivers/net/ti/cpsw.c                     |   6 +
 drivers/phy/allwinner/phy-sun4i-usb.c     |  12 +-
 drivers/phy/marvell/comphy_core.c         |   6 +-
 drivers/phy/phy-stm32-usbphyc.c           |   2 +-
 drivers/phy/phy-ti-am654.c                |   4 +-
 drivers/phy/rockchip/phy-rockchip-pcie.c  |  14 +--
 drivers/phy/rockchip/phy-rockchip-typec.c |   6 +-
 drivers/remoteproc/k3_system_controller.c |   9 +-
 drivers/remoteproc/rproc-elf-loader.c     |  16 ---
 drivers/remoteproc/ti_k3_r5f_rproc.c      |  24 ++--
 drivers/smem/msm_smem.c                   |   2 +-
 drivers/spi/spi-sunxi.c                   |   6 +-
 drivers/spi/zynqmp_gqspi.c                |   6 +-
 drivers/sysreset/sysreset-ti-sci.c        |   3 +-
 drivers/usb/cdns3/ep0.c                   |   5 +-
 drivers/usb/cdns3/gadget.c                |   3 +-
 drivers/usb/dwc3/core.c                   |  15 +--
 drivers/usb/dwc3/dwc3-generic.c           |   1 -
 drivers/usb/dwc3/ep0.c                    |   1 +
 drivers/usb/dwc3/gadget.c                 |  23 ++--
 drivers/usb/dwc3/ti_usb_phy.c             |   4 +-
 drivers/usb/host/dwc2.c                   |  39 ++++---
 drivers/usb/musb-new/sunxi.c              |   9 +-
 drivers/video/dw_mipi_dsi.c               |  24 ++--
 include/dm/device_compat.h                | 127 ++++++++++++++++------
 include/linux/compat.h                    |  19 ----
 include/mmc.h                             |   2 +
 include/remoteproc.h                      |  13 ---
 net/mdio-uclass.c                         |   4 +-
 48 files changed, 486 insertions(+), 407 deletions(-)
Quoted 2 lines

--
2.28.0

For the serie, tested on STM32MP157C-DK2

This target se the modified files:
drivers/core/syscon-uclass.c
drivers/phy/phy-stm32-usbphyc.c
drivers/usb/host/dwc2.c
drivers/video/dw_mipi_dsi.c

I execute compilation and boot with
CONFIG_LOGLEVEL=8
CONFIG_LOG_MAX_LEVEL=8

For stm32mp15_basic_defconfig

Thanks, I can now enable CONFIG_LOG now for stm32mp15x targets. even if stm32 drivers still need update for full "log" migration.

Patrick

#77 lore raw

v2 cover dm: Print device name in dev_xxx like Linux

In reply to Sean Anderson
Quoted 165 lines · Sean Anderson

This series adds some additional information to dev_xxx output. This requires the first argument to dev_xxx to be a struct udevice. The first argument has never been used in U-Boot, so many drivers have some invalid calls. To fix these drivers, the following strategies were generally followed

* If there is a udevice already passed to the function, use it.
* If there is a udevice contained in a struct passed to the function, use it. When there are multiple possible devices, I have tried to use whatever "makes sense" given the content of the message.
* If there is no udevice passed to the function either directly or indirectly, but all the callers of said function can access a udevice, modify the function signature to pass in a udevice and use that.
* If the driver does not use DM, convert the log statements to log_xxx.
* If the driver uses DM only some of the time, use ifdefs to select an appropriate log function.

I have done a little bit of cleanup beyond these strategies, but for the most part I have tried to *only* to the minimum necessary. Many drivers could use a follow-up patch to convert their printf()s and debug()s to an appropriate log function.

I have tried to CC relevant maintainers/reviewers only for patches they maintain/review. If I have left someone out, please let me know and I will add them.

CI is passing at [1]. This does not necessarily mean that this series is free of bugs, so I would appreciate testing on hardware. During my refactoring, I noticed a few bugs like

	struct udevice *dev;

	if (some_condition)
		dev_err(dev, "Something went wrong\n");

	dev = some_function();

I have fixed such errors when I have encountered them, but they will not always warn or error on build.

Removal of the duplicate definitions in <linux/compat.h> will be done in a follow-up patch due to the already-large size of this series.

To test this series on sandbox, apply the following options in addition to sandbox_defconfig

CONFIG_LOGLEVEL=8
CONFIG_LOG=n
CONFIG_CMD_LOG=n
CONFIG_CMD_TPM=n

Note that there is a soft dependency on [2] if you would like to test this patch with CONFIG_LOG and a higher LOG_LEVEL than LOGL_INFO.

[1] https://dev.azure.com/seanga2/u-boot/_build/results?buildId=34&view=results
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=201343

Changes in v2:
- Support logging with struct device as well as struct udevice. A lot of drivers, especially USB gadgets, log with devices and not udevices. There is no major reason why they can't use udevice, but big changes like that are outside the scope of this series.
- Add some comments to __dev_printk and dev_printk_emit
- Handle struct device as well as struct udevice
- Match format strings for the NULL path to the regular path. This reduces the amount of duplicated strings.
- Print the device name before the driver name
- Many new patches added to fix build bugs

Sean Anderson (46):
dm: syscon: Fix calling dev_dbg with an uninitialized device
firmware: ti_sci: Fix not calling dev_err with a device
i2c: mxc: Fix dev_err being called on a nonexistant variable
mtd: nand: pxa3xx: Fix not calling dev_xxx with a device
mtd: nand: sunxi: Fix not calling dev_err with a device
mtd: spi: Include dm.h in spi-nor-core.c
mtd: spi: Fix logging in spi-nor-tiny
mtd: spi-nand: Fix not calling dev_err with a device
mmc: Add mmc_dev()
mmc: bcm2835-host: Fix not calling dev_dbg with a device
mmc: mtk-sd: Fix not calling dev_err with a device
mailbox: k3: Fix not calling dev_err with a device
nand: atmel: Fix not calling dev_xxx with a device
nand: brcmnand: Fix not calling dev_err() with a device
nand: vybrid: Re-introduce vf610_nfc.dev
net: bcm6368: Fix not calling dev_info with a device
net: mdio: Fix not calling dev_dbg with a device
net: mvneta: Fix not always calling dev_err with a device
net: mvneta: Convert netdev_xxx to dev_xxx
net: mvpp2: Fix not calling dev_xxx with a device
net: mvpp2: Convert netdev_xxx to dev_xxx linux/compat.h: Remove netdev_xxx functions
net: sunxi: Fix not calling dev_xxx with a device
net: sun8i_emac: Fix not calling dev_xxx with a device
net: ti: cpsw: Fix not calling dev_dbg with a device
phy: marvell: Fix not calling dev_err with a device
phy: rockchip: Fix not calling dev_err with a device
phy: sun4i-usb: Fix not calling dev_err with a device
phy: ti: Fix not calling dev_err with a device
phy: usbphyc: Fix not calling dev_err with a device
remoteproc: Remove unused function rproc_elf_sanity_check
remoteproc: k3-r5: Fix not calling dev_xxx with a device
remoteproc: k3: Fix not calling dev_xxx with a device
soc: qualcomm: Fix not calling dev_err with a device
spi: sunxi: Fix not calling dev_err with a device
spi: zynqmp_gqspi: Fix not calling dev_err with a device
sysreset: ti: Fix not calling dev_err with a device
usb: cdns3: Fix not calling dev_xxx with a device
usb: dwc2: Fix not calling dev_xxx with a device
usb: dwc3: Fix not calling dev_xxx with a device
usb: dwc3: ti: Fix not calling dev_err with a device
usb: dwc3: Don't include asm-generic/io.h
usb: musb-new: sunxi: Fix not calling dev_err with a device
video: stm32: Fix not calling dev_xxx with a device
dm: Use symbolic constants for log levels in dev_xxx
dm: Print device name in dev_xxx like Linux

 drivers/core/syscon-uclass.c              |   2 +-
 drivers/firmware/ti_sci.c                 |  23 ++--
 drivers/i2c/mxc_i2c.c                     |   7 +-
 drivers/mailbox/k3-sec-proxy.c            |   6 +-
 drivers/mmc/bcm2835_sdhost.c              |  34 +++---
 drivers/mmc/mtk-sd.c                      |  24 ++--
 drivers/mtd/nand/raw/atmel_nand.c         |  69 +++++++-----
 drivers/mtd/nand/raw/brcmnand/brcmnand.c  |  20 +---
 drivers/mtd/nand/raw/pxa3xx_nand.c        |  30 ++---
 drivers/mtd/nand/raw/sunxi_nand.c         |  45 ++++----
 drivers/mtd/nand/raw/vf610_nfc.c          |  38 ++++---
 drivers/mtd/nand/spi/core.c               |   8 +-
 drivers/mtd/spi/spi-nor-core.c            |   1 +
 drivers/mtd/spi/spi-nor-tiny.c            |  21 +++-
 drivers/net/bcm6368-eth.c                 |   3 +-
 drivers/net/mvneta.c                      |  56 +++++-----
 drivers/net/mvpp2.c                       |  87 ++++++++-------
 drivers/net/sun8i_emac.c                  |   9 +-
 drivers/net/sunxi_emac.c                  |   5 +-
 drivers/net/ti/cpsw.c                     |   6 +
 drivers/phy/allwinner/phy-sun4i-usb.c     |  12 +-
 drivers/phy/marvell/comphy_core.c         |   6 +-
 drivers/phy/phy-stm32-usbphyc.c           |   2 +-
 drivers/phy/phy-ti-am654.c                |   4 +-
 drivers/phy/rockchip/phy-rockchip-pcie.c  |  14 +--
 drivers/phy/rockchip/phy-rockchip-typec.c |   6 +-
 drivers/remoteproc/k3_system_controller.c |   9 +-
 drivers/remoteproc/rproc-elf-loader.c     |  16 ---
 drivers/remoteproc/ti_k3_r5f_rproc.c      |  24 ++--
 drivers/smem/msm_smem.c                   |   2 +-
 drivers/spi/spi-sunxi.c                   |   6 +-
 drivers/spi/zynqmp_gqspi.c                |   6 +-
 drivers/sysreset/sysreset-ti-sci.c        |   3 +-
 drivers/usb/cdns3/ep0.c                   |   5 +-
 drivers/usb/cdns3/gadget.c                |   3 +-
 drivers/usb/dwc3/core.c                   |  15 +--
 drivers/usb/dwc3/dwc3-generic.c           |   1 -
 drivers/usb/dwc3/ep0.c                    |   1 +
 drivers/usb/dwc3/gadget.c                 |  23 ++--
 drivers/usb/dwc3/ti_usb_phy.c             |   4 +-
 drivers/usb/host/dwc2.c                   |  39 ++++---
 drivers/usb/musb-new/sunxi.c              |   9 +-
 drivers/video/dw_mipi_dsi.c               |  24 ++--
 include/dm/device_compat.h                | 127 ++++++++++++++++------
 include/linux/compat.h                    |  19 ----
 include/mmc.h                             |   2 +
 include/remoteproc.h                      |  13 ---
 net/mdio-uclass.c                         |   4 +-
 48 files changed, 486 insertions(+), 407 deletions(-)
Quoted 1 line

I'm about to apply this series to -next and I'm cc'ing the board maintainers list. A feature of this series is that a large number of drivers that had put in information / error / etc messages that had intended to be seen (presumably) by the user and were being discarded at link/compile time before are included now. buildman has a set of flags to tell you what exact functions grew between commits and if there's messages that should have their log level changed, we really should do that.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200930/168c88c8/attachment.sig>
#78 lore raw

v2 cover dm: Print device name in dev_xxx like Linux

In reply to Sean Anderson
Quoted 157 lines · Sean Anderson

This series adds some additional information to dev_xxx output. This requires the first argument to dev_xxx to be a struct udevice. The first argument has never been used in U-Boot, so many drivers have some invalid calls. To fix these drivers, the following strategies were generally followed

* If there is a udevice already passed to the function, use it.
* If there is a udevice contained in a struct passed to the function, use it. When there are multiple possible devices, I have tried to use whatever "makes sense" given the content of the message.
* If there is no udevice passed to the function either directly or indirectly, but all the callers of said function can access a udevice, modify the function signature to pass in a udevice and use that.
* If the driver does not use DM, convert the log statements to log_xxx.
* If the driver uses DM only some of the time, use ifdefs to select an appropriate log function.

I have done a little bit of cleanup beyond these strategies, but for the most part I have tried to *only* to the minimum necessary. Many drivers could use a follow-up patch to convert their printf()s and debug()s to an appropriate log function.

I have tried to CC relevant maintainers/reviewers only for patches they maintain/review. If I have left someone out, please let me know and I will add them.

CI is passing at [1]. This does not necessarily mean that this series is free of bugs, so I would appreciate testing on hardware. During my refactoring, I noticed a few bugs like

	struct udevice *dev;

	if (some_condition)
		dev_err(dev, "Something went wrong\n");

	dev = some_function();

I have fixed such errors when I have encountered them, but they will not always warn or error on build.

Removal of the duplicate definitions in <linux/compat.h> will be done in a follow-up patch due to the already-large size of this series.

To test this series on sandbox, apply the following options in addition to sandbox_defconfig

CONFIG_LOGLEVEL=8
CONFIG_LOG=n
CONFIG_CMD_LOG=n
CONFIG_CMD_TPM=n

Note that there is a soft dependency on [2] if you would like to test this patch with CONFIG_LOG and a higher LOG_LEVEL than LOGL_INFO.

[1] https://dev.azure.com/seanga2/u-boot/_build/results?buildId=34&view=results
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=201343

Changes in v2:
- Support logging with struct device as well as struct udevice. A lot of drivers, especially USB gadgets, log with devices and not udevices. There is no major reason why they can't use udevice, but big changes like that are outside the scope of this series.
- Add some comments to __dev_printk and dev_printk_emit
- Handle struct device as well as struct udevice
- Match format strings for the NULL path to the regular path. This reduces the amount of duplicated strings.
- Print the device name before the driver name
- Many new patches added to fix build bugs

Sean Anderson (46):
dm: syscon: Fix calling dev_dbg with an uninitialized device
firmware: ti_sci: Fix not calling dev_err with a device
i2c: mxc: Fix dev_err being called on a nonexistant variable
mtd: nand: pxa3xx: Fix not calling dev_xxx with a device
mtd: nand: sunxi: Fix not calling dev_err with a device
mtd: spi: Include dm.h in spi-nor-core.c
mtd: spi: Fix logging in spi-nor-tiny
mtd: spi-nand: Fix not calling dev_err with a device
mmc: Add mmc_dev()
mmc: bcm2835-host: Fix not calling dev_dbg with a device
mmc: mtk-sd: Fix not calling dev_err with a device
mailbox: k3: Fix not calling dev_err with a device
nand: atmel: Fix not calling dev_xxx with a device
nand: brcmnand: Fix not calling dev_err() with a device
nand: vybrid: Re-introduce vf610_nfc.dev
net: bcm6368: Fix not calling dev_info with a device
net: mdio: Fix not calling dev_dbg with a device
net: mvneta: Fix not always calling dev_err with a device
net: mvneta: Convert netdev_xxx to dev_xxx
net: mvpp2: Fix not calling dev_xxx with a device
net: mvpp2: Convert netdev_xxx to dev_xxx linux/compat.h: Remove netdev_xxx functions
net: sunxi: Fix not calling dev_xxx with a device
net: sun8i_emac: Fix not calling dev_xxx with a device
net: ti: cpsw: Fix not calling dev_dbg with a device
phy: marvell: Fix not calling dev_err with a device
phy: rockchip: Fix not calling dev_err with a device
phy: sun4i-usb: Fix not calling dev_err with a device
phy: ti: Fix not calling dev_err with a device
phy: usbphyc: Fix not calling dev_err with a device
remoteproc: Remove unused function rproc_elf_sanity_check
remoteproc: k3-r5: Fix not calling dev_xxx with a device
remoteproc: k3: Fix not calling dev_xxx with a device
soc: qualcomm: Fix not calling dev_err with a device
spi: sunxi: Fix not calling dev_err with a device
spi: zynqmp_gqspi: Fix not calling dev_err with a device
sysreset: ti: Fix not calling dev_err with a device
usb: cdns3: Fix not calling dev_xxx with a device
usb: dwc2: Fix not calling dev_xxx with a device
usb: dwc3: Fix not calling dev_xxx with a device
usb: dwc3: ti: Fix not calling dev_err with a device
usb: dwc3: Don't include asm-generic/io.h
usb: musb-new: sunxi: Fix not calling dev_err with a device
video: stm32: Fix not calling dev_xxx with a device
dm: Use symbolic constants for log levels in dev_xxx
dm: Print device name in dev_xxx like Linux

 drivers/core/syscon-uclass.c              |   2 +-
 drivers/firmware/ti_sci.c                 |  23 ++--
 drivers/i2c/mxc_i2c.c                     |   7 +-
 drivers/mailbox/k3-sec-proxy.c            |   6 +-
 drivers/mmc/bcm2835_sdhost.c              |  34 +++---
 drivers/mmc/mtk-sd.c                      |  24 ++--
 drivers/mtd/nand/raw/atmel_nand.c         |  69 +++++++-----
 drivers/mtd/nand/raw/brcmnand/brcmnand.c  |  20 +---
 drivers/mtd/nand/raw/pxa3xx_nand.c        |  30 ++---
 drivers/mtd/nand/raw/sunxi_nand.c         |  45 ++++----
 drivers/mtd/nand/raw/vf610_nfc.c          |  38 ++++---
 drivers/mtd/nand/spi/core.c               |   8 +-
 drivers/mtd/spi/spi-nor-core.c            |   1 +
 drivers/mtd/spi/spi-nor-tiny.c            |  21 +++-
 drivers/net/bcm6368-eth.c                 |   3 +-
 drivers/net/mvneta.c                      |  56 +++++-----
 drivers/net/mvpp2.c                       |  87 ++++++++-------
 drivers/net/sun8i_emac.c                  |   9 +-
 drivers/net/sunxi_emac.c                  |   5 +-
 drivers/net/ti/cpsw.c                     |   6 +
 drivers/phy/allwinner/phy-sun4i-usb.c     |  12 +-
 drivers/phy/marvell/comphy_core.c         |   6 +-
 drivers/phy/phy-stm32-usbphyc.c           |   2 +-
 drivers/phy/phy-ti-am654.c                |   4 +-
 drivers/phy/rockchip/phy-rockchip-pcie.c  |  14 +--
 drivers/phy/rockchip/phy-rockchip-typec.c |   6 +-
 drivers/remoteproc/k3_system_controller.c |   9 +-
 drivers/remoteproc/rproc-elf-loader.c     |  16 ---
 drivers/remoteproc/ti_k3_r5f_rproc.c      |  24 ++--
 drivers/smem/msm_smem.c                   |   2 +-
 drivers/spi/spi-sunxi.c                   |   6 +-
 drivers/spi/zynqmp_gqspi.c                |   6 +-
 drivers/sysreset/sysreset-ti-sci.c        |   3 +-
 drivers/usb/cdns3/ep0.c                   |   5 +-
 drivers/usb/cdns3/gadget.c                |   3 +-
 drivers/usb/dwc3/core.c                   |  15 +--
 drivers/usb/dwc3/dwc3-generic.c           |   1 -
 drivers/usb/dwc3/ep0.c                    |   1 +
 drivers/usb/dwc3/gadget.c                 |  23 ++--
 drivers/usb/dwc3/ti_usb_phy.c             |   4 +-
 drivers/usb/host/dwc2.c                   |  39 ++++---
Quoted 8 lines
 drivers/usb/musb-new/sunxi.c              |   9 +-
 drivers/video/dw_mipi_dsi.c               |  24 ++--
 include/dm/device_compat.h                | 127 ++++++++++++++++------
 include/linux/compat.h                    |  19 ----
 include/mmc.h                             |   2 +
 include/remoteproc.h                      |  13 ---
 net/mdio-uclass.c                         |   4 +-
 48 files changed, 486 insertions(+), 407 deletions(-)

For the series, applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200930/a91aa67f/attachment.sig>