diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Makefile | 14 | ||||
| -rw-r--r-- | lib/fdtdec.c | 1 | ||||
| -rw-r--r-- | lib/string.c | 59 | 
3 files changed, 64 insertions, 10 deletions
| diff --git a/lib/Makefile b/lib/Makefile index 5d586098d..a94830f51 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -26,7 +26,6 @@ include $(TOPDIR)/config.mk  LIB	= $(obj)libgeneric.o  ifndef CONFIG_SPL_BUILD -COBJS-$(CONFIG_ADDR_MAP) += addr_map.o  COBJS-$(CONFIG_AES) += aes.o  COBJS-$(CONFIG_BZIP2) += bzlib.o  COBJS-$(CONFIG_BZIP2) += bzlib_crctable.o @@ -36,13 +35,10 @@ COBJS-$(CONFIG_BZIP2) += bzlib_huffman.o  COBJS-$(CONFIG_USB_TTY) += circbuf.o  COBJS-y += crc7.o  COBJS-y += crc16.o -COBJS-y += display_options.o -COBJS-y += errno.o  COBJS-$(CONFIG_OF_CONTROL) += fdtdec.o  COBJS-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o  COBJS-$(CONFIG_GZIP) += gunzip.o  COBJS-$(CONFIG_GZIP_COMPRESSED) += gzip.o -COBJS-y += hashtable.o  COBJS-y += initcall.o  COBJS-$(CONFIG_LMB) += lmb.o  COBJS-y += ldiv.o @@ -60,14 +56,12 @@ endif  ifdef CONFIG_SPL_BUILD  COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o -COBJS-$(CONFIG_SPL_NET_SUPPORT) += crc32.o -ifneq ($(CONFIG_SPL_SPI_FLASH_SUPPORT)$(CONFIG_SPL_NET_SUPPORT),) -COBJS-y += display_options.o -endif -COBJS-$(CONFIG_SPL_NET_SUPPORT) += errno.o -COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o  COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o  endif +COBJS-$(CONFIG_ADDR_MAP) += addr_map.o +COBJS-y += hashtable.o +COBJS-y += errno.o +COBJS-y += display_options.o  COBJS-$(CONFIG_BCH) += bch.o  COBJS-y += crc32.o  COBJS-y += ctype.o diff --git a/lib/fdtdec.c b/lib/fdtdec.c index e3142cbdf..ad25a0c9c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -67,6 +67,7 @@ static const char * const compat_names[COMPAT_COUNT] = {  	COMPAT(GENERIC_SPI_FLASH, "spi-flash"),  	COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),  	COMPAT(INFINEON_SLB9635_TPM, "infineon,slb9635-tpm"), +	COMPAT(INFINEON_SLB9645_TPM, "infineon,slb9645-tpm"),  };  const char *fdtdec_get_compatible(enum fdt_compat_id id) diff --git a/lib/string.c b/lib/string.c index 09dfae03c..3a82efab6 100644 --- a/lib/string.c +++ b/lib/string.c @@ -617,3 +617,62 @@ void *memchr(const void *s, int c, size_t n)  }  #endif +#ifndef __HAVE_ARCH_MEMCHR_INV +static void *check_bytes8(const u8 *start, u8 value, unsigned int bytes) +{ +	while (bytes) { +		if (*start != value) +			return (void *)start; +		start++; +		bytes--; +	} +	return NULL; +} +/** + * memchr_inv - Find an unmatching character in an area of memory. + * @start: The memory area + * @c: Find a character other than c + * @bytes: The size of the area. + * + * returns the address of the first character other than @c, or %NULL + * if the whole buffer contains just @c. + */ +void *memchr_inv(const void *start, int c, size_t bytes) +{ +	u8 value = c; +	u64 value64; +	unsigned int words, prefix; + +	if (bytes <= 16) +		return check_bytes8(start, value, bytes); + +	value64 = value; +	value64 |= value64 << 8; +	value64 |= value64 << 16; +	value64 |= value64 << 32; + +	prefix = (unsigned long)start % 8; +	if (prefix) { +		u8 *r; + +		prefix = 8 - prefix; +		r = check_bytes8(start, value, prefix); +		if (r) +			return r; +		start += prefix; +		bytes -= prefix; +	} + +	words = bytes / 8; + +	while (words) { +		if (*(u64 *)start != value64) +			return check_bytes8(start, value, 8); +		start += 8; +		words--; +	} + +	return check_bytes8(start, value, bytes % 8); +} +#endif + |