> Date: Fri, 29 Apr 2016 23:12:57 +1000
> From: Jonathan Gray <[email protected]>
> 
> On Sat, Apr 23, 2016 at 10:20:15PM +0200, Joerg Jung wrote:
> > On Tue, Apr 19, 2016 at 10:57:38AM +0200, Caspar Schutijser wrote:
> > > Hi bugs@,
> > > 
> > > On my laptop, wsconsctl crashes with a floating point exception when it
> > > wants to print keyboard.backlight. It divides by 0.
> > > 
> > > Below is a patch that fixes the issue, output from gdb and my dmesg.
> > 
> > Yes this is a known problem.  There were some suggestion to fix this not
> > in wsconsctl (but instead in acpithinkpad?).
> 
> Given this still isn't fixed here is a diff to do just that and
> return an error from the ioctl callback when max is 0.
> 
> Index: acpithinkpad.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/acpi/acpithinkpad.c,v
> retrieving revision 1.51
> diff -u -p -r1.51 acpithinkpad.c
> --- acpithinkpad.c    10 Jan 2016 16:30:43 -0000      1.51
> +++ acpithinkpad.c    29 Apr 2016 13:05:02 -0000
> @@ -630,6 +630,9 @@ thinkpad_get_backlight(struct wskbd_back
>  
>       kbl->min = 0;
>       kbl->max = (sc->sc_thinklight >> 8) & 0x0f;
> +     if (kbl->max == 0)
> +             return (-1);
> +
>       kbl->curval = sc->sc_thinklight & 0x0f;
>       return 0;
>  }

I think you should return ENOTTY, since that is what
wskbd_displayioctl() would have returned if we had no keyboard
backlight.

Reply via email to