fw/layer1: Change the tdma_schedule_set return value to # frames spanned
authorSylvain Munaut <tnt@246tNt.com>
Mon, 26 Apr 2010 18:45:59 +0000 (20:45 +0200)
committerSylvain Munaut <tnt@246tNt.com>
Wed, 28 Apr 2010 08:16:51 +0000 (10:16 +0200)
Previously, it returned the number of item + number of frames spanned
by the set. But that value isn't that useful and wasn't used by anyone.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
src/target/firmware/layer1/tdma_sched.c

index 9469369..8289210 100644 (file)
@@ -78,9 +78,9 @@ int tdma_schedule_set(uint8_t frame_offset, const struct tdma_sched_item *item_s
 {
        struct tdma_scheduler *sched = &l1s.tdma_sched;
        uint8_t bucket_nr = wrap_bucket(frame_offset);
-       int i;
+       int i, j;
 
-       for (i = 0; 1; i++) {
+       for (i = 0, j = 0; 1; i++) {
                const struct tdma_sched_item *sched_item = &item_set[i];
                struct tdma_sched_bucket *bucket = &sched->bucket[bucket_nr];
 
@@ -92,6 +92,7 @@ int tdma_schedule_set(uint8_t frame_offset, const struct tdma_sched_item *item_s
                if (sched_item->cb == NULL) {
                        /* advance to next bucket (== TDMA frame) */
                        bucket_nr = wrap_bucket(++frame_offset);
+                       j++;
                        continue;
                }
                /* check for bucket overflow */
@@ -105,7 +106,7 @@ int tdma_schedule_set(uint8_t frame_offset, const struct tdma_sched_item *item_s
                bucket->num_items++;
        }
 
-       return i;
+       return j;
 }
 
 /* Advance TDMA scheduler to the next bucket */