-
Notifications
You must be signed in to change notification settings - Fork 6
SoftPWM fails to build on kernel >= 4.10 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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). |
An alternative is to drop the SoftPWM driver and do the PWM is userspace, I guess. |
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. |
Hi, any update here guys? |
Here is a fix. As far as I understood while lurking into kernel code for a few nights
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 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 |
@YNikiforov, just now I tested your patch, it builds, and works, however, for my device I had to change the gpio chip with the |
I don't know if this project is still alive...
The softpwm module doesn't build on kernels from 4.10 onward. It fails with
Quick googling tells me that this is a common error introduced with kernel 4.10, but I am not a programmer and cannot easily fix this.
The text was updated successfully, but these errors were encountered: