public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 01/11] linux_compat: add kmemdup()
Date: Thu, 17 Oct 2019 12:04:04 +0900	[thread overview]
Message-ID: <20191017030403.GP18778@linaro.org> (raw)
In-Reply-To: <1aa9259c-5d21-9851-5656-47a56fd5bf18@gmx.de>

On Sat, Oct 12, 2019 at 01:22:15PM +0200, Heinrich Schuchardt wrote:
> On 10/11/19 9:41 AM, AKASHI Takahiro wrote:
> >Adding kmemdup() will help improve portability from linux kernel
> >code (in my case, lib/crypto/x509_cert_parser.c and pkcs7_parser.c).
> >
> >Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> >---
> >  include/linux/compat.h |  4 ++--
> >  lib/linux_compat.c     | 11 +++++++++++
> >  2 files changed, 13 insertions(+), 2 deletions(-)
> >
> >diff --git a/include/linux/compat.h b/include/linux/compat.h
> >index d0f51baab407..d23ef50454ce 100644
> >--- a/include/linux/compat.h
> >+++ b/include/linux/compat.h
> >@@ -117,6 +117,8 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep)
> >  	free(cachep);
> >  }
> >
> >+void *kmemdup(const void *src, size_t size, int flags);
> 
> kememdup() is already implemented in fs/ubifs/ubifs.c and used both in
> drivers/mtd/ and in fs/ubifs/.

Good catch, I haven't noticed that.
ubifs.c is a very bad place for that function.
# drivers/mtd/mtd*.c doesn't use it as relevant code is guarded by
  "#ifndef __UBOOT__" though.

> Why would you want to use a different signature than both the Linux
> kernel and current U-Boot?
> 
> >+
> >  #define DECLARE_WAITQUEUE(...)	do { } while (0)
> >  #define add_wait_queue(...)	do { } while (0)
> >  #define remove_wait_queue(...)	do { } while (0)
> >@@ -346,8 +348,6 @@ struct writeback_control {
> >  	unsigned for_sync:1;		/* sync(2) WB_SYNC_ALL writeback */
> >  };
> >
> >-void *kmemdup(const void *src, size_t len, gfp_t gfp);
> >-
> >  typedef int irqreturn_t;
> >
> >  struct timer_list {};
> >diff --git a/lib/linux_compat.c b/lib/linux_compat.c
> >index 6373b4451eb3..dd1e5b3c2087 100644
> >--- a/lib/linux_compat.c
> >+++ b/lib/linux_compat.c
> >@@ -40,3 +40,14 @@ void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
> >  {
> >  	return malloc_cache_aligned(obj->sz);
> >  }
> >+
> >+void *kmemdup(const void *src, size_t size, int flags)
> >+{
> 
> You should not duplicate the implementation in the UBI filesystem.
> Instead move the existing implementation to a place that can be linked
> in your future work.

Okay, I'll remove it from ubifs.c.

Thanks,
-Takahiro Akashi

> Best regards
> 
> Heinrich
> 
> >+	void *p;
> >+
> >+	p = kmalloc(size, flags);
> >+	if (p)
> >+		memcpy(p, src, size);
> >+
> >+	return p;
> >+}
> >
> 

  reply	other threads:[~2019-10-17  3:04 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11  7:41 [U-Boot] [PATCH v1 00/11] import x509/pkcs7 parsers from linux AKASHI Takahiro
2019-10-11  7:41 ` [U-Boot] [PATCH v1 01/11] linux_compat: add kmemdup() AKASHI Takahiro
2019-10-12 11:22   ` Heinrich Schuchardt
2019-10-17  3:04     ` AKASHI Takahiro [this message]
2019-10-11  7:41 ` [U-Boot] [PATCH v1 02/11] include: time.h: define time64_t AKASHI Takahiro
2019-10-12 11:40   ` Heinrich Schuchardt
2019-10-17  5:39     ` AKASHI Takahiro
2019-10-17  5:51       ` Heinrich Schuchardt
2019-10-11  7:41 ` [U-Boot] [PATCH v1 03/11] include: kernel.h: include printk.h AKASHI Takahiro
2019-10-12 11:47   ` Heinrich Schuchardt
2019-10-17  5:58     ` AKASHI Takahiro
2019-10-17  6:17       ` AKASHI Takahiro
2019-10-11  7:41 ` [U-Boot] [PATCH v1 04/11] cmd: add asn1_compiler AKASHI Takahiro
2019-10-12 12:22   ` Heinrich Schuchardt
2019-10-17  6:25     ` AKASHI Takahiro
2019-10-11  7:41 ` [U-Boot] [PATCH v1 05/11] Makefile: add build script for asn1 parsers AKASHI Takahiro
2019-10-12 12:36   ` Heinrich Schuchardt
2019-10-17  6:40     ` AKASHI Takahiro
2019-10-11  7:41 ` [U-Boot] [PATCH v1 06/11] lib: add asn1 decoder AKASHI Takahiro
2019-10-12 12:29   ` Heinrich Schuchardt
2019-10-17  7:02     ` AKASHI Takahiro
2019-10-11  7:41 ` [U-Boot] [PATCH v1 07/11] lib: add oid registry utility AKASHI Takahiro
2019-10-12 12:58   ` Heinrich Schuchardt
2019-10-11  7:41 ` [U-Boot] [PATCH v1 08/11] lib: crypto: add public key utility AKASHI Takahiro
2019-10-11  7:41 ` [U-Boot] [PATCH v1 09/11] lib: crypto: add x509 parser AKASHI Takahiro
2019-10-11  7:41 ` [U-Boot] [PATCH v1 10/11] lib: crypto: add pkcs7 message parser AKASHI Takahiro
2019-10-11  7:42 ` [U-Boot] [PATCH v1 11/11] lib: crypto: add rsa public key parser AKASHI Takahiro
2019-10-12 13:11   ` Heinrich Schuchardt
2019-10-11  7:55 ` [U-Boot] [PATCH v1 00/11] import x509/pkcs7 parsers from linux AKASHI Takahiro
2019-10-12 13:02   ` Heinrich Schuchardt
2019-10-15  3:18     ` AKASHI Takahiro
2019-10-15  5:33       ` Heinrich Schuchardt
2019-10-15  8:56         ` AKASHI Takahiro
2019-10-15 11:10           ` Heinrich Schuchardt
2019-10-15  9:25         ` AKASHI Takahiro
2019-10-17 15:23           ` Tom Rini
2019-10-18  8:36             ` AKASHI Takahiro
2019-10-18 12:35               ` Tom Rini
2019-10-23  6:43                 ` AKASHI Takahiro

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=20191017030403.GP18778@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    /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