2013/1/14 Matt Dainty <[email protected]>:
> Attached is a patch that adds soekris(4) which provides access to the
> GPIO and LEDs as implemented by the onboard Xilinx FPGA on the Soekris
Dunno if I am out of my league here, but:
> +void
> +soekris_gpio_write(void *arg, int pin, int value)
> +{
> + struct soekris_softc *sc = arg;
> + u_int16_t data;
> +
> + data = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SOEKRIS_GPIO_INPUT);
> +
> + if (value == GPIO_PIN_LOW)
> + data &= ~(1 << pin);
> + else if (value == GPIO_PIN_HIGH)
> + data |= (1 << pin);
> +
> + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SOEKRIS_GPIO_OUTPUT, data);
> +}
> +void
> +soekris_led_write(void *arg, int pin, int value)
> +{
> + struct soekris_softc *sc = arg;
> +
> + bus_space_write_1(sc->sc_iot, sc->sc_ioh, soekris_led_offset[pin],
> + value);
These two (and the read function) don't really seem to prevent me from
writing or reading pin/led 23498324 and have it wander far off into
memory. Then again, that protection may be at the ioctl level, making
my whole comment moot, but at least bus_space_write_N() doesn't check
it afterwards.
--
May the most significant bit of your life be positive.