[PATCH 1/2] pstore: move slash handling into common function
Sascha Hauer
s.hauer at pengutronix.de
Wed May 8 05:43:16 PDT 2024
On Wed, May 08, 2024 at 01:18:35PM +0200, Ahmad Fatoum wrote:
> Both open and stat receive a file path and manually skip over the slash
> before calling pstore_get_by_name. Follow-up commit adds one more user
> of pstore_get_by_name, so instead of duplicating the flash skip a third
> time, move it into pstore_get_by_name.
s/flash/slash while applying.
Sascha
>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
> fs/pstore/fs.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
> index 238a316e9157..f2ffc0ac6251 100644
> --- a/fs/pstore/fs.c
> +++ b/fs/pstore/fs.c
> @@ -130,6 +130,9 @@ static struct pstore_private *pstore_get_by_name(struct list_head *head,
> if (!name)
> return NULL;
>
> + if (name[0] == '/')
> + name++;
> +
> list_for_each_entry(d, head, list) {
> if (strcmp(d->name, name) == 0)
> return d;
> @@ -143,9 +146,6 @@ static int pstore_open(struct device *dev, FILE *file, const char *filename)
> struct list_head *head = dev->priv;
> struct pstore_private *d;
>
> - if (filename[0] == '/')
> - filename++;
> -
> d = pstore_get_by_name(head, filename);
> if (!d)
> return -ENOENT;
> @@ -221,9 +221,6 @@ static int pstore_stat(struct device *dev, const char *filename,
> {
> struct pstore_private *d;
>
> - if (filename[0] == '/')
> - filename++;
> -
> d = pstore_get_by_name(&allpstore, filename);
> if (!d)
> return -ENOENT;
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list