}
}
+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)
{
struct led *newled;
newled->sysfspath = bp;
newled->controlfd = bfp;
-
+
*led = newled;
+
+ if ( set_led(newled, 255) )
+ goto cleanup_fp;
+
+ if ( set_led(newled, 0) )
+ goto cleanup_fp;
+
return 0;
cleanup_fp:
(*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)
{