Re: [OpenWrt-Devel] [PATCH] ralink: Add support for GPIO as interrupt-controller

2018-11-04 Thread Rosen Penev
On Sun, Nov 4, 2018 at 6:49 PM Daniel Santos  wrote:
>
> The gpio-ralink driver has everything it needs to be used as an
> interrupt controller except for device tree support.  This simple patch
> adds that support by configuring the irq domain to use two cells and
> adding the appropriate documentation to the devicetree bindings.
Note that there is a mainline driver that does this already:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/gpio/gpio-mt7621.c?h=v4.19.1

I've backported it in my tree as well:
https://github.com/neheb/source/commit/aa3a57cdcf91a4483cfd511f8a34fb9a595f4af2

I have not submitted as I don't have hardware to test that uses GPIO
beyond a simple push button.

I think ramips maintainer currently wants to wait until 4.19 to make
such changes.
>
> Signed-off-by: Daniel Santos 
> ---
>  ...-Add-support-for-GPIO-as-interrupt-contro.patch | 51 
> ++
>  1 file changed, 51 insertions(+)
>  create mode 100644 
> target/linux/ramips/patches-4.14/0029-gpio-ralink-Add-support-for-GPIO-as-interrupt-contro.patch
>
> diff --git 
> a/target/linux/ramips/patches-4.14/0029-gpio-ralink-Add-support-for-GPIO-as-interrupt-contro.patch
>  
> b/target/linux/ramips/patches-4.14/0029-gpio-ralink-Add-support-for-GPIO-as-interrupt-contro.patch
> new file mode 100644
> index 00..d93f39c746
> --- /dev/null
> +++ 
> b/target/linux/ramips/patches-4.14/0029-gpio-ralink-Add-support-for-GPIO-as-interrupt-contro.patch
> @@ -0,0 +1,51 @@
> +From 57fa7f2f4ef6f78ce1d30509c0d111aa3791b524 Mon Sep 17 00:00:00 2001
> +From: Daniel Santos 
> +Date: Sun, 4 Nov 2018 20:24:32 -0600
> +Subject: gpio-ralink: Add support for GPIO as interrupt-controller
> +
> +Signed-off-by: Daniel Santos 
> +---
> + Documentation/devicetree/bindings/gpio/gpio-ralink.txt | 6 ++
> + drivers/gpio/gpio-ralink.c | 2 +-
> + 2 files changed, 7 insertions(+), 1 deletion(-)
> +
> +diff --git a/Documentation/devicetree/bindings/gpio/gpio-ralink.txt 
> b/Documentation/devicetree/bindings/gpio/gpio-ralink.txt
> +index 5cd17f225fe3..2775449614d4 100644
> +--- a/Documentation/devicetree/bindings/gpio/gpio-ralink.txt
>  b/Documentation/devicetree/bindings/gpio/gpio-ralink.txt
> +@@ -17,6 +17,9 @@ Required properties:
> +
> + Optional properties:
> + - ralink,gpio-base : Specify the GPIO chips base number
> ++- interrupt-controller : marks this as an interrupt controller
> ++- #interrupt-cells : a standard two-cell interrupt flag, see
> ++  interrupt-controller/interrupts.txt
> +
> + Example:
> +
> +@@ -28,6 +31,9 @@ Example:
> +
> +   reg = <0x600 0x34>;
> +
> ++  interrupt-controller;
> ++  #interrupt-cells = <2>;
> ++
> +   interrupt-parent = <>;
> +   interrupts = <6>;
> +
> +diff --git a/drivers/gpio/gpio-ralink.c b/drivers/gpio/gpio-ralink.c
> +index 27910e384013..b6e30083d012 100644
> +--- a/drivers/gpio/gpio-ralink.c
>  b/drivers/gpio/gpio-ralink.c
> +@@ -220,7 +220,7 @@ static int gpio_map(struct irq_domain *d, unsigned int 
> irq, irq_hw_number_t hw)
> + }
> +
> + static const struct irq_domain_ops irq_domain_ops = {
> +-  .xlate = irq_domain_xlate_onecell,
> ++  .xlate = irq_domain_xlate_twocell,
> +   .map = gpio_map,
> + };
> +
> +--
> +2.16.4
> +
> --
> 2.16.4
>
>
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Proposal for managing the kernel patches.

2018-11-04 Thread Daniel Santos
I had a discussion about this on irc a few weeks ago as well and I am in
favor.  There are just far too many reasons to list for the OpenWRT
kernel to exist as a set of branches in git.  Among them are the ability
to move patches around, cherry-pick and git-blame.  It is often very
important to understand the rationale of a particular change and this is
fairly easy to determine in gitk (presuming the patch was well documented).

Done properly, this should greatly reduce the burden of upgrading and
even backporting.  There are a vast array of git tools that this would
enable -- most of which kernel programmers are *used* to having and tend
to feel naked without.

However, there is one elephant in the living room here and it has pooped
on the carpet:  target/linux/*/files.  These are a particular
abomination because they aren't connected to any patches and have no
explanation for existing.  Each of these changes will need to be
associated with a documented change.

Which brings me to yet another reason for the OpenWRT kernel to be in
git: discipline. One does not simply walk into git with a tree of 65
files that are added/overwritten without explanation. :)

BTW, I have a few kernel debugging-related patches that still aren't
quite ready for submission, but I think we need a HOWTO somewhere for
this as I find myself trying to explain too much in the Kconfig help.

Thanks,
Daniel


On 11/01/2018 01:20 PM, Ben Greear wrote:
> I just had a good discussion with jow about this on irc, thought I'd put
> my ideas in email form in case others are interested.
>
> In my opinion, it is difficult to develop against the current model of
> local
> kernel patches and backports patches.  So, I am thinking something
> like this
> might be a better approach.
>
> Fork the kernel that we want to use for a base (4.19, for instance). 
> Apply the
> existing patches one at a time to this tree.  Push this tree to
> github.  Auto-create
> tarballs as needed, put them somewhere openwrt can download them.
>
> Now, openwrt can select a kernel to use, which is one of these
> tarballs during
> compile time.
>
> It should be easy to select different kernels with a small makefile
> tweak (and no need
> to deal with local patches conflicting).  And, we can do 'stable'
> backport patches for
> older kernels like upstream does.
>
> In addition, the openwrt kernel can be easily compiled for and
> installed on a desktop OS which might
> make debugging easier.
>
>
> When it is time to start developing on a new kernel, clone a new one,
> use 'git am'
> to create the old patch-set, and then apply it on the new kernel. 
> Push that tree
> upstream as a new github repo  (so we can easily have a 4.19 kernel as
> well as 4.14, etc).
>
>
> I'd also like to somehow cram backports into this same tree, but not
> sure how reasonable
> that is...maybe not worth the effort.
>
> Thanks,
> Ben
>


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ralink: Add support for GPIO as interrupt-controller

2018-11-04 Thread Daniel Santos
The gpio-ralink driver has everything it needs to be used as an
interrupt controller except for device tree support.  This simple patch
adds that support by configuring the irq domain to use two cells and
adding the appropriate documentation to the devicetree bindings.

Signed-off-by: Daniel Santos 
---
 ...-Add-support-for-GPIO-as-interrupt-contro.patch | 51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 
target/linux/ramips/patches-4.14/0029-gpio-ralink-Add-support-for-GPIO-as-interrupt-contro.patch

diff --git 
a/target/linux/ramips/patches-4.14/0029-gpio-ralink-Add-support-for-GPIO-as-interrupt-contro.patch
 
b/target/linux/ramips/patches-4.14/0029-gpio-ralink-Add-support-for-GPIO-as-interrupt-contro.patch
new file mode 100644
index 00..d93f39c746
--- /dev/null
+++ 
b/target/linux/ramips/patches-4.14/0029-gpio-ralink-Add-support-for-GPIO-as-interrupt-contro.patch
@@ -0,0 +1,51 @@
+From 57fa7f2f4ef6f78ce1d30509c0d111aa3791b524 Mon Sep 17 00:00:00 2001
+From: Daniel Santos 
+Date: Sun, 4 Nov 2018 20:24:32 -0600
+Subject: gpio-ralink: Add support for GPIO as interrupt-controller
+
+Signed-off-by: Daniel Santos 
+---
+ Documentation/devicetree/bindings/gpio/gpio-ralink.txt | 6 ++
+ drivers/gpio/gpio-ralink.c | 2 +-
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/Documentation/devicetree/bindings/gpio/gpio-ralink.txt 
b/Documentation/devicetree/bindings/gpio/gpio-ralink.txt
+index 5cd17f225fe3..2775449614d4 100644
+--- a/Documentation/devicetree/bindings/gpio/gpio-ralink.txt
 b/Documentation/devicetree/bindings/gpio/gpio-ralink.txt
+@@ -17,6 +17,9 @@ Required properties:
+ 
+ Optional properties:
+ - ralink,gpio-base : Specify the GPIO chips base number
++- interrupt-controller : marks this as an interrupt controller
++- #interrupt-cells : a standard two-cell interrupt flag, see
++  interrupt-controller/interrupts.txt
+ 
+ Example:
+ 
+@@ -28,6 +31,9 @@ Example:
+ 
+   reg = <0x600 0x34>;
+ 
++  interrupt-controller;
++  #interrupt-cells = <2>;
++
+   interrupt-parent = <>;
+   interrupts = <6>;
+ 
+diff --git a/drivers/gpio/gpio-ralink.c b/drivers/gpio/gpio-ralink.c
+index 27910e384013..b6e30083d012 100644
+--- a/drivers/gpio/gpio-ralink.c
 b/drivers/gpio/gpio-ralink.c
+@@ -220,7 +220,7 @@ static int gpio_map(struct irq_domain *d, unsigned int 
irq, irq_hw_number_t hw)
+ }
+ 
+ static const struct irq_domain_ops irq_domain_ops = {
+-  .xlate = irq_domain_xlate_onecell,
++  .xlate = irq_domain_xlate_twocell,
+   .map = gpio_map,
+ };
+ 
+-- 
+2.16.4
+
-- 
2.16.4


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Merged: ipq40xx: fix NBG6617 LED mapping

2018-11-04 Thread Kevin Darbyshire-Bryant
Merged into my staging tree.
Thank you!


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] packages/python-idna: Add missing dependency on python(3)-codecs

2018-11-04 Thread Daniel Santos
Signed-off-by: Daniel Santos 
---
 lang/python/python-idna/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lang/python/python-idna/Makefile b/lang/python/python-idna/Makefile
index 47f4b9668..1f36b21e9 100644
--- a/lang/python/python-idna/Makefile
+++ b/lang/python/python-idna/Makefile
@@ -37,14 +37,14 @@ endef
 define Package/python-idna
 $(call Package/python-idna/Default)
   TITLE:=python-idna
-  DEPENDS:=+PACKAGE_python-idna:python-light
+  DEPENDS:=+PACKAGE_python-idna:python-light +python-codecs
   VARIANT:=python
 endef
 
 define Package/python3-idna
 $(call Package/python-idna/Default)
   TITLE:=python3-idna
-  DEPENDS:=+PACKAGE_python3-idna:python3-light
+  DEPENDS:=+PACKAGE_python3-idna:python3-light +python3-codecs
   VARIANT:=python3
 endef
 
-- 
2.16.4


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ath79: add support for GL-iNet GL-X750

2018-11-04 Thread Luochongjun
this patch adds supports for GL-X750.

Specification:
- SOC: QCA9531 (650MHz)
- Flash: 16 MiB (W25Q128FVSG)
- RAM: 128 MiB DDR2
- Ethernet: 10/100: 1xLAN + 10/100: 1xWAN
- Wireless: 2.4GHz (bgn) and 5GHz (ac)
- USB: 1x USB 2.0 port
- Button: 1x reset button
- LED: 5x LEDS (green)

Flash instruction:
The original firmware is openwrt, so both LuCI or sysupgrade can be used.

Signed-off-by: Luo chongjun 
---
 target/linux/ath79/base-files/etc/board.d/01_leds  |  3 +
 .../linux/ath79/base-files/etc/board.d/02_network  |  1 +
 .../etc/hotplug.d/firmware/11-ath10k-caldata   |  4 +
 target/linux/ath79/dts/qca9533_glinet_x750.dts | 46 +++
 target/linux/ath79/dts/qca9533_glinet_x750.dtsi| 95 ++
 target/linux/ath79/image/generic.mk|  8 ++
 6 files changed, 157 insertions(+)
 create mode 100644 target/linux/ath79/dts/qca9533_glinet_x750.dts
 create mode 100644 target/linux/ath79/dts/qca9533_glinet_x750.dtsi

diff --git a/target/linux/ath79/base-files/etc/board.d/01_leds 
b/target/linux/ath79/base-files/etc/board.d/01_leds
index f04eb7f..62584e2 100755
--- a/target/linux/ath79/base-files/etc/board.d/01_leds
+++ b/target/linux/ath79/base-files/etc/board.d/01_leds
@@ -33,6 +33,9 @@ etactica,eg200)
ucidef_set_led_oneshot "modbus" "Modbus" "$boardname:red:modbus" "100" 
"33"
ucidef_set_led_default "etactica" "etactica" "$boardname:red:etactica" 
"ignore"
;;
+glinet,x750)
+   ucidef_set_led_netdev "wan" "WAN" "gl-x750:green:wan" "eth0"
+   ;;
 netgear,wnr612-v2|\
 on,n150r)
ucidef_set_led_netdev "wan" "WAN" "netgear:green:wan" "eth0"
diff --git a/target/linux/ath79/base-files/etc/board.d/02_network 
b/target/linux/ath79/base-files/etc/board.d/02_network
index 56eb42f..c18558e 100755
--- a/target/linux/ath79/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/base-files/etc/board.d/02_network
@@ -69,6 +69,7 @@ ath79_setup_interfaces()
ucidef_set_interface_lan "eth0" "dhcp"
;;
glinet,ar150|\
+   glinet,x750|\
glinet,ar300m)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
diff --git 
a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata 
b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 9365d67..dbd64af 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -87,6 +87,10 @@ board=$(board_name)
 case "$FIRMWARE" in
 "ath10k/cal-pci-:00:00.0.bin")
case $board in
+   glinet,x750)
+   ath10kcal_extract "art" 20480 2116
+   ath10kcal_patch_mac $(macaddr_add $(cat 
/sys/class/net/eth0/address) +1)
+   ;;
iodata,wn-ac1167dgr|\
iodata,wn-ac1600dgr2)
ath10kcal_extract "art" 20480 2116
diff --git a/target/linux/ath79/dts/qca9533_glinet_x750.dts 
b/target/linux/ath79/dts/qca9533_glinet_x750.dts
new file mode 100644
index 000..7313f96
--- /dev/null
+++ b/target/linux/ath79/dts/qca9533_glinet_x750.dts
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include 
+#include 
+
+#include "qca9533_glinet_x750.dtsi"
+
+ {
+   status = "okay";
+   num-cs = <0>;
+
+   flash@0 {
+   compatible = "jedec,spi-nor";
+   reg = <0>;
+   spi-max-frequency = <2500>;
+
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@0 {
+   label = "u-boot";
+   reg = <0x00 0x04>;
+   read-only;
+   };
+
+   partition@4 {
+   label = "u-boot-env";
+   reg = <0x04 0x01>;
+   };
+
+art: partition@5 {
+label = "art";
+reg = <0x05 0x01>;
+};
+
+   partition@6 {
+   label = "firmware";
+   reg = <0x06 0xfa>;
+   };
+
+   };
+   };
+};
diff --git a/target/linux/ath79/dts/qca9533_glinet_x750.dtsi 
b/target/linux/ath79/dts/qca9533_glinet_x750.dtsi
new file mode 100644
index 000..b84c332
--- /dev/null
+++ b/target/linux/ath79/dts/qca9533_glinet_x750.dtsi
@@ -0,0 +1,95 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include "qca9533.dtsi"
+
+/ {
+   compatible = "glinet,x750", "qca,qca9533";
+   model = "GL.iNet GL-X750";
+
+   keys {
+   compatible = "gpio-keys-polled";
+   poll-interval = <20>;

[OpenWrt-Devel] [PATCH v3] uqmi: allow matching IMSI for qmi networks

2018-11-04 Thread Daniel Golle
Introduce 'imsi' configuration option for proto 'qmi' network
interfaces. Setting it makes sure the configuration only gets used
on the intended SIM card. In this way, one can have many configurations
for different SIM cards selected automatically when the card was either
swapped physically or in software (as possible on the APU3 board).
In order to allow multiple configurations using the same character
device, add locking in netifd protocol handler to avoid overlapping
execution of uqmi of the same device.

Signed-off-by: Daniel Golle 
---
 package/network/utils/uqmi/Makefile   |  2 +-
 .../utils/uqmi/files/lib/netifd/proto/qmi.sh  | 54 ---
 2 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/package/network/utils/uqmi/Makefile 
b/package/network/utils/uqmi/Makefile
index b2f3474400..8eaf0bff3f 100644
--- a/package/network/utils/uqmi/Makefile
+++ b/package/network/utils/uqmi/Makefile
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uqmi
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git
diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh 
b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index 9b2f69f009..2edbe7c28e 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -10,6 +10,7 @@ proto_qmi_init_config() {
available=1
no_device=1
proto_config_add_string "device:device"
+   proto_config_add_string imsi
proto_config_add_string apn
proto_config_add_string auth
proto_config_add_string username
@@ -28,12 +29,12 @@ proto_qmi_init_config() {
 
 proto_qmi_setup() {
local interface="$1"
-   local dataformat connstat
-   local device apn auth username password pincode delay modes pdptype 
profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS
+   local dataformat connstat imsi_actual
+   local device imsi apn auth username password pincode delay modes 
pdptype profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS
local ip4table ip6table
local cid_4 pdh_4 cid_6 pdh_6
local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
-   json_get_vars device apn auth username password pincode delay modes 
pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout 
$PROTO_DEFAULT_OPTIONS
+   json_get_vars device imsi apn auth username password pincode delay 
modes pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout 
$PROTO_DEFAULT_OPTIONS
 
[ "$timeout" = "" ] && timeout="10"
 
@@ -68,10 +69,16 @@ proto_qmi_setup() {
return 1
}
 
+   lockname="/var/lock/LCK..$devname"
+   lock "$lockname"
+
echo "Waiting for SIM initialization"
local uninitialized_timeout=0
while uqmi -s -d "$device" --get-pin-status | grep '"UIM 
uninitialized"' > /dev/null; do
-   [ -e "$device" ] || return 1
+   [ -e "$device" ] || {
+   lock -u "$lockname"
+   return 1
+   }
if [ "$uninitialized_timeout" -lt "$timeout" ]; then
let uninitialized_timeout++
sleep 1;
@@ -79,16 +86,29 @@ proto_qmi_setup() {
echo "SIM not initialized"
proto_notify_error "$interface" SIM_NOT_INITIALIZED
proto_block_restart "$interface"
+   lock -u "$lockname"
return 1
fi
done
 
+   [ -n "$imsi" ] && {
+   imsi_actual="$(uqmi -s -d "$device" --get-imsi | cut -d'"' -f2)"
+   [ "$imsi" = "$imsi_actual" ] || {
+   echo "Configured IMSI doesn't match SIM card."
+   proto_notify_error "$interface" SIM_WRONG
+   proto_set_available "$interface" 0
+   lock -u "$lockname"
+   return 1
+   }
+   }
+
if uqmi -s -d "$device" --get-pin-status | grep '"Not supported"' > 
/dev/null; then
[ -n "$pincode" ] && {
uqmi -s -d "$device" --verify-pin1 "$pincode" > 
/dev/null || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null || {
echo "Unable to verify PIN"
proto_notify_error "$interface" PIN_FAILED
proto_block_restart "$interface"
+   lock -u "$lockname"
return 1
}
}
@@ -106,6 +126,7 @@ proto_qmi_setup() {
echo "SIM locked PUK required"
proto_notify_error "$interface" PUK_NEEDED
proto_block_restart "$interface"
+   

[OpenWrt-Devel] [RFC PATCH] build: re-enable parallelism for mksquashfs

2018-11-04 Thread Daniel Santos
This was disabled by commit dcd0e4a6727611f03eb3d3a75f073235f5f1229c due
to a threading bug back in 2009.  The specifics of the bug are not given
in the commit message and squashfs-tools has had several updates to it's
parallelism since this time.  There are currently no open issues related
to parallelism in their issue tracker:
https://github.com/plougher/squashfs-tools/issues

It now "works for me" with 16 threads, and while this is a terrible test
for a race condition I still propose we remove this work-around
unless and until we have specific knowledge of a current bug.

Signed-off-by: Daniel Santos 
---
 include/image.mk | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/image.mk b/include/image.mk
index f2a85f6feb..dcf1e3572a 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -203,7 +203,6 @@ define Image/mkfs/squashfs
$(STAGING_DIR_HOST)/bin/mksquashfs4 $(call mkfs_target_dir,$(1)) $@ \
-nopad -noappend -root-owned \
-comp $(SQUASHFSCOMP) $(SQUASHFSOPT) \
-   -processors 1 \
$(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
 endef
 
-- 
2.16.4


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] kernel: add option to root .config for /proc/config.gz

2018-11-04 Thread Daniel Santos
Exports CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC to the kernel .config
based upon menu choices under Global build settings --> Kernel build
options.  For simplicity, /proc/config.gz support is assumed, but if
kernel_menuconfig has disabled CONFIG_PROC_FS it will be pruned in
oldconfig.

Signed-off-by: Daniel Santos 
---
 config/Config-kernel.in | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/config/Config-kernel.in b/config/Config-kernel.in
index f38cc792dd..b03eb929c9 100644
--- a/config/Config-kernel.in
+++ b/config/Config-kernel.in
@@ -20,6 +20,24 @@ config KERNEL_BUILD_DOMAIN
  returned by 'uname -a' on running systems.
  If not set, uses system hostname at build time.
 
+config KERNEL_IKCONFIG_PROC
+bool
+default n
+
+config KERNEL_IKCONFIG
+   bool "Kernel .config support"
+   select KERNEL_IKCONFIG_PROC
+   default n
+   help
+ This option enables the complete Linux kernel ".config" file
+ contents to be saved in the kernel. It provides documentation
+ of which kernel options are used in a running kernel or in an
+ on-disk kernel.  This information can be extracted from the kernel
+ image file with the script scripts/extract-ikconfig and used as
+ input to rebuild the current kernel or to build another kernel.
+ Unless PROC_FS is disabled, it will also be exported via
+ /proc/config.gz.
+
 config KERNEL_PRINTK
bool "Enable support for printk"
default y
-- 
2.16.4


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2] uqmi: allow matching IMSI for qmi networks

2018-11-04 Thread Daniel Golle
Introduce 'imsi' configuration option for proto 'qmi' network
interfaces. Setting it makes sure the configuration only gets used
on the intended SIM card. In this way, one can have many configurations
for different SIM cards selected automatically when the card was either
swapped physically or in software (as possible on the APU3 board).
We may need to add locking in dev.c function
int qmi_device_open(struct qmi_dev *qmi, const char *path)
to avoid multiple instances of uqmi operating on the same chardev.

Signed-off-by: Daniel Golle 
---
 package/network/utils/uqmi/Makefile |  2 +-
 .../utils/uqmi/files/lib/netifd/proto/qmi.sh| 17 ++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/package/network/utils/uqmi/Makefile 
b/package/network/utils/uqmi/Makefile
index b2f3474400..8eaf0bff3f 100644
--- a/package/network/utils/uqmi/Makefile
+++ b/package/network/utils/uqmi/Makefile
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uqmi
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git
diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh 
b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index 9b2f69f009..f52f28676b 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -10,6 +10,7 @@ proto_qmi_init_config() {
available=1
no_device=1
proto_config_add_string "device:device"
+   proto_config_add_string imsi
proto_config_add_string apn
proto_config_add_string auth
proto_config_add_string username
@@ -28,12 +29,12 @@ proto_qmi_init_config() {
 
 proto_qmi_setup() {
local interface="$1"
-   local dataformat connstat
-   local device apn auth username password pincode delay modes pdptype 
profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS
+   local dataformat connstat imsi_actual
+   local device imsi apn auth username password pincode delay modes 
pdptype profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS
local ip4table ip6table
local cid_4 pdh_4 cid_6 pdh_6
local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
-   json_get_vars device apn auth username password pincode delay modes 
pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout 
$PROTO_DEFAULT_OPTIONS
+   json_get_vars device imsi apn auth username password pincode delay 
modes pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout 
$PROTO_DEFAULT_OPTIONS
 
[ "$timeout" = "" ] && timeout="10"
 
@@ -83,6 +84,16 @@ proto_qmi_setup() {
fi
done
 
+   [ -n "$imsi" ] && {
+   imsi_actual="$(uqmi -s -d "$device" --get-imsi | cut -d'"' -f2)"
+   [ "$imsi" = "$imsi_actual" ] || {
+   echo "Configured IMSI doesn't match SIM card."
+   proto_notify_error "$interface" SIM_WRONG
+   proto_set_available "$interface" 0
+   return 1
+   }
+   }
+
if uqmi -s -d "$device" --get-pin-status | grep '"Not supported"' > 
/dev/null; then
[ -n "$pincode" ] && {
uqmi -s -d "$device" --verify-pin1 "$pincode" > 
/dev/null || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null || {
-- 
2.19.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v4 2/2] kernel: rework module stripping, add Kconfig option

2018-11-04 Thread Daniel Santos
Add an option to the "Global build settings" menu to choose if and how
kernel modules are stripped.  Stripping is now performed upon install
into staging, leaving modules in the kernel build tree untouched so that
they are useful for remote debugging and such.

The user will now be allowed to choose to 1.) leave modules unstripped,
2.) strip unneeded symbols and sections, or 3.) strip all -- the later
of which exposes access to Felix's hack for removing non-essential
module information.  Thus, rather than having to go to the
kernel_menuconfig to disable it when not desired, it can be disabled
simply by selecting either "strip unneeded" or "strip none".  The
functionality of "strip all" and Felix's patch are logical mates.
Although it is concievable that one may want to retain author, parameter
descriptions, etc., but also do a strip-all, this can still be done by
disabling Felix's patch via kernel_menuconfig.

The kernel .config option MODULE_STRIPPED is renamed to MODULE_STRIP_ALL
for disabiguation while the options to not strip or only strip-unneeded
are not exported to the kernel .config as they are only relevent to the
OpenWRT build.

Signed-off-by: Daniel Santos 
---
 config/Config-build.in | 29 ++
 include/kernel.mk  | 17 +++--
 target/linux/generic/config-4.14   |  1 -
 target/linux/generic/config-4.9|  1 -
 .../linux/generic/hack-4.14/204-module_strip.patch | 22 
 .../linux/generic/hack-4.9/204-module_strip.patch  | 24 +-
 6 files changed, 67 insertions(+), 27 deletions(-)

diff --git a/config/Config-build.in b/config/Config-build.in
index a082a5e0e2..72076d0648 100644
--- a/config/Config-build.in
+++ b/config/Config-build.in
@@ -151,6 +151,35 @@ menu "Global build settings"
  image.  Note that this might make the kernel incompatible 
with any kernel
  modules that were not selected at the time the kernel image 
was created.
 
+   choice
+   prompt "Kernel module stripping"
+   default KERNEL_MODULE_STRIP_ALL
+   help
+ If and how modules should be stripped upon install.  Modules
+ in the Linux build tree remain unchanged.
+
+   config MODULE_STRIP_NONE
+   bool "strip none"
+   help
+ Will install modules exactly as they are built in the
+ tree, including any debug symbols if enabled in the
+ Kernel Hacking menuconfig menu.
+
+   config MODULE_STRIP_UNNEEDED
+   bool "strip unneeded"
+   help
+ Strips all unneeded symbols from modules as they are
+ installed.
+
+   config KERNEL_MODULE_STRIP_ALL
+   bool "strip all"
+   help
+ Further reduces size of kernel modules by stripping
+ all symbols, including relocations, and removing
+ customary strings such as author, version, parameter
+ descriptions, etc.
+   endchoice
+
config USE_MKLIBS
bool "Strip unnecessary functions from libraries"
help
diff --git a/include/kernel.mk b/include/kernel.mk
index 62a8e99e2d..251ac1c94c 100644
--- a/include/kernel.mk
+++ b/include/kernel.mk
@@ -122,6 +122,18 @@ ifdef CONFIG_USE_SPARSE
   KERNEL_MAKEOPTS += C=1 CHECK=$(STAGING_DIR_HOST)/bin/sparse
 endif
 
+# Define command for copying kernel modules.
+ifeq ($(CONFIG_MODULE_STRIP_NONE),y)
+  MODULE_COPY := $(CP) -L
+else
+  MODULE_COPY = $(KERNEL_CROSS)objcopy
+  ifeq ($(CONFIG_MODULE_STRIP_UNNEEDED),y)
+MODULE_COPY += --strip-unneeded
+  else # CONFIG_MODULE_STRIP_ALL
+MODULE_COPY += --strip-all
+  endif
+endif
+
 PKG_EXTMOD_SUBDIRS ?= .
 
 define populate_module_symvers
@@ -229,8 +241,9 @@ $(call KernelPackage/$(1)/config)
if grep -q "{mod##$(LINUX_DIR)/}" 
"$(LINUX_DIR)/modules.builtin"; then \
echo "NOTICE: module 'mod' is 
built-in."; \
elif [ -e mod ]; then \
-   mkdir -p $$(1)/$(MODULES_SUBDIR) ; \
-   $(CP) -L mod $$(1)/$(MODULES_SUBDIR)/ ; 
\
+   mkdir -p $$(1)/$(MODULES_SUBDIR); \
+   mod_name=`basename mod`; \
+   $(MODULE_COPY) mod 
$$(1)/$(MODULES_SUBDIR)/mod_name; \
else \
echo "ERROR: module 'mod' is missing." 
>&2; \
exit 1; \
diff --git a/target/linux/generic/config-4.14 b/target/linux/generic/config-4.14
index 

[OpenWrt-Devel] [PATCH v4 1/2] kernel: revert bad module stripping patch

2018-11-04 Thread Daniel Santos
This patch is wrong in several regards.  1.) It violates the the
principle of least astonishment, 2.) it makes a radical change to the
kernel build without informing the user, 3.) it makes the change without
obtaining user consent, thus violating the spirit of free and open
source software, and 4.) it not only breaks debugging, but other
features such as kmemleak.

Signed-off-by: Daniel Santos 
---
 .../generic/hack-4.14/202-reduce_module_size.patch | 24 --
 .../generic/hack-4.9/202-reduce_module_size.patch  | 24 --
 2 files changed, 48 deletions(-)
 delete mode 100644 target/linux/generic/hack-4.14/202-reduce_module_size.patch
 delete mode 100644 target/linux/generic/hack-4.9/202-reduce_module_size.patch

diff --git a/target/linux/generic/hack-4.14/202-reduce_module_size.patch 
b/target/linux/generic/hack-4.14/202-reduce_module_size.patch
deleted file mode 100644
index 2cbb6add9a..00
--- a/target/linux/generic/hack-4.14/202-reduce_module_size.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-From fd66884da2f96d2a7ea73f58b1b86251b959a913 Mon Sep 17 00:00:00 2001
-From: Felix Fietkau 
-Date: Fri, 7 Jul 2017 16:56:19 +0200
-Subject: kernel: strip unnecessary symbol table information from kernel modules
-
-reduces default squashfs size on ar71xx by about 4k
-
-lede-commit: 058d331a39077f159ca8922f1f422a1346d6aa67
-Signed-off-by: Felix Fietkau 

- Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
 a/Makefile
-+++ b/Makefile
-@@ -425,7 +425,7 @@ KBUILD_AFLAGS_KERNEL :=
- KBUILD_CFLAGS_KERNEL :=
- KBUILD_AFLAGS_MODULE  := -DMODULE
- KBUILD_CFLAGS_MODULE  := -DMODULE
--KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
-+KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds $(if 
$(CONFIG_PROFILING),,-s)
- GCC_PLUGINS_CFLAGS :=
- 
- export ARCH SRCARCH SUBARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD
diff --git a/target/linux/generic/hack-4.9/202-reduce_module_size.patch 
b/target/linux/generic/hack-4.9/202-reduce_module_size.patch
deleted file mode 100644
index f744b945fe..00
--- a/target/linux/generic/hack-4.9/202-reduce_module_size.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-From fd66884da2f96d2a7ea73f58b1b86251b959a913 Mon Sep 17 00:00:00 2001
-From: Felix Fietkau 
-Date: Fri, 7 Jul 2017 16:56:19 +0200
-Subject: kernel: strip unnecessary symbol table information from kernel modules
-
-reduces default squashfs size on ar71xx by about 4k
-
-lede-commit: 058d331a39077f159ca8922f1f422a1346d6aa67
-Signed-off-by: Felix Fietkau 

- Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
 a/Makefile
-+++ b/Makefile
-@@ -403,7 +403,7 @@ KBUILD_AFLAGS_KERNEL :=
- KBUILD_CFLAGS_KERNEL :=
- KBUILD_AFLAGS_MODULE  := -DMODULE
- KBUILD_CFLAGS_MODULE  := -DMODULE
--KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
-+KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds $(if 
$(CONFIG_PROFILING),,-s)
- GCC_PLUGINS_CFLAGS :=
- 
- # Read KERNELRELEASE from include/config/kernel.release (if it exists)
-- 
2.16.4


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH/RFC] uqmi: allow matching IMSI for qmi networks

2018-11-04 Thread Daniel Golle
Introduce 'imsi' configuration option for proto 'qmi' network
interfaces. Setting it makes sure the configuration only gets used
on the intended SIM card. In this way, one could have configuration
for different SIM cards selected automatically when the card was either
swapped physically or in software (as possible on the APU3 board).

Signed-off-by: Daniel Golle 
---
 .../utils/uqmi/files/lib/netifd/proto/qmi.sh   | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh 
b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index 9b2f69f009..ec1b936177 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -28,12 +28,12 @@ proto_qmi_init_config() {
 
 proto_qmi_setup() {
local interface="$1"
-   local dataformat connstat
-   local device apn auth username password pincode delay modes pdptype 
profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS
+   local dataformat connstat imsi_actual
+   local device imsi apn auth username password pincode delay modes 
pdptype profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS
local ip4table ip6table
local cid_4 pdh_4 cid_6 pdh_6
local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
-   json_get_vars device apn auth username password pincode delay modes 
pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout 
$PROTO_DEFAULT_OPTIONS
+   json_get_vars device imsi apn auth username password pincode delay 
modes pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout 
$PROTO_DEFAULT_OPTIONS
 
[ "$timeout" = "" ] && timeout="10"
 
@@ -68,6 +68,14 @@ proto_qmi_setup() {
return 1
}
 
+   imsi_actual="$(uqmi -s -d "$device" --get-imsi | cut -d'"' -f2)"
+   [ -n "$imsi" -a "$imsi" != "$imsi_actual" ] && {
+   echo "Configured IMSI doesn't match SIM card."
+   proto_notify_error "$interface" NO_IFACE
+   proto_set_available "$interface" 0
+   return 1
+   }
+
echo "Waiting for SIM initialization"
local uninitialized_timeout=0
while uqmi -s -d "$device" --get-pin-status | grep '"UIM 
uninitialized"' > /dev/null; do
-- 
2.19.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Why does perl get compiled even if it not selected by any package?

2018-11-04 Thread Jo-Philipp Wich
Hi Hannu,

yes - without any dependency tweaking (e.g. by introducing conditionals
like you suggested) a given source package build-depends on the union of
all dependencies of all binary packages declared by the source package.

The only way to mitigate that is using conditional dependencies in the
form DEPENDS:=+PACKAGE_foo-with-bar:libbar


~ Jo



signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Why does perl get compiled even if it not selected by any package?

2018-11-04 Thread Hannu Nyman
Why does the presence of perl in a larger multi-package Makefile force the 
compilation of perl even if the specific package depending on perl is not 
even selected. (compilation of perl takes long, so it is rather annoying...)


I have stumbled into two cases, where my package selection leads into perl 
compilation during build, although perl is not a dependency of my package 
selection, and the final perl package .ipk is not even produced.


* xtables-addons Makefile has geoip components that depend on perl, but even 
if those are not selected and only e.g. rstp is selected, perl is still 
compiled for the xtables-addons.


* lm-sensors Makefile defines several packages, of which only 
"lm-sensors-detect" depends on perl. Selecting only some other package like 
libsensors still leads into perl compilation.


My hunch is that this is related to perl having a host build component. That 
apparently gets evaluated in any case, regardless of the package needing perl 
actually being selected, or something like that.


Is this just a limitation of the dependency parsing, and is caused by the 
presence of a host build in the package Makefile  ??


Could this be mitigated somehow?

E.g. by saying  " +PACKAGE_lm-sensors-detect:perl " instead of just "+perl"  ???

Any input from the dependency gurus?

https://github.com/openwrt/packages/blob/master/utils/lm-sensors/Makefile

Looking at the tmp/.packagedeps, perl likely gets into the dependency tree 
this way:


package-$(CONFIG_PACKAGE_lm-sensors) += feeds/packages/lm-sensors
package-$(CONFIG_PACKAGE_lm-sensors-detect) += feeds/packages/lm-sensors
package-$(CONFIG_PACKAGE_libsensors) += feeds/packages/lm-sensors

$(curdir)/feeds/packages/lm-sensors/compile += 
$(curdir)/feeds/packages/perl/compile $(curdir)/libs/sysfsutils/compile 
$(curdir)/libs/toolchain/compile $(if 
$(CONFIG_GCC_LIBSSP),$(curdir)/libs/toolchain/compile) $(if 
$(CONFIG_USE_GLIBC),$(curdir)/libs/toolchain/compile)




perus@ub1810:/Openwrt/wrt3200$ grep sensor .config
# CONFIG_PACKAGE_libupm-pulsensor is not set
CONFIG_PACKAGE_libsensors=y
CONFIG_PACKAGE_collectd-mod-sensors=y
# CONFIG_PACKAGE_lm-sensors is not set

# CONFIG_PACKAGE_lm-sensors-detect is not set
perus@ub1810:/Openwrt/wrt3200$ grep perl .config# CONFIG_PACKAGE_perl is not set



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ipq40xx: fix NBG6617 LED mapping

2018-11-04 Thread David Bauer
The NBG6617's LEDs are wrongly identified in the 01_leds boardinit
script (board instead of boardname), resulting in referencing
non-existent LEDs in UCI.

Signed-off-by: David Bauer 
---
 target/linux/ipq40xx/base-files/etc/board.d/01_leds | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/linux/ipq40xx/base-files/etc/board.d/01_leds 
b/target/linux/ipq40xx/base-files/etc/board.d/01_leds
index 475a8623f7..ab2f77ee10 100755
--- a/target/linux/ipq40xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq40xx/base-files/etc/board.d/01_leds
@@ -35,9 +35,9 @@ meraki,mr33)
ucidef_set_interface_lan "eth0"
;;
 zyxel,nbg6617)
-   ucidef_set_led_wlan "wlan2g" "WLAN2G" "$board:green:wlan2G" "phy0tpt"
-   ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:green:wlan5G" "phy1tpt"
-   ucidef_set_led_usbport "usb" "USB" "${board}:green:usb" "usb1-port1" 
"usb2-port1" "usb3-port1" "usb4-port1"
+   ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2G" 
"phy0tpt"
+   ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:green:wlan5G" 
"phy1tpt"
+   ucidef_set_led_usbport "usb" "USB" "${boardname}:green:usb" 
"usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1"
;;
 zyxel,wre6606)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2g" 
"phy0tpt"
-- 
2.19.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH procd] watchdog: improve seting watchdog timeout and frequency

2018-11-04 Thread Hans Dedecker
Due to the watchdog file descriptor check in both watchdog_timeout and
watchdog_frequency it's impossible to set the timeout/frequency via ubus
in case the watchdog was stopped.
Fix this by removing the watchdog file descriptor check in both functions
and by caching locally the set watchdog driver timeout value. The latter
will be used to set the watchdog driver timeout value in case the
watchdog is active or when the watchdog is started.
In addition when parsing the watchdog ubus call check if timeout
attribute is set so the correct value is used when doing the frequency
sanity check.

Signed-off-by: Hans Dedecker 
---
 system.c   |  3 ++-
 watchdog.c | 26 --
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/system.c b/system.c
index 46c420b..8ed3f93 100644
--- a/system.c
+++ b/system.c
@@ -304,7 +304,8 @@ static int watchdog_set(struct ubus_context *ctx, struct 
ubus_object *obj,
 
blobmsg_parse(watchdog_policy, __WDT_MAX, tb, blob_data(msg), 
blob_len(msg));
if (tb[WDT_FREQUENCY]) {
-   unsigned int timeout = watchdog_timeout(0);
+   unsigned int timeout = tb[WDT_TIMEOUT] ? 
blobmsg_get_u32(tb[WDT_TIMEOUT]) :
+   watchdog_timeout(0);
unsigned int freq = blobmsg_get_u32(tb[WDT_FREQUENCY]);
 
if (freq) {
diff --git a/watchdog.c b/watchdog.c
index 7493a0f..9d770b4 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -30,6 +30,7 @@
 
 static struct uloop_timeout wdt_timeout;
 static int wdt_fd = -1;
+static int wdt_drv_timeout = 30;
 static int wdt_frequency = 5;
 static bool wdt_magicclose = false;
 
@@ -84,6 +85,14 @@ static void watchdog_close(void)
wdt_fd = -1;
 }
 
+static int watchdog_set_drv_timeout(void)
+{
+   if (wdt_fd < 0)
+   return -1;
+
+   return ioctl(wdt_fd, WDIOC_SETTIMEOUT, _drv_timeout);
+}
+
 void watchdog_set_magicclose(bool val)
 {
wdt_magicclose = val;
@@ -104,6 +113,7 @@ void watchdog_set_stopped(bool val)
}
else {
watchdog_open(true);
+   watchdog_set_drv_timeout();
watchdog_timeout_cb(_timeout);
}
 }
@@ -115,23 +125,19 @@ bool watchdog_get_stopped(void)
 
 int watchdog_timeout(int timeout)
 {
-   if (wdt_fd < 0)
-   return 0;
-
if (timeout) {
DEBUG(4, "Set watchdog timeout: %ds\n", timeout);
-   ioctl(wdt_fd, WDIOC_SETTIMEOUT, );
+   wdt_drv_timeout = timeout;
+
+   if (wdt_fd >= 0)
+   watchdog_set_drv_timeout();
}
-   ioctl(wdt_fd, WDIOC_GETTIMEOUT, );
 
-   return timeout;
+   return wdt_drv_timeout;
 }
 
 int watchdog_frequency(int frequency)
 {
-   if (wdt_fd < 0)
-   return 0;
-
if (frequency) {
DEBUG(4, "Set watchdog frequency: %ds\n", frequency);
wdt_frequency = frequency;
@@ -160,7 +166,7 @@ void watchdog_init(int preinit)
return;
 
LOG("- watchdog -\n");
-   watchdog_timeout(30);
+   watchdog_set_drv_timeout();
watchdog_timeout_cb(_timeout);
 
DEBUG(4, "Opened watchdog with timeout %ds\n", watchdog_timeout(0));
-- 
2.19.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel