From 5ca5ec1e3272f40a7ad26a15e3df3bb18e0b11d8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 11 Oct 2019 16:16:49 -0600 Subject: dm: regmap: Fix mask in regmap_update_bits() This function assumes that the 'val' parameter has no masked bits set. This is not defined by the function prototype though. Fix the function to mask the value and update the documentation. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Reviewed-by: Jean-Jacques Hiblot --- drivers/core/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/core') diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index d1d12eef385..e9e55c9d165 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -462,5 +462,5 @@ int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val) reg &= ~mask; - return regmap_write(map, offset, reg | val); + return regmap_write(map, offset, reg | (val & mask)); } -- cgit v1.3.1 From 97b5f9d1a0dcae66cf7fe5e892f6dc56d14b0c21 Mon Sep 17 00:00:00 2001 From: Kever Yang Date: Tue, 22 Oct 2019 15:39:47 +0800 Subject: dm: core: Update log method for uclass_find_device_by_seq Use log() insted of debug() for uclass_find_device_by_seq function, since this print is very much and we can filter it out with log() interface. Signed-off-by: Kever Yang Reviewed-by: Simon Glass Move #define to top of file as per docs: Signed-off-by: Simon Glass --- drivers/core/uclass.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'drivers/core') diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 36f4d1c289d..c520ef113a2 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -6,6 +6,8 @@ * Pavel Herrmann */ +#define LOG_CATEGORY LOGC_DM + #include #include #include @@ -303,7 +305,7 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, int ret; *devp = NULL; - debug("%s: %d %d\n", __func__, find_req_seq, seq_or_req_seq); + log_debug("%d %d\n", find_req_seq, seq_or_req_seq); if (seq_or_req_seq == -1) return -ENODEV; ret = uclass_get(id, &uc); @@ -311,15 +313,16 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, return ret; uclass_foreach_dev(dev, uc) { - debug(" - %d %d '%s'\n", dev->req_seq, dev->seq, dev->name); + log_debug(" - %d %d '%s'\n", + dev->req_seq, dev->seq, dev->name); if ((find_req_seq ? dev->req_seq : dev->seq) == seq_or_req_seq) { *devp = dev; - debug(" - found\n"); + log_debug(" - found\n"); return 0; } } - debug(" - not found\n"); + log_debug(" - not found\n"); return -ENODEV; } -- cgit v1.3.1 From d60ae4c59df55c08dc96202ff58fed21ab3afb7d Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Tue, 22 Oct 2019 10:05:22 +0200 Subject: fdt: Fix alignment issue when reading 64-bits properties from fdt The FDT specification [0] gives a requirement of aligning properties on 32-bits. Make sure that the compiler is aware of this constraint when accessing 64-bits properties. [0]: https://github.com/devicetree-org/devicetree-specification/blob/master/source/flattened-format.rst Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- common/fdt_support.c | 2 +- drivers/core/ofnode.c | 2 +- include/linux/libfdt_env.h | 1 + lib/fdtdec.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/core') diff --git a/common/fdt_support.c b/common/fdt_support.c index baf7924ff61..68343990395 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1566,7 +1566,7 @@ static int fdt_read_prop(const fdt32_t *prop, int prop_len, int cell_off, uint64_t *val, int cells) { const fdt32_t *prop32 = &prop[cell_off]; - const fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off]; + const unaligned_fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off]; if ((cell_off + cells) > prop_len) return -FDT_ERR_NOSPACE; diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 297f0a0c7cc..8f0eab2ca62 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -57,7 +57,7 @@ int ofnode_read_s32_default(ofnode node, const char *propname, s32 def) int ofnode_read_u64(ofnode node, const char *propname, u64 *outp) { - const fdt64_t *cell; + const unaligned_fdt64_t *cell; int len; assert(ofnode_valid(node)); diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h index e2bf79c7ee8..e49fcd72bd6 100644 --- a/include/linux/libfdt_env.h +++ b/include/linux/libfdt_env.h @@ -16,6 +16,7 @@ typedef __be16 fdt16_t; typedef __be32 fdt32_t; typedef __be64 fdt64_t; +typedef __be64 unaligned_fdt64_t __aligned(4); #define fdt32_to_cpu(x) be32_to_cpu(x) #define cpu_to_fdt32(x) cpu_to_be32(x) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 17736ce6655..125d9dbf263 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -242,7 +242,7 @@ int fdtdec_get_pci_bar32(struct udevice *dev, struct fdt_pci_addr *addr, uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name, uint64_t default_val) { - const uint64_t *cell64; + const unaligned_fdt64_t *cell64; int length; cell64 = fdt_getprop(blob, node, prop_name, &length); -- cgit v1.3.1