mirror of
https://xff.cz/git/u-boot/
synced 2025-10-29 01:23:25 +01:00
Merge branch '2023-08-18-assorted-updates' into next
- Use built-in ffs/fls on ARM, fix a PIE issue in SPL on ARMv8, bcm283x and mediatek updates, whitespace fix in UFS uclass, make CI use "tools-only" defconfig for more tests, add TI TCA9554 GPIO support, cache alignment fix for SCSI, and fix a problem with SYS_MMCSD_RAW_MODE_ARGS_SECTOR in SPL.
This commit is contained in:
@@ -163,10 +163,10 @@ stages:
|
|||||||
. /tmp/venv/bin/activate
|
. /tmp/venv/bin/activate
|
||||||
pip install -r test/py/requirements.txt
|
pip install -r test/py/requirements.txt
|
||||||
pip install -r tools/buildman/requirements.txt
|
pip install -r tools/buildman/requirements.txt
|
||||||
export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl
|
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only
|
||||||
export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
|
export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
|
||||||
export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
|
export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
|
||||||
./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board sandbox_spl
|
./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only
|
||||||
set -ex
|
set -ex
|
||||||
./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test
|
./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test
|
||||||
./tools/buildman/buildman -t
|
./tools/buildman/buildman -t
|
||||||
@@ -215,8 +215,8 @@ stages:
|
|||||||
export PATH=${PATH}:~/.local/bin
|
export PATH=${PATH}:~/.local/bin
|
||||||
echo "[MASTER]" >> .pylintrc
|
echo "[MASTER]" >> .pylintrc
|
||||||
echo "load-plugins=pylint.extensions.docparams" >> .pylintrc
|
echo "load-plugins=pylint.extensions.docparams" >> .pylintrc
|
||||||
export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl
|
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only
|
||||||
./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board sandbox_spl
|
./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only
|
||||||
set -ex
|
set -ex
|
||||||
pylint --version
|
pylint --version
|
||||||
export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
|
export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
|
||||||
|
|||||||
@@ -212,12 +212,12 @@ Run binman, buildman, dtoc, Kconfig and patman testsuites:
|
|||||||
. /tmp/venv/bin/activate;
|
. /tmp/venv/bin/activate;
|
||||||
pip install -r test/py/requirements.txt;
|
pip install -r test/py/requirements.txt;
|
||||||
pip install -r tools/buildman/requirements.txt;
|
pip install -r tools/buildman/requirements.txt;
|
||||||
export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl;
|
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
|
||||||
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
|
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
|
||||||
export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
|
export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
|
||||||
set +e;
|
set +e;
|
||||||
./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w
|
./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w
|
||||||
--board sandbox_spl;
|
--board tools-only;
|
||||||
set -e;
|
set -e;
|
||||||
./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test;
|
./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test;
|
||||||
./tools/buildman/buildman -t;
|
./tools/buildman/buildman -t;
|
||||||
@@ -249,10 +249,10 @@ Run pylint:
|
|||||||
- export PATH=${PATH}:~/.local/bin
|
- export PATH=${PATH}:~/.local/bin
|
||||||
- echo "[MASTER]" >> .pylintrc
|
- echo "[MASTER]" >> .pylintrc
|
||||||
- echo "load-plugins=pylint.extensions.docparams" >> .pylintrc
|
- echo "load-plugins=pylint.extensions.docparams" >> .pylintrc
|
||||||
- export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl
|
- export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only
|
||||||
- set +e
|
- set +e
|
||||||
- ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w
|
- ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w
|
||||||
--board sandbox_spl
|
--board tools-only
|
||||||
- set -e
|
- set -e
|
||||||
- pylint --version
|
- pylint --version
|
||||||
- export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"
|
- export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ reset:
|
|||||||
.globl save_boot_params_ret
|
.globl save_boot_params_ret
|
||||||
save_boot_params_ret:
|
save_boot_params_ret:
|
||||||
|
|
||||||
#if CONFIG_POSITION_INDEPENDENT
|
#if CONFIG_POSITION_INDEPENDENT && !defined(CONFIG_SPL_BUILD)
|
||||||
/* Verify that we're 4K aligned. */
|
/* Verify that we're 4K aligned. */
|
||||||
adr x0, _start
|
adr x0, _start
|
||||||
ands x0, x0, #0xfff
|
ands x0, x0, #0xfff
|
||||||
|
|||||||
@@ -76,12 +76,12 @@
|
|||||||
ð {
|
ð {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
mediatek,gmac-id = <0>;
|
mediatek,gmac-id = <0>;
|
||||||
phy-mode = "sgmii";
|
phy-mode = "2500base-x";
|
||||||
mediatek,switch = "mt7531";
|
mediatek,switch = "mt7531";
|
||||||
reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
|
reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
|
||||||
|
|
||||||
fixed-link {
|
fixed-link {
|
||||||
speed = <1000>;
|
speed = <2500>;
|
||||||
full-duplex;
|
full-duplex;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <dt-bindings/clock/mt7988-clk.h>
|
#include <dt-bindings/clock/mt7988-clk.h>
|
||||||
#include <dt-bindings/reset/mt7988-reset.h>
|
#include <dt-bindings/reset/mt7988-reset.h>
|
||||||
#include <dt-bindings/gpio/gpio.h>
|
#include <dt-bindings/gpio/gpio.h>
|
||||||
|
#include <dt-bindings/phy/phy.h>
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
compatible = "mediatek,mt7988-rfb";
|
compatible = "mediatek,mt7988-rfb";
|
||||||
@@ -161,6 +162,65 @@
|
|||||||
#clock-cells = <1>;
|
#clock-cells = <1>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dummy_clk: dummy12m {
|
||||||
|
compatible = "fixed-clock";
|
||||||
|
clock-frequency = <12000000>;
|
||||||
|
#clock-cells = <0>;
|
||||||
|
/* must need this line, or uart uanable to get dummy_clk */
|
||||||
|
bootph-all;
|
||||||
|
};
|
||||||
|
|
||||||
|
xhci1: xhci@11200000 {
|
||||||
|
compatible = "mediatek,mt7988-xhci",
|
||||||
|
"mediatek,mtk-xhci";
|
||||||
|
reg = <0 0x11200000 0 0x2e00>,
|
||||||
|
<0 0x11203e00 0 0x0100>;
|
||||||
|
reg-names = "mac", "ippc";
|
||||||
|
interrupts = <GIC_SPI 172 IRQ_TYPE_LEVEL_HIGH>;
|
||||||
|
phys = <&tphyu2port0 PHY_TYPE_USB2>,
|
||||||
|
<&tphyu3port0 PHY_TYPE_USB3>;
|
||||||
|
clocks = <&dummy_clk>,
|
||||||
|
<&dummy_clk>,
|
||||||
|
<&dummy_clk>,
|
||||||
|
<&dummy_clk>,
|
||||||
|
<&dummy_clk>;
|
||||||
|
clock-names = "sys_ck",
|
||||||
|
"xhci_ck",
|
||||||
|
"ref_ck",
|
||||||
|
"mcu_ck",
|
||||||
|
"dma_ck";
|
||||||
|
#address-cells = <2>;
|
||||||
|
#size-cells = <2>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
usbtphy: usb-phy@11c50000 {
|
||||||
|
compatible = "mediatek,mt7988",
|
||||||
|
"mediatek,generic-tphy-v2";
|
||||||
|
#address-cells = <2>;
|
||||||
|
#size-cells = <2>;
|
||||||
|
ranges;
|
||||||
|
status = "okay";
|
||||||
|
|
||||||
|
tphyu2port0: usb-phy@11c50000 {
|
||||||
|
reg = <0 0x11c50000 0 0x700>;
|
||||||
|
clocks = <&dummy_clk>;
|
||||||
|
clock-names = "ref";
|
||||||
|
#phy-cells = <1>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
tphyu3port0: usb-phy@11c50700 {
|
||||||
|
reg = <0 0x11c50700 0 0x900>;
|
||||||
|
clocks = <&dummy_clk>;
|
||||||
|
clock-names = "ref";
|
||||||
|
#phy-cells = <1>;
|
||||||
|
mediatek,usb3-pll-ssc-delta;
|
||||||
|
mediatek,usb3-pll-ssc-delta1;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
xfi_pextp0: syscon@11f20000 {
|
xfi_pextp0: syscon@11f20000 {
|
||||||
compatible = "mediatek,mt7988-xfi_pextp_0", "syscon";
|
compatible = "mediatek,mt7988-xfi_pextp_0", "syscon";
|
||||||
reg = <0 0x11f20000 0 0x10000>;
|
reg = <0 0x11f20000 0 0x10000>;
|
||||||
|
|||||||
@@ -15,9 +15,34 @@
|
|||||||
#ifndef __ASM_ARM_BITOPS_H
|
#ifndef __ASM_ARM_BITOPS_H
|
||||||
#define __ASM_ARM_BITOPS_H
|
#define __ASM_ARM_BITOPS_H
|
||||||
|
|
||||||
|
#if __LINUX_ARM_ARCH__ < 5
|
||||||
|
|
||||||
#include <asm-generic/bitops/__ffs.h>
|
#include <asm-generic/bitops/__ffs.h>
|
||||||
#include <asm-generic/bitops/__fls.h>
|
#include <asm-generic/bitops/__fls.h>
|
||||||
#include <asm-generic/bitops/fls.h>
|
#include <asm-generic/bitops/fls.h>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define PLATFORM_FFS
|
||||||
|
#define PLATFORM_FLS
|
||||||
|
|
||||||
|
#if !IS_ENABLED(CONFIG_HAS_THUMB2) && CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
|
||||||
|
|
||||||
|
unsigned long __fls(unsigned long word);
|
||||||
|
unsigned long __ffs(unsigned long word);
|
||||||
|
int fls(unsigned int x);
|
||||||
|
int ffs(int x);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <asm-generic/bitops/builtin-__fls.h>
|
||||||
|
#include <asm-generic/bitops/builtin-__ffs.h>
|
||||||
|
#include <asm-generic/bitops/builtin-fls.h>
|
||||||
|
#include <asm-generic/bitops/builtin-ffs.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <asm-generic/bitops/fls64.h>
|
#include <asm-generic/bitops/fls64.h>
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
@@ -113,7 +138,7 @@ static inline int test_bit(int nr, const void * addr)
|
|||||||
|
|
||||||
static inline int __ilog2(unsigned int x)
|
static inline int __ilog2(unsigned int x)
|
||||||
{
|
{
|
||||||
return generic_fls(x) - 1;
|
return fls(x) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ffz(x) __ffs(~(x))
|
#define ffz(x) __ffs(~(x))
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ AFLAGS_REMOVE_memset.o := -mthumb -mthumb-interwork
|
|||||||
AFLAGS_REMOVE_memcpy.o := -mthumb -mthumb-interwork
|
AFLAGS_REMOVE_memcpy.o := -mthumb -mthumb-interwork
|
||||||
AFLAGS_memset.o := -DMEMSET_NO_THUMB_BUILD
|
AFLAGS_memset.o := -DMEMSET_NO_THUMB_BUILD
|
||||||
AFLAGS_memcpy.o := -DMEMCPY_NO_THUMB_BUILD
|
AFLAGS_memcpy.o := -DMEMCPY_NO_THUMB_BUILD
|
||||||
|
|
||||||
|
# This is only necessary to force ARM mode on THUMB1 targets.
|
||||||
|
ifneq ($(CONFIG_SYS_ARM_ARCH),4)
|
||||||
|
obj-y += bitops.o
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
45
arch/arm/lib/bitops.S
Normal file
45
arch/arm/lib/bitops.S
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Sean Anderson <sean.anderson@seco.com>
|
||||||
|
*
|
||||||
|
* ARM bitops to call when using THUMB1, which doesn't have these instructions.
|
||||||
|
*/
|
||||||
|
#include <linux/linkage.h>
|
||||||
|
#include <asm/assembler.h>
|
||||||
|
|
||||||
|
.pushsection .text.__fls
|
||||||
|
ENTRY(__fls)
|
||||||
|
clz r0, r0
|
||||||
|
rsb r0, r0, #31
|
||||||
|
ret lr
|
||||||
|
ENDPROC(__fls)
|
||||||
|
.popsection
|
||||||
|
|
||||||
|
.pushsection .text.__ffs
|
||||||
|
ENTRY(__ffs)
|
||||||
|
rsb r3, r0, #0
|
||||||
|
and r0, r0, r3
|
||||||
|
clz r0, r0
|
||||||
|
rsb r0, r0, #31
|
||||||
|
ret lr
|
||||||
|
ENDPROC(__ffs)
|
||||||
|
.popsection
|
||||||
|
|
||||||
|
.pushsection .text.fls
|
||||||
|
ENTRY(fls)
|
||||||
|
cmp r0, #0
|
||||||
|
clzne r0, r0
|
||||||
|
rsbne r0, r0, #32
|
||||||
|
ret lr
|
||||||
|
ENDPROC(fls)
|
||||||
|
.popsection
|
||||||
|
|
||||||
|
.pushsection .text.ffs
|
||||||
|
ENTRY(ffs)
|
||||||
|
rsb r3, r0, #0
|
||||||
|
and r0, r0, r3
|
||||||
|
clz r0, r0
|
||||||
|
rsb r0, r0, #32
|
||||||
|
ret lr
|
||||||
|
ENDPROC(ffs)
|
||||||
|
.popsection
|
||||||
@@ -146,6 +146,14 @@ int mach_cpu_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_DISPLAY_CPUINFO)
|
||||||
|
int print_cpuinfo(void)
|
||||||
|
{
|
||||||
|
printf("CPU: BCM283x\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ARMV7_LPAE
|
#ifdef CONFIG_ARMV7_LPAE
|
||||||
#ifdef CONFIG_TARGET_RPI_4_32B
|
#ifdef CONFIG_TARGET_RPI_4_32B
|
||||||
#define BCM2711_RPI4_PCIE_XHCI_MMIO_VIRT 0xffc00000UL
|
#define BCM2711_RPI4_PCIE_XHCI_MMIO_VIRT 0xffc00000UL
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#if CONFIG_VAL(SYS_MMCSD_RAW_MODE_ARGS_SECTOR)
|
#if defined(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
|
|
||||||
count = blk_dread(mmc_get_blk_desc(mmc),
|
count = blk_dread(mmc_get_blk_desc(mmc),
|
||||||
|
|||||||
@@ -407,6 +407,7 @@ static const struct udevice_id pca953x_ids[] = {
|
|||||||
{ .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), },
|
{ .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), },
|
||||||
{ .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), },
|
{ .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), },
|
||||||
{ .compatible = "ti,tca9539", .data = OF_953X(16, PCA_INT), },
|
{ .compatible = "ti,tca9539", .data = OF_953X(16, PCA_INT), },
|
||||||
|
{ .compatible = "ti,tca9554", .data = OF_953X(8, PCA_INT), },
|
||||||
|
|
||||||
{ .compatible = "onsemi,pca9654", .data = OF_953X(8, PCA_INT), },
|
{ .compatible = "onsemi,pca9654", .data = OF_953X(8, PCA_INT), },
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <env.h>
|
#include <env.h>
|
||||||
#include <libata.h>
|
#include <libata.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
|
#include <memalign.h>
|
||||||
#include <part.h>
|
#include <part.h>
|
||||||
#include <pci.h>
|
#include <pci.h>
|
||||||
#include <scsi.h>
|
#include <scsi.h>
|
||||||
@@ -42,7 +43,7 @@ const struct pci_device_id scsi_device_list[] = { SCSI_DEV_LIST };
|
|||||||
#endif
|
#endif
|
||||||
static struct scsi_cmd tempccb; /* temporary scsi command buffer */
|
static struct scsi_cmd tempccb; /* temporary scsi command buffer */
|
||||||
|
|
||||||
static unsigned char tempbuff[512]; /* temporary data buffer */
|
DEFINE_CACHE_ALIGN_BUFFER(u8, tempbuff, 512); /* temporary data buffer */
|
||||||
|
|
||||||
#if !defined(CONFIG_DM_SCSI)
|
#if !defined(CONFIG_DM_SCSI)
|
||||||
static int scsi_max_devs; /* number of highest available scsi device */
|
static int scsi_max_devs; /* number of highest available scsi device */
|
||||||
@@ -490,7 +491,7 @@ static int scsi_detect_dev(struct udevice *dev, int target, int lun,
|
|||||||
|
|
||||||
pccb->target = target;
|
pccb->target = target;
|
||||||
pccb->lun = lun;
|
pccb->lun = lun;
|
||||||
pccb->pdata = (unsigned char *)&tempbuff;
|
pccb->pdata = tempbuff;
|
||||||
pccb->datalen = 512;
|
pccb->datalen = 512;
|
||||||
pccb->dma_dir = DMA_FROM_DEVICE;
|
pccb->dma_dir = DMA_FROM_DEVICE;
|
||||||
scsi_setup_inquiry(pccb);
|
scsi_setup_inquiry(pccb);
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ static const struct udevice_id cdns_ufs_pltfm_ids[] = {
|
|||||||
|
|
||||||
U_BOOT_DRIVER(cdns_ufs_pltfm) = {
|
U_BOOT_DRIVER(cdns_ufs_pltfm) = {
|
||||||
.name = "cdns-ufs-pltfm",
|
.name = "cdns-ufs-pltfm",
|
||||||
.id = UCLASS_UFS,
|
.id = UCLASS_UFS,
|
||||||
.of_match = cdns_ufs_pltfm_ids,
|
.of_match = cdns_ufs_pltfm_ids,
|
||||||
.probe = cdns_ufs_pltfm_probe,
|
.probe = cdns_ufs_pltfm_probe,
|
||||||
.bind = cdns_ufs_pltfm_bind,
|
.bind = cdns_ufs_pltfm_bind,
|
||||||
|
|||||||
16
include/asm-generic/bitops/builtin-__ffs.h
Normal file
16
include/asm-generic/bitops/builtin-__ffs.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#ifndef _ASM_GENERIC_BITOPS_BUILTIN___FFS_H_
|
||||||
|
#define _ASM_GENERIC_BITOPS_BUILTIN___FFS_H_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __ffs - find first bit in word.
|
||||||
|
* @word: The word to search
|
||||||
|
*
|
||||||
|
* Undefined if no bit exists, so code should check against 0 first.
|
||||||
|
*/
|
||||||
|
static __always_inline unsigned long __ffs(unsigned long word)
|
||||||
|
{
|
||||||
|
return __builtin_ctzl(word);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
16
include/asm-generic/bitops/builtin-__fls.h
Normal file
16
include/asm-generic/bitops/builtin-__fls.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#ifndef _ASM_GENERIC_BITOPS_BUILTIN___FLS_H_
|
||||||
|
#define _ASM_GENERIC_BITOPS_BUILTIN___FLS_H_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __fls - find last (most-significant) set bit in a long word
|
||||||
|
* @word: the word to search
|
||||||
|
*
|
||||||
|
* Undefined if no set bit exists, so code should check against 0 first.
|
||||||
|
*/
|
||||||
|
static __always_inline unsigned long __fls(unsigned long word)
|
||||||
|
{
|
||||||
|
return (sizeof(word) * 8) - 1 - __builtin_clzl(word);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
15
include/asm-generic/bitops/builtin-ffs.h
Normal file
15
include/asm-generic/bitops/builtin-ffs.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#ifndef _ASM_GENERIC_BITOPS_BUILTIN_FFS_H_
|
||||||
|
#define _ASM_GENERIC_BITOPS_BUILTIN_FFS_H_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ffs - find first bit set
|
||||||
|
* @x: the word to search
|
||||||
|
*
|
||||||
|
* This is defined the same way as
|
||||||
|
* the libc and compiler builtin ffs routines, therefore
|
||||||
|
* differs in spirit from ffz (man ffs).
|
||||||
|
*/
|
||||||
|
#define ffs(x) __builtin_ffs(x)
|
||||||
|
|
||||||
|
#endif
|
||||||
17
include/asm-generic/bitops/builtin-fls.h
Normal file
17
include/asm-generic/bitops/builtin-fls.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#ifndef _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_
|
||||||
|
#define _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fls - find last (most-significant) bit set
|
||||||
|
* @x: the word to search
|
||||||
|
*
|
||||||
|
* This is defined the same way as ffs.
|
||||||
|
* Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
|
||||||
|
*/
|
||||||
|
static __always_inline int fls(unsigned int x)
|
||||||
|
{
|
||||||
|
return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user