From e3abd1fc0acaee7a7f1440098cbd336341d01041 Mon Sep 17 00:00:00 2001
From: Michal Hrusecky <michal.hrusecky@turris.com>
Date: Fri, 24 Nov 2023 14:55:27 +0100
Subject: [PATCH] patches/openwrt: Update kernel to 5.15.139

Update to the latest kernel and drop two patches related to Omnia LEDs
as they were merged upstream.
---
 NEWS                                          |   2 +-
 ...15-Backport-Turris-Omnia-LED-changes.patch | 235 +-----------------
 ...add-dedicated-files-for-versions-5.1.patch |   4 +-
 ...000-kernel-bump-release-version-to-2.patch |  28 ---
 4 files changed, 7 insertions(+), 262 deletions(-)
 delete mode 100644 patches/openwrt/wip/9000-kernel-bump-release-version-to-2.patch

diff --git a/NEWS b/NEWS
index 63174511f..6bdd9158a 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,7 @@
   • easycwmp: Improve integration - fix Wi-Fi information and serial number/software version getters
 
 đź“Ś Updates
-  • kernel: Updated to version 5.15.137
+  • kernel: Updated to version 5.15.139
 
 🐛 Bug Fixes
   • modem-manager-autosetup: Detect and don't break 3G setups
diff --git a/patches/openwrt/a-new-kernel-5.15/0018-mvebu-patches-5.15-Backport-Turris-Omnia-LED-changes.patch b/patches/openwrt/a-new-kernel-5.15/0018-mvebu-patches-5.15-Backport-Turris-Omnia-LED-changes.patch
index 3ed94b334..e8cf4b632 100644
--- a/patches/openwrt/a-new-kernel-5.15/0018-mvebu-patches-5.15-Backport-Turris-Omnia-LED-changes.patch
+++ b/patches/openwrt/a-new-kernel-5.15/0018-mvebu-patches-5.15-Backport-Turris-Omnia-LED-changes.patch
@@ -1,22 +1,18 @@
-From e4bb65724234112cdeea590c97d64d7e7f523507 Mon Sep 17 00:00:00 2001
+From 0ffe3b232fc3b827b1f3f1bbcd313ab28ab5b86b Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <marek.behun@nic.cz>
 Date: Mon, 16 Oct 2023 10:59:27 +0200
-Subject: [PATCH 1/3] mvebu: patches-5.15: Backport Turris Omnia LED changes
+Subject: [PATCH] mvebu: patches-5.15: Backport Turris Omnia LED changes
 
 ---
  ...rris-omnia-convert-to-use-dev_groups.patch |  45 ++++
  ...ia-Use-sysfs_emit-instead-of-sprintf.patch |  31 +++
- ...omnia-Drop-unnecessary-mutex-locking.patch |  66 +++++
- ...-turris-omnia-Do-not-use-SMBUS-calls.patch | 145 +++++++++++
  ...a-Make-set_brightness-more-efficient.patch | 207 +++++++++++++++
  ...a-Support-HW-controlled-mode-via-pri.patch | 201 +++++++++++++++
  ...a-Add-support-for-enabling-disabling.patch | 244 ++++++++++++++++++
  ...a-Fix-brightness-setting-and-trigger.patch | 167 ++++++++++++
- 8 files changed, 1106 insertions(+)
+ 6 files changed, 895 insertions(+)
  create mode 100644 target/linux/generic/backport-5.15/830-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch
  create mode 100644 target/linux/generic/backport-5.15/830-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch
- create mode 100644 target/linux/generic/backport-5.15/830-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
- create mode 100644 target/linux/generic/backport-5.15/830-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
  create mode 100644 target/linux/generic/backport-5.15/830-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch
  create mode 100644 target/linux/generic/backport-5.15/830-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch
  create mode 100644 target/linux/generic/backport-5.15/830-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch
@@ -110,229 +106,6 @@ index 0000000000..200d693b73
 + }
 + 
 + static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
-diff --git a/target/linux/generic/backport-5.15/830-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch b/target/linux/generic/backport-5.15/830-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
-new file mode 100644
-index 0000000000..4178f150d9
---- /dev/null
-+++ b/target/linux/generic/backport-5.15/830-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
-@@ -0,0 +1,66 @@
-+From 760b6b7925bf09491aafa4727eef74fc6bf738b0 Mon Sep 17 00:00:00 2001
-+From: Marek BehĂşn <kabel@kernel.org>
-+Date: Wed, 2 Aug 2023 18:07:43 +0200
-+Subject: leds: turris-omnia: Drop unnecessary mutex locking
-+MIME-Version: 1.0
-+Content-Type: text/plain; charset=UTF-8
-+Content-Transfer-Encoding: 8bit
-+
-+Do not lock driver mutex in the global LED panel brightness sysfs
-+accessors brightness_show() and brightness_store().
-+
-+The mutex locking is unnecessary here. The I2C transfers are guarded by
-+I2C core locking mechanism, and the LED commands itself do not interfere
-+with other commands.
-+
-+Fixes: 089381b27abe ("leds: initial support for Turris Omnia LEDs")
-+Signed-off-by: Marek BehĂşn <kabel@kernel.org>
-+Reviewed-by: Lee Jones <lee@kernel.org>
-+Link: https://lore.kernel.org/r/20230802160748.11208-2-kabel@kernel.org
-+Signed-off-by: Lee Jones <lee@kernel.org>
-+---
-+ drivers/leds/leds-turris-omnia.c | 11 +----------
-+ 1 file changed, 1 insertion(+), 10 deletions(-)
-+
-+(limited to 'drivers/leds/leds-turris-omnia.c')
-+
-+--- a/drivers/leds/leds-turris-omnia.c
-++++ b/drivers/leds/leds-turris-omnia.c
-+@@ -156,12 +156,9 @@ static ssize_t brightness_show(struct de
-+ 			       char *buf)
-+ {
-+ 	struct i2c_client *client = to_i2c_client(dev);
-+-	struct omnia_leds *leds = i2c_get_clientdata(client);
-+ 	int ret;
-+ 
-+-	mutex_lock(&leds->lock);
-+ 	ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
-+-	mutex_unlock(&leds->lock);
-+ 
-+ 	if (ret < 0)
-+ 		return ret;
-+@@ -173,7 +170,6 @@ static ssize_t brightness_store(struct d
-+ 				const char *buf, size_t count)
-+ {
-+ 	struct i2c_client *client = to_i2c_client(dev);
-+-	struct omnia_leds *leds = i2c_get_clientdata(client);
-+ 	unsigned long brightness;
-+ 	int ret;
-+ 
-+@@ -183,15 +179,10 @@ static ssize_t brightness_store(struct d
-+ 	if (brightness > 100)
-+ 		return -EINVAL;
-+ 
-+-	mutex_lock(&leds->lock);
-+ 	ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
-+ 					(u8)brightness);
-+-	mutex_unlock(&leds->lock);
-+ 
-+-	if (ret < 0)
-+-		return ret;
-+-
-+-	return count;
-++	return ret < 0 ? ret : count;
-+ }
-+ static DEVICE_ATTR_RW(brightness);
-+ 
-diff --git a/target/linux/generic/backport-5.15/830-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch b/target/linux/generic/backport-5.15/830-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
-new file mode 100644
-index 0000000000..5460881cca
---- /dev/null
-+++ b/target/linux/generic/backport-5.15/830-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
-@@ -0,0 +1,145 @@
-+From 28350bc0ac77e17365ba87d3edb2db0a79c98fdd Mon Sep 17 00:00:00 2001
-+From: Marek BehĂşn <kabel@kernel.org>
-+Date: Mon, 18 Sep 2023 18:11:01 +0200
-+Subject: leds: turris-omnia: Do not use SMBUS calls
-+MIME-Version: 1.0
-+Content-Type: text/plain; charset=UTF-8
-+Content-Transfer-Encoding: 8bit
-+
-+The leds-turris-omnia driver uses three function for I2C access:
-+- i2c_smbus_write_byte_data() and i2c_smbus_read_byte_data(), which
-+  cause an emulated SMBUS transfer,
-+- i2c_master_send(), which causes an ordinary I2C transfer.
-+
-+The Turris Omnia MCU LED controller is not semantically SMBUS, it
-+operates as a simple I2C bus. It does not implement any of the SMBUS
-+specific features, like PEC, or procedure calls, or anything. Moreover
-+the I2C controller driver also does not implement SMBUS, and so the
-+emulated SMBUS procedure from drivers/i2c/i2c-core-smbus.c is used for
-+the SMBUS calls, which gives an unnecessary overhead.
-+
-+When I first wrote the driver, I was unaware of these facts, and I
-+simply used the first function that worked.
-+
-+Drop the I2C SMBUS calls and instead use simple I2C transfers.
-+
-+Fixes: 089381b27abe ("leds: initial support for Turris Omnia LEDs")
-+Signed-off-by: Marek BehĂşn <kabel@kernel.org>
-+Link: https://lore.kernel.org/r/20230918161104.20860-2-kabel@kernel.org
-+Signed-off-by: Lee Jones <lee@kernel.org>
-+---
-+ drivers/leds/leds-turris-omnia.c | 54 +++++++++++++++++++++++++++++++---------
-+ 1 file changed, 42 insertions(+), 12 deletions(-)
-+
-+--- a/drivers/leds/leds-turris-omnia.c
-++++ b/drivers/leds/leds-turris-omnia.c
-+@@ -2,7 +2,7 @@
-+ /*
-+  * CZ.NIC's Turris Omnia LEDs driver
-+  *
-+- * 2020 by Marek BehĂşn <kabel@kernel.org>
-++ * 2020, 2023 by Marek BehĂşn <kabel@kernel.org>
-+  */
-+ 
-+ #include <linux/i2c.h>
-+@@ -41,6 +41,37 @@ struct omnia_leds {
-+ 	struct omnia_led leds[];
-+ };
-+ 
-++static int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd, u8 val)
-++{
-++	u8 buf[2] = { cmd, val };
-++
-++	return i2c_master_send(client, buf, sizeof(buf));
-++}
-++
-++static int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd)
-++{
-++	struct i2c_msg msgs[2];
-++	u8 reply;
-++	int ret;
-++
-++	msgs[0].addr = client->addr;
-++	msgs[0].flags = 0;
-++	msgs[0].len = 1;
-++	msgs[0].buf = &cmd;
-++	msgs[1].addr = client->addr;
-++	msgs[1].flags = I2C_M_RD;
-++	msgs[1].len = 1;
-++	msgs[1].buf = &reply;
-++
-++	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
-++	if (likely(ret == ARRAY_SIZE(msgs)))
-++		return reply;
-++	else if (ret < 0)
-++		return ret;
-++	else
-++		return -EIO;
-++}
-++
-+ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
-+ 					     enum led_brightness brightness)
-+ {
-+@@ -64,7 +95,7 @@ static int omnia_led_brightness_set_bloc
-+ 	if (buf[2] || buf[3] || buf[4])
-+ 		state |= CMD_LED_STATE_ON;
-+ 
-+-	ret = i2c_smbus_write_byte_data(leds->client, CMD_LED_STATE, state);
-++	ret = omnia_cmd_write_u8(leds->client, CMD_LED_STATE, state);
-+ 	if (ret >= 0 && (state & CMD_LED_STATE_ON))
-+ 		ret = i2c_master_send(leds->client, buf, 5);
-+ 
-+@@ -114,9 +145,9 @@ static int omnia_led_register(struct i2c
-+ 	cdev->brightness_set_blocking = omnia_led_brightness_set_blocking;
-+ 
-+ 	/* put the LED into software mode */
-+-	ret = i2c_smbus_write_byte_data(client, CMD_LED_MODE,
-+-					CMD_LED_MODE_LED(led->reg) |
-+-					CMD_LED_MODE_USER);
-++	ret = omnia_cmd_write_u8(client, CMD_LED_MODE,
-++				 CMD_LED_MODE_LED(led->reg) |
-++				 CMD_LED_MODE_USER);
-+ 	if (ret < 0) {
-+ 		dev_err(dev, "Cannot set LED %pOF to software mode: %i\n", np,
-+ 			ret);
-+@@ -124,8 +155,8 @@ static int omnia_led_register(struct i2c
-+ 	}
-+ 
-+ 	/* disable the LED */
-+-	ret = i2c_smbus_write_byte_data(client, CMD_LED_STATE,
-+-					CMD_LED_STATE_LED(led->reg));
-++	ret = omnia_cmd_write_u8(client, CMD_LED_STATE,
-++				 CMD_LED_STATE_LED(led->reg));
-+ 	if (ret < 0) {
-+ 		dev_err(dev, "Cannot set LED %pOF brightness: %i\n", np, ret);
-+ 		return ret;
-+@@ -158,7 +189,7 @@ static ssize_t brightness_show(struct de
-+ 	struct i2c_client *client = to_i2c_client(dev);
-+ 	int ret;
-+ 
-+-	ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
-++	ret = omnia_cmd_read_u8(client, CMD_LED_GET_BRIGHTNESS);
-+ 
-+ 	if (ret < 0)
-+ 		return ret;
-+@@ -179,8 +210,7 @@ static ssize_t brightness_store(struct d
-+ 	if (brightness > 100)
-+ 		return -EINVAL;
-+ 
-+-	ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
-+-					(u8)brightness);
-++	ret = omnia_cmd_write_u8(client, CMD_LED_SET_BRIGHTNESS, brightness);
-+ 
-+ 	return ret < 0 ? ret : count;
-+ }
-+@@ -238,8 +268,8 @@ static int omnia_leds_remove(struct i2c_
-+ 	u8 buf[5];
-+ 
-+ 	/* put all LEDs into default (HW triggered) mode */
-+-	i2c_smbus_write_byte_data(client, CMD_LED_MODE,
-+-				  CMD_LED_MODE_LED(OMNIA_BOARD_LEDS));
-++	omnia_cmd_write_u8(client, CMD_LED_MODE,
-++			   CMD_LED_MODE_LED(OMNIA_BOARD_LEDS));
-+ 
-+ 	/* set all LEDs color to [255, 255, 255] */
-+ 	buf[0] = CMD_LED_COLOR;
 diff --git a/target/linux/generic/backport-5.15/830-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch b/target/linux/generic/backport-5.15/830-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch
 new file mode 100644
 index 0000000000..3f7dd64841
@@ -1177,5 +950,5 @@ index 0000000000..ec6171ec67
 + 
 + 	return le16_to_cpu(reply);
 -- 
-2.41.0
+2.43.0
 
diff --git a/patches/openwrt/wip/0003-include-kernels-add-dedicated-files-for-versions-5.1.patch b/patches/openwrt/wip/0003-include-kernels-add-dedicated-files-for-versions-5.1.patch
index 796b5a6a5..3176f0a59 100644
--- a/patches/openwrt/wip/0003-include-kernels-add-dedicated-files-for-versions-5.1.patch
+++ b/patches/openwrt/wip/0003-include-kernels-add-dedicated-files-for-versions-5.1.patch
@@ -26,8 +26,8 @@ index 0000000000..4c18bc35c2
 --- /dev/null
 +++ b/include/kernel-5.15
 @@ -0,0 +1,2 @@
-+LINUX_VERSION-5.15 = .137
-+LINUX_KERNEL_HASH-5.15.137 = 9749b21609f9e7ad9c46160c2c107db823b99cef77fa6cb080b6c2dc685fb2f7
++LINUX_VERSION-5.15 = .139
++LINUX_KERNEL_HASH-5.15.139 = 9c68c10dfe18e59b892e940436dea6a18d167160d55e62563cf7282244d8044e
 -- 
 2.40.1
 
diff --git a/patches/openwrt/wip/9000-kernel-bump-release-version-to-2.patch b/patches/openwrt/wip/9000-kernel-bump-release-version-to-2.patch
deleted file mode 100644
index 458c95db7..000000000
--- a/patches/openwrt/wip/9000-kernel-bump-release-version-to-2.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From dcf6250f15d59ba27616cbc7313870fd6452aa8a Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <marek.behun@nic.cz>
-Date: Thu, 19 Oct 2023 11:07:16 +0200
-Subject: [PATCH] kernel: bump release version to 2
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Signed-off-by: Marek BehĂşn <marek.behun@nic.cz>
----
- include/kernel-version.mk | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/include/kernel-version.mk b/include/kernel-version.mk
-index 1edb01df27..4b1c852a08 100644
---- a/include/kernel-version.mk
-+++ b/include/kernel-version.mk
-@@ -1,6 +1,6 @@
- 
- # Use the default kernel version if the Makefile doesn't override it
--LINUX_RELEASE?=1
-+LINUX_RELEASE?=2
- 
- ifdef CONFIG_TESTING_KERNEL
-   KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER)
--- 
-2.41.0
-
-- 
GitLab