Merge Official Source
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
commit
9511eba447
@ -1,50 +0,0 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
#
|
|
||||||
# Copyright (C) 2022-2023 Enéas Ulir de Queiroz
|
|
||||||
|
|
||||||
ENGINES_DIR=engines-3
|
|
||||||
|
|
||||||
define Package/openssl/engine/Default
|
|
||||||
SECTION:=libs
|
|
||||||
CATEGORY:=Libraries
|
|
||||||
SUBMENU:=SSL
|
|
||||||
DEPENDS:=libopenssl @OPENSSL_ENGINE +libopenssl-conf
|
|
||||||
endef
|
|
||||||
|
|
||||||
# 1 = engine name
|
|
||||||
# 2 - package name, defaults to libopenssl-$(1)
|
|
||||||
define Package/openssl/add-engine
|
|
||||||
OSSL_ENG_PKG:=$(if $(2),$(2),libopenssl-$(1))
|
|
||||||
Package/$$(OSSL_ENG_PKG)/conffiles:=/etc/ssl/engines.cnf.d/$(1).cnf
|
|
||||||
|
|
||||||
define Package/$$(OSSL_ENG_PKG)/install
|
|
||||||
$$(INSTALL_DIR) $$(1)/usr/lib/$(ENGINES_DIR)
|
|
||||||
$$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/$(1).so \
|
|
||||||
$$(1)/usr/lib/$(ENGINES_DIR)
|
|
||||||
$$(INSTALL_DIR) $$(1)/etc/ssl/engines.cnf.d
|
|
||||||
$$(INSTALL_DATA) ./files/$(1).cnf $$(1)/etc/ssl/engines.cnf.d/
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/$$(OSSL_ENG_PKG)/postinst :=
|
|
||||||
#!/bin/sh
|
|
||||||
OPENSSL_UCI="$$$${IPKG_INSTROOT}/etc/config/openssl"
|
|
||||||
|
|
||||||
[ -z "$$$${IPKG_INSTROOT}" ] && uci -q get openssl.$(1) >/dev/null && exit 0
|
|
||||||
|
|
||||||
cat << EOF >> "$$$${OPENSSL_UCI}"
|
|
||||||
|
|
||||||
config engine '$(1)'
|
|
||||||
option enabled '1'
|
|
||||||
EOF
|
|
||||||
|
|
||||||
[ -n "$$$${IPKG_INSTROOT}" ] || /etc/init.d/openssl reload
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/$$(OSSL_ENG_PKG)/postrm :=
|
|
||||||
#!/bin/sh
|
|
||||||
[ -n "$$$${IPKG_INSTROOT}" ] && exit 0
|
|
||||||
uci delete openssl.$(1)
|
|
||||||
uci commit openssl
|
|
||||||
/etc/init.d/openssl reload
|
|
||||||
endef
|
|
||||||
endef
|
|
||||||
79
include/openssl-module.mk
Normal file
79
include/openssl-module.mk
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022-2023 Enéas Ulir de Queiroz
|
||||||
|
|
||||||
|
ENGINES_DIR=engines-3
|
||||||
|
|
||||||
|
define Package/openssl/module/Default
|
||||||
|
SECTION:=libs
|
||||||
|
CATEGORY:=Libraries
|
||||||
|
SUBMENU:=SSL
|
||||||
|
DEPENDS:=libopenssl +libopenssl-conf
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/openssl/engine/Default
|
||||||
|
$(Package/openssl/module/Default)
|
||||||
|
DEPENDS+=@OPENSSL_ENGINE
|
||||||
|
endef
|
||||||
|
|
||||||
|
|
||||||
|
# 1 = moudule type (engine|provider)
|
||||||
|
# 2 = module name
|
||||||
|
# 3 = directory to save .so file
|
||||||
|
# 4 = [ package name, defaults to libopenssl-$(2) ]
|
||||||
|
define Package/openssl/add-module
|
||||||
|
$(eval MOD_TYPE:=$(1))
|
||||||
|
$(eval MOD_NAME:=$(2))
|
||||||
|
$(eval MOD_DIR:=$(3))
|
||||||
|
$(eval OSSL_PKG:=$(if $(4),$(4),libopenssl-$(MOD_NAME)))
|
||||||
|
$(info Package/openssl/add-module 1='$(1)'; 2='$(2)'; 3='$(3)' 4='$(4)')
|
||||||
|
$(info MOD_TYPE='$(MOD_TYPE)'; MOD_NAME='$(MOD_NAME)'; MOD_DIR='$(MOD_DIR)' OSSL_PKG='$(OSSL_PKG)')
|
||||||
|
Package/$(OSSL_PKG)/conffiles:=/etc/ssl/modules.cnf.d/$(MOD_NAME).cnf
|
||||||
|
|
||||||
|
define Package/$(OSSL_PKG)/install
|
||||||
|
$$(INSTALL_DIR) $$(1)/$(MOD_DIR)
|
||||||
|
$$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/$(MOD_DIR)/$(MOD_NAME).so \
|
||||||
|
$$(1)/$(MOD_DIR)
|
||||||
|
$$(INSTALL_DIR) $$(1)/etc/ssl/modules.cnf.d
|
||||||
|
$$(INSTALL_DATA) ./files/$(MOD_NAME).cnf $$(1)/etc/ssl/modules.cnf.d/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(OSSL_PKG)/postinst
|
||||||
|
#!/bin/sh
|
||||||
|
OPENSSL_UCI="$$$${IPKG_INSTROOT}/etc/config/openssl"
|
||||||
|
|
||||||
|
[ -z "$$$${IPKG_INSTROOT}" ] \
|
||||||
|
&& uci -q get openssl.$(MOD_NAME) >/dev/null \
|
||||||
|
&& exit 0
|
||||||
|
|
||||||
|
cat << EOF >> "$$$${OPENSSL_UCI}"
|
||||||
|
|
||||||
|
config $(MOD_TYPE) '$(MOD_NAME)'
|
||||||
|
option enabled '1'
|
||||||
|
EOF
|
||||||
|
|
||||||
|
[ -n "$$$${IPKG_INSTROOT}" ] || /etc/init.d/openssl reload
|
||||||
|
exit 0
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(OSSL_PKG)/postrm
|
||||||
|
#!/bin/sh
|
||||||
|
[ -n "$$$${IPKG_INSTROOT}" ] && exit 0
|
||||||
|
uci -q delete openssl.$(MOD_NAME) && uci commit openssl
|
||||||
|
/etc/init.d/openssl reload
|
||||||
|
exit 0
|
||||||
|
endef
|
||||||
|
endef
|
||||||
|
|
||||||
|
# 1 = engine name
|
||||||
|
# 2 - package name, defaults to libopenssl-$(1)
|
||||||
|
define Package/openssl/add-engine
|
||||||
|
$(call Package/openssl/add-module,engine,$(1),/usr/lib/$(ENGINES_DIR),$(2))
|
||||||
|
endef
|
||||||
|
|
||||||
|
# 1 = provider name
|
||||||
|
# 2 = [ package name, defaults to libopenssl-$(1) ]
|
||||||
|
define Package/openssl/add-provider
|
||||||
|
$(call Package/openssl/add-module,provider,$(1),/usr/lib/ossl-modules,$(2))
|
||||||
|
endef
|
||||||
|
|
||||||
@ -43,13 +43,15 @@ define Package/autocore/install/Default
|
|||||||
|
|
||||||
$(INSTALL_DIR) $(1)/sbin
|
$(INSTALL_DIR) $(1)/sbin
|
||||||
$(INSTALL_BIN) ./files/generic/cpuinfo $(1)/sbin/
|
$(INSTALL_BIN) ./files/generic/cpuinfo $(1)/sbin/
|
||||||
$(INSTALL_BIN) ./files/generic/ethinfo $(1)/sbin/
|
|
||||||
|
|
||||||
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
|
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
|
||||||
$(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/
|
$(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/
|
||||||
|
|
||||||
|
ifeq ($(filter ipq806x%, $(TARGETID)),)
|
||||||
|
$(INSTALL_BIN) ./files/generic/ethinfo $(1)/sbin/
|
||||||
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
|
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
|
||||||
$(INSTALL_DATA) ./files/generic/29_ethinfo.js $(1)/www/luci-static/resources/view/status/include/
|
$(INSTALL_DATA) ./files/generic/29_ethinfo.js $(1)/www/luci-static/resources/view/status/include/
|
||||||
|
endif
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/autocore-arm/install
|
define Package/autocore-arm/install
|
||||||
|
|||||||
@ -12,6 +12,20 @@ config OPENSSL_OPTIMIZE_SPEED
|
|||||||
The increase in performance and size depends on the
|
The increase in performance and size depends on the
|
||||||
target CPU. EC and AES seem to benefit the most.
|
target CPU. EC and AES seem to benefit the most.
|
||||||
|
|
||||||
|
config OPENSSL_SMALL_FOOTPRINT
|
||||||
|
bool
|
||||||
|
depends on !OPENSSL_OPTIMIZE_SPEED
|
||||||
|
default y if SMALL_FLASH || LOW_MEMORY_FOOTPRINT
|
||||||
|
prompt "Build with OPENSSL_SMALL_FOOTPRINT (read help)"
|
||||||
|
help
|
||||||
|
This turns on -DOPENSSL_SMALL_FOOTPRINT. This will save only
|
||||||
|
1-3% of of the ipk size. The performance drop depends on
|
||||||
|
architecture and algorithm. MIPS drops 13% of performance for
|
||||||
|
a 3% decrease in ipk size. On Aarch64, for a 1% reduction in
|
||||||
|
size, ghash and GCM performance decreases 90%, while
|
||||||
|
Chacha20-Poly1305 is 15% slower. X86_64 drops 1% of its size
|
||||||
|
for 3% of performance. Other arches have not been tested.
|
||||||
|
|
||||||
config OPENSSL_WITH_ASM
|
config OPENSSL_WITH_ASM
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
@ -46,7 +60,7 @@ config OPENSSL_NO_DEPRECATED
|
|||||||
|
|
||||||
config OPENSSL_WITH_ERROR_MESSAGES
|
config OPENSSL_WITH_ERROR_MESSAGES
|
||||||
bool
|
bool
|
||||||
default y if !SMALL_FLASH && !LOW_MEMORY_FOOTPRINT
|
default y if !OPENSSL_SMALL_FOOTPRINT || (!SMALL_FLASH && !LOW_MEMORY_FOOTPRINT)
|
||||||
prompt "Include error messages"
|
prompt "Include error messages"
|
||||||
help
|
help
|
||||||
This option aids debugging, but increases package size and
|
This option aids debugging, but increases package size and
|
||||||
@ -153,16 +167,24 @@ config OPENSSL_WITH_CAMELLIA
|
|||||||
|
|
||||||
config OPENSSL_WITH_IDEA
|
config OPENSSL_WITH_IDEA
|
||||||
bool
|
bool
|
||||||
prompt "Enable IDEA cipher support"
|
default y if !SMALL_FLASH
|
||||||
|
prompt "Enable IDEA cipher support (needs legacy provider)"
|
||||||
help
|
help
|
||||||
IDEA is a block cipher with 128-bit keys.
|
IDEA is a block cipher with 128-bit keys.
|
||||||
|
To use the cipher, one must install the libopenssl-legacy
|
||||||
|
package, using a main libopenssl package compiled with this
|
||||||
|
option enabled as well.
|
||||||
|
|
||||||
config OPENSSL_WITH_SEED
|
config OPENSSL_WITH_SEED
|
||||||
bool
|
bool
|
||||||
prompt "Enable SEED cipher support"
|
default y if !SMALL_FLASH
|
||||||
|
prompt "Enable SEED cipher support (needs legacy provider)"
|
||||||
help
|
help
|
||||||
SEED is a block cipher with 128-bit keys broadly used in
|
SEED is a block cipher with 128-bit keys broadly used in
|
||||||
South Korea, but seldom found elsewhere.
|
South Korea, but seldom found elsewhere.
|
||||||
|
To use the cipher, one must install the libopenssl-legacy
|
||||||
|
package, using a main libopenssl package compiled with this
|
||||||
|
option enabled as well.
|
||||||
|
|
||||||
config OPENSSL_WITH_SM234
|
config OPENSSL_WITH_SM234
|
||||||
bool
|
bool
|
||||||
@ -183,11 +205,21 @@ config OPENSSL_WITH_BLAKE2
|
|||||||
|
|
||||||
config OPENSSL_WITH_MDC2
|
config OPENSSL_WITH_MDC2
|
||||||
bool
|
bool
|
||||||
prompt "Enable MDC2 digest support"
|
default y if !SMALL_FLASH
|
||||||
|
prompt "Enable MDC2 digest support (needs legacy provider)"
|
||||||
|
help
|
||||||
|
To use the digest, one must install the libopenssl-legacy
|
||||||
|
package, using a main libopenssl package compiled with this
|
||||||
|
option enabled as well.
|
||||||
|
|
||||||
config OPENSSL_WITH_WHIRLPOOL
|
config OPENSSL_WITH_WHIRLPOOL
|
||||||
bool
|
bool
|
||||||
prompt "Enable Whirlpool digest support"
|
default y if !SMALL_FLASH
|
||||||
|
prompt "Enable Whirlpool digest support (needs legacy provider)"
|
||||||
|
help
|
||||||
|
To use the digest, one must install the libopenssl-legacy
|
||||||
|
package, using a main libopenssl package compiled with this
|
||||||
|
option enabled as well.
|
||||||
|
|
||||||
config OPENSSL_WITH_COMPRESSION
|
config OPENSSL_WITH_COMPRESSION
|
||||||
bool
|
bool
|
||||||
|
|||||||
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=openssl
|
PKG_NAME:=openssl
|
||||||
PKG_VERSION:=3.0.8
|
PKG_VERSION:=3.0.8
|
||||||
PKG_RELEASE:=4
|
PKG_RELEASE:=7
|
||||||
PKG_BUILD_FLAGS:=no-mips16 gc-sections
|
PKG_BUILD_FLAGS:=no-mips16 gc-sections
|
||||||
|
|
||||||
PKG_BUILD_PARALLEL:=1
|
PKG_BUILD_PARALLEL:=1
|
||||||
@ -41,6 +41,7 @@ PKG_CONFIG_DEPENDS:= \
|
|||||||
CONFIG_OPENSSL_NO_DEPRECATED \
|
CONFIG_OPENSSL_NO_DEPRECATED \
|
||||||
CONFIG_OPENSSL_OPTIMIZE_SPEED \
|
CONFIG_OPENSSL_OPTIMIZE_SPEED \
|
||||||
CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM \
|
CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM \
|
||||||
|
CONFIG_OPENSSL_SMALL_FOOTPRINT \
|
||||||
CONFIG_OPENSSL_WITH_ARIA \
|
CONFIG_OPENSSL_WITH_ARIA \
|
||||||
CONFIG_OPENSSL_WITH_ASM \
|
CONFIG_OPENSSL_WITH_ASM \
|
||||||
CONFIG_OPENSSL_WITH_ASYNC \
|
CONFIG_OPENSSL_WITH_ASYNC \
|
||||||
@ -65,7 +66,7 @@ PKG_CONFIG_DEPENDS:= \
|
|||||||
CONFIG_OPENSSL_WITH_WHIRLPOOL
|
CONFIG_OPENSSL_WITH_WHIRLPOOL
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
include $(INCLUDE_DIR)/openssl-engine.mk
|
include $(INCLUDE_DIR)/openssl-module.mk
|
||||||
|
|
||||||
ifneq ($(CONFIG_CCACHE),)
|
ifneq ($(CONFIG_CCACHE),)
|
||||||
HOSTCC=$(HOSTCC_NOCACHE)
|
HOSTCC=$(HOSTCC_NOCACHE)
|
||||||
@ -130,8 +131,8 @@ endef
|
|||||||
|
|
||||||
define Package/libopenssl-conf/conffiles
|
define Package/libopenssl-conf/conffiles
|
||||||
/etc/ssl/openssl.cnf
|
/etc/ssl/openssl.cnf
|
||||||
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),/etc/ssl/engines.cnf.d/devcrypto.cnf)
|
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),/etc/ssl/modules.cnf.d/devcrypto.cnf)
|
||||||
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),/etc/ssl/engines.cnf.d/padlock.cnf)
|
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),/etc/ssl/modules.cnf.d/padlock.cnf)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/libopenssl-conf/description
|
define Package/libopenssl-conf/description
|
||||||
@ -139,6 +140,44 @@ $(call Package/openssl/Default/description)
|
|||||||
This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
|
This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK)$(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),)
|
||||||
|
define Package/libopenssl-conf/postinst
|
||||||
|
#!/bin/sh
|
||||||
|
OPENSSL_UCI="$${IPKG_INSTROOT}/etc/config/openssl"
|
||||||
|
|
||||||
|
add_engine_config() {
|
||||||
|
if [ -z "$${IPKG_INSTROOT}" ] && uci -q get "openssl.$$1" >/dev/null; then
|
||||||
|
[ "$$(uci -q get "openssl.$$1.builtin")" = 1 ] && return
|
||||||
|
uci set "openssl.$$1.builtin=1" && uci commit openssl
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
{
|
||||||
|
echo "engine '$$1'"
|
||||||
|
echo " option enabled '1'"
|
||||||
|
echo " option builtin '1'"
|
||||||
|
echo
|
||||||
|
} >>"$${OPENSSL_UCI}"
|
||||||
|
}
|
||||||
|
|
||||||
|
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),add_engine_config devcrypto)
|
||||||
|
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),add_engine_config padlock)
|
||||||
|
endef
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(eval $(call Package/openssl/add-provider,legacy))
|
||||||
|
define Package/libopenssl-legacy
|
||||||
|
$(call Package/openssl/Default)
|
||||||
|
$(call Package/openssl/module/Default)
|
||||||
|
TITLE:=OpenSSL legacy provider
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/libopenssl-legacy/description
|
||||||
|
The OpenSSL legacy provider supplies OpenSSL implementations of algorithms that
|
||||||
|
have been deemed legacy. Such algorithms have commonly fallen out of use, have
|
||||||
|
been deemed insecure by the cryptography community, or something similar. See
|
||||||
|
https://www.openssl.org/docs/man3.0/man7/OSSL_PROVIDER-legacy.html
|
||||||
|
endef
|
||||||
|
|
||||||
$(eval $(call Package/openssl/add-engine,afalg))
|
$(eval $(call Package/openssl/add-engine,afalg))
|
||||||
define Package/libopenssl-afalg
|
define Package/libopenssl-afalg
|
||||||
$(call Package/openssl/Default)
|
$(call Package/openssl/Default)
|
||||||
@ -151,7 +190,7 @@ endef
|
|||||||
define Package/libopenssl-afalg/description
|
define Package/libopenssl-afalg/description
|
||||||
This package adds an engine that enables hardware acceleration
|
This package adds an engine that enables hardware acceleration
|
||||||
through the AF_ALG kernel interface.
|
through the AF_ALG kernel interface.
|
||||||
See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
|
See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
|
||||||
and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
|
and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
|
||||||
The engine_id is "afalg"
|
The engine_id is "afalg"
|
||||||
endef
|
endef
|
||||||
@ -167,7 +206,7 @@ endef
|
|||||||
define Package/libopenssl-devcrypto/description
|
define Package/libopenssl-devcrypto/description
|
||||||
This package adds an engine that enables hardware acceleration
|
This package adds an engine that enables hardware acceleration
|
||||||
through the /dev/crypto kernel interface.
|
through the /dev/crypto kernel interface.
|
||||||
See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
|
See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
|
||||||
and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
|
and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
|
||||||
The engine_id is "devcrypto"
|
The engine_id is "devcrypto"
|
||||||
endef
|
endef
|
||||||
@ -183,7 +222,7 @@ endef
|
|||||||
|
|
||||||
define Package/libopenssl-padlock/description
|
define Package/libopenssl-padlock/description
|
||||||
This package adds an engine that enables VIA Padlock hardware acceleration.
|
This package adds an engine that enables VIA Padlock hardware acceleration.
|
||||||
See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
|
See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
|
||||||
and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
|
and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
|
||||||
The engine_id is "padlock"
|
The engine_id is "padlock"
|
||||||
endef
|
endef
|
||||||
@ -260,7 +299,9 @@ endif
|
|||||||
|
|
||||||
ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
|
ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
|
||||||
TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
|
TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
|
||||||
else
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_OPENSSL_SMALL_FOOTPRINT),y)
|
||||||
OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
|
OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -378,16 +419,16 @@ define Package/libopenssl/install
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/libopenssl-conf/install
|
define Package/libopenssl-conf/install
|
||||||
$(INSTALL_DIR) $(1)/etc/ssl/engines.cnf.d $(1)/etc/config $(1)/etc/init.d
|
$(INSTALL_DIR) $(1)/etc/ssl/modules.cnf.d $(1)/etc/config $(1)/etc/init.d
|
||||||
$(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
|
$(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
|
||||||
$(INSTALL_BIN) ./files/openssl.init $(1)/etc/init.d/openssl
|
$(INSTALL_BIN) ./files/openssl.init $(1)/etc/init.d/openssl
|
||||||
$(SED) 's!%ENGINES_DIR%!/usr/lib/$(ENGINES_DIR)!' $(1)/etc/init.d/openssl
|
$(SED) 's!%ENGINES_DIR%!/usr/lib/$(ENGINES_DIR)!' $(1)/etc/init.d/openssl
|
||||||
touch $(1)/etc/config/openssl
|
touch $(1)/etc/config/openssl
|
||||||
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),
|
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),
|
||||||
$(CP) ./files/devcrypto.cnf $(1)/etc/ssl/engines.cnf.d/
|
$(CP) ./files/devcrypto.cnf $(1)/etc/ssl/modules.cnf.d/
|
||||||
echo -e "config engine 'devcrypto'\n\toption enabled '1'" >> $(1)/etc/config/openssl)
|
echo -e "config engine 'devcrypto'\n\toption enabled '1'" >> $(1)/etc/config/openssl)
|
||||||
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),
|
$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),
|
||||||
$(CP) ./files/padlock.cnf $(1)/etc/ssl/engines.cnf.d/
|
$(CP) ./files/padlock.cnf $(1)/etc/ssl/modules.cnf.d/
|
||||||
echo -e "\nconfig engine 'padlock'\n\toption enabled '1'" >> $(1)/etc/config/openssl)
|
echo -e "\nconfig engine 'padlock'\n\toption enabled '1'" >> $(1)/etc/config/openssl)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
@ -400,5 +441,6 @@ $(eval $(call BuildPackage,libopenssl))
|
|||||||
$(eval $(call BuildPackage,libopenssl-conf))
|
$(eval $(call BuildPackage,libopenssl-conf))
|
||||||
$(eval $(call BuildPackage,libopenssl-afalg))
|
$(eval $(call BuildPackage,libopenssl-afalg))
|
||||||
$(eval $(call BuildPackage,libopenssl-devcrypto))
|
$(eval $(call BuildPackage,libopenssl-devcrypto))
|
||||||
|
$(eval $(call BuildPackage,libopenssl-legacy))
|
||||||
$(eval $(call BuildPackage,libopenssl-padlock))
|
$(eval $(call BuildPackage,libopenssl-padlock))
|
||||||
$(eval $(call BuildPackage,openssl-util))
|
$(eval $(call BuildPackage,openssl-util))
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
[afalg]
|
[afalg_sect]
|
||||||
default_algorithms = ALL
|
default_algorithms = ALL
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
[devcrypto]
|
[devcrypto_sect]
|
||||||
# Leave this alone and configure algorithms with CIPERS/DIGESTS below
|
# Leave this alone and configure algorithms with CIPERS/DIGESTS below
|
||||||
default_algorithms = ALL
|
default_algorithms = ALL
|
||||||
|
|
||||||
|
|||||||
3
package/libs/openssl/files/legacy.cnf
Normal file
3
package/libs/openssl/files/legacy.cnf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[legacy_sect]
|
||||||
|
activate = 1
|
||||||
|
|
||||||
@ -1,31 +1,72 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
START=13
|
START=13
|
||||||
ENGINES_CNF_D="/etc/ssl/engines.cnf.d"
|
ENGINES_CNF=/var/etc/ssl/engines.cnf
|
||||||
ENGINES_CNF="/var/etc/ssl/engines.cnf"
|
ENGINES_DIR=%ENGINES_DIR%
|
||||||
ENGINES_DIR="%ENGINES_DIR%"
|
MODULES_DIR=/usr/lib/ossl-modules
|
||||||
|
PROVIDERS_CNF=/var/etc/ssl/providers.cnf
|
||||||
|
|
||||||
config_engine() {
|
#1: cnf file
|
||||||
local enabled force
|
write_cnf_header() {
|
||||||
|
mkdir -p "$(dirname "$1")" && \
|
||||||
|
echo "# This file is automatically generated from /etc/config/openssl." >"$1" || {
|
||||||
|
echo "Error writing to $1."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#1: module name
|
||||||
|
#2: output cnf file
|
||||||
|
#3: module.so
|
||||||
|
enable_module() {
|
||||||
|
local builtin enabled force
|
||||||
|
|
||||||
|
config_get_bool builtin "$1" builtin 0
|
||||||
config_get_bool enabled "$1" enabled 1
|
config_get_bool enabled "$1" enabled 1
|
||||||
config_get_bool force "$1" force 0
|
config_get_bool force "$1" force 0
|
||||||
[ "$enabled" = 0 ] && return
|
|
||||||
if [ "$force" = 0 ] && \
|
if [ "$enabled" = 0 ]; then
|
||||||
[ ! -f "${ENGINES_CNF_D}/$1.cnf" ] && \
|
[ "$builtin" = 0 ] && return 1
|
||||||
[ ! -f "${ENGINES_DIR}/$1.so" ]; then
|
echo "Engine $1 is built into the libcrypto library and can't be disabled through UCI."
|
||||||
echo Skipping engine "$1": not installed
|
echo "If the engine was not built-in, remove 'config builtin' from /etc/config/openssl."
|
||||||
return
|
elif [ "$force" = 1 ]; then
|
||||||
|
printf "[Forced] "
|
||||||
|
elif ! grep -q "\\[ *$1_sect *]" /etc/ssl/modules.cnf.d/*; then
|
||||||
|
echo "$1: Could not find section [$1] in config files."
|
||||||
|
return 1
|
||||||
|
elif [ "$builtin" = 1 ]; then
|
||||||
|
printf "[Builtin] "
|
||||||
|
elif [ ! -f "$3" ];then
|
||||||
|
echo "Skipping $1: $3 not found."
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
echo Enabling engine "$1"
|
echo "Enabling $1"
|
||||||
echo "$1=$1" >> "${ENGINES_CNF}"
|
echo "$1=$1_sect" >>"$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
config_engine() {
|
||||||
|
enable_module "$1" "$ENGINES_CNF" \
|
||||||
|
"${ENGINES_DIR}/${1}.so"
|
||||||
|
}
|
||||||
|
|
||||||
|
config_provider() {
|
||||||
|
enable_module "$1" "$PROVIDERS_CNF" \
|
||||||
|
"${MODULES_DIR}/${1}.so"
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
mkdir -p "$(dirname "${ENGINES_CNF}")" || exit 1
|
local ret=0
|
||||||
echo Generating engines.cnf
|
|
||||||
echo "# This file is automatically generated from /etc/config/openssl." \
|
|
||||||
> "${ENGINES_CNF}" || \
|
|
||||||
{ echo Error writing ${ENGINES_CNF} >&2; exit 1; }
|
|
||||||
config_load openssl
|
config_load openssl
|
||||||
config_foreach config_engine engine
|
|
||||||
|
echo Generating engines.cnf
|
||||||
|
write_cnf_header "${ENGINES_CNF}" && \
|
||||||
|
config_foreach config_engine engine || ret=$?
|
||||||
|
|
||||||
|
echo Generating providers.cnf
|
||||||
|
write_cnf_header "${PROVIDERS_CNF}" && \
|
||||||
|
config_foreach config_provider provider || ret=$?
|
||||||
|
|
||||||
|
return $ret
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
[padlock]
|
[padlock_sect]
|
||||||
default_algorithms = ALL
|
default_algorithms = ALL
|
||||||
|
|
||||||
|
|||||||
@ -10,20 +10,32 @@ Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
|
|||||||
|
|
||||||
--- a/apps/openssl.cnf
|
--- a/apps/openssl.cnf
|
||||||
+++ b/apps/openssl.cnf
|
+++ b/apps/openssl.cnf
|
||||||
@@ -30,6 +30,16 @@ oid_section = new_oids
|
@@ -52,10 +52,13 @@ tsa_policy3 = 1.2.3.4.5.7
|
||||||
# (Alternatively, use a configuration file that has only
|
|
||||||
# X.509v3 extensions in its main [= default] section.)
|
|
||||||
|
|
||||||
+openssl_conf=openssl_conf
|
[openssl_init]
|
||||||
|
providers = provider_sect
|
||||||
|
+engines = engines_sect
|
||||||
|
|
||||||
|
# List of providers to load
|
||||||
|
[provider_sect]
|
||||||
|
default = default_sect
|
||||||
|
+.include /var/etc/ssl/providers.cnf
|
||||||
+
|
+
|
||||||
+[openssl_conf]
|
# The fips section name should match the section name inside the
|
||||||
+engines=engines
|
# included fipsmodule.cnf.
|
||||||
|
# fips = fips_sect
|
||||||
|
@@ -69,7 +72,13 @@ default = default_sect
|
||||||
|
# OpenSSL may not work correctly which could lead to significant system
|
||||||
|
# problems including inability to remotely access the system.
|
||||||
|
[default_sect]
|
||||||
|
-# activate = 1
|
||||||
|
+activate = 1
|
||||||
+
|
+
|
||||||
+[engines]
|
+[engines_sect]
|
||||||
+.include /var/etc/ssl/engines.cnf
|
+.include /var/etc/ssl/engines.cnf
|
||||||
+
|
+
|
||||||
+.include /etc/ssl/engines.cnf.d
|
+.include /etc/ssl/modules.cnf.d
|
||||||
+
|
+
|
||||||
[ new_oids ]
|
|
||||||
# We can add new OIDs in here for use by 'ca', 'req' and 'ts'.
|
|
||||||
# Add a simple OID like this:
|
####################################################################
|
||||||
|
|||||||
@ -12,9 +12,9 @@ PKG_RELEASE:=1
|
|||||||
|
|
||||||
PKG_SOURCE_PROTO:=git
|
PKG_SOURCE_PROTO:=git
|
||||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/odhcpd.git
|
PKG_SOURCE_URL=$(PROJECT_GIT)/project/odhcpd.git
|
||||||
PKG_MIRROR_HASH:=f95c2edfa6756e2a6522cd9d3e0560bfc1cbc2aed9e0c3763c5f6081b153eb49
|
PKG_MIRROR_HASH:=c2851b577d1ee632c902eca1864444fa22cad98956bfa852019e6d621c0f8d2a
|
||||||
PKG_SOURCE_DATE:=2023-03-24
|
PKG_SOURCE_DATE:=2023-04-05
|
||||||
PKG_SOURCE_VERSION:=29c934d7ab98ca0b5da0e3757b885a1d3c19a2f4
|
PKG_SOURCE_VERSION:=40ab806bf4c8698ac925d094ce11ce1d57ae2e46
|
||||||
|
|
||||||
PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
|
PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
|
||||||
PKG_LICENSE:=GPL-2.0
|
PKG_LICENSE:=GPL-2.0
|
||||||
|
|||||||
@ -192,6 +192,7 @@ proto_qmi_setup() {
|
|||||||
|
|
||||||
# Cleanup current state if any
|
# Cleanup current state if any
|
||||||
uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null 2>&1
|
uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null 2>&1
|
||||||
|
uqmi -s -d "$device" --set-ip-family ipv6 --stop-network 0xffffffff --autoconnect > /dev/null 2>&1
|
||||||
|
|
||||||
# Go online
|
# Go online
|
||||||
uqmi -s -d "$device" --set-device-operating-mode online > /dev/null 2>&1
|
uqmi -s -d "$device" --set-device-operating-mode online > /dev/null 2>&1
|
||||||
@ -326,7 +327,7 @@ proto_qmi_setup() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check data connection state
|
# Check data connection state
|
||||||
connstat=$(uqmi -s -d "$device" --set-client-id wds,"$cid_6" --get-data-status)
|
connstat=$(uqmi -s -d "$device" --set-client-id wds,"$cid_6" --set-ip-family ipv6 --get-data-status)
|
||||||
[ "$connstat" == '"connected"' ] || {
|
[ "$connstat" == '"connected"' ] || {
|
||||||
echo "No data link!"
|
echo "No data link!"
|
||||||
uqmi -s -d "$device" --set-client-id wds,"$cid_6" --release-client-id wds > /dev/null 2>&1
|
uqmi -s -d "$device" --set-client-id wds,"$cid_6" --release-client-id wds > /dev/null 2>&1
|
||||||
|
|||||||
@ -106,7 +106,7 @@ configfs: New of_overlay API
|
|||||||
+++ b/drivers/of/Makefile
|
+++ b/drivers/of/Makefile
|
||||||
@@ -1,6 +1,7 @@
|
@@ -1,6 +1,7 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
obj-y = base.o device.o platform.o property.o
|
obj-y = base.o device.o module.o platform.o property.o
|
||||||
obj-$(CONFIG_OF_KOBJ) += kobj.o
|
obj-$(CONFIG_OF_KOBJ) += kobj.o
|
||||||
+obj-$(CONFIG_OF_CONFIGFS) += configfs.o
|
+obj-$(CONFIG_OF_CONFIGFS) += configfs.o
|
||||||
obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
|
obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
|
||||||
|
|||||||
@ -0,0 +1,70 @@
|
|||||||
|
From b19a4266c52de78496fe40f0b37580a3b762e67d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:09 +0100
|
||||||
|
Subject: [PATCH] of: Fix modalias string generation
|
||||||
|
|
||||||
|
The helper generating an OF based modalias (of_device_get_modalias())
|
||||||
|
works fine, but due to the use of snprintf() internally it needs a
|
||||||
|
buffer one byte longer than what should be needed just for the entire
|
||||||
|
string (excluding the '\0'). Most users of this helper are sysfs hooks
|
||||||
|
providing the modalias string to users. They all provide a PAGE_SIZE
|
||||||
|
buffer which is way above the number of bytes required to fit the
|
||||||
|
modalias string and hence do not suffer from this issue.
|
||||||
|
|
||||||
|
There is another user though, of_device_request_module(), which is only
|
||||||
|
called by drivers/usb/common/ulpi.c. This request module function is
|
||||||
|
faulty, but maybe because in most cases there is an alternative, ULPI
|
||||||
|
driver users have not noticed it.
|
||||||
|
|
||||||
|
In this function, of_device_get_modalias() is called twice. The first
|
||||||
|
time without buffer just to get the number of bytes required by the
|
||||||
|
modalias string (excluding the null byte), and a second time, after
|
||||||
|
buffer allocation, to fill the buffer. The allocation asks for an
|
||||||
|
additional byte, in order to store the trailing '\0'. However, the
|
||||||
|
buffer *length* provided to of_device_get_modalias() excludes this extra
|
||||||
|
byte. The internal use of snprintf() with a length that is exactly the
|
||||||
|
number of bytes to be written has the effect of using the last available
|
||||||
|
byte to store a '\0', which then smashes the last character of the
|
||||||
|
modalias string.
|
||||||
|
|
||||||
|
Provide the actual size of the buffer to of_device_get_modalias() to fix
|
||||||
|
this issue.
|
||||||
|
|
||||||
|
Note: the "str[size - 1] = '\0';" line is not really needed as snprintf
|
||||||
|
will anyway end the string with a null byte, but there is a possibility
|
||||||
|
that this function might be called on a struct device_node without
|
||||||
|
compatible, in this case snprintf() would not be executed. So we keep it
|
||||||
|
just to avoid possible unbounded strings.
|
||||||
|
|
||||||
|
Cc: Stephen Boyd <sboyd@kernel.org>
|
||||||
|
Cc: Peter Chen <peter.chen@kernel.org>
|
||||||
|
Fixes: 9c829c097f2f ("of: device: Support loading a module with OF based modalias")
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-2-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/of/device.c | 7 +++++--
|
||||||
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/of/device.c
|
||||||
|
+++ b/drivers/of/device.c
|
||||||
|
@@ -264,12 +264,15 @@ int of_device_request_module(struct devi
|
||||||
|
if (size < 0)
|
||||||
|
return size;
|
||||||
|
|
||||||
|
- str = kmalloc(size + 1, GFP_KERNEL);
|
||||||
|
+ /* Reserve an additional byte for the trailing '\0' */
|
||||||
|
+ size++;
|
||||||
|
+
|
||||||
|
+ str = kmalloc(size, GFP_KERNEL);
|
||||||
|
if (!str)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
of_device_get_modalias(dev, str, size);
|
||||||
|
- str[size] = '\0';
|
||||||
|
+ str[size - 1] = '\0';
|
||||||
|
ret = request_module(str);
|
||||||
|
kfree(str);
|
||||||
|
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
From 5c3d15e127ebfc0754cd18def7124633b6d46672 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:15 +0100
|
||||||
|
Subject: [PATCH] of: Update of_device_get_modalias()
|
||||||
|
|
||||||
|
This function only needs a "struct device_node" to work, but for
|
||||||
|
convenience the author (and only user) of this helper did use a "struct
|
||||||
|
device" and put it in device.c.
|
||||||
|
|
||||||
|
Let's convert this helper to take a "struct device node" instead. This
|
||||||
|
change asks for two additional changes: renaming it "of_modalias()"
|
||||||
|
to fit the current naming, and moving it outside of device.c which will
|
||||||
|
be done in a follow-up commit.
|
||||||
|
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-8-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/of/device.c | 29 +++++++++++++++++------------
|
||||||
|
1 file changed, 17 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/of/device.c
|
||||||
|
+++ b/drivers/of/device.c
|
||||||
|
@@ -215,7 +215,7 @@ const void *of_device_get_match_data(con
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_device_get_match_data);
|
||||||
|
|
||||||
|
-static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
|
||||||
|
+static ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
|
||||||
|
{
|
||||||
|
const char *compat;
|
||||||
|
char *c;
|
||||||
|
@@ -223,19 +223,16 @@ static ssize_t of_device_get_modalias(st
|
||||||
|
ssize_t csize;
|
||||||
|
ssize_t tsize;
|
||||||
|
|
||||||
|
- if ((!dev) || (!dev->of_node) || dev->of_node_reused)
|
||||||
|
- return -ENODEV;
|
||||||
|
-
|
||||||
|
/* Name & Type */
|
||||||
|
/* %p eats all alphanum characters, so %c must be used here */
|
||||||
|
- csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T',
|
||||||
|
- of_node_get_device_type(dev->of_node));
|
||||||
|
+ csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
|
||||||
|
+ of_node_get_device_type(np));
|
||||||
|
tsize = csize;
|
||||||
|
len -= csize;
|
||||||
|
if (str)
|
||||||
|
str += csize;
|
||||||
|
|
||||||
|
- of_property_for_each_string(dev->of_node, "compatible", p, compat) {
|
||||||
|
+ of_property_for_each_string(np, "compatible", p, compat) {
|
||||||
|
csize = strlen(compat) + 1;
|
||||||
|
tsize += csize;
|
||||||
|
if (csize > len)
|
||||||
|
@@ -260,7 +257,10 @@ int of_device_request_module(struct devi
|
||||||
|
ssize_t size;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- size = of_device_get_modalias(dev, NULL, 0);
|
||||||
|
+ if (!dev || !dev->of_node)
|
||||||
|
+ return -ENODEV;
|
||||||
|
+
|
||||||
|
+ size = of_modalias(dev->of_node, NULL, 0);
|
||||||
|
if (size < 0)
|
||||||
|
return size;
|
||||||
|
|
||||||
|
@@ -271,7 +271,7 @@ int of_device_request_module(struct devi
|
||||||
|
if (!str)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
- of_device_get_modalias(dev, str, size);
|
||||||
|
+ of_modalias(dev->of_node, str, size);
|
||||||
|
str[size - 1] = '\0';
|
||||||
|
ret = request_module(str);
|
||||||
|
kfree(str);
|
||||||
|
@@ -285,7 +285,12 @@ EXPORT_SYMBOL_GPL(of_device_request_modu
|
||||||
|
*/
|
||||||
|
ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len)
|
||||||
|
{
|
||||||
|
- ssize_t sl = of_device_get_modalias(dev, str, len - 2);
|
||||||
|
+ ssize_t sl;
|
||||||
|
+
|
||||||
|
+ if (!dev || !dev->of_node || dev->of_node_reused)
|
||||||
|
+ return -ENODEV;
|
||||||
|
+
|
||||||
|
+ sl = of_modalias(dev->of_node, str, len - 2);
|
||||||
|
if (sl < 0)
|
||||||
|
return sl;
|
||||||
|
if (sl > len - 2)
|
||||||
|
@@ -348,8 +353,8 @@ int of_device_uevent_modalias(struct dev
|
||||||
|
if (add_uevent_var(env, "MODALIAS="))
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
- sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
|
||||||
|
- sizeof(env->buf) - env->buflen);
|
||||||
|
+ sl = of_modalias(dev->of_node, &env->buf[env->buflen-1],
|
||||||
|
+ sizeof(env->buf) - env->buflen);
|
||||||
|
if (sl < 0)
|
||||||
|
return sl;
|
||||||
|
if (sl >= (sizeof(env->buf) - env->buflen))
|
||||||
@ -0,0 +1,173 @@
|
|||||||
|
From 673aa1ed1c9b6710bf24e3f0957d85e2f46c77db Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:16 +0100
|
||||||
|
Subject: [PATCH] of: Rename of_modalias_node()
|
||||||
|
|
||||||
|
This helper does not produce a real modalias, but tries to get the
|
||||||
|
"product" compatible part of the "vendor,product" compatibles only. It
|
||||||
|
is far from creating a purely useful modalias string and does not seem
|
||||||
|
to be used like that directly anyway, so let's try to give this helper a
|
||||||
|
more meaningful name before moving there a real modalias helper (already
|
||||||
|
existing under of/device.c).
|
||||||
|
|
||||||
|
Also update the various documentations to refer to the strings as
|
||||||
|
"aliases" rather than "modaliases" which has a real meaning in the Linux
|
||||||
|
kernel.
|
||||||
|
|
||||||
|
There is no functional change.
|
||||||
|
|
||||||
|
Cc: Rafael J. Wysocki <rafael@kernel.org>
|
||||||
|
Cc: Len Brown <lenb@kernel.org>
|
||||||
|
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
|
||||||
|
Cc: Maxime Ripard <mripard@kernel.org>
|
||||||
|
Cc: Thomas Zimmermann <tzimmermann@suse.de>
|
||||||
|
Cc: Sebastian Reichel <sre@kernel.org>
|
||||||
|
Cc: Wolfram Sang <wsa@kernel.org>
|
||||||
|
Cc: Mark Brown <broonie@kernel.org>
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Acked-by: Mark Brown <broonie@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Acked-by: Sebastian Reichel <sre@kernel.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-9-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/acpi/bus.c | 7 ++++---
|
||||||
|
drivers/gpu/drm/drm_mipi_dsi.c | 2 +-
|
||||||
|
drivers/hsi/hsi_core.c | 2 +-
|
||||||
|
drivers/i2c/busses/i2c-powermac.c | 2 +-
|
||||||
|
drivers/i2c/i2c-core-of.c | 2 +-
|
||||||
|
drivers/of/base.c | 18 +++++++++++-------
|
||||||
|
drivers/spi/spi.c | 4 ++--
|
||||||
|
include/linux/of.h | 3 ++-
|
||||||
|
8 files changed, 23 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/acpi/bus.c
|
||||||
|
+++ b/drivers/acpi/bus.c
|
||||||
|
@@ -693,9 +693,10 @@ static bool acpi_of_modalias(struct acpi
|
||||||
|
* @modalias: Pointer to buffer that modalias value will be copied into
|
||||||
|
* @len: Length of modalias buffer
|
||||||
|
*
|
||||||
|
- * This is a counterpart of of_modalias_node() for struct acpi_device objects.
|
||||||
|
- * If there is a compatible string for @adev, it will be copied to @modalias
|
||||||
|
- * with the vendor prefix stripped; otherwise, @default_id will be used.
|
||||||
|
+ * This is a counterpart of of_alias_from_compatible() for struct acpi_device
|
||||||
|
+ * objects. If there is a compatible string for @adev, it will be copied to
|
||||||
|
+ * @modalias with the vendor prefix stripped; otherwise, @default_id will be
|
||||||
|
+ * used.
|
||||||
|
*/
|
||||||
|
void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
|
||||||
|
char *modalias, size_t len)
|
||||||
|
--- a/drivers/gpu/drm/drm_mipi_dsi.c
|
||||||
|
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
|
||||||
|
@@ -160,7 +160,7 @@ of_mipi_dsi_device_add(struct mipi_dsi_h
|
||||||
|
int ret;
|
||||||
|
u32 reg;
|
||||||
|
|
||||||
|
- if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
|
||||||
|
+ if (of_alias_from_compatible(node, info.type, sizeof(info.type)) < 0) {
|
||||||
|
drm_err(host, "modalias failure on %pOF\n", node);
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
}
|
||||||
|
--- a/drivers/hsi/hsi_core.c
|
||||||
|
+++ b/drivers/hsi/hsi_core.c
|
||||||
|
@@ -207,7 +207,7 @@ static void hsi_add_client_from_dt(struc
|
||||||
|
if (!cl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- err = of_modalias_node(client, name, sizeof(name));
|
||||||
|
+ err = of_alias_from_compatible(client, name, sizeof(name));
|
||||||
|
if (err)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
--- a/drivers/i2c/busses/i2c-powermac.c
|
||||||
|
+++ b/drivers/i2c/busses/i2c-powermac.c
|
||||||
|
@@ -289,7 +289,7 @@ static bool i2c_powermac_get_type(struct
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* First try proper modalias */
|
||||||
|
- if (of_modalias_node(node, tmp, sizeof(tmp)) >= 0) {
|
||||||
|
+ if (of_alias_from_compatible(node, tmp, sizeof(tmp)) >= 0) {
|
||||||
|
snprintf(type, type_size, "MAC,%s", tmp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
--- a/drivers/i2c/i2c-core-of.c
|
||||||
|
+++ b/drivers/i2c/i2c-core-of.c
|
||||||
|
@@ -27,7 +27,7 @@ int of_i2c_get_board_info(struct device
|
||||||
|
|
||||||
|
memset(info, 0, sizeof(*info));
|
||||||
|
|
||||||
|
- if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) {
|
||||||
|
+ if (of_alias_from_compatible(node, info->type, sizeof(info->type)) < 0) {
|
||||||
|
dev_err(dev, "of_i2c: modalias failure on %pOF\n", node);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
--- a/drivers/of/base.c
|
||||||
|
+++ b/drivers/of/base.c
|
||||||
|
@@ -1160,19 +1160,23 @@ struct device_node *of_find_matching_nod
|
||||||
|
EXPORT_SYMBOL(of_find_matching_node_and_match);
|
||||||
|
|
||||||
|
/**
|
||||||
|
- * of_modalias_node - Lookup appropriate modalias for a device node
|
||||||
|
+ * of_alias_from_compatible - Lookup appropriate alias for a device node
|
||||||
|
+ * depending on compatible
|
||||||
|
* @node: pointer to a device tree node
|
||||||
|
- * @modalias: Pointer to buffer that modalias value will be copied into
|
||||||
|
- * @len: Length of modalias value
|
||||||
|
+ * @alias: Pointer to buffer that alias value will be copied into
|
||||||
|
+ * @len: Length of alias value
|
||||||
|
*
|
||||||
|
* Based on the value of the compatible property, this routine will attempt
|
||||||
|
- * to choose an appropriate modalias value for a particular device tree node.
|
||||||
|
+ * to choose an appropriate alias value for a particular device tree node.
|
||||||
|
* It does this by stripping the manufacturer prefix (as delimited by a ',')
|
||||||
|
* from the first entry in the compatible list property.
|
||||||
|
*
|
||||||
|
+ * Note: The matching on just the "product" side of the compatible is a relic
|
||||||
|
+ * from I2C and SPI. Please do not add any new user.
|
||||||
|
+ *
|
||||||
|
* Return: This routine returns 0 on success, <0 on failure.
|
||||||
|
*/
|
||||||
|
-int of_modalias_node(struct device_node *node, char *modalias, int len)
|
||||||
|
+int of_alias_from_compatible(const struct device_node *node, char *alias, int len)
|
||||||
|
{
|
||||||
|
const char *compatible, *p;
|
||||||
|
int cplen;
|
||||||
|
@@ -1181,10 +1185,10 @@ int of_modalias_node(struct device_node
|
||||||
|
if (!compatible || strlen(compatible) > cplen)
|
||||||
|
return -ENODEV;
|
||||||
|
p = strchr(compatible, ',');
|
||||||
|
- strlcpy(modalias, p ? p + 1 : compatible, len);
|
||||||
|
+ strlcpy(alias, p ? p + 1 : compatible, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
-EXPORT_SYMBOL_GPL(of_modalias_node);
|
||||||
|
+EXPORT_SYMBOL_GPL(of_alias_from_compatible);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* of_find_node_by_phandle - Find a node given a phandle
|
||||||
|
--- a/drivers/spi/spi.c
|
||||||
|
+++ b/drivers/spi/spi.c
|
||||||
|
@@ -2038,8 +2038,8 @@ of_register_spi_device(struct spi_contro
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select device driver */
|
||||||
|
- rc = of_modalias_node(nc, spi->modalias,
|
||||||
|
- sizeof(spi->modalias));
|
||||||
|
+ rc = of_alias_from_compatible(nc, spi->modalias,
|
||||||
|
+ sizeof(spi->modalias));
|
||||||
|
if (rc < 0) {
|
||||||
|
dev_err(&ctlr->dev, "cannot find modalias for %pOF\n", nc);
|
||||||
|
goto err_out;
|
||||||
|
--- a/include/linux/of.h
|
||||||
|
+++ b/include/linux/of.h
|
||||||
|
@@ -361,7 +361,8 @@ extern int of_n_addr_cells(struct device
|
||||||
|
extern int of_n_size_cells(struct device_node *np);
|
||||||
|
extern const struct of_device_id *of_match_node(
|
||||||
|
const struct of_device_id *matches, const struct device_node *node);
|
||||||
|
-extern int of_modalias_node(struct device_node *node, char *modalias, int len);
|
||||||
|
+extern int of_alias_from_compatible(const struct device_node *node, char *alias,
|
||||||
|
+ int len);
|
||||||
|
extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args);
|
||||||
|
extern int __of_parse_phandle_with_args(const struct device_node *np,
|
||||||
|
const char *list_name, const char *cells_name, int cell_count,
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
From bd7a7ed774afd1a4174df34227626c95573be517 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:17 +0100
|
||||||
|
Subject: [PATCH] of: Move of_modalias() to module.c
|
||||||
|
|
||||||
|
Create a specific .c file for OF related module handling.
|
||||||
|
Move of_modalias() inside as a first step.
|
||||||
|
|
||||||
|
The helper is exposed through of.h even though it is only used by core
|
||||||
|
files because the users from device.c will soon be split into an OF-only
|
||||||
|
helper in module.c as well as a device-oriented inline helper in
|
||||||
|
of_device.h. Putting this helper in of_private.h would require to
|
||||||
|
include of_private.h from of_device.h, which is not acceptable.
|
||||||
|
|
||||||
|
Suggested-by: Rob Herring <robh+dt@kernel.org>
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-10-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/of/Makefile | 2 +-
|
||||||
|
drivers/of/device.c | 37 -------------------------------------
|
||||||
|
drivers/of/module.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
include/linux/of.h | 9 +++++++++
|
||||||
|
4 files changed, 54 insertions(+), 38 deletions(-)
|
||||||
|
create mode 100644 drivers/of/module.c
|
||||||
|
|
||||||
|
--- a/drivers/of/Makefile
|
||||||
|
+++ b/drivers/of/Makefile
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
-obj-y = base.o device.o platform.o property.o
|
||||||
|
+obj-y = base.o device.o module.o platform.o property.o
|
||||||
|
obj-$(CONFIG_OF_KOBJ) += kobj.o
|
||||||
|
obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
|
||||||
|
obj-$(CONFIG_OF_FLATTREE) += fdt.o
|
||||||
|
--- a/drivers/of/device.c
|
||||||
|
+++ b/drivers/of/device.c
|
||||||
|
@@ -1,5 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
-#include <linux/string.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
|
@@ -215,42 +214,6 @@ const void *of_device_get_match_data(con
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_device_get_match_data);
|
||||||
|
|
||||||
|
-static ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
|
||||||
|
-{
|
||||||
|
- const char *compat;
|
||||||
|
- char *c;
|
||||||
|
- struct property *p;
|
||||||
|
- ssize_t csize;
|
||||||
|
- ssize_t tsize;
|
||||||
|
-
|
||||||
|
- /* Name & Type */
|
||||||
|
- /* %p eats all alphanum characters, so %c must be used here */
|
||||||
|
- csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
|
||||||
|
- of_node_get_device_type(np));
|
||||||
|
- tsize = csize;
|
||||||
|
- len -= csize;
|
||||||
|
- if (str)
|
||||||
|
- str += csize;
|
||||||
|
-
|
||||||
|
- of_property_for_each_string(np, "compatible", p, compat) {
|
||||||
|
- csize = strlen(compat) + 1;
|
||||||
|
- tsize += csize;
|
||||||
|
- if (csize > len)
|
||||||
|
- continue;
|
||||||
|
-
|
||||||
|
- csize = snprintf(str, len, "C%s", compat);
|
||||||
|
- for (c = str; c; ) {
|
||||||
|
- c = strchr(c, ' ');
|
||||||
|
- if (c)
|
||||||
|
- *c++ = '_';
|
||||||
|
- }
|
||||||
|
- len -= csize;
|
||||||
|
- str += csize;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return tsize;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
int of_device_request_module(struct device *dev)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/drivers/of/module.c
|
||||||
|
@@ -0,0 +1,44 @@
|
||||||
|
+// SPDX-License-Identifier: GPL-2.0
|
||||||
|
+/*
|
||||||
|
+ * Linux kernel module helpers.
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include <linux/of.h>
|
||||||
|
+#include <linux/slab.h>
|
||||||
|
+#include <linux/string.h>
|
||||||
|
+
|
||||||
|
+ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
|
||||||
|
+{
|
||||||
|
+ const char *compat;
|
||||||
|
+ char *c;
|
||||||
|
+ struct property *p;
|
||||||
|
+ ssize_t csize;
|
||||||
|
+ ssize_t tsize;
|
||||||
|
+
|
||||||
|
+ /* Name & Type */
|
||||||
|
+ /* %p eats all alphanum characters, so %c must be used here */
|
||||||
|
+ csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
|
||||||
|
+ of_node_get_device_type(np));
|
||||||
|
+ tsize = csize;
|
||||||
|
+ len -= csize;
|
||||||
|
+ if (str)
|
||||||
|
+ str += csize;
|
||||||
|
+
|
||||||
|
+ of_property_for_each_string(np, "compatible", p, compat) {
|
||||||
|
+ csize = strlen(compat) + 1;
|
||||||
|
+ tsize += csize;
|
||||||
|
+ if (csize > len)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ csize = snprintf(str, len, "C%s", compat);
|
||||||
|
+ for (c = str; c; ) {
|
||||||
|
+ c = strchr(c, ' ');
|
||||||
|
+ if (c)
|
||||||
|
+ *c++ = '_';
|
||||||
|
+ }
|
||||||
|
+ len -= csize;
|
||||||
|
+ str += csize;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return tsize;
|
||||||
|
+}
|
||||||
|
--- a/include/linux/of.h
|
||||||
|
+++ b/include/linux/of.h
|
||||||
|
@@ -373,6 +373,9 @@ extern int of_parse_phandle_with_args_ma
|
||||||
|
extern int of_count_phandle_with_args(const struct device_node *np,
|
||||||
|
const char *list_name, const char *cells_name);
|
||||||
|
|
||||||
|
+/* module functions */
|
||||||
|
+extern ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len);
|
||||||
|
+
|
||||||
|
/* phandle iterator functions */
|
||||||
|
extern int of_phandle_iterator_init(struct of_phandle_iterator *it,
|
||||||
|
const struct device_node *np,
|
||||||
|
@@ -878,6 +881,12 @@ static inline int of_count_phandle_with_
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static inline ssize_t of_modalias(const struct device_node *np, char *str,
|
||||||
|
+ ssize_t len)
|
||||||
|
+{
|
||||||
|
+ return -ENODEV;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static inline int of_phandle_iterator_init(struct of_phandle_iterator *it,
|
||||||
|
const struct device_node *np,
|
||||||
|
const char *list_name,
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
From e6506f06d5e82765666902ccf9e9162f3e31d518 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:18 +0100
|
||||||
|
Subject: [PATCH] of: Move the request module helper logic to module.c
|
||||||
|
|
||||||
|
Depending on device.c for pure OF handling is considered
|
||||||
|
backwards. Let's extract the content of of_device_request_module() to
|
||||||
|
have the real logic under module.c.
|
||||||
|
|
||||||
|
The next step will be to convert users of of_device_request_module() to
|
||||||
|
use the new helper.
|
||||||
|
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-11-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/of/device.c | 25 ++-----------------------
|
||||||
|
drivers/of/module.c | 30 ++++++++++++++++++++++++++++++
|
||||||
|
include/linux/of.h | 6 ++++++
|
||||||
|
3 files changed, 38 insertions(+), 23 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/of/device.c
|
||||||
|
+++ b/drivers/of/device.c
|
||||||
|
@@ -7,7 +7,6 @@
|
||||||
|
#include <linux/dma-direct.h> /* for bus_dma_region */
|
||||||
|
#include <linux/dma-map-ops.h>
|
||||||
|
#include <linux/init.h>
|
||||||
|
-#include <linux/module.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
@@ -216,30 +215,10 @@ EXPORT_SYMBOL(of_device_get_match_data);
|
||||||
|
|
||||||
|
int of_device_request_module(struct device *dev)
|
||||||
|
{
|
||||||
|
- char *str;
|
||||||
|
- ssize_t size;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- if (!dev || !dev->of_node)
|
||||||
|
+ if (!dev)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
- size = of_modalias(dev->of_node, NULL, 0);
|
||||||
|
- if (size < 0)
|
||||||
|
- return size;
|
||||||
|
-
|
||||||
|
- /* Reserve an additional byte for the trailing '\0' */
|
||||||
|
- size++;
|
||||||
|
-
|
||||||
|
- str = kmalloc(size, GFP_KERNEL);
|
||||||
|
- if (!str)
|
||||||
|
- return -ENOMEM;
|
||||||
|
-
|
||||||
|
- of_modalias(dev->of_node, str, size);
|
||||||
|
- str[size - 1] = '\0';
|
||||||
|
- ret = request_module(str);
|
||||||
|
- kfree(str);
|
||||||
|
-
|
||||||
|
- return ret;
|
||||||
|
+ return of_request_module(dev->of_node);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(of_device_request_module);
|
||||||
|
|
||||||
|
--- a/drivers/of/module.c
|
||||||
|
+++ b/drivers/of/module.c
|
||||||
|
@@ -4,6 +4,7 @@
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/of.h>
|
||||||
|
+#include <linux/module.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/string.h>
|
||||||
|
|
||||||
|
@@ -42,3 +43,32 @@ ssize_t of_modalias(const struct device_
|
||||||
|
|
||||||
|
return tsize;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+int of_request_module(const struct device_node *np)
|
||||||
|
+{
|
||||||
|
+ char *str;
|
||||||
|
+ ssize_t size;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ if (!np)
|
||||||
|
+ return -ENODEV;
|
||||||
|
+
|
||||||
|
+ size = of_modalias(np, NULL, 0);
|
||||||
|
+ if (size < 0)
|
||||||
|
+ return size;
|
||||||
|
+
|
||||||
|
+ /* Reserve an additional byte for the trailing '\0' */
|
||||||
|
+ size++;
|
||||||
|
+
|
||||||
|
+ str = kmalloc(size, GFP_KERNEL);
|
||||||
|
+ if (!str)
|
||||||
|
+ return -ENOMEM;
|
||||||
|
+
|
||||||
|
+ of_modalias(np, str, size);
|
||||||
|
+ str[size - 1] = '\0';
|
||||||
|
+ ret = request_module(str);
|
||||||
|
+ kfree(str);
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+EXPORT_SYMBOL_GPL(of_request_module);
|
||||||
|
--- a/include/linux/of.h
|
||||||
|
+++ b/include/linux/of.h
|
||||||
|
@@ -375,6 +375,7 @@ extern int of_count_phandle_with_args(co
|
||||||
|
|
||||||
|
/* module functions */
|
||||||
|
extern ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len);
|
||||||
|
+extern int of_request_module(const struct device_node *np);
|
||||||
|
|
||||||
|
/* phandle iterator functions */
|
||||||
|
extern int of_phandle_iterator_init(struct of_phandle_iterator *it,
|
||||||
|
@@ -886,6 +887,11 @@ static inline ssize_t of_modalias(const
|
||||||
|
{
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+static inline int of_request_module(const struct device_node *np)
|
||||||
|
+{
|
||||||
|
+ return -ENODEV;
|
||||||
|
+}
|
||||||
|
|
||||||
|
static inline int of_phandle_iterator_init(struct of_phandle_iterator *it,
|
||||||
|
const struct device_node *np,
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
From b19a4266c52de78496fe40f0b37580a3b762e67d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:09 +0100
|
||||||
|
Subject: [PATCH] of: Fix modalias string generation
|
||||||
|
|
||||||
|
The helper generating an OF based modalias (of_device_get_modalias())
|
||||||
|
works fine, but due to the use of snprintf() internally it needs a
|
||||||
|
buffer one byte longer than what should be needed just for the entire
|
||||||
|
string (excluding the '\0'). Most users of this helper are sysfs hooks
|
||||||
|
providing the modalias string to users. They all provide a PAGE_SIZE
|
||||||
|
buffer which is way above the number of bytes required to fit the
|
||||||
|
modalias string and hence do not suffer from this issue.
|
||||||
|
|
||||||
|
There is another user though, of_device_request_module(), which is only
|
||||||
|
called by drivers/usb/common/ulpi.c. This request module function is
|
||||||
|
faulty, but maybe because in most cases there is an alternative, ULPI
|
||||||
|
driver users have not noticed it.
|
||||||
|
|
||||||
|
In this function, of_device_get_modalias() is called twice. The first
|
||||||
|
time without buffer just to get the number of bytes required by the
|
||||||
|
modalias string (excluding the null byte), and a second time, after
|
||||||
|
buffer allocation, to fill the buffer. The allocation asks for an
|
||||||
|
additional byte, in order to store the trailing '\0'. However, the
|
||||||
|
buffer *length* provided to of_device_get_modalias() excludes this extra
|
||||||
|
byte. The internal use of snprintf() with a length that is exactly the
|
||||||
|
number of bytes to be written has the effect of using the last available
|
||||||
|
byte to store a '\0', which then smashes the last character of the
|
||||||
|
modalias string.
|
||||||
|
|
||||||
|
Provide the actual size of the buffer to of_device_get_modalias() to fix
|
||||||
|
this issue.
|
||||||
|
|
||||||
|
Note: the "str[size - 1] = '\0';" line is not really needed as snprintf
|
||||||
|
will anyway end the string with a null byte, but there is a possibility
|
||||||
|
that this function might be called on a struct device_node without
|
||||||
|
compatible, in this case snprintf() would not be executed. So we keep it
|
||||||
|
just to avoid possible unbounded strings.
|
||||||
|
|
||||||
|
Cc: Stephen Boyd <sboyd@kernel.org>
|
||||||
|
Cc: Peter Chen <peter.chen@kernel.org>
|
||||||
|
Fixes: 9c829c097f2f ("of: device: Support loading a module with OF based modalias")
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-2-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/of/device.c | 7 +++++--
|
||||||
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/of/device.c
|
||||||
|
+++ b/drivers/of/device.c
|
||||||
|
@@ -290,12 +290,15 @@ int of_device_request_module(struct devi
|
||||||
|
if (size < 0)
|
||||||
|
return size;
|
||||||
|
|
||||||
|
- str = kmalloc(size + 1, GFP_KERNEL);
|
||||||
|
+ /* Reserve an additional byte for the trailing '\0' */
|
||||||
|
+ size++;
|
||||||
|
+
|
||||||
|
+ str = kmalloc(size, GFP_KERNEL);
|
||||||
|
if (!str)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
of_device_get_modalias(dev, str, size);
|
||||||
|
- str[size] = '\0';
|
||||||
|
+ str[size - 1] = '\0';
|
||||||
|
ret = request_module(str);
|
||||||
|
kfree(str);
|
||||||
|
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
From 5c3d15e127ebfc0754cd18def7124633b6d46672 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:15 +0100
|
||||||
|
Subject: [PATCH] of: Update of_device_get_modalias()
|
||||||
|
|
||||||
|
This function only needs a "struct device_node" to work, but for
|
||||||
|
convenience the author (and only user) of this helper did use a "struct
|
||||||
|
device" and put it in device.c.
|
||||||
|
|
||||||
|
Let's convert this helper to take a "struct device node" instead. This
|
||||||
|
change asks for two additional changes: renaming it "of_modalias()"
|
||||||
|
to fit the current naming, and moving it outside of device.c which will
|
||||||
|
be done in a follow-up commit.
|
||||||
|
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-8-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/of/device.c | 29 +++++++++++++++++------------
|
||||||
|
1 file changed, 17 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/of/device.c
|
||||||
|
+++ b/drivers/of/device.c
|
||||||
|
@@ -241,7 +241,7 @@ const void *of_device_get_match_data(con
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_device_get_match_data);
|
||||||
|
|
||||||
|
-static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
|
||||||
|
+static ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
|
||||||
|
{
|
||||||
|
const char *compat;
|
||||||
|
char *c;
|
||||||
|
@@ -249,19 +249,16 @@ static ssize_t of_device_get_modalias(st
|
||||||
|
ssize_t csize;
|
||||||
|
ssize_t tsize;
|
||||||
|
|
||||||
|
- if ((!dev) || (!dev->of_node) || dev->of_node_reused)
|
||||||
|
- return -ENODEV;
|
||||||
|
-
|
||||||
|
/* Name & Type */
|
||||||
|
/* %p eats all alphanum characters, so %c must be used here */
|
||||||
|
- csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T',
|
||||||
|
- of_node_get_device_type(dev->of_node));
|
||||||
|
+ csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
|
||||||
|
+ of_node_get_device_type(np));
|
||||||
|
tsize = csize;
|
||||||
|
len -= csize;
|
||||||
|
if (str)
|
||||||
|
str += csize;
|
||||||
|
|
||||||
|
- of_property_for_each_string(dev->of_node, "compatible", p, compat) {
|
||||||
|
+ of_property_for_each_string(np, "compatible", p, compat) {
|
||||||
|
csize = strlen(compat) + 1;
|
||||||
|
tsize += csize;
|
||||||
|
if (csize > len)
|
||||||
|
@@ -286,7 +283,10 @@ int of_device_request_module(struct devi
|
||||||
|
ssize_t size;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- size = of_device_get_modalias(dev, NULL, 0);
|
||||||
|
+ if (!dev || !dev->of_node)
|
||||||
|
+ return -ENODEV;
|
||||||
|
+
|
||||||
|
+ size = of_modalias(dev->of_node, NULL, 0);
|
||||||
|
if (size < 0)
|
||||||
|
return size;
|
||||||
|
|
||||||
|
@@ -297,7 +297,7 @@ int of_device_request_module(struct devi
|
||||||
|
if (!str)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
- of_device_get_modalias(dev, str, size);
|
||||||
|
+ of_modalias(dev->of_node, str, size);
|
||||||
|
str[size - 1] = '\0';
|
||||||
|
ret = request_module(str);
|
||||||
|
kfree(str);
|
||||||
|
@@ -314,7 +314,12 @@ EXPORT_SYMBOL_GPL(of_device_request_modu
|
||||||
|
*/
|
||||||
|
ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len)
|
||||||
|
{
|
||||||
|
- ssize_t sl = of_device_get_modalias(dev, str, len - 2);
|
||||||
|
+ ssize_t sl;
|
||||||
|
+
|
||||||
|
+ if (!dev || !dev->of_node || dev->of_node_reused)
|
||||||
|
+ return -ENODEV;
|
||||||
|
+
|
||||||
|
+ sl = of_modalias(dev->of_node, str, len - 2);
|
||||||
|
if (sl < 0)
|
||||||
|
return sl;
|
||||||
|
if (sl > len - 2)
|
||||||
|
@@ -379,8 +384,8 @@ int of_device_uevent_modalias(struct dev
|
||||||
|
if (add_uevent_var(env, "MODALIAS="))
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
- sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
|
||||||
|
- sizeof(env->buf) - env->buflen);
|
||||||
|
+ sl = of_modalias(dev->of_node, &env->buf[env->buflen-1],
|
||||||
|
+ sizeof(env->buf) - env->buflen);
|
||||||
|
if (sl < 0)
|
||||||
|
return sl;
|
||||||
|
if (sl >= (sizeof(env->buf) - env->buflen))
|
||||||
@ -0,0 +1,173 @@
|
|||||||
|
From 673aa1ed1c9b6710bf24e3f0957d85e2f46c77db Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:16 +0100
|
||||||
|
Subject: [PATCH] of: Rename of_modalias_node()
|
||||||
|
|
||||||
|
This helper does not produce a real modalias, but tries to get the
|
||||||
|
"product" compatible part of the "vendor,product" compatibles only. It
|
||||||
|
is far from creating a purely useful modalias string and does not seem
|
||||||
|
to be used like that directly anyway, so let's try to give this helper a
|
||||||
|
more meaningful name before moving there a real modalias helper (already
|
||||||
|
existing under of/device.c).
|
||||||
|
|
||||||
|
Also update the various documentations to refer to the strings as
|
||||||
|
"aliases" rather than "modaliases" which has a real meaning in the Linux
|
||||||
|
kernel.
|
||||||
|
|
||||||
|
There is no functional change.
|
||||||
|
|
||||||
|
Cc: Rafael J. Wysocki <rafael@kernel.org>
|
||||||
|
Cc: Len Brown <lenb@kernel.org>
|
||||||
|
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
|
||||||
|
Cc: Maxime Ripard <mripard@kernel.org>
|
||||||
|
Cc: Thomas Zimmermann <tzimmermann@suse.de>
|
||||||
|
Cc: Sebastian Reichel <sre@kernel.org>
|
||||||
|
Cc: Wolfram Sang <wsa@kernel.org>
|
||||||
|
Cc: Mark Brown <broonie@kernel.org>
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Acked-by: Mark Brown <broonie@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Acked-by: Sebastian Reichel <sre@kernel.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-9-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/acpi/bus.c | 7 ++++---
|
||||||
|
drivers/gpu/drm/drm_mipi_dsi.c | 2 +-
|
||||||
|
drivers/hsi/hsi_core.c | 2 +-
|
||||||
|
drivers/i2c/busses/i2c-powermac.c | 2 +-
|
||||||
|
drivers/i2c/i2c-core-of.c | 2 +-
|
||||||
|
drivers/of/base.c | 18 +++++++++++-------
|
||||||
|
drivers/spi/spi.c | 4 ++--
|
||||||
|
include/linux/of.h | 3 ++-
|
||||||
|
8 files changed, 23 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/acpi/bus.c
|
||||||
|
+++ b/drivers/acpi/bus.c
|
||||||
|
@@ -785,9 +785,10 @@ static bool acpi_of_modalias(struct acpi
|
||||||
|
* @modalias: Pointer to buffer that modalias value will be copied into
|
||||||
|
* @len: Length of modalias buffer
|
||||||
|
*
|
||||||
|
- * This is a counterpart of of_modalias_node() for struct acpi_device objects.
|
||||||
|
- * If there is a compatible string for @adev, it will be copied to @modalias
|
||||||
|
- * with the vendor prefix stripped; otherwise, @default_id will be used.
|
||||||
|
+ * This is a counterpart of of_alias_from_compatible() for struct acpi_device
|
||||||
|
+ * objects. If there is a compatible string for @adev, it will be copied to
|
||||||
|
+ * @modalias with the vendor prefix stripped; otherwise, @default_id will be
|
||||||
|
+ * used.
|
||||||
|
*/
|
||||||
|
void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
|
||||||
|
char *modalias, size_t len)
|
||||||
|
--- a/drivers/gpu/drm/drm_mipi_dsi.c
|
||||||
|
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
|
||||||
|
@@ -160,7 +160,7 @@ of_mipi_dsi_device_add(struct mipi_dsi_h
|
||||||
|
int ret;
|
||||||
|
u32 reg;
|
||||||
|
|
||||||
|
- if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
|
||||||
|
+ if (of_alias_from_compatible(node, info.type, sizeof(info.type)) < 0) {
|
||||||
|
drm_err(host, "modalias failure on %pOF\n", node);
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
}
|
||||||
|
--- a/drivers/hsi/hsi_core.c
|
||||||
|
+++ b/drivers/hsi/hsi_core.c
|
||||||
|
@@ -207,7 +207,7 @@ static void hsi_add_client_from_dt(struc
|
||||||
|
if (!cl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- err = of_modalias_node(client, name, sizeof(name));
|
||||||
|
+ err = of_alias_from_compatible(client, name, sizeof(name));
|
||||||
|
if (err)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
--- a/drivers/i2c/busses/i2c-powermac.c
|
||||||
|
+++ b/drivers/i2c/busses/i2c-powermac.c
|
||||||
|
@@ -284,7 +284,7 @@ static bool i2c_powermac_get_type(struct
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* First try proper modalias */
|
||||||
|
- if (of_modalias_node(node, tmp, sizeof(tmp)) >= 0) {
|
||||||
|
+ if (of_alias_from_compatible(node, tmp, sizeof(tmp)) >= 0) {
|
||||||
|
snprintf(type, type_size, "MAC,%s", tmp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
--- a/drivers/i2c/i2c-core-of.c
|
||||||
|
+++ b/drivers/i2c/i2c-core-of.c
|
||||||
|
@@ -27,7 +27,7 @@ int of_i2c_get_board_info(struct device
|
||||||
|
|
||||||
|
memset(info, 0, sizeof(*info));
|
||||||
|
|
||||||
|
- if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) {
|
||||||
|
+ if (of_alias_from_compatible(node, info->type, sizeof(info->type)) < 0) {
|
||||||
|
dev_err(dev, "of_i2c: modalias failure on %pOF\n", node);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
--- a/drivers/of/base.c
|
||||||
|
+++ b/drivers/of/base.c
|
||||||
|
@@ -1159,19 +1159,23 @@ struct device_node *of_find_matching_nod
|
||||||
|
EXPORT_SYMBOL(of_find_matching_node_and_match);
|
||||||
|
|
||||||
|
/**
|
||||||
|
- * of_modalias_node - Lookup appropriate modalias for a device node
|
||||||
|
+ * of_alias_from_compatible - Lookup appropriate alias for a device node
|
||||||
|
+ * depending on compatible
|
||||||
|
* @node: pointer to a device tree node
|
||||||
|
- * @modalias: Pointer to buffer that modalias value will be copied into
|
||||||
|
- * @len: Length of modalias value
|
||||||
|
+ * @alias: Pointer to buffer that alias value will be copied into
|
||||||
|
+ * @len: Length of alias value
|
||||||
|
*
|
||||||
|
* Based on the value of the compatible property, this routine will attempt
|
||||||
|
- * to choose an appropriate modalias value for a particular device tree node.
|
||||||
|
+ * to choose an appropriate alias value for a particular device tree node.
|
||||||
|
* It does this by stripping the manufacturer prefix (as delimited by a ',')
|
||||||
|
* from the first entry in the compatible list property.
|
||||||
|
*
|
||||||
|
+ * Note: The matching on just the "product" side of the compatible is a relic
|
||||||
|
+ * from I2C and SPI. Please do not add any new user.
|
||||||
|
+ *
|
||||||
|
* Return: This routine returns 0 on success, <0 on failure.
|
||||||
|
*/
|
||||||
|
-int of_modalias_node(struct device_node *node, char *modalias, int len)
|
||||||
|
+int of_alias_from_compatible(const struct device_node *node, char *alias, int len)
|
||||||
|
{
|
||||||
|
const char *compatible, *p;
|
||||||
|
int cplen;
|
||||||
|
@@ -1180,10 +1184,10 @@ int of_modalias_node(struct device_node
|
||||||
|
if (!compatible || strlen(compatible) > cplen)
|
||||||
|
return -ENODEV;
|
||||||
|
p = strchr(compatible, ',');
|
||||||
|
- strlcpy(modalias, p ? p + 1 : compatible, len);
|
||||||
|
+ strlcpy(alias, p ? p + 1 : compatible, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
-EXPORT_SYMBOL_GPL(of_modalias_node);
|
||||||
|
+EXPORT_SYMBOL_GPL(of_alias_from_compatible);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* of_find_node_by_phandle - Find a node given a phandle
|
||||||
|
--- a/drivers/spi/spi.c
|
||||||
|
+++ b/drivers/spi/spi.c
|
||||||
|
@@ -2128,8 +2128,8 @@ of_register_spi_device(struct spi_contro
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select device driver */
|
||||||
|
- rc = of_modalias_node(nc, spi->modalias,
|
||||||
|
- sizeof(spi->modalias));
|
||||||
|
+ rc = of_alias_from_compatible(nc, spi->modalias,
|
||||||
|
+ sizeof(spi->modalias));
|
||||||
|
if (rc < 0) {
|
||||||
|
dev_err(&ctlr->dev, "cannot find modalias for %pOF\n", nc);
|
||||||
|
goto err_out;
|
||||||
|
--- a/include/linux/of.h
|
||||||
|
+++ b/include/linux/of.h
|
||||||
|
@@ -361,7 +361,8 @@ extern int of_n_addr_cells(struct device
|
||||||
|
extern int of_n_size_cells(struct device_node *np);
|
||||||
|
extern const struct of_device_id *of_match_node(
|
||||||
|
const struct of_device_id *matches, const struct device_node *node);
|
||||||
|
-extern int of_modalias_node(struct device_node *node, char *modalias, int len);
|
||||||
|
+extern int of_alias_from_compatible(const struct device_node *node, char *alias,
|
||||||
|
+ int len);
|
||||||
|
extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args);
|
||||||
|
extern int __of_parse_phandle_with_args(const struct device_node *np,
|
||||||
|
const char *list_name, const char *cells_name, int cell_count,
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
From bd7a7ed774afd1a4174df34227626c95573be517 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:17 +0100
|
||||||
|
Subject: [PATCH] of: Move of_modalias() to module.c
|
||||||
|
|
||||||
|
Create a specific .c file for OF related module handling.
|
||||||
|
Move of_modalias() inside as a first step.
|
||||||
|
|
||||||
|
The helper is exposed through of.h even though it is only used by core
|
||||||
|
files because the users from device.c will soon be split into an OF-only
|
||||||
|
helper in module.c as well as a device-oriented inline helper in
|
||||||
|
of_device.h. Putting this helper in of_private.h would require to
|
||||||
|
include of_private.h from of_device.h, which is not acceptable.
|
||||||
|
|
||||||
|
Suggested-by: Rob Herring <robh+dt@kernel.org>
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-10-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/of/Makefile | 2 +-
|
||||||
|
drivers/of/device.c | 37 -------------------------------------
|
||||||
|
drivers/of/module.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
include/linux/of.h | 9 +++++++++
|
||||||
|
4 files changed, 54 insertions(+), 38 deletions(-)
|
||||||
|
create mode 100644 drivers/of/module.c
|
||||||
|
|
||||||
|
--- a/drivers/of/Makefile
|
||||||
|
+++ b/drivers/of/Makefile
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
-obj-y = base.o device.o platform.o property.o
|
||||||
|
+obj-y = base.o device.o module.o platform.o property.o
|
||||||
|
obj-$(CONFIG_OF_KOBJ) += kobj.o
|
||||||
|
obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
|
||||||
|
obj-$(CONFIG_OF_FLATTREE) += fdt.o
|
||||||
|
--- a/drivers/of/device.c
|
||||||
|
+++ b/drivers/of/device.c
|
||||||
|
@@ -1,5 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
-#include <linux/string.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
|
@@ -241,42 +240,6 @@ const void *of_device_get_match_data(con
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_device_get_match_data);
|
||||||
|
|
||||||
|
-static ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
|
||||||
|
-{
|
||||||
|
- const char *compat;
|
||||||
|
- char *c;
|
||||||
|
- struct property *p;
|
||||||
|
- ssize_t csize;
|
||||||
|
- ssize_t tsize;
|
||||||
|
-
|
||||||
|
- /* Name & Type */
|
||||||
|
- /* %p eats all alphanum characters, so %c must be used here */
|
||||||
|
- csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
|
||||||
|
- of_node_get_device_type(np));
|
||||||
|
- tsize = csize;
|
||||||
|
- len -= csize;
|
||||||
|
- if (str)
|
||||||
|
- str += csize;
|
||||||
|
-
|
||||||
|
- of_property_for_each_string(np, "compatible", p, compat) {
|
||||||
|
- csize = strlen(compat) + 1;
|
||||||
|
- tsize += csize;
|
||||||
|
- if (csize > len)
|
||||||
|
- continue;
|
||||||
|
-
|
||||||
|
- csize = snprintf(str, len, "C%s", compat);
|
||||||
|
- for (c = str; c; ) {
|
||||||
|
- c = strchr(c, ' ');
|
||||||
|
- if (c)
|
||||||
|
- *c++ = '_';
|
||||||
|
- }
|
||||||
|
- len -= csize;
|
||||||
|
- str += csize;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return tsize;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
int of_device_request_module(struct device *dev)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/drivers/of/module.c
|
||||||
|
@@ -0,0 +1,44 @@
|
||||||
|
+// SPDX-License-Identifier: GPL-2.0
|
||||||
|
+/*
|
||||||
|
+ * Linux kernel module helpers.
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include <linux/of.h>
|
||||||
|
+#include <linux/slab.h>
|
||||||
|
+#include <linux/string.h>
|
||||||
|
+
|
||||||
|
+ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
|
||||||
|
+{
|
||||||
|
+ const char *compat;
|
||||||
|
+ char *c;
|
||||||
|
+ struct property *p;
|
||||||
|
+ ssize_t csize;
|
||||||
|
+ ssize_t tsize;
|
||||||
|
+
|
||||||
|
+ /* Name & Type */
|
||||||
|
+ /* %p eats all alphanum characters, so %c must be used here */
|
||||||
|
+ csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
|
||||||
|
+ of_node_get_device_type(np));
|
||||||
|
+ tsize = csize;
|
||||||
|
+ len -= csize;
|
||||||
|
+ if (str)
|
||||||
|
+ str += csize;
|
||||||
|
+
|
||||||
|
+ of_property_for_each_string(np, "compatible", p, compat) {
|
||||||
|
+ csize = strlen(compat) + 1;
|
||||||
|
+ tsize += csize;
|
||||||
|
+ if (csize > len)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ csize = snprintf(str, len, "C%s", compat);
|
||||||
|
+ for (c = str; c; ) {
|
||||||
|
+ c = strchr(c, ' ');
|
||||||
|
+ if (c)
|
||||||
|
+ *c++ = '_';
|
||||||
|
+ }
|
||||||
|
+ len -= csize;
|
||||||
|
+ str += csize;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return tsize;
|
||||||
|
+}
|
||||||
|
--- a/include/linux/of.h
|
||||||
|
+++ b/include/linux/of.h
|
||||||
|
@@ -373,6 +373,9 @@ extern int of_parse_phandle_with_args_ma
|
||||||
|
extern int of_count_phandle_with_args(const struct device_node *np,
|
||||||
|
const char *list_name, const char *cells_name);
|
||||||
|
|
||||||
|
+/* module functions */
|
||||||
|
+extern ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len);
|
||||||
|
+
|
||||||
|
/* phandle iterator functions */
|
||||||
|
extern int of_phandle_iterator_init(struct of_phandle_iterator *it,
|
||||||
|
const struct device_node *np,
|
||||||
|
@@ -885,6 +888,12 @@ static inline int of_count_phandle_with_
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static inline ssize_t of_modalias(const struct device_node *np, char *str,
|
||||||
|
+ ssize_t len)
|
||||||
|
+{
|
||||||
|
+ return -ENODEV;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static inline int of_phandle_iterator_init(struct of_phandle_iterator *it,
|
||||||
|
const struct device_node *np,
|
||||||
|
const char *list_name,
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
From e6506f06d5e82765666902ccf9e9162f3e31d518 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Date: Tue, 4 Apr 2023 18:21:18 +0100
|
||||||
|
Subject: [PATCH] of: Move the request module helper logic to module.c
|
||||||
|
|
||||||
|
Depending on device.c for pure OF handling is considered
|
||||||
|
backwards. Let's extract the content of of_device_request_module() to
|
||||||
|
have the real logic under module.c.
|
||||||
|
|
||||||
|
The next step will be to convert users of of_device_request_module() to
|
||||||
|
use the new helper.
|
||||||
|
|
||||||
|
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||||
|
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||||
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||||
|
Link: https://lore.kernel.org/r/20230404172148.82422-11-srinivas.kandagatla@linaro.org
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
---
|
||||||
|
drivers/of/device.c | 25 ++-----------------------
|
||||||
|
drivers/of/module.c | 30 ++++++++++++++++++++++++++++++
|
||||||
|
include/linux/of.h | 6 ++++++
|
||||||
|
3 files changed, 38 insertions(+), 23 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/of/device.c
|
||||||
|
+++ b/drivers/of/device.c
|
||||||
|
@@ -8,7 +8,6 @@
|
||||||
|
#include <linux/dma-direct.h> /* for bus_dma_region */
|
||||||
|
#include <linux/dma-map-ops.h>
|
||||||
|
#include <linux/init.h>
|
||||||
|
-#include <linux/module.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
@@ -242,30 +241,10 @@ EXPORT_SYMBOL(of_device_get_match_data);
|
||||||
|
|
||||||
|
int of_device_request_module(struct device *dev)
|
||||||
|
{
|
||||||
|
- char *str;
|
||||||
|
- ssize_t size;
|
||||||
|
- int ret;
|
||||||
|
-
|
||||||
|
- if (!dev || !dev->of_node)
|
||||||
|
+ if (!dev)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
- size = of_modalias(dev->of_node, NULL, 0);
|
||||||
|
- if (size < 0)
|
||||||
|
- return size;
|
||||||
|
-
|
||||||
|
- /* Reserve an additional byte for the trailing '\0' */
|
||||||
|
- size++;
|
||||||
|
-
|
||||||
|
- str = kmalloc(size, GFP_KERNEL);
|
||||||
|
- if (!str)
|
||||||
|
- return -ENOMEM;
|
||||||
|
-
|
||||||
|
- of_modalias(dev->of_node, str, size);
|
||||||
|
- str[size - 1] = '\0';
|
||||||
|
- ret = request_module(str);
|
||||||
|
- kfree(str);
|
||||||
|
-
|
||||||
|
- return ret;
|
||||||
|
+ return of_request_module(dev->of_node);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(of_device_request_module);
|
||||||
|
|
||||||
|
--- a/drivers/of/module.c
|
||||||
|
+++ b/drivers/of/module.c
|
||||||
|
@@ -4,6 +4,7 @@
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/of.h>
|
||||||
|
+#include <linux/module.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/string.h>
|
||||||
|
|
||||||
|
@@ -42,3 +43,32 @@ ssize_t of_modalias(const struct device_
|
||||||
|
|
||||||
|
return tsize;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+int of_request_module(const struct device_node *np)
|
||||||
|
+{
|
||||||
|
+ char *str;
|
||||||
|
+ ssize_t size;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ if (!np)
|
||||||
|
+ return -ENODEV;
|
||||||
|
+
|
||||||
|
+ size = of_modalias(np, NULL, 0);
|
||||||
|
+ if (size < 0)
|
||||||
|
+ return size;
|
||||||
|
+
|
||||||
|
+ /* Reserve an additional byte for the trailing '\0' */
|
||||||
|
+ size++;
|
||||||
|
+
|
||||||
|
+ str = kmalloc(size, GFP_KERNEL);
|
||||||
|
+ if (!str)
|
||||||
|
+ return -ENOMEM;
|
||||||
|
+
|
||||||
|
+ of_modalias(np, str, size);
|
||||||
|
+ str[size - 1] = '\0';
|
||||||
|
+ ret = request_module(str);
|
||||||
|
+ kfree(str);
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+EXPORT_SYMBOL_GPL(of_request_module);
|
||||||
|
--- a/include/linux/of.h
|
||||||
|
+++ b/include/linux/of.h
|
||||||
|
@@ -375,6 +375,7 @@ extern int of_count_phandle_with_args(co
|
||||||
|
|
||||||
|
/* module functions */
|
||||||
|
extern ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len);
|
||||||
|
+extern int of_request_module(const struct device_node *np);
|
||||||
|
|
||||||
|
/* phandle iterator functions */
|
||||||
|
extern int of_phandle_iterator_init(struct of_phandle_iterator *it,
|
||||||
|
@@ -893,6 +894,11 @@ static inline ssize_t of_modalias(const
|
||||||
|
{
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+static inline int of_request_module(const struct device_node *np)
|
||||||
|
+{
|
||||||
|
+ return -ENODEV;
|
||||||
|
+}
|
||||||
|
|
||||||
|
static inline int of_phandle_iterator_init(struct of_phandle_iterator *it,
|
||||||
|
const struct device_node *np,
|
||||||
@ -26,7 +26,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
|
|
||||||
--- a/drivers/net/phy/sfp.c
|
--- a/drivers/net/phy/sfp.c
|
||||||
+++ b/drivers/net/phy/sfp.c
|
+++ b/drivers/net/phy/sfp.c
|
||||||
@@ -373,6 +373,11 @@ static const struct sfp_quirk sfp_quirks
|
@@ -377,6 +377,11 @@ static const struct sfp_quirk sfp_quirks
|
||||||
.modes = sfp_quirk_2500basex,
|
.modes = sfp_quirk_2500basex,
|
||||||
.fixup = sfp_fixup_ignore_tx_fault,
|
.fixup = sfp_fixup_ignore_tx_fault,
|
||||||
}, {
|
}, {
|
||||||
@ -38,7 +38,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
// Lantech 8330-262D-E can operate at 2500base-X, but
|
// Lantech 8330-262D-E can operate at 2500base-X, but
|
||||||
// incorrectly report 2500MBd NRZ in their EEPROM
|
// incorrectly report 2500MBd NRZ in their EEPROM
|
||||||
.vendor = "Lantech",
|
.vendor = "Lantech",
|
||||||
@@ -2306,7 +2311,8 @@ static void sfp_sm_main(struct sfp *sfp,
|
@@ -2310,7 +2315,8 @@ static void sfp_sm_main(struct sfp *sfp,
|
||||||
* or t_start_up, so assume there is a fault.
|
* or t_start_up, so assume there is a fault.
|
||||||
*/
|
*/
|
||||||
sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT,
|
sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT,
|
||||||
@ -48,7 +48,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
} else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
|
} else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
|
||||||
init_done:
|
init_done:
|
||||||
sfp->sm_phy_retries = R_PHY_RETRY;
|
sfp->sm_phy_retries = R_PHY_RETRY;
|
||||||
@@ -2529,10 +2535,12 @@ static void sfp_check_state(struct sfp *
|
@@ -2533,10 +2539,12 @@ static void sfp_check_state(struct sfp *
|
||||||
mutex_lock(&sfp->st_mutex);
|
mutex_lock(&sfp->st_mutex);
|
||||||
state = sfp_get_state(sfp);
|
state = sfp_get_state(sfp);
|
||||||
changed = state ^ sfp->state;
|
changed = state ^ sfp->state;
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
--- a/drivers/net/phy/sfp.c
|
||||||
|
+++ b/drivers/net/phy/sfp.c
|
||||||
|
@@ -366,6 +366,10 @@ static const struct sfp_quirk sfp_quirks
|
||||||
|
.part = "HL-GSFP",
|
||||||
|
.fixup = sfp_fixup_halny_gsfp,
|
||||||
|
}, {
|
||||||
|
+ .vendor = "HG GENUINE",
|
||||||
|
+ .part = "MXPD-483II",
|
||||||
|
+ .modes = sfp_quirk_2500basex,
|
||||||
|
+ }, {
|
||||||
|
// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd
|
||||||
|
// NRZ in their EEPROM
|
||||||
|
.vendor = "HUAWEI",
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
From 312753d0aadba0f58841ae513b80fdbabc887523 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Chukun Pan <amadeus@jmu.edu.cn>
|
||||||
|
Date: Wed, 8 Feb 2023 16:32:18 +0800
|
||||||
|
Subject: [PATCH] net: phy: realtek: support switching between SGMII and
|
||||||
|
2500BASE-X for RTL822x series
|
||||||
|
|
||||||
|
After commit ace6aba ("net: phy: realtek: rtl8221: allow to configure
|
||||||
|
SERDES mode"), the rtl8221 phy can work in SGMII and 2500base-x modes
|
||||||
|
respectively. So add interface automatic switching for rtl8221 phy to
|
||||||
|
match various wire speeds.
|
||||||
|
|
||||||
|
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
|
||||||
|
---
|
||||||
|
drivers/net/phy/realtek.c | 26 ++++++++++++++++++++++++--
|
||||||
|
1 file changed, 24 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
--- a/drivers/net/phy/realtek.c
|
||||||
|
+++ b/drivers/net/phy/realtek.c
|
||||||
|
@@ -676,6 +676,25 @@ static int rtl822x_config_aneg(struct ph
|
||||||
|
return __genphy_config_aneg(phydev, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void rtl822x_update_interface(struct phy_device *phydev)
|
||||||
|
+{
|
||||||
|
+ /* Automatically switch SERDES interface between
|
||||||
|
+ * SGMII and 2500-BaseX according to speed.
|
||||||
|
+ */
|
||||||
|
+ switch (phydev->speed) {
|
||||||
|
+ case SPEED_2500:
|
||||||
|
+ phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
|
||||||
|
+ break;
|
||||||
|
+ case SPEED_1000:
|
||||||
|
+ case SPEED_100:
|
||||||
|
+ case SPEED_10:
|
||||||
|
+ phydev->interface = PHY_INTERFACE_MODE_SGMII;
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int rtl822x_read_status(struct phy_device *phydev)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
@@ -694,11 +713,14 @@ static int rtl822x_read_status(struct ph
|
||||||
|
phydev->lp_advertising, lpadv & RTL_LPADV_2500FULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
- ret = genphy_read_status(phydev);
|
||||||
|
+ ret = rtlgen_read_status(phydev);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- return rtlgen_get_speed(phydev);
|
||||||
|
+ if (phydev->link)
|
||||||
|
+ rtl822x_update_interface(phydev);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool rtlgen_supports_2_5gbps(struct phy_device *phydev)
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
From 85cd45580f5e3b26068cccb7d6173f200e754dc0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Daniel Golle <daniel@makrotopia.org>
|
||||||
|
Date: Sun, 2 Apr 2023 23:56:16 +0100
|
||||||
|
Subject: [PATCH 1/2] net: phy: realtek: use genphy_soft_reset for 2.5G PHYs
|
||||||
|
|
||||||
|
Some vendor bootloaders do weird things with those PHYs which result in
|
||||||
|
link modes being reported wrongly. Start from a clean sheet by resetting
|
||||||
|
the PHY.
|
||||||
|
|
||||||
|
Reported-by: Yevhen Kolomeiko <jarvis2709@gmail.com>
|
||||||
|
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||||
|
---
|
||||||
|
drivers/net/phy/realtek.c | 6 ++++++
|
||||||
|
1 file changed, 6 insertions(+)
|
||||||
|
|
||||||
|
--- a/drivers/net/phy/realtek.c
|
||||||
|
+++ b/drivers/net/phy/realtek.c
|
||||||
|
@@ -1013,6 +1013,7 @@ static struct phy_driver realtek_drvs[]
|
||||||
|
.write_page = rtl821x_write_page,
|
||||||
|
.read_mmd = rtl822x_read_mmd,
|
||||||
|
.write_mmd = rtl822x_write_mmd,
|
||||||
|
+ .soft_reset = genphy_soft_reset,
|
||||||
|
}, {
|
||||||
|
PHY_ID_MATCH_EXACT(0x001cc840),
|
||||||
|
.name = "RTL8226B_RTL8221B 2.5Gbps PHY",
|
||||||
|
@@ -1025,6 +1026,7 @@ static struct phy_driver realtek_drvs[]
|
||||||
|
.write_page = rtl821x_write_page,
|
||||||
|
.read_mmd = rtl822x_read_mmd,
|
||||||
|
.write_mmd = rtl822x_write_mmd,
|
||||||
|
+ .soft_reset = genphy_soft_reset,
|
||||||
|
}, {
|
||||||
|
PHY_ID_MATCH_EXACT(0x001cc838),
|
||||||
|
.name = "RTL8226-CG 2.5Gbps PHY",
|
||||||
|
@@ -1035,6 +1037,7 @@ static struct phy_driver realtek_drvs[]
|
||||||
|
.resume = rtlgen_resume,
|
||||||
|
.read_page = rtl821x_read_page,
|
||||||
|
.write_page = rtl821x_write_page,
|
||||||
|
+ .soft_reset = genphy_soft_reset,
|
||||||
|
}, {
|
||||||
|
PHY_ID_MATCH_EXACT(0x001cc848),
|
||||||
|
.name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY",
|
||||||
|
@@ -1045,6 +1048,7 @@ static struct phy_driver realtek_drvs[]
|
||||||
|
.resume = rtlgen_resume,
|
||||||
|
.read_page = rtl821x_read_page,
|
||||||
|
.write_page = rtl821x_write_page,
|
||||||
|
+ .soft_reset = genphy_soft_reset,
|
||||||
|
}, {
|
||||||
|
PHY_ID_MATCH_EXACT(0x001cc849),
|
||||||
|
.name = "RTL8221B-VB-CG 2.5Gbps PHY",
|
||||||
|
@@ -1056,6 +1060,7 @@ static struct phy_driver realtek_drvs[]
|
||||||
|
.resume = rtlgen_resume,
|
||||||
|
.read_page = rtl821x_read_page,
|
||||||
|
.write_page = rtl821x_write_page,
|
||||||
|
+ .soft_reset = genphy_soft_reset,
|
||||||
|
}, {
|
||||||
|
PHY_ID_MATCH_EXACT(0x001cc84a),
|
||||||
|
.name = "RTL8221B-VM-CG 2.5Gbps PHY",
|
||||||
|
@@ -1067,6 +1072,7 @@ static struct phy_driver realtek_drvs[]
|
||||||
|
.resume = rtlgen_resume,
|
||||||
|
.read_page = rtl821x_read_page,
|
||||||
|
.write_page = rtl821x_write_page,
|
||||||
|
+ .soft_reset = genphy_soft_reset,
|
||||||
|
}, {
|
||||||
|
PHY_ID_MATCH_EXACT(0x001cc961),
|
||||||
|
.name = "RTL8366RB Gigabit Ethernet",
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
From 2b1b8c4c215af7988136401c902338d091d408a1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Daniel Golle <daniel@makrotopia.org>
|
||||||
|
Date: Mon, 3 Apr 2023 01:21:57 +0300
|
||||||
|
Subject: [PATCH 2/2] net: phy: realtek: disable SGMII in-band AN for 2.5G PHYs
|
||||||
|
|
||||||
|
MAC drivers don't use SGMII in-band autonegotiation unless told to do so
|
||||||
|
in device tree using 'managed = "in-band-status"'. When using MDIO to
|
||||||
|
access a PHY, in-band-status is unneeded as we have link-status via
|
||||||
|
MDIO. Switch off SGMII in-band autonegotiation using magic values.
|
||||||
|
|
||||||
|
Reported-by: Chen Minqiang <ptpt52@gmail.com>
|
||||||
|
Reported-by: Chukun Pan <amadeus@jmu.edu.cn>
|
||||||
|
Reported-by: Yevhen Kolomeiko <jarvis2709@gmail.com>
|
||||||
|
Tested-by: Yevhen Kolomeiko <jarvis2709@gmail.com>
|
||||||
|
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||||
|
---
|
||||||
|
drivers/net/phy/realtek.c | 8 ++++++++
|
||||||
|
1 file changed, 8 insertions(+)
|
||||||
|
|
||||||
|
--- a/drivers/net/phy/realtek.c
|
||||||
|
+++ b/drivers/net/phy/realtek.c
|
||||||
|
@@ -875,6 +875,7 @@ static irqreturn_t rtl9000a_handle_inter
|
||||||
|
static int rtl8221b_config_init(struct phy_device *phydev)
|
||||||
|
{
|
||||||
|
u16 option_mode;
|
||||||
|
+ int val;
|
||||||
|
|
||||||
|
switch (phydev->interface) {
|
||||||
|
case PHY_INTERFACE_MODE_SGMII:
|
||||||
|
@@ -906,6 +907,13 @@ static int rtl8221b_config_init(struct p
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* Disable SGMII AN */
|
||||||
|
+ phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7588, 0x2);
|
||||||
|
+ phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7589, 0x71d0);
|
||||||
|
+ phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587, 0x3);
|
||||||
|
+ phy_read_mmd_poll_timeout(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587, val,
|
||||||
|
+ !(val & BIT(0)), 500, 100000, false);
|
||||||
|
+
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@ -94,7 +94,12 @@ platform_do_upgrade_linksys() {
|
|||||||
|
|
||||||
|
|
||||||
# complete std upgrade
|
# complete std upgrade
|
||||||
nand_upgrade_tar "$1"
|
if nand_upgrade_tar "$1" ; then
|
||||||
|
nand_do_upgrade_success
|
||||||
|
else
|
||||||
|
nand_do_upgrade_failure
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
[ "$magic_long" = "27051956" ] && {
|
[ "$magic_long" = "27051956" ] && {
|
||||||
get_image "$1" | mtd write - $part_label
|
get_image "$1" | mtd write - $part_label
|
||||||
|
|||||||
@ -15,7 +15,7 @@ DEFAULT_PACKAGES += \
|
|||||||
kmod-usb3 kmod-usb-dwc3 kmod-usb-dwc3-qcom \
|
kmod-usb3 kmod-usb-dwc3 kmod-usb-dwc3-qcom \
|
||||||
kmod-leds-gpio kmod-gpio-button-hotplug \
|
kmod-leds-gpio kmod-gpio-button-hotplug \
|
||||||
kmod-qca-nss-dp qca-ssdk-shell kmod-phy-aquantia \
|
kmod-qca-nss-dp qca-ssdk-shell kmod-phy-aquantia \
|
||||||
ath11k-firmware-ipq8074 kmod-ath11k-ahb \
|
ath11k-firmware-ipq8074 kmod-ath11k-ahb wpad-openssl \
|
||||||
wpad-openssl uboot-envtools
|
uboot-envtools automount
|
||||||
|
|
||||||
$(eval $(call BuildTarget))
|
$(eval $(call BuildTarget))
|
||||||
|
|||||||
@ -18,7 +18,7 @@ redmi,ax6|\
|
|||||||
redmi,ax6-stock|\
|
redmi,ax6-stock|\
|
||||||
xiaomi,ax3600|\
|
xiaomi,ax3600|\
|
||||||
xiaomi,ax3600-stock)
|
xiaomi,ax3600-stock)
|
||||||
ucidef_set_led_netdev "wan" "WAN" "blue:network" "wan"
|
ucidef_set_led_netdev "wan" "WAN" "blue:network" "wan" "link"
|
||||||
;;
|
;;
|
||||||
qnap,301w)
|
qnap,301w)
|
||||||
ucidef_set_led_netdev "lan1" "LAN1" "green:lan1" "lan1"
|
ucidef_set_led_netdev "lan1" "LAN1" "green:lan1" "lan1"
|
||||||
|
|||||||
@ -107,7 +107,7 @@ define Device/redmi_ax6
|
|||||||
$(call Device/xiaomi_ax3600)
|
$(call Device/xiaomi_ax3600)
|
||||||
DEVICE_VENDOR := Redmi
|
DEVICE_VENDOR := Redmi
|
||||||
DEVICE_MODEL := AX6
|
DEVICE_MODEL := AX6
|
||||||
DEVICE_PACKAGES := ipq-wifi-redmi_ax6 -kmod-usb3 -kmod-usb-dwc3 -kmod-usb-dwc3-qcom
|
DEVICE_PACKAGES := ipq-wifi-redmi_ax6 -kmod-usb3 -kmod-usb-dwc3 -kmod-usb-dwc3-qcom -automount
|
||||||
endef
|
endef
|
||||||
TARGET_DEVICES += redmi_ax6
|
TARGET_DEVICES += redmi_ax6
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ define Device/xiaomi_ax3600
|
|||||||
SOC := ipq8071
|
SOC := ipq8071
|
||||||
KERNEL_SIZE := 36608k
|
KERNEL_SIZE := 36608k
|
||||||
DEVICE_PACKAGES := ipq-wifi-xiaomi_ax3600 kmod-ath10k-ct-smallbuffers ath10k-firmware-qca9887-ct \
|
DEVICE_PACKAGES := ipq-wifi-xiaomi_ax3600 kmod-ath10k-ct-smallbuffers ath10k-firmware-qca9887-ct \
|
||||||
-kmod-usb3 -kmod-usb-dwc3 -kmod-usb-dwc3-qcom
|
-kmod-usb3 -kmod-usb-dwc3 -kmod-usb-dwc3-qcom -automount
|
||||||
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
|
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
|
||||||
ARTIFACTS := initramfs-factory.ubi
|
ARTIFACTS := initramfs-factory.ubi
|
||||||
ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-uImage.itb | ubinize-kernel
|
ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-uImage.itb | ubinize-kernel
|
||||||
|
|||||||
@ -49,22 +49,31 @@ define Build/fullimage
|
|||||||
rm $@.tmp
|
rm $@.tmp
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/loader-okli-compile
|
define Build/loader-common
|
||||||
rm -rf $@.src
|
rm -rf $@.src
|
||||||
$(MAKE) -C lzma-loader \
|
$(MAKE) -C lzma-loader \
|
||||||
PKG_BUILD_DIR="$@.src" \
|
PKG_BUILD_DIR="$@.src" \
|
||||||
TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
|
TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
|
||||||
PLATFORM="lantiq" \
|
BOARD="$(BOARDNAME)" PLATFORM="lantiq" \
|
||||||
LZMA_TEXT_START=0x82000000 \
|
LZMA_TEXT_START=0x82000000 \
|
||||||
LOADADDR=0x80002000 \
|
LOADADDR=0x80002000 \
|
||||||
FLASH_START=0x10000000 \
|
|
||||||
FLASH_OFFS=$(LOADER_FLASH_OFFS) \
|
|
||||||
FLASH_MAX=0x0 \
|
|
||||||
$(1) compile loader.bin
|
$(1) compile loader.bin
|
||||||
mv "$@.bin" "$@"
|
mv "$@.bin" "$@"
|
||||||
rm -rf $@.src
|
rm -rf $@.src
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define Build/loader-kernel
|
||||||
|
$(call Build/loader-common,LOADER_DATA="$@")
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/loader-okli-compile
|
||||||
|
$(call Build/loader-common, \
|
||||||
|
FLASH_START=0x10000000 \
|
||||||
|
FLASH_OFFS=$(LOADER_FLASH_OFFS) \
|
||||||
|
FLASH_MAX=0x0 \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
define Build/prepend-loader-okli
|
define Build/prepend-loader-okli
|
||||||
cat "$(KDIR)/loader-$(word 1,$(1)).bin" "$@" >> "$@.new"
|
cat "$(KDIR)/loader-$(word 1,$(1)).bin" "$@" >> "$@.new"
|
||||||
mv "$@.new" "$@"
|
mv "$@.new" "$@"
|
||||||
|
|||||||
@ -90,6 +90,8 @@ define Device/netgear_dgn3500
|
|||||||
DEVICE_MODEL := DGN3500
|
DEVICE_MODEL := DGN3500
|
||||||
SOC := ar9
|
SOC := ar9
|
||||||
IMAGE_SIZE := 16000k
|
IMAGE_SIZE := 16000k
|
||||||
|
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
|
||||||
|
KERNEL_INITRAMFS := $$(KERNEL)
|
||||||
IMAGES := \
|
IMAGES := \
|
||||||
sysupgrade-na.bin sysupgrade.bin \
|
sysupgrade-na.bin sysupgrade.bin \
|
||||||
factory-na.img factory.img
|
factory-na.img factory.img
|
||||||
@ -121,6 +123,8 @@ define Device/netgear_dgn3500b
|
|||||||
DEVICE_MODEL := DGN3500B
|
DEVICE_MODEL := DGN3500B
|
||||||
SOC := ar9
|
SOC := ar9
|
||||||
IMAGE_SIZE := 16000k
|
IMAGE_SIZE := 16000k
|
||||||
|
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
|
||||||
|
KERNEL_INITRAMFS := $$(KERNEL)
|
||||||
IMAGES += factory.img
|
IMAGES += factory.img
|
||||||
IMAGE/sysupgrade.bin := \
|
IMAGE/sysupgrade.bin := \
|
||||||
append-kernel | append-rootfs | dgn3500-sercom-footer 0x0 "DE" | \
|
append-kernel | append-rootfs | dgn3500-sercom-footer 0x0 "DE" | \
|
||||||
|
|||||||
@ -0,0 +1,38 @@
|
|||||||
|
From 416f25a948d11ef15733f2e31658d31b5cc7bef6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Thomas Nixon <tom@tomn.co.uk>
|
||||||
|
Date: Sun, 26 Mar 2023 11:08:49 +0100
|
||||||
|
Subject: [PATCH] mtd: rawnand: xway: don't yield while holding spinlock
|
||||||
|
|
||||||
|
The nand driver normally while waiting for the device to become ready;
|
||||||
|
this is normally fine, but xway_nand holds the ebu_lock spinlock, and
|
||||||
|
this can cause lockups if other threads which use ebu_lock are
|
||||||
|
interleaved. Fix this by waiting instead of polling.
|
||||||
|
|
||||||
|
This mainly showed up as crashes in ath9k_pci_owl_loader (see
|
||||||
|
https://github.com/openwrt/openwrt/issues/9829 ), but turning on
|
||||||
|
spinlock debugging shows this happening in other places too.
|
||||||
|
|
||||||
|
This doesn't seem to measurably impact boot time.
|
||||||
|
|
||||||
|
Signed-off-by: Thomas Nixon <tom@tomn.co.uk>
|
||||||
|
---
|
||||||
|
drivers/mtd/nand/raw/xway_nand.c | 8 +++++++-
|
||||||
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
--- a/drivers/mtd/nand/raw/xway_nand.c
|
||||||
|
+++ b/drivers/mtd/nand/raw/xway_nand.c
|
||||||
|
@@ -175,7 +175,13 @@ static void xway_cmd_ctrl(struct nand_ch
|
||||||
|
|
||||||
|
static int xway_dev_ready(struct nand_chip *chip)
|
||||||
|
{
|
||||||
|
- return ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_RD;
|
||||||
|
+ /*
|
||||||
|
+ * wait until ready, as otherwise the driver will yield in nand_wait or
|
||||||
|
+ * nand_wait_ready, which is a bad idea when we're holding ebu_lock
|
||||||
|
+ */
|
||||||
|
+ while ((ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_RD) == 0)
|
||||||
|
+ cpu_relax();
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char xway_read_byte(struct nand_chip *chip)
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
From 416f25a948d11ef15733f2e31658d31b5cc7bef6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Thomas Nixon <tom@tomn.co.uk>
|
||||||
|
Date: Sun, 26 Mar 2023 11:08:49 +0100
|
||||||
|
Subject: [PATCH] mtd: rawnand: xway: don't yield while holding spinlock
|
||||||
|
|
||||||
|
The nand driver normally while waiting for the device to become ready;
|
||||||
|
this is normally fine, but xway_nand holds the ebu_lock spinlock, and
|
||||||
|
this can cause lockups if other threads which use ebu_lock are
|
||||||
|
interleaved. Fix this by waiting instead of polling.
|
||||||
|
|
||||||
|
This mainly showed up as crashes in ath9k_pci_owl_loader (see
|
||||||
|
https://github.com/openwrt/openwrt/issues/9829 ), but turning on
|
||||||
|
spinlock debugging shows this happening in other places too.
|
||||||
|
|
||||||
|
This doesn't seem to measurably impact boot time.
|
||||||
|
|
||||||
|
Signed-off-by: Thomas Nixon <tom@tomn.co.uk>
|
||||||
|
---
|
||||||
|
drivers/mtd/nand/raw/xway_nand.c | 8 +++++++-
|
||||||
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
--- a/drivers/mtd/nand/raw/xway_nand.c
|
||||||
|
+++ b/drivers/mtd/nand/raw/xway_nand.c
|
||||||
|
@@ -175,7 +175,13 @@ static void xway_cmd_ctrl(struct nand_ch
|
||||||
|
|
||||||
|
static int xway_dev_ready(struct nand_chip *chip)
|
||||||
|
{
|
||||||
|
- return ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_RD;
|
||||||
|
+ /*
|
||||||
|
+ * wait until ready, as otherwise the driver will yield in nand_wait or
|
||||||
|
+ * nand_wait_ready, which is a bad idea when we're holding ebu_lock
|
||||||
|
+ */
|
||||||
|
+ while ((ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_RD) == 0)
|
||||||
|
+ cpu_relax();
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char xway_read_byte(struct nand_chip *chip)
|
||||||
@ -6,6 +6,11 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
include $(INCLUDE_DIR)/image.mk
|
include $(INCLUDE_DIR)/image.mk
|
||||||
|
|
||||||
|
loadaddr-$(CONFIG_TARGET_mediatek_mt7622) := 0x44000000
|
||||||
|
loadaddr-$(CONFIG_TARGET_mediatek_mt7623) := 0x80008000
|
||||||
|
loadaddr-$(CONFIG_TARGET_mediatek_mt7629) := 0x40008000
|
||||||
|
loadaddr-$(CONFIG_TARGET_mediatek_filogic) := 0x48000000
|
||||||
|
|
||||||
# default all platform image(fit) build
|
# default all platform image(fit) build
|
||||||
define Device/Default
|
define Device/Default
|
||||||
PROFILES = Default $$(DEVICE_NAME)
|
PROFILES = Default $$(DEVICE_NAME)
|
||||||
@ -14,6 +19,7 @@ define Device/Default
|
|||||||
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
|
||||||
KERNEL_INITRAMFS = kernel-bin | lzma | \
|
KERNEL_INITRAMFS = kernel-bin | lzma | \
|
||||||
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
|
||||||
|
KERNEL_LOADADDR = $(loadaddr-y)
|
||||||
FILESYSTEMS := squashfs
|
FILESYSTEMS := squashfs
|
||||||
DEVICE_DTS_DIR := $(DTS_DIR)
|
DEVICE_DTS_DIR := $(DTS_DIR)
|
||||||
IMAGES := sysupgrade.bin
|
IMAGES := sysupgrade.bin
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
DTS_DIR := $(DTS_DIR)/mediatek
|
DTS_DIR := $(DTS_DIR)/mediatek
|
||||||
|
|
||||||
KERNEL_LOADADDR := 0x44000000
|
|
||||||
|
|
||||||
define Image/Prepare
|
define Image/Prepare
|
||||||
# For UBI we want only one extra block
|
# For UBI we want only one extra block
|
||||||
rm -f $(KDIR)/ubi_mark
|
rm -f $(KDIR)/ubi_mark
|
||||||
@ -46,8 +44,7 @@ define Device/asus_tuf-ax4200
|
|||||||
DEVICE_DTS_LOADADDR := 0x47000000
|
DEVICE_DTS_LOADADDR := 0x47000000
|
||||||
DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware
|
DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware
|
||||||
IMAGES := sysupgrade.bin
|
IMAGES := sysupgrade.bin
|
||||||
KERNEL_LOADADDR := 0x48000000
|
KERNEL := kernel-bin | lzma | \
|
||||||
KERNEL = kernel-bin | lzma | \
|
|
||||||
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
|
||||||
KERNEL_INITRAMFS := kernel-bin | lzma | \
|
KERNEL_INITRAMFS := kernel-bin | lzma | \
|
||||||
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
|
||||||
@ -65,6 +62,7 @@ define Device/bananapi_bpi-r3
|
|||||||
DEVICE_DTS_DIR := ../dts
|
DEVICE_DTS_DIR := ../dts
|
||||||
DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-gpio kmod-mt7986-firmware kmod-sfp kmod-usb3 e2fsprogs f2fsck mkf2fs mt7986-wo-firmware
|
DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-gpio kmod-mt7986-firmware kmod-sfp kmod-usb3 e2fsprogs f2fsck mkf2fs mt7986-wo-firmware
|
||||||
IMAGES := sysupgrade.itb
|
IMAGES := sysupgrade.itb
|
||||||
|
KERNEL_LOADADDR := 0x44000000
|
||||||
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
|
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
|
||||||
ARTIFACTS := \
|
ARTIFACTS := \
|
||||||
emmc-preloader.bin emmc-bl31-uboot.fip \
|
emmc-preloader.bin emmc-bl31-uboot.fip \
|
||||||
@ -108,7 +106,6 @@ define Device/mediatek_mt7986a-rfb-nand
|
|||||||
DEVICE_DTS := mt7986a-rfb-spim-nand
|
DEVICE_DTS := mt7986a-rfb-spim-nand
|
||||||
DEVICE_DTS_DIR := $(DTS_DIR)/
|
DEVICE_DTS_DIR := $(DTS_DIR)/
|
||||||
DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware
|
DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware
|
||||||
KERNEL_LOADADDR := 0x48000000
|
|
||||||
SUPPORTED_DEVICES := mediatek,mt7986a-rfb-snand
|
SUPPORTED_DEVICES := mediatek,mt7986a-rfb-snand
|
||||||
UBINIZE_OPTS := -E 5
|
UBINIZE_OPTS := -E 5
|
||||||
BLOCKSIZE := 128k
|
BLOCKSIZE := 128k
|
||||||
@ -132,7 +129,6 @@ define Device/mediatek_mt7986b-rfb
|
|||||||
DEVICE_DTS := mt7986b-rfb
|
DEVICE_DTS := mt7986b-rfb
|
||||||
DEVICE_DTS_DIR := $(DTS_DIR)/
|
DEVICE_DTS_DIR := $(DTS_DIR)/
|
||||||
DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware
|
DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware
|
||||||
KERNEL_LOADADDR := 0x48000000
|
|
||||||
SUPPORTED_DEVICES := mediatek,mt7986b-rfb
|
SUPPORTED_DEVICES := mediatek,mt7986b-rfb
|
||||||
UBINIZE_OPTS := -E 5
|
UBINIZE_OPTS := -E 5
|
||||||
BLOCKSIZE := 128k
|
BLOCKSIZE := 128k
|
||||||
@ -166,7 +162,6 @@ define Device/xiaomi_redmi-router-ax6000-stock
|
|||||||
DEVICE_DTS := mt7986a-xiaomi-redmi-router-ax6000-stock
|
DEVICE_DTS := mt7986a-xiaomi-redmi-router-ax6000-stock
|
||||||
DEVICE_DTS_DIR := ../dts
|
DEVICE_DTS_DIR := ../dts
|
||||||
DEVICE_PACKAGES := kmod-leds-ws2812b kmod-mt7986-firmware mt7986-wo-firmware
|
DEVICE_PACKAGES := kmod-leds-ws2812b kmod-mt7986-firmware mt7986-wo-firmware
|
||||||
KERNEL_LOADADDR := 0x48000000
|
|
||||||
UBINIZE_OPTS := -E 5
|
UBINIZE_OPTS := -E 5
|
||||||
BLOCKSIZE := 128k
|
BLOCKSIZE := 128k
|
||||||
PAGESIZE := 2048
|
PAGESIZE := 2048
|
||||||
@ -186,7 +181,6 @@ define Device/xiaomi_redmi-router-ax6000-ubootmod
|
|||||||
DEVICE_PACKAGES := kmod-leds-ws2812b kmod-mt7986-firmware mt7986-wo-firmware
|
DEVICE_PACKAGES := kmod-leds-ws2812b kmod-mt7986-firmware mt7986-wo-firmware
|
||||||
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
|
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
|
||||||
IMAGES := sysupgrade.itb
|
IMAGES := sysupgrade.itb
|
||||||
KERNEL_LOADADDR := 0x48000000
|
|
||||||
UBINIZE_OPTS := -E 5
|
UBINIZE_OPTS := -E 5
|
||||||
BLOCKSIZE := 128k
|
BLOCKSIZE := 128k
|
||||||
PAGESIZE := 2048
|
PAGESIZE := 2048
|
||||||
|
|||||||
@ -1,11 +1,5 @@
|
|||||||
DTS_DIR := $(DTS_DIR)/mediatek
|
DTS_DIR := $(DTS_DIR)/mediatek
|
||||||
|
|
||||||
ifdef CONFIG_LINUX_5_4
|
|
||||||
KERNEL_LOADADDR := 0x44080000
|
|
||||||
else
|
|
||||||
KERNEL_LOADADDR := 0x44000000
|
|
||||||
endif
|
|
||||||
|
|
||||||
define Image/Prepare
|
define Image/Prepare
|
||||||
# For UBI we want only one extra block
|
# For UBI we want only one extra block
|
||||||
rm -f $(KDIR)/ubi_mark
|
rm -f $(KDIR)/ubi_mark
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
KERNEL_LOADADDR := 0x80008000
|
|
||||||
DEVICE_VARS += UBOOT_TARGET UBOOT_OFFSET UBOOT_IMAGE
|
DEVICE_VARS += UBOOT_TARGET UBOOT_OFFSET UBOOT_IMAGE
|
||||||
|
|
||||||
# The bootrom of MT7623 expects legacy MediaTek headers present in
|
# The bootrom of MT7623 expects legacy MediaTek headers present in
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
KERNEL_LOADADDR := 0x40008000
|
|
||||||
|
|
||||||
define Device/mediatek_mt7629-rfb
|
define Device/mediatek_mt7629-rfb
|
||||||
DEVICE_VENDOR := MediaTek
|
DEVICE_VENDOR := MediaTek
|
||||||
DEVICE_MODEL := MT7629 rfb AP
|
DEVICE_MODEL := MT7629 rfb AP
|
||||||
|
|||||||
@ -7,6 +7,11 @@ preinit_set_mac_address() {
|
|||||||
ip link set dev eth0 address $(mtd_get_mac_ascii cfg1 ethaddr)
|
ip link set dev eth0 address $(mtd_get_mac_ascii cfg1 ethaddr)
|
||||||
ip link set dev eth1 address $(mtd_get_mac_ascii cfg1 eth1addr)
|
ip link set dev eth1 address $(mtd_get_mac_ascii cfg1 eth1addr)
|
||||||
;;
|
;;
|
||||||
|
watchguard,firebox-t10)
|
||||||
|
ip link set dev eth0 address "$(mtd_get_mac_text "device_id" 0x1830)"
|
||||||
|
ip link set dev eth1 address "$(mtd_get_mac_text "device_id" 0x1844)"
|
||||||
|
ip link set dev eth2 address "$(mtd_get_mac_text "device_id" 0x1858)"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
129
target/linux/ramips/dts/mt7628an_oraybox_x1.dts
Normal file
129
target/linux/ramips/dts/mt7628an_oraybox_x1.dts
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "mt7628an.dtsi"
|
||||||
|
|
||||||
|
#include <dt-bindings/gpio/gpio.h>
|
||||||
|
#include <dt-bindings/input/input.h>
|
||||||
|
|
||||||
|
/ {
|
||||||
|
compatible = "oraybox,x1", "mediatek,mt7628an-soc";
|
||||||
|
model = "OrayBox X1";
|
||||||
|
|
||||||
|
aliases {
|
||||||
|
led-boot = &led_status_white;
|
||||||
|
led-failsafe = &led_status_red;
|
||||||
|
led-running = &led_status_white;
|
||||||
|
led-upgrade = &led_status_red;
|
||||||
|
};
|
||||||
|
|
||||||
|
chosen {
|
||||||
|
bootargs = "console=ttyS0,115200";
|
||||||
|
};
|
||||||
|
|
||||||
|
leds {
|
||||||
|
compatible = "gpio-leds";
|
||||||
|
|
||||||
|
led_status_blue: status-blue {
|
||||||
|
label = "blue:status";
|
||||||
|
gpios = <&gpio 37 GPIO_ACTIVE_HIGH>;
|
||||||
|
};
|
||||||
|
|
||||||
|
led_status_red: status-red {
|
||||||
|
label = "red:status";
|
||||||
|
gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
|
||||||
|
};
|
||||||
|
|
||||||
|
led_status_white: status-white {
|
||||||
|
label = "white:status";
|
||||||
|
gpios = <&gpio 44 GPIO_ACTIVE_HIGH>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
keys {
|
||||||
|
compatible = "gpio-keys";
|
||||||
|
|
||||||
|
reset {
|
||||||
|
label = "reset";
|
||||||
|
gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
|
||||||
|
linux,code = <KEY_RESTART>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&spi0 {
|
||||||
|
status = "okay";
|
||||||
|
|
||||||
|
flash@0 {
|
||||||
|
compatible = "jedec,spi-nor";
|
||||||
|
reg = <0>;
|
||||||
|
spi-max-frequency = <40000000>;
|
||||||
|
|
||||||
|
partitions {
|
||||||
|
compatible = "fixed-partitions";
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
|
partition@0 {
|
||||||
|
label = "u-boot";
|
||||||
|
reg = <0x0 0x30000>;
|
||||||
|
read-only;
|
||||||
|
};
|
||||||
|
|
||||||
|
partition@30000 {
|
||||||
|
label = "kpanic";
|
||||||
|
reg = <0x30000 0x10000>;
|
||||||
|
read-only;
|
||||||
|
};
|
||||||
|
|
||||||
|
partition@40000 {
|
||||||
|
label = "factory";
|
||||||
|
reg = <0x40000 0x10000>;
|
||||||
|
read-only;
|
||||||
|
};
|
||||||
|
|
||||||
|
partition@50000 {
|
||||||
|
compatible = "denx,uimage";
|
||||||
|
label = "firmware";
|
||||||
|
reg = <0x50000 0xf00000>;
|
||||||
|
};
|
||||||
|
|
||||||
|
bdinfo: partition@fe0000 {
|
||||||
|
label = "bdinfo";
|
||||||
|
reg = <0xfe0000 0x10000>;
|
||||||
|
read-only;
|
||||||
|
};
|
||||||
|
|
||||||
|
partition@ff0000 {
|
||||||
|
label = "reserve";
|
||||||
|
reg = <0xff0000 0x10000>;
|
||||||
|
read-only;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&state_default {
|
||||||
|
gpio {
|
||||||
|
groups = "jtag", "wdt";
|
||||||
|
function = "gpio";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
ðernet {
|
||||||
|
nvmem-cells = <&macaddr_bdinfo_9>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
|
};
|
||||||
|
|
||||||
|
&wmac {
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
&bdinfo {
|
||||||
|
compatible = "nvmem-cells";
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
|
macaddr_bdinfo_9: macaddr@9 {
|
||||||
|
reg = <0x9 0x6>;
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -475,6 +475,14 @@ define Device/onion_omega2p
|
|||||||
endef
|
endef
|
||||||
TARGET_DEVICES += onion_omega2p
|
TARGET_DEVICES += onion_omega2p
|
||||||
|
|
||||||
|
define Device/oraybox_x1
|
||||||
|
IMAGE_SIZE := 15360k
|
||||||
|
DEVICE_VENDOR := OrayBox
|
||||||
|
DEVICE_MODEL := X1
|
||||||
|
DEVICE_PACKAGES:= kmod-usb2 kmod-usb-ohci
|
||||||
|
endef
|
||||||
|
TARGET_DEVICES += oraybox_x1
|
||||||
|
|
||||||
define Device/rakwireless_rak633
|
define Device/rakwireless_rak633
|
||||||
IMAGE_SIZE := 7872k
|
IMAGE_SIZE := 7872k
|
||||||
DEVICE_VENDOR := Rakwireless
|
DEVICE_VENDOR := Rakwireless
|
||||||
|
|||||||
@ -59,6 +59,9 @@ keenetic,kn-1613)
|
|||||||
mediatek,linkit-smart-7688)
|
mediatek,linkit-smart-7688)
|
||||||
ucidef_set_led_wlan "wifi" "wifi" "orange:wifi" "phy0tpt"
|
ucidef_set_led_wlan "wifi" "wifi" "orange:wifi" "phy0tpt"
|
||||||
;;
|
;;
|
||||||
|
oraybox,x1)
|
||||||
|
ucidef_set_led_netdev "wifi" "wifi" "blue:status" "wlan0"
|
||||||
|
;;
|
||||||
rakwireless,rak633)
|
rakwireless,rak633)
|
||||||
ucidef_set_led_netdev "wifi_led" "wifi" "blue:wifi" "wlan0"
|
ucidef_set_led_netdev "wifi_led" "wifi" "blue:wifi" "wlan0"
|
||||||
;;
|
;;
|
||||||
|
|||||||
@ -141,6 +141,10 @@ ramips_setup_interfaces()
|
|||||||
ucidef_add_switch "switch0" \
|
ucidef_add_switch "switch0" \
|
||||||
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
|
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
|
||||||
;;
|
;;
|
||||||
|
oraybox,x1)
|
||||||
|
ucidef_add_switch "switch0" \
|
||||||
|
"3:lan" "6@eth0"
|
||||||
|
;;
|
||||||
rakwireless,rak633)
|
rakwireless,rak633)
|
||||||
ucidef_add_switch "switch0" \
|
ucidef_add_switch "switch0" \
|
||||||
"0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
|
"0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
|
||||||
|
|||||||
@ -10,7 +10,7 @@ Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
|
|||||||
|
|
||||||
--- a/drivers/net/phy/sfp.c
|
--- a/drivers/net/phy/sfp.c
|
||||||
+++ b/drivers/net/phy/sfp.c
|
+++ b/drivers/net/phy/sfp.c
|
||||||
@@ -2147,6 +2147,13 @@ static void sfp_sm_module(struct sfp *sf
|
@@ -2151,6 +2151,13 @@ static void sfp_sm_module(struct sfp *sf
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
|
|||||||
|
|
||||||
--- a/drivers/net/phy/sfp.c
|
--- a/drivers/net/phy/sfp.c
|
||||||
+++ b/drivers/net/phy/sfp.c
|
+++ b/drivers/net/phy/sfp.c
|
||||||
@@ -539,32 +539,72 @@ static int sfp_i2c_write(struct sfp *sfp
|
@@ -543,32 +543,72 @@ static int sfp_i2c_write(struct sfp *sfp
|
||||||
return ret == ARRAY_SIZE(msgs) ? len : 0;
|
return ret == ARRAY_SIZE(msgs) ? len : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
tools/7z/patches/7-zip-flags.patch
Normal file
27
tools/7z/patches/7-zip-flags.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
--- a/CPP/7zip/7zip_gcc.mak
|
||||||
|
+++ b/CPP/7zip/7zip_gcc.mak
|
||||||
|
@@ -18,13 +18,13 @@ PROGPATH_STATIC = $(O)/$(PROG)s
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(CC), xlc)
|
||||||
|
-CFLAGS_WARN_WALL = -Wall -Werror -Wextra
|
||||||
|
+CFLAGS_WARN_WALL = -Wall -Wextra
|
||||||
|
endif
|
||||||
|
|
||||||
|
# for object file
|
||||||
|
CFLAGS_BASE_LIST = -c
|
||||||
|
# CFLAGS_BASE_LIST = -S
|
||||||
|
-CFLAGS_BASE = -O2 $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \
|
||||||
|
+CFLAGS_BASE = $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) -D_GNU_SOURCE \
|
||||||
|
-DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
|
||||||
|
-fPIC
|
||||||
|
|
||||||
|
@@ -192,7 +192,7 @@ all: $(O) $(PROGPATH) $(STATIC_TARGET)
|
||||||
|
$(O):
|
||||||
|
$(MY_MKDIR) $(O)
|
||||||
|
|
||||||
|
-LFLAGS_ALL = -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
|
||||||
|
+LFLAGS_ALL = $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
|
||||||
|
$(PROGPATH): $(OBJS)
|
||||||
|
$(CXX) -o $(PROGPATH) $(LFLAGS_ALL)
|
||||||
|
|
||||||
59
tools/7z/patches/7-zip-musl.patch
Normal file
59
tools/7z/patches/7-zip-musl.patch
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
--- a/C/CpuArch.c
|
||||||
|
+++ b/C/CpuArch.c
|
||||||
|
@@ -421,8 +421,6 @@ BoolInt CPU_IsSupported_AES (void) { ret
|
||||||
|
|
||||||
|
#ifdef USE_HWCAP
|
||||||
|
|
||||||
|
-#include <asm/hwcap.h>
|
||||||
|
-
|
||||||
|
#define MY_HWCAP_CHECK_FUNC_2(name1, name2) \
|
||||||
|
BoolInt CPU_IsSupported_ ## name1() { return (getauxval(AT_HWCAP) & (HWCAP_ ## name2)) ? 1 : 0; }
|
||||||
|
|
||||||
|
--- a/C/Threads.c
|
||||||
|
+++ b/C/Threads.c
|
||||||
|
@@ -257,7 +257,7 @@ WRes Thread_Create_With_CpuSet(CThread *
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ret2 =
|
||||||
|
- pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet);
|
||||||
|
+ //pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet);
|
||||||
|
// if (ret2) ret = ret2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@@ -267,14 +267,12 @@ WRes Thread_Create_With_CpuSet(CThread *
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
p->_created = 1;
|
||||||
|
- /*
|
||||||
|
if (cpuSet)
|
||||||
|
{
|
||||||
|
// ret2 =
|
||||||
|
pthread_setaffinity_np(p->_tid, sizeof(*cpuSet), cpuSet);
|
||||||
|
// if (ret2) ret = ret2;
|
||||||
|
}
|
||||||
|
- */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ret2 =
|
||||||
|
--- a/C/Threads.h
|
||||||
|
+++ b/C/Threads.h
|
||||||
|
@@ -19,6 +19,7 @@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
+#include <sched.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
--- a/CPP/Windows/SystemInfo.cpp
|
||||||
|
+++ b/CPP/Windows/SystemInfo.cpp
|
||||||
|
@@ -36,9 +36,6 @@
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
-#ifdef MY_CPU_ARM_OR_ARM64
|
||||||
|
-#include <asm/hwcap.h>
|
||||||
|
-#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
@ -5,14 +5,13 @@
|
|||||||
# See /LICENSE for more information.
|
# See /LICENSE for more information.
|
||||||
#
|
#
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
include $(INCLUDE_DIR)/target.mk
|
|
||||||
|
|
||||||
PKG_NAME:=ccache
|
PKG_NAME:=ccache
|
||||||
PKG_VERSION:=4.7.4
|
PKG_VERSION:=4.8
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||||
PKG_SOURCE_URL:=https://github.com/ccache/ccache/releases/download/v$(PKG_VERSION)
|
PKG_SOURCE_URL:=https://github.com/ccache/ccache/releases/download/v$(PKG_VERSION)
|
||||||
PKG_HASH:=df0c64d15d3efaf0b4f6837dd6b1467e40eeaaa807db25ce79c3a08a46a84e36
|
PKG_HASH:=b963ee3bf88d7266b8a0565e4ba685d5666357f0a7e364ed98adb0dc1191fcbb
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/host-build.mk
|
include $(INCLUDE_DIR)/host-build.mk
|
||||||
include $(INCLUDE_DIR)/cmake.mk
|
include $(INCLUDE_DIR)/cmake.mk
|
||||||
@ -22,10 +21,7 @@ CMAKE_HOST_OPTIONS += \
|
|||||||
-DCMAKE_CXX_COMPILER_LAUNCHER="" \
|
-DCMAKE_CXX_COMPILER_LAUNCHER="" \
|
||||||
-DCMAKE_SKIP_RPATH=FALSE \
|
-DCMAKE_SKIP_RPATH=FALSE \
|
||||||
-DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOST}/lib" \
|
-DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOST}/lib" \
|
||||||
|
-DENABLE_DOCUMENTATION=OFF
|
||||||
-DREDIS_STORAGE_BACKEND=OFF
|
-DREDIS_STORAGE_BACKEND=OFF
|
||||||
|
|
||||||
ifneq (docs-$(CONFIG_BUILD_DOCUMENTATION),docs-y)
|
|
||||||
CMAKE_HOST_OPTIONS += -DENABLE_DOCUMENTATION=OFF
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(eval $(call HostBuild))
|
$(eval $(call HostBuild))
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
--- a/src/ccache.cpp
|
--- a/src/ccache.cpp
|
||||||
+++ b/src/ccache.cpp
|
+++ b/src/ccache.cpp
|
||||||
@@ -1779,6 +1779,7 @@ get_manifest_key(Context& ctx, Hash& has
|
@@ -1813,6 +1813,7 @@ get_manifest_key(Context& ctx, Hash& has
|
||||||
"CPLUS_INCLUDE_PATH",
|
"CPLUS_INCLUDE_PATH",
|
||||||
"OBJC_INCLUDE_PATH",
|
"OBJC_INCLUDE_PATH",
|
||||||
"OBJCPLUS_INCLUDE_PATH", // clang
|
"OBJCPLUS_INCLUDE_PATH", // clang
|
||||||
|
|||||||
@ -8,14 +8,13 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=coreutils
|
PKG_NAME:=coreutils
|
||||||
PKG_CPE_ID:=cpe:/a:gnu:coreutils
|
PKG_CPE_ID:=cpe:/a:gnu:coreutils
|
||||||
PKG_VERSION:=9.1
|
PKG_VERSION:=9.2
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||||
PKG_SOURCE_URL:=@GNU/coreutils
|
PKG_SOURCE_URL:=@GNU/coreutils
|
||||||
PKG_HASH:=61a1f410d78ba7e7f37a5a4f50e6d1320aca33375484a3255eddf17a38580423
|
PKG_HASH:=6885ff47b9cdb211de47d368c17853f406daaf98b148aaecdf10de29cc04b0b3
|
||||||
|
|
||||||
HOST_BUILD_PARALLEL := 1
|
HOST_BUILD_PARALLEL := 1
|
||||||
PKG_FIXUP:=autoreconf
|
|
||||||
|
|
||||||
BUILD_PROGRAMS = date readlink touch ln chown ginstall
|
BUILD_PROGRAMS = date readlink touch ln chown ginstall
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,126 @@
|
|||||||
|
From 093a8b4bfaba60005f14493ce7ef11ed665a0176 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||||
|
Date: Thu, 23 Mar 2023 13:19:04 +0000
|
||||||
|
Subject: [PATCH] copy: fix --reflink=auto to fallback in more cases
|
||||||
|
|
||||||
|
On restricted systems like android or some containers,
|
||||||
|
FICLONE could return EPERM, EACCES, or ENOTTY,
|
||||||
|
which would have induced the command to fail to copy
|
||||||
|
rather than falling back to a more standard copy.
|
||||||
|
|
||||||
|
* src/copy.c (is_terminal_failure): A new function refactored
|
||||||
|
from handle_clone_fail().
|
||||||
|
(is_CLONENOTSUP): Merge in the handling of EACCES, ENOTTY, EPERM
|
||||||
|
as they also pertain to determination of whether cloning is supported
|
||||||
|
if we ever use this function in that context.
|
||||||
|
(handle_clone_fail): Use is_terminal_failure() in all cases,
|
||||||
|
so that we assume a terminal failure in less errno cases.
|
||||||
|
* NEWS: Mention the bug fix.
|
||||||
|
Addresses https://bugs.gnu.org/62404
|
||||||
|
---
|
||||||
|
--- a/src/copy.c
|
||||||
|
+++ b/src/copy.c
|
||||||
|
@@ -278,15 +278,27 @@ create_hole (int fd, char const *name, b
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-/* Whether the errno from FICLONE, or copy_file_range
|
||||||
|
- indicates operation is not supported for this file or file system. */
|
||||||
|
+/* Whether the errno indicates the operation is a transient failure.
|
||||||
|
+ I.e., a failure that would indicate the operation _is_ supported,
|
||||||
|
+ but has failed in a terminal way. */
|
||||||
|
+
|
||||||
|
+static bool
|
||||||
|
+is_terminal_error (int err)
|
||||||
|
+{
|
||||||
|
+ return err == EIO || err == ENOMEM || err == ENOSPC || err == EDQUOT;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+/* Whether the errno from FICLONE, or copy_file_range indicates
|
||||||
|
+ the operation is not supported/allowed for this file or process. */
|
||||||
|
|
||||||
|
static bool
|
||||||
|
is_CLONENOTSUP (int err)
|
||||||
|
{
|
||||||
|
- return err == ENOSYS || is_ENOTSUP (err)
|
||||||
|
+ return err == ENOSYS || err == ENOTTY || is_ENOTSUP (err)
|
||||||
|
|| err == EINVAL || err == EBADF
|
||||||
|
- || err == EXDEV || err == ETXTBSY;
|
||||||
|
+ || err == EXDEV || err == ETXTBSY
|
||||||
|
+ || err == EPERM || err == EACCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -339,20 +351,18 @@ sparse_copy (int src_fd, int dest_fd, ch
|
||||||
|
{
|
||||||
|
copy_debug.offload = COPY_DEBUG_UNSUPPORTED;
|
||||||
|
|
||||||
|
- if (is_CLONENOTSUP (errno))
|
||||||
|
- break;
|
||||||
|
-
|
||||||
|
- /* copy_file_range might not be enabled in seccomp filters,
|
||||||
|
- so retry with a standard copy. EPERM can also occur
|
||||||
|
- for immutable files, but that would only be in the edge case
|
||||||
|
- where the file is made immutable after creating/truncating,
|
||||||
|
+ /* Consider operation unsupported only if no data copied.
|
||||||
|
+ For example, EPERM could occur if copy_file_range not enabled
|
||||||
|
+ in seccomp filters, so retry with a standard copy. EPERM can
|
||||||
|
+ also occur for immutable files, but that would only be in the
|
||||||
|
+ edge case where the file is made immutable after creating,
|
||||||
|
in which case the (more accurate) error is still shown. */
|
||||||
|
- if (errno == EPERM && *total_n_read == 0)
|
||||||
|
+ if (*total_n_read == 0 && is_CLONENOTSUP (errno))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ENOENT was seen sometimes across CIFS shares, resulting in
|
||||||
|
no data being copied, but subsequent standard copies succeed. */
|
||||||
|
- if (errno == ENOENT && *total_n_read == 0)
|
||||||
|
+ if (*total_n_read == 0 && errno == ENOENT)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (errno == EINTR)
|
||||||
|
@@ -1172,17 +1182,15 @@ handle_clone_fail (int dst_dirfd, char c
|
||||||
|
char const* src_name, char const* dst_name,
|
||||||
|
int dest_desc, bool new_dst, enum Reflink_type reflink_mode)
|
||||||
|
{
|
||||||
|
- /* If the clone operation is creating the destination,
|
||||||
|
- then don't try and cater for all non transient file system errors,
|
||||||
|
- and instead only cater for specific transient errors. */
|
||||||
|
- bool transient_failure;
|
||||||
|
- if (dest_desc < 0) /* currently for fclonefileat(). */
|
||||||
|
- transient_failure = errno == EIO || errno == ENOMEM
|
||||||
|
- || errno == ENOSPC || errno == EDQUOT;
|
||||||
|
- else /* currently for FICLONE. */
|
||||||
|
- transient_failure = ! is_CLONENOTSUP (errno);
|
||||||
|
+ /* When the clone operation fails, report failure only with errno values
|
||||||
|
+ known to mean trouble when the clone is supported and called properly.
|
||||||
|
+ Do not report failure merely because !is_CLONENOTSUP (errno),
|
||||||
|
+ as systems may yield oddball errno values here with FICLONE.
|
||||||
|
+ Also is_CLONENOTSUP() is not appropriate for the range of errnos
|
||||||
|
+ possible from fclonefileat(), so it's more consistent to avoid. */
|
||||||
|
+ bool report_failure = is_terminal_error (errno);
|
||||||
|
|
||||||
|
- if (reflink_mode == REFLINK_ALWAYS || transient_failure)
|
||||||
|
+ if (reflink_mode == REFLINK_ALWAYS || report_failure)
|
||||||
|
error (0, errno, _("failed to clone %s from %s"),
|
||||||
|
quoteaf_n (0, dst_name), quoteaf_n (1, src_name));
|
||||||
|
|
||||||
|
@@ -1190,14 +1198,14 @@ handle_clone_fail (int dst_dirfd, char c
|
||||||
|
but cloned no data. */
|
||||||
|
if (new_dst /* currently not for fclonefileat(). */
|
||||||
|
&& reflink_mode == REFLINK_ALWAYS
|
||||||
|
- && ((! transient_failure) || lseek (dest_desc, 0, SEEK_END) == 0)
|
||||||
|
+ && ((! report_failure) || lseek (dest_desc, 0, SEEK_END) == 0)
|
||||||
|
&& unlinkat (dst_dirfd, dst_relname, 0) != 0 && errno != ENOENT)
|
||||||
|
error (0, errno, _("cannot remove %s"), quoteaf (dst_name));
|
||||||
|
|
||||||
|
- if (! transient_failure)
|
||||||
|
+ if (! report_failure)
|
||||||
|
copy_debug.reflink = COPY_DEBUG_UNSUPPORTED;
|
||||||
|
|
||||||
|
- if (reflink_mode == REFLINK_ALWAYS || transient_failure)
|
||||||
|
+ if (reflink_mode == REFLINK_ALWAYS || report_failure)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
@ -1,95 +0,0 @@
|
|||||||
--- a/m4/gnulib-comp.m4
|
|
||||||
+++ b/m4/gnulib-comp.m4
|
|
||||||
@@ -2671,7 +2671,7 @@ changequote([, ])dnl
|
|
||||||
fi
|
|
||||||
gl_SYS_SOCKET_MODULE_INDICATOR([socket])
|
|
||||||
AC_REQUIRE([gt_TYPE_WCHAR_T])
|
|
||||||
- AC_REQUIRE([gt_TYPE_WINT_T])
|
|
||||||
+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
|
|
||||||
gl_FUNC_STRERROR_R
|
|
||||||
AS_IF([test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1], [
|
|
||||||
AC_LIBOBJ([strerror_r])
|
|
||||||
--- a/m4/stdint.m4
|
|
||||||
+++ b/m4/stdint.m4
|
|
||||||
@@ -15,7 +15,7 @@ AC_DEFUN_ONCE([gl_STDINT_H],
|
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
||||||
|
|
||||||
AC_REQUIRE([gl_LIMITS_H])
|
|
||||||
- AC_REQUIRE([gt_TYPE_WINT_T])
|
|
||||||
+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
|
|
||||||
|
|
||||||
dnl For backward compatibility. Some packages may still be testing these
|
|
||||||
dnl macros.
|
|
||||||
--- a/m4/vasnprintf.m4
|
|
||||||
+++ b/m4/vasnprintf.m4
|
|
||||||
@@ -33,7 +33,7 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
|
|
||||||
AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
|
|
||||||
[
|
|
||||||
AC_REQUIRE([gt_TYPE_WCHAR_T])
|
|
||||||
- AC_REQUIRE([gt_TYPE_WINT_T])
|
|
||||||
+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
|
|
||||||
])
|
|
||||||
|
|
||||||
# Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
|
|
||||||
@@ -41,7 +41,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
|
|
||||||
[
|
|
||||||
AC_REQUIRE([gl_FEATURES_H])
|
|
||||||
AC_REQUIRE([gt_TYPE_WCHAR_T])
|
|
||||||
- AC_REQUIRE([gt_TYPE_WINT_T])
|
|
||||||
+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
|
|
||||||
AC_REQUIRE([AC_TYPE_SIZE_T])
|
|
||||||
AC_CHECK_TYPE([ptrdiff_t], ,
|
|
||||||
[AC_DEFINE([ptrdiff_t], [long],
|
|
||||||
@@ -55,7 +55,7 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
|
|
||||||
[
|
|
||||||
AC_REQUIRE([AC_FUNC_ALLOCA])
|
|
||||||
AC_REQUIRE([gt_TYPE_WCHAR_T])
|
|
||||||
- AC_REQUIRE([gt_TYPE_WINT_T])
|
|
||||||
+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
|
|
||||||
AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
|
|
||||||
dnl Use the _snprintf function only if it is declared (because on NetBSD it
|
|
||||||
dnl is defined as a weak alias of snprintf; we prefer to use the latter).
|
|
||||||
--- a/m4/wchar_h.m4
|
|
||||||
+++ b/m4/wchar_h.m4
|
|
||||||
@@ -27,7 +27,7 @@ AC_DEFUN_ONCE([gl_WCHAR_H],
|
|
||||||
|
|
||||||
AC_REQUIRE([gl_FEATURES_H])
|
|
||||||
|
|
||||||
- AC_REQUIRE([gt_TYPE_WINT_T])
|
|
||||||
+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
|
|
||||||
if test $gt_cv_c_wint_t = yes; then
|
|
||||||
HAVE_WINT_T=1
|
|
||||||
else
|
|
||||||
--- a/m4/wctype_h.m4
|
|
||||||
+++ b/m4/wctype_h.m4
|
|
||||||
@@ -22,7 +22,7 @@ AC_DEFUN_ONCE([gl_WCTYPE_H],
|
|
||||||
fi
|
|
||||||
AC_SUBST([HAVE_ISWCNTRL])
|
|
||||||
|
|
||||||
- AC_REQUIRE([gt_TYPE_WINT_T])
|
|
||||||
+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
|
|
||||||
if test $gt_cv_c_wint_t = yes; then
|
|
||||||
HAVE_WINT_T=1
|
|
||||||
else
|
|
||||||
--- a/m4/wcwidth.m4
|
|
||||||
+++ b/m4/wcwidth.m4
|
|
||||||
@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_WCWIDTH],
|
|
||||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
|
||||||
|
|
||||||
AC_REQUIRE([gt_TYPE_WCHAR_T])
|
|
||||||
- AC_REQUIRE([gt_TYPE_WINT_T])
|
|
||||||
+ AC_REQUIRE([gt_TYPE_WINT_T_GNUTLS])
|
|
||||||
|
|
||||||
AC_CHECK_HEADERS_ONCE([wchar.h])
|
|
||||||
AC_CHECK_FUNCS_ONCE([wcwidth])
|
|
||||||
--- a/m4/wint_t.m4
|
|
||||||
+++ b/m4/wint_t.m4
|
|
||||||
@@ -9,7 +9,7 @@ dnl Test whether <wchar.h> has the 'wint
|
|
||||||
dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
|
|
||||||
dnl Prerequisite: AC_PROG_CC
|
|
||||||
|
|
||||||
-AC_DEFUN([gt_TYPE_WINT_T],
|
|
||||||
+AC_DEFUN([gt_TYPE_WINT_T_GNUTLS],
|
|
||||||
[
|
|
||||||
AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
|
|
||||||
[AC_COMPILE_IFELSE(
|
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
From 9c5e542fd190a14431092e3b6cb45d18fe95f26f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
Date: Tue, 28 Mar 2023 01:52:43 -0700
|
||||||
|
Subject: [PATCH] date: diagnose -f read errors
|
||||||
|
|
||||||
|
* src/date.c (batch_convert): Diagnose read errors, fixing Bug#62497.
|
||||||
|
---
|
||||||
|
--- a/src/date.c
|
||||||
|
+++ b/src/date.c
|
||||||
|
@@ -368,7 +368,9 @@ batch_convert (char const *input_filenam
|
||||||
|
ssize_t line_length = getline (&line, &buflen, in_stream);
|
||||||
|
if (line_length < 0)
|
||||||
|
{
|
||||||
|
- /* FIXME: detect/handle error here. */
|
||||||
|
+ if (ferror (in_stream))
|
||||||
|
+ die (EXIT_FAILURE, errno, _("%s: read error"),
|
||||||
|
+ quotef (input_filename));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user