Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1184397

Re: [PATCH 2/2] gpio: gpio-ftdi-cbus: add driver for FTDI CBUS GPIOs

From Linus Walleij <linus.walleij@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] gpio: gpio-ftdi-cbus: add driver for FTDI CBUS GPIOs
Date 2015-07-15 09:50 +0200
Message-ID <pMpC2-X9-17@gated-at.bofh.it> (permalink)
References <pDzhf-31o-1@gated-at.bofh.it> <pDzhf-31o-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Jun 21, 2015 at 12:12 AM, Stefan Agner <stefan@agner.ch> wrote:

> This driver allows to use the CBUS pins, e.g. CBUS 0-3 on FT232R
> type of devices. Note that the pins need to be configured first
> by using I/O mode signal option in the EEPROM. This is _not_ the
> factory default configuration of any of the four pins.
>
> See also FTDI's Application Note AN_232R-01.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>

I see no big problems with this driver but I guess the serial portions
are the controversial parts.

> +++ b/drivers/gpio/gpio-ftdi-cbus.c
> @@ -0,0 +1,167 @@
> +/*
> + * gpiolib support for FTDI SIO chips supporting CBUS GPIO's (FT232R class)
> + *
> + * Copyright 2015 Stefan Agner
> + *
> + * Author: Stefan Agner <stefan@agner.ch>
> + *
> + *  This program is free software; you can redistribute  it and/or modify it
> + *  under  the terms of  the GNU General  Public License as published by the
> + *  Free Software Foundation;  either version 2 of the  License, or (at your
> + *  option) any later version.
> + *
> + * Note: To use the GPIOs on CBUS the signal option need to be set to
> + * I/O mode in EEPROM!
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/slab.h>
> +#include <linux/module.h>
> +#include <linux/gpio.h>

#include <linux/gpio/driver.h>

should be enough.

> +static int ftdi_cbus_gpio_direction_input(struct gpio_chip *chip,
> +                                         unsigned offset)
> +{
> +       struct ftdi_cbus_gpio *fcg = to_ftdi_cbus_gpio(chip);
> +
> +       fcg->cbus_mask &= ~((1 << offset) << 4);

I usually replace:

(1 << offset)

with

#include <linux/bitops.h>

BIT(offset)

so it's clear what is happening.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH 2/2] gpio: gpio-ftdi-cbus: add driver for FTDI CBUS GPIOs Linus Walleij <linus.walleij@linaro.org> - 2015-07-15 09:50 +0200

csiph-web