2017-03-23 13:12:51

by Geliang Tang

[permalink] [raw]
Subject: [PATCH] staging: media: atomisp: fix build error

Fix the following build error:

CC drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.o
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c:52:2:
error: excess elements in array initializer [-Werror]
"i", /* ion */
^~~
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c:52:2:
note: (near initialization for ‘hmm_bo_type_strings’)
cc1: all warnings being treated as errors
scripts/Makefile.build:294: recipe for target
'drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.o' failed

Signed-off-by: Geliang Tang <[email protected]>
---
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
index a362b49..e78f02f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
@@ -49,7 +49,9 @@ const char *hmm_bo_type_strings[HMM_BO_LAST] = {
"p", /* private */
"s", /* shared */
"u", /* user */
+#ifdef CONFIG_ION
"i", /* ion */
+#endif
};

static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
--
2.9.3


2017-03-23 13:12:59

by Geliang Tang

[permalink] [raw]
Subject: [PATCH] staging: media: atomisp: use kvmalloc and kvfree

Use kvmalloc() and kvfree() instead of open-coding.

Signed-off-by: Geliang Tang <[email protected]>
---
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..c7b9320 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -90,10 +90,7 @@ union host {
void *atomisp_kernel_malloc(size_t bytes)
{
/* vmalloc() is preferable if allocating more than 1 page */
- if (bytes > PAGE_SIZE)
- return vmalloc(bytes);
-
- return kmalloc(bytes, GFP_KERNEL);
+ return kvmalloc(bytes, GFP_KERNEL);
}

/*
@@ -118,10 +115,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
void atomisp_kernel_free(void *ptr)
{
/* Verify if buffer was allocated by vmalloc() or kmalloc() */
- if (is_vmalloc_addr(ptr))
- vfree(ptr);
- else
- kfree(ptr);
+ kvfree(ptr);
}

/*
--
2.9.3

2017-03-23 13:37:50

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] staging: media: atomisp: use kvmalloc and kvfree

On Thu, Mar 23, 2017 at 09:12:39PM +0800, Geliang Tang wrote:
> Use kvmalloc() and kvfree() instead of open-coding.

These functions are not in Linus's tree, so I can't apply this patch
without breaking things :(

thanks,

greg k-h

2017-03-23 16:00:12

by Alan

[permalink] [raw]
Subject: Re: [PATCH] staging: media: atomisp: fix build error

On Thu, 2017-03-23 at 21:12 +0800, Geliang Tang wrote:
> Fix the following build error:
>
>   CC      drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.o
> drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c:52:2:
>  error: excess elements in array initializer [-Werror]
>   "i", /* ion */
>   ^~~

NAK

I've sent a patch to sort this out properly we shouldn't be using
string arrays for single char values to start with...

Alan