Skip to contentSkip to conversation

+ drivers-base-devresc-add-devm_kmalloc.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Oct 10, 2013 Driver core

lore
Share & tools
lore
#0 lore raw

Subject: + drivers-base-devresc-add-devm_kmalloc.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Thu, 10 Oct 2013 16:07:56 -0700

The patch titled
Subject: drivers/base/devres.c: add devm_kmalloc()
has been added to the -mm tree. Its filename is
drivers-base-devresc-add-devm_kmalloc.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/drivers-base-devresc-add-devm_kmalloc.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/drivers-base-devresc-add-devm_kmalloc.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: drivers/base/devres.c: add devm_kmalloc()

The interface provides only devm_kzalloc(), but devm_kmalloc() is easy.

Cc Joe Perches <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Greg KH <[email protected]>

---

 drivers/base/devres.c  |   16 ++++++++++++++--
 include/linux/device.h |    3 ++-
 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/base/devres.c renamed from drivers/base/devres.c~drivers-base-devresc-add-devm_kmalloc +14 -2
diff -puN drivers/base/devres.c~drivers-base-devresc-add-devm_kmalloc drivers/base/devres.c
@@ -91,7 +91,8 @@ static __always_inline struct devres * a
 	if (unlikely(!dr))
 		return NULL;
 
-	memset(dr, 0, tot_size);
+	if (gfp & __GFP_ZERO)
+		memset(dr, 0, tot_size);
 	INIT_LIST_HEAD(&dr->node.entry);
 	dr->node.release = release;
 	return dr;
@@ -770,7 +771,7 @@ static int devm_kzalloc_match(struct dev
  * RETURNS:
  * Pointer to allocated memory on success, NULL on failure.
  */
-void * devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
+static void *__devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
 {
 	struct devres *dr;
 
@@ -783,8 +784,19 @@ void * devm_kzalloc(struct device *dev,
 	devres_add(dev, dr->data);
 	return dr->data;
 }
+
+void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
+{
+	return __devm_kzalloc(dev, size, gfp | __GFP_ZERO);
+}
 EXPORT_SYMBOL_GPL(devm_kzalloc);
 
+void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
+{
+	return __devm_kzalloc(dev, size, gfp);
+}
+EXPORT_SYMBOL_GPL(devm_kmalloc);
+
 /**
  * devm_kfree - Resource-managed kfree
  * @dev: Device this memory belongs to
include/linux/device.h renamed from include/linux/device.h~drivers-base-devresc-add-devm_kmalloc +2 -1
diff -puN include/linux/device.h~drivers-base-devresc-add-devm_kmalloc include/linux/device.h
@@ -602,8 +602,9 @@ extern void devres_close_group(struct de
 extern void devres_remove_group(struct device *dev, void *id);
 extern int devres_release_group(struct device *dev, void *id);
 
-/* managed kzalloc/kfree for device drivers, no kmalloc, always use kzalloc */
+/* managed kmalloc/kzalloc/kfree for device drivers */
 extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp);
+extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
 extern void devm_kfree(struct device *dev, void *p);
 
 void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);

_

Patches currently in -mm which might be from [email protected] are

arch-alpha-kernel-systblss-remove-debug-check.patch
i-need-old-gcc.patch
ipc-update-locking-scheme-comments-fix.patch mm-zswap-bugfix-memory-leak-when-invalidate-and-reclaim-occur-concurrently-checkpatch-fixes.patch mm-hugetlb-initialize-pg_reserved-for-tail-pages-of-gigantig-compound-pages-fix.patch drivers-base-devresc-add-devm_kmalloc.patch kernel-time-tick-commonc-document-tick_do_timer_cpu.patch makefile-enable-werror=implicit-int-and-werror=strict-prototypes-by-default.patch mm-readaheadc-do_readhead-dont-check-for-readpage.patch posix_acl-uninlining.patch
mm.patch
mm-thp-khugepaged-add-policy-for-finding-target-node-fix.patch mm-hugetlb-convert-hugetlbfs-to-use-split-pmd-lock-checkpatch-fixes.patch x86-mm-enable-split-page-table-lock-for-pmd-level-checkpatch-fixes.patch kernel-printk-printkc-convert-to-pr_foo.patch maintainers-remove-richard-purdie-as-backlight-maintainer-fix.patch checkpatch-extend-camelcase-types-and-ignore-existing-camelcase-uses-in-a-patch.patch checkpatch-add-test-for-defines-of-arch_has_foo.patch epoll-do-not-take-global-epmutex-for-simple-topologies-fix.patch binfmt_elfc-use-get_random_int-to-fix-entropy-depleting.patch init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs-fix.patch gcov-add-support-for-gcc-47-gcov-format-fix.patch gcov-add-support-for-gcc-47-gcov-format-fix-fix.patch gcov-add-support-for-gcc-47-gcov-format-checkpatch-fixes.patch kernel-modulec-use-pr_foo.patch
kernel-gcov-fsc-use-pr_warn.patch
linux-next.patch
linux-next-git-rejects.patch mm-drop-actor-argument-of-do_generic_file_read-fix.patch debugging-keep-track-of-page-owners-fix-2-fix.patch debugging-keep-track-of-page-owners-fix-2-fix-fix-fix.patch journal_add_journal_head-debug.patch kernel-forkc-export-kernel_thread-to-modules.patch mutex-subsystem-synchro-test-module.patch
slab-leaks3-default-y.patch
put_bh-debug.patch