Git Product home page Git Product logo

Comments (5)

YNikiforov avatar YNikiforov commented on June 8, 2024 1

Here is a fix. As far as I understood while lurking into kernel code for a few nights

  • .class_attrs structure must be wrapped into .class_groups
  • .tv64 does not exist anymore and it looks kinda not needed as ktime_t is signed 64-bit in nanoseconds and is already comparable.

But I'm not a kernel developer, actually haven't done any code for Linux ever, so I'd appreciate a code review.

These changes were tested on openmediavault 5.6.5-1 (Usul) with Proxmox test kernel 5.11.7-1-pve. During compilation I had an error mentioning scripts/module.lds like here https://github.com/mkubecek/vmware-host-modules/issues/88 and the proposed solution worked for me.

Also the version without PWM proposed by @gpancot in #4 works fine for me. So if anyone doesn't like softpwm it makes perfect sense to use this on/off option.

So here is the diff, check it out, comment, try, have fun.

diff --git a/src/softpwm/dkms.conf b/src/softpwm/dkms.conf
index 0e9f44a..c274dd2 100644
--- a/src/softpwm/dkms.conf
+++ b/src/softpwm/dkms.conf
@@ -4,5 +4,5 @@ BUILT_MODULE_NAME=softpwm
 BUILT_MODULE_LOCATION=.
 DEST_MODULE_LOCATION=/updates
 PACKAGE_NAME=softpwm
-PACKAGE_VERSION=20180507
+PACKAGE_VERSION=20210503
 REMAKE_INITRD=yes
diff --git a/src/softpwm/softpwm.c b/src/softpwm/softpwm.c
index 7fe69b5..0453e4a 100644
--- a/src/softpwm/softpwm.c
+++ b/src/softpwm/softpwm.c
@@ -12,6 +12,7 @@ http://www.acmesystems.it/soft_pwm
 http://www.acmesystems.it/DAISY-2
 */
 
+/* Fix for newer kernels >= 4.10 by Yurii Nikiforov */
 
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -201,17 +202,21 @@ done:
 	return status ? : len;
 }
 
-/* Sysfs definitions for soft_pwm class */
-static struct class_attribute soft_pwm_class_attrs[] = {
-	__ATTR(export,   0200, NULL, export_store),
-	__ATTR(unexport, 0200, NULL, unexport_store),
-	__ATTR_NULL,
+static CLASS_ATTR_WO(export);
+static CLASS_ATTR_WO(unexport);
+
+static struct attribute *soft_pwm_class_attrs[] = {
+	&class_attr_export.attr,
+	&class_attr_unexport.attr,
+	NULL,
 };
 
+ATTRIBUTE_GROUPS(soft_pwm_class);
+
 static struct class soft_pwm_class = {
 	.name = "soft_pwm",
 	.owner = THIS_MODULE,
-	.class_attrs = soft_pwm_class_attrs,
+	.class_groups = soft_pwm_class_groups,
 };
 
 /* Setup the sysfs directory for a claimed PWM device */
@@ -308,7 +313,7 @@ enum hrtimer_restart soft_pwm_hrtimer_callback(struct hrtimer *timer) {
 		else if (desc->pulse >= desc->period)
 			desc->value = 1;
 		else {
-			if (desc->next_tick.tv64 <= now.tv64) {
+			if (desc->next_tick <= now) {
 				desc->value = 1 - desc->value;
 
 				desc->counter ++;
@@ -318,7 +323,7 @@ enum hrtimer_restart soft_pwm_hrtimer_callback(struct hrtimer *timer) {
 				if (desc->pulse == 0 ||
 					desc->pulse == desc->period ||
 					desc->pulses == 0) {
-					desc->next_tick.tv64 = KTIME_MAX;
+					desc->next_tick = KTIME_MAX;
 				} else {
 					t = desc->value ?
 						desc->pulse :
@@ -327,9 +332,9 @@ enum hrtimer_restart soft_pwm_hrtimer_callback(struct hrtimer *timer) {
 						t * 1000);
 				}
 			}
-			if (next_tick.tv64 == 0 ||
-				desc->next_tick.tv64 < next_tick.tv64) {
-				next_tick.tv64 = desc->next_tick.tv64;
+			if (next_tick == 0 ||
+				desc->next_tick < next_tick) {
+				next_tick = desc->next_tick;
 			}
 		}
 
@@ -340,7 +345,7 @@ next:
 		}
 	}
 
-	if (next_tick.tv64 > 0)
+	if (next_tick > 0)
 		hrtimer_start(&hr_timer, next_tick, HRTIMER_MODE_ABS);
 
 	return HRTIMER_NORESTART;
@@ -351,7 +356,7 @@ static int __init soft_pwm_init(void){
 	//struct timespec tp;
 
 	int status;
-	printk(KERN_INFO "SoftPWM v0.2-acme initializing.\n");
+	printk(KERN_INFO "SoftPWM v0.3-acme initializing.\n");
 
 	//hrtimer_get_res(CLOCK_MONOTONIC, &tp);
 	//printk(KERN_INFO "Clock resolution is %ldns\n", tp.tv_nsec);
@@ -394,4 +399,3 @@ static void __exit soft_pwm_exit(void){
 
 module_init(soft_pwm_init);
 module_exit(soft_pwm_exit);
-

Download as patch.txt

from hp_n36-40-54l_health_led_drivers.

stupidpupil avatar stupidpupil commented on June 8, 2024

It's not exactly dead. I'm glad you raised this issue!

I'm barely a programmer, I'm afraid, but I'll see if I can work out how hard this will be to fix (or better yet if someone else has already fixed the driver).

from hp_n36-40-54l_health_led_drivers.

stupidpupil avatar stupidpupil commented on June 8, 2024

An alternative is to drop the SoftPWM driver and do the PWM is userspace, I guess.

from hp_n36-40-54l_health_led_drivers.

TonyPuryer avatar TonyPuryer commented on June 8, 2024

Bumping this issue just to see if a fix or workaround has been found. I encountered the exact same error log when attempting to install the led drivers package on openmediavault 5.5.3-1. Thanks in advance.

from hp_n36-40-54l_health_led_drivers.

abonforti avatar abonforti commented on June 8, 2024

Hi, any update here guys?

from hp_n36-40-54l_health_led_drivers.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.