[PATCH v4 4/5] mikrobus: Add mikroBUS driver

Markus Elfring Markus.Elfring at web.de
Mon Mar 18 10:58:10 PDT 2024


…
> +++ b/drivers/misc/mikrobus/mikrobus_core.c
…
> +static int mikrobus_pinctrl_setup(struct mikrobus_port *port,
> +				  struct addon_board_info *board)
> +{
> +	int ret;
> +
> +	if (!board || board->pin_state[MIKROBUS_PIN_PWM] == MIKROBUS_STATE_PWM)
> +		ret = mikrobus_pinctrl_select(port, "pwm_default");
> +	else
> +		ret = mikrobus_pinctrl_select(port, "pwm_gpio");
…

How do you think about to avoid the specification of a bit of duplicate source code here
by using conditional operator expressions?

	ret = mikrobus_pinctrl_select(port,
				      ((!board ||
					board->pin_state[MIKROBUS_PIN_PWM] == MIKROBUS_STATE_PWM)
				      ? "pwm_default"
				      : "pwm_gpio"));


Regards,
Markus



More information about the linux-arm-kernel mailing list