All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] compat: backport vzalloc()
@ 2011-04-27 18:04 Hauke Mehrtens
  2011-04-27 18:08 ` Johannes Berg
  2011-04-27 18:08 ` [PATCH] compat: backport vzalloc() Luis R. Rodriguez
  0 siblings, 2 replies; 5+ messages in thread
From: Hauke Mehrtens @ 2011-04-27 18:04 UTC (permalink / raw)
  To: mcgrof, lrodriguez; +Cc: linux-wireless, Hauke Mehrtens

vzalloc() is used in rtl8192ce now.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 compat/compat-2.6.37.c        |   19 +++++++++++++++++++
 include/linux/compat-2.6.37.h |    2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c
index 8636c65..c49efea 100644
--- a/compat/compat-2.6.37.c
+++ b/compat/compat-2.6.37.c
@@ -334,4 +334,23 @@ void compat_led_classdev_unregister(struct led_classdev *led_cdev)
 }
 EXPORT_SYMBOL(compat_led_classdev_unregister);
 
+/**
+ *	vzalloc - allocate virtually contiguous memory with zero fill
+ *	@size:	allocation size
+ *	Allocate enough pages to cover @size from the page level
+ *	allocator and map them into contiguous kernel virtual space.
+ *	The memory allocated is set to zero.
+ *
+ *	For tight control over page level allocator and protection flags
+ *	use __vmalloc() instead.
+ */
+void *vzalloc(unsigned long size)
+{
+	void *buf;
+	buf = vmalloc(size);
+	memset(buf, 0, size);
+	return buf;
+}
+EXPORT_SYMBOL(vzalloc);
+
 #endif
diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h
index cee23a8..57868f5 100644
--- a/include/linux/compat-2.6.37.h
+++ b/include/linux/compat-2.6.37.h
@@ -110,6 +110,8 @@ extern void compat_led_brightness_set(struct led_classdev *led_cdev,
 
 #define netdev_refcnt_read(a) atomic_read(&a->refcnt)
 
+extern void *vzalloc(unsigned long size);
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */
 
 #endif /* LINUX_26_37_COMPAT_H */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] compat: backport vzalloc()
  2011-04-27 18:04 [PATCH] compat: backport vzalloc() Hauke Mehrtens
@ 2011-04-27 18:08 ` Johannes Berg
  2011-04-27 19:01   ` [PATCH] compat: handle fail of vmalloc() Hauke Mehrtens
  2011-04-27 18:08 ` [PATCH] compat: backport vzalloc() Luis R. Rodriguez
  1 sibling, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2011-04-27 18:08 UTC (permalink / raw)
  To: Hauke Mehrtens; +Cc: mcgrof, lrodriguez, linux-wireless

On Wed, 2011-04-27 at 20:04 +0200, Hauke Mehrtens wrote:

> +	void *buf;
> +	buf = vmalloc(size);
> +	memset(buf, 0, size);
> +	return buf;

vmalloc can fail, right?

johannes


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] compat: backport vzalloc()
  2011-04-27 18:04 [PATCH] compat: backport vzalloc() Hauke Mehrtens
  2011-04-27 18:08 ` Johannes Berg
@ 2011-04-27 18:08 ` Luis R. Rodriguez
  1 sibling, 0 replies; 5+ messages in thread
From: Luis R. Rodriguez @ 2011-04-27 18:08 UTC (permalink / raw)
  To: Hauke Mehrtens; +Cc: linux-wireless

On Wed, Apr 27, 2011 at 11:04 AM, Hauke Mehrtens <hauke@hauke-m.de> wrote:
> vzalloc() is used in rtl8192ce now.
>
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

Applied, and pushed, thanks.

 Luis

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] compat: handle fail of vmalloc()
  2011-04-27 18:08 ` Johannes Berg
@ 2011-04-27 19:01   ` Hauke Mehrtens
  2011-04-27 19:59     ` Luis R. Rodriguez
  0 siblings, 1 reply; 5+ messages in thread
From: Hauke Mehrtens @ 2011-04-27 19:01 UTC (permalink / raw)
  To: mcgrof, lrodriguez; +Cc: linux-wireless, Hauke Mehrtens

Only memset the memory if we get a valid pointer.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 compat/compat-2.6.37.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c
index c49efea..8698e1d 100644
--- a/compat/compat-2.6.37.c
+++ b/compat/compat-2.6.37.c
@@ -348,7 +348,8 @@ void *vzalloc(unsigned long size)
 {
 	void *buf;
 	buf = vmalloc(size);
-	memset(buf, 0, size);
+	if (buf)
+		memset(buf, 0, size);
 	return buf;
 }
 EXPORT_SYMBOL(vzalloc);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] compat: handle fail of vmalloc()
  2011-04-27 19:01   ` [PATCH] compat: handle fail of vmalloc() Hauke Mehrtens
@ 2011-04-27 19:59     ` Luis R. Rodriguez
  0 siblings, 0 replies; 5+ messages in thread
From: Luis R. Rodriguez @ 2011-04-27 19:59 UTC (permalink / raw)
  To: Hauke Mehrtens; +Cc: linux-wireless

On Wed, Apr 27, 2011 at 12:01 PM, Hauke Mehrtens <hauke@hauke-m.de> wrote:
> Only memset the memory if we get a valid pointer.
>
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---

Applied and pushed, thanks!

 Luis

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-27 20:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 18:04 [PATCH] compat: backport vzalloc() Hauke Mehrtens
2011-04-27 18:08 ` Johannes Berg
2011-04-27 19:01   ` [PATCH] compat: handle fail of vmalloc() Hauke Mehrtens
2011-04-27 19:59     ` Luis R. Rodriguez
2011-04-27 18:08 ` [PATCH] compat: backport vzalloc() Luis R. Rodriguez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.