[Pommed-commits] r452 - in trunk: . pommed pommed/mactel
jblache at alioth.debian.org
jblache at alioth.debian.org
Sat Apr 5 16:07:49 UTC 2008
Author: jblache
Date: 2008-04-05 16:07:48 +0000 (Sat, 05 Apr 2008)
New Revision: 452
Modified:
trunk/ChangeLog
trunk/pommed/kbd_backlight.h
trunk/pommed/mactel/kbd_backlight.c
Log:
Handle path change for applesmc led with kernel 2.6.25.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-03-02 09:12:39 UTC (rev 451)
+++ trunk/ChangeLog 2008-04-05 16:07:48 UTC (rev 452)
@@ -2,6 +2,8 @@
--------------------
version 1.17:
+ - pommed: handle path change for the applesmc led interface
+ starting with kernel 2.6.25.
version 1.16:
- pommed: add support for the MacBookPro4,1.
Modified: trunk/pommed/kbd_backlight.h
===================================================================
--- trunk/pommed/kbd_backlight.h 2008-03-02 09:12:39 UTC (rev 451)
+++ trunk/pommed/kbd_backlight.h 2008-04-05 16:07:48 UTC (rev 452)
@@ -7,6 +7,7 @@
#ifndef __powerpc__
#define KBD_BACKLIGHT "/sys/class/leds/smc:kbd_backlight/brightness"
+#define KBD_BACKLIGHT_2625 "/sys/class/leds/smc::kbd_backlight/brightness"
#endif /* !__powerpc__ */
Modified: trunk/pommed/mactel/kbd_backlight.c
===================================================================
--- trunk/pommed/mactel/kbd_backlight.c 2008-03-02 09:12:39 UTC (rev 451)
+++ trunk/pommed/mactel/kbd_backlight.c 2008-04-05 16:07:48 UTC (rev 452)
@@ -43,18 +43,39 @@
static int
+kbd_backlight_open(int flags)
+{
+ int errno1;
+ int fd;
+
+ fd = open(KBD_BACKLIGHT, flags);
+ if (fd < 0)
+ {
+ errno1 = errno;
+
+ fd = open(KBD_BACKLIGHT_2625, flags);
+ if (fd < 0)
+ {
+ logmsg(LOG_WARNING, "Could not open %s: %s", KBD_BACKLIGHT, strerror(errno1));
+ logmsg(LOG_WARNING, "Could not open %s: %s", KBD_BACKLIGHT_2625, strerror(errno));
+ return -1;
+ }
+ }
+
+ return fd;
+}
+
+
+static int
kbd_backlight_get(void)
{
int fd;
int ret;
char buf[8];
- fd = open(KBD_BACKLIGHT, O_RDONLY);
+ fd = kbd_backlight_open(O_RDONLY);
if (fd < 0)
- {
- logmsg(LOG_WARNING, "Could not open %s: %s", KBD_BACKLIGHT, strerror(errno));
- return -1;
- }
+ return -1;
memset(buf, 0, 8);
@@ -85,6 +106,7 @@
float step;
struct timespec fade_step;
+ int fd;
FILE *fp;
if (kbd_bck_info.inhibit & ~KBD_INHIBIT_CFG)
@@ -110,10 +132,15 @@
{
fadeval += step;
- fp = fopen(KBD_BACKLIGHT, "a");
+ fd = kbd_backlight_open(O_WRONLY);
+ if (fd < 0)
+ continue;
+
+ fp = fdopen(fd, "a");
if (fp == NULL)
{
- logmsg(LOG_WARNING, "Could not open %s: %s", KBD_BACKLIGHT, strerror(errno));
+ logmsg(LOG_WARNING, "Could not fdopen backlight fd: %s", strerror(errno));
+ close(fd);
continue;
}
@@ -127,10 +154,15 @@
}
}
- fp = fopen(KBD_BACKLIGHT, "a");
+ fd = kbd_backlight_open(O_WRONLY);
+ if (fd < 0)
+ return;
+
+ fp = fdopen(fd, "a");
if (fp == NULL)
{
- logmsg(LOG_WARNING, "Could not open %s: %s", KBD_BACKLIGHT, strerror(errno));
+ logmsg(LOG_WARNING, "Could not fdopen backlight fd %d: %s", fd, strerror(errno));
+ close(fd);
return;
}
More information about the Pommed-commits
mailing list