Commit 67cfcfa7 authored by Miguel Gómez Sexto's avatar Miguel Gómez Sexto

tdc: store channel activation in the library structure

Signed-off-by: Miguel Gómez Sexto's avatarMiguel Gomez <magomez@igalia.com>
parent b4a073d2
...@@ -94,9 +94,11 @@ int tdc_init(void) ...@@ -94,9 +94,11 @@ int tdc_init(void)
for (j = 0; j < ARRAY_SIZE(b->ctrl); j++) { for (j = 0; j < ARRAY_SIZE(b->ctrl); j++) {
b->ctrl[j] = -1; b->ctrl[j] = -1;
b->data[j] = -1; b->data[j] = -1;
b->enabled[j] = 0;
} }
printf("Found device %s\n", b->sysbase); printf("Found device %s\n", b->sysbase);
} }
globfree(&glob_dev); globfree(&glob_dev);
globfree(&glob_sys); globfree(&glob_sys);
...@@ -120,6 +122,7 @@ void tdc_exit(void) ...@@ -120,6 +122,7 @@ void tdc_exit(void)
b->data[j] = -1; b->data[j] = -1;
err++; err++;
} }
b->enabled[j] = 0;
} }
if (err) if (err)
fprintf(stderr, "%s: device %s was still open\n", fprintf(stderr, "%s: device %s was still open\n",
...@@ -259,8 +262,10 @@ int tdc_set_active_channels(struct tdc_board *b, uint32_t config) ...@@ -259,8 +262,10 @@ int tdc_set_active_channels(struct tdc_board *b, uint32_t config)
sprintf(file, "tdc-cset%i/enable", i); sprintf(file, "tdc-cset%i/enable", i);
if (config & (1 << i)) { if (config & (1 << i)) {
res = tdc_sysfs_set(b, file, 1); res = tdc_sysfs_set(b, file, 1);
b->enabled[i] = 1;
} else { } else {
res = tdc_sysfs_set(b, file, 0); res = tdc_sysfs_set(b, file, 0);
b->enabled[i] = 0;
} }
if (res) { if (res) {
printf("Error setting ZIO chan config in cset %i\n", i); printf("Error setting ZIO chan config in cset %i\n", i);
......
...@@ -9,6 +9,7 @@ struct tdc_board { ...@@ -9,6 +9,7 @@ struct tdc_board {
char *sysbase; char *sysbase;
int ctrl[5]; /* The 5 control channels */ int ctrl[5]; /* The 5 control channels */
int data[5]; /* The 5 data channels */ int data[5]; /* The 5 data channels */
int enabled[5]; /* channel activation */
}; };
struct tdc_time { struct tdc_time {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment