Message ID | 20220210140745.1059087-2-brgl@bgdev.pl |
---|---|
State | New |
Headers | show |
Series | libgpiod v2: rewrite tests for the C library | expand |
On Thu, Feb 10, 2022 at 03:07:42PM +0100, Bartosz Golaszewski wrote: > While it was initially agreed that NULL line_config passed to > gpiod_chip_request_lines() would result in lines being requested with > default config (just like a newly created struct gpiod_line_config), > I believe this is unintuitive in the context of all other functions in > the C library not being NULL-aware (as advertised in one of the first > paragraphs of the documentation) and should be changed to make both > config structures mandatory. > > This is C after all and it should be both explicit and spartan. :) > Fair enough. Reviewed-by: Kent Gibson <warthog618@gmail.com> > Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> > --- > include/gpiod.h | 4 +--- > lib/line-config.c | 5 ----- > 2 files changed, 1 insertion(+), 8 deletions(-) > > diff --git a/include/gpiod.h b/include/gpiod.h > index 68130ad..074e395 100644 > --- a/include/gpiod.h > +++ b/include/gpiod.h > @@ -173,11 +173,9 @@ int gpiod_chip_find_line(struct gpiod_chip *chip, const char *name); > * @brief Request a set of lines for exclusive usage. > * @param chip GPIO chip object. > * @param req_cfg Request config object. > - * @param line_cfg Line config object. May be NULL. > + * @param line_cfg Line config object. > * @return New line request object or NULL if an error occurred. The request > * must be released by the caller using ::gpiod_line_request_release. > - * @note If line_cfg is NULL, lines will be requested in input mode with no > - * additional parameters set. > */ > struct gpiod_line_request * > gpiod_chip_request_lines(struct gpiod_chip *chip, > diff --git a/lib/line-config.c b/lib/line-config.c > index 2ac9f5f..346d331 100644 > --- a/lib/line-config.c > +++ b/lib/line-config.c > @@ -903,11 +903,6 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config, > uint64_t mask, values; > int ret; > > - if (!config) { > - cfgbuf->flags = GPIO_V2_LINE_FLAG_INPUT; > - return 0; > - } > - > if (config->too_complex) > goto err_2big; > > -- > 2.30.1 >
diff --git a/include/gpiod.h b/include/gpiod.h index 68130ad..074e395 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -173,11 +173,9 @@ int gpiod_chip_find_line(struct gpiod_chip *chip, const char *name); * @brief Request a set of lines for exclusive usage. * @param chip GPIO chip object. * @param req_cfg Request config object. - * @param line_cfg Line config object. May be NULL. + * @param line_cfg Line config object. * @return New line request object or NULL if an error occurred. The request * must be released by the caller using ::gpiod_line_request_release. - * @note If line_cfg is NULL, lines will be requested in input mode with no - * additional parameters set. */ struct gpiod_line_request * gpiod_chip_request_lines(struct gpiod_chip *chip, diff --git a/lib/line-config.c b/lib/line-config.c index 2ac9f5f..346d331 100644 --- a/lib/line-config.c +++ b/lib/line-config.c @@ -903,11 +903,6 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config, uint64_t mask, values; int ret; - if (!config) { - cfgbuf->flags = GPIO_V2_LINE_FLAG_INPUT; - return 0; - } - if (config->too_complex) goto err_2big;
While it was initially agreed that NULL line_config passed to gpiod_chip_request_lines() would result in lines being requested with default config (just like a newly created struct gpiod_line_config), I believe this is unintuitive in the context of all other functions in the C library not being NULL-aware (as advertised in one of the first paragraphs of the documentation) and should be changed to make both config structures mandatory. This is C after all and it should be both explicit and spartan. :) Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> --- include/gpiod.h | 4 +--- lib/line-config.c | 5 ----- 2 files changed, 1 insertion(+), 8 deletions(-)