public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: andrew@lunn•ch (Andrew Lunn)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2 3/7] drivers: gpio: Add support for GPIOs over Moxtet bus
Date: Thu, 9 Aug 2018 04:49:52 +0200	[thread overview]
Message-ID: <20180809024952.GC6884@lunn.ch> (raw)
In-Reply-To: <20180809022037.12001-4-marek.behun@nic.cz>

> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index 1324c8f966a7..8db046da5850 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -84,7 +84,8 @@ obj-$(CONFIG_GPIO_MC33880)	+= gpio-mc33880.o
>  obj-$(CONFIG_GPIO_MC9S08DZ60)	+= gpio-mc9s08dz60.o
>  obj-$(CONFIG_GPIO_ML_IOH)	+= gpio-ml-ioh.o
>  obj-$(CONFIG_GPIO_MM_LANTIQ)	+= gpio-mm-lantiq.o
> -obj-$(CONFIG_GPIO_MOCKUP)      += gpio-mockup.o
> +obj-$(CONFIG_GPIO_MOCKUP)	+= gpio-mockup.o
> +obj-$(CONFIG_GPIO_MOXTET)	+= gpio-moxtet.o
>  obj-$(CONFIG_GPIO_MPC5200)	+= gpio-mpc5200.o
>  obj-$(CONFIG_GPIO_MPC8XXX)	+= gpio-mpc8xxx.o
>  obj-$(CONFIG_GPIO_MSIC)		+= gpio-msic.o
> @@ -100,7 +101,7 @@ obj-$(CONFIG_GPIO_PCI_IDIO_16)	+= gpio-pci-idio-16.o
>  obj-$(CONFIG_GPIO_PCIE_IDIO_24)	+= gpio-pcie-idio-24.o
>  obj-$(CONFIG_GPIO_PISOSR)	+= gpio-pisosr.o
>  obj-$(CONFIG_GPIO_PL061)	+= gpio-pl061.o
> -obj-$(CONFIG_GPIO_PMIC_EIC_SPRD)	+= gpio-pmic-eic-sprd.o
> +obj-$(CONFIG_GPIO_PMIC_EIC_SPRD)+= gpio-pmic-eic-sprd.o
>  obj-$(CONFIG_GPIO_PXA)		+= gpio-pxa.o
>  obj-$(CONFIG_GPIO_RC5T583)	+= gpio-rc5t583.o
>  obj-$(CONFIG_GPIO_RDC321X)	+= gpio-rdc321x.o

Did you review your own patch? If so, you would of noticed something
odd going on here.

> diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
> new file mode 100644
> index 000000000000..d0b50581118d
> --- /dev/null
> +++ b/drivers/gpio/gpio-moxtet.c
> @@ -0,0 +1,209 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + *  Turris Mox Moxtet GPIO expander
> + *
> + *  Copyright (C) 2018 Marek Behun <marek.behun@nic•cz>
> + */
> +
> +#include <linux/gpio/consumer.h>
> +#include <linux/gpio.h>
> +#include <linux/mfd/moxtet.h>
> +#include <linux/module.h>
> +#include <linux/of_gpio.h>
> +
> +struct moxtet_gpio_chip {
> +	struct device		*dev;
> +	struct gpio_chip	gpio_chip;
> +	u8			in_mask;
> +	u8			out_mask;
> +};
> +
> +static int moxtet_gpio_dir_mask(struct gpio_chip *gc, unsigned int offset,
> +				int *dir, u8 *mask)
> +{
> +	struct moxtet_gpio_chip *chip = gpiochip_get_data(gc);
> +	int i;
> +
> +	*dir = 0;
> +	for (i = 0; i < 4; ++i) {
> +		*mask = 1 << i;
> +		if (*mask & chip->in_mask) {
> +			if (offset == 0)
> +				return 0;
> +			--offset;
> +		}
> +	}
> +
> +	*dir = 1;
> +	for (i = 0; i < 8; ++i) {
> +		*mask = 1 << i;
> +		if (*mask & chip->out_mask) {
> +			if (offset == 0)
> +				return 0;
> +		}
> +	}

You need some comment about what is going on here, because it is not
obvious.

	Andrew

  reply	other threads:[~2018-08-09  2:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09  2:20 [PATCH v2 0/7] Add support for the Turris Mox router Marek Behún
2018-08-09  2:20 ` [PATCH v2 1/7] pinctrl: armada-37xx: Correct mpp definitions Marek Behún
2018-08-09  2:20 ` [PATCH v2 2/7] drivers: mfd: Add support for Moxtet bus Marek Behún
2018-08-09  2:20 ` [PATCH v2 3/7] drivers: gpio: Add support for GPIOs over " Marek Behún
2018-08-09  2:49   ` Andrew Lunn [this message]
2018-08-09  2:57   ` Andrew Lunn
2018-08-09  2:20 ` [PATCH v2 4/7] watchdog: Add support for Armada 37xx CPU watchdog Marek Behún
2018-08-10  8:53   ` Miquel Raynal
2018-08-09  2:20 ` [PATCH v2 5/7] arm64: dts: marvell: armada-37xx: add nodes to support watchdog Marek Behún
2018-08-10  9:02   ` Miquel Raynal
2018-08-09  2:20 ` [PATCH v2 6/7] net: mvneta: Don't use GRO on Armada 3720 Marek Behún
2018-08-09  2:20 ` [PATCH v2 7/7] ARM64: dts: marvell: Add DTS file for Turris Mox Marek Behún

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180809024952.GC6884@lunn.ch \
    --to=andrew@lunn$(echo .)ch \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox