dm: Various enhancements to prepare for ACPI
Subsystems (7)
cover dm: Various enhancements to prepare for ACPI
This series contains various minor enhancements needed to implement the programmatic generation of ACPI tables on x86 devices. These are mostly generic routines and are likely to be useful elsewhere.
It also includes a few test improvements to support checking console output more easily.
Simon Glass (21):
dm: core: Use const where possible in device.h
dm: pci: Update the PCI read_config() method to const dev *
dm: pci: Update a few more interfaces for const udevice *
dm: core: Use const device for the devfdt...() interface
dm: core: Use const device for the dev_read_...() interface
test: Add underscore prefix to macro parameters
dm: core: Update comment for ofnode_get_chosen_node()
dm: core: Rename ofnode_get_chosen_prop()
dm: core: Add ofnode_read_prop()
dm: core: Reimplement ofnode_read_size()
dm: core: Add ofnode_get_chosen_prop()
dm: core: Add a way to read platdata for all child devices
dm: core: Add a way to iterate through children, probing each
dm: core: Drop uclass_find_next_free_req_seq() conditions
bloblist: Add a new function to add or check size
bloblist: Tidy up a few comments and code-style nits
bloblist: Zero records when adding
sandbox: pmic: Correct i2c pmic emulator platdata method
console: Add a function to read a line of the output / eof
test: Enable console recording in tests
test: Add a way to check each line of console output
arch/sandbox/dts/test.dts | 3 + .../puma_rk3399/puma-rk3399.c | 2 +- board/xilinx/common/board.c | 2 +- common/bloblist.c | 23 +- common/console.c | 11 + doc/README.bloblist | 4 +- drivers/core/device.c | 85 +++++-- drivers/core/fdtaddr.c | 26 +-- drivers/core/ofnode.c | 71 +++--- drivers/core/read.c | 97 ++++---- drivers/core/uclass.c | 4 - drivers/misc/p2sb_emul.c | 5 +- drivers/misc/swap_case.c | 9 +- drivers/pci/pci-aardvark.c | 2 +- drivers/pci/pci-emul-uclass.c | 2 +- drivers/pci/pci-rcar-gen2.c | 4 +- drivers/pci/pci-rcar-gen3.c | 2 +- drivers/pci/pci-uclass.c | 32 +-- drivers/pci/pci_mpc85xx.c | 2 +- drivers/pci/pci_mvebu.c | 2 +- drivers/pci/pci_sandbox.c | 2 +- drivers/pci/pci_sh7751.c | 2 +- drivers/pci/pci_tegra.c | 2 +- drivers/pci/pci_x86.c | 5 +- drivers/pci/pcie_dw_mvebu.c | 2 +- drivers/pci/pcie_dw_ti.c | 2 +- drivers/pci/pcie_ecam_generic.c | 11 +- drivers/pci/pcie_fsl.c | 2 +- drivers/pci/pcie_imx.c | 2 +- drivers/pci/pcie_intel_fpga.c | 4 +- drivers/pci/pcie_layerscape.c | 4 +- drivers/pci/pcie_layerscape_gen4.c | 2 +- drivers/pci/pcie_mediatek.c | 4 +- drivers/pci/pcie_phytium.c | 7 +- drivers/pci/pcie_xilinx.c | 4 +- drivers/power/acpi_pmc/pmc_emul.c | 2 +- drivers/power/pmic/i2c_pmic_emul.c | 16 +- include/bloblist.h | 16 +- include/console.h | 19 ++ include/dm/device.h | 111 +++++++-- include/dm/fdtaddr.h | 26 +-- include/dm/ofnode.h | 39 +++- include/dm/read.h | 212 +++++++++--------- include/fdtdec.h | 2 +- include/pci.h | 38 ++-- include/test/test.h | 4 + include/test/ut.h | 109 +++++++-- lib/fdtdec.c | 2 +- test/bloblist.c | 61 ++++- test/dm/ofnode.c | 55 +++++ test/dm/test-fdt.c | 38 ++++ test/dm/test-main.c | 4 +- test/ut.c | 46 ++++ 53 files changed, 892 insertions(+), 351 deletions(-)
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 1/21 dm: core: Use const where possible in device.h
Update this header file to use const devices where possible, to permit callers to also use const.
---
drivers/core/device.c | 27 ++++++++++++++------------- include/dm/device.h | 30 ++++++++++++++++-------------- include/dm/read.h | 4 ++-- 3 files changed, 32 insertions(+), 29 deletions(-)
drivers/core/device.c +14 -13
@@ -591,7 +591,8 @@ static int device_find_by_ofnode(ofnode node, struct udevice **devp) }#endif -int device_get_child (struct udevice *parent,int index,struct udevice **devp) +int device_get_child (const struct udevice *parent,int index, +struct udevice **devp) {struct udevice *dev;
@@ -603,7 +604,7 @@ int device_get_child(struct udevice *parent, int index, struct udevice **devp)return -ENODEV ; } -int device_get_child_count (struct udevice *parent) +int device_get_child_count (const struct udevice *parent) {struct udevice *dev;int count =0 ;
@@ -614,7 +615,7 @@ int device_get_child_count(struct udevice *parent)return count; } -int device_find_child_by_seq (struct udevice *parent,int seq_or_req_seq, +int device_find_child_by_seq (const struct udevice *parent,int seq_or_req_seq,bool find_req_seq,struct udevice **devp) {struct udevice *dev;
@@ -634,7 +635,7 @@ int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq,return -ENODEV ; } -int device_get_child_by_seq (struct udevice *parent,int seq, +int device_get_child_by_seq (const struct udevice *parent,int seq,struct udevice **devp) {struct udevice *dev;
@@ -652,7 +653,7 @@ int device_get_child_by_seq(struct udevice *parent, int seq,return device_get_device_tail (dev, ret, devp); } -int device_find_child_by_of_offset (struct udevice *parent,int of_offset, +int device_find_child_by_of_offset (const struct udevice *parent,int of_offset,struct udevice **devp) {struct udevice *dev;
@@ -669,7 +670,7 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset,return -ENODEV ; } -int device_get_child_by_of_offset (struct udevice *parent,int node, +int device_get_child_by_of_offset (const struct udevice *parent,int node,struct udevice **devp) {struct udevice *dev;
@@ -712,7 +713,7 @@ int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp)return device_get_device_tail (dev, dev ?0 : -ENOENT , devp); } -int device_find_first_child (struct udevice *parent,struct udevice **devp) +int device_find_first_child (const struct udevice *parent,struct udevice **devp) {if (list_empty (&parent->child_head)) { *devp =NULL ;
@@ -739,7 +740,7 @@ int device_find_next_child(struct udevice **devp)return 0 ; } -int device_find_first_inactive_child (struct udevice *parent, +int device_find_first_inactive_child (const struct udevice *parent,enum uclass_id uclass_id,struct udevice **devp) {
@@ -757,7 +758,7 @@ int device_find_first_inactive_child(struct udevice *parent,return -ENODEV ; } -int device_find_first_child_by_uclass (struct udevice *parent, +int device_find_first_child_by_uclass (const struct udevice *parent,enum uclass_id uclass_id,struct udevice **devp) {
@@ -774,7 +775,7 @@ int device_find_first_child_by_uclass(struct udevice *parent,return -ENODEV ; } -int device_find_child_by_name (struct udevice *parent,const char *name, +int device_find_child_by_name (const struct udevice *parent,const char *name,struct udevice **devp) {struct udevice *dev;
@@ -827,7 +828,7 @@ bool device_has_children(const struct udevice *dev)return !list_empty (&dev->child_head); } -bool device_has_active_children (struct udevice *dev) +bool device_has_active_children (const struct udevice *dev) {struct udevice *child;
@@ -841,7 +842,7 @@ bool device_has_active_children(struct udevice *dev)return false; } -bool device_is_last_sibling (struct udevice *dev) +bool device_is_last_sibling (const struct udevice *dev) {struct udevice *parent = dev->parent;
@@ -867,7 +868,7 @@ int device_set_name(struct udevice *dev, const char *name) }#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA ) -bool device_is_compatible (struct udevice *dev,const char *compat) +bool device_is_compatible (const struct udevice *dev,const char *compat) {return ofnode_device_is_compatible (dev_ofnode (dev), compat); }
include/dm/device.h +16 -14
@@ -409,7 +409,8 @@ const char *dev_get_uclass_name(const struct udevice *dev);* @return 0 if OK, -ENODEV if no such device, other error if the device fails * to probe */ -int device_get_child (struct udevice *parent,int index,struct udevice **devp); +int device_get_child (const struct udevice *parent,int index, +struct udevice **devp);/** * device_get_child_count() - Get the available child count of a device
@@ -418,7 +419,7 @@ int device_get_child(struct udevice *parent, int index, struct udevice **devp);* * @parent: Parent device to check */ -int device_get_child_count (struct udevice *parent); +int device_get_child_count (const struct udevice *parent);/** * device_find_child_by_seq() - Find a child device based on a sequence
@@ -439,7 +440,7 @@ int device_get_child_count(struct udevice *parent);* Set to NULL if none is found * @return 0 if OK, -ve on error */ -int device_find_child_by_seq (struct udevice *parent,int seq_or_req_seq, +int device_find_child_by_seq (const struct udevice *parent,int seq_or_req_seq,bool find_req_seq,struct udevice **devp);/**
@@ -457,7 +458,7 @@ int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq,* Set to NULL if none is found * @return 0 if OK, -ve on error */ -int device_get_child_by_seq (struct udevice *parent,int seq, +int device_get_child_by_seq (const struct udevice *parent,int seq,struct udevice **devp);/**
@@ -470,7 +471,7 @@ int device_get_child_by_seq(struct udevice *parent, int seq,* @devp: Returns pointer to device if found, otherwise this is set to NULL * @return 0 if OK, -ve on error */ -int device_find_child_by_of_offset (struct udevice *parent,int of_offset, +int device_find_child_by_of_offset (const struct udevice *parent,int of_offset,struct udevice **devp);/**
@@ -485,7 +486,7 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset,* @devp: Returns pointer to device if found, otherwise this is set to NULL * @return 0 if OK, -ve on error */ -int device_get_child_by_of_offset (struct udevice *parent,int of_offset, +int device_get_child_by_of_offset (const struct udevice *parent,int of_offset,struct udevice **devp);/**
@@ -524,7 +525,8 @@ int device_get_global_by_ofnode(ofnode node, struct udevice **devp);* @devp: Returns first child device, or NULL if none * @return 0 */ -int device_find_first_child (struct udevice *parent,struct udevice **devp); +int device_find_first_child (const struct udevice *parent, +struct udevice **devp);/** * device_find_next_child() - Find the next child of a device
@@ -548,7 +550,7 @@ int device_find_next_child(struct udevice **devp);* @devp: Returns device found, if any * @return 0 if found, else -ENODEV */ -int device_find_first_inactive_child (struct udevice *parent, +int device_find_first_inactive_child (const struct udevice *parent,enum uclass_id uclass_id,struct udevice **devp);
@@ -560,7 +562,7 @@ int device_find_first_inactive_child(struct udevice *parent,* @devp: Returns first child device in that uclass, if any * @return 0 if found, else -ENODEV */ -int device_find_first_child_by_uclass (struct udevice *parent, +int device_find_first_child_by_uclass (const struct udevice *parent,enum uclass_id uclass_id,struct udevice **devp);
@@ -572,7 +574,7 @@ int device_find_first_child_by_uclass(struct udevice *parent,* @devp: Returns device found, if any * @return 0 if found, else -ENODEV */ -int device_find_child_by_name (struct udevice *parent,const char *name, +int device_find_child_by_name (const struct udevice *parent,const char *name,struct udevice **devp);/**
@@ -590,7 +592,7 @@ bool device_has_children(const struct udevice *dev);* @return true if the device has one or more children and at least one of * them is active (probed). */ -bool device_has_active_children (struct udevice *dev); +bool device_has_active_children (const struct udevice *dev);/** * device_is_last_sibling() - check if a device is the last sibling
@@ -603,7 +605,7 @@ bool device_has_active_children(struct udevice *dev);* @return true if there are no more siblings after this one - i.e. is it * last in the list. */ -bool device_is_last_sibling (struct udevice *dev); +bool device_is_last_sibling (const struct udevice *dev);/** * device_set_name() - set the name of a device
@@ -643,7 +645,7 @@ void device_set_name_alloced(struct udevice *dev);* device * @return true if OK, false if the compatible is not found */ -bool device_is_compatible (struct udevice *dev,const char *compat); +bool device_is_compatible (const struct udevice *dev,const char *compat);/** * of_machine_is_compatible() - check if the machine is compatible with
@@ -678,7 +680,7 @@ int dev_enable_by_path(const char *path);* @dev: device to test * @return: true if it is on a PCI bus, false otherwise */ -static inline bool device_is_on_pci_bus (struct udevice *dev) +static inline bool device_is_on_pci_bus (const struct udevice *dev) {return device_get_uclass_id (dev->parent) ==UCLASS_PCI ; }
include/dm/read.h +2 -2
@@ -33,12 +33,12 @@ static inline const struct device_node *dev_np(struct udevice *dev)* @dev: device to check * @return reference of the the device's DT node */ -static inline ofnode dev_ofnode (struct udevice *dev) +static inline ofnode dev_ofnode (const struct udevice *dev) {return dev->node; } -static inline bool dev_of_valid (struct udevice *dev) +static inline bool dev_of_valid (const struct udevice *dev) {return ofnode_valid (dev_ofnode (dev)); }
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 1/21 dm: core: Use const where possible in device.h
Update this header file to use const devices where possible, to permit callers to also use const.
---
drivers/core/device.c | 27 ++++++++++++++------------- include/dm/device.h | 30 ++++++++++++++++-------------- include/dm/read.h | 4 ++-- 3 files changed, 32 insertions(+), 29 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 2/21 dm: pci: Update the PCI read_config() method to const dev *
In reply to Simon GlassAt present this method uses a non-const udevice pointer, but the call should not modify the device. Use a const pointer.
---
drivers/misc/p2sb_emul.c | 5 +++-- drivers/misc/swap_case.c | 9 +++++---- drivers/pci/pci-aardvark.c | 2 +- drivers/pci/pci-emul-uclass.c | 2 +- drivers/pci/pci-rcar-gen2.c | 4 ++-- drivers/pci/pci-rcar-gen3.c | 2 +- drivers/pci/pci-uclass.c | 14 ++++++++------ drivers/pci/pci_mpc85xx.c | 2 +- drivers/pci/pci_mvebu.c | 2 +- drivers/pci/pci_sandbox.c | 2 +- drivers/pci/pci_sh7751.c | 2 +- drivers/pci/pci_tegra.c | 2 +- drivers/pci/pci_x86.c | 5 +++-- drivers/pci/pcie_dw_mvebu.c | 2 +- drivers/pci/pcie_dw_ti.c | 2 +- drivers/pci/pcie_ecam_generic.c | 11 ++++++----- drivers/pci/pcie_fsl.c | 2 +- drivers/pci/pcie_imx.c | 2 +- drivers/pci/pcie_intel_fpga.c | 4 ++-- drivers/pci/pcie_layerscape.c | 4 ++-- drivers/pci/pcie_layerscape_gen4.c | 2 +- drivers/pci/pcie_mediatek.c | 4 ++-- drivers/pci/pcie_phytium.c | 7 +++---- drivers/pci/pcie_xilinx.c | 4 ++-- drivers/power/acpi_pmc/pmc_emul.c | 2 +- include/pci.h | 22 ++++++++++++---------- 26 files changed, 64 insertions(+), 57 deletions(-)
drivers/misc/p2sb_emul.c +3 -2
@@ -48,8 +48,9 @@ struct p2sb_emul_priv {u8 regs[16 ]; }; -static int sandbox_p2sb_emul_read_config (struct udevice *emul,uint offset, -ulong *valuep,enum pci_size_t size) +static int sandbox_p2sb_emul_read_config (const struct udevice *emul, +uint offset,ulong *valuep, +enum pci_size_t size) {struct p2sb_emul_platdata *plat =dev_get_platdata (emul);
drivers/misc/swap_case.c +5 -4
@@ -51,7 +51,7 @@ struct swap_case_priv {char mem_text[MEM_TEXT_SIZE ]; }; -static int sandbox_swap_case_use_ea (struct udevice *dev) +static int sandbox_swap_case_use_ea (const struct udevice *dev) {return !!ofnode_get_property (dev->node,"use-ea" ,NULL ); }
@@ -82,7 +82,7 @@ static const u32 ea_regs[] = { PCI_CAP_EA_SIZE_HI, }; -static int sandbox_swap_case_read_ea (struct udevice *emul,uint offset, +static int sandbox_swap_case_read_ea (const struct udevice *emul,uint offset,ulong *valuep,enum pci_size_t size) {u32 reg;
@@ -95,8 +95,9 @@ static int sandbox_swap_case_read_ea(struct udevice *emul, uint offset,return 0 ; } -static int sandbox_swap_case_read_config (struct udevice *emul,uint offset, -ulong *valuep,enum pci_size_t size) +static int sandbox_swap_case_read_config (const struct udevice *emul, +uint offset,ulong *valuep, +enum pci_size_t size) {struct swap_case_platdata *plat =dev_get_platdata (emul);
drivers/pci/pci-aardvark.c +1 -1
@@ -297,7 +297,7 @@ static int pcie_advk_check_pio_status(struct pcie_advk *pcie,* * Return: 0 on success */ -static int pcie_advk_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_advk_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pci-emul-uclass.c +1 -1
@@ -15,7 +15,7 @@ struct sandbox_pci_emul_priv {int dev_count; }; -int sandbox_pci_get_emul (struct udevice *bus,pci_dev_t find_devfn, +int sandbox_pci_get_emul (const struct udevice *bus,pci_dev_t find_devfn,struct udevice **containerp,struct udevice **emulp) {struct pci_emul_uc_priv *upriv;
drivers/pci/pci-rcar-gen2.c +2 -2
@@ -107,7 +107,7 @@ static int rcar_gen2_pci_addr_valid(pci_dev_t d, uint offset)return 0 ; } -static u32 get_bus_address (struct udevice *dev,pci_dev_t bdf,u32 offset) +static u32 get_bus_address (const struct udevice *dev,pci_dev_t bdf,u32 offset) {struct rcar_gen2_pci_priv *priv =dev_get_priv (dev);
@@ -126,7 +126,7 @@ static u32 setup_bus_address(struct udevice *dev, pci_dev_t bdf, u32 offset)return get_bus_address (dev, bdf, offset); } -static int rcar_gen2_pci_read_config (struct udevice *dev,pci_dev_t bdf, +static int rcar_gen2_pci_read_config (const struct udevice *dev,pci_dev_t bdf,uint offset,ulong *value,enum pci_size_t size) {
drivers/pci/pci-rcar-gen3.c +1 -1
@@ -204,7 +204,7 @@ static int rcar_gen3_pcie_addr_valid(pci_dev_t d, uint where)return 0 ; } -static int rcar_gen3_pcie_read_config (struct udevice *dev,pci_dev_t bdf, +static int rcar_gen3_pcie_read_config (const struct udevice *dev,pci_dev_t bdf,uint where,ulong *val,enum pci_size_t size) {
drivers/pci/pci-uclass.c +8 -6
@@ -124,7 +124,7 @@ static void pci_dev_find_ofnode(struct udevice *bus, phys_addr_t bdf, } }; -int pci_bus_find_devfn (struct udevice *bus,pci_dev_t find_devfn, +int pci_bus_find_devfn (const struct udevice *bus,pci_dev_t find_devfn,struct udevice **devp) {struct udevice *dev;
@@ -551,8 +551,9 @@ int pci_auto_config_devices(struct udevice *bus) } int pci_generic_mmap_write_config( - struct udevice *bus, - int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp), + const struct udevice *bus, + int (*addr_f)(const struct udevice *bus, pci_dev_t bdf, uint offset, + void **addrp), pci_dev_t bdf, uint offset, ulong value,
@@ -579,8 +580,9 @@ int pci_generic_mmap_write_config( } int pci_generic_mmap_read_config( - struct udevice *bus, - int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp), + const struct udevice *bus, + int (*addr_f)(const struct udevice *bus, pci_dev_t bdf, uint offset, + void **addrp), pci_dev_t bdf, uint offset, ulong *valuep,
@@ -1054,7 +1056,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev)return 0 ; } -static int pci_bridge_read_config (struct udevice *bus,pci_dev_t bdf, +static int pci_bridge_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pci_mpc85xx.c +1 -1
@@ -15,7 +15,7 @@ struct mpc85xx_pci_priv {void __iomem *cfg_data; }; -static int mpc85xx_pci_dm_read_config (struct udevice *dev,pci_dev_t bdf, +static int mpc85xx_pci_dm_read_config (const struct udevice *dev,pci_dev_t bdf,uint offset,ulong *value,enum pci_size_t size) {
drivers/pci/pci_mvebu.c +1 -1
@@ -136,7 +136,7 @@ static inline struct mvebu_pcie *hose_to_pcie(struct pci_controller *hose) return container_of(hose, struct mvebu_pcie, hose); } -static int mvebu_pcie_read_config (struct udevice *bus,pci_dev_t bdf, +static int mvebu_pcie_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pci_sandbox.c +1 -1
@@ -39,7 +39,7 @@ static int sandbox_pci_write_config(struct udevice *bus, pci_dev_t devfn,return ops->write_config (emul, offset, value, size); } -static int sandbox_pci_read_config (struct udevice *bus,pci_dev_t devfn, +static int sandbox_pci_read_config (const struct udevice *bus,pci_dev_t devfn,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pci_sh7751.c +1 -1
@@ -85,7 +85,7 @@ static u32 get_bus_address(struct udevice *dev, pci_dev_t bdf, u32 offset)return BIT (31 ) | (PCI_DEV (bdf) <<8 ) | (offset & ~3 ); } -static int sh7751_pci_read_config (struct udevice *dev,pci_dev_t bdf, +static int sh7751_pci_read_config (const struct udevice *dev,pci_dev_t bdf,uint offset,ulong *value,enum pci_size_t size) {
drivers/pci/pci_tegra.c +1 -1
@@ -308,7 +308,7 @@ static int tegra_pcie_conf_address(struct tegra_pcie *pcie, pci_dev_t bdf, } } -static int pci_tegra_read_config (struct udevice *bus,pci_dev_t bdf, +static int pci_tegra_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pci_x86.c +3 -2
@@ -8,8 +8,9 @@#include <pci.h> #include <asm/pci.h> -static int _pci_x86_read_config (struct udevice *bus,pci_dev_t bdf,uint offset, -ulong *valuep,enum pci_size_t size) +static int _pci_x86_read_config (const struct udevice *bus,pci_dev_t bdf, +uint offset,ulong *valuep, +enum pci_size_t size) {return pci_x86_read_config (bdf, offset, valuep, size); }
drivers/pci/pcie_dw_mvebu.c +1 -1
@@ -240,7 +240,7 @@ static int pcie_dw_addr_valid(pci_dev_t d, int first_busno)* * Return: 0 on success */ -static int pcie_dw_mvebu_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_dw_mvebu_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pcie_dw_ti.c +1 -1
@@ -289,7 +289,7 @@ static int pcie_dw_addr_valid(pci_dev_t d, int first_busno)* * Return: 0 on success */ -static int pcie_dw_ti_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_dw_ti_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pcie_ecam_generic.c +6 -5
@@ -35,8 +35,9 @@ struct generic_ecam_pcie {* code. Otherwise the address to access will be written to the pointer pointed * to by @paddress. */ -static int pci_generic_ecam_conf_address (struct udevice *bus,pci_dev_t bdf, -uint offset,void **paddress) +static int pci_generic_ecam_conf_address (const struct udevice *bus, +pci_dev_t bdf,uint offset, +void **paddress) {struct generic_ecam_pcie *pcie =dev_get_priv (bus);void *addr;
@@ -63,9 +64,9 @@ static int pci_generic_ecam_conf_address(struct udevice *bus, pci_dev_t bdf,* space of the device identified by the bus, device & function numbers in @bdf * on the PCI bus @bus. */ -static int pci_generic_ecam_read_config (struct udevice *bus,pci_dev_t bdf, -uint offset,ulong *valuep, -enum pci_size_t size) +static int pci_generic_ecam_read_config (const struct udevice *bus, +pci_dev_t bdf,uint offset, +ulong *valuep,enum pci_size_t size) {return pci_generic_mmap_read_config (bus, pci_generic_ecam_conf_address, bdf, offset, valuep, size);
drivers/pci/pcie_fsl.c +1 -1
@@ -42,7 +42,7 @@ static int fsl_pcie_addr_valid(struct fsl_pcie *pcie, pci_dev_t bdf)return 0 ; } -static int fsl_pcie_read_config (struct udevice *bus,pci_dev_t bdf, +static int fsl_pcie_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pcie_imx.c +1 -1
@@ -748,7 +748,7 @@ void pci_init_board(void) imx_pcie_init(); }#else -static int imx_pcie_dm_read_config (struct udevice *dev,pci_dev_t bdf, +static int imx_pcie_dm_read_config (const struct udevice *dev,pci_dev_t bdf,uint offset,ulong *value,enum pci_size_t size) {
drivers/pci/pcie_intel_fpga.c +2 -2
@@ -226,7 +226,7 @@ static int tlp_cfg_dword_write(struct intel_fpga_pcie *pcie, pci_dev_t bdf,return tlp_read_packet (pcie,NULL ); } -int intel_fpga_rp_conf_addr (struct udevice *bus,pci_dev_t bdf, +int intel_fpga_rp_conf_addr (const struct udevice *bus,pci_dev_t bdf,uint offset,void **paddress) {struct intel_fpga_pcie *pcie =dev_get_priv (bus);
@@ -326,7 +326,7 @@ static int _pcie_intel_fpga_write_config(struct intel_fpga_pcie *pcie, byte_en, data); } -static int pcie_intel_fpga_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_intel_fpga_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pcie_layerscape.c +2 -2
@@ -243,7 +243,7 @@ static int ls_pcie_addr_valid(struct ls_pcie *pcie, pci_dev_t bdf)return 0 ; } -int ls_pcie_conf_address (struct udevice *bus,pci_dev_t bdf, +int ls_pcie_conf_address (const struct udevice *bus,pci_dev_t bdf,uint offset,void **paddress) {struct ls_pcie *pcie =dev_get_priv (bus);
@@ -271,7 +271,7 @@ int ls_pcie_conf_address(struct udevice *bus, pci_dev_t bdf,return 0 ; } -static int ls_pcie_read_config (struct udevice *bus,pci_dev_t bdf, +static int ls_pcie_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pcie_layerscape_gen4.c +1 -1
@@ -227,7 +227,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf,return pcie->cfg + offset; } -static int ls_pcie_g4_read_config (struct udevice *bus,pci_dev_t bdf, +static int ls_pcie_g4_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pcie_mediatek.c +2 -2
@@ -66,7 +66,7 @@ struct mtk_pcie {struct list_head ports; }; -static int mtk_pcie_config_address (struct udevice *udev,pci_dev_t bdf, +static int mtk_pcie_config_address (const struct udevice *udev,pci_dev_t bdf,uint offset,void **paddress) {struct mtk_pcie *pcie =dev_get_priv (udev);
@@ -77,7 +77,7 @@ static int mtk_pcie_config_address(struct udevice *udev, pci_dev_t bdf,return 0 ; } -static int mtk_pcie_read_config (struct udevice *bus,pci_dev_t bdf, +static int mtk_pcie_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pcie_phytium.c +3 -4
@@ -75,9 +75,8 @@ static int phytium_pci_skip_dev(pci_dev_t parent)* code. Otherwise the address to access will be written to the pointer pointed * to by @paddress. */ -static int pci_phytium_conf_address (struct udevice *bus,pci_dev_t bdf, -uint offset, -void **paddress) +static int pci_phytium_conf_address (const struct udevice *bus,pci_dev_t bdf, +uint offset,void **paddress) {struct phytium_pcie *pcie =dev_get_priv (bus);void *addr;
@@ -119,7 +118,7 @@ static int pci_phytium_conf_address(struct udevice *bus, pci_dev_t bdf,* space of the device identified by the bus, device & function numbers in @bdf * on the PCI bus @bus. */ -static int pci_phytium_read_config (struct udevice *bus,pci_dev_t bdf, +static int pci_phytium_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/pci/pcie_xilinx.c +2 -2
@@ -54,7 +54,7 @@ static bool pcie_xilinx_link_up(struct xilinx_pcie *pcie)* * Return: 0 on success, else -ENODEV */ -static int pcie_xilinx_config_address (struct udevice *udev,pci_dev_t bdf, +static int pcie_xilinx_config_address (const struct udevice *udev,pci_dev_t bdf,uint offset,void **paddress) {struct xilinx_pcie *pcie =dev_get_priv (udev);
@@ -97,7 +97,7 @@ static int pcie_xilinx_config_address(struct udevice *udev, pci_dev_t bdf,* * Return: 0 on success, else -ENODEV or -EINVAL */ -static int pcie_xilinx_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_xilinx_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {
drivers/power/acpi_pmc/pmc_emul.c +1 -1
@@ -42,7 +42,7 @@ struct pmc_emul_priv {u8 regs[MEMMAP_SIZE ]; }; -static int sandbox_pmc_emul_read_config (struct udevice *emul,uint offset, +static int sandbox_pmc_emul_read_config (const struct udevice *emul,uint offset,ulong *valuep,enum pci_size_t size) {struct pmc_emul_platdata *plat =dev_get_platdata (emul);
include/pci.h +12 -10
@@ -899,8 +899,8 @@ struct dm_pci_ops {* @size: Access size * @return 0 if OK, -ve on error */ -int (*read_config)(struct udevice *bus,pci_dev_t bdf,uint offset, -ulong *valuep,enum pci_size_t size); +int (*read_config)(const struct udevice *bus,pci_dev_t bdf, +uint offset,ulong *valuep,enum pci_size_t size);/** * write_config() - Write a PCI configuration value *
@@ -974,7 +974,7 @@ int dm_pci_bus_find_bdf(pci_dev_t bdf, struct udevice **devp);* @devp: Returns the device for this address, if found * @return 0 if OK, -ENODEV if not found */ -int pci_bus_find_devfn (struct udevice *bus,pci_dev_t find_devfn, +int pci_bus_find_devfn (const struct udevice *bus,pci_dev_t find_devfn,struct udevice **devp);/**
@@ -1155,8 +1155,9 @@ int pci_read_config8(pci_dev_t pcidev, int offset, u8 *valuep);* Return: 0 on success, else -EINVAL */ int pci_generic_mmap_write_config( - struct udevice *bus, - int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp), + const struct udevice *bus, + int (*addr_f)(const struct udevice *bus, pci_dev_t bdf, uint offset, + void **addrp), pci_dev_t bdf, uint offset, ulong value,
@@ -1180,8 +1181,9 @@ int pci_generic_mmap_write_config(* Return: 0 on success, else -EINVAL */ int pci_generic_mmap_read_config( - struct udevice *bus, - int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp), + const struct udevice *bus, + int (*addr_f)(const struct udevice *bus, pci_dev_t bdf, uint offset, + void **addrp), pci_dev_t bdf, uint offset, ulong *valuep,
@@ -1523,8 +1525,8 @@ struct dm_pci_emul_ops {* @size: Access size * @return 0 if OK, -ve on error */ -int (*read_config)(struct udevice *dev,uint offset,ulong *valuep, -enum pci_size_t size); +int (*read_config)(const struct udevice *dev,uint offset, +ulong *valuep,enum pci_size_t size);/** * write_config() - Write a PCI configuration value *
@@ -1609,7 +1611,7 @@ struct dm_pci_emul_ops {* @emulp: Returns emulated device if found * @return 0 if found, -ENODEV if not found */ -int sandbox_pci_get_emul (struct udevice *bus,pci_dev_t find_devfn, +int sandbox_pci_get_emul (const struct udevice *bus,pci_dev_t find_devfn,struct udevice **containerp,struct udevice **emulp);/**
Signature · 1 line
2.25.0.341.g760bfbb309-goog
Tan
PATCH 2/21 dm: pci: Update the PCI read_config() method to const dev *
Quoted 26 lines
-----Original Message-----
From: Simon Glass <[email protected]>
Sent: Monday, January 27, 2020 11:50 PM
To: U-Boot Mailing List <[email protected]>
Cc: Simon Glass <[email protected]>; Alex Marginean <[email protected]>; Bao Xiaowei <[email protected]>; Bin Meng <[email protected]>; Frank Wunderlich <[email protected]>;GSS_MTK_Uboot_upstream<[email protected]>; Heiko Schocher <[email protected]>; Hou Zhiqiang <[email protected]>; Jaehoon Chung <[email protected]>; Tan, Ley Foon <[email protected]>; Marek Behún <[email protected]>; Marek Vasut <[email protected]>; Marek Vasut <[email protected]>; Michael Walle <[email protected]>; Michal Simek <[email protected]>; Pankaj Bansal <[email protected]>; Pavel Herrmann <[email protected]>; Prabhakar Kushwaha <[email protected]>; Priyanka Jain <[email protected]>; Ramon Fried <[email protected]>; Ryder Lee <[email protected]>; Sekhar Nori <[email protected]>; Stefan Roese <[email protected]>; Thierry Reding <[email protected]>; Wasim Khan <[email protected]>; Weijie Gao <[email protected]>; liuhao <[email protected]>; shuyiqi <[email protected]>
Subject: [PATCH 02/21] dm: pci: Update the PCIread_config()method to const dev *
Quoted 4 lines
At present this method uses a non-const udevice pointer, but the call should not modify the device. Use a const pointer.
Signed-off-by Simon Glass <[email protected]>
For drivers/pci/pcie_intel_fpga.c,
Quoted 609 lines
---
drivers/misc/p2sb_emul.c | 5 +++-- drivers/misc/swap_case.c | 9 +++++---- drivers/pci/pci-aardvark.c | 2 +- drivers/pci/pci-emul-uclass.c | 2 +- drivers/pci/pci-rcar-gen2.c | 4 ++-- drivers/pci/pci-rcar-gen3.c | 2 +- drivers/pci/pci-uclass.c | 14 ++++++++------ drivers/pci/pci_mpc85xx.c | 2 +- drivers/pci/pci_mvebu.c | 2 +- drivers/pci/pci_sandbox.c | 2 +- drivers/pci/pci_sh7751.c | 2 +- drivers/pci/pci_tegra.c | 2 +- drivers/pci/pci_x86.c | 5 +++-- drivers/pci/pcie_dw_mvebu.c | 2 +- drivers/pci/pcie_dw_ti.c | 2 +- drivers/pci/pcie_ecam_generic.c | 11 ++++++----- drivers/pci/pcie_fsl.c | 2 +- drivers/pci/pcie_imx.c | 2 +- drivers/pci/pcie_intel_fpga.c | 4 ++-- drivers/pci/pcie_layerscape.c | 4 ++-- drivers/pci/pcie_layerscape_gen4.c | 2 +- drivers/pci/pcie_mediatek.c | 4 ++-- drivers/pci/pcie_phytium.c | 7 +++---- drivers/pci/pcie_xilinx.c | 4 ++-- drivers/power/acpi_pmc/pmc_emul.c | 2 +- include/pci.h | 22 ++++++++++++---------- 26 files changed, 64 insertions(+), 57 deletions(-)drivers/misc/p2sb_emul.c index renamed from drivers/misc/p2sb_emul.c +0
-0
c3795c59c0..a6ee9a235e100644drivers/misc/p2sb_emul.c +3
-2@@ -48,8 +48,9 @@ struct p2sb_emul_priv {u8 regs[16 ]; }; -static int sandbox_p2sb_emul_read_config (struct udevice *emul,uint offset, -ulong *valuep,enum pci_size_t size) +static int sandbox_p2sb_emul_read_config (const struct udevice *emul, +uint offset,ulong *valuep, +enum pci_size_t size) {struct p2sb_emul_platdata *plat =dev_get_platdata (emul);drivers/misc/swap_case.c index renamed from drivers/misc/swap_case.c +0
-0
11189d16c8..97e2afa676100644drivers/misc/swap_case.c +1
-1@@ -51,7 +51,7 @@ struct swap_case_priv {char mem_text[MEM_TEXT_SIZE ]; }; -static int sandbox_swap_case_use_ea (struct udevice *dev) +static int sandbox_swap_case_use_ea (const struct udevice *dev) { return !!ofnode_get_property(dev->node, "use-ea", NULL); } @@ - 82,7 +82,7 @@ static const u32 ea_regs[] = {drivers/misc/swap_case.c +5
-3PCI_CAP_EA_SIZE_HI, }; -static int sandbox_swap_case_read_ea (struct udevice *emul,uint offset, +static int sandbox_swap_case_read_ea (const struct udevice *emul,uint +offset,ulong *valuep,enum pci_size_t size) {u32 reg;@@ -95,8 +95,9 @@ static int sandbox_swap_case_read_ea(struct udevice *emul, uint offset, return 0; } -static int sandbox_swap_case_read_config (struct udevice *emul,uint offset, -ulong *valuep,enum pci_size_t size) +static int sandbox_swap_case_read_config (const struct udevice *emul, +uint offset,ulong *valuep, +enum pci_size_t size) {struct swap_case_platdata *plat =dev_get_platdata (emul);drivers/pci/pci-aardvark.c index renamed from drivers/pci/pci-aardvark.c +0
-0
aa0b4bc845..f1527ac667100644drivers/pci/pci-aardvark.c +2
-1@@ -297,7 +297,7 @@ static int pcie_advk_check_pio_status(structpcie_advk *pcie, * * Return: 0 on success */ -static int pcie_advk_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_advk_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pci-emul-uclass.c index renamed from drivers/pci/pci-emul-uclass.c +0
-0
0f63e491a7..9486e1cb96100644drivers/pci/pci-emul-uclass.c +2
-1@@ -15,7 +15,7 @@ struct sandbox_pci_emul_priv {int dev_count; }; -int sandbox_pci_get_emul (struct udevice *bus,pci_dev_t find_devfn, +int sandbox_pci_get_emul (const struct udevice *bus,pci_dev_t +find_devfn,struct udevice **containerp,struct udevice **emulp) {struct pci_emul_uc_priv *upriv;drivers/pci/pci-rcar-gen2.c index renamed from drivers/pci/pci-rcar-gen2.c +0
-0
d913d53f3c..014d870478100644drivers/pci/pci-rcar-gen2.c +4
-2@@ -107,7 +107,7 @@ static int rcar_gen2_pci_addr_valid(pci_dev_t d, uint offset)return 0 ; } -static u32 get_bus_address (struct udevice *dev,pci_dev_t bdf,u32 offset) +static u32 get_bus_address (const struct udevice *dev,pci_dev_t bdf, +u32 offset) {struct rcar_gen2_pci_priv *priv =dev_get_priv (dev);@@ -126,7 +126,7 @@ static u32 setup_bus_address(struct udevice *dev, pci_dev_t bdf, u32 offset) return get_bus_address(dev, bdf, offset); } -static int rcar_gen2_pci_read_config (struct udevice *dev,pci_dev_t bdf, +static int rcar_gen2_pci_read_config (const struct udevice *dev, +pci_dev_t bdf,uint offset,ulong *value,enum pci_size_t size) {drivers/pci/pci-rcar-gen3.c index renamed from drivers/pci/pci-rcar-gen3.c +0
-0
52ca13b70c..4ea7930613100644drivers/pci/pci-rcar-gen3.c +2
-1@@ -204,7 +204,7 @@ static int rcar_gen3_pcie_addr_valid(pci_dev_t d, uint where)return 0 ; } -static int rcar_gen3_pcie_read_config (struct udevice *dev,pci_dev_t bdf, +static int rcar_gen3_pcie_read_config (const struct udevice *dev, +pci_dev_t bdf,uint where,ulong *val,enum pci_size_t size) {drivers/pci/pci-uclass.c index renamed from drivers/pci/pci-uclass.c +0
-0
5be2dfd0bf..78d4129572100644drivers/pci/pci-uclass.c +1
-1@@ -124,7 +124,7 @@ static void pci_dev_find_ofnode(struct udevice *bus, phys_addr_t bdf, } }; -int pci_bus_find_devfn (struct udevice *bus,pci_dev_t find_devfn, +int pci_bus_find_devfn (const struct udevice *bus,pci_dev_t find_devfn,struct udevice **devp) {drivers/pci/pci-uclass.c +8
-5struct udevice *dev;@@ -551,8 +551,9 @@ int pci_auto_config_devices(struct udevice *bus) } int pci_generic_mmap_write_config( - struct udevice *bus, - int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp), + const struct udevice *bus, + int (*addr_f)(const struct udevice *bus, pci_dev_t bdf, uint offset, +void **addrp), pci_dev_t bdf, uint offset, ulong value,@@ -579,8 +580,9 @@ int pci_generic_mmap_write_config( } int pci_generic_mmap_read_config( - struct udevice *bus, - int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp), + const struct udevice *bus, + int (*addr_f)(const struct udevice *bus, pci_dev_t bdf, uint offset, +void **addrp), pci_dev_t bdf, uint offset, ulong *valuep,@@ -1054,7 +1056,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev)return 0 ; } -static int pci_bridge_read_config (struct udevice *bus,pci_dev_t bdf, +static int pci_bridge_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pci_mpc85xx.c index renamed from drivers/pci/pci_mpc85xx.c +0
-0
e58ab60ee0..8dff68dbd0100644drivers/pci/pci_mpc85xx.c +2
-1@@ -15,7 +15,7 @@ struct mpc85xx_pci_priv {void __iomem *cfg_data; }; -static int mpc85xx_pci_dm_read_config (struct udevice *dev,pci_dev_t bdf, +static int mpc85xx_pci_dm_read_config (const struct udevice *dev, +pci_dev_t bdf,uint offset,ulong *value,enum pci_size_t size) {drivers/pci/pci_mvebu.c index renamed from drivers/pci/pci_mvebu.c +0
-0
f9b08f38a1..7d9ad34e9d100644drivers/pci/pci_mvebu.c +2
-1@@ -136,7 +136,7 @@ static inline struct mvebu_pcie *hose_to_pcie(struct pci_controller *hose) return container_of(hose, struct mvebu_pcie, hose); } -static int mvebu_pcie_read_config (struct udevice *bus,pci_dev_t bdf, +static int mvebu_pcie_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pci_sandbox.c index renamed from drivers/pci/pci_sandbox.c +0
-0
2af2b79c05..fa4c476597100644drivers/pci/pci_sandbox.c +2
-1@@ -39,7 +39,7 @@ static int sandbox_pci_write_config(struct udevice *bus, pci_dev_t devfn, return ops->write_config(emul, offset, value, size); } -static int sandbox_pci_read_config (struct udevice *bus,pci_dev_t devfn, +static int sandbox_pci_read_config (const struct udevice *bus,pci_dev_t +devfn,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pci_sh7751.c index renamed from drivers/pci/pci_sh7751.c +0
-0
53e1668c99..b39c6283db100644drivers/pci/pci_sh7751.c +2
-1@@ -85,7 +85,7 @@ static u32 get_bus_address(struct udevice *dev, pci_dev_t bdf, u32 offset)return BIT (31 ) | (PCI_DEV (bdf) <<8 ) | (offset & ~3 ); } -static int sh7751_pci_read_config (struct udevice *dev,pci_dev_t bdf, +static int sh7751_pci_read_config (const struct udevice *dev,pci_dev_t +bdf,uint offset,ulong *value,enum pci_size_t size) {drivers/pci/pci_tegra.c index renamed from drivers/pci/pci_tegra.c +0
-0
56c08585e6..96d308f7bf100644drivers/pci/pci_tegra.c +2
-1@@ -308,7 +308,7 @@ static int tegra_pcie_conf_address(struct tegra_pcie *pcie, pci_dev_t bdf, } } -static int pci_tegra_read_config (struct udevice *bus,pci_dev_t bdf, +static int pci_tegra_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pci_x86.c index renamed from drivers/pci/pci_x86.c +0
-0
e76a9c6e44..8d036930e7100644drivers/pci/pci_x86.c +3
-2@@ -8,8 +8,9 @@#include <pci.h> #include <asm/pci.h> -static int _pci_x86_read_config (struct udevice *bus,pci_dev_t bdf,uint offset, -ulong *valuep,enum pci_size_t size) +static int _pci_x86_read_config(const struct udevice *bus, pci_dev_t bdf, +uint offset,ulong *valuep, +enum pci_size_t size) { return pci_x86_read_config(bdf, offset, valuep, size); } diff --git
a/drivers/pci/pcie_dw_mvebu.cb/drivers/pci/pcie_dw_mvebu.cindex693591e375..1f216e1c68100644drivers/pci/pcie_dw_mvebu.c +2
-1@@ -240,7 +240,7 @@ static int pcie_dw_addr_valid(pci_dev_t d, intfirst_busno) * * Return: 0 on success */ -static int pcie_dw_mvebu_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_dw_mvebu_read_config (const struct udevice *bus, +pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pcie_dw_ti.c index renamed from drivers/pci/pcie_dw_ti.c +0
-0
b37fc2de7f..433640d3e7100644drivers/pci/pcie_dw_ti.c +2
-1@@ -289,7 +289,7 @@ static int pcie_dw_addr_valid(pci_dev_t d, intfirst_busno) * * Return: 0 on success */ -static int pcie_dw_ti_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_dw_ti_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {(quoted diff) +0
-0
b/drivers/pci/pcie_ecam_generic.cindex00644edd26..c875f3a5b7100644drivers/pci/pcie_ecam_generic.c +0
-0@@ -35,8 +35,9 @@ struct generic_ecam_pcie {* code. Otherwise the address to access will be written to the pointer pointed
* to by @paddress.
*/
-static int pci_generic_ecam_conf_address(struct udevice *bus,pci_dev_tbdf,drivers/pci/pcie_ecam_generic.c +3
-1- uint offset, void **paddress) +static int pci_generic_ecam_conf_address (const struct udevice *bus, +pci_dev_t bdf,uint offset, +void **paddress) {struct generic_ecam_pcie *pcie =dev_get_priv (bus);void *addr;@@ -63,9 +64,9 @@ static int pci_generic_ecam_conf_address(struct udevice *bus, pci_dev_t bdf, * space of the device identified by the bus, device & function numbers in@bdf
* on the PCI bus @bus.
*/drivers/pci/pcie_ecam_generic.c +3
-3-static int pci_generic_ecam_read_config (struct udevice *bus,pci_dev_t bdf, -uint offset,ulong *valuep, -enum pci_size_t size) +static int pci_generic_ecam_read_config (const struct udevice *bus, +pci_dev_t bdf,uint offset, +ulong *valuep,enum pci_size_t size) { return pci_generic_mmap_read_config(bus,
pci_generic_ecam_conf_address,drivers/pci/pcie_ecam_generic.c +0
-0bdf, offset, valuep, size);drivers/pci/pcie_fsl.c index renamed from drivers/pci/pcie_fsl.c +0
-0
ab25aeee73..f516ec0576100644drivers/pci/pcie_fsl.c +2
-1@@ -42,7 +42,7 @@ static int fsl_pcie_addr_valid(struct fsl_pcie *pcie, pci_dev_t bdf)return 0 ; } -static int fsl_pcie_read_config (struct udevice *bus,pci_dev_t bdf, +static int fsl_pcie_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pcie_imx.c index renamed from drivers/pci/pcie_imx.c +0
-0
3621636cb2..8e1713a2d1100644drivers/pci/pcie_imx.c +2
-1@@ -748,7 +748,7 @@ void pci_init_board(void) imx_pcie_init(); }#else -static int imx_pcie_dm_read_config (struct udevice *dev,pci_dev_t bdf, +static int imx_pcie_dm_read_config (const struct udevice *dev,pci_dev_t +bdf,uint offset,ulong *value,enum pci_size_t size) {drivers/pci/pcie_intel_fpga.c index renamed from drivers/pci/pcie_intel_fpga.c +0
-0
a5ea4888f3..a1f6e95e69100644drivers/pci/pcie_intel_fpga.c +1
-1@@ -226,7 +226,7 @@ static int tlp_cfg_dword_write(struct intel_fpga_pcie *pcie, pci_dev_t bdf, return tlp_read_packet(pcie, NULL); } -int intel_fpga_rp_conf_addr (struct udevice *bus,pci_dev_t bdf, +int intel_fpga_rp_conf_addr (const struct udevice *bus,pci_dev_t bdf,uint offset,void **paddress) {struct
intel_fpga_pcie*pcie =dev_get_priv(bus); @@ -326,7 +326,7
@@ static int _pcie_intel_fpga_write_config(structintel_fpga_pcie*pcie,drivers/pci/pcie_intel_fpga.c +2
-1byte_en, data); } -static int pcie_intel_fpga_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_intel_fpga_read_config (const struct udevice *bus, +pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pcie_layerscape.c +1
-1@@ -243,7 +243,7 @@ static int ls_pcie_addr_valid(struct ls_pcie *pcie, pci_dev_t bdf)return 0 ; } -int ls_pcie_conf_address (struct udevice *bus,pci_dev_t bdf, +int ls_pcie_conf_address (const struct udevice *bus,pci_dev_t bdf,uint offset,void **paddress) {struct
ls_pcie*pcie =dev_get_priv(bus); @@ -271,7 +271,7 @@ int
ls_pcie_conf_address(struct udevice *bus,pci_dev_tbdf,drivers/pci/pcie_layerscape.c +2
-1return 0 ; } -static int ls_pcie_read_config (struct udevice *bus,pci_dev_t bdf, +static int ls_pcie_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pcie_layerscape_gen4.c +2
-1@@ -227,7 +227,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf, return pcie->cfg + offset; } -static int ls_pcie_g4_read_config (struct udevice *bus,pci_dev_t bdf, +static int ls_pcie_g4_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pcie_mediatek.c index renamed from drivers/pci/pcie_mediatek.c +0
-0
a0dcb258b0..0b412aca0e100644drivers/pci/pcie_mediatek.c +2
-1@@ -66,7 +66,7 @@ struct mtk_pcie {struct list_head ports; }; -static int mtk_pcie_config_address (struct udevice *udev,pci_dev_t bdf, +static int mtk_pcie_config_address (const struct udevice *udev, +pci_dev_t bdf,uint offset,void **paddress) { struct mtk_pcie *pcie = dev_get_priv(udev); @@ -77,7 +77,7 @@static int mtk_pcie_config_address(struct udevice *udev,
pci_dev_tbdf,drivers/pci/pcie_mediatek.c +2
-1return 0 ; } -static int mtk_pcie_read_config (struct udevice *bus,pci_dev_t bdf, +static int mtk_pcie_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pcie_phytium.c index renamed from drivers/pci/pcie_phytium.c +0
-0
92e281e7c2..51b2171f9f100644drivers/pci/pcie_phytium.c +0
-0@@ -75,9 +75,8 @@ static int phytium_pci_skip_dev(pci_dev_t parent)* code. Otherwise the address to access will be written to the pointer pointed
* to by @paddress.
*/drivers/pci/pcie_phytium.c +1
-3-static int pci_phytium_conf_address (struct udevice *bus,pci_dev_t bdf, -uint offset, -void **paddress) +static int pci_phytium_conf_address(const struct udevice *bus, pci_dev_tbdf,
drivers/pci/pcie_phytium.c +1
-0+ uint offset, void **paddress) { struct phytium_pcie *pcie = dev_get_priv(bus);void *addr;@@ -119,7 +118,7 @@ static int pci_phytium_conf_address(struct udevice *bus, pci_dev_t bdf, * space of the device identified by the bus, device & function numbers in@bdf
* on the PCI bus @bus.
*/drivers/pci/pcie_phytium.c +2
-1-static int pci_phytium_read_config (struct udevice *bus,pci_dev_t bdf, +static int pci_phytium_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/pci/pcie_xilinx.c index renamed from drivers/pci/pcie_xilinx.c +0
-0
44a5f1e1f4..05787ae144100644drivers/pci/pcie_xilinx.c +2
-1@@ -54,7 +54,7 @@ static bool pcie_xilinx_link_up(struct xilinx_pcie *pcie)* * Return: 0 on success, else -ENODEV */ -static int pcie_xilinx_config_address (struct udevice *udev,pci_dev_t bdf, +static int pcie_xilinx_config_address (const struct udevice *udev, +pci_dev_t bdf,uint offset,void **paddress) { struct xilinx_pcie *pcie = dev_get_priv(udev); @@ -97,7 +97,7 @@static int pcie_xilinx_config_address(struct udevice *udev,
pci_dev_tbdf,
*
* Return: 0 on success, else-ENODEVor-EINVAL
*/drivers/pci/pcie_xilinx.c +2
-1-static int pcie_xilinx_read_config (struct udevice *bus,pci_dev_t bdf, +static int pcie_xilinx_read_config (const struct udevice *bus,pci_dev_t +bdf,uint offset,ulong *valuep,enum pci_size_t size) {drivers/power/acpi_pmc/pmc_emul.c +2
-1@@ -42,7 +42,7 @@ struct pmc_emul_priv {u8 regs[MEMMAP_SIZE ]; }; -static int sandbox_pmc_emul_read_config (struct udevice *emul,uint offset, +static int sandbox_pmc_emul_read_config (const struct udevice *emul, +uint offset,ulong *valuep,enum pci_size_t size) { struct pmc_emul_platdata *plat = dev_get_platdata(emul); diff --git
a/include/pci.hb/include/pci.hindex8c761d8da3..40e3c3fc6f100644include/pci.h +3
-3@@ -899,8 +899,8 @@ struct dm_pci_ops {* @size: Access size * @return 0 if OK, -ve on error */ -int (*read_config)(struct udevice *bus,pci_dev_t bdf,uint offset, -ulong *valuep,enum pci_size_t size); +int (*read_config)(const struct udevice *bus,pci_dev_t bdf, +uint offset,ulong *valuep,enum pci_size_t size);/** * write_config() - Write a PCI configuration value * @@ -974,7 +974,7 @@ int dm_pci_bus_find_bdf(pci_dev_t bdf, structudevice **devp); * @devp: Returns the device for this address, if found * @return 0 if OK, -ENODEV if not found */ -int pci_bus_find_devfn (struct udevice *bus,pci_dev_t find_devfn, +int pci_bus_find_devfn (const struct udevice *bus,pci_dev_t find_devfn,struct udevice **devp);/**
include/pci.h +3
-2@@ -1155,8 +1155,9 @@ int pci_read_config8(pci_dev_t pcidev, int offset,u8 *valuep); * Return: 0 on success, else -EINVAL */ int pci_generic_mmap_write_config( - struct udevice *bus, - int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp), + const struct udevice *bus, + int (*addr_f)(const struct udevice *bus, pci_dev_t bdf, uint offset, +void **addrp), pci_dev_t bdf,include/pci.h +3
-2uint offset, ulong value,@@ -1180,8 +1181,9 @@ int pci_generic_mmap_write_config(* Return: 0 on success, else -EINVAL */ int pci_generic_mmap_read_config( - struct udevice *bus, - int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp), + const struct udevice *bus, + int (*addr_f)(const struct udevice *bus, pci_dev_t bdf, uint offset, +void **addrp), pci_dev_t bdf, uint offset,include/pci.h +4
-4ulong *valuep,@@ -1523,8 +1525,8 @@ struct dm_pci_emul_ops {* @size: Access size * @return 0 if OK, -ve on error */ -int (*read_config)(struct udevice *dev,uint offset,ulong *valuep, -enum pci_size_t size); +int (*read_config)(const struct udevice *dev,uint offset, +ulong *valuep,enum pci_size_t size);/** * write_config() - Write a PCI configuration value * @@ -1609,7 +1611,7 @@ struct dm_pci_emul_ops {* @emulp: Returns emulated device if found * @return 0 if found, -ENODEV if not found */ -int sandbox_pci_get_emul (struct udevice *bus,pci_dev_t find_devfn, +int sandbox_pci_get_emul (const struct udevice *bus,pci_dev_t +find_devfn,struct udevice **containerp,struct udevice **emulp);/** -- 2.25.0.341.g760bfbb309-goog
PATCH 2/21 dm: pci: Update the PCI read_config() method to const dev *
Quoted 24 lines
-----Original Message-----
From: Simon Glass <[email protected]>
Sent: Monday, January 27, 2020 11:50 PM
To: U-Boot Mailing List <[email protected]>
Cc: Simon Glass <[email protected]>; Alex Marginean <[email protected]>; Bao Xiaowei <[email protected]>; Bin Meng <[email protected]>; Frank Wunderlich <[email protected]>;GSS_MTK_Uboot_upstream<[email protected]>; Heiko Schocher <[email protected]>; Hou Zhiqiang <[email protected]>; Jaehoon Chung <[email protected]>; Tan, Ley Foon <[email protected]>; Marek Behún <[email protected]>; Marek Vasut <[email protected]>; Marek Vasut <[email protected]>; Michael Walle <[email protected]>; Michal Simek <[email protected]>; Pankaj Bansal <[email protected]>; Pavel Herrmann <[email protected]>; Prabhakar Kushwaha <[email protected]>; Priyanka Jain <[email protected]>; Ramon Fried <[email protected]>; Ryder Lee <[email protected]>; Sekhar Nori <[email protected]>; Stefan Roese <[email protected]>; Thierry Reding <[email protected]>; Wasim Khan <[email protected]>; Weijie Gao <[email protected]>; liuhao <[email protected]>; shuyiqi <[email protected]>
Subject: [PATCH 02/21] dm: pci: Update the PCIread_config()method to const dev *
Quoted 4 lines
At present this method uses a non-const udevice pointer, but the call should not modify the device. Use a const pointer.
Signed-off-by Simon Glass <[email protected]>
For drivers/pci/pcie_intel_fpga.c,
Quoted 21 lines
---
drivers/misc/p2sb_emul.c | 5 +++-- drivers/misc/swap_case.c | 9 +++++---- drivers/pci/pci-aardvark.c | 2 +- drivers/pci/pci-emul-uclass.c | 2 +- drivers/pci/pci-rcar-gen2.c | 4 ++-- drivers/pci/pci-rcar-gen3.c | 2 +- drivers/pci/pci-uclass.c | 14 ++++++++------ drivers/pci/pci_mpc85xx.c | 2 +- drivers/pci/pci_mvebu.c | 2 +- drivers/pci/pci_sandbox.c | 2 +- drivers/pci/pci_sh7751.c | 2 +- drivers/pci/pci_tegra.c | 2 +- drivers/pci/pci_x86.c | 5 +++-- drivers/pci/pcie_dw_mvebu.c | 2 +- drivers/pci/pcie_dw_ti.c | 2 +- drivers/pci/pcie_ecam_generic.c | 11 ++++++----- drivers/pci/pcie_fsl.c | 2 +- drivers/pci/pcie_imx.c | 2 +- drivers/pci/pcie_intel_fpga.c | 4 ++--
Quoted 9 lines
drivers/pci/pcie_layerscape.c | 4 ++-- drivers/pci/pcie_layerscape_gen4.c | 2 +- drivers/pci/pcie_mediatek.c | 4 ++-- drivers/pci/pcie_phytium.c | 7 +++---- drivers/pci/pcie_xilinx.c | 4 ++-- drivers/power/acpi_pmc/pmc_emul.c | 2 +- include/pci.h | 22 ++++++++++++---------- 26 files changed, 64 insertions(+), 57 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 3/21 dm: pci: Update a few more interfaces for const udevice *
In reply to Simon GlassTidy up a few places where const * should be used.
---
drivers/pci/pci-uclass.c | 18 +++++++++--------- include/fdtdec.h | 2 +- include/pci.h | 16 ++++++++-------- lib/fdtdec.c | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-)
drivers/pci/pci-uclass.c +9 -9
@@ -43,7 +43,7 @@ struct udevice *pci_get_controller(struct udevice *dev)return dev; } -pci_dev_t dm_pci_get_bdf (struct udevice *dev) +pci_dev_t dm_pci_get_bdf (const struct udevice *dev) {struct pci_child_platdata *pplat =dev_get_parent_platdata (dev);struct udevice *bus = dev->parent;
@@ -349,7 +349,7 @@ int dm_pci_write_config32(struct udevice *dev, int offset, u32 value)return dm_pci_write_config (dev, offset, value,PCI_SIZE_32 ); } -int pci_bus_read_config (struct udevice *bus,pci_dev_t bdf,int offset, +int pci_bus_read_config (const struct udevice *bus,pci_dev_t bdf,int offset,unsigned long *valuep,enum pci_size_t size) {struct dm_pci_ops *ops;
@@ -373,10 +373,10 @@ int pci_read_config(pci_dev_t bdf, int offset, unsigned long *valuep,return pci_bus_read_config (bus, bdf, offset, valuep, size); } -int dm_pci_read_config (struct udevice *dev,int offset,unsigned long *valuep, -enum pci_size_t size) +int dm_pci_read_config (const struct udevice *dev,int offset, +unsigned long *valuep,enum pci_size_t size) { -struct udevice *bus; +const struct udevice *bus;for (bus = dev;device_is_on_pci_bus (bus);) bus = bus->parent;
@@ -423,7 +423,7 @@ int pci_read_config8(pci_dev_t bdf, int offset, u8 *valuep)return 0 ; } -int dm_pci_read_config8 (struct udevice *dev,int offset,u8 *valuep) +int dm_pci_read_config8 (const struct udevice *dev,int offset,u8 *valuep) {unsigned long value;int ret;
@@ -436,7 +436,7 @@ int dm_pci_read_config8(struct udevice *dev, int offset, u8 *valuep)return 0 ; } -int dm_pci_read_config16 (struct udevice *dev,int offset,u16 *valuep) +int dm_pci_read_config16 (const struct udevice *dev,int offset,u16 *valuep) {unsigned long value;int ret;
@@ -449,7 +449,7 @@ int dm_pci_read_config16(struct udevice *dev, int offset, u16 *valuep)return 0 ; } -int dm_pci_read_config32 (struct udevice *dev,int offset,u32 *valuep) +int dm_pci_read_config32 (const struct udevice *dev,int offset,u32 *valuep) {unsigned long value;int ret;
@@ -1203,7 +1203,7 @@ int pci_get_regions(struct udevice *dev, struct pci_region **iop,return (*iop !=NULL ) + (*memp !=NULL ) + (*prefp !=NULL ); } -u32 dm_pci_read_bar32 (struct udevice *dev,int barnum) +u32 dm_pci_read_bar32 (const struct udevice *dev,int barnum) {u32 addr;int bar;
include/fdtdec.h +1 -1
@@ -441,7 +441,7 @@ int fdtdec_get_pci_vendev(const void *blob, int node,* @param bar returns base address of the pci device's registers * @return 0 if ok, negative on error */ -int fdtdec_get_pci_bar32 (struct udevice *dev,struct fdt_pci_addr *addr, +int fdtdec_get_pci_bar32 (const struct udevice *dev,struct fdt_pci_addr *addr,u32 *bar);/**
include/pci.h +8 -8
@@ -924,7 +924,7 @@ struct dm_pci_ops {* @dev: Device to check * @return bus/device/function value (see PCI_BDF()) */ -pci_dev_t dm_pci_get_bdf (struct udevice *dev); +pci_dev_t dm_pci_get_bdf (const struct udevice *dev);/** * pci_bind_bus_devices() - scan a PCI bus and bind devices
@@ -1067,7 +1067,7 @@ int dm_pci_hose_probe_bus(struct udevice *bus);* @size: Access size * @return 0 if OK, -ve on error */ -int pci_bus_read_config (struct udevice *bus,pci_dev_t bdf,int offset, +int pci_bus_read_config (const struct udevice *bus,pci_dev_t bdf,int offset,unsigned long *valuep,enum pci_size_t size);/**
@@ -1102,12 +1102,12 @@ int pci_bus_clrset_config32(struct udevice *bus, pci_dev_t bdf, int offset,* Driver model PCI config access functions. Use these in preference to others * when you have a valid device */ -int dm_pci_read_config (struct udevice *dev,int offset,unsigned long *valuep, -enum pci_size_t size); +int dm_pci_read_config (const struct udevice *dev,int offset, +unsigned long *valuep,enum pci_size_t size); -int dm_pci_read_config8 (struct udevice *dev,int offset,u8 *valuep); -int dm_pci_read_config16 (struct udevice *dev,int offset,u16 *valuep); -int dm_pci_read_config32 (struct udevice *dev,int offset,u32 *valuep); +int dm_pci_read_config8 (const struct udevice *dev,int offset,u8 *valuep); +int dm_pci_read_config16 (const struct udevice *dev,int offset,u16 *valuep); +int dm_pci_read_config32 (const struct udevice *dev,int offset,u32 *valuep);int dm_pci_write_config (struct udevice *dev,int offset,unsigned long value,enum pci_size_t size);
@@ -1313,7 +1313,7 @@ void dm_pci_write_bar32(struct udevice *dev, int barnum, u32 addr);* @barnum: Bar number to read (numbered from 0) * @return: value of BAR */ -u32 dm_pci_read_bar32 (struct udevice *dev,int barnum); +u32 dm_pci_read_bar32 (const struct udevice *dev,int barnum);/** * dm_pci_bus_to_phys() - convert a PCI bus address to a physical address
lib/fdtdec.c +1 -1
@@ -224,7 +224,7 @@ int fdtdec_get_pci_vendev(const void *blob, int node, u16 *vendor, u16 *device)return -ENOENT ; } -int fdtdec_get_pci_bar32 (struct udevice *dev,struct fdt_pci_addr *addr, +int fdtdec_get_pci_bar32 (const struct udevice *dev,struct fdt_pci_addr *addr,u32 *bar) {int barnum;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 3/21 dm: pci: Update a few more interfaces for const udevice *
Tidy up a few places where const * should be used.
---
drivers/pci/pci-uclass.c | 18 +++++++++--------- include/fdtdec.h | 2 +- include/pci.h | 16 ++++++++-------- lib/fdtdec.c | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 4/21 dm: core: Use const device for the devfdt...() interface
In reply to Simon GlassThese functions do not modify the device so should use a const pointer to it. Update the code accordingly.
---
drivers/core/fdtaddr.c | 26 +++++++++++++------------- include/dm/fdtaddr.h | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-)
drivers/core/fdtaddr.c +13 -13
@@ -16,7 +16,7 @@DECLARE_GLOBAL_DATA_PTR ; -fdt_addr_t devfdt_get_addr_index (struct udevice *dev,int index) +fdt_addr_t devfdt_get_addr_index (const struct udevice *dev,int index) {#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )fdt_addr_t addr;
@@ -91,8 +91,8 @@ fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index)#endif } -fdt_addr_t devfdt_get_addr_size_index (struct udevice *dev,int index, -fdt_size_t *size) +fdt_addr_t devfdt_get_addr_size_index (const struct udevice *dev,int index, +fdt_size_t *size) {#if CONFIG_IS_ENABLED (OF_CONTROL )/*
@@ -113,7 +113,7 @@ fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,#endif } -fdt_addr_t devfdt_get_addr_name (struct udevice *dev,const char *name) +fdt_addr_t devfdt_get_addr_name (const struct udevice *dev,const char *name) {#if CONFIG_IS_ENABLED (OF_CONTROL )int index;
@@ -129,8 +129,8 @@ fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name)#endif } -fdt_addr_t devfdt_get_addr_size_name (struct udevice *dev,const char *name, -fdt_size_t *size) +fdt_addr_t devfdt_get_addr_size_name (const struct udevice *dev, +const char *name,fdt_size_t *size) {#if CONFIG_IS_ENABLED (OF_CONTROL )int index;
@@ -146,17 +146,17 @@ fdt_addr_t devfdt_get_addr_size_name(struct udevice *dev, const char *name,#endif } -fdt_addr_t devfdt_get_addr (struct udevice *dev) +fdt_addr_t devfdt_get_addr (const struct udevice *dev) {return devfdt_get_addr_index (dev,0 ); } -void *devfdt_get_addr_ptr (struct udevice *dev) +void *devfdt_get_addr_ptr (const struct udevice *dev) {return (void *)(uintptr_t )devfdt_get_addr_index (dev,0 ); } -void *devfdt_remap_addr_index (struct udevice *dev,int index) +void *devfdt_remap_addr_index (const struct udevice *dev,int index) {fdt_addr_t addr =devfdt_get_addr_index (dev, index);
@@ -166,7 +166,7 @@ void *devfdt_remap_addr_index(struct udevice *dev, int index)return map_physmem (addr,0 ,MAP_NOCACHE ); } -void *devfdt_remap_addr_name (struct udevice *dev,const char *name) +void *devfdt_remap_addr_name (const struct udevice *dev,const char *name) {fdt_addr_t addr =devfdt_get_addr_name (dev, name);
@@ -176,12 +176,12 @@ void *devfdt_remap_addr_name(struct udevice *dev, const char *name)return map_physmem (addr,0 ,MAP_NOCACHE ); } -void *devfdt_remap_addr (struct udevice *dev) +void *devfdt_remap_addr (const struct udevice *dev) {return devfdt_remap_addr_index (dev,0 ); } -void *devfdt_map_physmem (struct udevice *dev,unsigned long size) +void *devfdt_map_physmem (const struct udevice *dev,unsigned long size) {fdt_addr_t addr =devfdt_get_addr (dev);
@@ -191,7 +191,7 @@ void *devfdt_map_physmem(struct udevice *dev, unsigned long size)return map_physmem (addr, size,MAP_NOCACHE ); } -fdt_addr_t devfdt_get_addr_pci (struct udevice *dev) +fdt_addr_t devfdt_get_addr_pci (const struct udevice *dev) {ulong addr;
include/dm/fdtaddr.h +13 -13
@@ -21,7 +21,7 @@ struct udevice;* * @return addr */ -fdt_addr_t devfdt_get_addr (struct udevice *dev); +fdt_addr_t devfdt_get_addr (const struct udevice *dev);/** * devfdt_get_addr_ptr() - Return pointer to the address of the reg property
@@ -31,7 +31,7 @@ fdt_addr_t devfdt_get_addr(struct udevice *dev);* * @return Pointer to addr, or NULL if there is no such property */ -void *devfdt_get_addr_ptr (struct udevice *dev); +void *devfdt_get_addr_ptr (const struct udevice *dev);/** * devfdt_remap_addr() - Return pointer to the memory-mapped I/O address
@@ -41,7 +41,7 @@ void *devfdt_get_addr_ptr(struct udevice *dev);* * @return Pointer to addr, or NULL if there is no such property */ -void *devfdt_remap_addr (struct udevice *dev); +void *devfdt_remap_addr (const struct udevice *dev);/** * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped
@@ -53,7 +53,7 @@ void *devfdt_remap_addr(struct udevice *dev);* * @return Pointer to addr, or NULL if there is no such property */ -void *devfdt_remap_addr_index (struct udevice *dev,int index); +void *devfdt_remap_addr_index (const struct udevice *dev,int index);/** * devfdt_remap_addr_name() - Get the reg property of a device, indexed by
@@ -66,7 +66,7 @@ void *devfdt_remap_addr_index(struct udevice *dev, int index);* * @return Pointer to addr, or NULL if there is no such property */ -void *devfdt_remap_addr_name (struct udevice *dev,const char *name); +void *devfdt_remap_addr_name (const struct udevice *dev,const char *name);/** * devfdt_map_physmem() - Read device address from reg property of the
@@ -79,7 +79,7 @@ void *devfdt_remap_addr_name(struct udevice *dev, const char *name);* @return mapped address, or NULL if the device does not have reg * property. */ -void *devfdt_map_physmem (struct udevice *dev,unsigned long size); +void *devfdt_map_physmem (const struct udevice *dev,unsigned long size);/** * devfdt_get_addr_index() - Get the indexed reg property of a device
@@ -90,7 +90,7 @@ void *devfdt_map_physmem(struct udevice *dev, unsigned long size);* * @return addr */ -fdt_addr_t devfdt_get_addr_index (struct udevice *dev,int index); +fdt_addr_t devfdt_get_addr_index (const struct udevice *dev,int index);/** * devfdt_get_addr_size_index() - Get the indexed reg property of a device
@@ -105,8 +105,8 @@ fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index);* * @return addr */ -fdt_addr_t devfdt_get_addr_size_index (struct udevice *dev,int index, -fdt_size_t *size); +fdt_addr_t devfdt_get_addr_size_index (const struct udevice *dev,int index, +fdt_size_t *size);/** * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
@@ -118,7 +118,7 @@ fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,* * @return addr */ -fdt_addr_t devfdt_get_addr_name (struct udevice *dev,const char *name); +fdt_addr_t devfdt_get_addr_name (const struct udevice *dev,const char *name);/** * devfdt_get_addr_size_name() - Get the reg property and its size for a device,
@@ -135,8 +135,8 @@ fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);* * @return addr */ -fdt_addr_t devfdt_get_addr_size_name (struct udevice *dev,const char *name, -fdt_size_t *size); +fdt_addr_t devfdt_get_addr_size_name (const struct udevice *dev, +const char *name,fdt_size_t *size);/** * devfdt_get_addr_pci() - Read an address and handle PCI address translation
@@ -144,6 +144,6 @@ fdt_addr_t devfdt_get_addr_size_name(struct udevice *dev, const char *name,* @dev: Device to read from * @return address or FDT_ADDR_T_NONE if not found */ -fdt_addr_t devfdt_get_addr_pci (struct udevice *dev); +fdt_addr_t devfdt_get_addr_pci (const struct udevice *dev);#endif
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 4/21 dm: core: Use const device for the devfdt...() interface
These functions do not modify the device so should use a const pointer to it. Update the code accordingly.
---
drivers/core/fdtaddr.c | 26 +++++++++++++------------- include/dm/fdtaddr.h | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 5/21 dm: core: Use const device for the dev_read_...() interface
In reply to Simon GlassThese functions do not modify the device so should use a const pointer to it. Update the code accordingly.
---
drivers/core/read.c | 97 +++++++++++---------- include/dm/read.h | 205 +++++++++++++++++++++++--------------------- 2 files changed, 159 insertions(+), 143 deletions(-)
drivers/core/read.c +51 -46
@@ -11,27 +11,29 @@#include <mapmem.h> #include <dm/of_access.h> -int dev_read_u32 (struct udevice *dev,const char *propname,u32 *outp) +int dev_read_u32 (const struct udevice *dev,const char *propname,u32 *outp) {return ofnode_read_u32 (dev_ofnode (dev), propname, outp); } -int dev_read_u32_default (struct udevice *dev,const char *propname,int def) +int dev_read_u32_default (const struct udevice *dev,const char *propname, +int def) {return ofnode_read_u32_default (dev_ofnode (dev), propname, def); } -int dev_read_s32 (struct udevice *dev,const char *propname,s32 *outp) +int dev_read_s32 (const struct udevice *dev,const char *propname,s32 *outp) {return ofnode_read_u32 (dev_ofnode (dev), propname, (u32 *)outp); } -int dev_read_s32_default (struct udevice *dev,const char *propname,int def) +int dev_read_s32_default (const struct udevice *dev,const char *propname, +int def) {return ofnode_read_u32_default (dev_ofnode (dev), propname, def); } -int dev_read_u32u (struct udevice *dev,const char *propname,uint *outp) +int dev_read_u32u (const struct udevice *dev,const char *propname,uint *outp) {u32 val;int ret;
@@ -44,32 +46,33 @@ int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp)return 0 ; } -int dev_read_u64 (struct udevice *dev,const char *propname,u64 *outp) +int dev_read_u64 (const struct udevice *dev,const char *propname,u64 *outp) {return ofnode_read_u64 (dev_ofnode (dev), propname, outp); } -u64 dev_read_u64_default (struct udevice *dev,const char *propname,u64 def) +u64 dev_read_u64_default (const struct udevice *dev,const char *propname, +u64 def) {return ofnode_read_u64_default (dev_ofnode (dev), propname, def); } -const char *dev_read_string (struct udevice *dev,const char *propname) +const char *dev_read_string (const struct udevice *dev,const char *propname) {return ofnode_read_string (dev_ofnode (dev), propname); } -bool dev_read_bool (struct udevice *dev,const char *propname) +bool dev_read_bool (const struct udevice *dev,const char *propname) {return ofnode_read_bool (dev_ofnode (dev), propname); } -ofnode dev_read_subnode (struct udevice *dev,const char *subnode_name) +ofnode dev_read_subnode (const struct udevice *dev,const char *subnode_name) {return ofnode_find_subnode (dev_ofnode (dev), subnode_name); } -ofnode dev_read_first_subnode (struct udevice *dev) +ofnode dev_read_first_subnode (const struct udevice *dev) {return ofnode_first_subnode (dev_ofnode (dev)); }
@@ -79,12 +82,12 @@ ofnode dev_read_next_subnode(ofnode node)return ofnode_next_subnode (node); } -int dev_read_size (struct udevice *dev,const char *propname) +int dev_read_size (const struct udevice *dev,const char *propname) {return ofnode_read_size (dev_ofnode (dev), propname); } -fdt_addr_t dev_read_addr_index (struct udevice *dev,int index) +fdt_addr_t dev_read_addr_index (const struct udevice *dev,int index) {if (ofnode_is_np (dev_ofnode (dev)))return ofnode_get_addr_index (dev_ofnode (dev), index);
@@ -92,7 +95,7 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index)return devfdt_get_addr_index (dev, index); } -fdt_addr_t dev_read_addr_size_index (struct udevice *dev,int index, +fdt_addr_t dev_read_addr_size_index (const struct udevice *dev,int index,fdt_size_t *size) {if (ofnode_is_np (dev_ofnode (dev)))
@@ -101,7 +104,7 @@ fdt_addr_t dev_read_addr_size_index(struct udevice *dev, int index,return devfdt_get_addr_size_index (dev, index, size); } -void *dev_remap_addr_index (struct udevice *dev,int index) +void *dev_remap_addr_index (const struct udevice *dev,int index) {fdt_addr_t addr =dev_read_addr_index (dev, index);
@@ -111,7 +114,7 @@ void *dev_remap_addr_index(struct udevice *dev, int index)return map_physmem (addr,0 ,MAP_NOCACHE ); } -fdt_addr_t dev_read_addr_name (struct udevice *dev,const char *name) +fdt_addr_t dev_read_addr_name (const struct udevice *dev,const char *name) {int index =dev_read_stringlist_search (dev,"reg-names" , name);
@@ -121,7 +124,7 @@ fdt_addr_t dev_read_addr_name(struct udevice *dev, const char *name)return dev_read_addr_index (dev, index); } -fdt_addr_t dev_read_addr_size_name (struct udevice *dev,const char *name, +fdt_addr_t dev_read_addr_size_name (const struct udevice *dev,const char *name,fdt_size_t *size) {int index =dev_read_stringlist_search (dev,"reg-names" , name);
@@ -132,7 +135,7 @@ fdt_addr_t dev_read_addr_size_name(struct udevice *dev, const char *name,return dev_read_addr_size_index (dev, index, size); } -void *dev_remap_addr_name (struct udevice *dev,const char *name) +void *dev_remap_addr_name (const struct udevice *dev,const char *name) {fdt_addr_t addr =dev_read_addr_name (dev, name);
@@ -142,52 +145,52 @@ void *dev_remap_addr_name(struct udevice *dev, const char *name)return map_physmem (addr,0 ,MAP_NOCACHE ); } -fdt_addr_t dev_read_addr (struct udevice *dev) +fdt_addr_t dev_read_addr (const struct udevice *dev) {return dev_read_addr_index (dev,0 ); } -void *dev_read_addr_ptr (struct udevice *dev) +void *dev_read_addr_ptr (const struct udevice *dev) {fdt_addr_t addr =dev_read_addr (dev);return (addr ==FDT_ADDR_T_NONE ) ?NULL :map_sysmem (addr,0 ); } -void *dev_remap_addr (struct udevice *dev) +void *dev_remap_addr (const struct udevice *dev) {return dev_remap_addr_index (dev,0 ); } -fdt_addr_t dev_read_addr_size (struct udevice *dev,const char *property, +fdt_addr_t dev_read_addr_size (const struct udevice *dev,const char *property,fdt_size_t *sizep) {return ofnode_get_addr_size (dev_ofnode (dev), property, sizep); } -const char *dev_read_name (struct udevice *dev) +const char *dev_read_name (const struct udevice *dev) {return ofnode_get_name (dev_ofnode (dev)); } -int dev_read_stringlist_search (struct udevice *dev,const char *property, +int dev_read_stringlist_search (const struct udevice *dev,const char *property,const char *string) {return ofnode_stringlist_search (dev_ofnode (dev), property, string); } -int dev_read_string_index (struct udevice *dev,const char *propname,int index, -const char **outp) +int dev_read_string_index (const struct udevice *dev,const char *propname, +int index,const char **outp) {return ofnode_read_string_index (dev_ofnode (dev), propname, index, outp); } -int dev_read_string_count (struct udevice *dev,const char *propname) +int dev_read_string_count (const struct udevice *dev,const char *propname) {return ofnode_read_string_count (dev_ofnode (dev), propname); } -int dev_read_phandle_with_args (struct udevice *dev,const char *list_name, +int dev_read_phandle_with_args (const struct udevice *dev,const char *list_name,const char *cells_name,int cell_count,int index,struct ofnode_phandle_args *out_args) {
@@ -196,34 +199,34 @@ int dev_read_phandle_with_args(struct udevice *dev, const char *list_name, out_args); } -int dev_count_phandle_with_args (struct udevice *dev,const char *list_name, -const char *cells_name) +int dev_count_phandle_with_args (const struct udevice *dev, +const char *list_name,const char *cells_name) {return ofnode_count_phandle_with_args (dev_ofnode (dev), list_name, cells_name); } -int dev_read_addr_cells (struct udevice *dev) +int dev_read_addr_cells (const struct udevice *dev) {return ofnode_read_addr_cells (dev_ofnode (dev)); } -int dev_read_size_cells (struct udevice *dev) +int dev_read_size_cells (const struct udevice *dev) {return ofnode_read_size_cells (dev_ofnode (dev)); } -int dev_read_simple_addr_cells (struct udevice *dev) +int dev_read_simple_addr_cells (const struct udevice *dev) {return ofnode_read_simple_addr_cells (dev_ofnode (dev)); } -int dev_read_simple_size_cells (struct udevice *dev) +int dev_read_simple_size_cells (const struct udevice *dev) {return ofnode_read_simple_size_cells (dev_ofnode (dev)); } -int dev_read_phandle (struct udevice *dev) +int dev_read_phandle (const struct udevice *dev) {ofnode node =dev_ofnode (dev);
@@ -233,12 +236,13 @@ int dev_read_phandle(struct udevice *dev)return fdt_get_phandle (gd->fdt_blob,ofnode_to_offset (node)); } -const void *dev_read_prop (struct udevice *dev,const char *propname,int *lenp) +const void *dev_read_prop (const struct udevice *dev,const char *propname, +int *lenp) {return ofnode_get_property (dev_ofnode (dev), propname, lenp); } -int dev_read_alias_seq (struct udevice *dev,int *devnump) +int dev_read_alias_seq (const struct udevice *dev,int *devnump) {ofnode node =dev_ofnode (dev);const char *uc_name = dev->uclass->uc_drv->name;
@@ -256,19 +260,19 @@ int dev_read_alias_seq(struct udevice *dev, int *devnump)return ret; } -int dev_read_u32_array (struct udevice *dev,const char *propname, +int dev_read_u32_array (const struct udevice *dev,const char *propname,u32 *out_values,size_t sz) {return ofnode_read_u32_array (dev_ofnode (dev), propname, out_values, sz); } -const uint8_t *dev_read_u8_array_ptr (struct udevice *dev,const char *propname, -size_t sz) +const uint8_t *dev_read_u8_array_ptr (const struct udevice *dev, +const char *propname,size_t sz) {return ofnode_read_u8_array_ptr (dev_ofnode (dev), propname, sz); } -int dev_read_enabled (struct udevice *dev) +int dev_read_enabled (const struct udevice *dev) {ofnode node =dev_ofnode (dev);
@@ -279,23 +283,24 @@ int dev_read_enabled(struct udevice *dev) ofnode_to_offset(node)); } -int dev_read_resource (struct udevice *dev,uint index,struct resource *res) +int dev_read_resource (const struct udevice *dev,uint index, +struct resource *res) {return ofnode_read_resource (dev_ofnode (dev), index, res); } -int dev_read_resource_byname (struct udevice *dev,const char *name, +int dev_read_resource_byname (const struct udevice *dev,const char *name,struct resource *res) {return ofnode_read_resource_byname (dev_ofnode (dev), name, res); } -u64 dev_translate_address (struct udevice *dev,const fdt32_t *in_addr) +u64 dev_translate_address (const struct udevice *dev,const fdt32_t *in_addr) {return ofnode_translate_address (dev_ofnode (dev), in_addr); } -u64 dev_translate_dma_address (struct udevice *dev,const fdt32_t *in_addr) +u64 dev_translate_dma_address (const struct udevice *dev,const fdt32_t *in_addr) {return ofnode_translate_dma_address (dev_ofnode (dev), in_addr); }
@@ -308,7 +313,7 @@ int dev_read_alias_highest_id(const char *stem)return fdtdec_get_alias_highest_id (gd->fdt_blob, stem); } -fdt_addr_t dev_read_addr_pci (struct udevice *dev) +fdt_addr_t dev_read_addr_pci (const struct udevice *dev) {ulong addr;
include/dm/read.h +108 -97
683 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 5/21 dm: core: Use const device for the dev_read_...() interface
These functions do not modify the device so should use a const pointer to it. Update the code accordingly.
---
drivers/core/read.c | 97 +++++++++++---------- include/dm/read.h | 205 +++++++++++++++++++++++--------------------- 2 files changed, 159 insertions(+), 143 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 6/21 test: Add underscore prefix to macro parameters
In reply to Simon GlassIf a test happens to use the same variable as the macro parameter the macro does not work as intended. Add an underscore to guard against this.
---
include/test/ut.h | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
include/test/ut.h +22 -22
@@ -56,39 +56,39 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line,/* Assert that two int expressions are equal */ #define ut_asserteq (expr1, expr2) { \ - unsigned int val1 = (expr1), val2 = (expr2); \ + unsigned int _val1 = (expr1), _val2 = (expr2); \ \ - if (val1 != val2) { \ + if (_val1 != _val2) { \ ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr1 " == " #expr2, \ - "Expected %#x (%d), got %#x (%d)", val1, val1, \ - val2, val2); \ + "Expected %#x (%d), got %#x (%d)", \ + _val1, _val1, _val2, _val2); \ return CMD_RET_FAILURE; \ } \ }/* Assert that two string expressions are equal */ #define ut_asserteq_str (expr1, expr2) { \ - const char *val1 = (expr1), *val2 = (expr2); \ + const char *_val1 = (expr1), *_val2 = (expr2); \ \ - if (strcmp(val1, val2)) { \ + if (strcmp(_val1, _val2)) { \ ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr1 " = " #expr2, \ - "Expected \"%s\", got \"%s\"", val1, val2); \ + "Expected \"%s\", got \"%s\"", _val1, _val2); \ return CMD_RET_FAILURE; \ } \ }/* Assert that two memory areas are equal */ #define ut_asserteq_mem (expr1, expr2, len) { \ - const u8 *val1 = (u8 *)(expr1), *val2 = (u8 *)(expr2); \ + const u8 *_val1 = (u8 *)(expr1), *_val2 = (u8 *)(expr2); \ const uint __len = len; \ \ - if (memcmp(val1, val2, __len)) { \ + if (memcmp(_val1, _val2, __len)) { \ char __buf1[64 + 1] = "\0"; \ char __buf2[64 + 1] = "\0"; \ - bin2hex(__buf1, val1, min(__len, (uint)32)); \ - bin2hex(__buf2, val2, min(__len, (uint)32)); \ + bin2hex(__buf1, _val1, min(__len, (uint)32)); \ + bin2hex(__buf2, _val2, min(__len, (uint)32)); \ ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr1 " = " #expr2, \ "Expected \"%s\", got \"%s\"", \
@@ -99,33 +99,33 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line,/* Assert that two pointers are equal */ #define ut_asserteq_ptr (expr1, expr2) { \ - const void *val1 = (expr1), *val2 = (expr2); \ + const void *_val1 = (expr1), *_val2 = (expr2); \ \ - if (val1 != val2) { \ + if (_val1 != _val2) { \ ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr1 " = " #expr2, \ - "Expected %p, got %p", val1, val2); \ + "Expected %p, got %p", _val1, _val2); \ return CMD_RET_FAILURE; \ } \ }/* Assert that a pointer is NULL */ #define ut_assertnull (expr) { \ - const void *val = (expr); \ + const void *_val = (expr); \ \ - if (val != NULL) { \ + if (_val) { \ ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr " != NULL", \ - "Expected NULL, got %p", val); \ + "Expected NULL, got %p", _val); \ return CMD_RET_FAILURE; \ } \ }/* Assert that a pointer is not NULL */ #define ut_assertnonnull (expr) { \ - const void *val = (expr); \ + const void *_val = (expr); \ \ - if (val == NULL) { \ + if (!_val) { \ ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr " = NULL", \ "Expected non-null, got NULL"); \
@@ -135,13 +135,13 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line,/* Assert that a pointer is not an error pointer */ #define ut_assertok_ptr (expr) { \ - const void *val = (expr); \ + const void *_val = (expr); \ \ - if (IS_ERR(val)) { \ + if (IS_ERR(_val)) { \ ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr " = NULL", \ "Expected pointer, got error %ld", \ - PTR_ERR(val)); \ + PTR_ERR(_val)); \ return CMD_RET_FAILURE; \ } \ }
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 6/21 test: Add underscore prefix to macro parameters
If a test happens to use the same variable as the macro parameter the macro does not work as intended. Add an underscore to guard against this.
---
include/test/ut.h | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 7/21 dm: core: Update comment for ofnode_get_chosen_node()
In reply to Simon GlassThe current comment is a big vague and misleading. Rewrite it to state precisely what the function does.
---
include/dm/ofnode.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
include/dm/ofnode.h +6 -3
@@ -520,11 +520,14 @@ ofnode ofnode_path(const char *path);const char *ofnode_get_chosen_prop (const char *propname);/** -* ofnode_get_chosen_node() - get the chosen node +* ofnode_get_chosen_node() - get a referenced node from the chosen node * -* @return the chosen node if present, else ofnode_null() +* This looks up a named property in the chosen node and uses that as a path to +* look up a code. +* +* @return the referenced node if present, else ofnode_null() */ -ofnode ofnode_get_chosen_node (const char *name); +ofnode ofnode_get_chosen_node (const char *propname);struct display_timing ;/**
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 7/21 dm: core: Update comment for ofnode_get_chosen_node()
The current comment is a big vague and misleading. Rewrite it to state precisely what the function does.
---
include/dm/ofnode.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 8/21 dm: core: Rename ofnode_get_chosen_prop()
In reply to Simon GlassThis function is actually intended to read a string rather than a property. All of its current callers use it that way. Also there is no way to return the length of the property from this function.
Rename it to better indicate its purpose, using ofnode_read as the prefix since this matches most other functions.
Also add some tests which are missing for these functions.
---
arch/sandbox/dts/test.dts | 2 ++ .../puma_rk3399/puma-rk3399.c | 2 +- board/xilinx/common/board.c | 2 +- drivers/core/ofnode.c | 4 ++-- include/dm/ofnode.h | 9 ++++---- test/dm/ofnode.c | 21 +++++++++++++++++++ 6 files changed, 32 insertions(+), 8 deletions(-)
arch/sandbox/dts/test.dts +2 -0
@@ -813,6 +813,8 @@ chosen { #address-cells = <1>; #size-cells = <1>; + setting = "sunrise ohoka"; + other-node = "/some-bus/c-test at 5"; chosen-test { compatible = "denx,u-boot-fdt-test"; reg = <9 1>;
board/theobroma-systems/puma_rk3399/puma-rk3399.c +1 -1
@@ -49,7 +49,7 @@ static void setup_iodomain(void)static int setup_boottargets (void ) {const char *boot_device = -ofnode_get_chosen_prop ("u-boot,spl-boot-device" ); +ofnode_read_chosen_string ("u-boot,spl-boot-device" );char *env_default, *env;if (!boot_device) {
board/xilinx/common/board.c +1 -1
@@ -22,7 +22,7 @@ int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)return -ENODEV ;debug ("%s: Path to EEPROM %s\n" , __func__, -ofnode_get_chosen_prop ("xlnx,eeprom" )); +ofnode_read_chosen_string ("xlnx,eeprom" )); ret =uclass_get_device_by_ofnode (UCLASS_I2C_EEPROM , eeprom, &dev);if (ret)
drivers/core/ofnode.c +2 -2
@@ -419,7 +419,7 @@ ofnode ofnode_path(const char *path)return offset_to_ofnode (fdt_path_offset (gd->fdt_blob, path)); } -const char *ofnode_get_chosen_prop (const char *name) +const char *ofnode_read_chosen_string (const char *name) {ofnode chosen_node;
@@ -432,7 +432,7 @@ ofnode ofnode_get_chosen_node(const char *name) {const char *prop; - prop =ofnode_get_chosen_prop (name); + prop =ofnode_read_chosen_string (name);if (!prop)return ofnode_null ();
include/dm/ofnode.h +5 -4
@@ -510,14 +510,15 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,ofnode ofnode_path (const char *path);/** -* ofnode_get_chosen_prop() - get the value of a chosen property +* ofnode_read_chosen_string() - get the string value of a chosen property * -* This looks for a property within the /chosen node and returns its value +* This looks for a property within the /chosen node and returns its value, +* checking that it is a valid nul-terminated string * * @propname: Property name to look for -* @return property value if found, else NULL +* @return string value if found, else NULL */ -const char *ofnode_get_chosen_prop (const char *propname); +const char *ofnode_read_chosen_string (const char *propname);/** * ofnode_get_chosen_node() - get a referenced node from the chosen node
test/dm/ofnode.c +21 -0
@@ -58,3 +58,24 @@ static int dm_test_ofnode_fmap(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_ofnode_fmap,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +static int dm_test_ofnode_read_chosen (struct unit_test_state *uts) +{ +const char *str; +ofnode node; + + str =ofnode_read_chosen_string ("setting" ); +ut_assertnonnull (str); +ut_asserteq_str ("sunrise ohoka" , str); +ut_asserteq_ptr (NULL ,ofnode_read_chosen_string ("no-setting" )); + + node =ofnode_get_chosen_node ("other-node" ); +ut_assert (ofnode_valid (node)); +ut_asserteq_str ("c-test at 5" ,ofnode_get_name (node)); + + node =ofnode_get_chosen_node ("setting" ); +ut_assert (!ofnode_valid (node)); + +return 0 ; +} +DM_TEST (dm_test_ofnode_read_chosen,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 8/21 dm: core: Rename ofnode_get_chosen_prop()
This function is actually intended to read a string rather than a property. All of its current callers use it that way. Also there is no way to return the length of the property from this function.
Rename it to better indicate its purpose, using ofnode_read as the prefix since this matches most other functions.
Also add some tests which are missing for these functions.
---
arch/sandbox/dts/test.dts | 2 ++ .../puma_rk3399/puma-rk3399.c | 2 +- board/xilinx/common/board.c | 2 +- drivers/core/ofnode.c | 4 ++-- include/dm/ofnode.h | 9 ++++---- test/dm/ofnode.c | 21 +++++++++++++++++++ 6 files changed, 32 insertions(+), 8 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 9/21 dm: core: Add ofnode_read_prop()
In reply to Simon GlassAdd a new function to read a property that supports reading the length as well.
Reimplement ofnode_read_string() using it and fix its comment.
---
drivers/core/ofnode.c | 31 ++++++++++++++++++++++++------- include/dm/ofnode.h | 13 ++++++++++++- test/dm/ofnode.c | 26 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 8 deletions(-)
drivers/core/ofnode.c +24 -7
@@ -101,30 +101,47 @@ bool ofnode_read_bool(ofnode node, const char *propname)return prop ? true : false; } -const char *ofnode_read_string (ofnode node,const char *propname) +const void *ofnode_read_prop (ofnode node,const char *propname,int *sizep) { -const char *str =NULL ; -int len =-1 ; +const char *val =NULL ; +int len;assert (ofnode_valid (node));debug ("%s: %s: " , __func__, propname);if (ofnode_is_np (node)) {struct property *prop =of_find_property ( -ofnode_to_np (node), propname,NULL ); +ofnode_to_np (node), propname, &len);if (prop) { - str = prop->value; + val = prop->value; len = prop->length; } }else { - str =fdt_getprop (gd->fdt_blob,ofnode_to_offset (node), + val =fdt_getprop (gd->fdt_blob,ofnode_to_offset (node), propname, &len); } -if (!str) { +if (!val) {debug ("<not found>\n" ); +if (sizep) + *sizep = -FDT_ERR_NOTFOUND ;return NULL ; } +if (sizep) + *sizep = len; + +return val; +} + +const char *ofnode_read_string (ofnode node,const char *propname) +{ +const char *str; +int len; + + str =ofnode_read_prop (node, propname, &len); +if (!str) +return NULL ; +if (strnlen (str, len) >= len) {debug ("<invalid>\n" );return NULL ;
include/dm/ofnode.h +12 -1
@@ -256,10 +256,21 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp);*/ u64 ofnode_read_u64_default (ofnode node,const char *propname,u64 def); +/** +* ofnode_read_prop() - Read a property from a node +* +* @node: valid node reference to read property from +* @propname: name of the property to read +* @sizep: if non-NULL, returns the size of the property, or an error code +if not found +* @return property value, or NULL if there is no such property +*/ +const void *ofnode_read_prop (ofnode node,const char *propname,int *sizep); +/** * ofnode_read_string() - Read a string from a property * -* @ref: valid node reference to read property from +* @node: valid node reference to read property from * @propname: name of the property to read * @return string from property value, or NULL if there is no such property */
test/dm/ofnode.c +26 -0
@@ -59,6 +59,32 @@ static int dm_test_ofnode_fmap(struct unit_test_state *uts) }DM_TEST (dm_test_ofnode_fmap,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); +static int dm_test_ofnode_read (struct unit_test_state *uts) +{ +const u32 *val; +ofnode node; +int size; + + node =ofnode_path ("/a-test" ); +ut_assert (ofnode_valid (node)); + + val =ofnode_read_prop (node,"int-value" , &size); +ut_assertnonnull (val); +ut_asserteq (4 , size); +ut_asserteq (1234 ,fdt32_to_cpu (val[0 ])); + + val =ofnode_read_prop (node,"missing" , &size); +ut_assertnull (val); +ut_asserteq (-FDT_ERR_NOTFOUND , size); + +/* Check it works without a size parameter */ + val =ofnode_read_prop (node,"missing" ,NULL ); +ut_assertnull (val); + +return 0 ; +} +DM_TEST (dm_test_ofnode_read,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); +static int dm_test_ofnode_read_chosen (struct unit_test_state *uts) {const char *str;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 9/21 dm: core: Add ofnode_read_prop()
Add a new function to read a property that supports reading the length as well.
Reimplement ofnode_read_string() using it and fix its comment.
---
drivers/core/ofnode.c | 31 ++++++++++++++++++++++++------- include/dm/ofnode.h | 13 ++++++++++++- test/dm/ofnode.c | 26 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 8 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 10/21 dm: core: Reimplement ofnode_read_size()
In reply to Simon GlassNow that we have ofnode_read_prop() we can rewrite this function using that one, reducing the amount of duplicated code.
Update ofnode_read_size() and move it up next to the other similar functions.
---
drivers/core/ofnode.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-)
drivers/core/ofnode.c +10 -19
@@ -151,6 +151,16 @@ const char *ofnode_read_string(ofnode node, const char *propname)return str; } +int ofnode_read_size (ofnode node,const char *propname) +{ +int len; + +if (!ofnode_read_prop (node, propname, &len)) +return -EINVAL ; + +return len; +} +ofnode ofnode_find_subnode (ofnode node,const char *subnode_name) {ofnode subnode;
@@ -253,25 +263,6 @@ ofnode ofnode_get_by_phandle(uint phandle)return node; } -int ofnode_read_size (ofnode node,const char *propname) -{ -int len; - -if (ofnode_is_np (node)) { -struct property *prop =of_find_property ( -ofnode_to_np (node), propname,NULL ); - -if (prop) -return prop->length; - }else { -if (fdt_getprop (gd->fdt_blob,ofnode_to_offset (node), propname, - &len)) -return len; - } - -return -EINVAL ; -} -fdt_addr_t ofnode_get_addr_size_index (ofnode node,int index,fdt_size_t *size) {int na, ns;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 10/21 dm: core: Reimplement ofnode_read_size()
Now that we have ofnode_read_prop() we can rewrite this function using that one, reducing the amount of duplicated code.
Update ofnode_read_size() and move it up next to the other similar functions.
---
drivers/core/ofnode.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 11/21 dm: core: Add ofnode_get_chosen_prop()
In reply to Simon GlassAdd a function to read a property from the chosen node, providing access to its length. Update ofnode_get_chosen_string() to make use of it.
---
arch/sandbox/dts/test.dts | 1 + drivers/core/ofnode.c | 11 ++++++++--- include/dm/ofnode.h | 12 ++++++++++++ test/dm/ofnode.c | 8 ++++++++ 4 files changed, 29 insertions(+), 3 deletions(-)
arch/sandbox/dts/test.dts +1 -0
@@ -815,6 +815,7 @@ #size-cells = <1>; setting = "sunrise ohoka"; other-node = "/some-bus/c-test at 5"; + int-values = <0x1937 72993>; chosen-test { compatible = "denx,u-boot-fdt-test"; reg = <9 1>;
drivers/core/ofnode.c +8 -3
@@ -427,20 +427,25 @@ ofnode ofnode_path(const char *path)return offset_to_ofnode (fdt_path_offset (gd->fdt_blob, path)); } -const char *ofnode_read_chosen_string (const char *name) +const void *ofnode_read_chosen_prop (const char *propname,int *sizep) {ofnode chosen_node; chosen_node =ofnode_path ("/chosen" ); -return ofnode_read_string (chosen_node, name); +return ofnode_read_prop (chosen_node, propname, sizep); +} + +const char *ofnode_read_chosen_string (const char *propname) +{ +return ofnode_read_chosen_prop (propname,NULL ); }ofnode ofnode_get_chosen_node (const char *name) {const char *prop; - prop =ofnode_read_chosen_string (name); + prop =ofnode_read_chosen_prop (name,NULL );if (!prop)return ofnode_null ();
include/dm/ofnode.h +12 -0
@@ -520,6 +520,18 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,*/ ofnode ofnode_path (const char *path); +/** +* ofnode_read_chosen_prop() - get the value of a chosen property +* +* This looks for a property within the /chosen node and returns its value +* +* @propname: Property name to look for +* @sizep: Returns size of property, or FDT_ERR_... error code if function +* returns NULL +* @return property value if found, else NULL +*/ +const void *ofnode_read_chosen_prop (const char *propname,int *sizep); +/** * ofnode_read_chosen_string() - get the string value of a chosen property *
test/dm/ofnode.c +8 -0
@@ -88,7 +88,9 @@ DM_TEST(dm_test_ofnode_read, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);static int dm_test_ofnode_read_chosen (struct unit_test_state *uts) {const char *str; +const u32 *val;ofnode node; +int size; str =ofnode_read_chosen_string ("setting" );ut_assertnonnull (str);
@@ -102,6 +104,12 @@ static int dm_test_ofnode_read_chosen(struct unit_test_state *uts) node =ofnode_get_chosen_node ("setting" );ut_assert (!ofnode_valid (node)); + val =ofnode_read_chosen_prop ("int-values" , &size); +ut_assertnonnull (val); +ut_asserteq (8 , size); +ut_asserteq (0x1937 ,fdt32_to_cpu (val[0 ])); +ut_asserteq (72993 ,fdt32_to_cpu (val[1 ])); +return 0 ; }DM_TEST (dm_test_ofnode_read_chosen,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 11/21 dm: core: Add ofnode_get_chosen_prop()
Add a function to read a property from the chosen node, providing access to its length. Update ofnode_get_chosen_string() to make use of it.
---
arch/sandbox/dts/test.dts | 1 + drivers/core/ofnode.c | 11 ++++++++--- include/dm/ofnode.h | 12 ++++++++++++ test/dm/ofnode.c | 8 ++++++++ 4 files changed, 29 insertions(+), 3 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 12/21 dm: core: Add a way to read platdata for all child devices
In reply to Simon GlassWhen generating ACPI tables we need to make sure that all devices have read their platform data, so that they can generate the tables correctly.
Rather than adding this code in ACPI, create a core function to handle it.
---
drivers/core/device.c | 36 ++++++++++++++++++++++++++++++++++++ include/dm/device.h | 42 ++++++++++++++++++++++++++++++++++++++++++ include/dm/read.h | 3 ++- test/dm/test-fdt.c | 19 +++++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-)
drivers/core/device.c +36 -0
@@ -792,6 +792,42 @@ int device_find_child_by_name(const struct udevice *parent, const char *name,return -ENODEV ; } +int device_first_child_ofdata_err (struct udevice *parent,struct udevice **devp) +{ +struct udevice *dev; +int ret; + +device_find_first_child (parent, &dev); +if (!dev) +return -ENODEV ; + + ret =device_ofdata_to_platdata (dev); +if (ret) +return ret; + + *devp = dev; + +return 0 ; +} + +int device_next_child_ofdata_err (struct udevice **devp) +{ +struct udevice *dev = *devp; +int ret; + +device_find_next_child (&dev); +if (!dev) +return -ENODEV ; + + ret =device_ofdata_to_platdata (dev); +if (ret) +return ret; + + *devp = dev; + +return 0 ; +} +struct udevice *dev_get_parent (const struct udevice *child) {return child->parent;
include/dm/device.h +42 -0
54 lines not on this page · raw message
include/dm/read.h +2 -1
@@ -844,7 +844,8 @@ static inline ofnode dev_read_next_subnode(ofnode node) }static inline const uint8_t *dev_read_u8_array_ptr (const struct udevice *dev, -const char *propname,size_t sz) +const char *propname, +size_t sz) {return ofnode_read_u8_array_ptr (dev_ofnode (dev), propname, sz); }
test/dm/test-fdt.c +19 -0
@@ -872,3 +872,22 @@ static int dm_test_read_int(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_read_int,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test device_first_child_ofdata_err(), etc. */ +static int dm_test_child_ofdata (struct unit_test_state *uts) +{ +struct udevice *bus, *dev; +int count; + +ut_assertok (uclass_first_device_err (UCLASS_TEST_BUS , &bus)); + count =0 ; + device_foreach_child_ofdata_to_platdata(dev, bus) { +ut_assert (dev->flags &DM_FLAG_PLATDATA_VALID ); +ut_assert (!(dev->flags &DM_FLAG_ACTIVATED )); + count++; + } +ut_asserteq (3 , count); + +return 0 ; +} +DM_TEST (dm_test_child_ofdata,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 12/21 dm: core: Add a way to read platdata for all child devices
When generating ACPI tables we need to make sure that all devices have read their platform data, so that they can generate the tables correctly.
Rather than adding this code in ACPI, create a core function to handle it.
---
drivers/core/device.c | 36 ++++++++++++++++++++++++++++++++++++ include/dm/device.h | 42 ++++++++++++++++++++++++++++++++++++++++++ include/dm/read.h | 3 ++- test/dm/test-fdt.c | 19 +++++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-)
Applied to u-boot-dm, thanks!
PATCH 13/21 dm: core: Add a way to iterate through children, probing each
In reply to Simon GlassIt is sometimes useful to process all children, making sure they are probed first. Add functions to help with this and a macro to make it more convenient.
---
drivers/core/device.c | 22 ++++++++++++++++++++++ include/dm/device.h | 39 +++++++++++++++++++++++++++++++++++++++ test/dm/test-fdt.c | 19 +++++++++++++++++++ 3 files changed, 80 insertions(+)
drivers/core/device.c +22 -0
@@ -792,6 +792,28 @@ int device_find_child_by_name(const struct udevice *parent, const char *name,return -ENODEV ; } +int device_first_child_err (struct udevice *parent,struct udevice **devp) +{ +struct udevice *dev; + +device_find_first_child (parent, &dev); +if (!dev) +return -ENODEV ; + +return device_get_device_tail (dev,0 , devp); +} + +int device_next_child_err (struct udevice **devp) +{ +struct udevice *dev = *devp; + +device_find_next_child (&dev); +if (!dev) +return -ENODEV ; + +return device_get_device_tail (dev,0 , devp); +} +int device_first_child_ofdata_err (struct udevice *parent,struct udevice **devp) {struct udevice *dev;
include/dm/device.h +39 -0
@@ -602,6 +602,28 @@ int device_first_child_ofdata_err(struct udevice *parent,*/ int device_next_child_ofdata_err (struct udevice **devp); +/** +* device_first_child_err() - Get the first child of a device +* +* The device returned is probed if necessary, and ready for use +* +* @parent: Parent device to search +* @devp: Returns device found, if any +* @return 0 if found, -ENODEV if not, -ve error if device failed to probe +*/ +int device_first_child_err (struct udevice *parent,struct udevice **devp); + +/** +* device_next_child_err() - Get the next child of a parent device +* +* The device returned is probed if necessary, and ready for use +* +* @devp: On entry, pointer to device to lookup. On exit, returns pointer +* to the next sibling if no error occurred +* @return 0 if found, -ENODEV if not, -ve error if device failed to probe +*/ +int device_next_child_err (struct udevice **devp); +/** * device_has_children() - check if a device has any children *
@@ -748,6 +770,23 @@ static inline bool device_is_on_pci_bus(const struct udevice *dev)for (int _ret =device_first_child_ofdata_err (parent, &dev); !_ret; \ _ret =device_next_child_ofdata_err (&dev)) +/** +* device_foreach_child_probe() - iterate through children, probing them +* +* This creates a for() loop which works through the available children of +* a device in order from start to end. Devices are probed if necessary, +* and ready for use. +* +* This stops when it gets an error, with @pos set to the device that failed to +* probe +* +* @pos: struct udevice * for the current device +* @parent: parent device to scan + */ +#define device_foreach_child_probe (pos, parent) \ + for (int _ret = device_first_child_err(parent, &dev); !_ret; \ + _ret = device_next_child_err(&dev)) +/** * dm_scan_fdt_dev() - Bind child device in a the device tree *
test/dm/test-fdt.c +19 -0
@@ -891,3 +891,22 @@ static int dm_test_child_ofdata(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_child_ofdata,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test device_first_child_err(), etc. */ +static int dm_test_first_child_probe (struct unit_test_state *uts) +{ +struct udevice *bus, *dev; +int count; + +ut_assertok (uclass_first_device_err (UCLASS_TEST_BUS , &bus)); + count =0 ; + device_foreach_child_probe(dev, bus) { +ut_assert (dev->flags &DM_FLAG_PLATDATA_VALID ); +ut_assert (dev->flags &DM_FLAG_ACTIVATED ); + count++; + } +ut_asserteq (3 , count); + +return 0 ; +} +DM_TEST (dm_test_first_child_probe,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 13/21 dm: core: Add a way to iterate through children, probing each
It is sometimes useful to process all children, making sure they are probed first. Add functions to help with this and a macro to make it more convenient.
---
drivers/core/device.c | 22 ++++++++++++++++++++++ include/dm/device.h | 39 +++++++++++++++++++++++++++++++++++++++ test/dm/test-fdt.c | 19 +++++++++++++++++++ 3 files changed, 80 insertions(+)
Applied to u-boot-dm, thanks!
PATCH 14/21 dm: core: Drop uclass_find_next_free_req_seq() conditions
In reply to Simon GlassThese conditions are not needed and just reduce build coverage. Drop them.
---
drivers/core/uclass.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/core/uclass.c +0 -4
@@ -271,9 +271,6 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,return -ENODEV ; } -#if !CONFIG_IS_ENABLED (OF_CONTROL ) || \ -CONFIG_IS_ENABLED (OF_PLATDATA ) || \ -CONFIG_IS_ENABLED (OF_PRIOR_STAGE )int uclass_find_next_free_req_seq (enum uclass_id id) {struct uclass *uc;
@@ -295,7 +292,6 @@ int uclass_find_next_free_req_seq(enum uclass_id id)return max +1 ; } -#endif int uclass_find_device_by_seq (enum uclass_id id,int seq_or_req_seq,bool find_req_seq,struct udevice **devp)
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 14/21 dm: core: Drop uclass_find_next_free_req_seq() conditions
These conditions are not needed and just reduce build coverage. Drop them.
---
drivers/core/uclass.c | 4 ---- 1 file changed, 4 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 15/21 bloblist: Add a new function to add or check size
In reply to Simon GlassA common check is to see if a blob is present, create it if not and make sure that the size is large enough. Add a function to handle this.
---
common/bloblist.c | 15 +++++++++++++++ include/bloblist.h | 13 +++++++++++++ test/bloblist.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+)
common/bloblist.c +15 -0
@@ -145,6 +145,21 @@ void *bloblist_ensure(uint tag, int size)return (void *)rec + rec->hdr_size; } +int bloblist_ensure_size_ret (uint tag,int *sizep,void **blobp) +{ +struct bloblist_rec *rec; +int ret; + + ret =bloblist_ensurerec (tag, &rec, *sizep); +if (ret == -ESPIPE ) + *sizep = rec->size; +else if (ret) +return ret; + *blobp = (void *)rec + rec->hdr_size; + +return 0 ; +} +static u32 bloblist_calc_chksum (struct bloblist_hdr *hdr) {struct bloblist_rec *rec;
include/bloblist.h +13 -0
@@ -151,6 +151,19 @@ int bloblist_ensure_size(uint tag, int size, void **blobp);*/ void *bloblist_ensure (uint tag,int size); +/** +* bloblist_ensure_size_ret() - Find or add a blob +* +* Find an existing blob, or add a new one if not found +* +* @tag: Tag to add (enum bloblist_tag_t) +* @sizep: Size of the blob to create; returns size of actual blob +* @blobp: Returns a pointer to blob on success +* @return 0 if OK, -ENOSPC if it is missing and could not be added due to lack +* of space +*/ +int bloblist_ensure_size_ret (uint tag,int *sizep,void **blobp); +/** * bloblist_new() - Create a new, empty bloblist of a given size *
test/bloblist.c +34 -0
@@ -24,6 +24,7 @@ enum {TEST_SIZE =10 ,TEST_SIZE2 =20 , +TEST_SIZE_LARGE =0xe0 ,TEST_ADDR =CONFIG_BLOBLIST_ADDR , TEST_BLOBLIST_SIZE = 0x100,
@@ -97,6 +98,39 @@ static int bloblist_test_blob(struct unit_test_state *uts) }BLOBLIST_TEST (bloblist_test_blob,0 ); +/* Check bloblist_ensure_size_ret() */ +static int bloblist_test_blob_ensure (struct unit_test_state *uts) +{ +void *data, *data2; +int size; + +/* At the start there should be no records */ +clear_bloblist (); +ut_assertok (bloblist_new (TEST_ADDR ,TEST_BLOBLIST_SIZE ,0 )); + +/* Test with an empty bloblist */ + size =TEST_SIZE ; +ut_assertok (bloblist_ensure_size_ret (TEST_TAG , &size, &data)); +ut_asserteq (TEST_SIZE , size); + +/* Check that we get the same thing again */ +ut_assertok (bloblist_ensure_size_ret (TEST_TAG , &size, &data2)); +ut_asserteq (TEST_SIZE , size); +ut_asserteq_ptr (data, data2); + +/* Check that the size remains the same */ + size =TEST_SIZE2 ; +ut_assertok (bloblist_ensure_size_ret (TEST_TAG , &size, &data)); +ut_asserteq (TEST_SIZE , size); + +/* Check running out of space */ + size =TEST_SIZE_LARGE ; +ut_asserteq (-ENOSPC ,bloblist_ensure_size_ret (TEST_TAG2 , &size, &data)); + +return 0 ; +} +BLOBLIST_TEST (bloblist_test_blob_ensure,0 ); +static int bloblist_test_bad_blob (struct unit_test_state *uts) {struct bloblist_hdr *hdr;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 15/21 bloblist: Add a new function to add or check size
A common check is to see if a blob is present, create it if not and make sure that the size is large enough. Add a function to handle this.
---
common/bloblist.c | 15 +++++++++++++++ include/bloblist.h | 13 +++++++++++++ test/bloblist.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+)
Applied to u-boot-dm, thanks!
PATCH 16/21 bloblist: Tidy up a few comments and code-style nits
In reply to Simon GlassAdd a messing error code to bloblist_new() and tidy up the line length in bloblist_addrec().
---
common/bloblist.c | 5 ++--- include/bloblist.h | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-)
common/bloblist.c +2 -3
@@ -59,11 +59,10 @@ static int bloblist_addrec(uint tag, int size, struct bloblist_rec **recp)struct bloblist_rec *rec;int new_alloced; - new_alloced = hdr->alloced +sizeof (*rec) + -ALIGN (size,BLOBLIST_ALIGN ); + new_alloced = hdr->alloced +sizeof (*rec) +ALIGN (size,BLOBLIST_ALIGN );if (new_alloced >= hdr->size) {log (LOGC_BLOBLIST ,LOGL_ERR , -"Failed to allocate %x bytes size=%x, need size>=%x\n" , +"Failed to allocate %x bytes size=%x, need size=%x\n" , size, hdr->size, new_alloced);return log_msg_ret ("bloblist add" , -ENOSPC ); }
include/bloblist.h +2 -1
@@ -183,7 +183,8 @@ int bloblist_new(ulong addr, uint size, uint flags);* @return 0 if OK, -ENOENT if the magic number doesn't match (indicating that * there problem is no bloblist at the given address), -EPROTONOSUPPORT * if the version does not match, -EIO if the checksum does not match, -* -EFBIG if the expected size does not match the detected size +* -EFBIG if the expected size does not match the detected size, -ENOSPC +* if the size is not large enough to hold the headers */ int bloblist_check (ulong addr,uint size);
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 16/21 bloblist: Tidy up a few comments and code-style nits
Add a messing error code to bloblist_new() and tidy up the line length in bloblist_addrec().
---
common/bloblist.c | 5 ++--- include/bloblist.h | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 17/21 bloblist: Zero records when adding
In reply to Simon GlassIt is convenient for bloblist to zero out the contents of a records when it is added. This saves the callers having to do it.
Update the API accordingly.
---
common/bloblist.c | 3 +++ doc/README.bloblist | 4 ++-- test/bloblist.c | 27 +++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-)
common/bloblist.c +3 -0
@@ -73,6 +73,9 @@ static int bloblist_addrec(uint tag, int size, struct bloblist_rec **recp) rec->hdr_size =sizeof (*rec); rec->size = size; rec->spare =0 ; + +/* Zero the record data */ +memset (rec +1 ,'\0' , rec->size); *recp = rec;return 0 ;
doc/README.bloblist +2 -2
@@ -55,8 +55,8 @@ a single bloblist. API --- -Bloblist provides a fairly simple API which allows blobs to be created and -found. All access is via the blob's tag. +Bloblist provides a fairly simple API which allows blobs to be created and +found. All access is via the blob's tag. Blob records are zeroed when added. Finishing the bloblist
test/bloblist.c +25 -2
@@ -34,13 +34,31 @@ static struct bloblist_hdr *clear_bloblist(void) {struct bloblist_hdr *hdr; -/* Clear out any existing bloblist so we have a clean slate */ +/* +* Clear out any existing bloblist so we have a clean slate. Zero the +* header so that existing records are removed, but set everything else +* to 0xff for testing purposes. +*/ hdr =map_sysmem (CONFIG_BLOBLIST_ADDR ,TEST_BLOBLIST_SIZE ); -memset (hdr,'\0' ,TEST_BLOBLIST_SIZE ); +memset (hdr,'\xff' ,TEST_BLOBLIST_SIZE ); +memset (hdr,'\0' ,sizeof (*hdr));return hdr; } +static int check_zero (void *data,int size) +{ +u8 *ptr; +int i; + +for (ptr = data, i =0 ; i < size; i++, ptr++) { +if (*ptr) +return -EINVAL ; + } + +return 0 ; +} +static int bloblist_test_init (struct unit_test_state *uts) {struct bloblist_hdr *hdr;
@@ -84,10 +102,14 @@ static int bloblist_test_blob(struct unit_test_state *uts) data =bloblist_find (TEST_TAG ,TEST_SIZE );ut_asserteq_ptr (rec +1 , data); +/* Check the data is zeroed */ +ut_assertok (check_zero (data,TEST_SIZE )); +/* Check the 'ensure' method */ ut_asserteq_ptr (data,bloblist_ensure (TEST_TAG ,TEST_SIZE ));ut_assertnull (bloblist_ensure (TEST_TAG ,TEST_SIZE2 )); rec2 = (struct bloblist_rec *)(data +ALIGN (TEST_SIZE ,BLOBLIST_ALIGN )); +ut_assertok (check_zero (data,TEST_SIZE ));/* Check for a non-existent record */ ut_asserteq_ptr (data,bloblist_ensure (TEST_TAG ,TEST_SIZE ));
@@ -112,6 +134,7 @@ static int bloblist_test_blob_ensure(struct unit_test_state *uts) size =TEST_SIZE ;ut_assertok (bloblist_ensure_size_ret (TEST_TAG , &size, &data));ut_asserteq (TEST_SIZE , size); +ut_assertok (check_zero (data,TEST_SIZE ));/* Check that we get the same thing again */ ut_assertok (bloblist_ensure_size_ret (TEST_TAG , &size, &data2));
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 17/21 bloblist: Zero records when adding
It is convenient for bloblist to zero out the contents of a records when it is added. This saves the callers having to do it.
Update the API accordingly.
---
common/bloblist.c | 3 +++ doc/README.bloblist | 4 ++-- test/bloblist.c | 27 +++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 18/21 sandbox: pmic: Correct i2c pmic emulator platdata method
In reply to Simon GlassThis currently reads the uclass's private data in the ofdata_to_platdata method which is not allowed, since the uclass has not read it from the device tree. This happens in the probe method.
Fix it by adding a probe() method and moving the code there.
---
drivers/power/pmic/i2c_pmic_emul.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/power/pmic/i2c_pmic_emul.c +13 -3
@@ -105,12 +105,21 @@ static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul) {struct sandbox_i2c_pmic_plat_data *plat =dev_get_platdata (emul);struct udevice *pmic_dev =i2c_emul_get_device (emul); -struct uc_pmic_priv *priv =dev_get_uclass_priv (pmic_dev); -const u8 *reg_defaults;debug ("%s:%d Setting PMIC default registers\n" , __func__, __LINE__); plat->reg_count =pmic_reg_count (pmic_dev); - plat->trans_len = priv->trans_len; + +return 0 ; +} + +static int sandbox_i2c_pmic_probe (struct udevice *emul) +{ +struct sandbox_i2c_pmic_plat_data *plat =dev_get_platdata (emul); +struct udevice *pmic_dev =i2c_emul_get_device (emul); +struct uc_pmic_priv *upriv =dev_get_uclass_priv (pmic_dev); +const u8 *reg_defaults; + + plat->trans_len = upriv->trans_len; plat->buf_size = plat->reg_count * plat->trans_len; plat->reg =calloc (1 , plat->buf_size);
@@ -149,6 +158,7 @@ U_BOOT_DRIVER(sandbox_i2c_pmic_emul) = { .id = UCLASS_I2C_EMUL, .of_match = sandbox_i2c_pmic_ids, .ofdata_to_platdata = sandbox_i2c_pmic_ofdata_to_platdata, + .probe = sandbox_i2c_pmic_probe, .platdata_auto_alloc_size = sizeof(struct sandbox_i2c_pmic_plat_data), .ops = &sandbox_i2c_pmic_emul_ops, };
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 18/21 sandbox: pmic: Correct i2c pmic emulator platdata method
This currently reads the uclass's private data in the ofdata_to_platdata method which is not allowed, since the uclass has not read it from the device tree. This happens in the probe method.
Fix it by adding a probe() method and moving the code there.
---
drivers/power/pmic/i2c_pmic_emul.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 19/21 console: Add a function to read a line of the output / eof
In reply to Simon GlassWhen recording the console output for testing it is useful to be able to read the output a line at a time to check that the output is correct. Also we need to check that we get to the end of the output.
Add a console function to return the next line and another to see how must data is left.
---
common/console.c | 11 +++++++++++ include/console.h | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+)
common/console.c +11 -0
@@ -621,6 +621,17 @@ void console_record_reset_enable(void)console_record_reset (); gd->flags |= GD_FLG_RECORD; } + +int console_record_readline (char *str,int maxlen) +{ +return membuff_readline (&gd->console_out, str, maxlen,' ' ); +} + +int console_record_avail (void ) +{ +return membuff_avail (&gd->console_out); +} +#endif /* test if ctrl-c was pressed */
include/console.h +19 -0
@@ -41,6 +41,25 @@ void console_record_reset(void);*/ void console_record_reset_enable (void ); +/** +* console_record_readline() - Read a line from the console output +* +* This reads the next available line from the console output previously +* recorded. +* +* @str: Place to put string +* @maxlen: Maximum length of @str including nul terminator +* @return length of string returned +*/ +int console_record_readline (char *str,int maxlen); + +/** +* console_record_avail() - Get the number of available bytes in console output +* +* @return available bytes (0 if empty) +*/ +int console_record_avail (void ); +/** * console_announce_r() - print a U-Boot console on non-serial consoles *
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 19/21 console: Add a function to read a line of the output / eof
When recording the console output for testing it is useful to be able to read the output a line at a time to check that the output is correct. Also we need to check that we get to the end of the output.
Add a console function to return the next line and another to see how must data is left.
---
common/console.c | 11 +++++++++++ include/console.h | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+)
Applied to u-boot-dm, thanks!
PATCH 19/21 console: Add a function to read a line of the output / eof
Quoted 7 lines · sjg at google.com
When recording the console output for testing it is useful to be able to read the output a line at a time to check that the output is correct. Also we need to check that we get to the end of the output.
Add a console function to return the next line and another to see how must data is left.
Quoted 9 lines
Signed-off-by Simon Glass <[email protected]>---
common/console.c | 11 +++++++++++ include/console.h | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+)Applied to u-boot-dm, thanks!
With this merged patch U-Boot does not compile:
common/console.c:629:26: error: passing argument 1 of ?membuff_readline? discards ?volatile? qualifier from pointer target type [-Werror=discarded-qualifiers]
629 | return membuff_readline(&gd->console_out, str, maxlen, ' ');
| ^~~~~~~~~~~~~~~~
In file included from include/asm-generic/global_data.h:24,
from ./arch/arm/include/asm/global_data.h:87,
from include/common.h:36,
from common/console.c:7:Best regards
Heinrich
PATCH 19/21 console: Add a function to read a line of the output / eof
Quoted 23 lines · Heinrich Schuchardt
Quoted 7 lines · sjg at google.com
When recording the console output for testing it is useful to be able to read the output a line at a time to check that the output is correct. Also we need to check that we get to the end of the output.
Add a console function to return the next line and another to see how must data is left.
Quoted 9 lines
Signed-off-by Simon Glass <[email protected]>---
common/console.c | 11 +++++++++++ include/console.h | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+)Applied to u-boot-dm, thanks!
With this merged patch U-Boot does not compile:
common/console.c:629:26: error: passing argument 1 of ?membuff_readline? discards ?volatile? qualifier from pointer target type [-Werror=discarded-qualifiers]
Quoted 6 lines
629 | return membuff_readline(&gd->console_out, str, maxlen, ' ');
| ^~~~~~~~~~~~~~~~
In file included from include/asm-generic/global_data.h:24,
from ./arch/arm/include/asm/global_data.h:87,
from include/common.h:36,
from common/console.c:7:... with gcc-9.x I assume. We really do need to extend the CI loops to cover this someway or another, at least for Sandbox like with do with clang. Or maybe even just a newer clang would also catch it? It looks like an "easy" path forward here to test at least is to switch from LLVM-7 to LLVM-10. I'll fire off a travis test now and see what happens.
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/20200212/502db09d/attachment.sig>
PATCH 19/21 console: Add a function to read a line of the output / eof
Quoted 31 lines · Tom Rini
Quoted 23 lines · Heinrich Schuchardt
Quoted 7 lines · sjg at google.com
When recording the console output for testing it is useful to be able to read the output a line at a time to check that the output is correct. Also we need to check that we get to the end of the output.
Add a console function to return the next line and another to see how must data is left.
Quoted 9 lines
Signed-off-by Simon Glass <[email protected]>---
common/console.c | 11 +++++++++++ include/console.h | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+)Applied to u-boot-dm, thanks!
With this merged patch U-Boot does not compile:
common/console.c:629:26: error: passing argument 1 of ?membuff_readline? discards ?volatile? qualifier from pointer target type [-Werror=discarded-qualifiers]Quoted 6 lines
629 | return membuff_readline(&gd->console_out, str, maxlen, ' '); | ^~~~~~~~~~~~~~~~ In file included from include/asm-generic/global_data.h:24, from ./arch/arm/include/asm/global_data.h:87, from include/common.h:36, from common/console.c:7:
Quoted 6 lines
... with gcc-9.x I assume. We really do need to extend the CI loops to cover this someway or another, at least for Sandbox like with do with clang. Or maybe even just a newer clang would also catch it? It looks like an "easy" path forward here to test at least is to switch from LLVM-7 to LLVM-10. I'll fire off a travis test now and see what happens.
I did manage to convince Travis to use LLVM-10 but it doesn't throw out a warning on this code. I'll post the patch all the same as an RFC for now as we'll need it at some point.
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/20200212/9fed0971/attachment.sig>
PATCH 20/21 test: Enable console recording in tests
In reply to Simon GlassAt present we reset the console buffer before each test but do not actually set the recording flag. Without this, the output is not recorded.
Update the code to set the flag before the test and clear it afterwards.
---
test/dm/test-main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
test/dm/test-main.c +2 -2
@@ -97,11 +97,11 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,* Silence the console and rely on console recording to get * our output. */ -console_record_reset (); +console_record_reset_enable ();if (!state->show_test_output) gd->flags |=GD_FLG_SILENT ; test->func (uts); - gd->flags &= ~GD_FLG_SILENT ; + gd->flags &= ~(GD_FLG_SILENT |GD_FLG_RECORD );state_set_skip_delays (false);ut_assertok (dm_test_destroy (uts));
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 20/21 test: Enable console recording in tests
At present we reset the console buffer before each test but do not actually set the recording flag. Without this, the output is not recorded.
Update the code to set the flag before the test and clear it afterwards.
---
test/dm/test-main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 21/21 test: Add a way to check each line of console output
In reply to Simon GlassWhen writing tests to check the output from commands it is useful to be able to check the output line by line using an assertion. Add helper macros to support this and to check that there is no unexpected trailing data.
Also some commands produce a dump using print_buffer(). Add a way to check that the correct number of bytes are dumped (ignoring the actual contents).
---
include/test/test.h | 4 +++ include/test/ut.h | 65 +++++++++++++++++++++++++++++++++++++++++++++ test/ut.c | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+)
include/test/test.h +4 -0
@@ -15,12 +15,16 @@* @start: Store the starting mallinfo when doing leak test * @priv: A pointer to some other info some suites want to track * @of_root: Record of the livetree root node (used for setting up tests) +* @expect_str: Temporary string used to hold expected string value +* @actual_str: Temporary string used to hold actual string value */ struct unit_test_state {int fail_count;struct mallinfo start;void *priv;struct device_node *of_root; +char expect_str[256 ]; +char actual_str[256 ]; };/**
include/test/ut.h +65 -0
77 lines not on this page · raw message
test/ut.c +46 -0
55 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 21/21 test: Add a way to check each line of console output
When writing tests to check the output from commands it is useful to be able to check the output line by line using an assertion. Add helper macros to support this and to check that there is no unexpected trailing data.
Also some commands produce a dump using print_buffer(). Add a way to check that the correct number of bytes are dumped (ignoring the actual contents).
---
include/test/test.h | 4 +++ include/test/ut.h | 65 +++++++++++++++++++++++++++++++++++++++++++++ test/ut.c | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+)
Applied to u-boot-dm, thanks!