/* Set GPOUT to the state specified (1, 0). Returns 0 on success, -EINVAL otherwise.  */
s32 stm32f2_gpout_set(const struct stm32f2_gpio_dsc *dsc, int state)
/* Set GPOUT to the state specified (1, 0). Returns 0 on success, -EINVAL otherwise.  */
s32 stm32f2_gpout_set(const struct stm32f2_gpio_dsc *dsc, int state)
{
	volatile struct stm32f2_gpio_regs	*gpio_regs;
	s32					rv;
	if (!dsc || dsc->port >= ARRAY_SIZE(io_base) || dsc->pin > 15) {
		if (gd->have_console) {
			printf("%s: incorrect params %d.%d.\n", __func__,
				dsc ? dsc->port : -1,
				dsc ? dsc->pin  : -1);
		}
		rv = -EINVAL;
		goto out;
	}
	gpio_regs = (struct stm32f2_gpio_regs *)io_base[dsc->port];
	if (state) {
		gpio_regs->bsrr = 1 << dsc->pin;
	} else {
		gpio_regs->bsrr = 1 << (dsc->pin + 16);
	}
	rv = 0;
out:
	return rv;
}