You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Does Line.request()'s default arg matter for Input lines? #49
Does it matter what we set this arg for an input line? If not, can we get a short note in the docs that it doesn't matter. Maybe have it be an Option<u8> that can be set to None?
* @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set for a requested
* line, this specifies the default output value, should be 0 (low) or
* 1 (high), anything else than 0 or 1 will be interpreted as 1 (high)
if (lflags&GPIOHANDLE_REQUEST_OUTPUT) {
intval= !!handlereq.default_values[i];
ret=gpiod_direction_output(desc, val);
if (ret)
goto out_free_lh;
} elseif (lflags&GPIOHANDLE_REQUEST_INPUT) {
ret=gpiod_direction_input(desc);
if (ret)
goto out_free_lh;
}
You can see that for REQUEST_OUTPUT, the value from default_values[i] (which is the default arg in Rust code) is passed to gpiod_direction_output() to actually set the mode to output and the default state.
For REQUEST_INPUT however, default_values[i] is not used. (It's not used anywhere else in that function.)
I think a short note in the doc to say it only applies for outputs would make sense. Changing it to Option<u8> would just add unnecessary complexity, IMO.
Activity
[-]Does Line.request()[/-][+]Does Line.request() matter for Input lines?[/+][-]Does Line.request() matter for Input lines?[/-][+]Does Line.request()'s default arg matter for Input lines?[/+]JonathonReinhart commentedon Dec 18, 2023
Nope. I was in the neighborhood and tracked this down.
In the uAPI,
default_valuesis documented:So it only applies for
REQUEST_OUTPUT.This is confirmed by looking in the kernel:
You can see that for
REQUEST_OUTPUT, the value fromdefault_values[i](which is thedefaultarg in Rust code) is passed togpiod_direction_output()to actually set the mode to output and the default state.For
REQUEST_INPUThowever,default_values[i]is not used. (It's not used anywhere else in that function.)I think a short note in the doc to say it only applies for outputs would make sense. Changing it to
Option<u8>would just add unnecessary complexity, IMO.