Skip to content
Snippets Groups Projects
Commit 19f91b26 authored by Florian Fainelli's avatar Florian Fainelli
Browse files

rssileds: improve performance


LEDs brightness is now only updated if the value actually changed, thus reducing
the number of fwrite syscalls significantly.

Signed-off-by: default avatarDaniel Golle <dgolle@allnet.de>

SVN-Revision: 33766
parent ed393422
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=rssileds PKG_NAME:=rssileds
PKG_VERSION:=0.1 PKG_VERSION:=0.2
PKG_RELEASE:=1 PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
......
...@@ -70,6 +70,32 @@ void log_rules(rule_t *rules) ...@@ -70,6 +70,32 @@ void log_rules(rule_t *rules)
} }
} }
int set_led(struct led *led, unsigned char value)
{
char buf[8];
if ( ! led )
return -1;
if ( ! led->controlfd )
return -1;
if ( led->state == value )
return 0;
snprintf(buf, 8, "%d", value);
rewind(led->controlfd);
if ( ! fwrite(buf, sizeof(char), strlen(buf), led->controlfd) )
return -2;
fflush(led->controlfd);
led->state=value;
return 0;
}
int init_led(struct led **led, char *ledname) int init_led(struct led **led, char *ledname)
{ {
struct led *newled; struct led *newled;
...@@ -102,8 +128,15 @@ int init_led(struct led **led, char *ledname) ...@@ -102,8 +128,15 @@ int init_led(struct led **led, char *ledname)
newled->sysfspath = bp; newled->sysfspath = bp;
newled->controlfd = bfp; newled->controlfd = bfp;
*led = newled; *led = newled;
if ( set_led(newled, 255) )
goto cleanup_fp;
if ( set_led(newled, 0) )
goto cleanup_fp;
return 0; return 0;
cleanup_fp: cleanup_fp:
...@@ -124,29 +157,6 @@ void close_led(struct led **led) ...@@ -124,29 +157,6 @@ void close_led(struct led **led)
(*led)=NULL; (*led)=NULL;
} }
int set_led(struct led *led, unsigned char value)
{
char buf[8];
if ( ! led )
return -1;
if ( ! led->controlfd )
return -1;
snprintf(buf, 8, "%d", value);
rewind(led->controlfd);
if ( ! fwrite(buf, sizeof(char), strlen(buf), led->controlfd) )
return -2;
fflush(led->controlfd);
led->state=value;
return 0;
}
int quality(const struct iwinfo_ops *iw, const char *ifname) int quality(const struct iwinfo_ops *iw, const char *ifname)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment