* [PATCH 0/5] mtd: nand: Rework/cleanup the Atmel NAND driver
@ 2017-01-27 16:34 Boris Brezillon
2017-01-27 16:34 ` [PATCH 1/5] gpio: Add the devm_get_index_gpiod_from_child() helper Boris Brezillon
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Boris Brezillon @ 2017-01-27 16:34 UTC (permalink / raw)
To: linux-arm-kernel
This is a complete rewrite of the driver whose main purpose is to
support the new DT representation where the NAND controller node is now
really visible in the DT and appears under the EBI bus. With this new
representation, we can add other devices under the EBI bus without
risking pinmuxing conflicts (the NAND controller is under the EBI
bus logic and as such, share some of its pins with other devices
connected on this bus).
Even though the goal of this rework was not necessarily to add new
features, the new driver has been designed with this in mind. With a
clearer separation between the different blocks and different IP
revisions, adding new functionalities should be easier (we already
have plans to support SMC timing configuration so that we no longer
have to rely on the configuration done by the bootloader/bootstrap).
Also note that we no longer have a custom ->cmdfunc() implementation,
which means we can now benefit from new features added in the core
implementation for free (support for new NAND operations for example).
The last thing that we gain with this rework is support for multi-chips
and multi-dies chips, thanks to the clean NAND controller <-> NAND
devices representation.
This new driver has been tested on several platforms (at91sam9261,
at91sam9g45, at91sam9x5, sama5d3 and sama5d4) to make sure it did not
introduce regressions, and it's worth mentioning that old bindings are
still supported (which partly explain the positive diffstat).
Here is a short description of the different patches:
Patches 1 and 2 are adding new helpers functions respectively to the
gpio and dmaengine subsystems. Note that I can put this code directly
in my driver but I had the impression these would better fit in the
dmaengine and gpio subsystem.
Alexandre, Linus, Vinod, let me know if you think I should keep this
code in my driver.
Patch 3 is the bulk of the work. As said above, it's a complete rewrite
of the existing driver, and patch 4 is documenting the new bindings.
And finally, patch 5 is removing the chip->write_page() whose only user
was the Atmel NAND driver.
Wenyou, Nicolas, Josh, I'd really appreciate if you could review this
series carefully (especially patch 3).
Haarvard, Hans-Christian, I only compile-tested for avr32. Can you test
it on a real platform?
Thanks,
Boris
Boris Brezillon (5):
gpio: Add the devm_get_index_gpiod_from_child() helper
dmaengine: Provide a wrapper for memcpy operations
mtd: nand: Cleanup/rework the atmel_nand driver
mtd: nand: atmel: Document the new DT bindings
mtd: nand: Remove unused chip->write_page() hook
.../devicetree/bindings/mtd/atmel-nand.txt | 106 +-
MAINTAINERS | 2 +-
drivers/gpio/devres.c | 30 +-
drivers/gpio/gpiolib.c | 9 +-
drivers/mtd/nand/Makefile | 2 +-
drivers/mtd/nand/atmel/Makefile | 4 +
drivers/mtd/nand/atmel/nfc.c | 2168 +++++++++++++++++
drivers/mtd/nand/atmel/pmecc.c | 1011 ++++++++
drivers/mtd/nand/atmel/pmecc.h | 73 +
drivers/mtd/nand/atmel_nand.c | 2479 --------------------
drivers/mtd/nand/atmel_nand_ecc.h | 163 --
drivers/mtd/nand/atmel_nand_nfc.h | 103 -
drivers/mtd/nand/nand_base.c | 10 +-
include/linux/dmaengine.h | 11 +
include/linux/gpio/consumer.h | 15 +-
include/linux/mtd/nand.h | 4 -
16 files changed, 3421 insertions(+), 2769 deletions(-)
create mode 100644 drivers/mtd/nand/atmel/Makefile
create mode 100644 drivers/mtd/nand/atmel/nfc.c
create mode 100644 drivers/mtd/nand/atmel/pmecc.c
create mode 100644 drivers/mtd/nand/atmel/pmecc.h
delete mode 100644 drivers/mtd/nand/atmel_nand.c
delete mode 100644 drivers/mtd/nand/atmel_nand_ecc.h
delete mode 100644 drivers/mtd/nand/atmel_nand_nfc.h
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] gpio: Add the devm_get_index_gpiod_from_child() helper
2017-01-27 16:34 [PATCH 0/5] mtd: nand: Rework/cleanup the Atmel NAND driver Boris Brezillon
@ 2017-01-27 16:34 ` Boris Brezillon
2017-01-30 9:49 ` Linus Walleij
2017-01-27 16:34 ` [PATCH 2/5] dmaengine: Provide a wrapper for memcpy operations Boris Brezillon
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Boris Brezillon @ 2017-01-27 16:34 UTC (permalink / raw)
To: linux-arm-kernel
devm_get_gpiod_from_child() currently allows GPIO users to request a GPIO
that is defined in a child fwnode instead of directly in the device
fwnode. Extend this API by adding the devm_get_index_gpiod_from_child()
helpers which does the same except you can also specify an index in case
the 'xx-gpios' property describe several GPIOs.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
I've added a new function instead of modifying the existing
devm_get_gpiod_from_child() helper to avoid patching all users of this
function.
Note that fwnode_get_named_gpiod() has been modified because there's no
external users.
---
drivers/gpio/devres.c | 30 +++++++++++++++++++++++++-----
drivers/gpio/gpiolib.c | 9 +++++----
include/linux/gpio/consumer.h | 15 +++++++++++++--
3 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
index b760cbbb41d8..4dbab629a05e 100644
--- a/drivers/gpio/devres.c
+++ b/drivers/gpio/devres.c
@@ -123,17 +123,20 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
EXPORT_SYMBOL(devm_gpiod_get_index);
/**
- * devm_get_gpiod_from_child - get a GPIO descriptor from a device's child node
+ * devm_get_index_gpiod_from_child - get a GPIO descriptor from a device's
+ * child node
* @dev: GPIO consumer
* @con_id: function within the GPIO consumer
+ * @index: index of the GPIO to obtain in the consumer
* @child: firmware node (child of @dev)
*
* GPIO descriptors returned from this function are automatically disposed on
* driver detach.
*/
-struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
- const char *con_id,
- struct fwnode_handle *child)
+struct gpio_desc *devm_get_index_gpiod_from_child(struct device *dev,
+ const char *con_id,
+ int index,
+ struct fwnode_handle *child)
{
static const char * const suffixes[] = { "gpios", "gpio" };
char prop_name[32]; /* 32 is max size of property name */
@@ -154,7 +157,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
snprintf(prop_name, sizeof(prop_name), "%s",
suffixes[i]);
- desc = fwnode_get_named_gpiod(child, prop_name);
+ desc = fwnode_get_named_gpiod(child, prop_name, index);
if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
break;
}
@@ -168,6 +171,23 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
return desc;
}
+EXPORT_SYMBOL(devm_get_index_gpiod_from_child);
+
+/**
+ * devm_get_gpiod_from_child - get a GPIO descriptor from a device's child node
+ * @dev: GPIO consumer
+ * @con_id: function within the GPIO consumer
+ * @child: firmware node (child of @dev)
+ *
+ * GPIO descriptors returned from this function are automatically disposed on
+ * driver detach.
+ */
+struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
+ const char *con_id,
+ struct fwnode_handle *child)
+{
+ return devm_get_index_gpiod_from_child(dev, con_id, 0, child);
+}
EXPORT_SYMBOL(devm_get_gpiod_from_child);
/**
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 86bf3b84ada5..9b7a7734e742 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3309,6 +3309,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
* fwnode_get_named_gpiod - obtain a GPIO from firmware node
* @fwnode: handle of the firmware node
* @propname: name of the firmware property representing the GPIO
+ * @index: index of the GPIO to obtain in the consumer
*
* This function can be used for drivers that get their configuration
* from firmware.
@@ -3320,7 +3321,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
* In case of error an ERR_PTR() is returned.
*/
struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
- const char *propname)
+ const char *propname, int index)
{
struct gpio_desc *desc = ERR_PTR(-ENODEV);
bool active_low = false;
@@ -3333,8 +3334,8 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
if (is_of_node(fwnode)) {
enum of_gpio_flags flags;
- desc = of_get_named_gpiod_flags(to_of_node(fwnode), propname, 0,
- &flags);
+ desc = of_get_named_gpiod_flags(to_of_node(fwnode), propname,
+ index, &flags);
if (!IS_ERR(desc)) {
active_low = flags & OF_GPIO_ACTIVE_LOW;
single_ended = flags & OF_GPIO_SINGLE_ENDED;
@@ -3342,7 +3343,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
} else if (is_acpi_node(fwnode)) {
struct acpi_gpio_info info;
- desc = acpi_node_get_gpiod(fwnode, propname, 0, &info);
+ desc = acpi_node_get_gpiod(fwnode, propname, index, &info);
if (!IS_ERR(desc))
active_low = info.polarity == GPIO_ACTIVE_LOW;
}
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index fb0fde686cb1..5b3c025333a6 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -135,7 +135,11 @@ int desc_to_gpio(const struct gpio_desc *desc);
struct fwnode_handle;
struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
- const char *propname);
+ const char *propname, int index);
+struct gpio_desc *devm_get_index_gpiod_from_child(struct device *dev,
+ const char *con_id,
+ int index,
+ struct fwnode_handle *child);
struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
const char *con_id,
struct fwnode_handle *child);
@@ -412,7 +416,14 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
struct fwnode_handle;
static inline struct gpio_desc *fwnode_get_named_gpiod(
- struct fwnode_handle *fwnode, const char *propname)
+ struct fwnode_handle *fwnode, const char *propname, int index)
+{
+ return ERR_PTR(-ENOSYS);
+}
+
+static inline struct gpio_desc *devm_get_index_gpiod_from_child(
+ struct device *dev, const char *con_id, int index,
+ struct fwnode_handle *child)
{
return ERR_PTR(-ENOSYS);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] dmaengine: Provide a wrapper for memcpy operations
2017-01-27 16:34 [PATCH 0/5] mtd: nand: Rework/cleanup the Atmel NAND driver Boris Brezillon
2017-01-27 16:34 ` [PATCH 1/5] gpio: Add the devm_get_index_gpiod_from_child() helper Boris Brezillon
@ 2017-01-27 16:34 ` Boris Brezillon
2017-01-27 16:34 ` [PATCH 4/5] mtd: nand: atmel: Document the new DT bindings Boris Brezillon
2017-01-27 16:34 ` [PATCH 5/5] mtd: nand: Remove unused chip->write_page() hook Boris Brezillon
3 siblings, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2017-01-27 16:34 UTC (permalink / raw)
To: linux-arm-kernel
Almost all ->device_prep_dma_xx() methods have a wrapper defined in
dmaengine.h. Add one for ->device_prep_dma_memcpy().
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
include/linux/dmaengine.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index feee6ec6a13b..533680860865 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -894,6 +894,17 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_memset(
len, flags);
}
+static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_memcpy(
+ struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
+ size_t len, unsigned long flags)
+{
+ if (!chan || !chan->device || !chan->device->device_prep_dma_memcpy)
+ return NULL;
+
+ return chan->device->device_prep_dma_memcpy(chan, dest, src,
+ len, flags);
+}
+
static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_sg(
struct dma_chan *chan,
struct scatterlist *dst_sg, unsigned int dst_nents,
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] mtd: nand: atmel: Document the new DT bindings
2017-01-27 16:34 [PATCH 0/5] mtd: nand: Rework/cleanup the Atmel NAND driver Boris Brezillon
2017-01-27 16:34 ` [PATCH 1/5] gpio: Add the devm_get_index_gpiod_from_child() helper Boris Brezillon
2017-01-27 16:34 ` [PATCH 2/5] dmaengine: Provide a wrapper for memcpy operations Boris Brezillon
@ 2017-01-27 16:34 ` Boris Brezillon
2017-01-27 16:34 ` [PATCH 5/5] mtd: nand: Remove unused chip->write_page() hook Boris Brezillon
3 siblings, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2017-01-27 16:34 UTC (permalink / raw)
To: linux-arm-kernel
Document the new DT bindings for the Atmel NAND controller and
deprecate the old ones.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
.../devicetree/bindings/mtd/atmel-nand.txt | 106 ++++++++++++++++++++-
1 file changed, 105 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
index 3e7ee99d3949..2a86ef2332dc 100644
--- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
@@ -1,4 +1,108 @@
-Atmel NAND flash
+Atmel NAND flash controller bindings
+
+The NAND flash controller node should be defined under the EBI bus (see
+Documentation/devicetree/bindings/memory-controllers/atmel,ebi.txt).
+One or several NAND devices can be defined under this NAND controller.
+The NAND controller might be connected to an ECC engine.
+
+* NAND controller bindings:
+
+Required properties:
+- compatible: should be one of the following
+ "atmel,at91rm9200-nand-controller"
+ "atmel,at91sam9261-nand-controller"
+ "atmel,at91sam9g45-nand-controller"
+ "atmel,sama5d3-nand-controller"
+- ranges: empty ranges property to forward EBI ranges definitions.
+- #address-cells: should be set to 2.
+- #size-cells: should be set to 1.
+- atmel,nfc-io: phandle to the NFC IO block. Only required for sama5d3
+ controllers.
+- atmel,nfc-sram: phandle to the NFC SRAM block. Only required for sama5d3
+ controllers.
+
+Optional properties:
+- ecc-engine: phandle to the PMECC block. Only meaningful if the SoC embeds
+ a PMECC engine.
+
+* NAND device/chip bindings:
+
+Required properties:
+- reg: describes the CS lines assigned to the NAND device. If the NAND device
+ exposes multiple CS lines (multi-dies chips), your reg property will
+ contain X tuples of 3 entries.
+ 1st entry: the CS line this NAND chip is connected to
+ 2nd entry: the base offset of the memory region assigned to this
+ device (always 0)
+ 3rd entry: the memory region size (always 0x800000)
+
+Optional properties:
+- rb-gpios: the GPIO(s) used to check the Ready/Busy status of the NAND.
+- cs-gpios: the GPIO(s) used to control the CS line.
+- det-gpios: the GPIO used to detect if a Smartmedia Card is present.
+- atmel,rb: an integer identifying the native Ready/Busy pin. Only meaningful
+ on sama5 SoCs.
+
+All generic properties described in
+Documentation/devicetree/bindings/mtd/{common,nand}.txt also apply to the NAND
+device node, and NAND partitions should be defined under the NAND node as
+described in Documentation/devicetree/bindings/mtd/partition.txt.
+
+* ECC engine (PMECC) bindings:
+
+Required properties:
+- compatible: should be one of the following
+ "atmel,at91sam9g45-pmecc"
+ "atmel,sama5d4-pmecc"
+ "atmel,sama5d2-pmecc"
+- reg: should contain 2 register ranges. The first one is pointing to the PMECC
+ block, and the second one to the PMECC_ERRLOC block.
+
+Example:
+
+ pmecc: ecc-engine at ffffc070 {
+ compatible = "atmel,at91sam9g45-pmecc";
+ reg = <0xffffc070 0x490>,
+ <0xffffc500 0x100>;
+ };
+
+ ebi: ebi at 10000000 {
+ compatible = "atmel,sama5d3-ebi";
+ #address-cells = <2>;
+ #size-cells = <1>;
+ atmel,smc = <&hsmc>;
+ reg = <0x10000000 0x10000000
+ 0x40000000 0x30000000>;
+ ranges = <0x0 0x0 0x10000000 0x10000000
+ 0x1 0x0 0x40000000 0x10000000
+ 0x2 0x0 0x50000000 0x10000000
+ 0x3 0x0 0x60000000 0x10000000>;
+ clocks = <&mck>;
+
+ nand_controller: nand-controller {
+ compatible = "atmel,sama5d3-nand-controller";
+ atmel,nfc-sram = <&nfc_sram>;
+ atmel,nfc-io = <&nfc_io>;
+ ecc-engine = <&pmecc>;
+ #address-cells = <2>;
+ #size-cells = <1>;
+ ranges;
+
+ nand at 3 {
+ reg = <0x3 0x0 0x800000>;
+ atmel,rb = <0>;
+
+ /*
+ * Put generic NAND/MTD properties and
+ * subnodes here.
+ */
+ };
+ };
+ };
+
+-----------------------------------------------------------------------
+
+Deprecated bindings (should not be used in new device trees):
Required properties:
- compatible: The possible values are:
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] mtd: nand: Remove unused chip->write_page() hook
2017-01-27 16:34 [PATCH 0/5] mtd: nand: Rework/cleanup the Atmel NAND driver Boris Brezillon
` (2 preceding siblings ...)
2017-01-27 16:34 ` [PATCH 4/5] mtd: nand: atmel: Document the new DT bindings Boris Brezillon
@ 2017-01-27 16:34 ` Boris Brezillon
3 siblings, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2017-01-27 16:34 UTC (permalink / raw)
To: linux-arm-kernel
The last/only user of the chip->write_page() hook (the Atmel NAND
controller driver) has been reworked and is no longer specifying a custom
->write_page() implementation.
Drop this hook before someone else start abusing it.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
drivers/mtd/nand/nand_base.c | 10 ++++------
include/linux/mtd/nand.h | 4 ----
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ec1c28aaaf23..c8894f31392e 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2839,9 +2839,10 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
/* We still need to erase leftover OOB data */
memset(chip->oob_poi, 0xff, mtd->oobsize);
}
- ret = chip->write_page(mtd, chip, column, bytes, wbuf,
- oob_required, page, cached,
- (ops->mode == MTD_OPS_RAW));
+
+ ret = nand_write_page(mtd, chip, column, bytes, wbuf,
+ oob_required, page, cached,
+ (ops->mode == MTD_OPS_RAW));
if (ret)
break;
@@ -4623,9 +4624,6 @@ int nand_scan_tail(struct mtd_info *mtd)
}
}
- if (!chip->write_page)
- chip->write_page = nand_write_page;
-
/*
* Check ECC mode, default to software if 3byte/512byte hardware ECC is
* selected and we have 256 byte pagesize fallback to software ECC
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index c5f3a012ae62..9d51dee53be4 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -818,7 +818,6 @@ nand_get_sdr_timings(const struct nand_data_interface *conf)
* @errstat: [OPTIONAL] hardware specific function to perform
* additional error status checks (determine if errors are
* correctable).
- * @write_page: [REPLACEABLE] High-level page write function
*/
struct nand_chip {
@@ -843,9 +842,6 @@ struct nand_chip {
int (*scan_bbt)(struct mtd_info *mtd);
int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state,
int status, int page);
- int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
- uint32_t offset, int data_len, const uint8_t *buf,
- int oob_required, int page, int cached, int raw);
int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip,
int feature_addr, uint8_t *subfeature_para);
int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/5] gpio: Add the devm_get_index_gpiod_from_child() helper
2017-01-27 16:34 ` [PATCH 1/5] gpio: Add the devm_get_index_gpiod_from_child() helper Boris Brezillon
@ 2017-01-30 9:49 ` Linus Walleij
2017-01-30 10:19 ` Boris Brezillon
0 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2017-01-30 9:49 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Jan 27, 2017 at 5:34 PM, Boris Brezillon
<boris.brezillon@free-electrons.com> wrote:
> devm_get_gpiod_from_child() currently allows GPIO users to request a GPIO
> that is defined in a child fwnode instead of directly in the device
> fwnode. Extend this API by adding the devm_get_index_gpiod_from_child()
> helpers which does the same except you can also specify an index in case
> the 'xx-gpios' property describe several GPIOs.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc Russell who faced this problem in the mvebu PCI driver (IIRC).
(...)
> +struct gpio_desc *devm_get_index_gpiod_from_child(struct device *dev,
> + const char *con_id,
> + int index,
> + struct fwnode_handle *child)
> {
> static const char * const suffixes[] = { "gpios", "gpio" };
> char prop_name[32]; /* 32 is max size of property name */
> @@ -154,7 +157,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
> snprintf(prop_name, sizeof(prop_name), "%s",
> suffixes[i]);
>
> - desc = fwnode_get_named_gpiod(child, prop_name);
> + desc = fwnode_get_named_gpiod(child, prop_name, index);
> if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
> break;
> }
> @@ -168,6 +171,23 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
>
> return desc;
> }
> +EXPORT_SYMBOL(devm_get_index_gpiod_from_child);
Rename this devm_fwnode_get_index_gpiod_from_child()
so that it fits the namespace of the other fwnode functions.
> + * devm_get_gpiod_from_child - get a GPIO descriptor from a device's child node
> + * @dev: GPIO consumer
> + * @con_id: function within the GPIO consumer
> + * @child: firmware node (child of @dev)
> + *
> + * GPIO descriptors returned from this function are automatically disposed on
> + * driver detach.
> + */
> +struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
> + const char *con_id,
> + struct fwnode_handle *child)
> +{
> + return devm_get_index_gpiod_from_child(dev, con_id, 0, child);
> +}
Take the opportunity to rename this devm_fwnode_get_gpiod_from_child()
as well.
I don't remember exactly why this wasn't added earlier, there was some
problem with referencing nodes that do not have devices.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] gpio: Add the devm_get_index_gpiod_from_child() helper
2017-01-30 9:49 ` Linus Walleij
@ 2017-01-30 10:19 ` Boris Brezillon
0 siblings, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2017-01-30 10:19 UTC (permalink / raw)
To: linux-arm-kernel
Hi Linus,
On Mon, 30 Jan 2017 10:49:23 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:
> On Fri, Jan 27, 2017 at 5:34 PM, Boris Brezillon
> <boris.brezillon@free-electrons.com> wrote:
>
> > devm_get_gpiod_from_child() currently allows GPIO users to request a GPIO
> > that is defined in a child fwnode instead of directly in the device
> > fwnode. Extend this API by adding the devm_get_index_gpiod_from_child()
> > helpers which does the same except you can also specify an index in case
> > the 'xx-gpios' property describe several GPIOs.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>
> Cc Russell who faced this problem in the mvebu PCI driver (IIRC).
>
> (...)
>
> > +struct gpio_desc *devm_get_index_gpiod_from_child(struct device *dev,
> > + const char *con_id,
> > + int index,
> > + struct fwnode_handle *child)
> > {
> > static const char * const suffixes[] = { "gpios", "gpio" };
> > char prop_name[32]; /* 32 is max size of property name */
> > @@ -154,7 +157,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
> > snprintf(prop_name, sizeof(prop_name), "%s",
> > suffixes[i]);
> >
> > - desc = fwnode_get_named_gpiod(child, prop_name);
> > + desc = fwnode_get_named_gpiod(child, prop_name, index);
> > if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
> > break;
> > }
> > @@ -168,6 +171,23 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
> >
> > return desc;
> > }
> > +EXPORT_SYMBOL(devm_get_index_gpiod_from_child);
>
> Rename this devm_fwnode_get_index_gpiod_from_child()
> so that it fits the namespace of the other fwnode functions.
Okay.
>
> > + * devm_get_gpiod_from_child - get a GPIO descriptor from a device's child node
> > + * @dev: GPIO consumer
> > + * @con_id: function within the GPIO consumer
> > + * @child: firmware node (child of @dev)
> > + *
> > + * GPIO descriptors returned from this function are automatically disposed on
> > + * driver detach.
> > + */
> > +struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
> > + const char *con_id,
> > + struct fwnode_handle *child)
> > +{
> > + return devm_get_index_gpiod_from_child(dev, con_id, 0, child);
> > +}
>
> Take the opportunity to rename this devm_fwnode_get_gpiod_from_child()
> as well.
Sure, I'll provide a separate patch renaming this function.
Thanks,
Boris
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-01-30 10:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-27 16:34 [PATCH 0/5] mtd: nand: Rework/cleanup the Atmel NAND driver Boris Brezillon
2017-01-27 16:34 ` [PATCH 1/5] gpio: Add the devm_get_index_gpiod_from_child() helper Boris Brezillon
2017-01-30 9:49 ` Linus Walleij
2017-01-30 10:19 ` Boris Brezillon
2017-01-27 16:34 ` [PATCH 2/5] dmaengine: Provide a wrapper for memcpy operations Boris Brezillon
2017-01-27 16:34 ` [PATCH 4/5] mtd: nand: atmel: Document the new DT bindings Boris Brezillon
2017-01-27 16:34 ` [PATCH 5/5] mtd: nand: Remove unused chip->write_page() hook Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).