public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Bernhard Frauendienst <kernel@nospam.obeliks.de>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/3] mtd: core: add get_mtd_device_by_node
Date: Thu, 6 Sep 2018 20:23:55 +0200	[thread overview]
Message-ID: <20180906202355.47b3fd3b@xps13> (raw)
In-Reply-To: <20180906161413.6335-2-kernel@nospam.obeliks.de>

Hi Bernhard,

Minor nits below.

Bernhard Frauendienst <kernel@nospam.obeliks.de> wrote on Thu,  6 Sep
2018 18:14:11 +0200:

> Add function to retrieve a mtd device by its OF node. Since drivers can
> assign arbitrary names to mtd devices in the absence of a label
> property, there is no other reliable way to retrieve a mtd device for a
> given OF node.
> 
> Signed-off-by: Bernhard Frauendienst <kernel@nospam.obeliks.de>
> ---
>  drivers/mtd/mtdcore.c   | 39 +++++++++++++++++++++++++++++++++++++++
>  include/linux/mtd/mtd.h |  2 ++
>  2 files changed, 41 insertions(+)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 97ac219c082e..e59b6a06814c 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -926,6 +926,45 @@ struct mtd_info *get_mtd_device_nm(const char *name)
>  }
>  EXPORT_SYMBOL_GPL(get_mtd_device_nm);
>  
> +/**
> + *	get_mtd_device_by_node - obtain a validated handle for an MTD device
> + *	by of_node
> + *	@name: OF node of MTD device to open

Should be @of_node

> + *
> + *	This function returns MTD device description structure in case of
> + *	success and an error code in case of failure.
> + */
> +struct mtd_info *get_mtd_device_by_node(const struct device_node *of_node)
> +{
> +	int err = -ENODEV;
> +	struct mtd_info *mtd = NULL, *other;
> +
> +	mutex_lock(&mtd_table_mutex);
> +
> +	mtd_for_each_device(other) {
> +		if (of_node == other->dev.of_node) {
> +			mtd = other;
> +			break;
> +		}
> +	}
> +
> +	if (!mtd)
> +		goto out_unlock;
> +
> +	err = __get_mtd_device(mtd);
> +	if (err)
> +		goto out_unlock;
> +
> +	mutex_unlock(&mtd_table_mutex);
> +	return mtd;
> +
> +out_unlock:
> +	mutex_unlock(&mtd_table_mutex);
> +	return ERR_PTR(err);
> +}
> +EXPORT_SYMBOL_GPL(get_mtd_device_by_node);
> +
> +

Extra space here

>  void put_mtd_device(struct mtd_info *mtd)
>  {
>  	mutex_lock(&mtd_table_mutex);
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index cd0be91bdefa..fe71358f8eaa 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -570,6 +570,8 @@ extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
>  extern int __get_mtd_device(struct mtd_info *mtd);
>  extern void __put_mtd_device(struct mtd_info *mtd);
>  extern struct mtd_info *get_mtd_device_nm(const char *name);
> +extern struct mtd_info *get_mtd_device_by_node(
> +		const struct device_node *of_node);
>  extern void put_mtd_device(struct mtd_info *mtd);
>  
>  

Otherwise,

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

  reply	other threads:[~2018-09-06 18:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 16:14 [PATCH 0/3] Virtual MTD concat device driver Bernhard Frauendienst
2018-09-06 16:14 ` [PATCH 1/3] mtd: core: add get_mtd_device_by_node Bernhard Frauendienst
2018-09-06 18:23   ` Miquel Raynal [this message]
2018-09-06 16:14 ` [PATCH 2/3] dt-bindings: add bindings for mtd-concat devices Bernhard Frauendienst
2018-09-06 16:14 ` [PATCH 3/3] mtd: mtdconcat: add dt driver for concat devices Bernhard Frauendienst
2018-09-06 18:47   ` Miquel Raynal
2018-09-06 22:54     ` Bernhard Frauendienst
2018-09-07 13:13       ` Miquel Raynal
2018-09-06 20:59 ` [PATCH 0/3] Virtual MTD concat device driver Boris Brezillon
2018-09-06 21:03   ` Boris Brezillon
2018-09-06 21:19     ` Bernhard Frauendienst
     [not found]     ` <d8c4e901-ae96-965c-0d01-4fa012da41b8@nospam.obeliks.de>
2018-09-06 21:23       ` Boris Brezillon
2018-09-06 21:35         ` Bernhard Frauendienst
2018-09-06 21:11 ` Boris Brezillon
2018-09-06 21:32   ` Bernhard Frauendienst

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=20180906202355.47b3fd3b@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=kernel@nospam.obeliks.de \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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