Hi Mary, thanks for your patch! On Thu, Sep 19, 2024 at 4:10 PM Mary Strodl <mstrodl@xxxxxxxxxxx> wrote: > FTDI FT2232H is a USB to GPIO chip. Sealevel produces some devices > with this chip. FT2232H presents itself as a composite device with two > interfaces (each is an "MPSSE"). Each MPSSE has two banks (high and low) > of 8 GPIO each. I believe some MPSSE's have only one bank, but I don't > know how to identify them (I don't have any for testing) and as a result > are unsupported for the time being. > > Additionally, this driver provides software polling-based interrupts for > edge detection. For the Sealevel device I have to test with, this works > well because there is hardware debouncing. From talking to Sealevel's > people, this is their preferred way to do edge detection. > > Signed-off-by: Mary Strodl <mstrodl@xxxxxxxxxxx> Interesting device! Is it working nicely with hotplug and using libgpiod for userspace access? Overall this looks very good, some comments: > +static int gpio_mpsse_get_direction(struct gpio_chip *chip, > + unsigned int offset) > +{ > + int ret; > + int bank = (offset & 8) >> 3; > + int bank_offset = offset & 7; > + struct mpsse_priv *priv = gpiochip_get_data(chip); > + > + mutex_lock(&priv->io_mutex); In all instances of mutex, I suggest using the new guarded mutexes from <linux/cleanup.h>. I this case just guard(mutex)(&priv->io_mutex); And then the mutex will be dropped when the function exits. Tighter scopes are possible, just: git grep guard drivers/gpio/ for a ton of examples. > + /* MPSSE directions are inverted */ > + if (priv->gpio_dir[bank] & BIT(bank_offset)) > + ret = 0; > + else > + ret = 1; Please use the new defines from <linux/gpio/driver.h>: #define GPIO_LINE_DIRECTION_IN 1 #define GPIO_LINE_DIRECTION_OUT 0 With the above addressed: Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx> Yours, Linus Walleij