From 0dd89119614ba7afb6fe901a1760fa2e706cce86 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Fri, 24 Mar 2017 22:10:49 +0800 Subject: drivers: base: dma-mapping: use nth_page helper Use nth_page() helper instead of page_to_pfn() and pfn_to_page() to simplify the code. Signed-off-by: Geliang Tang Signed-off-by: Greg Kroah-Hartman --- drivers/base/dma-mapping.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c index efd71cf4fdea..51b7061ff7c0 100644 --- a/drivers/base/dma-mapping.c +++ b/drivers/base/dma-mapping.c @@ -309,14 +309,13 @@ void *dma_common_contiguous_remap(struct page *page, size_t size, int i; struct page **pages; void *ptr; - unsigned long pfn; pages = kmalloc(sizeof(struct page *) << get_order(size), GFP_KERNEL); if (!pages) return NULL; - for (i = 0, pfn = page_to_pfn(page); i < (size >> PAGE_SHIFT); i++) - pages[i] = pfn_to_page(pfn + i); + for (i = 0; i < (size >> PAGE_SHIFT); i++) + pages[i] = nth_page(page, i); ptr = dma_common_pages_remap(pages, size, vm_flags, prot, caller); -- cgit v1.2.3 From 35dbf4efb044fbe4096a5edbb449e894aca9ef50 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Fri, 17 Mar 2017 12:24:22 +0530 Subject: driver core: don't initialize 'parent' in device_add() 'parent' is always overwritten before getting used and there is no need to initialize it with NULL. Signed-off-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/base') diff --git a/drivers/base/core.c b/drivers/base/core.c index 6bb60fb6a30b..bbecaf9293be 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1607,7 +1607,7 @@ int device_private_init(struct device *dev) */ int device_add(struct device *dev) { - struct device *parent = NULL; + struct device *parent; struct kobject *kobj; struct class_interface *class_intf; int error = -EINVAL; -- cgit v1.2.3